[FFmpeg-devel] [PATCH 1/3] avformat/matroskadec: don't use sizeof(AVMasteringDisplayMetadata)
James Almer
jamrial at gmail.com
Wed Jun 19 21:24:11 EEST 2024
It's not part of the libavutil ABI.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/matroskadec.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 328109b354..6bc5fa621e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2324,15 +2324,15 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) {
}
if (has_mastering_primaries || has_mastering_luminance) {
- AVMasteringDisplayMetadata *metadata;
- AVPacketSideData *sd = av_packet_side_data_new(&st->codecpar->coded_side_data,
- &st->codecpar->nb_coded_side_data,
- AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
- sizeof(AVMasteringDisplayMetadata), 0);
- if (!sd)
+ size_t size = 0;
+ AVMasteringDisplayMetadata *metadata = av_mastering_display_metadata_alloc_size(&size);
+ if (!metadata)
+ return AVERROR(ENOMEM);
+ if (!av_packet_side_data_add(&st->codecpar->coded_side_data, &st->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_MASTERING_DISPLAY_METADATA, metadata, size, 0)) {
+ av_freep(&metadata);
return AVERROR(ENOMEM);
- metadata = (AVMasteringDisplayMetadata*)sd->data;
- memset(metadata, 0, sizeof(AVMasteringDisplayMetadata));
+ }
if (has_mastering_primaries) {
metadata->display_primaries[0][0] = av_d2q(mastering_meta->r_x, INT_MAX);
metadata->display_primaries[0][1] = av_d2q(mastering_meta->r_y, INT_MAX);
--
2.45.2
More information about the ffmpeg-devel
mailing list