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

Thomas Guillem thomas at gllm.fr
Thu Apr 23 21:23:25 CEST 2015



On Thu, Apr 23, 2015, at 20:51, Rémi Denis-Courmont wrote:
> 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.

No I was wrong, It's not the absence of SPS/PPS that make the decoder
crash. It's when you configure MediaCodec with a width and a height of
0. I didn't catch it because I was focused on the absence of SPS/PPS...
If you don't set it, or set an invalid one, the decoder won't output
anything. But it depends on the device/CPU, indeed, some can cope with
the absence of PPS/SPS.
 
> 
> > +                {
> > +                    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/
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list