From ad17b9d2d47af5dfb7c380db9c5fc6d719dcf883 Mon Sep 17 00:00:00 2001 From: Neil Birkbeck Date: Mon, 22 Feb 2016 14:53:06 -0800 Subject: [PATCH] libavcodec:add packet level support for mastering metadata Some containers, like webm/mkv, will contain this mastering metadata. This is analogous to the way 3D fpa data is handled (in frame and packet side data). Signed-off-by: Neil Birkbeck Signed-off-by: Michael Niedermayer --- libavcodec/avcodec.h | 7 +++++++ libavcodec/avpacket.c | 35 ++++++++++++++++++----------------- libavcodec/utils.c | 9 +++++---- libavcodec/version.h | 2 +- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index f4fe05618e..7a5689904d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1408,6 +1408,13 @@ enum AVPacketSideDataType { * information from the demuxer to the corresponding muxer. */ AV_PKT_DATA_MPEGTS_STREAM_ID, + + /** + * Mastering display metadata (based on SMPTE-2086:2014). This metadata + * should be associated with a video stream and containts data in the form + * of the AVMasteringDisplayMetadata struct. + */ + AV_PKT_DATA_MASTERING_DISPLAY_METADATA }; #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 9538bf39f3..97f079f901 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -335,23 +335,24 @@ uint8_t *av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, const char *av_packet_side_data_name(enum AVPacketSideDataType type) { switch(type) { - case AV_PKT_DATA_PALETTE: return "Palette"; - case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata"; - case AV_PKT_DATA_PARAM_CHANGE: return "Param Change"; - case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info"; - case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain"; - case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix"; - case AV_PKT_DATA_STEREO3D: return "Stereo 3D"; - case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type"; - case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples"; - case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono"; - case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata"; - case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position"; - case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional"; - case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID"; - case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings"; - case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update"; - case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID"; + case AV_PKT_DATA_PALETTE: return "Palette"; + case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata"; + case AV_PKT_DATA_PARAM_CHANGE: return "Param Change"; + case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info"; + case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain"; + case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix"; + case AV_PKT_DATA_STEREO3D: return "Stereo 3D"; + case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type"; + case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples"; + case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono"; + case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata"; + case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position"; + case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional"; + case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID"; + case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings"; + case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update"; + case AV_PKT_DATA_MPEGTS_STREAM_ID: return "MPEGTS Stream ID"; + case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata"; } return NULL; } diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 216e5439ea..af21cdd95f 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -757,10 +757,11 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) enum AVPacketSideDataType packet; enum AVFrameSideDataType frame; } sd[] = { - { AV_PKT_DATA_REPLAYGAIN , AV_FRAME_DATA_REPLAYGAIN }, - { AV_PKT_DATA_DISPLAYMATRIX, AV_FRAME_DATA_DISPLAYMATRIX }, - { AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D }, - { AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE }, + { AV_PKT_DATA_REPLAYGAIN , AV_FRAME_DATA_REPLAYGAIN }, + { AV_PKT_DATA_DISPLAYMATRIX, AV_FRAME_DATA_DISPLAYMATRIX }, + { AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D }, + { AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE }, + { AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA }, }; if (pkt) { diff --git a/libavcodec/version.h b/libavcodec/version.h index abb8c472e8..0856b199a2 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 57 #define LIBAVCODEC_VERSION_MINOR 25 -#define LIBAVCODEC_VERSION_MICRO 100 +#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \