diff options
author | John Stebbins <[email protected]> | 2017-04-12 15:09:26 -0600 |
---|---|---|
committer | John Stebbins <[email protected]> | 2017-04-12 15:09:26 -0600 |
commit | 969b60fff13091268e9aa5775e6822c1bca7e874 (patch) | |
tree | 80c74e31ada627fab3b7170bd134cd3871cd378c /libhb | |
parent | 9a22ae2b2715b088cd936ba5e7d700ee4fbea096 (diff) |
scan: fix very slow scanning for some files
The threshold in bytes for when to give up trying to decode a frame was
too big for a lot of streams. It was made large to accomodate 4K raw
video. Instead of counting bytes, count frames fed to the decoder.
This is more consistant regardless of video resolution and codec.
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.h | 1 | ||||
-rw-r--r-- | libhb/decavcodec.c | 1 | ||||
-rw-r--r-- | libhb/scan.c | 8 |
3 files changed, 6 insertions, 4 deletions
diff --git a/libhb/common.h b/libhb/common.h index e6ef1270d..a9bc3d412 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -1151,6 +1151,7 @@ struct hb_work_object_s volatile int * done; volatile int * die; int status; + int frame_count; int codec_param; hb_title_t * title; diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 7b94274e1..cf62002fe 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -1375,6 +1375,7 @@ static void decodeVideo( hb_work_object_t *w, hb_buffer_t * in) pv->packet_info.dts = parser_dts; decodeFrame(w, &pv->packet_info); + w->frame_count++; // There could have been an unfinished packet when we entered // decodeVideo that is now finished. The next packet is associated diff --git a/libhb/scan.c b/libhb/scan.c index 8b5c5d47a..86d1f324d 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -31,7 +31,7 @@ typedef struct uint64_t min_title_duration; } hb_scan_t; -#define PREVIEW_READ_THRESH (1024 * 1024 * 300) +#define PREVIEW_READ_THRESH (200) static void ScanFunc( void * ); static int DecodePreviews( hb_scan_t *, hb_title_t * title, int flush ); @@ -676,8 +676,9 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush ) hb_buffer_t * vid_buf = NULL; - int total_read = 0, packets = 0; - while (total_read < PREVIEW_READ_THRESH || + int packets = 0; + vid_decoder->frame_count = 0; + while (vid_decoder->frame_count < PREVIEW_READ_THRESH || (!AllAudioOK(title) && packets < 10000)) { if (data->bd) @@ -741,7 +742,6 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush ) abort = 1; goto skip_preview; } - total_read += buf->size; packets++; (hb_demux[title->demuxer])(buf, &list_es, 0 ); |