lavf: replace avio_seek(SEEK_CUR) with avio_skip where it makes sense

Message ID 20110317064225.GA18946@zohar.khirnov.net
State Committed
Headers show

Commit Message

Anton Khirnov March 17, 2011, 6:42 a.m.
On Wed, Mar 16, 2011 at 10:28:03PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> 
> Another review of pending ones:
> 
> bash-3.2$ grep SEEK_CUR libavformat/*.c
> libavformat/avio.c:        pos = url_seek(h, 0, SEEK_CUR);
> 
> avio_tell()?

Note the lack of 'f' in url_seek ;)

> 
> libavformat/concat.c:        pos += url_seek(nodes[i].uc, 0, SEEK_CUR);
> 
> avio_tell()?

same here
> 
> libavformat/id3v2.c:    avio_seek(s->pb, len, SEEK_CUR);
> 
> avio_skip()?
> 

This one's removed by one of my pending id3v2 patches

> libavformat/mp3dec.c:    avio_seek(s->pb, xing_offtbl[c.lsf ==
> 1][c.nb_channels == 1], SEEK_CUR);
> 
> avio_skip()?
> 

Fixed in attached patch

> libavformat/nutdec.c:        avio_seek(bc, pos, SEEK_CUR);
> 
> avio_skip()?
> 

This one's under if (pos < 0)

> libavformat/rmenc.c:        index_pos = avio_seek(pb, 0, SEEK_CUR);
> 
> avio_tell()?
> 

Fixed

> libavformat/wtv.c:            avio_seek(pb, FFMAX(size - consumed, 0),
> SEEK_CUR);
> libavformat/wtv.c:            avio_seek(pb, FFMAX(size - consumed, 0),
> SEEK_CUR);
> 
> if (size - consumed > 0) avio_skip(..)?

I like the FFMAX version more. Replaced with avio_skip though.

Comments

Ronald Bultje March 17, 2011, 12:34 p.m. | #1
Hi,

On Thu, Mar 17, 2011 at 2:42 AM, Anton Khirnov <anton@khirnov.net> wrote:
> On Wed, Mar 16, 2011 at 10:28:03PM -0400, Ronald S. Bultje wrote:
>> Hi,
>>
>>
>> Another review of pending ones:
>>
>> bash-3.2$ grep SEEK_CUR libavformat/*.c
>> libavformat/avio.c:        pos = url_seek(h, 0, SEEK_CUR);
>>
>> avio_tell()?
>
> Note the lack of 'f' in url_seek ;)
>
>>
>> libavformat/concat.c:        pos += url_seek(nodes[i].uc, 0, SEEK_CUR);
>>
>> avio_tell()?
>
> same here
>>
>> libavformat/id3v2.c:    avio_seek(s->pb, len, SEEK_CUR);
>>
>> avio_skip()?
>>
>
> This one's removed by one of my pending id3v2 patches
>
>> libavformat/mp3dec.c:    avio_seek(s->pb, xing_offtbl[c.lsf ==
>> 1][c.nb_channels == 1], SEEK_CUR);
>>
>> avio_skip()?
>>
>
> Fixed in attached patch
>
>> libavformat/nutdec.c:        avio_seek(bc, pos, SEEK_CUR);
>>
>> avio_skip()?
>>
>
> This one's under if (pos < 0)
>
>> libavformat/rmenc.c:        index_pos = avio_seek(pb, 0, SEEK_CUR);
>>
>> avio_tell()?
>>
>
> Fixed
>
>> libavformat/wtv.c:            avio_seek(pb, FFMAX(size - consumed, 0),
>> SEEK_CUR);
>> libavformat/wtv.c:            avio_seek(pb, FFMAX(size - consumed, 0),
>> SEEK_CUR);
>>
>> if (size - consumed > 0) avio_skip(..)?
>
> I like the FFMAX version more. Replaced with avio_skip though.

OK, queued both.

Ronald

Patch

From 822d451df14e9ac0ad22c25f95b46d8299c72374 Mon Sep 17 00:00:00 2001
From: Anton Khirnov <anton@khirnov.net>
Date: Thu, 17 Mar 2011 07:41:19 +0100
Subject: [PATCH 2/2] rmenc: replace avio_seek(0) with avio_tell()

---
 libavformat/rmenc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c
index 4835cf4..28ee173 100644
--- a/libavformat/rmenc.c
+++ b/libavformat/rmenc.c
@@ -436,7 +436,7 @@  static int rm_write_trailer(AVFormatContext *s)
 
     if (!url_is_streamed(s->pb)) {
         /* end of file: finish to write header */
-        index_pos = avio_seek(pb, 0, SEEK_CUR);
+        index_pos = avio_tell(pb);
         data_size = index_pos - rm->data_pos;
 
         /* FIXME: write index */
-- 
1.7.4.1