[FFmpeg-devel] [PATCH 3/3] lavf: deprecate get_strz() in favor of avio_get_str

Anton Khirnov anton
Thu Mar 3 13:51:57 CET 2011


---
 libavformat/avio.h    |    7 ++++++-
 libavformat/aviobuf.c |   13 +++----------
 libavformat/ffmdec.c  |    3 ++-
 libavformat/mov.c     |    2 +-
 4 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index fd4839c..fba98e3 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -548,7 +548,12 @@ int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
 
-char *get_strz(AVIOContext *s, char *buf, int maxlen);
+#if FF_API_OLD_AVIO
+/**
+ * @deprecated use avio_get_str instead
+ */
+attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen);
+#endif
 unsigned int avio_rb16(AVIOContext *s);
 unsigned int avio_rb24(AVIOContext *s);
 unsigned int avio_rb32(AVIOContext *s);
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 5b2f9c0..9807c46 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -675,20 +675,13 @@ unsigned int avio_rb32(AVIOContext *s)
     return val;
 }
 
+#if FF_API_OLD_AVIO
 char *get_strz(AVIOContext *s, char *buf, int maxlen)
 {
-    int i = 0;
-    char c;
-
-    while ((c = avio_r8(s))) {
-        if (i < maxlen-1)
-            buf[i++] = c;
-    }
-
-    buf[i] = 0; /* Ensure null terminated, but may be truncated */
-
+    avio_get_str(s, INT_MAX, buf, maxlen);
     return buf;
 }
+#endif
 
 int ff_get_line(AVIOContext *s, char *buf, int maxlen)
 {
diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index bcfc165..7dd567e 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -325,7 +325,8 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
             codec->qcompress = avio_rb16(pb) / 10000.0;
             codec->qblur = avio_rb16(pb) / 10000.0;
             codec->bit_rate_tolerance = avio_rb32(pb);
-            codec->rc_eq = av_strdup(get_strz(pb, rc_eq_buf, sizeof(rc_eq_buf)));
+            avio_get_str(pb, INT_MAX, rc_eq_buf, sizeof(rc_eq_buf));
+            codec->rc_eq = av_strdup(rc_eq_buf);
             codec->rc_max_rate = avio_rb32(pb);
             codec->rc_min_rate = avio_rb32(pb);
             codec->rc_buffer_size = avio_rb32(pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 537b9c6..ad5bada 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2331,7 +2331,7 @@ static void mov_read_chapters(AVFormatContext *s)
             avio_get_str16le(sc->pb, len, title, title_len);
         else {
             AV_WB16(title, ch);
-            get_strz(sc->pb, title + 2, len - 1);
+            avio_get_str(sc->pb, len - 2, title + 2, title_len - 2);
         }
 
         ff_new_chapter(s, i, st->time_base, sample->timestamp, end, title);
-- 
1.7.4.1




More information about the ffmpeg-devel mailing list