Commit 8c5e5016 authored by Thomas Guillem's avatar Thomas Guillem

mediacodec: refactor StartMediaCodec

Add ParseVideoExtra that parse video extra data for h264/hevc.
Leave room for a possible ParseAudioExtra.
parent 935db7d6
......@@ -330,25 +330,15 @@ static int H264SetCSD(decoder_t *p_dec, void *p_buf, size_t i_size,
return VLC_EGENERIC;
}
/*****************************************************************************
* StartMediaCodec: Create the mediacodec instance
*****************************************************************************/
static int StartMediaCodec(decoder_t *p_dec)
static int ParseVideoExtra(decoder_t *p_dec, uint8_t *p_extra, int i_extra)
{
decoder_sys_t *p_sys = p_dec->p_sys;
int i_ret;
size_t h264_profile = 0;
char *psz_name = NULL;
union mc_api_args args;
if (p_dec->fmt_in.i_extra && !p_sys->p_csd)
{
if (p_dec->fmt_in.i_cat == VIDEO_ES
&& (p_dec->fmt_in.i_codec == VLC_CODEC_H264
|| p_dec->fmt_in.i_codec == VLC_CODEC_HEVC))
if (p_dec->fmt_in.i_codec == VLC_CODEC_H264
|| p_dec->fmt_in.i_codec == VLC_CODEC_HEVC)
{
int buf_size = p_dec->fmt_in.i_extra + 20;
uint32_t size = p_dec->fmt_in.i_extra;
int buf_size = i_extra + 20;
uint32_t size = i_extra;
void *p_buf = malloc(buf_size);
if (!p_buf)
......@@ -359,16 +349,14 @@ static int StartMediaCodec(decoder_t *p_dec)
if (p_dec->fmt_in.i_codec == VLC_CODEC_H264)
{
if (((uint8_t*)p_dec->fmt_in.p_extra)[0] == 1
&& convert_sps_pps(p_dec, p_dec->fmt_in.p_extra,
p_dec->fmt_in.i_extra,
if (p_extra[0] == 1
&& convert_sps_pps(p_dec, p_extra, i_extra,
p_buf, buf_size, &size,
&p_sys->u.video.i_nal_size) == VLC_SUCCESS)
H264SetCSD(p_dec, p_buf, size, NULL);
} else
{
if (convert_hevc_nal_units(p_dec, p_dec->fmt_in.p_extra,
p_dec->fmt_in.i_extra,
if (convert_hevc_nal_units(p_dec, p_extra, i_extra,
p_buf, buf_size, &size,
&p_sys->u.video.i_nal_size) == VLC_SUCCESS)
{
......@@ -381,6 +369,31 @@ static int StartMediaCodec(decoder_t *p_dec)
}
free(p_buf);
}
return VLC_SUCCESS;
}
/*****************************************************************************
* StartMediaCodec: Create the mediacodec instance
*****************************************************************************/
static int StartMediaCodec(decoder_t *p_dec)
{
decoder_sys_t *p_sys = p_dec->p_sys;
int i_ret = 0;
size_t h264_profile = 0;
char *psz_name = NULL;
union mc_api_args args;
if (p_dec->fmt_in.i_extra && !p_sys->p_csd)
{
/* Try first to configure specific Video CSD */
if (p_dec->fmt_in.i_cat == VIDEO_ES)
i_ret = ParseVideoExtra(p_dec, p_dec->fmt_in.p_extra,
p_dec->fmt_in.i_extra);
if (i_ret != VLC_SUCCESS)
return i_ret;
/* Set default CSD if ParseVideoExtra failed to configure one */
if (!p_sys->p_csd)
{
struct csd csd;
......
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