[vlc-commits] mux: mp4: generate AV1 extradata when missing
Francois Cartegnie
git at videolan.org
Fri Dec 21 11:09:01 CET 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Dec 20 15:05:30 2018 +0100| [3d5290f7d2dd99b40e15dbc93d31556f62856957] | committer: Francois Cartegnie
mux: mp4: generate AV1 extradata when missing
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3d5290f7d2dd99b40e15dbc93d31556f62856957
---
modules/mux/Makefile.am | 2 ++
modules/mux/mp4/libmp4mux.c | 8 --------
modules/mux/mp4/mp4.c | 18 ++++++++++++++++++
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/modules/mux/Makefile.am b/modules/mux/Makefile.am
index b3f916bae5..581e8a1dd9 100644
--- a/modules/mux/Makefile.am
+++ b/modules/mux/Makefile.am
@@ -13,6 +13,8 @@ libmux_mp4_plugin_la_SOURCES = mux/mp4/mp4.c \
packetizer/hxxx_nal.c packetizer/hxxx_nal.h \
packetizer/hevc_nal.c packetizer/hevc_nal.h \
packetizer/h264_nal.c packetizer/h264_nal.h
+libmux_mp4_plugin_la_SOURCES += $(extradata_builder_SOURCES)
+
libmux_mpjpeg_plugin_la_SOURCES = mux/mpjpeg.c
libmux_ps_plugin_la_SOURCES = \
mux/mpeg/pes.c mux/mpeg/pes.h \
diff --git a/modules/mux/mp4/libmp4mux.c b/modules/mux/mp4/libmp4mux.c
index 366a989f57..4581417799 100644
--- a/modules/mux/mp4/libmp4mux.c
+++ b/modules/mux/mp4/libmp4mux.c
@@ -2255,15 +2255,7 @@ bool mp4mux_CanMux(vlc_object_t *p_obj, const es_format_t *p_fmt,
case VLC_CODEC_YUYV:
case VLC_CODEC_VC1:
case VLC_CODEC_WMAP:
- break;
case VLC_CODEC_AV1:
- /* Extradata is an AVC1DecoderConfigurationRecord */
- if(p_fmt->i_extra < 4 || ((uint8_t *)p_fmt->p_extra)[0] != 0x81)
- {
- if(p_obj)
- msg_Err(p_obj, "Can't mux AV1 without extradata");
- return false;
- }
break;
case VLC_CODEC_H264:
if(!p_fmt->i_extra && p_obj)
diff --git a/modules/mux/mp4/mp4.c b/modules/mux/mp4/mp4.c
index 506dc3c226..8413a393bf 100644
--- a/modules/mux/mp4/mp4.c
+++ b/modules/mux/mp4/mp4.c
@@ -44,6 +44,7 @@
#include "libmp4mux.h"
#include "../packetizer/hxxx_nal.h"
#include "../av1_pack.h"
+#include "../extradata.h"
/*****************************************************************************
* Module descriptor
@@ -130,6 +131,8 @@ typedef struct
mp4mux_trackinfo_t *tinfo;
const es_format_t *p_fmt;
+ mux_extradata_builder_t *extrabuilder;
+
/* index */
vlc_tick_t i_length_neg;
@@ -177,6 +180,9 @@ typedef struct
static void mp4_stream_Delete(mp4_stream_t *p_stream)
{
+ if(p_stream->extrabuilder)
+ mux_extradata_builder_Delete(p_stream->extrabuilder);
+
/* mp4 frag */
if (p_stream->p_held_entry)
{
@@ -520,6 +526,7 @@ static int AddStream(sout_mux_t *p_mux, sout_input_t *p_input)
return VLC_ENOMEM;
}
+ p_stream->extrabuilder = mux_extradata_builder_New(p_input->p_fmt->i_codec);
p_stream->p_fmt = p_input->p_fmt;
p_input->p_sys = p_stream;
@@ -602,6 +609,17 @@ static block_t * BlockDequeue(sout_input_t *p_input, mp4_stream_t *p_stream)
if(unlikely(!p_block))
return NULL;
+ /* Create on the fly extradata as packetizer is not in the loop */
+ if(p_stream->extrabuilder && !mp4mux_track_HasSamplePriv(p_stream->tinfo))
+ {
+ mux_extradata_builder_Feed(p_stream->extrabuilder,
+ p_block->p_buffer, p_block->i_buffer);
+ const uint8_t *p_extra;
+ size_t i_extra = mux_extradata_builder_Get(p_stream->extrabuilder, &p_extra);
+ if(i_extra)
+ mp4mux_track_SetSamplePriv(p_stream->tinfo, p_extra, i_extra);
+ }
+
switch(p_stream->p_fmt->i_codec)
{
case VLC_CODEC_AV1:
More information about the vlc-commits
mailing list