[Ffmpeg-devel] [PATCH] file length handling
Michael Niedermayer
michaelni
Mon Dec 18 19:30:57 CET 2006
Hi
On Mon, Dec 18, 2006 at 09:20:49AM -0500, Ronald S. Bultje wrote:
> Hi,
>
> attached patch adds a file_size value to URIContext and ByteIOContext
> (which sets it to 0 or copies it from URIContext), and uses it
> preferentially over using seek_end,-1 to retrieve filesize. This is
> useful for http, where seeking may not always be possible, but the size
> of the file could still be known through the Content-Length or
> Content-Range values in the reply-header.
> The patch also adds handling of Content-Length/Range to http.c. I've
> also taken the freedom to set it to -1 for tcp/udp/rtp/pipe, although it
> really won't make any difference.
> Since it changes ABI, I've also increased LIBAVFORMAT_VERSION_INT.
>
> Cheers,
> Ronald
> Index: ffmpeg-mpe/libavformat/avformat.h
> ===================================================================
> --- ffmpeg-mpe.orig/libavformat/avformat.h 2006-12-18 09:00:24.000000000 -0500
> +++ ffmpeg-mpe/libavformat/avformat.h 2006-12-18 09:00:38.000000000 -0500
> @@ -25,8 +25,8 @@
> extern "C" {
> #endif
>
> -#define LIBAVFORMAT_VERSION_INT ((51<<16)+(6<<8)+0)
> -#define LIBAVFORMAT_VERSION 51.6.0
> +#define LIBAVFORMAT_VERSION_INT ((52<<16)+(0<<8)+0)
> +#define LIBAVFORMAT_VERSION 52.0.0
> #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
how is compatibility broken? if it isnt then theres no need to bump
the version number up
>
> #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
[...]
> if (!s->seek)
> return -EPIPE;
> - size = s->seek(s->opaque, -1, SEEK_END) + 1;
> + size = s->seek(s->opaque, -1, SEEK_END)+1;
cosmetic
> s->seek(s->opaque, s->pos, SEEK_SET);
> return size;
> }
> @@ -516,6 +519,7 @@
> }
> s->is_streamed = h->is_streamed;
> s->max_packet_size = max_packet_size;
> + s->file_size = h->file_size;
the copying of possible non constant variables is bad, iam not sure how to
best solve it though, maybe function ptrs would after all be better then a
variable, dunno
> return 0;
> }
>
> Index: ffmpeg-mpe/libavformat/file.c
> ===================================================================
> --- ffmpeg-mpe.orig/libavformat/file.c 2006-12-10 12:54:52.000000000 -0500
> +++ ffmpeg-mpe/libavformat/file.c 2006-12-18 09:02:53.000000000 -0500
> @@ -110,6 +110,7 @@
> #endif
> h->priv_data = (void *)(size_t)fd;
> h->is_streamed = 1;
> + h->file_size = -1;
checking against 0 and setting to -1 wont work
and the default value should be set in url_open() or another common place
(of course only if its nor zeroed anyway...)
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
More information about the ffmpeg-devel
mailing list