From 164175d6f7e2e1eab767c129d953e6e9ebbfc94d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Fri, 8 Nov 2024 11:26:24 +0100
Subject: [PATCH 2/2] lavf/mxfenc: Return AVERROR(EINVAL) in
mxf_write_jpeg2000_subdesc() is pixfmt not set
---
libavformat/mxfenc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
@@ -1483,7 +1483,7 @@ static void mxf_write_avc_subdesc(AVFormatContext *s, AVStream *st)
mxf_update_klv_size(s->pb, pos);
}
-static void mxf_write_jpeg2000_subdesc(AVFormatContext *s, AVStream *st)
+static int mxf_write_jpeg2000_subdesc(AVFormatContext *s, AVStream *st)
{
MXFStreamContext *sc = st->priv_data;
AVIOContext *pb = s->pb;
@@ -1492,7 +1492,7 @@ static void mxf_write_jpeg2000_subdesc(AVFormatContext *s, AVStream *st)
if (!pix_desc) {
av_log(s, AV_LOG_ERROR, "Pixel format not set - not writing JPEG2000SubDescriptor\n");
- return;
+ return AVERROR(EINVAL);
}
/* JPEG2000 subdescriptor key */
@@ -1543,6 +1543,7 @@ static void mxf_write_jpeg2000_subdesc(AVFormatContext *s, AVStream *st)
avio_write(pb, sc->j2k_info.j2k_comp_desc, 3*pix_desc->nb_components);
mxf_update_klv_size(pb, pos);
+ return 0;
}
static int mxf_write_cdci_desc(AVFormatContext *s, AVStream *st)
@@ -1554,7 +1555,7 @@ static int mxf_write_cdci_desc(AVFormatContext *s, AVStream *st)
mxf_write_avc_subdesc(s, st);
}
if (st->codecpar->codec_id == AV_CODEC_ID_JPEG2000) {
- mxf_write_jpeg2000_subdesc(s, st);
+ return mxf_write_jpeg2000_subdesc(s, st);
}
return 0;
}
--
2.39.2