diff mbox series

[FFmpeg-devel,v3,10/11] avformat: add h266/vvc muxer

Message ID 20210111163319.13387-11-nuomi2021@gmail.com
State Superseded
Headers show
Series add vvc raw demuxer, muxer, parser, metadata bsf | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Nuo Mi Jan. 11, 2021, 4:33 p.m. UTC
---
 libavformat/Makefile     |  1 +
 libavformat/allformats.c |  1 +
 libavformat/rawenc.c     | 25 +++++++++++++++++++++++++
 3 files changed, 27 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 4a5406da38..0253aa7d5a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -564,6 +564,7 @@  OBJS-$(CONFIG_VPK_DEMUXER)               += vpk.o
 OBJS-$(CONFIG_VPLAYER_DEMUXER)           += vplayerdec.o subtitles.o
 OBJS-$(CONFIG_VQF_DEMUXER)               += vqf.o
 OBJS-$(CONFIG_VVC_DEMUXER)               += vvcdec.o rawdec.o
+OBJS-$(CONFIG_VVC_MUXER)                 += rawenc.o
 OBJS-$(CONFIG_W64_DEMUXER)               += wavdec.o w64.o pcm.o
 OBJS-$(CONFIG_W64_MUXER)                 += wavenc.o w64.o
 OBJS-$(CONFIG_WAV_DEMUXER)               += wavdec.o pcm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index fdbf424e31..ae9a98a18e 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -463,6 +463,7 @@  extern AVInputFormat  ff_vpk_demuxer;
 extern AVInputFormat  ff_vplayer_demuxer;
 extern AVInputFormat  ff_vqf_demuxer;
 extern AVInputFormat  ff_vvc_demuxer;
+extern AVOutputFormat ff_vvc_muxer;
 extern AVInputFormat  ff_w64_demuxer;
 extern AVOutputFormat ff_w64_muxer;
 extern AVInputFormat  ff_wav_demuxer;
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 32704f9bfd..5eb95f069c 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -372,6 +372,31 @@  AVOutputFormat ff_hevc_muxer = {
 };
 #endif
 
+#if CONFIG_VVC_MUXER
+static int vvc_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
+{
+    if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
+                          AV_RB24(pkt->data) != 0x000001) {
+        //TODO: fixed this after vvc codec defined in http://mp4ra.org/#/codecs
+        av_log(s, AV_LOG_ERROR, "vvc: mp4 to annexb is not supported\n");
+        return AVERROR_PATCHWELCOME;
+    }
+    return 1;
+}
+
+AVOutputFormat ff_vvc_muxer = {
+    .name              = "vvc",
+    .long_name         = NULL_IF_CONFIG_SMALL("raw VVC video"),
+    .extensions        = "hevc,h266,266",
+    .audio_codec       = AV_CODEC_ID_NONE,
+    .video_codec       = AV_CODEC_ID_VVC,
+    .write_header      = force_one_stream,
+    .write_packet      = ff_raw_write_packet,
+    .check_bitstream   = vvc_check_bitstream,
+    .flags             = AVFMT_NOTIMESTAMPS,
+};
+#endif
+
 #if CONFIG_M4V_MUXER
 AVOutputFormat ff_m4v_muxer = {
     .name              = "m4v",