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

Michael Niedermayer michaelni
Mon Apr 9 02:43:44 CEST 2007


Hi

On Sun, Apr 08, 2007 at 09:48:26AM -0500, John Donaghy wrote:
> >
> >iam fine with either that is as long as it works, no seek no flush is of
> >course nicer if it mostly works
> 
> 
> Jon Elwood (who is working on DVRMSToolbox to make it use mencoder as the
> default way of converting dvr-ms files) has extensively tested this patch
> and discovered that it wasnt always possible to avoid a seek and flush
> without sync issues.
> 
> He also discovered that the probe functions sometimes return 1 rather than a
> value greater than 1 on the audio data I provide. (I would have expected
> higher values in all cases.) So this version first tries to detect the audio
> stream type by looking for a value > 1 and then, if that fails, it looks for
> a probe result of '1' to determine the stream type. It works for all Jon's
> samples.
> 
> I also had to do a url_fseek after the flush to avoid and output errors.
> 
> Let me know if all of this is acceptable.
> 
> Finally I removed the line that sets the format tag and consequently this
> will not work with the lavf demuxer in mplayer. So I will attempt to fix
> this and I'll raise a bug if I cant.
[...]
> Index: utils.c
> ===================================================================
> --- utils.c	(revision 8646)
> +++ utils.c	(working copy)
> @@ -1662,6 +1662,10 @@
>      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[MAX_STREAMS];
> +    int codec_identified[MAX_STREAMS]={0};

> +    int stream_needs_parsing[MAX_STREAMS]={0};

what is this good for?


> +    int need_flush=0;
>  
>      duration_error = av_mallocz(MAX_STREAMS * sizeof(*duration_error));
>      if (!duration_error) return AVERROR_NOMEM;
> @@ -1681,10 +1685,14 @@
>                  st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
>              }
>          }
> +        stream_needs_parsing[st->index] = st->need_parsing;
>      }
>  
>      for(i=0;i<MAX_STREAMS;i++){
>          last_dts[i]= AV_NOPTS_VALUE;
> +        probe_data[i].filename = "";
> +        probe_data[i].buf = NULL;
> +        probe_data[i].buf_size = 0;
>      }

memset(0) is simpler


>  
>      count = 0;
> @@ -1702,6 +1710,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
> @@ -1787,6 +1799,24 @@
>              }
>              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) {
> +                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;
> +
> +                if (ff_mp3_read_probe(pd) > 1) {
> +                    st->codec->codec_id = CODEC_ID_MP3;
> +                    codec_identified[st->index] = 1;
> +                    need_flush = 1;
> +                } else if (ff_ac3_probe(pd) > 1){
> +                    st->codec->codec_id = CODEC_ID_AC3;
> +                    codec_identified[st->index] = 1;
> +                    need_flush = 1;
> +                }
> +             }
>          }
>          if(st->parser && st->parser->parser->split && !st->codec->extradata){
>              int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
> @@ -1866,12 +1896,40 @@
>                  }
>              }
>          }else if(st->codec->codec_type == CODEC_TYPE_AUDIO) {
> +            if (st->codec->codec_id == CODEC_ID_NONE) {
> +                // If codec wasnt positively identified as mp2/3 or ac3
> +                // then test if it might be ac3 or mp3. 
> +                if (ff_ac3_probe(&(probe_data[st->index])) == 1) {
> +                    st->codec->codec_id = CODEC_ID_AC3;
> +                    codec_identified[st->index] = 1;
> +                    need_flush = 1;
> +                }
> +                else if (ff_mp3_read_probe(&(probe_data[st->index])) == 1) {
> +                    st->codec->codec_id = CODEC_ID_MP3;
> +                    codec_identified[st->index] = 1;
> +                    need_flush = 1;
> +                }
> +            }

code duplication, also the max score should win not some >1 or other random
test
actually, you should rather use av_probe_input_format() instead of this

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

Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- 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/20070409/98987ce5/attachment.pgp>



More information about the ffmpeg-devel mailing list