[Ffmpeg-devel] [PATCH] flv with streamed ByteIO support
Michael Niedermayer
michaelni
Thu Sep 21 15:55:14 CEST 2006
Hi
On Thu, Sep 21, 2006 at 07:34:17PM +0900, nazo wrote:
> Streamed ByteIO like http can't use url_fskip and url_fseek. So the
> attached patch is implemented url_fskip for streams and changed
> url_fseek to url_fskip. I tested in youtube.
[...]
> - if (av_rescale_q(st->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= MAX_STREAM_DURATION) {
> + if (av_rescale_q(st->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= MAX_STREAM_DURATION
> + || ((&ic->pb)->is_streamed && i==ic->nb_streams)) {
i see no sense in this change
[...]
> - url_fseek(&s->pb, offset, SEEK_SET);
> + url_fskip(&s->pb, offset - url_ftell(&s->pb));
rejected this is the same, or at least should be, if not thats a bug
[...]
> - next= size + url_ftell(&s->pb);
> + next = size + url_ftell(&s->pb);
cosmetic
[...]
> {
> - AVStream *st = s->streams[stream_index];
> - int index = av_index_search_timestamp(st, timestamp, flags);
> + AVStream *st;
> + int index;
> + if(url_is_streamed(s))
> + return -1;
> + st = s->streams[stream_index];
> + index = av_index_search_timestamp(st, timestamp, flags);
rejected this function must not be called if the if() is true
[...]
> +static void fill_buffer(ByteIOContext *s)
> +{
> + int len;
> +
> + /* no need to do anything if EOF already reached */
> + if (s->eof_reached)
> + return;
> +
> + if(s->update_checksum){
> + if(s->buf_end > s->checksum_ptr)
> + s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_end - s->checksum_ptr);
> + s->checksum_ptr= s->buffer;
> + }
> +
> + len = s->read_packet(s->opaque, s->buffer, s->buffer_size);
> + if (len <= 0) {
> + /* 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 {
> + s->pos += len;
> + s->buf_ptr = s->buffer;
> + s->buf_end = s->buffer + len;
> + }
> +}
> +
moving a function around is a purely cosmetical change which is not allowed
unless its 1. needed (its not here) and 2. its a seperate patch
> static void flush_buffer(ByteIOContext *s)
> {
> if (s->buf_ptr > s->buffer) {
> @@ -161,6 +189,14 @@
>
> void url_fskip(ByteIOContext *s, offset_t offset)
> {
> + if(url_is_streamed(s)){
> + while(s->buf_end - s->buf_ptr < offset){
> + offset -= s->buf_end - s->buf_ptr;
> + fill_buffer(s);
> + }
> + s->buf_ptr += offset;
> + return;
> + }
> url_fseek(s, offset, SEEK_CUR);
url_fskip() behavior MUST NOT differ from url_fseek(SEEK_CUR)
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is
More information about the ffmpeg-devel
mailing list