[FFmpeg-devel] [RFC] using ByteIOContext with buffer without reading function

Michael Niedermayer michaelni
Fri Mar 20 04:36:04 CET 2009


On Sun, Mar 15, 2009 at 03:53:07PM -0700, Baptiste Coudurier wrote:
> Hi,
> 
> I notice something strange when using ByteIOContext with a supplied
> buffer without read function, reading only.
> 
> aviobuf.c
> init:
>     if(!read_packet && !write_flag){
>         s->pos = buffer_size;
>         s->buf_end = s->buffer + buffer_size;
>     }
> 
> seek:
>     if (!s->must_flush &&
>         offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) {
>         /* can do the seek inside the buffer */
>         s->buf_ptr = s->buffer + offset1;
> 
> mov.c:
>     if(init_put_byte(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL,
> NULL) != 0)
>         goto free_and_return;
> 
> Problem is:
> when you use url_fskip on the ByteIOContext, for example to skip
> everything not read (size is 51, url_fskip(51)), you will end up seeking
> at s->buf_end.
> 
> However the condition in "seek" won't allow this since offset1 ==
> s->buf_end - s->buffer.
> 
> Would it be better to change init to set buf_end to s->buffer +
> buffer_size + 1 or check for <= in seek ?

i would guess to <= in seek but this should be carefully tested, iam
not sure if this might have some unexpeted sideeffects


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I hate to see young programmers poisoned by the kind of thinking
Ulrich Drepper puts forward since it is simply too narrow -- Roman Shaposhnik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090320/43fdd934/attachment.pgp>



More information about the ffmpeg-devel mailing list