Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/2] avformat/apvdec: don't fill container level fields with codec level info
Date: Sun, 27 Apr 2025 18:15:41 -0300
Message-ID: <20250427211541.10631-2-jamrial@gmail.com> (raw)
In-Reply-To: <20250427211541.10631-1-jamrial@gmail.com>

This is a raw demuxer, it should not read codec level information and export it
as container level information.
The generic demux code will use the recently introduced parser to take care of
that.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 configure            |  1 +
 libavformat/apvdec.c | 46 ++++++--------------------------------------
 2 files changed, 7 insertions(+), 40 deletions(-)

diff --git a/configure b/configure
index ee270b770c..39e65870a3 100755
--- a/configure
+++ b/configure
@@ -3648,6 +3648,7 @@ act_demuxer_select="riffdec"
 adts_muxer_select="mpeg4audio"
 aiff_muxer_select="iso_media"
 amv_muxer_select="riffenc"
+apv_demuxer_select="apv_parser"
 asf_demuxer_select="riffdec"
 asf_o_demuxer_select="riffdec"
 asf_muxer_select="riffenc"
diff --git a/libavformat/apvdec.c b/libavformat/apvdec.c
index e1ac34b003..4597199970 100644
--- a/libavformat/apvdec.c
+++ b/libavformat/apvdec.c
@@ -36,24 +36,13 @@ typedef struct APVHeaderInfo {
     int      frame_width;
     int      frame_height;
 
-    uint8_t  chroma_format_idc;
     uint8_t  bit_depth_minus8;
-
-    enum AVPixelFormat pixel_format;
 } APVHeaderInfo;
 
-static const enum AVPixelFormat apv_format_table[5][5] = {
-    { AV_PIX_FMT_GRAY8,    AV_PIX_FMT_GRAY10,     AV_PIX_FMT_GRAY12,     AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16 },
-    { 0 }, // 4:2:0 is not valid.
-    { AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV422P10,  AV_PIX_FMT_YUV422P12,  AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUV422P16 },
-    { AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUV444P10,  AV_PIX_FMT_YUV444P12,  AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUV444P16 },
-    { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUVA444P16 },
-};
-
-static int apv_extract_header_info(APVHeaderInfo *info,
-                                   GetByteContext *gbc)
+static int apv_extract_header_info(GetByteContext *gbc)
 {
-    int zero, byte, bit_depth_index;
+    APVHeaderInfo header, *info = &header;
+    int zero, byte;
 
     info->pbu_type = bytestream2_get_byte(gbc);
     info->group_id = bytestream2_get_be16(gbc);
@@ -81,7 +70,6 @@ static int apv_extract_header_info(APVHeaderInfo *info,
         return AVERROR_INVALIDDATA;
 
     byte = bytestream2_get_byte(gbc);
-    info->chroma_format_idc = byte >> 4;
     info->bit_depth_minus8  = byte & 0xf;
 
     if (info->bit_depth_minus8 > 8) {
@@ -91,18 +79,6 @@ static int apv_extract_header_info(APVHeaderInfo *info,
         // Odd bit depths are technically valid but not useful here.
         return AVERROR_INVALIDDATA;
     }
-    bit_depth_index = info->bit_depth_minus8 / 2;
-
-    switch (info->chroma_format_idc) {
-    case APV_CHROMA_FORMAT_400:
-    case APV_CHROMA_FORMAT_422:
-    case APV_CHROMA_FORMAT_444:
-    case APV_CHROMA_FORMAT_4444:
-        info->pixel_format = apv_format_table[info->chroma_format_idc][bit_depth_index];
-        break;
-    default:
-        return AVERROR_INVALIDDATA;
-    }
 
     // Ignore capture_time_distance.
     bytestream2_skip(gbc, 1);
@@ -117,7 +93,6 @@ static int apv_extract_header_info(APVHeaderInfo *info,
 static int apv_probe(const AVProbeData *p)
 {
     GetByteContext gbc;
-    APVHeaderInfo header;
     uint32_t au_size, signature, pbu_size;
     int err;
 
@@ -144,7 +119,7 @@ static int apv_probe(const AVProbeData *p)
         return 0;
     }
 
-    err = apv_extract_header_info(&header, &gbc);
+    err = apv_extract_header_info(&gbc);
     if (err < 0) {
         // Header does not look like APV.
         return 0;
@@ -156,8 +131,7 @@ static int apv_read_header(AVFormatContext *s)
 {
     AVStream *st;
     GetByteContext gbc;
-    APVHeaderInfo header;
-    uint8_t buffer[28];
+    uint8_t buffer[12];
     uint32_t au_size, signature, pbu_size;
     int err, size;
 
@@ -186,22 +160,14 @@ static int apv_read_header(AVFormatContext *s)
         return AVERROR_INVALIDDATA;
     }
 
-    err = apv_extract_header_info(&header, &gbc);
-    if (err < 0)
-        return err;
-
     st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
 
     st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codecpar->codec_id   = AV_CODEC_ID_APV;
-    st->codecpar->format     = header.pixel_format;
-    st->codecpar->profile    = header.profile_idc;
-    st->codecpar->level      = header.level_idc;
-    st->codecpar->width      = header.frame_width;
-    st->codecpar->height     = header.frame_height;
 
+    ffstream(st)->need_parsing = AVSTREAM_PARSE_HEADERS;
     st->avg_frame_rate = (AVRational){ 30, 1 };
     avpriv_set_pts_info(st, 64, 1, 30);
 
-- 
2.49.0

_______________________________________________
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".

  reply	other threads:[~2025-04-27 21:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-27 21:15 [FFmpeg-devel] [PATCH 1/2] avcodec: add an APV parser James Almer
2025-04-27 21:15 ` James Almer [this message]
2025-04-27 23:39 ` [FFmpeg-devel] [PATCH v2 " James Almer
2025-05-01 17:23   ` James Almer

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=20250427211541.10631-2-jamrial@gmail.com \
    --to=jamrial@gmail.com \
    --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