[vlc-devel] [RFC PATCH 7/7] mediacodec: WIP reopen MediaCodec if sps changes

Francois Cartegnie fcvlcdev at free.fr
Fri Apr 24 15:52:26 CEST 2015


Le 23/04/2015 19:30, Thomas Guillem a écrit :
> +    if (p_dec->fmt_in.i_codec == VLC_CODEC_H264 && p_block)
> +    {
> +        uint8_t *p_sps, *p_pps;
> +        size_t i_sps, i_pps;
> +
> +        if (h264_get_spspps(p_block->p_buffer, p_block->i_buffer,
> +                            &p_sps, &i_sps, &p_pps, &i_pps) == 0)
> +        {
> +            struct nal_sps sps;
> +
> +            if (h264_parse_sps(p_sps, i_sps, &sps) == 0)
> +            {
> +                if (sps.i_id != p_sys->i_sps_id)
> +                {
> +                    msg_Warn(p_dec, "found a new SPS, restart MediaCodec");
> +                    if (p_sys->codec)
> +                        CloseMediaCodec(p_dec, env);
> +
> +                    if (p_sys->p_extra_buffer)
> +                        free(p_sys->p_extra_buffer);
> +                    p_sys->p_extra_buffer = malloc(i_sps);
> +                    if (p_sys->p_extra_buffer)
> +                    {
> +                        memcpy(p_sys->p_extra_buffer, p_sps, i_sps);
> +                        p_sys->i_extra_buffer = i_sps;
> +                    }
> +
> +                    p_sys->i_sps_id = sps.i_id;
> +                    p_sys->i_width = sps.i_width;
> +                    p_sys->i_height = sps.i_height;
> +                    if (p_sys->i_width != 0 && p_sys->i_height != 0)
> +                        b_delayed_open = true;
> +                }
> +            }
> +        }
> +
> +    }

If I understood correctly, you might want:

if (p_sys->i_width != 0 && p_sys->i_height != 0)
   b_delayed_open = true;

while(b_delayed_open == true && !sps && !pps)
{
	h264_get_spspps
	{
	}
}




More information about the vlc-devel mailing list