Index: test/test.c =================================================================== --- test/test.c (revision 999) +++ test/test.c (working copy) @@ -739,7 +739,8 @@ #define p s.param.muxing case HB_STATE_MUXING: { - fprintf( stderr, "\rMuxing: %.2f %%", 100.0 * p.progress ); + //fprintf( stderr, "\rMuxing: %.2f %%", 100.0 * p.progress ); + fprintf( stderr, "\rMuxing -- This could take awhile." ); break; } #undef p Index: libhb/detelecine.c =================================================================== --- libhb/detelecine.c (revision 999) +++ libhb/detelecine.c (working copy) @@ -975,7 +975,7 @@ } else { - goto output_frame; + goto discard_frame; } } @@ -987,7 +987,7 @@ if (!frame) { - goto output_frame; + goto discard_frame; } if( frame->length < 2 ) { @@ -995,19 +995,19 @@ if( !(buf_in->flags & PIC_FLAG_REPEAT_FIRST_FIELD) ) { - goto output_frame; + goto discard_frame; } frame = pullup_get_frame( ctx ); if( !frame ) { - goto output_frame; + goto discard_frame; } if( frame->length < 2 ) { pullup_release_frame( frame ); - goto output_frame; + goto discard_frame; } } } @@ -1029,11 +1029,34 @@ memcpy( pv->pic_out.data[2], frame->buffer->planes[2], pv->width[2] * pv->height[2] * sizeof(uint8_t) ); +// hb_log("frame length: %i", frame->length); + if (frame->length != 2) + { + /* Frame length not being 2 means ivtc */ + pullup_release_frame ( frame ); + goto output_ivtc_frame; + } + + pullup_release_frame( frame ); output_frame: *buf_out = pv->buf_out; return FILTER_OK; + +/* This and all discard_frame calls shown above are + the result of me restoring the functionality in + pullup that huevos_rancheros disabled because + HB couldn't handle it. */ +discard_frame: + *buf_out = pv->buf_out; + return FILTER_DROP; + +output_ivtc_frame: + *buf_out = pv->buf_out; + return FILTER_OK_IVTC; + + } Index: libhb/muxmp4.c =================================================================== --- libhb/muxmp4.c (revision 999) +++ libhb/muxmp4.c (working copy) @@ -380,7 +380,7 @@ /* Because we use the audio samplerate as the timescale, we have to use potentially variable durations so the video doesn't go out of sync */ - duration = ( buf->stop * job->arate / 90000 ) - m->sum_dur; + duration = ( ( buf->stop * job->arate / 90000 ) - ( buf->start * job->arate / 90000 ) ); m->sum_dur += duration; } else Index: libhb/render.c =================================================================== --- libhb/render.c (revision 999) +++ libhb/render.c (working copy) @@ -9,6 +9,11 @@ #include "ffmpeg/avcodec.h" #include "ffmpeg/swscale.h" +/* Used for keeping track of when frames are dropped by detelecine. */ +int ivtc_cadence[12]; +int frame_length[12]; +hb_buffer_t * temp = NULL; + struct hb_work_private_s { hb_job_t * job; @@ -184,6 +189,15 @@ /* Setup render buffer */ hb_buffer_t * buf_render = hb_buffer_init( 3 * job->width * job->height / 2 ); + /* Rotate the cadence tracking. */ + int i = 0; + for(i=11; i > 0; i--) + { + ivtc_cadence[i] = ivtc_cadence[i-1]; + frame_length[i] = frame_length[i-1]; + + } + /* Apply filters */ if( job->filters ) { @@ -217,6 +231,8 @@ if( result == FILTER_OK ) { buf_tmp_in = buf_tmp_out; + ivtc_cadence[0] = 0; + frame_length[0] = 0; } else if( result == FILTER_DELAY ) { @@ -225,13 +241,80 @@ } else if( result == FILTER_DROP ) { + /* A drop means detelecine's latched its teeth onto + something and has duped frames to discard. */ + ivtc_cadence[0] = 1; + hb_fifo_get( pv->subtitle_queue ); buf_tmp_in = NULL; break; } + else if( result == FILTER_OK_IVTC ) + { + /* Frame length isnt' 2 */ + buf_tmp_in = buf_tmp_out; + ivtc_cadence[0] = 0; + frame_length[0] = 1; + } + + } + +// hb_log("temp data: %lld", temp->data); + +// hb_log("buffer data: %lld", in->data); + + + if ( (frame_length[0] == 1) || (frame_length[1] == 1) || (frame_length[2] == 1) || (frame_length[3] == 1) ) + { + if (job->vrate_base != 1126125) + { + in->stop = in->stop + 751; + } + } + else + { + if ( job->vrate_base == 1126125 ) + { + // in->stop = in->stop - 751; + } + } + +/* I need to adjust this section to compensate for the chosen bitrate. Only add 751 to the ivtc ones if the job->rate is 900900 (29.97), else remove 751 from the non-ivtc ones if the vrate is 1126125 (23.976) */ + +// if ( (ivtc_cadence[1] == 1) || (ivtc_cadence[2] == 1) || (ivtc_cadence[3] == 1) || (ivtc_cadence[4] == 1) /*|| (ivtc_cadence[5] == 1) || (ivtc_cadence[6] == 1) || (ivtc_cadence[7] == 1) || (ivtc_cadence[8] == 1) */ //) +// { + /* One of the last 5 frames was ditched by detelecine, or + flagged as progressive. That's telecined stuff, and the + frames need to be displayed with a a 23.976 duration, + so extend their durations from ~3003 to ~3754 ticks. */ + +// if (job->vrate_base != 1126125) +// { +// /* Only extend ivtc frames if they aren't already extended */ +// in->stop = in->stop + 751 ; +// } +// } +// else +// { +// if ( (job->vrate_base == 1126125) && !(in->flags & 16) ) +// { + /* Shorten frame durations for non-ivtc video stuff when using 23.976 */ +// in->stop = in->stop - 751; +// } +// } + +// else if ( in->flags & 16 ) +// { + /* One of the last 5 frames was ditched by detelecine, or + flagged as progressive. That's telecined stuff, and the + frames need to be displayed with a a 23.976 duration, + so extend their durations from ~3003 to ~3754 ticks. */ + //in->stop = in->stop + 751 ; +// } + } - + /* Apply subtitles */ if( buf_tmp_in ) { @@ -268,6 +351,11 @@ buf_tmp_in = buf_render; } + /* Pass VFR NTSC IVTC frame durations on through the workflow. + I totally wish I could slip some cryptic abbreviations into + the last sentence. */ + buf_render->stop = in->stop; + /* Set output to render buffer */ (*buf_out) = buf_render; Index: libhb/internal.h =================================================================== --- libhb/internal.h (revision 999) +++ libhb/internal.h (working copy) @@ -49,7 +49,7 @@ #define HB_FRAME_KEY 0x0F #define HB_FRAME_REF 0xF0 uint8_t frametype; - uint8_t flags; + uint32_t flags; /* Holds the output PTS from x264, for use by b-frame offsets in muxmp4.c */ int64_t renderOffset; Index: libhb/common.h =================================================================== --- libhb/common.h (revision 999) +++ libhb/common.h (working copy) @@ -528,6 +528,7 @@ #define FILTER_DELAY 1 #define FILTER_FAILED 2 #define FILTER_DROP 3 +#define FILTER_OK_IVTC 4 struct hb_filter_object_s { Index: Jamrules =================================================================== --- Jamrules (revision 999) +++ Jamrules (working copy) @@ -12,7 +12,7 @@ } HB_VERSION = 0.9.1 ; -HB_BUILD = 2007083100 ; +HB_BUILD = 2007100800 ; DEFINES += HB_VERSION=\\\"$(HB_VERSION)\\\" HB_BUILD=$(HB_BUILD) ; LANGUAGES = fr de it pl ru nl es pt ja ; RM = rm -rf ;