Passes fate-mxf /Tomas
From 8f221258a9e5328c4a03fef6e8eab18ce20ce4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <g...@haerdin.se> Date: Fri, 8 Nov 2024 11:24:05 +0100 Subject: [PATCH 1/2] lavf/mxfenc: Make write_desc return int
This enables returning AVERRORs --- libavformat/mxfenc.c | 61 +++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 664e8ca743..abc870f133 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -129,7 +129,7 @@ typedef struct MXFContainerEssenceEntry { UID container_ul; UID element_ul; UID codec_ul; - void (*write_desc)(AVFormatContext *, AVStream *); + int (*write_desc)(AVFormatContext *, AVStream *); } MXFContainerEssenceEntry; typedef struct MXFPackage { @@ -170,14 +170,14 @@ static const struct { { AV_CODEC_ID_NONE } }; -static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st); -static void mxf_write_aes3_desc(AVFormatContext *s, AVStream *st); -static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st); -static void mxf_write_h264_desc(AVFormatContext *s, AVStream *st); -static void mxf_write_ffv1_desc(AVFormatContext *s, AVStream *st); -static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st); -static void mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st); -static void mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st); +static int mxf_write_wav_desc(AVFormatContext *s, AVStream *st); +static int mxf_write_aes3_desc(AVFormatContext *s, AVStream *st); +static int mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st); +static int mxf_write_h264_desc(AVFormatContext *s, AVStream *st); +static int mxf_write_ffv1_desc(AVFormatContext *s, AVStream *st); +static int mxf_write_cdci_desc(AVFormatContext *s, AVStream *st); +static int mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st); +static int mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st); static const MXFContainerEssenceEntry mxf_essence_container_uls[] = { { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, @@ -1545,7 +1545,7 @@ static void mxf_write_jpeg2000_subdesc(AVFormatContext *s, AVStream *st) mxf_update_klv_size(pb, pos); } -static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st) +static int mxf_write_cdci_desc(AVFormatContext *s, AVStream *st) { int64_t pos = mxf_write_cdci_common(s, st, mxf_cdci_descriptor_key); mxf_update_klv_size(s->pb, pos); @@ -1556,9 +1556,10 @@ static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st) if (st->codecpar->codec_id == AV_CODEC_ID_JPEG2000) { mxf_write_jpeg2000_subdesc(s, st); } + return 0; } -static void mxf_write_h264_desc(AVFormatContext *s, AVStream *st) +static int mxf_write_h264_desc(AVFormatContext *s, AVStream *st) { MXFStreamContext *sc = st->priv_data; if (sc->avc_intra) { @@ -1568,9 +1569,10 @@ static void mxf_write_h264_desc(AVFormatContext *s, AVStream *st) mxf_update_klv_size(s->pb, pos); mxf_write_avc_subdesc(s, st); } + return 0; } -static void mxf_write_ffv1_subdesc(AVFormatContext *s, AVStream *st) +static int mxf_write_ffv1_subdesc(AVFormatContext *s, AVStream *st) { AVIOContext *pb = s->pb; MXFStreamContext *sc = st->priv_data; @@ -1597,9 +1599,10 @@ static void mxf_write_ffv1_subdesc(AVFormatContext *s, AVStream *st) } mxf_update_klv_size(s->pb, pos); + return 0; } -static void mxf_write_ffv1_desc(AVFormatContext *s, AVStream *st) +static int mxf_write_ffv1_desc(AVFormatContext *s, AVStream *st) { int is_rgb, pos; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(st->codecpar->format); @@ -1608,16 +1611,17 @@ static void mxf_write_ffv1_desc(AVFormatContext *s, AVStream *st) pos = mxf_write_cdci_common(s, st, is_rgb ? mxf_rgba_descriptor_key : mxf_cdci_descriptor_key); mxf_update_klv_size(s->pb, pos); - mxf_write_ffv1_subdesc(s, st); + return mxf_write_ffv1_subdesc(s, st); } -static void mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st) +static int mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st) { int64_t pos = mxf_write_generic_desc(s, st, mxf_s436m_anc_descriptor_key); mxf_update_klv_size(s->pb, pos); + return 0; } -static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st) +static int mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st) { AVIOContext *pb = s->pb; MXFStreamContext *sc = st->priv_data; @@ -1653,6 +1657,7 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st) } mxf_update_klv_size(pb, pos); + return 0; } static int64_t mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st, const UID key) @@ -1719,22 +1724,25 @@ static int64_t mxf_write_wav_common(AVFormatContext *s, AVStream *st, const UID return pos; } -static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st) +static int mxf_write_wav_desc(AVFormatContext *s, AVStream *st) { int64_t pos = mxf_write_wav_common(s, st, mxf_wav_descriptor_key); mxf_update_klv_size(s->pb, pos); + return 0; } -static void mxf_write_aes3_desc(AVFormatContext *s, AVStream *st) +static int mxf_write_aes3_desc(AVFormatContext *s, AVStream *st) { int64_t pos = mxf_write_wav_common(s, st, mxf_aes3_descriptor_key); mxf_update_klv_size(s->pb, pos); + return 0; } -static void mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st) +static int mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st) { int64_t pos = mxf_write_generic_sound_common(s, st, mxf_generic_sound_descriptor_key); mxf_update_klv_size(s->pb, pos); + return 0; } static const uint8_t mxf_indirect_value_utf16le[] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }; @@ -1786,7 +1794,7 @@ static int mxf_write_user_comments(AVFormatContext *s, const AVDictionary *m) return count; } -static void mxf_write_package(AVFormatContext *s, MXFPackage *package) +static int mxf_write_package(AVFormatContext *s, MXFPackage *package) { MXFContext *mxf = s->priv_data; AVIOContext *pb = s->pb; @@ -1881,9 +1889,13 @@ static void mxf_write_package(AVFormatContext *s, MXFPackage *package) if (package->type == SourcePackage && package->instance == 1) { MXFStreamContext *sc = st->priv_data; - mxf_essence_container_uls[sc->index].write_desc(s, st); + int ret = mxf_essence_container_uls[sc->index].write_desc(s, st); + if (ret < 0) + return ret; } } + + return 0; } static int mxf_write_essence_container_data(AVFormatContext *s) @@ -1951,8 +1963,11 @@ static int mxf_write_header_metadata_sets(AVFormatContext *s) mxf_write_identification(s); mxf_write_content_storage(s, packages, package_count); mxf->track_instance_count = 0; - for (i = 0; i < package_count; i++) - mxf_write_package(s, &packages[i]); + for (i = 0; i < package_count; i++) { + int ret = mxf_write_package(s, &packages[i]); + if (ret < 0) + return ret; + } mxf_write_essence_container_data(s); return 0; } -- 2.39.2
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".