[libav-stable] flvdec: Don' t read the VP6 header byte when setting codec type based on metadata

Reinhard Tartler siretart at tauware.de
Sat Mar 2 08:26:34 CET 2013


On Fr, Mär 01, 2013 at 23:41:25 (CET), Martin Storsjö  wrote:

> Module: libav
> Branch: master
> Commit: c91c63b5380bf79655c09320774a022f84d76fd5
>
> Author:    Martin Storsjö <martin at martin.st>
> Committer: Martin Storsjö <martin at martin.st>
> Date:      Fri Mar  1 16:30:44 2013 +0200
>
> flvdec: Don't read the VP6 header byte when setting codec type based on metadata
>
> This header byte is only present when actually reading a VP6 frame,
> not when reading the codec type field in the metadata. This
> potential bug has been present since 5b54a90c.
>
> CC: libav-stable at libav.org
> Signed-off-by: Martin Storsjö <martin at martin.st>
>
> ---
>
>  libavformat/flvdec.c |   16 +++++++++-------
>  1 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 7d5ea56..e45a9a2 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -201,7 +201,7 @@ static int flv_same_video_codec(AVCodecContext *vcodec, int flags)
>      return 0;
>  }
>  
> -static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_codecid) {
> +static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_codecid, int read) {
>      AVCodecContext *vcodec = vstream->codec;
>      switch(flv_codecid) {
>          case FLV_CODECID_H263  : vcodec->codec_id = AV_CODEC_ID_FLV1   ; break;
> @@ -211,11 +211,13 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_co
>          case FLV_CODECID_VP6A  :
>              if(flv_codecid == FLV_CODECID_VP6A)
>                  vcodec->codec_id = AV_CODEC_ID_VP6A;
> -            if(vcodec->extradata_size != 1) {
> -                vcodec->extradata_size = 1;
> -                vcodec->extradata = av_malloc(1);
> +            if (read) {
> +                if (vcodec->extradata_size != 1) {
> +                    vcodec->extradata_size = 1;
> +                    vcodec->extradata = av_malloc(1);
> +                }
> +                vcodec->extradata[0] = avio_r8(s->pb);
>              }
> -            vcodec->extradata[0] = avio_r8(s->pb);
>              return 1; // 1 byte body size adjustment for flv_read_packet()
>          case FLV_CODECID_H264:
>              vcodec->codec_id = AV_CODEC_ID_H264;
> @@ -408,7 +410,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
>                  st->codec->codec_id = AV_CODEC_ID_TEXT;
>              } else if (flv->trust_metadata) {
>                  if (!strcmp(key, "videocodecid") && vcodec) {
> -                    flv_set_video_codec(s, vstream, num_val);
> +                    flv_set_video_codec(s, vstream, num_val, 0);
>                  } else
>                  if (!strcmp(key, "audiocodecid") && acodec) {
>                      flv_set_audio_codec(s, astream, acodec, num_val);
> @@ -766,7 +768,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
>              sample_rate = ctx.sample_rate;
>          }
>      }else{
> -        size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK);
> +        size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK, 1);
>      }

OK for stable
-- 
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4


More information about the libav-stable mailing list