Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Tomas Härdin" <git@haerdin.se>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH v2 4/7] lavf/codec2: Allow versions between 0.8 and 1.X
Date: Sat, 30 Dec 2023 22:25:39 +0100
Message-ID: <632179a77b474ea818c7023609398e7f4d0a6daa.camel@haerdin.se> (raw)
In-Reply-To: <a85bc5d6a405ba989d98383a10612d42d015ea90.camel@haerdin.se>

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0004-lavf-codec2-Allow-versions-between-0.8-and-1.X.patch --]
[-- Type: text/x-patch, Size: 2634 bytes --]

From 5a660d91c2f34c4e464212bf3694cdb7bca80f1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
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


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2023-12-30 21:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-30 21:22 [FFmpeg-devel] [PATCH v2 1/7] lavc/codec2utils: Use actual libcodec2 version Tomas Härdin
2023-12-30 21:23 ` [FFmpeg-devel] [PATCH v2 2/7] lavc/libcodec2: Report actual bitrate used both when decoding and encoding Tomas Härdin
2023-12-30 21:25 ` [FFmpeg-devel] [PATCH v2 3/7] lavf/codec2: Compute duration from filesize Tomas Härdin
2023-12-30 21:25 ` Tomas Härdin [this message]
2023-12-30 21:25 ` [FFmpeg-devel] [PATCH v2 5/7] lavf/codec2: Multiple of block_align -> not corrupt Tomas Härdin
2023-12-30 21:26 ` [FFmpeg-devel] [PATCH v2 6/7] lavf/codec2: Silence warnings when either muxer/demuxer is disabled Tomas Härdin
2023-12-30 21:27 ` [FFmpeg-devel] [PATCH v2 7/7] Add FATE tests for codec2, codec2raw and libcodec2 wrapper Tomas Härdin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=632179a77b474ea818c7023609398e7f4d0a6daa.camel@haerdin.se \
    --to=git@haerdin.se \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git