From patchwork Fri Nov 8 10:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Tomas_H=C3=A4rdin?= X-Patchwork-Id: 52634 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2fe5:b0:4a6:1c7:11b7 with SMTP id kw5csp2071489vqb; Fri, 8 Nov 2024 02:29:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXGGDq3bwQLupQXlO+6nmxekxY2Im9pqiqL2bDjXx6y/o+AyXV5VAWJceWms84QiSN6kTUtH2q1APh+k+tuiOBb@gmail.com X-Google-Smtp-Source: AGHT+IGc4YI8IBeeeWM5Whs1JAKjc4hzBzat9YzUAqG9dZ13fkBKp4qDMlGX+1GlNclsZ2K7PWvp X-Received: by 2002:a05:6402:5256:b0:5ce:df55:7a00 with SMTP id 4fb4d7f45d1cf-5cf0a4416aemr1609199a12.26.1731061764274; Fri, 08 Nov 2024 02:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731061764; cv=none; d=google.com; s=arc-20240605; b=CQ4YJ46Ubs2yf8mjwLWHmWet9hkl+JZt8o79u43vKI6lsCCrSJEs+spjWQetDxjxmJ mer1b60uhL0WJZ1fIkdX6wyNDtSsPzUOC47DRLyN9LKksVGoLjpcFHx7g4oqNzzRh3X+ 4MD7DrDsqhdDCqXEPtTYK9p1CpXADedqUjRYljQ7jGnvVWChDY1vPyMb4o+f3YgPYa9t s7MsCF9loGw5O4bQkKvEu0HujwvFoX2jq83VcZXP7pCBfmshoH17bLPJAngje/hNwusW Z/0RmrYrYdKBuZB/fjMSJ0IqPhLNlk355hyD+pBdKlL0LkW6hnFgeOMMeLRgIzJSaZy5 Zduw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:user-agent:date:to:from:message-id:delivered-to; bh=E6sBnZ8NLbTjY5j8NmnrlTfKu2uOlMrFK5OmDF8pm40=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=RQKw+zjSqcOPFx44ct8pjXQCqbCeI/h+VbmWtpODkI+bFAQTW4lfVBT9zYK2PuHTNK ElyWPWuAquRcAoVs24yxATDSb7d5fsQFtKhRzvAkzw4lkwU/moisKOSpQ3MHj4HgAFtx iWcOPltkJ7oFimWv52XFevvXK8gB26XgFL55ExCnwx0deUAlsQmUyxAu2Uvm6hbklNqj cRtCAjIQttB2lYQqrfjlSwSCkwhGsgCqMl304xm5qn4Pqt2Jz6cWi+eQWL766MIzEFgr tWk1gyb/X2hv+kUWCKzltpRT4f+jiTFWpy6N/e7GPOhth0qkwUv2uTj+HN2ZIz6ucSC6 ZLqA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5cf03c7c85bsi2302556a12.320.2024.11.08.02.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 02:29:24 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0C3CC68DDCF; Fri, 8 Nov 2024 12:29:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from glom.nmugroup.com (glom.nmugroup.com [193.183.80.6]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7646B68DDAD for ; Fri, 8 Nov 2024 12:29:12 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by glom.nmugroup.com (Postfix) with ESMTP id 092AC542875B for ; Fri, 8 Nov 2024 11:29:12 +0100 (CET) Received: from debian.lan (unknown [IPv6:2a00:66c0:a::72c]) (Authenticated sender: git01) by glom.nmugroup.com (Postfix) with ESMTPSA id C2D09542844F for ; Fri, 8 Nov 2024 11:29:11 +0100 (CET) Message-ID: <13261324b2fa866261cca27cf0f33a10bd314202.camel@haerdin.se> From: Tomas =?iso-8859-1?q?H=E4rdin?= To: FFmpeg development discussions and patches Date: Fri, 08 Nov 2024 11:29:10 +0100 User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] lavf/mxfenc: Make write_desc return int X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6h3RPMr3VivD Passes fate-mxf /Tomas From 8f221258a9e5328c4a03fef6e8eab18ce20ce4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 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 From patchwork Fri Nov 8 10:29:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Tomas_H=C3=A4rdin?= X-Patchwork-Id: 52635 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2fe5:b0:4a6:1c7:11b7 with SMTP id kw5csp2071810vqb; Fri, 8 Nov 2024 02:29:59 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVGU7FXD3LPPwdgHSOjVbX7ns9FwCDnVKAUFDHYHAkLCFPo4NbVy0DWwKghG+QnK7WnZbF2fFMkSuslwaR0xGoc@gmail.com X-Google-Smtp-Source: AGHT+IHcovqFAgzM5bjRxiQKeRLkn/sJEXjbqB97bRhrz3cUHdgzJoWYWdsgzH9iTl1UK2A3wyy8 X-Received: by 2002:a05:6402:1ecc:b0:5ce:dea8:890 with SMTP id 4fb4d7f45d1cf-5cf0a31cfccmr1628619a12.9.1731061799376; Fri, 08 Nov 2024 02:29:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731061799; cv=none; d=google.com; s=arc-20240605; b=hOz+Z0GnF9zBA4zahpXHn/GV816l7syFWn2dx3H1+d36GzL7Wat0CKJzV1Hz+y2YQ/ FF2QrBEqYHX+dQOjYOGs0UyDkW+HHbnAS+6M4/GCBLsA4ZBTDbculjyM5y+tLimDoOaE SFF9u1aYal42S3BGPPX7R55QSFFsUV/e9u5fuwVxnJ1gZGptthHH+FYn2O9O0rVli8Wp s/z8fLJk6cRpDbZu9n+g5uwmPQCj4GbaiMek77hyQzdJAdAHu9drHLDTCL7n1ceBnESB iu+cvacKD+GsWdUBv9fA7l6DD5Z8SnDH5FdoquYTXFcnn3GfAX4xnJDwvFqIRqQIbftJ OFPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:user-agent:references:in-reply-to:date:to:from :message-id:delivered-to; bh=l1UVPyydKAZFkecIoG77UAmJrO0VMBY8i7R/dqi+gqk=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=Y03aVTrh7kAFJcoFPG3tzVbOhxBWlJ6B0bu1x8G7o0rm/mZpGtRgrTEqn3oaymYd3+ LfW8Hd6fNWRjd601huHeyPjyh/ttUq0eY6BQXQG1W2tJlILFM7beZGI6kvFrxVUaNRZU ePE0pJI2SeSXm1sIsMnB7irgRjz6q+tu9jeFGIuG/QDEfDqHFFJN5Y1TYAt/LIOGQ/0l Iodlve9m+ISWdfjk94fNc06nER5on04mHO28BVFitj7LM8jYBT6BeZItLmSEsb1CpHLH XKJ96HnC2sJD2ni3cWcT/xp1VDLVrghl6mtTeWLCouaxgYXfpAU3IqwqFgATf3VQ9i57 TLvA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5cf03cfd2c1si2227953a12.615.2024.11.08.02.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 02:29:59 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7791B68DDD2; Fri, 8 Nov 2024 12:29:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from glom.nmugroup.com (glom.nmugroup.com [193.183.80.6]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 28B2A68DDBC for ; Fri, 8 Nov 2024 12:29:48 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by glom.nmugroup.com (Postfix) with ESMTP id C593D542875B for ; Fri, 8 Nov 2024 11:29:47 +0100 (CET) Received: from debian.lan (unknown [IPv6:2a00:66c0:a::72c]) (Authenticated sender: git01) by glom.nmugroup.com (Postfix) with ESMTPSA id 64163542844F for ; Fri, 8 Nov 2024 11:29:47 +0100 (CET) Message-ID: <32096f5317b1b0bcc270dfca16f23eceaa77494e.camel@haerdin.se> From: Tomas =?iso-8859-1?q?H=E4rdin?= To: FFmpeg development discussions and patches Date: Fri, 08 Nov 2024 11:29:46 +0100 In-Reply-To: <13261324b2fa866261cca27cf0f33a10bd314202.camel@haerdin.se> References: <13261324b2fa866261cca27cf0f33a10bd314202.camel@haerdin.se> User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] lavf/mxfenc: Return AVERROR(EINVAL) in mxf_write_jpeg2000_subdesc() is pixfmt not set X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: A7u5vfFuAz5l Also passes fate-mxf /Tomas From 164175d6f7e2e1eab767c129d953e6e9ebbfc94d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 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(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index abc870f133..a482a6a352 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -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