[FFmpeg-cvslog] lavf: move ff_get_v from avio.h to avio_internal.h

Anton Khirnov git at videolan.org
Thu Mar 17 17:49:23 CET 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Mar 14 20:38:57 2011 +0100| [4839c192de7782605e1b7c9cc84aaf692cf67284] | committer: Ronald S. Bultje

lavf: move ff_get_v from avio.h to avio_internal.h

And rename it to ffio_read_varlen.

Signed-off-by: Ronald S. Bultje <rsbultje at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4839c192de7782605e1b7c9cc84aaf692cf67284
---

 libavformat/avio.h          |    2 -
 libavformat/avio_internal.h |    2 +
 libavformat/aviobuf.c       |    2 +-
 libavformat/mpc8.c          |    9 +++--
 libavformat/nutdec.c        |   85 ++++++++++++++++++++++---------------------
 5 files changed, 51 insertions(+), 49 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 761ced6..8b404d0 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -568,8 +568,6 @@ unsigned int avio_rb24(AVIOContext *s);
 unsigned int avio_rb32(AVIOContext *s);
 uint64_t     avio_rb64(AVIOContext *s);
 
-uint64_t ff_get_v(AVIOContext *bc);
-
 static inline int url_is_streamed(AVIOContext *s)
 {
     return s->is_streamed;
diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index 3abb619..2e0b94c 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -61,4 +61,6 @@ static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
  */
 int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size);
 
+uint64_t ffio_read_varlen(AVIOContext *bc);
+
 #endif // AVFORMAT_AVIO_INTERNAL_H
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 4f39fe3..86f4928 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -753,7 +753,7 @@ uint64_t avio_rb64(AVIOContext *s)
     return val;
 }
 
