@ -28,17 +28,14 @@
# include <float.h>
# include <float.h>
# include "libavutil/avassert.h"
# include "libavutil/avassert.h"
# include "libavutil/bprint.h"
# include "libavutil/buffer.h"
# include "libavutil/buffer.h"
# include "libavutil/internal.h"
# include "libavutil/internal.h"
# include "libavutil/common.h"
# include "libavutil/mastering_display_metadata.h"
# include "libavutil/mastering_display_metadata.h"
# include "libavutil/opt.h"
# include "libavutil/opt.h"
# include "libavutil/pixdesc.h"
# include "libavutil/pixdesc.h"
# include "avcodec.h"
# include "avcodec.h"
# include "codec_internal.h"
# include "codec_internal.h"
# include "encode.h"
# include "encode.h"
# include "internal.h"
# include "packet_internal.h"
# include "packet_internal.h"
# include "atsc_a53.h"
# include "atsc_a53.h"
# include "sei.h"
# include "sei.h"
@ -182,13 +179,10 @@ static int handle_mdcv(const AVClass **avcl, const x265_api *api,
x265_param * params ,
x265_param * params ,
const AVMasteringDisplayMetadata * mdcv )
const AVMasteringDisplayMetadata * mdcv )
{
{
int ret = AVERROR_BUG ;
char buf [ 10 /* # of PRId64s */ * 20 /* max strlen for %PRId64 */ + sizeof ( " G(,)B(,)R(,)WP(,)L(,) " ) ] ;
AVBPrint buf ;
av_bprint_init ( & buf , 0 , AV_BPRINT_SIZE_AUTOMATIC ) ;
// G(%hu,%hu)B(%hu,%hu)R(%hu,%hu)WP(%hu,%hu)L(%u,%u)
// G(%hu,%hu)B(%hu,%hu)R(%hu,%hu)WP(%hu,%hu)L(%u,%u)
av_bprintf (
snprintf ( buf , sizeof ( buf ) ,
& buf ,
" G(% " PRId64 " ,% " PRId64 " )B(% " PRId64 " ,% " PRId64 " )R(% " PRId64 " ,% " PRId64 " ) "
" G(% " PRId64 " ,% " PRId64 " )B(% " PRId64 " ,% " PRId64 " )R(% " PRId64 " ,% " PRId64 " ) "
" WP(% " PRId64 " ,% " PRId64 " )L(% " PRId64 " ,% " PRId64 " ) " ,
" WP(% " PRId64 " ,% " PRId64 " )L(% " PRId64 " ,% " PRId64 " ) " ,
av_rescale_q ( 1 , mdcv - > display_primaries [ 1 ] [ 0 ] , ( AVRational ) { 1 , 50000 } ) ,
av_rescale_q ( 1 , mdcv - > display_primaries [ 1 ] [ 0 ] , ( AVRational ) { 1 , 50000 } ) ,
@ -202,28 +196,15 @@ static int handle_mdcv(const AVClass **avcl, const x265_api *api,
av_rescale_q ( 1 , mdcv - > max_luminance , ( AVRational ) { 1 , 10000 } ) ,
av_rescale_q ( 1 , mdcv - > max_luminance , ( AVRational ) { 1 , 10000 } ) ,
av_rescale_q ( 1 , mdcv - > min_luminance , ( AVRational ) { 1 , 10000 } ) ) ;
av_rescale_q ( 1 , mdcv - > min_luminance , ( AVRational ) { 1 , 10000 } ) ) ;
if ( ! av_bprint_is_complete ( & buf ) ) {
if ( api - > param_parse ( params , " master-display " , buf ) = =
av_log ( avcl , AV_LOG_ERROR ,
" MDCV string too long for its available space! \n " ) ;
ret = AVERROR ( ENOMEM ) ;
goto end ;
}
if ( api - > param_parse ( params , " master-display " , buf . str ) = =
X265_PARAM_BAD_VALUE ) {
X265_PARAM_BAD_VALUE ) {
av_log ( avcl , AV_LOG_ERROR ,
av_log ( avcl , AV_LOG_ERROR ,
" Invalid value \" %s \" for param \" master-display \" . \n " ,
" Invalid value \" %s \" for param \" master-display \" . \n " ,
buf . str ) ;
buf ) ;
ret = AVERROR ( EINVAL ) ;
return AVERROR ( EINVAL ) ;
goto end ;
}
}
ret = 0 ;
return 0 ;
end :
av_bprint_finalize ( & buf , NULL ) ;
return ret ;
}
}
static int handle_side_data ( AVCodecContext * avctx , const x265_api * api ,
static int handle_side_data ( AVCodecContext * avctx , const x265_api * api ,