X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;ds=sidebyside;f=libhb%2Fdetelecine.c;h=20210382846cb607e4d0ce7b5131e2abbe77dc51;hb=033e32de9c380f54c7d1362a3979da205ebc3a29;hp=a305cb4d20a6065ba63802e837646759b909b35c;hpb=4bc5b5e9a9eeb72edde3d9f6b5ba092d5f96b2f0;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/detelecine.c b/libhb/detelecine.c index a305cb4d..20210382 100644 --- a/libhb/detelecine.c +++ b/libhb/detelecine.c @@ -1,5 +1,5 @@ #include "hb.h" -#include "libavcodec/avcodec.h" +#include "hbffmpeg.h" #include "mpeg2dec/mpeg2.h" /* @@ -60,6 +60,7 @@ struct pullup_context int metric_plane; int strict_breaks; int strict_pairs; + int parity; /* Internal data */ struct pullup_field *first, *last, *head; struct pullup_buffer *buffers; @@ -567,15 +568,17 @@ void pullup_free_context( struct pullup_context * c ) free( c->buffers ); - f = c->head; - do + f = c->head->next; + while( f != c->head ) { free( f->diffs ); free( f->comb ); f = f->next; free( f->prev ); } - while( f != c->head ); + free( f->diffs ); + free( f->comb ); + free(f); free( c->frame ); free( c ); @@ -827,8 +830,7 @@ hb_filter_private_t * hb_detelecine_init( int pix_fmt, pv->width[1] = pv->width[2] = width >> 1; pv->height[1] = pv->height[2] = height >> 1; - int buf_size = 3 * width * height / 2; - pv->buf_out = hb_buffer_init( buf_size ); + pv->buf_out = hb_video_buffer_init( width, height ); struct pullup_context * ctx; pv->pullup_ctx = ctx = pullup_alloc_context(); @@ -837,16 +839,18 @@ hb_filter_private_t * hb_detelecine_init( int pix_fmt, ctx->junk_top = ctx->junk_bottom = 4; ctx->strict_breaks = -1; ctx->metric_plane = 0; - + ctx->parity = -1; + if( settings ) { - sscanf( settings, "%d:%d:%d:%d:%d:%d", + sscanf( settings, "%d:%d:%d:%d:%d:%d:%d", &ctx->junk_left, &ctx->junk_right, &ctx->junk_top, &ctx->junk_bottom, &ctx->strict_breaks, - &ctx->metric_plane ); + &ctx->metric_plane, + &ctx->parity ); } ctx->format = PULLUP_FMT_Y; @@ -946,12 +950,25 @@ int hb_detelecine_work( const hb_buffer_t * buf_in, memcpy( buf->planes[2], pv->pic_in.data[2], pv->width[2] * pv->height[2] * sizeof(uint8_t) ); - /* Submit buffer fields based on buffer flags */ + /* Submit buffer fields based on buffer flags. + Detelecine assumes BFF when the TFF flag isn't present. */ int parity = 1; if( buf_in->flags & PIC_FLAG_TOP_FIELD_FIRST ) { + /* Source signals TFF */ + parity = 0; + } + else if( ctx->parity == 0 ) + { + /* Many non-MPEG-2 sources lack parity flags even though + they are TFF, so this allow users to override. */ parity = 0; } + if( ctx->parity == 1 ) + { + /* Override autodetected parity with BFF */ + parity = 1; + } pullup_submit_field( ctx, buf, parity ); pullup_submit_field( ctx, buf, parity^1 ); if( buf_in->flags & PIC_FLAG_REPEAT_FIRST_FIELD )