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 6/7] lavf/codec2: Silence warnings when either muxer/demuxer is disabled
Date: Sat, 30 Dec 2023 22:26:20 +0100
Message-ID: <e07c3eb81e161c6d6d1215597710ab44416c6b13.camel@haerdin.se> (raw)
In-Reply-To: <a85bc5d6a405ba989d98383a10612d42d015ea90.camel@haerdin.se>

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



[-- Attachment #2: 0006-lavf-codec2-Silence-warnings-when-either-muxer-demux.patch --]
[-- Type: text/x-patch, Size: 4360 bytes --]

From f64b4a90ea22421db494d87f5904ae8c7294c871 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Wed, 27 Dec 2023 22:52:25 +0100
Subject: [PATCH 6/7] lavf/codec2: Silence warnings when either muxer/demuxer
 is disabled

---
 libavformat/codec2.c | 76 +++++++++++++++++++++++++-------------------
 1 file changed, 43 insertions(+), 33 deletions(-)

diff --git a/libavformat/codec2.c b/libavformat/codec2.c
index 7447109752..8ff14bc72a 100644
--- a/libavformat/codec2.c
+++ b/libavformat/codec2.c
@@ -49,6 +49,7 @@ typedef struct {
     int frames_per_packet;
 } Codec2Context;
 
+#if CONFIG_CODEC2_DEMUXER
 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)
@@ -69,7 +70,9 @@ static int codec2_probe(const AVProbeData *p)
     //32 bits of identification -> low score
     return AVPROBE_SCORE_EXTENSION + 1;
 }
+#endif
 
+#if CONFIG_CODEC2_DEMUXER || CONFIG_CODEC2RAW_DEMUXER
 //Mimics codec2_samples_per_frame()
 static int codec2_mode_frame_size(AVFormatContext *s, int mode)
 {
@@ -161,6 +164,41 @@ static int codec2_read_header_common(AVFormatContext *s, AVStream *st, int heade
     return 0;
 }
 
+static int codec2_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+    Codec2Context *c2 = s->priv_data;
+    AVStream *st = s->streams[0];
+    int ret, size, n, block_align, frame_size;
+
+    block_align = st->codecpar->block_align;
+    frame_size  = st->codecpar->frame_size;
+
+    if (block_align <= 0 || frame_size <= 0 || c2->frames_per_packet <= 0) {
+        return AVERROR(EINVAL);
+    }
+
+    //try to read desired number of frames, compute n from to actual number of bytes read
+    size = c2->frames_per_packet * block_align;
+    ret = av_get_packet(s->pb, pkt, size);
+    if (ret < 0) {
+        return ret;
+    }
+
+    //only set duration - compute_pkt_fields() and ff_pcm_read_seek() takes care of everything else
+    //tested by spamming the seek functionality in ffplay
+    n = ret / block_align;
+    pkt->duration = n * frame_size;
+
+    //un-mark packet as corrupt if size is a multiple of block_align
+    //this can happen when frames_per_packet > 1
+    if (ret % block_align == 0)
+        pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
+
+    return ret;
+}
+#endif
+
+#if CONFIG_CODEC2_DEMUXER
 static int codec2_read_header(AVFormatContext *s)
 {
     AVStream *st = avformat_new_stream(s, NULL);
@@ -197,40 +235,9 @@ static int codec2_read_header(AVFormatContext *s)
 
     return codec2_read_header_common(s, st, CODEC2_HEADER_SIZE);
 }
+#endif
 
-static int codec2_read_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    Codec2Context *c2 = s->priv_data;
-    AVStream *st = s->streams[0];
-    int ret, size, n, block_align, frame_size;
-
-    block_align = st->codecpar->block_align;
-    frame_size  = st->codecpar->frame_size;
-
-    if (block_align <= 0 || frame_size <= 0 || c2->frames_per_packet <= 0) {
-        return AVERROR(EINVAL);
-    }
-
-    //try to read desired number of frames, compute n from to actual number of bytes read
-    size = c2->frames_per_packet * block_align;
-    ret = av_get_packet(s->pb, pkt, size);
-    if (ret < 0) {
-        return ret;
-    }
-
-    //only set duration - compute_pkt_fields() and ff_pcm_read_seek() takes care of everything else
-    //tested by spamming the seek functionality in ffplay
-    n = ret / block_align;
-    pkt->duration = n * frame_size;
-
-    //un-mark packet as corrupt if size is a multiple of block_align
-    //this can happen when frames_per_packet > 1
-    if (ret % block_align == 0)
-        pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
-
-    return ret;
-}
-
+#if CONFIG_CODEC2_MUXER
 static int codec2_write_header(AVFormatContext *s)
 {
     AVStream *st;
@@ -253,7 +260,9 @@ static int codec2_write_header(AVFormatContext *s)
 
     return 0;
 }
+#endif
 
+#if CONFIG_CODEC2RAW_DEMUXER
 static int codec2raw_read_header(AVFormatContext *s)
 {
     Codec2Context *c2 = s->priv_data;
@@ -280,6 +289,7 @@ static int codec2raw_read_header(AVFormatContext *s)
 
     return codec2_read_header_common(s, st, 0);
 }
+#endif
 
 //transcoding report2074.c2 to wav went from 7.391s to 5.322s with -frames_per_packet 1000 compared to default, same sha1sum
 #define FRAMES_PER_PACKET \
-- 
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:26 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 ` [FFmpeg-devel] [PATCH v2 4/7] lavf/codec2: Allow versions between 0.8 and 1.X Tomas Härdin
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 ` Tomas Härdin [this message]
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=e07c3eb81e161c6d6d1215597710ab44416c6b13.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