[FFmpeg-devel] libavformat/aviobuf: don't treat 0 as EOF

Submitted by Daniel Kucera on June 18, 2017, 7:14 p.m.

Details

Message ID 20170618191421.14889-1-daniel.kucera@gmail.com
State New
Headers show

Commit Message

Daniel Kucera June 18, 2017, 7:14 p.m.
Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
---
 libavformat/aviobuf.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

Comments

Michael Niedermayer June 19, 2017, 2:09 p.m.
On Sun, Jun 18, 2017 at 09:14:21PM +0200, Daniel Kucera wrote:
> Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
> ---
>  libavformat/aviobuf.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)

This causes fate-swr-resample-s32p-2626-44100 to infinite loop

[...]
James Almer June 19, 2017, 2:15 p.m.
On 6/19/2017 11:09 AM, Michael Niedermayer wrote:
> On Sun, Jun 18, 2017 at 09:14:21PM +0200, Daniel Kucera wrote:
>> Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
>> ---
>>  libavformat/aviobuf.c | 20 ++++++++++++--------
>>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> This causes fate-swr-resample-s32p-2626-44100 to infinite loop

Why would that one be specifically affected out of the ~50 swr tests? Or
is it that you didn't try others after that one stalled?
Michael Niedermayer June 19, 2017, 2:34 p.m.
On Mon, Jun 19, 2017 at 11:15:27AM -0300, James Almer wrote:
> On 6/19/2017 11:09 AM, Michael Niedermayer wrote:
> > On Sun, Jun 18, 2017 at 09:14:21PM +0200, Daniel Kucera wrote:
> >> Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
> >> ---
> >>  libavformat/aviobuf.c | 20 ++++++++++++--------
> >>  1 file changed, 12 insertions(+), 8 deletions(-)
> > 
> > This causes fate-swr-resample-s32p-2626-44100 to infinite loop
> 
> Why would that one be specifically affected out of the ~50 swr tests? Or
> is it that you didn't try others after that one stalled?

almost every test gets stuck, i just picked a random one

[...]
Daniel Kucera June 19, 2017, 7:30 p.m.
2017-06-19 16:34 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Mon, Jun 19, 2017 at 11:15:27AM -0300, James Almer wrote:
>> On 6/19/2017 11:09 AM, Michael Niedermayer wrote:
>> > On Sun, Jun 18, 2017 at 09:14:21PM +0200, Daniel Kucera wrote:
>> >> Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
>> >> ---
>> >>  libavformat/aviobuf.c | 20 ++++++++++++--------
>> >>  1 file changed, 12 insertions(+), 8 deletions(-)
>> >
>> > This causes fate-swr-resample-s32p-2626-44100 to infinite loop
>>
>> Why would that one be specifically affected out of the ~50 swr tests? Or
>> is it that you didn't try others after that one stalled?
>
> almost every test gets stuck, i just picked a random one
>


It requires following patch to be applied:

libavformat/avio: fix retry_transfer_wrapper return value on error
Hendrik Leppkes June 19, 2017, 8:47 p.m.
On Mon, Jun 19, 2017 at 9:30 PM, Daniel Kučera <daniel.kucera@gmail.com> wrote:
> 2017-06-19 16:34 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
>> On Mon, Jun 19, 2017 at 11:15:27AM -0300, James Almer wrote:
>>> On 6/19/2017 11:09 AM, Michael Niedermayer wrote:
>>> > On Sun, Jun 18, 2017 at 09:14:21PM +0200, Daniel Kucera wrote:
>>> >> Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
>>> >> ---
>>> >>  libavformat/aviobuf.c | 20 ++++++++++++--------
>>> >>  1 file changed, 12 insertions(+), 8 deletions(-)
>>> >
>>> > This causes fate-swr-resample-s32p-2626-44100 to infinite loop
>>>
>>> Why would that one be specifically affected out of the ~50 swr tests? Or
>>> is it that you didn't try others after that one stalled?
>>
>> almost every test gets stuck, i just picked a random one
>>
>
>
> It requires following patch to be applied:
>
> libavformat/avio: fix retry_transfer_wrapper return value on error
>

If patches depend on  each other, please either send them as a series,
or clearly document this somewhere. We can't know otherwise.

- Hendrik

Patch hide | download patch | download mbox

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 1667e9f08b..293a7d3753 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -556,13 +556,14 @@  static void fill_buffer(AVIOContext *s)
     if (s->read_packet)
         len = s->read_packet(s->opaque, dst, len);
     else
-        len = 0;
-    if (len <= 0) {
+        len = AVERROR_EOF;
+    if (len == AVERROR_EOF) {
         /* do not modify buffer if EOF reached so that a seek back can
            be done without rereading data */
         s->eof_reached = 1;
-        if (len < 0)
-            s->error = len;
+    } else if (len < 0) {
+        s->eof_reached = 1;
+        s->error= len;
     } else {
         s->pos += len;
         s->buf_ptr = dst;
@@ -630,13 +631,16 @@  int avio_read(AVIOContext *s, unsigned char *buf, int size)
                 // bypass the buffer and read data directly into buf
                 if(s->read_packet)
                     len = s->read_packet(s->opaque, buf, size);
-
-                if (len <= 0) {
+                else
+                    len = AVERROR_EOF;
+                if (len == AVERROR_EOF) {
                     /* do not modify buffer if EOF reached so that a seek back can
                     be done without rereading data */
                     s->eof_reached = 1;
-                    if(len<0)
-                        s->error= len;
+                    break;
+                } else if (len < 0) {
+                    s->eof_reached = 1;
+                    s->error= len;
                     break;
                 } else {
                     s->pos += len;