@ -85,11 +85,12 @@ typedef struct PNGDecContext {
int have_clli ;
uint32_t clli_max ;
uint32_t clli_avg ;
int have_mdvc ;
uint16_t mdvc_primaries [ 3 ] [ 2 ] ;
uint16_t mdvc_white_point [ 2 ] ;
uint32_t mdvc_max_lum ;
uint32_t mdvc_min_lum ;
/* Mastering Display Color Volume */
int have_mdcv ;
uint16_t mdcv_primaries [ 3 ] [ 2 ] ;
uint16_t mdcv_white_point [ 2 ] ;
uint32_t mdcv_max_lum ;
uint32_t mdcv_min_lum ;
enum PNGHeaderState hdr_state ;
enum PNGImageState pic_state ;
@ -762,24 +763,24 @@ static int populate_avctx_color_fields(AVCodecContext *avctx, AVFrame *frame)
}
}
if ( s - > have_mdv c ) {
AVMasteringDisplayMetadata * mdv c ;
if ( s - > have_mdcv ) {
AVMasteringDisplayMetadata * mdcv ;
ret = ff_decode_mastering_display_new ( avctx , frame , & mdv c ) ;
ret = ff_decode_mastering_display_new ( avctx , frame , & mdcv ) ;
if ( ret < 0 )
return ret ;
if ( mdv c ) {
mdv c - > has_primaries = 1 ;
if ( mdcv ) {
mdcv - > has_primaries = 1 ;
for ( int i = 0 ; i < 3 ; i + + ) {
mdv c - > display_primaries [ i ] [ 0 ] = av_make_q ( s - > mdv c_primaries [ i ] [ 0 ] , 50000 ) ;
mdv c - > display_primaries [ i ] [ 1 ] = av_make_q ( s - > mdv c_primaries [ i ] [ 1 ] , 50000 ) ;
mdcv - > display_primaries [ i ] [ 0 ] = av_make_q ( s - > mdcv _primaries [ i ] [ 0 ] , 50000 ) ;
mdcv - > display_primaries [ i ] [ 1 ] = av_make_q ( s - > mdcv _primaries [ i ] [ 1 ] , 50000 ) ;
}
mdv c - > white_point [ 0 ] = av_make_q ( s - > mdv c_white_point [ 0 ] , 50000 ) ;
mdv c - > white_point [ 1 ] = av_make_q ( s - > mdv c_white_point [ 1 ] , 50000 ) ;
mdv c - > has_luminance = 1 ;
mdv c - > max_luminance = av_make_q ( s - > mdv c_max_lum , 10000 ) ;
mdv c - > min_luminance = av_make_q ( s - > mdv c_min_lum , 10000 ) ;
mdcv - > white_point [ 0 ] = av_make_q ( s - > mdcv _white_point [ 0 ] , 50000 ) ;
mdcv - > white_point [ 1 ] = av_make_q ( s - > mdcv _white_point [ 1 ] , 50000 ) ;
mdcv - > has_luminance = 1 ;
mdcv - > max_luminance = av_make_q ( s - > mdcv _max_lum , 10000 ) ;
mdcv - > min_luminance = av_make_q ( s - > mdcv _min_lum , 10000 ) ;
}
}
@ -1569,20 +1570,20 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
s - > clli_max = bytestream2_get_be32u ( & gb_chunk ) ;
s - > clli_avg = bytestream2_get_be32u ( & gb_chunk ) ;
break ;
case MKTAG ( ' m ' , ' D ' , ' V ' , ' c ' ) :
case MKTAG ( ' m ' , ' D ' , ' C ' , ' v ' ) :
if ( bytestream2_get_bytes_left ( & gb_chunk ) ! = 24 ) {
av_log ( avctx , AV_LOG_WARNING , " Invalid mDVc chunk size: %d \n " , bytestream2_get_bytes_left ( & gb_chunk ) ) ;
av_log ( avctx , AV_LOG_WARNING , " Invalid mDCv chunk size: %d \n " , bytestream2_get_bytes_left ( & gb_chunk ) ) ;
break ;
}
s - > have_mdv c = 1 ;
s - > have_mdcv = 1 ;
for ( int i = 0 ; i < 3 ; i + + ) {
s - > mdv c_primaries [ i ] [ 0 ] = bytestream2_get_be16u ( & gb_chunk ) ;
s - > mdv c_primaries [ i ] [ 1 ] = bytestream2_get_be16u ( & gb_chunk ) ;
s - > mdcv _primaries [ i ] [ 0 ] = bytestream2_get_be16u ( & gb_chunk ) ;
s - > mdcv _primaries [ i ] [ 1 ] = bytestream2_get_be16u ( & gb_chunk ) ;
}
s - > mdv c_white_point [ 0 ] = bytestream2_get_be16u ( & gb_chunk ) ;
s - > mdv c_white_point [ 1 ] = bytestream2_get_be16u ( & gb_chunk ) ;
s - > mdv c_max_lum = bytestream2_get_be32u ( & gb_chunk ) ;
s - > mdv c_min_lum = bytestream2_get_be32u ( & gb_chunk ) ;
s - > mdcv _white_point [ 0 ] = bytestream2_get_be16u ( & gb_chunk ) ;
s - > mdcv _white_point [ 1 ] = bytestream2_get_be16u ( & gb_chunk ) ;
s - > mdcv _max_lum = bytestream2_get_be32u ( & gb_chunk ) ;
s - > mdcv _min_lum = bytestream2_get_be32u ( & gb_chunk ) ;
break ;
case MKTAG ( ' I ' , ' E ' , ' N ' , ' D ' ) :
if ( ! ( s - > pic_state & PNG_ALLIMAGE ) )