summaryrefslogtreecommitdiffstats
path: root/libhb/encavcodec.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2016-05-17 11:51:25 -0600
committerJohn Stebbins <[email protected]>2016-05-17 11:51:25 -0600
commitde858d1600ac61258dc895b2fc8756b7c5d1d3a8 (patch)
treecdbd82e3d9ee83cfb9a31ebbb034852aa36fb2cb /libhb/encavcodec.c
parent9dcce9df07f4db1fa61f25ffeb106aa00bd64190 (diff)
libhb: send initial chapter through pipeline
Eliminate the need for everyone to assume that the first chapter starts at the first frame.
Diffstat (limited to 'libhb/encavcodec.c')
-rw-r--r--libhb/encavcodec.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c
index 129921d0b..59c787326 100644
--- a/libhb/encavcodec.c
+++ b/libhb/encavcodec.c
@@ -26,20 +26,22 @@
struct hb_work_private_s
{
- hb_job_t * job;
- AVCodecContext * context;
- FILE * file;
+ hb_job_t * job;
+ AVCodecContext * context;
+ FILE * file;
- int frameno_in;
- int frameno_out;
- hb_buffer_list_t delay_list;
+ int frameno_in;
+ int frameno_out;
+ hb_buffer_list_t delay_list;
- int64_t dts_delay;
+ int64_t dts_delay;
struct {
- int64_t start;
- int64_t duration;
+ int64_t start;
+ int64_t duration;
} frame_info[FRAME_INFO_SIZE];
+
+ hb_chapter_queue_t * chapter_queue;
};
int encavcodecInit( hb_work_object_t *, hb_job_t * );
@@ -62,8 +64,9 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
AVRational fps;
hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) );
- w->private_data = pv;
- pv->job = job;
+ w->private_data = pv;
+ pv->job = job;
+ pv->chapter_queue = hb_chapter_queue_init();
hb_buffer_list_clear(&pv->delay_list);
@@ -319,6 +322,11 @@ void encavcodecClose( hb_work_object_t * w )
{
hb_work_private_t * pv = w->private_data;
+ if (pv == NULL)
+ {
+ return;
+ }
+ hb_chapter_queue_close(&pv->chapter_queue);
if( pv->context && pv->context->codec )
{
hb_deep_log( 2, "encavcodec: closing libavcodec" );
@@ -513,6 +521,17 @@ int encavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
frame->linesize[1] = in->plane[1].stride;
frame->linesize[2] = in->plane[2].stride;
+ if (in->s.new_chap > 0 && job->chapter_markers)
+ {
+ /* chapters have to start with an IDR frame so request that this
+ frame be coded as IDR. Since there may be multiple frames
+ currently buffered in the encoder remember the timestamp so
+ when this frame finally pops out of the encoder we'll mark
+ its buffer as the start of a chapter. */
+ frame->pict_type = AV_PICTURE_TYPE_I;
+ hb_chapter_enqueue(pv->chapter_queue, in);
+ }
+
// For constant quality, setting the quality in AVCodecContext
// doesn't do the trick. It must be set in the AVFrame.
frame->quality = pv->context->global_quality;
@@ -558,6 +577,10 @@ int encavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
buf->s.stop = buf->s.stop + buf->s.duration;
buf->s.flags &= ~HB_FRAME_REF;
buf->s.frametype = convert_pict_type( pv->context->coded_frame->pict_type, pkt.flags & AV_PKT_FLAG_KEY, &buf->s.flags );
+ if (buf->s.frametype & HB_FRAME_KEY)
+ {
+ hb_chapter_dequeue(pv->chapter_queue, buf);
+ }
buf = process_delay_list( pv, buf );
hb_buffer_list_append(&list, buf);