diff options
author | John Stebbins <[email protected]> | 2016-05-17 13:28:23 -0600 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-05-17 13:28:23 -0600 |
commit | 9d52fbd1cefebb9bea49246c8d04081a20a1fc4d (patch) | |
tree | c3d73f481993b2ac537940e018d6d7f1644516b7 | |
parent | c6342c8124cf958f9d63a50e51ac776c8d02967e (diff) |
move cadence (Film->Video) logging to sync.c
-rw-r--r-- | libhb/decavcodec.c | 91 | ||||
-rw-r--r-- | libhb/sync.c | 95 |
2 files changed, 95 insertions, 91 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 91552ba8f..83bbcf517 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -944,95 +944,6 @@ static void flushDelayQueue( hb_work_private_t *pv ) } } -#define TOP_FIRST PIC_FLAG_TOP_FIELD_FIRST -#define PROGRESSIVE PIC_FLAG_PROGRESSIVE_FRAME -#define REPEAT_FIRST PIC_FLAG_REPEAT_FIRST_FIELD -#define TB 8 -#define BT 16 -#define BT_PROG 32 -#define BTB_PROG 64 -#define TB_PROG 128 -#define TBT_PROG 256 - -static void checkCadence( int * cadence, uint16_t flags, int64_t start ) -{ - /* Rotate the cadence tracking. */ - int i = 0; - for (i = 11; i > 0; i--) - { - cadence[i] = cadence[i-1]; - } - - if (!(flags & PROGRESSIVE) && !(flags & TOP_FIRST)) - { - /* Not progressive, not top first... - That means it's probably bottom - first, 2 fields displayed. - */ - //hb_log("MPEG2 Flag: Bottom field first, 2 fields displayed."); - cadence[0] = BT; - } - else if (!(flags & PROGRESSIVE) && (flags & TOP_FIRST)) - { - /* Not progressive, top is first, - Two fields displayed. - */ - //hb_log("MPEG2 Flag: Top field first, 2 fields displayed."); - cadence[0] = TB; - } - else if ((flags & PROGRESSIVE) && - !(flags & TOP_FIRST) && !(flags & REPEAT_FIRST)) - { - /* Progressive, but noting else. - That means Bottom first, - 2 fields displayed. - */ - //hb_log("MPEG2 Flag: Progressive. Bottom field first, 2 fields displayed."); - cadence[0] = BT_PROG; - } - else if ((flags & PROGRESSIVE) && - !(flags & TOP_FIRST) && (flags & REPEAT_FIRST)) - { - /* Progressive, and repeat. . - That means Bottom first, - 3 fields displayed. - */ - //hb_log("MPEG2 Flag: Progressive repeat. Bottom field first, 3 fields displayed."); - cadence[0] = BTB_PROG; - } - else if ((flags & PROGRESSIVE) && - (flags & TOP_FIRST) && !(flags & REPEAT_FIRST)) - { - /* Progressive, top first. - That means top first, - 2 fields displayed. - */ - //hb_log("MPEG2 Flag: Progressive. Top field first, 2 fields displayed."); - cadence[0] = TB_PROG; - } - else if ((flags & PROGRESSIVE) && - (flags & TOP_FIRST) && (flags & REPEAT_FIRST)) - { - /* Progressive, top, repeat. - That means top first, - 3 fields displayed. - */ - //hb_log("MPEG2 Flag: Progressive repeat. Top field first, 3 fields displayed."); - cadence[0] = TBT_PROG; - } - - if ((cadence[2] <= TB) && (cadence[1] <= TB) && - (cadence[0] > TB) && (cadence[11])) - { - hb_log("%fs: Video -> Film", (float)start / 90000); - } - if ((cadence[2] > TB) && (cadence[1] <= TB) && - (cadence[0] <= TB) && (cadence[11])) - { - hb_log("%fs: Film -> Video", (float)start / 90000); - } -} - // send cc_buf to the CC decoder(s) static void cc_send_to_decoder(hb_work_private_t *pv, hb_buffer_t *buf) { @@ -1343,7 +1254,6 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int64_t pt pv->new_chap = 0; pv->chap_time = 0; } - checkCadence( pv->cadence, flags, buf->s.start ); hb_buffer_list_append(&pv->list, buf); ++pv->nframes; return got_picture; @@ -1383,7 +1293,6 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int64_t pt pv->new_chap = 0; pv->chap_time = 0; } - checkCadence( pv->cadence, buf->s.flags, buf->s.start ); hb_buffer_list_append(&pv->list, buf); } diff --git a/libhb/sync.c b/libhb/sync.c index c1c8b7906..8375edc61 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -85,6 +85,7 @@ typedef struct struct { double dejitter_pts; + int cadence[12]; } video; // Audio stream context @@ -773,6 +774,95 @@ static void streamFlush( sync_stream_t * stream ) hb_buffer_list_append(&stream->out_queue, hb_buffer_eof_init()); } +#define TOP_FIRST PIC_FLAG_TOP_FIELD_FIRST +#define PROGRESSIVE PIC_FLAG_PROGRESSIVE_FRAME +#define REPEAT_FIRST PIC_FLAG_REPEAT_FIRST_FIELD +#define TB 8 +#define BT 16 +#define BT_PROG 32 +#define BTB_PROG 64 +#define TB_PROG 128 +#define TBT_PROG 256 + +static void checkCadence( int * cadence, hb_buffer_t * buf ) +{ + /* Rotate the cadence tracking. */ + int i = 0; + for (i = 11; i > 0; i--) + { + cadence[i] = cadence[i-1]; + } + + if (!(buf->s.flags & PROGRESSIVE) && !(buf->s.flags & TOP_FIRST)) + { + /* Not progressive, not top first... + That means it's probably bottom + first, 2 fields displayed. + */ + //hb_log("MPEG2 Flag: Bottom field first, 2 fields displayed."); + cadence[0] = BT; + } + else if (!(buf->s.flags & PROGRESSIVE) && (buf->s.flags & TOP_FIRST)) + { + /* Not progressive, top is first, + Two fields displayed. + */ + //hb_log("MPEG2 Flag: Top field first, 2 fields displayed."); + cadence[0] = TB; + } + else if ((buf->s.flags & PROGRESSIVE) && + !(buf->s.flags & TOP_FIRST) && !(buf->s.flags & REPEAT_FIRST)) + { + /* Progressive, but noting else. + That means Bottom first, + 2 fields displayed. + */ + //hb_log("MPEG2 Flag: Progressive. Bottom field first, 2 fields displayed."); + cadence[0] = BT_PROG; + } + else if ((buf->s.flags & PROGRESSIVE) && + !(buf->s.flags & TOP_FIRST) && (buf->s.flags & REPEAT_FIRST)) + { + /* Progressive, and repeat. . + That means Bottom first, + 3 fields displayed. + */ + //hb_log("MPEG2 Flag: Progressive repeat. Bottom field first, 3 fields displayed."); + cadence[0] = BTB_PROG; + } + else if ((buf->s.flags & PROGRESSIVE) && + (buf->s.flags & TOP_FIRST) && !(buf->s.flags & REPEAT_FIRST)) + { + /* Progressive, top first. + That means top first, + 2 fields displayed. + */ + //hb_log("MPEG2 Flag: Progressive. Top field first, 2 fields displayed."); + cadence[0] = TB_PROG; + } + else if ((buf->s.flags & PROGRESSIVE) && + (buf->s.flags & TOP_FIRST) && (buf->s.flags & REPEAT_FIRST)) + { + /* Progressive, top, repeat. + That means top first, + 3 fields displayed. + */ + //hb_log("MPEG2 Flag: Progressive repeat. Top field first, 3 fields displayed."); + cadence[0] = TBT_PROG; + } + + if ((cadence[2] <= TB) && (cadence[1] <= TB) && + (cadence[0] > TB) && (cadence[11])) + { + hb_log("%fs: Video -> Film", (float)buf->s.start / 90000); + } + if ((cadence[2] > TB) && (cadence[1] <= TB) && + (cadence[0] <= TB) && (cadence[11])) + { + hb_log("%fs: Film -> Video", (float)buf->s.start / 90000); + } +} + // OutputBuffer pulls buffers from the internal sync buffer queues in // lowest PTS first order. It then processes the queue the buffer is // pulled from for frame overlaps and gaps. @@ -921,6 +1011,11 @@ static void OutputBuffer( sync_common_t * common ) return; } + if (out_stream->type == SYNC_TYPE_VIDEO) + { + checkCadence(out_stream->video.cadence, buf); + } + // Out the buffer goes... hb_list_rem(out_stream->in_queue, buf); signalBuffer(out_stream); |