vlc | branch: master | Francois Cartegnie <[email protected]> | Fri Apr 28 15:25:20 2017 +0200| [5898acea210186ab6d9241318f7b4d0f50beb83f] | committer: Francois Cartegnie
input: decoder: revert decoder_QueueVideoWithCc to decoder_QueueVideo Captions are sent in picture decode order. Attaching them to picture results in broken order. reverts 4079bb24e655a16e0c18c7647008c25bd4bb2e12 > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5898acea210186ab6d9241318f7b4d0f50beb83f --- include/vlc_codec.h | 22 +++++++--------- modules/codec/libmpeg2.c | 68 ++++++++++++++++++++++++++++++++---------------- src/input/decoder.c | 43 ++++++++++++++++-------------- 3 files changed, 78 insertions(+), 55 deletions(-) diff --git a/include/vlc_codec.h b/include/vlc_codec.h index e8bd9e305b..442ec564ef 100644 --- a/include/vlc_codec.h +++ b/include/vlc_codec.h @@ -174,10 +174,11 @@ struct decoder_t int (*pf_get_display_rate)( decoder_t * ); /* XXX use decoder_QueueVideo or decoder_QueueVideoWithCc */ - int (*pf_queue_video)( decoder_t *, picture_t *, block_t *p_cc, - bool p_cc_present[4] ); + int (*pf_queue_video)( decoder_t *, picture_t * ); /* XXX use decoder_QueueAudio */ int (*pf_queue_audio)( decoder_t *, block_t * ); + /* XXX use decoder_QueueCC */ + int (*pf_queue_cc)( decoder_t *, block_t *, bool p_cc_present[4] ); /* XXX use decoder_QueueSub */ int (*pf_queue_sub)( decoder_t *, subpicture_t *); void *p_queue_ctx; @@ -300,22 +301,19 @@ static inline int decoder_QueueVideo( decoder_t *dec, picture_t *p_pic ) { assert( p_pic->p_next == NULL ); assert( dec->pf_queue_video != NULL ); - return dec->pf_queue_video( dec, p_pic, NULL, NULL ); + return dec->pf_queue_video( dec, p_pic ); } /** - * This function queues a single picture with CC to the video output + * This function queues queues the Closed Captions * - * This function also queues the Closed Captions associated with the picture. - * - * \return 0 if the picture is queued, -1 on error + * \return 0 if queued, -1 on error */ -static inline int decoder_QueueVideoWithCc( decoder_t *dec, picture_t *p_pic, - block_t *p_cc, bool p_cc_present[4] ) +static inline int decoder_QueueCc( decoder_t *dec, block_t *p_cc, + bool p_cc_present[4] ) { - assert( p_pic->p_next == NULL ); - assert( dec->pf_queue_video != NULL ); - return dec->pf_queue_video( dec, p_pic, p_cc, p_cc_present ); + assert( dec->pf_queue_cc != NULL ); + return dec->pf_queue_cc( dec, p_cc, p_cc_present ); } /** diff --git a/modules/codec/libmpeg2.c b/modules/codec/libmpeg2.c index f394f1b907..8c6da24f41 100644 --- a/modules/codec/libmpeg2.c +++ b/modules/codec/libmpeg2.c @@ -99,7 +99,9 @@ struct decoder_sys_t uint32_t i_cc_flags; mtime_t i_cc_pts; mtime_t i_cc_dts; +#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0) cc_data_t cc; +#endif uint8_t *p_gop_user_data; uint32_t i_gop_user_data; }; @@ -112,6 +114,7 @@ static void CloseDecoder( vlc_object_t * ); static int DecodeVideo( decoder_t *, block_t *); #if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0) +static void SendCc( decoder_t *p_dec ); #endif static picture_t *GetNewPicture( decoder_t * ); @@ -432,21 +435,29 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B ) p_sys->i_cc_flags = BLOCK_FLAG_TYPE_B; else p_sys->i_cc_flags = BLOCK_FLAG_TYPE_I; +#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0) bool b_top_field_first = p_sys->p_info->current_picture->flags & PIC_FLAG_TOP_FIELD_FIRST; - +#endif if( p_sys->i_gop_user_data > 2 ) { /* We now have picture info for any cached user_data out of the gop */ +#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0) cc_ProbeAndExtract( &p_sys->cc, b_top_field_first, &p_sys->p_gop_user_data[0], p_sys->i_gop_user_data ); +#endif p_sys->i_gop_user_data = 0; } /* Extract the CC from the user_data of the picture */ +#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0) if( p_info->user_data_len > 2 ) cc_ProbeAndExtract( &p_sys->cc, b_top_field_first, &p_info->user_data[0], p_info->user_data_len ); + + if( p_sys->cc.i_data ) + SendCc( p_dec ); +#endif } } break; @@ -594,34 +605,13 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) static int DecodeVideo( decoder_t *p_dec, block_t *p_block) { - decoder_sys_t *p_sys = p_dec->p_sys; - if( p_block == NULL ) /* No Drain */ return VLCDEC_SUCCESS; block_t **pp_block = &p_block; picture_t *p_pic; while( ( p_pic = DecodeBlock( p_dec, pp_block ) ) != NULL ) - { - block_t *p_cc = NULL; - bool *pb_present = NULL; -#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0) - pb_present = p_sys->cc.pb_present; - if( p_sys->cc.i_data > 0 ) - { - p_cc = block_Alloc( p_sys->cc.i_data); - if( p_cc ) - { - memcpy( p_cc->p_buffer, p_sys->cc.p_data, p_sys->cc.i_data ); - p_cc->i_dts = - p_cc->i_pts = p_sys->cc.b_reorder ? p_sys->i_cc_pts : p_sys->i_cc_dts; - p_cc->i_flags = ( p_sys->cc.b_reorder ? p_sys->i_cc_flags : BLOCK_FLAG_TYPE_P ) & ( BLOCK_FLAG_TYPE_I|BLOCK_FLAG_TYPE_P|BLOCK_FLAG_TYPE_B); - } - cc_Flush( &p_sys->cc ); - } -#endif - decoder_QueueVideoWithCc( p_dec, p_pic, p_cc, pb_present ); - } + decoder_QueueVideo( p_dec, p_pic ); return VLCDEC_SUCCESS; } @@ -633,6 +623,10 @@ static void CloseDecoder( vlc_object_t *p_this ) decoder_t *p_dec = (decoder_t *)p_this; decoder_sys_t *p_sys = p_dec->p_sys; +#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0) + cc_Flush( &p_sys->cc ); +#endif + DpbClean( p_dec ); free( p_sys->p_gop_user_data ); @@ -651,7 +645,9 @@ static void Reset( decoder_t *p_dec ) { decoder_sys_t *p_sys = p_dec->p_sys; +#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0) cc_Flush( &p_sys->cc ); +#endif mpeg2_reset( p_sys->p_mpeg2dec, 0 ); DpbClean( p_dec ); } @@ -704,6 +700,32 @@ static picture_t *GetNewPicture( decoder_t *p_dec ) return p_pic; } +#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0) +/***************************************************************************** + * SendCc: Sends the Closed Captions for the CC decoder. + *****************************************************************************/ +static void SendCc( decoder_t *p_dec ) +{ + decoder_sys_t *p_sys = p_dec->p_sys; + block_t *p_cc = NULL; + + if( p_sys->cc.i_data <= 0 ) + return; + + p_cc = block_Alloc( p_sys->cc.i_data); + if( p_cc ) + { + memcpy( p_cc->p_buffer, p_sys->cc.p_data, p_sys->cc.i_data ); + p_cc->i_dts = + p_cc->i_pts = p_sys->cc.b_reorder ? p_sys->i_cc_pts : p_sys->i_cc_dts; + p_cc->i_flags = ( p_sys->cc.b_reorder ? p_sys->i_cc_flags : BLOCK_FLAG_TYPE_P ) & ( BLOCK_FLAG_TYPE_I|BLOCK_FLAG_TYPE_P|BLOCK_FLAG_TYPE_B); + decoder_QueueCc( p_dec, p_cc, p_sys->cc.pb_present ); + } + cc_Flush( &p_sys->cc ); + return; +} +#endif + /***************************************************************************** * GetAR: Get aspect ratio *****************************************************************************/ diff --git a/src/input/decoder.c b/src/input/decoder.c index a32ec709d7..229871de49 100644 --- a/src/input/decoder.c +++ b/src/input/decoder.c @@ -872,8 +872,8 @@ static void DecoderProcessSout( decoder_t *p_dec, block_t *p_block ) } #endif -static void DecoderExtractCc( decoder_t *p_dec, block_t *p_cc, - bool pb_present[4] ) +static void DecoderPlayCc( decoder_t *p_dec, block_t *p_cc, + bool pb_present[4] ) { decoder_owner_sys_t *p_owner = p_dec->p_owner; bool b_processed = false; @@ -904,7 +904,7 @@ static void DecoderExtractCc( decoder_t *p_dec, block_t *p_cc, block_Release( p_cc ); } -static void DecoderGetCc( decoder_t *p_dec, decoder_t *p_dec_cc ) +static void PacketizerGetCc( decoder_t *p_dec, decoder_t *p_dec_cc ) { decoder_owner_sys_t *p_owner = p_dec->p_owner; block_t *p_cc; @@ -919,11 +919,25 @@ static void DecoderGetCc( decoder_t *p_dec, decoder_t *p_dec_cc ) p_cc = p_dec_cc->pf_get_cc( p_dec_cc, pb_present ); if( !p_cc ) return; - DecoderExtractCc( p_dec, p_cc, pb_present ); + DecoderPlayCc( p_dec, p_cc, pb_present ); +} + +static void DecoderQueueCc( decoder_t *p_videodec, block_t *p_cc, + bool p_cc_present[4] ) +{ + decoder_owner_sys_t *p_owner = p_videodec->p_owner; + + if( unlikely( p_cc != NULL ) ) + { + if( p_owner->cc.b_supported && + ( !p_owner->p_packetizer || !p_owner->p_packetizer->pf_get_cc ) ) + DecoderPlayCc( p_videodec, p_cc, p_cc_present ); + else + block_Release( p_cc ); + } } static int DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture, - block_t *p_cc, bool p_cc_present[4], unsigned *restrict pi_lost_sum ) { decoder_owner_sys_t *p_owner = p_dec->p_owner; @@ -935,8 +949,6 @@ static int DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture, { vlc_mutex_unlock( &p_owner->lock ); picture_Release( p_picture ); - if( unlikely( p_cc != NULL ) ) - block_Release( p_cc ); return -1; } @@ -952,15 +964,6 @@ static int DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture, vout_Flush( p_vout, VLC_TS_INVALID+1 ); } - if( unlikely( p_cc != NULL ) ) - { - if( p_owner->cc.b_supported && - ( !p_owner->p_packetizer || !p_owner->p_packetizer->pf_get_cc ) ) - DecoderExtractCc( p_dec, p_cc, p_cc_present ); - else - block_Release( p_cc ); - } - if( p_picture->date <= VLC_TS_INVALID ) { msg_Warn( p_dec, "non-dated video buffer received" ); @@ -1058,14 +1061,13 @@ static void DecoderUpdateStatVideo( decoder_owner_sys_t *p_owner, vlc_mutex_unlock( &input_priv(p_input)->counters.counters_lock ); } -static int DecoderQueueVideo( decoder_t *p_dec, picture_t *p_pic, - block_t *p_cc, bool p_cc_present[4] ) +static int DecoderQueueVideo( decoder_t *p_dec, picture_t *p_pic ) { assert( p_pic ); unsigned i_lost = 0; decoder_owner_sys_t *p_owner = p_dec->p_owner; - int ret = DecoderPlayVideo( p_dec, p_pic, p_cc, p_cc_present, &i_lost ); + int ret = DecoderPlayVideo( p_dec, p_pic, &i_lost ); p_owner->pf_update_stat( p_owner, 1, i_lost ); return ret; @@ -1382,7 +1384,7 @@ static void DecoderProcess( decoder_t *p_dec, block_t *p_block ) } if( p_packetizer->pf_get_cc ) - DecoderGetCc( p_dec, p_packetizer ); + PacketizerGetCc( p_dec, p_packetizer ); while( p_packetized_block ) { @@ -1686,6 +1688,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent, { case VIDEO_ES: p_dec->pf_queue_video = DecoderQueueVideo; + p_dec->pf_queue_cc = DecoderQueueCc; p_owner->pf_update_stat = DecoderUpdateStatVideo; break; case AUDIO_ES: _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
