summaryrefslogtreecommitdiffstats
path: root/libhb/decavcodec.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-10-02 21:05:08 +0000
committerjstebbins <[email protected]>2014-10-02 21:05:08 +0000
commit7265c862c042e81f0b86e7df8b58ee69d9cb9e83 (patch)
tree9289bb66d25218890c73331c55f91dedb57688a0 /libhb/decavcodec.c
parent9254fa47939e055f39f1cd5f8db52268d498558d (diff)
libhb: improve preview generateion when there are no IDRs
Puts the decoder into a mode that returns *all* frames. I.e. it won't just scan to the end of the file looking for an IDR. Then we decode multiple frames (up to 100) searching for an I frame. This way, the reconstructed frame we use for a preview is more likely to be complete. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6430 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/decavcodec.c')
-rw-r--r--libhb/decavcodec.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index e235111d8..4eb9f6947 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -1149,6 +1149,20 @@ static hb_buffer_t * cc_fill_buffer(hb_work_private_t *pv, uint8_t *cc, int size
return buf;
}
+static int get_frame_type(int type)
+{
+ switch(type)
+ {
+ case AV_PICTURE_TYPE_I:
+ return HB_FRAME_I;
+ case AV_PICTURE_TYPE_B:
+ return HB_FRAME_B;
+ case AV_PICTURE_TYPE_P:
+ return HB_FRAME_P;
+ }
+ return 0;
+}
+
/*
* Decodes a video frame from the specified raw packet data
* ('data', 'size', 'sequence').
@@ -1315,6 +1329,7 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen
{
flags |= PIC_FLAG_REPEAT_FRAME;
}
+ int frametype = get_frame_type(pv->frame->pict_type);
// Check for CC data
AVFrameSideData *sd;
@@ -1385,6 +1400,7 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen
buf->sequence = sequence;
buf->s.flags = flags;
+ buf->s.frametype = frametype;
if ( pv->new_chap && buf->s.start >= pv->chap_time )
{
@@ -1451,6 +1467,7 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int sequen
buf->sequence = sequence;
/* Store picture flags for later use by filters */
buf->s.flags = flags;
+ buf->s.frametype = frametype;
pv->delayq[slot] = buf;
heap_push( &pv->pts_heap, pts );
@@ -1654,6 +1671,10 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
// Set encoder opts...
AVDictionary * av_opts = NULL;
av_dict_set( &av_opts, "refcounted_frames", "1", 0 );
+ if (pv->title->flags & HBTF_NO_IDR)
+ {
+ av_dict_set( &av_opts, "flags", "output_corrupt", 0 );
+ }
if ( hb_avcodec_open( pv->context, codec, &av_opts, pv->threads ) )
{
@@ -1818,6 +1839,10 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
AVDictionary * av_opts = NULL;
av_dict_set( &av_opts, "refcounted_frames", "1", 0 );
+ if (pv->title->flags & HBTF_NO_IDR)
+ {
+ av_dict_set( &av_opts, "flags", "output_corrupt", 0 );
+ }
// disable threaded decoding for scan, can cause crashes
if ( hb_avcodec_open( pv->context, codec, &av_opts, pv->threads ) )