From: lance.lmwang@gmail.com
To: ffmpeg-devel@ffmpeg.org
Cc: Limin Wang <lance.lmwang@gmail.com>
Subject: [FFmpeg-devel] [PATCH v2 2/3] avformat: reuse the common code for v210/v210x
Date: Thu, 23 Dec 2021 07:03:03 +0800
Message-ID: <1640214184-12529-2-git-send-email-lance.lmwang@gmail.com> (raw)
In-Reply-To: <1640214184-12529-1-git-send-email-lance.lmwang@gmail.com>
From: Limin Wang <lance.lmwang@gmail.com>
As suggested by Andreas Rheinhardt, most code of v210 demuxer is common code
which is duplicated from rawvideodec, so it's better to move v210/v210x
demuxer code to rawvideodec.c and reuse the common code.
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
libavformat/Makefile | 4 ++--
libavformat/rawvideodec.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 65fb789..14b66e4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -559,8 +559,8 @@ OBJS-$(CONFIG_TTY_DEMUXER) += tty.o sauce.o
OBJS-$(CONFIG_TY_DEMUXER) += ty.o
OBJS-$(CONFIG_TXD_DEMUXER) += txd.o
OBJS-$(CONFIG_UNCODEDFRAMECRC_MUXER) += uncodedframecrcenc.o framehash.o
-OBJS-$(CONFIG_V210_DEMUXER) += v210.o
-OBJS-$(CONFIG_V210X_DEMUXER) += v210.o
+OBJS-$(CONFIG_V210_DEMUXER) += rawvideodec.o
+OBJS-$(CONFIG_V210X_DEMUXER) += rawvideodec.o
OBJS-$(CONFIG_VAG_DEMUXER) += vag.o
OBJS-$(CONFIG_VC1_DEMUXER) += rawdec.o vc1dec.o
OBJS-$(CONFIG_VC1_MUXER) += rawenc.o
diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c
index a2ce423..6ff87a8 100644
--- a/libavformat/rawvideodec.c
+++ b/libavformat/rawvideodec.c
@@ -33,6 +33,8 @@ typedef struct RawVideoDemuxerContext {
AVRational framerate; /**< AVRational describing framerate, set by a private option. */
} RawVideoDemuxerContext;
+// v210 frame width is padded to multiples of 48
+#define GET_PACKET_SIZE(w, h) (((w + 47) / 48) * 48 * h * 8 / 3)
static int rawvideo_read_header(AVFormatContext *ctx)
{
@@ -85,6 +87,12 @@ static int rawvideo_read_header(AVFormatContext *ctx)
}
st->codecpar->codec_tag = tag;
packet_size = s->width * s->height * pgroup / xinc;
+ } else if ((ctx->iformat->raw_codec_id == AV_CODEC_ID_V210) ||
+ (ctx->iformat->raw_codec_id == AV_CODEC_ID_V210X)) {
+ pix_fmt = ctx->iformat->raw_codec_id == AV_CODEC_ID_V210 ?
+ AV_PIX_FMT_YUV422P10 : AV_PIX_FMT_YUV422P16;
+
+ packet_size = GET_PACKET_SIZE(s->width, s->height);
} else {
packet_size = av_image_get_buffer_size(pix_fmt, s->width, s->height, 1);
if (packet_size < 0)
@@ -161,3 +169,38 @@ const AVInputFormat ff_bitpacked_demuxer = {
.priv_class = &bitpacked_demuxer_class,
};
#endif // CONFIG_BITPACKED_DEMUXER
+
+static const AVClass v210_demuxer_class = {
+ .class_name = "v210(x) demuxer",
+ .item_name = av_default_item_name,
+ .option = rawvideo_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+#if CONFIG_V210_DEMUXER
+const AVInputFormat ff_v210_demuxer = {
+ .name = "v210",
+ .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"),
+ .priv_data_size = sizeof(RawVideoDemuxerContext),
+ .read_header = rawvideo_read_header,
+ .read_packet = rawvideo_read_packet,
+ .flags = AVFMT_GENERIC_INDEX,
+ .extensions = "v210",
+ .raw_codec_id = AV_CODEC_ID_V210,
+ .priv_class = &v210_demuxer_class,
+};
+#endif // CONFIG_V210_DEMUXER
+
+#if CONFIG_V210X_DEMUXER
+const AVInputFormat ff_v210x_demuxer = {
+ .name = "v210x",
+ .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"),
+ .priv_data_size = sizeof(RawVideoDemuxerContext),
+ .read_header = rawvideo_read_header,
+ .read_packet = rawvideo_read_packet,
+ .flags = AVFMT_GENERIC_INDEX,
+ .extensions = "yuv10",
+ .raw_codec_id = AV_CODEC_ID_V210X,
+ .priv_class = &v210_demuxer_class,
+};
+#endif // CONFIG_V210X_DEMUXER
--
1.8.3.1
_______________________________________________
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".
next prev parent reply other threads:[~2021-12-22 23:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1639492513-12002-1-git-send-email-lance.lmwang@gmail.com>
2021-12-21 13:13 ` [FFmpeg-devel] [PATCH] avformat: add bitpacked demuxer lance.lmwang
2021-12-21 13:20 ` Andreas Rheinhardt
2021-12-21 13:34 ` lance.lmwang
2021-12-22 13:38 ` Andreas Rheinhardt
2021-12-22 14:01 ` lance.lmwang
2021-12-22 23:03 ` [FFmpeg-devel] [PATCH v2 1/3] " lance.lmwang
2021-12-22 23:03 ` lance.lmwang [this message]
2021-12-22 23:03 ` [FFmpeg-devel] [PATCH v2 3/3] avformat: remove unused v210.c lance.lmwang
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=1640214184-12529-2-git-send-email-lance.lmwang@gmail.com \
--to=lance.lmwang@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