-uint64_t ff_get_v(AVIOContext *bc){
+uint64_t ffio_read_varlen(AVIOContext *bc){
     uint64_t val = 0;
     int tmp;
 
diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c
index 00217fa..8b2d395 100644
--- a/libavformat/mpc8.c
+++ b/libavformat/mpc8.c
@@ -22,6 +22,7 @@
 #include "libavcodec/get_bits.h"
 #include "libavcodec/unary.h"
 #include "avformat.h"
+#include "avio_internal.h"
 
 /// Two-byte MPC tag
 #define MKMPCTAG(a, b) (a | (b << 8))
@@ -122,7 +123,7 @@ static void mpc8_get_chunk_header(AVIOContext *pb, int *tag, int64_t *size)
     int64_t pos;
     pos = avio_tell(pb);
     *tag = avio_rl16(pb);
-    *size = ff_get_v(pb);
+    *size = ffio_read_varlen(pb);
     *size -= avio_tell(pb) - pos;
 }
 
@@ -177,7 +178,7 @@ static void mpc8_handle_chunk(AVFormatContext *s, int tag, int64_t chunk_pos, in
     switch(tag){
     case TAG_SEEKTBLOFF:
         pos = avio_tell(pb) + size;
-        off = ff_get_v(pb);
+        off = ffio_read_varlen(pb);
         mpc8_parse_seektable(s, chunk_pos + off);
         avio_seek(pb, pos, SEEK_SET);
         break;
@@ -218,8 +219,8 @@ static int mpc8_read_header(AVFormatContext *s, AVFormatParameters *ap)
         av_log(s, AV_LOG_ERROR, "Unknown stream version %d\n", c->ver);
         return -1;
     }
-    c->samples = ff_get_v(pb);
-    ff_get_v(pb); //silence samples at the beginning
+    c->samples = ffio_read_varlen(pb);
+    ffio_read_varlen(pb); //silence samples at the beginning
 
     st = av_new_stream(s, 0);
     if (!st)
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index f010ad1..d9bb769 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -24,6 +24,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/bswap.h"
 #include "libavutil/tree.h"
+#include "avio_internal.h"
 #include "nut.h"
 
 #undef NDEBUG
@@ -36,7 +37,7 @@
 #endif
 
 static int get_str(AVIOContext *bc, char *string, unsigned int maxlen){
-    unsigned int len= ff_get_v(bc);
+    unsigned int len= ffio_read_varlen(bc);
 
     if(len && maxlen)
         avio_read(bc, string, FFMIN(len, maxlen));
@@ -55,14 +56,14 @@ static int get_str(AVIOContext *bc, char *string, unsigned int maxlen){
 }
 
 static int64_t get_s(AVIOContext *bc){
-    int64_t v = ff_get_v(bc) + 1;
+    int64_t v = ffio_read_varlen(bc) + 1;
 
     if (v&1) return -(v>>1);
     else     return  (v>>1);
 }
 
 static uint64_t get_fourcc(AVIOContext *bc){
-    unsigned int len= ff_get_v(bc);
+    unsigned int len= ffio_read_varlen(bc);
 
     if     (len==2) return avio_rl16(bc);
     else if(len==4) return avio_rl32(bc);
@@ -71,7 +72,7 @@ static uint64_t get_fourcc(AVIOContext *bc){
 
 #ifdef TRACE
 static inline uint64_t get_v_trace(AVIOContext *bc, char *file, char *func, int line){
-    uint64_t v= ff_get_v(bc);
+    uint64_t v= ffio_read_varlen(bc);
 
     av_log(NULL, AV_LOG_DEBUG, "get_v %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
     return v;
@@ -90,7 +91,7 @@ static inline uint64_t get_vb_trace(AVIOContext *bc, char *file, char *func, int
     av_log(NULL, AV_LOG_DEBUG, "get_vb %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
     return v;
 }
-#define ff_get_v(bc)  get_v_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+#define ffio_read_varlen(bc)  get_v_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
 #define get_s(bc)  get_s_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
 #define get_vb(bc)  get_vb_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
 #endif
@@ -104,7 +105,7 @@ static int get_packetheader(NUTContext *nut, AVIOContext *bc, int calculate_chec
     startcode= ff_crc04C11DB7_update(0, (uint8_t*)&startcode, 8);
 
     init_checksum(bc, ff_crc04C11DB7_update, startcode);
-    size= ff_get_v(bc);
+    size= ffio_read_varlen(bc);
     if(size > 4096)
         avio_rb32(bc);
     if(get_checksum(bc) && size > 4096)
@@ -168,7 +169,7 @@ static int nut_probe(AVProbeData *p){
 }
 
 #define GET_V(dst, check) \
-    tmp= ff_get_v(bc);\
+    tmp= ffio_read_varlen(bc);\
     if(!(check)){\
         av_log(s, AV_LOG_ERROR, "Error " #dst " is (%"PRId64")\n", tmp);\
         return -1;\
@@ -201,7 +202,7 @@ static int decode_main_header(NUTContext *nut){
     GET_V(tmp              , tmp >=2 && tmp <= 3)
     GET_V(stream_count     , tmp > 0 && tmp <= NUT_MAX_STREAMS)
 
-    nut->max_distance = ff_get_v(bc);
+    nut->max_distance = ffio_read_varlen(bc);
     if(nut->max_distance > 65536){
         av_log(s, AV_LOG_DEBUG, "max_distance %d\n", nut->max_distance);
         nut->max_distance= 65536;
@@ -224,22 +225,22 @@ static int decode_main_header(NUTContext *nut){
     tmp_match= 1-(1LL<<62);
     tmp_head_idx= 0;
     for(i=0; i<256;){
-        int tmp_flags = ff_get_v(bc);
-        int tmp_fields= ff_get_v(bc);
+        int tmp_flags = ffio_read_varlen(bc);
+        int tmp_fields= ffio_read_varlen(bc);
         if(tmp_fields>0) tmp_pts   = get_s(bc);
-        if(tmp_fields>1) tmp_mul   = ff_get_v(bc);
-        if(tmp_fields>2) tmp_stream= ff_get_v(bc);
-        if(tmp_fields>3) tmp_size  = ff_get_v(bc);
+        if(tmp_fields>1) tmp_mul   = ffio_read_varlen(bc);
+        if(tmp_fields>2) tmp_stream= ffio_read_varlen(bc);
+        if(tmp_fields>3) tmp_size  = ffio_read_varlen(bc);
         else             tmp_size  = 0;
-        if(tmp_fields>4) tmp_res   = ff_get_v(bc);
+        if(tmp_fields>4) tmp_res   = ffio_read_varlen(bc);
         else             tmp_res   = 0;
-        if(tmp_fields>5) count     = ff_get_v(bc);
+        if(tmp_fields>5) count     = ffio_read_varlen(bc);
         else             count     = tmp_mul - tmp_size;
         if(tmp_fields>6) tmp_match = get_s(bc);
-        if(tmp_fields>7) tmp_head_idx= ff_get_v(bc);
+        if(tmp_fields>7) tmp_head_idx= ffio_read_varlen(bc);
 
         while(tmp_fields-- > 8)
-           ff_get_v(bc);
+           ffio_read_varlen(bc);
 
         if(count == 0 || i+count > 256){
             av_log(s, AV_LOG_ERROR, "illegal count %d at %d\n", count, i);
@@ -315,7 +316,7 @@ static int decode_stream_header(NUTContext *nut){
     if (!st)
         return AVERROR(ENOMEM);
 
-    class = ff_get_v(bc);
+    class = ffio_read_varlen(bc);
     tmp = get_fourcc(bc);
     st->codec->codec_tag= tmp;
     switch(class)
@@ -347,10 +348,10 @@ static int decode_stream_header(NUTContext *nut){
 
     GET_V(stc->time_base_id    , tmp < nut->time_base_count);
     GET_V(stc->msb_pts_shift   , tmp < 16);
-    stc->max_pts_distance= ff_get_v(bc);
+    stc->max_pts_distance= ffio_read_varlen(bc);
     GET_V(stc->decode_delay    , tmp < 1000); //sanity limit, raise this if Moore's law is true
     st->codec->has_b_frames= stc->decode_delay;
-    ff_get_v(bc); //stream flags
+    ffio_read_varlen(bc); //stream flags
 
     GET_V(st->codec->extradata_size, tmp < (1<<30));
     if(st->codec->extradata_size){
@@ -361,16 +362,16 @@ static int decode_stream_header(NUTContext *nut){
     if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
         GET_V(st->codec->width , tmp > 0)
         GET_V(st->codec->height, tmp > 0)
-        st->sample_aspect_ratio.num= ff_get_v(bc);
-        st->sample_aspect_ratio.den= ff_get_v(bc);
+        st->sample_aspect_ratio.num= ffio_read_varlen(bc);
+        st->sample_aspect_ratio.den= ffio_read_varlen(bc);
         if((!st->sample_aspect_ratio.num) != (!st->sample_aspect_ratio.den)){
             av_log(s, AV_LOG_ERROR, "invalid aspect ratio %d/%d\n", st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
             return -1;
         }
-        ff_get_v(bc); /* csp type */
+        ffio_read_varlen(bc); /* csp type */
     }else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
         GET_V(st->codec->sample_rate , tmp > 0)
-        ff_get_v(bc); // samplerate_den
+        ffio_read_varlen(bc); // samplerate_den
         GET_V(st->codec->channels, tmp > 0)
     }
     if(skip_reserved(bc, end) || get_checksum(bc)){
@@ -413,9 +414,9 @@ static int decode_info_header(NUTContext *nut){
 
     GET_V(stream_id_plus1, tmp <= s->nb_streams)
     chapter_id   = get_s(bc);
-    chapter_start= ff_get_v(bc);
-    chapter_len  = ff_get_v(bc);
-    count        = ff_get_v(bc);
+    chapter_start= ffio_read_varlen(bc);
+    chapter_len  = ffio_read_varlen(bc);
+    count        = ffio_read_varlen(bc);
 
     if(chapter_id && !stream_id_plus1){
         int64_t start= chapter_start / nut->time_base_count;
@@ -444,7 +445,7 @@ static int decode_info_header(NUTContext *nut){
             value= get_s(bc);
         }else if(value == -4){
             type= "t";
-            value= ff_get_v(bc);
+            value= ffio_read_varlen(bc);
         }else if(value < -4){
             type= "r";
             get_s(bc);
@@ -485,8 +486,8 @@ static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
     end= get_packetheader(nut, bc, 1, SYNCPOINT_STARTCODE);
     end += avio_tell(bc);
 
-    tmp= ff_get_v(bc);
-    *back_ptr= nut->last_syncpoint_pos - 16*ff_get_v(bc);
+    tmp= ffio_read_varlen(bc);
+    *back_ptr= nut->last_syncpoint_pos - 16*ffio_read_varlen(bc);
     if(*back_ptr < 0)
         return -1;
 
@@ -523,12 +524,12 @@ static int find_and_decode_index(NUTContext *nut){
     end= get_packetheader(nut, bc, 1, INDEX_STARTCODE);
     end += avio_tell(bc);
 
-    ff_get_v(bc); //max_pts
+    ffio_read_varlen(bc); //max_pts
     GET_V(syncpoint_count, tmp < INT_MAX/8 && tmp > 0)
     syncpoints= av_malloc(sizeof(int64_t)*syncpoint_count);
     has_keyframe= av_malloc(sizeof(int8_t)*(syncpoint_count+1));
     for(i=0; i<syncpoint_count; i++){
-        syncpoints[i] = ff_get_v(bc);
+        syncpoints[i] = ffio_read_varlen(bc);
         if(syncpoints[i] <= 0)
             goto fail;
         if(i)
@@ -538,7 +539,7 @@ static int find_and_decode_index(NUTContext *nut){
     for(i=0; i<s->nb_streams; i++){
         int64_t last_pts= -1;
         for(j=0; j<syncpoint_count;){
-            uint64_t x= ff_get_v(bc);
+            uint64_t x= ffio_read_varlen(bc);
             int type= x&1;
             int n= j;
             x>>=1;
@@ -569,10 +570,10 @@ static int find_and_decode_index(NUTContext *nut){
             assert(n<=syncpoint_count+1);
             for(; j<n && j<syncpoint_count; j++){
                 if(has_keyframe[j]){
-                    uint64_t B, A= ff_get_v(bc);
+                    uint64_t B, A= ffio_read_varlen(bc);
                     if(!A){
-                        A= ff_get_v(bc);
-                        B= ff_get_v(bc);
+                        A= ffio_read_varlen(bc);
+                        B= ffio_read_varlen(bc);
                         //eor_pts[j][i] = last_pts + A + B
                     }else
                         B= 0;
@@ -687,13 +688,13 @@ static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, ui
     if(flags & FLAG_INVALID)
         return AVERROR_INVALIDDATA;
     if(flags & FLAG_CODED)
-        flags ^= ff_get_v(bc);
+        flags ^= ffio_read_varlen(bc);
     if(flags & FLAG_STREAM_ID){
         GET_V(*stream_id, tmp < s->nb_streams)
     }
     stc= &nut->stream[*stream_id];
     if(flags&FLAG_CODED_PTS){
-        int coded_pts= ff_get_v(bc);
+        int coded_pts= ffio_read_varlen(bc);
 //FIXME check last_pts validity?
         if(coded_pts < (1<<stc->msb_pts_shift)){
             *pts=ff_lsb2full(stc, coded_pts);
@@ -702,16 +703,16 @@ static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, ui
     }else
         *pts= stc->last_pts + pts_delta;
     if(flags&FLAG_SIZE_MSB){
-        size += size_mul*ff_get_v(bc);
+        size += size_mul*ffio_read_varlen(bc);
     }
     if(flags&FLAG_MATCH_TIME)
         get_s(bc);
     if(flags&FLAG_HEADER_IDX)
-        *header_idx= ff_get_v(bc);
+        *header_idx= ffio_read_varlen(bc);
     if(flags&FLAG_RESERVED)
-        reserved_count= ff_get_v(bc);
+        reserved_count= ffio_read_varlen(bc);
     for(i=0; i<reserved_count; i++)
-        ff_get_v(bc);
+        ffio_read_varlen(bc);
 
     if(*header_idx >= (unsigned)nut->header_count){
         av_log(s, AV_LOG_ERROR, "header_idx invalid\n");




More information about the ffmpeg-cvslog mailing list