Commit 61a8d24b authored by François Cartegnie's avatar François Cartegnie 🤞

mux: mp4: use samplepriv as fallback location for extra

parent 40d59bd8
......@@ -870,17 +870,19 @@ static bo_t *GetD263Tag(void)
return d263;
}
static bo_t *GetHvcCTag(es_format_t *p_fmt, bool b_completeness)
static bo_t *GetHvcCTag(const uint8_t *p_extra, size_t i_extra,
bool b_completeness)
{
/* Generate hvcC box matching iso/iec 14496-15 3rd edition */
bo_t *hvcC = box_new("hvcC");
if(!hvcC || !p_fmt->i_extra)
if(!hvcC || !i_extra)
return hvcC;
/* Extradata is already an HEVCDecoderConfigurationRecord */
if(hevc_ishvcC(p_fmt->p_extra, p_fmt->i_extra))
if(hevc_ishvcC(p_extra, i_extra))
{
(void) bo_add_mem(hvcC, p_fmt->i_extra, p_fmt->p_extra);
(void) bo_add_mem(hvcC, i_extra, p_extra);
return hvcC;
}
......@@ -889,7 +891,7 @@ static bo_t *GetHvcCTag(es_format_t *p_fmt, bool b_completeness)
size_t i_nal;
hxxx_iterator_ctx_t it;
hxxx_iterator_init(&it, p_fmt->p_extra, p_fmt->i_extra, 0);
hxxx_iterator_init(&it, p_extra, i_extra, 0);
while(hxxx_annexb_iterate_next(&it, &p_nal, &i_nal))
{
switch (hevc_getNALType(p_nal))
......@@ -975,12 +977,13 @@ static bo_t *GetWaveFormatExTag(es_format_t *p_fmt, const char *tag)
return box;
}
static bo_t *GetxxxxTag(es_format_t *p_fmt, const char *tag)
static bo_t *GetxxxxTag(const uint8_t *p_extra, size_t i_extra,
const char *tag)
{
bo_t *box = box_new(tag);
if(!box)
return NULL;
bo_add_mem(box, p_fmt->i_extra, p_fmt->p_extra);
bo_add_mem(box, i_extra, p_extra);
return box;
}
......@@ -1028,7 +1031,7 @@ static bo_t *GetClli(const video_format_t *p_vfmt)
return p_box;
}
static bo_t *GetAvcCTag(es_format_t *p_fmt)
static bo_t *GetAvcCTag(const uint8_t *p_extra, size_t i_extra)
{
bo_t *avcC = box_new("avcC");/* FIXME use better value */
if(!avcC)
......@@ -1036,7 +1039,7 @@ static bo_t *GetAvcCTag(es_format_t *p_fmt)
const uint8_t *p_sps, *p_pps, *p_ext;
size_t i_sps_size, i_pps_size, i_ext_size;
if(! h264_AnnexB_get_spspps(p_fmt->p_extra, p_fmt->i_extra,
if(! h264_AnnexB_get_spspps(p_extra, i_extra,
&p_sps, &i_sps_size,
&p_pps, &i_pps_size,
&p_ext, &i_ext_size ) )
......@@ -1093,15 +1096,15 @@ static bo_t *GetAvcCTag(es_format_t *p_fmt)
}
/* TODO: No idea about these values */
static bo_t *GetSVQ3Tag(es_format_t *p_fmt)
static bo_t *GetSVQ3Tag(const uint8_t *p_extra, size_t i_extra)
{
bo_t *smi = box_new("SMI ");
if(!smi)
return NULL;
if (p_fmt->i_extra > 0x4e) {
uint8_t *p_end = &((uint8_t*)p_fmt->p_extra)[p_fmt->i_extra];
uint8_t *p = &((uint8_t*)p_fmt->p_extra)[0x46];
if (i_extra > 0x4e) {
const uint8_t *p_end = &p_extra[i_extra];
const uint8_t *p = &p_extra[0x46];
while (p + 8 < p_end) {
int i_size = GetDWBE(p);
......@@ -1254,14 +1257,23 @@ static bo_t *GetSounBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
if (b_descr) {
bo_t *box;
/* codec specific extradata */
const uint8_t *p_extradata = p_track->fmt.p_extra;
size_t i_extradata = p_track->fmt.i_extra;
if(p_track->sample_priv.i_data)
{
p_extradata = p_track->sample_priv.p_data;
i_extradata = p_track->sample_priv.i_data;
}
if (b_mov && codec == VLC_CODEC_MP4A)
box = GetWaveTag(p_track);
else if (codec == VLC_CODEC_AMR_NB)
box = GetDamrTag(&p_track->fmt);
else if (codec == VLC_CODEC_A52)
box = GetDac3Tag(p_track->sample_priv.p_data, p_track->sample_priv.i_data);
box = GetDac3Tag(p_extradata, i_extradata);
else if (codec == VLC_CODEC_EAC3)
box = GetDec3Tag(&p_track->fmt, p_track->sample_priv.p_data, p_track->sample_priv.i_data);
box = GetDec3Tag(&p_track->fmt, p_extradata, i_extradata);
else if (codec == VLC_CODEC_WMAP)
box = GetWaveFormatExTag(&p_track->fmt, "wfex");
else
......@@ -1337,11 +1349,20 @@ static bo_t *GetVideBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
bo_add_16be(vide, 0x18); // depth
bo_add_16be(vide, 0xffff); // predefined
/* codec specific extradata */
const uint8_t *p_extradata = p_track->fmt.p_extra;
size_t i_extradata = p_track->fmt.i_extra;
if(p_track->sample_priv.i_data)
{
p_extradata = p_track->sample_priv.p_data;
i_extradata = p_track->sample_priv.i_data;
}
/* add an ES Descriptor */
switch(p_track->fmt.i_codec)
{
case VLC_CODEC_AV1:
box_gather(vide, GetxxxxTag(&p_track->fmt, "av1C"));
box_gather(vide, GetxxxxTag(p_extradata, i_extradata, "av1C"));
box_gather(vide, GetColrBox(&p_track->fmt.video, b_mov));
box_gather(vide, GetMdcv(&p_track->fmt.video));
box_gather(vide, GetClli(&p_track->fmt.video));
......@@ -1357,20 +1378,20 @@ static bo_t *GetVideBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
break;
case VLC_CODEC_SVQ3:
box_gather(vide, GetSVQ3Tag(&p_track->fmt));
box_gather(vide, GetSVQ3Tag(p_extradata, i_extradata));
break;
case VLC_CODEC_H264:
box_gather(vide, GetAvcCTag(&p_track->fmt));
box_gather(vide, GetAvcCTag(p_extradata, i_extradata));
break;
case VLC_CODEC_VC1:
box_gather(vide, GetxxxxTag(&p_track->fmt, "dvc1"));
box_gather(vide, GetxxxxTag(p_extradata, i_extradata, "dvc1"));
break;
case VLC_CODEC_HEVC:
/* Write HvcC without forcing VPS/SPS/PPS/SEI array_completeness */
box_gather(vide, GetHvcCTag(&p_track->fmt, false));
box_gather(vide, GetHvcCTag(p_extradata, i_extradata, false));
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment