[FFmpeg-devel] [PATCH 2/2] avformat/flvdec: re enable flv_data_packet() and use AVMEDIA_TYPE_SUBTITLE

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Fri Mar 13 13:49:39 CET 2015


On 21.01.2015 00:10, Michael Niedermayer wrote:
> Found-by: kurosu
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libavformat/flvdec.c |   15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 572268f..f98cb97 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -482,7 +482,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
>                           0 <= (int)(num_val * 1024.0))
>                      acodec->bit_rate = num_val * 1024.0;
>                  else if (!strcmp(key, "datastream")) {
> -                    AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA);
> +                    AVStream *st = create_stream(s, AVMEDIA_TYPE_SUBTITLE);
>                      if (!st)
>                          return AVERROR(ENOMEM);
>                      st->codec->codec_id = AV_CODEC_ID_TEXT;
> @@ -749,12 +749,12 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
>  
>      for (i = 0; i < s->nb_streams; i++) {
>          st = s->streams[i];
> -        if (st->codec->codec_type == AVMEDIA_TYPE_DATA)
> +        if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
>              break;
>      }
>  
>      if (i == s->nb_streams) {
> -        st = create_stream(s, AVMEDIA_TYPE_DATA);
> +        st = create_stream(s, AVMEDIA_TYPE_SUBTITLE);
>          if (!st)
>              return AVERROR(ENOMEM);
>          st->codec->codec_id = AV_CODEC_ID_TEXT;

The changes above seem to be unrelated to those below, so please split.
Also there are more occurrences of AVMEDIA_TYPE_DATA in flvdec.c.
Why are those not changed as well?

> @@ -830,11 +830,14 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
>                  goto skip;
>          } else if (type == FLV_TAG_TYPE_META) {
>              stream_type=FLV_STREAM_TYPE_DATA;
> -            if (size > 13 + 1 + 4 && dts == 0) { // Header-type metadata stuff
> +            if (size > 13 + 1 + 4) { // Header-type metadata stuff
> +                int type;
>                  meta_pos = avio_tell(s->pb);
> -                if (flv_read_metabody(s, next) <= 0) {
> +                type = flv_read_metabody(s, next);
> +                if (type == 0 && dts == 0 || type < 0) {
>                      goto skip;
> -                }
> +                } else if (type == TYPE_ONTEXTDATA)
> +                    return flv_data_packet(s, pkt, dts, next);
>                  avio_seek(s->pb, meta_pos, SEEK_SET);
>              }
>          } else {
> 

The only difference to my attempt to fix this is the handling of dts == 0.
I think it's more correct in this patch, so this part looks good to me.

Best regards,
Andreas


More information about the ffmpeg-devel mailing list