Opened 5 years ago

Closed 5 years ago

#861 closed defect (fixed)

problem with ffio_limit

Reported by: exobuzz Owned by:
Priority: normal Component: avformat
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

since ffmpeg commit 27d323577c19af218f8a5ac33364f213b623a023 dvd playback (via libdvdnav) with xbmc4xbox hasn't worked. I have reverted this commit and all is fine. When the code has got to

if(s->maxsize>=0 && remaining+1 < size){

remaining is a negative number and so the size is reest.

when entering the function ffio_limit

s->maxsize is 0
avio_tell(s) is a gradually increasing number as each packet is processed (i assume this is called for each packet of data ?)

avio_size(s) returns 0.

I assume this is related to the way ffmpeg is being used by the xbmc4xbox code, and so the size is not known, so I guess this function needs a check for that, or we need to pass ffmpeg some additional information?

in anycase, when the code

size= remaining+1;

is run and size is set to for example -2354555 you can imagine things don't work right.

..

the code before that last commit had

if(s->maxsize>=0 && remaining>=0 && remaining+1 < size){

and so size never got reset as remaining was negative.

  • apologies if my understanding is wrong, as I am not familiar with the ffmpeg code. Please advise me if this is something we need to change in our code, or if ffmpeg should skip this if maxsize / avio_size is 0 for example.

Change History (3)

comment:1 Changed 5 years ago by exobuzz

correction, i mean with the last commit remaining is set to 0 at remaining= FFMAX(remaining, 0); (it is negative) so remaining+1 < size will be true, and size will be set to 1.

comment:2 Changed 5 years ago by exobuzz

something like this would also fix it - I was thinking that the calculation "int64_t remaining= s->maxsize - avio_tell(s);" shouldn't be done anyway if maxsize is 0?

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7248f91..1629c32 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -269,7 +269,7 @@ AVInputFormat *av_find_input_format(const char *short_name)
 
 int ffio_limit(AVIOContext *s, int size)
 {
-    if(s->maxsize>=0){
+    if(s->maxsize>0){
         int64_t remaining= s->maxsize - avio_tell(s);
         if(remaining < size){
             int64_t newsize= avio_size(s);

or perhaps to check both maxsize and avio_size are greater than 0 ?

Last edited 5 years ago by exobuzz (previous) (diff)

comment:3 Changed 5 years ago by michael

  • Reproduced by developer set
  • Resolution set to fixed
  • Status changed from new to closed

Workaround added, avio_size() should not return 0 though when the filesize is not 0. Theres a bug in the io/protocol code that interfaces with ffmpeg probably

Note: See TracTickets for help on using tickets.