[FFmpeg-devel] [PATCH] avio: add avio_skip function

Peter Ross pross
Fri Mar 4 11:41:03 CET 2011


This is a substitute for the url_fskip function that was deprecated by
commit 0300db8ad778a194b4a8ec98f6da3de5b41c46ee. avio_fskip is provided to
improve demuxer code readability. It distinguishes the act of skipping over
unknown or irrelevant bytes from the standard avio_seek operation.
---

On Thu, Mar 03, 2011 at 03:16:19PM +0100, Michael Niedermayer wrote:
> On Thu, Mar 03, 2011 at 08:26:50AM -0500, Ronald S. Bultje wrote:
> > Hi,
> >
> > On Thu, Mar 3, 2011 at 6:37 AM, Peter Ross <pross at xvid.org> wrote:
> > > This is a substitute for the url_fskip function that was deprecated by
[..]
> for the record id like to repeat that a function is better for this

I am happy either way.
Here is an patch with avio_skip as a function.

 libavformat/avio.h    |    7 +++++++
 libavformat/aviobuf.c |    9 +++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index cc46ad7..5e0fb39 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -470,6 +470,13 @@ int avio_put_str16le(AVIOContext *s, const char *str);
 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
 
 /**
+ * Skip given number of bytes forward
+ * @param offset number of bytes
+ * @return 0 on success, <0 on error
+ */
+int avio_skip(AVIOContext *s, int64_t offset);
+
+/**
  * ftell() equivalent for AVIOContext.
  * @return position or AVERROR.
  */
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 3f3721c..35e38fe 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -233,12 +233,17 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
     return offset;
 }
 
-#if FF_API_OLD_AVIO
-int url_fskip(AVIOContext *s, int64_t offset)
+int avio_skip(AVIOContext *s, int64_t offset)
 {
     int64_t ret = avio_seek(s, offset, SEEK_CUR);
     return ret < 0 ? ret : 0;
 }
+
+#if FF_API_OLD_AVIO
+int url_fskip(AVIOContext *s, int64_t offset)
+{
+    return avio_skip(s, offset);
+}
 #endif
 
 int64_t url_ftell(AVIOContext *s)
-- 
1.7.1


-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110304/27b54840/attachment.pgp>



More information about the ffmpeg-devel mailing list