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

Michael Niedermayer michaelni
Tue Mar 20 01:54:46 CET 2007


Hi

On Sun, Mar 18, 2007 at 06:40:20PM -0500, John Donaghy wrote:
> >search for several valid frames in a row, the AVParser for AC3 can find
> the
> >size of each, there should be a matching header immedeatly after that
> AFAIK
> >see mp3_read_probe()
> 
> How about this version which relies on Justin Ruggles updated ac3 probe
> function which appears to work well?
> 
> John

[...]

> Index: utils.c
> ===================================================================
> --- utils.c	(revision 8441)
> +++ utils.c	(working copy)
> @@ -21,7 +21,7 @@
>  #include "avformat.h"
>  #include "allformats.h"
>  #include "opt.h"
> -
> +#include "mpegaudio.h"
>  #undef NDEBUG

including a random mp3 related header from libavcodec in libavformat/utils.c
is something i would like to avoid, please remove this
also isnt the frame size from the asf-wav header correct?


>  #include <assert.h>
>  
> @@ -1671,9 +1671,13 @@
>      offset_t old_offset = url_ftell(&ic->pb);
>      int64_t codec_info_duration[MAX_STREAMS]={0};
>      int codec_info_nb_frames[MAX_STREAMS]={0};
> +    AVProbeData probe_data, *pd = &probe_data;
>  
>      duration_error = av_mallocz(MAX_STREAMS * sizeof(*duration_error));
>      if (!duration_error) return AVERROR_NOMEM;
> +    pd->filename = "";
> +    pd->buf = NULL;
> +    pd->buf_size = 0;

this data must be per stream


>  
>      for(i=0;i<ic->nb_streams;i++) {
>          st = ic->streams[i];
> @@ -1711,6 +1715,10 @@
>                  break;
>              if(st->parser && st->parser->parser->split && !st->codec->extradata)
>                  break;
> +            if (st->codec->codec_type == CODEC_TYPE_AUDIO &&
> +                st->codec->codec_id == CODEC_ID_NONE) {
> +                break;
> +            }
>          }
>          if (i == ic->nb_streams) {
>              /* NOTE: if the format has no header, then we need to read
> @@ -1796,6 +1804,22 @@
>              }
>              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) {
> +                pd->buf = av_realloc(pd->buf, read_size);

read_size is the size of all streams not of a specific stream


> +                memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);
> +                pd->buf_size = read_size;
> +
> +                if (mp3_read_probe(pd) > 1) {
> +                    st->codec->codec_id = CODEC_ID_MP3;
> +                    st->codec->frame_size = MPA_FRAME_SIZE;
> +                } else if (ac3_probe(pd) > 1){
> +                    st->codec->codec_id = CODEC_ID_AC3;

> +                    st->codec->frame_size = 1;

this frame size is wrong


> +                }
> +                st->codec->codec_tag = codec_get_wav_tag(st->codec->codec_id);

this is wrong you cannot just override codec_tag at will
also i dont see why that would be needed


[...]
> Index: mp3.c
> ===================================================================
> --- mp3.c	(revision 8441)
> +++ mp3.c	(working copy)
> @@ -243,8 +243,7 @@
>  }
>  
>  /* mp3 read */
> -
> -static int mp3_read_probe(AVProbeData *p)
> +int mp3_read_probe(AVProbeData *p)
>  {

all no static functions need a ff_ or av_ prefix to avoid name clashes
here a ff_ prefix is the correct one


[...]
> @@ -407,7 +407,7 @@
>      return 0;
>  }
>  
> -static int ac3_probe(AVProbeData *p)
> +int ac3_probe(AVProbeData *p)
>  {

this also needs a ff_ prefix

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070320/d26762e7/attachment.pgp>



More information about the ffmpeg-devel mailing list