[FFmpeg-devel] [RFC][PATCH] return packets for known codecs earlier when codec probing is done

Baptiste Coudurier baptiste.coudurier
Thu May 28 02:47:22 CEST 2009


On 5/27/2009 5:10 PM, Michael Niedermayer wrote:
> On Wed, May 27, 2009 at 04:40:49PM -0700, Baptiste Coudurier wrote:
>> On 5/27/2009 3:00 PM, Michael Niedermayer wrote:
>>> On Wed, May 27, 2009 at 12:54:27AM -0700, Baptiste Coudurier wrote:
>>>> Hi Michael,
>>>>
>>>> Michael Niedermayer wrote:
>>>>> [...]
>>>>>
>>>>>> @@ -537,10 +537,18 @@ int av_read_packet(AVFormatContext *s, AVPacket *p
>>>>>>  
>>>>>>          av_init_packet(pkt);
>>>>>>          ret= s->iformat->read_packet(s, pkt);
>>>>>> -        if (ret < 0)
>>>>>> -            return ret;
>>>>>> +        if (ret < 0) {
>>>>>> +            if (!pktl)
>>>>>> +                return ret;
>>>>>> +            for (i = 0; i < s->nb_streams; i++)
>>>>>> +                if (s->streams[i]->codec->codec_id == CODEC_ID_PROBE)
>>>>>> +                    s->streams[i]->codec->codec_id = CODEC_ID_NONE;
>>>>>> +            continue;
>>>>>> +        }
>>>>> i dont like this
>>>>>
>>>> Well, we have a problem if probe_packets is not 0 when eof is reached.
>>>> Do you see another way to avoid this ?
>>> is this special case really relevant?
>>> it just looses data on streams when all of the following is true
>>> * stream is set to CODEC_ID_PROBE
>>> * stream contains less than 100 packets in the whole file
>>> * probing fails even with all packets in the whole file
>> I think it is:
>> code will call av_read_packet until st->probe_packets is 0, which will
>> provoke an infinite loop.
> 
> hmm, i must be missing something, as i thought the packets would just never
> be output and the player would end at EOF in whichever way it did before the
> patch

Before the patch, ie currently, if EOF is reach, packets are not outputed.
This is a bug IMHO.

When EOF is reached, all packets must be outputed that's what the patch
is trying to achieve, but for this it needs to specify in some way to
ingnore CODEC_ID_PROBE since it failed.
!st->probe_packets is not sufficient since it might not be 0 when EOF is
reached. We have to find a way at EOF to specify that CODEC_ID_PROBE
must be ignored.

So either at EOF:
- CODEC_ID_PROBE is changed to CODEC_ID_NONE.
- st->probe_packets is set to 0

>> We have to stop in some way. EOF means, CODEC_ID_PROBE is now CODEC_ID_NONE.
> 
> This leads to probe failure if the user seeks to short before EOF

Yes, do you prefer to keep CODEC_ID_PROBE ?
I don't mind personally, I'll just set probe_packets to 0 instead.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list