Opened 13 years ago

Closed 13 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 by exobuzz, 13 years ago

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 by exobuzz, 13 years ago

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?

[code]
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);

code

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

Version 1, edited 13 years ago by exobuzz (previous) (next) (diff)

comment:3 by Michael Niedermayer, 13 years ago

Reproduced by developer: set
Resolution: fixed
Status: newclosed

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.