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

Rémi Denis-Courmont remi at remlab.net
Thu Apr 23 20:51:41 CEST 2015


Le jeudi 23 avril 2015, 19:30:55 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)

Does the decoder crash if the SPS is invalid? Apparently, invalid SPS update 
with identical ID do occur. And well, deliberately invalid or accidentally 
corrupted bit streams occur too.

> +                {
> +                    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;
> +                }
> +            }
> +        }
> +
> +    }
> +
>      /* try delayed opening if there is a new extra data */
>      if (!p_sys->codec)
>      {
> -        bool b_delayed_open = false;
> -
>          switch (p_dec->fmt_in.i_codec)
>          {
>          case VLC_CODEC_VC1:

-- 
Rémi Denis-Courmont
http://www.remlab.net/




More information about the vlc-devel mailing list