[FFmpeg-devel] [PATCH] mpegts: Return AVERROR(EAGAIN) instead of -1 if there isn't enough data

Ronald S. Bultje rsbultje
Fri Oct 15 17:38:48 CEST 2010


Hi,

On Thu, Oct 14, 2010 at 5:28 PM, Martin Storsj? <martin at martin.st> wrote:
> On Wed, 13 Oct 2010, Ronald S. Bultje wrote:
>> On Wed, Oct 13, 2010 at 3:45 PM, Martin Storsj? <martin at martin.st> wrote:
>> > On Wed, 13 Oct 2010, Ronald S. Bultje wrote:
>> >> On Wed, Oct 13, 2010 at 3:32 PM, Martin Storsj? <martin at martin.st> wrote:
>> >> > On Wed, 13 Oct 2010, Baptiste Coudurier wrote:
>> >> >> On 10/13/2010 01:52 AM, Martin Storsjo wrote:
>> >> >> > This makes the rtpdec queue code able to process packets more efficiently,
>> >> >> > keeping the queue shorter, by parsing the next packet instead of returning
>> >> >> > the unidentified error code -1 as an error.
>> >> >> > ---
>> >> >> > ? libavformat/mpegts.c | ? ?2 +-
>> >> >> > ? 1 files changed, 1 insertions(+), 1 deletions(-)
>> >> >> >
>> >> >> > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
>> >> >> > index d2f9f1e..13a9908 100644
>> >> >> > --- a/libavformat/mpegts.c
>> >> >> > +++ b/libavformat/mpegts.c
>> >> >> > @@ -1742,7 +1742,7 @@ int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket
>> >> >> > *pkt,
>> >> >> > ? ? ? ? ? if (ts->stop_parse>0)
>> >> >> > ? ? ? ? ? ? ? break;
>> >> >> > ? ? ? ? ? if (len< ?TS_PACKET_SIZE)
>> >> >> > - ? ? ? ? ? ?return -1;
>> >> >> > + ? ? ? ? ? ?return AVERROR(EAGAIN);
>> >> >> > ? ? ? ? ? if (buf[0] != 0x47) {
>> >> >> > ? ? ? ? ? ? ? buf++;
>> >> >> > ? ? ? ? ? ? ? len--;
>> >> >>
>> >> >> Nope, if we couldn't read TS_PACKET_SIZE, it is an error, there is no need to
>> >> >> retry.
>> >> >
>> >> > Well then, could this piece of code return some other specific error code,
>> >> > not just the generic -1, so that the caller knows that the actual error is
>> >> > "not enough data provided"?
>> >>
>> >> Sounds a lot like what I had with rtp/asf, see the custom
>> >> ByteIOContext read handlers in rtpdec_asf.c, might be useful and was
>> >> acceptable to Michael, who voiced similar concerns.
>> >
>> > Those routines also seem to use AVERROR(EAGAIN) for this situation.
>>
>> Right, but the code is in rtp*.c, not in asf*.c.
>
> Ok, so here is what it would look like handling this the way Luca B
> requested, but within rtpdec instead of changing ff_mpegts_parse_packet.
>
> Ronald, Luca, is this ok?

It's probably OK. Is there a particular reason that returning anything
else than EAGAIN only caused issues for mpegts, as opposed to, say,
RTP/ASF?

Ronald



More information about the ffmpeg-devel mailing list