summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2015-02-15 21:22:06 +0000
committerjstebbins <[email protected]>2015-02-15 21:22:06 +0000
commit901d81b2b980c3afa7e14f434cc8ffd092cc750e (patch)
treefbce59314887fe3b1ae3bce2dca4717a521e8cc1 /libhb
parent56586d73ed29fe64187c9083a84da4146db65bcc (diff)
scan: work around libav mpeg2 dummy first frame
libav generates a dummy first frame after any seek for some mpeg2 streams. This results in black preview frames and invalid autocrop values. So always decode at least 2 frames before using the frame for preview. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6906 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/scan.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libhb/scan.c b/libhb/scan.c
index 74d960117..d116f6815 100644
--- a/libhb/scan.c
+++ b/libhb/scan.c
@@ -497,6 +497,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush )
int interlaced_preview_count = 0;
int frame_wait = 0;
int cc_wait = 10;
+ int frames;
hb_stream_t * stream = NULL;
info_list_t * info_list = calloc( data->preview_count+1, sizeof(*info_list) );
crop_record_t *crops = crop_record_init( data->preview_count );
@@ -611,6 +612,14 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush )
frame_wait = 10;
}
}
+ else
+ {
+ // For certain mpeg-2 streams, libav is delivering a
+ // dummy first frame that is all black. So always skip
+ // one frame
+ frame_wait = 1;
+ }
+ frames = 0;
hb_buffer_t * vid_buf = NULL;
@@ -693,7 +702,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush )
// additional frames to find the CCs.
if (vid_buf != NULL && (frame_wait || cc_wait))
{
- if (vid_buf->s.frametype == HB_FRAME_I)
+ if (frames > 0 && vid_buf->s.frametype == HB_FRAME_I)
frame_wait = 0;
if (frame_wait || cc_wait)
{
@@ -701,6 +710,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush )
if (frame_wait) frame_wait--;
if (cc_wait) cc_wait--;
}
+ frames++;
}
}
else if( ! AllAudioOK( title ) )