[FFmpeg-devel] [PATCH] Additional probing based on sequence header and group startcodes
Baptiste Coudurier
baptiste.coudurier
Sun Jun 14 10:59:12 CEST 2009
Jai Menon wrote:
> On Sat, Jun 13, 2009 at 10:21 PM, Baptiste
> Coudurier<baptiste.coudurier at gmail.com> wrote:
>> Jai Menon wrote:
>>> On Sat, Jun 13, 2009 at 9:29 PM, Baptiste
>>> Coudurier<baptiste.coudurier at gmail.com> wrote:
>>>> Michael Niedermayer wrote:
>>>>> On Sat, Jun 13, 2009 at 08:27:26PM +0000, Jai Menon wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I'm not too familiar with the probing mechanism so any help is
>>>>>> appreciated. This might not be the right way to do it. Also, this
>>>>>> fixes issue 1185 and possibly others.
>>>>> [...]
>>>>>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>>>>>> index dc18885..0096343 100644
>>>>>> --- a/libavformat/utils.c
>>>>>> +++ b/libavformat/utils.c
>>>>>> @@ -339,6 +339,9 @@ static int set_codec_from_probe_data(AVStream *st, AVProbeData *pd, int score)
>>>>>> } else if (!strcmp(fmt->name, "dts")) {
>>>>>> st->codec->codec_id = CODEC_ID_DTS;
>>>>>> st->codec->codec_type = CODEC_TYPE_AUDIO;
>>>>>> + } else if (!strcmp(fmt->name, "mpeg")) {
>>>>>> + st->codec->codec_id = CODEC_ID_MPEG2VIDEO;
>>>>>> + st->codec->codec_type = CODEC_TYPE_VIDEO;
>>>>>> }
>>>>>> }
>>>>>> return !!fmt;
>>>>> this part is ok and can be commited seperately
>>>> Humm, what if stream contain H264 ? "mpeg" is mpeg ps demuxer.
>>> Do you have any samples where avc isn't muxed with ES type 0x1b set in
>>> the stream map? I had thought about this too and hoped if nothing else
>>> to get a sample. And what should be done in this case? should the
>>> probing be done in the demuxer?
>>>
>> No I don't have a sample. Thing is if "mpeg" matches this does not say
>> that stream contains mpeg2video. This case is handled by mpegvideo
>> probe. If this stream is not matched for a reason, the reason should be
>> in mpegvideo probe.
>
> Thanks for the explanation, I added the modifications to the mpegvideo
> probe code in raw.c.
> Patch attached.
>
>
>
> ------------------------------------------------------------------------
>
> From ab037622f26b512c79c4f0f1edd7c2974ea6368e Mon Sep 17 00:00:00 2001
> From: Jai Menon <jai at retroficial.org>
> Date: Sun, 14 Jun 2009 13:27:29 +0000
> Subject: [PATCH 2/2] add additional probing based on group startcode.
>
> ---
> libavformat/raw.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/raw.c b/libavformat/raw.c
> index f086581..265d9cb 100644
> --- a/libavformat/raw.c
> +++ b/libavformat/raw.c
> @@ -309,6 +309,7 @@ static int mpegvideo_probe(AVProbeData *p)
> {
> uint32_t code= -1;
> int pic=0, seq=0, slice=0, pspack=0, pes=0;
> + int gop = 0;
> int i;
>
> for(i=0; i<p->buf_size; i++){
> @@ -319,13 +320,16 @@ static int mpegvideo_probe(AVProbeData *p)
> case PICTURE_START_CODE: pic++; break;
> case SLICE_START_CODE: slice++; break;
> case PACK_START_CODE: pspack++; break;
> + case GOP_START_CODE: gop++; break;
> }
> if ((code & 0x1f0) == VIDEO_ID) pes++;
> else if((code & 0x1e0) == AUDIO_ID) pes++;
> }
> }
> if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes)
> - return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
> + return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
> + if(pic*9<=slice*10 && pes && !gop)
> + return AVPROBE_SCORE_MAX/2+1;
> return 0;
Humm I don't get it, in mpeg2video, gop start code has good chance to be
present. Why are you checking for !gop and pes. If a pes is present it's
probably PS or TS.
What are you trying to achieve ?
--
Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer http://www.ffmpeg.org
More information about the ffmpeg-devel
mailing list