[Ffmpeg-devel] [PATCH] DVR-MS probe audio format - was DVR-MS bug (MP2 decoding)

John Donaghy johnfdonaghy
Tue Apr 10 00:14:39 CEST 2007


> [...]
> > @@ -1787,6 +1808,18 @@
> >              }
> >              if(last == AV_NOPTS_VALUE || duration_count[index]<=1)
> >                  last_dts[pkt->stream_index]= pkt->dts;
> > +
> > +            if (st->codec->codec_type == CODEC_TYPE_AUDIO &&
> > +                st->codec->codec_id == CODEC_ID_NONE) {
> > +                int score;
> > +                AVProbeData *pd = &(probe_data[st->index]);
> > +                pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size);
> > +                memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);
> > +                pd->buf_size = pd->buf_size+pkt->size;
> > +
> > +                score = pd->buf_size < PROBE_BUF_MAX ?
> AVPROBE_SCORE_MAX/4 : 0;
> > +                codec_identified[st->index] =
> set_codec_from_probe_data(st, pd, score);
> > +             }
> >          }
> >          if(st->parser && st->parser->parser->split &&
> !st->codec->extradata){
> >              int i= st->parser->parser->split(st->codec, pkt->data,
> pkt->size);
> > @@ -1866,12 +1899,28 @@
> >                  }
> >              }
>
> >          }else if(st->codec->codec_type == CODEC_TYPE_AUDIO) {
> > +            if (!codec_identified[st->index])
> > +                codec_identified[st->index] =
> set_codec_from_probe_data(st, &(probe_data[st->index]), 0);
> > +            if (codec_identified[st->index]) {
> > +                st->need_parsing = 1;
> > +            }
>
> why is the code run twice?


This function is called the first time with a score value calculated from
the size of the probe data (as done elsewhere in this file). If no matching
codec is found using the higher score value, it is called the second time
with a score of 0 to look for a probe match of > 0. The reason for this is
that on some data the probe functions return higher definitive values (e.g.
25 or 50) but on other data they return values of 1. In some cases both the
mp3 and ac3 probe functions return 1 but we know from testing that in these
cases the data is always ac3 - i.e the mp3 probe function sometimes returns
a value of 1 on an ac3 stream and the ac3 probe also returns a value of 1 on
the same stream. Perhaps the probe functions need improving and then my code
could be simplified but I dont currently know how to do that.




More information about the ffmpeg-devel mailing list