[Ffmpeg-devel] privatizing FifoBuffer into libavutil -- take II
Michael Niedermayer
michaelni
Tue Sep 19 12:37:08 CEST 2006
Hi
On Mon, Sep 18, 2006 at 11:49:23PM -0700, Roman Shaposhnik wrote:
> Please review and comment.
>
> Thanks,
> Roman.
>
> P.S. Since patch was generated after 'svn cp' I'm attaching actual
> fifo.[ch] for the ease of review.
[...]
>
> -int fifo_size(FifoBuffer *f, uint8_t *rptr)
> +int av_fifo_size(AVFifoBuffer *f)
> {
> int size;
>
[...]
> + if (f->wptr >= f->rptr) {
> + size = f->wptr - f->rptr;
> } else {
[...]
> + size = (f->end - f->rptr) + (f->wptr - f->buffer);
> }
int size = f->wptr - f->rptr;
if(size<0)
size += f->end - f->buffer;
is simpler, same for the other such pieces of code
[...]
> -void fifo_write(FifoBuffer *f, const uint8_t *buf, int size, uint8_t **wptr_ptr)
> +void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
> {
> int len;
> - uint8_t *wptr;
>
> - if(!wptr_ptr)
> - wptr_ptr= &f->wptr;
> - wptr = *wptr_ptr;
> -
> while (size > 0) {
> - len = f->end - wptr;
> + len = f->end - f->wptr;
> if (len > size)
> len = size;
len= FFMIN(f->end - f->wptr, size)
[...]
> +void av_fifo_drain(AVFifoBuffer *f, int size)
> {
> - char buf[1024];
> - return filename && (av_get_frame_filename(buf, sizeof(buf), filename, 1)>=0);
> + f->rptr += size;
> + if (f->rptr >= f->end)
> + f->rptr = f->buffer + (f->rptr - f->end);
f->rptr -= f->end - f->buffer;
[...]
> +static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs)
> {
> return f->buffer[(f->rptr - f->buffer + offs) % (f->end - f->buffer)];
i bet that the following is faster
ptr= f->rptr + offs;
if(ptr >= s->end)
ptr -= f->end - f->buffer;
return *ptr;
[...]
--
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