From patchwork Sat Dec 30 21:25:39 2023 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: 45404 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6623:b0:194:e134:edd4 with SMTP id n35csp5486858pzh; Sat, 30 Dec 2023 13:25:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHm/GoMSNC8TEjzgpPBtkLZOjBxq9fFf5qy2hnZ1nfnSTjd4xPYNz+UVI3rRqrgfLmwUgJD X-Received: by 2002:a05:6402:524d:b0:554:8bfd:30 with SMTP id t13-20020a056402524d00b005548bfd0030mr11957820edd.5.1703971546807; Sat, 30 Dec 2023 13:25:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703971546; cv=none; d=google.com; s=arc-20160816; b=Bfg0YpQs8xfIrHbbGr4votxAL+o/2n0BNY4+eyhXlYoWpugkt+1t5cYNo7K71GI/+s WSLUplBfmDaLUJS+R+RRjUduEaAuPJeIDFLaGrB3vowD7M8VmMMRREUZRQP84KydFyom YEffppFwCKgMplKIJan40LiJbC9LVSBgjvezjOK8S5GtqNwsMET6W7A2RcJ+2It4oWUo WhXDSBFTjZS/EqjBqXVH27rHLSrYleELAIvkpNNHLDy9xHuZl6kXSz1ejdhPExrxtYSM ZhHVcYJG8yvbdHIOrO4fL097HOSQyVmX3KbXI1UoRbrg0ksveomYq0a7Ir1b/NUCpHgM UHMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=DuANwt3/5pTyEBYKvsjehNqdRKQSD6bc7EhLpjDHXiU=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=hhKfTnlDGo/uM4QYsxR9kZWUYYj11NPi5DsQilAiaSxPiUZAP3ydwdYQpDl8mt2faS ENCBFr/HrmKIbxyfcv+sK+vbV94jxFmeb5+9QcWvv1eD2afzpWM70gls09EuOMzUn1ID poSDqzsf+nKSYhopSwxvbFI2YWT8fPBW/iXH/GjpxGzPUud0wG1F0vjcNSolbWYbpLJT B+XciZp4t7XKKRggkSxYNXC312Gm9i+B9asPzbra0GUi3v702WK3q49nlfNYeeZPVhL+ Rh2jrwIA953Nrwnx2R5wQkhRR4rTAl6dXW8xS5uQ+tVUaZJSNydTFRzt/tY4dLUHPu3f x41g== 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 ESMTP id j22-20020a508a96000000b00550db2b31ebsi9023108edj.294.2023.12.30.13.25.46; Sat, 30 Dec 2023 13:25:46 -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 5D3DE68CD06; Sat, 30 Dec 2023 23:25:44 +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 8AB7768CC40 for ; Sat, 30 Dec 2023 23:25:41 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by glom.nmugroup.com (Postfix) with ESMTP id D65B55428493 for ; Sat, 30 Dec 2023 22:25:40 +0100 (CET) Received: from debian.lan (unknown [IPv6:2a00:66c0:a::72c]) (Authenticated sender: git01) by glom.nmugroup.com (Postfix) with ESMTPSA id 91E945428441 for ; Sat, 30 Dec 2023 22:25:40 +0100 (CET) Message-ID: <632179a77b474ea818c7023609398e7f4d0a6daa.camel@haerdin.se> From: Tomas =?iso-8859-1?q?H=E4rdin?= To: FFmpeg development discussions and patches Date: Sat, 30 Dec 2023 22:25:39 +0100 In-Reply-To: References: User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 4/7] lavf/codec2: Allow versions between 0.8 and 1.X 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: uBtqmPEb+Pxs From 5a660d91c2f34c4e464212bf3694cdb7bca80f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Wed, 27 Dec 2023 17:33:18 +0100 Subject: [PATCH 4/7] lavf/codec2: Allow versions between 0.8 and 1.X --- libavformat/codec2.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/libavformat/codec2.c b/libavformat/codec2.c index 78bc339209..8299302acc 100644 --- a/libavformat/codec2.c +++ b/libavformat/codec2.c @@ -37,8 +37,11 @@ //the lowest version we should ever run across is 0.8 //we may run across later versions as the format evolves -#define EXPECTED_CODEC2_MAJOR_VERSION 0 -#define EXPECTED_CODEC2_MINOR_VERSION 8 +#define MIN_MAJOR_VERSION 0 +#define MIN_MINOR_VERSION 8 +//accept any minor version with major version 1.X +//as of writing the latest release is 1.2.0 +#define MAX_MAJOR_VERSION 1 typedef struct { const AVClass *class; @@ -46,17 +49,20 @@ typedef struct { int frames_per_packet; } Codec2Context; +static int check_version(uint8_t major, uint8_t minor) { + //no .c2 files prior to 0.8 or later than 1.X + if (major == MIN_MAJOR_VERSION && minor < MIN_MINOR_VERSION) + return 1; + if (major > MAX_MAJOR_VERSION) + return 1; + return 0; +} + static int codec2_probe(const AVProbeData *p) { //must start wih C0 DE C2 - if (AV_RB24(p->buf) != CODEC2_MAGIC) { - return 0; - } - - //no .c2 files prior to 0.8 - //be strict about major version while we're at it - if (p->buf[3] != EXPECTED_CODEC2_MAJOR_VERSION || - p->buf[4] < EXPECTED_CODEC2_MINOR_VERSION) { + if (AV_RB24(p->buf) != CODEC2_MAGIC || + check_version(p->buf[3], p->buf[4])) { return 0; } @@ -158,7 +164,8 @@ static int codec2_read_header_common(AVFormatContext *s, AVStream *st, int heade static int codec2_read_header(AVFormatContext *s) { AVStream *st = avformat_new_stream(s, NULL); - int ret, version; + int ret; + uint8_t major, minor; if (!st) { return AVERROR(ENOMEM); @@ -179,9 +186,10 @@ static int codec2_read_header(AVFormatContext *s) return ret; } - version = AV_RB16(st->codecpar->extradata); - if ((version >> 8) != EXPECTED_CODEC2_MAJOR_VERSION) { - avpriv_report_missing_feature(s, "Major version %i", version >> 8); + major = st->codecpar->extradata[0]; + minor = st->codecpar->extradata[1]; + if (check_version(major, minor)) { + avpriv_report_missing_feature(s, "Version %i.%i", major, minor); return AVERROR_PATCHWELCOME; } -- 2.39.2