vlc | branch: master | Francois Cartegnie <[email protected]> | Thu Jun 8 18:40:49 2017 +0200| [558ca5ca19e008aa3834a920fb38edd19944256a] | committer: Francois Cartegnie
codec: avcodec: split sidedata processing unreadable > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=558ca5ca19e008aa3834a920fb38edd19944256a --- modules/codec/avcodec/video.c | 203 ++++++++++++++++++++++-------------------- 1 file changed, 105 insertions(+), 98 deletions(-) diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c index 55aae2d2da..e8b27fdf1e 100644 --- a/modules/codec/avcodec/video.c +++ b/modules/codec/avcodec/video.c @@ -747,6 +747,110 @@ static void update_late_frame_count( decoder_t *p_dec, block_t *p_block, mtime_t } +static void DecodeSidedata( decoder_t *p_dec, const AVFrame *frame, picture_t *p_pic ) +{ + decoder_sys_t *p_sys = p_dec->p_sys; + bool format_changed = false; + +#if (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 55, 16, 101 ) ) +#define FROM_AVRAT(default_factor, avrat) \ +(uint64_t)(default_factor) * (avrat).num / (avrat).den + const AVFrameSideData *metadata = + av_frame_get_side_data( frame, + AV_FRAME_DATA_MASTERING_DISPLAY_METADATA ); + if ( metadata ) + { + const AVMasteringDisplayMetadata *hdr_meta = + (const AVMasteringDisplayMetadata *) metadata->data; + if ( hdr_meta->has_luminance ) + { +#define ST2086_LUMA_FACTOR 10000 + p_pic->format.mastering.max_luminance = + FROM_AVRAT(ST2086_LUMA_FACTOR, hdr_meta->max_luminance); + p_pic->format.mastering.min_luminance = + FROM_AVRAT(ST2086_LUMA_FACTOR, hdr_meta->min_luminance); + } + if ( hdr_meta->has_primaries ) + { +#define ST2086_RED 2 +#define ST2086_GREEN 0 +#define ST2086_BLUE 1 +#define LAV_RED 0 +#define LAV_GREEN 1 +#define LAV_BLUE 2 +#define ST2086_PRIM_FACTOR 50000 + p_pic->format.mastering.primaries[ST2086_RED*2 + 0] = + FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_RED][0]); + p_pic->format.mastering.primaries[ST2086_RED*2 + 1] = + FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_RED][1]); + p_pic->format.mastering.primaries[ST2086_GREEN*2 + 0] = + FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_GREEN][0]); + p_pic->format.mastering.primaries[ST2086_GREEN*2 + 1] = + FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_GREEN][1]); + p_pic->format.mastering.primaries[ST2086_BLUE*2 + 0] = + FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_BLUE][0]); + p_pic->format.mastering.primaries[ST2086_BLUE*2 + 1] = + FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_BLUE][1]); + p_pic->format.mastering.white_point[0] = + FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->white_point[0]); + p_pic->format.mastering.white_point[1] = + FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->white_point[1]); + } + + if ( memcmp( &p_dec->fmt_out.video.mastering, + &p_pic->format.mastering, + sizeof(p_pic->format.mastering) ) ) + { + p_dec->fmt_out.video.mastering = p_pic->format.mastering; + format_changed = true; + } +#undef FROM_AVRAT + } +#endif +#if (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 55, 60, 100 ) ) + const AVFrameSideData *metadata_lt = + av_frame_get_side_data( frame, + AV_FRAME_DATA_CONTENT_LIGHT_LEVEL ); + if ( metadata_lt ) + { + const AVContentLightMetadata *light_meta = + (const AVContentLightMetadata *) metadata_lt->data; + p_pic->format.lighting.MaxCLL = light_meta->MaxCLL; + p_pic->format.lighting.MaxFALL = light_meta->MaxFALL; + if ( memcmp( &p_dec->fmt_out.video.lighting, + &p_pic->format.lighting, + sizeof(p_pic->format.lighting) ) ) + { + p_dec->fmt_out.video.lighting = p_pic->format.lighting; + format_changed = true; + } + } +#endif + + if (format_changed) + decoder_UpdateVideoFormat( p_dec ); + + const AVFrameSideData *p_avcc = av_frame_get_side_data( frame, AV_FRAME_DATA_A53_CC ); + if( p_avcc ) + { + cc_Extract( &p_sys->cc, CC_PAYLOAD_RAW, true, p_avcc->data, p_avcc->size ); + if( p_sys->cc.i_data ) + { + block_t *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 ); + if( p_sys->cc.b_reorder ) + p_cc->i_dts = p_cc->i_pts = p_pic->date; + else + p_cc->i_pts = p_cc->i_dts; + decoder_QueueCc( p_dec, p_cc, p_sys->cc.pb_present, 4 ); + } + cc_Flush( &p_sys->cc ); + } + } +} + /***************************************************************************** * DecodeBlock: Called to decode one or more frames *****************************************************************************/ @@ -1067,107 +1171,10 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error p_pic->b_progressive = !frame->interlaced_frame; p_pic->b_top_field_first = frame->top_field_first; - bool format_changed = false; -#if (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 55, 16, 101 ) ) -#define FROM_AVRAT(default_factor, avrat) \ - (uint64_t)(default_factor) * (avrat).num / (avrat).den - const AVFrameSideData *metadata = - av_frame_get_side_data( frame, - AV_FRAME_DATA_MASTERING_DISPLAY_METADATA ); - if ( metadata ) - { - const AVMasteringDisplayMetadata *hdr_meta = - (const AVMasteringDisplayMetadata *) metadata->data; - if ( hdr_meta->has_luminance ) - { -#define ST2086_LUMA_FACTOR 10000 - p_pic->format.mastering.max_luminance = - FROM_AVRAT(ST2086_LUMA_FACTOR, hdr_meta->max_luminance); - p_pic->format.mastering.min_luminance = - FROM_AVRAT(ST2086_LUMA_FACTOR, hdr_meta->min_luminance); - } - if ( hdr_meta->has_primaries ) - { -#define ST2086_RED 2 -#define ST2086_GREEN 0 -#define ST2086_BLUE 1 -#define LAV_RED 0 -#define LAV_GREEN 1 -#define LAV_BLUE 2 -#define ST2086_PRIM_FACTOR 50000 - p_pic->format.mastering.primaries[ST2086_RED*2 + 0] = - FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_RED][0]); - p_pic->format.mastering.primaries[ST2086_RED*2 + 1] = - FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_RED][1]); - p_pic->format.mastering.primaries[ST2086_GREEN*2 + 0] = - FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_GREEN][0]); - p_pic->format.mastering.primaries[ST2086_GREEN*2 + 1] = - FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_GREEN][1]); - p_pic->format.mastering.primaries[ST2086_BLUE*2 + 0] = - FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_BLUE][0]); - p_pic->format.mastering.primaries[ST2086_BLUE*2 + 1] = - FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->display_primaries[LAV_BLUE][1]); - p_pic->format.mastering.white_point[0] = - FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->white_point[0]); - p_pic->format.mastering.white_point[1] = - FROM_AVRAT(ST2086_PRIM_FACTOR, hdr_meta->white_point[1]); - } - - if ( memcmp( &p_dec->fmt_out.video.mastering, - &p_pic->format.mastering, - sizeof(p_pic->format.mastering) ) ) - { - p_dec->fmt_out.video.mastering = p_pic->format.mastering; - format_changed = true; - } -#undef FROM_AVRAT - } -#endif -#if (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 55, 60, 100 ) ) - const AVFrameSideData *metadata_lt = - av_frame_get_side_data( frame, - AV_FRAME_DATA_CONTENT_LIGHT_LEVEL ); - if ( metadata_lt ) - { - const AVContentLightMetadata *light_meta = - (const AVContentLightMetadata *) metadata_lt->data; - p_pic->format.lighting.MaxCLL = light_meta->MaxCLL; - p_pic->format.lighting.MaxFALL = light_meta->MaxFALL; - if ( memcmp( &p_dec->fmt_out.video.lighting, - &p_pic->format.lighting, - sizeof(p_pic->format.lighting) ) ) - { - p_dec->fmt_out.video.lighting = p_pic->format.lighting; - format_changed = true; - } - } -#endif - - const AVFrameSideData *p_avcc = av_frame_get_side_data( frame, AV_FRAME_DATA_A53_CC ); - if( p_avcc ) - { - cc_Extract( &p_sys->cc, CC_PAYLOAD_RAW, true, p_avcc->data, p_avcc->size ); - if( p_sys->cc.i_data ) - { - block_t *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 ); - if( p_sys->cc.b_reorder ) - p_cc->i_dts = p_cc->i_pts = i_pts; - else - p_cc->i_pts = p_cc->i_dts; - decoder_QueueCc( p_dec, p_cc, p_sys->cc.pb_present, 4 ); - } - cc_Flush( &p_sys->cc ); - } - } + DecodeSidedata( p_dec, frame, p_pic ); av_frame_free(&frame); - if (format_changed) - decoder_UpdateVideoFormat( p_dec ); - /* Send decoded frame to vout */ if (i_pts > VLC_TS_INVALID) { _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
