[8/9] avio: make get_checksum() internal.

Message ID 1300367015-21591-9-git-send-email-anton@khirnov.net
State Committed
Headers show

Commit Message

Anton Khirnov March 17, 2011, 1:03 p.m.
---
 libavformat/avio.h          |    3 +--
 libavformat/avio_internal.h |    1 +
 libavformat/aviobuf.c       |    6 +++++-
 libavformat/nutdec.c        |   12 ++++++------
 libavformat/nutenc.c        |    8 ++++----
 libavformat/oggenc.c        |    2 +-
 6 files changed, 18 insertions(+), 14 deletions(-)

Comments

Ronald Bultje March 30, 2011, 5:39 a.m. | #1
Hi,

On Thu, Mar 17, 2011 at 6:03 AM, Anton Khirnov <anton@khirnov.net> wrote:
> ---
>  libavformat/avio.h          |    3 +--
>  libavformat/avio_internal.h |    1 +
>  libavformat/aviobuf.c       |    6 +++++-
>  libavformat/nutdec.c        |   12 ++++++------
>  libavformat/nutenc.c        |    8 ++++----
>  libavformat/oggenc.c        |    2 +-
>  6 files changed, 18 insertions(+), 14 deletions(-)

OK. Same for the init_checksum() counterpart.

Ronald

Patch

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 0e4e93e..8f58d8c 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -468,6 +468,7 @@  attribute_deprecated int udp_get_local_port(URLContext *h);
 attribute_deprecated void init_checksum(AVIOContext *s,
                    unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
                    unsigned long checksum);
+attribute_deprecated unsigned long get_checksum(AVIOContext *s);
 #endif
 
 AVIOContext *avio_alloc_context(
@@ -693,8 +694,6 @@  int avio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
  */
 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
 
-unsigned long get_checksum(AVIOContext *s);
-
 #if FF_API_UDP_GET_FILE
 int udp_get_file_handle(URLContext *h);
 #endif
diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index d2441a2..d95b015 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -77,6 +77,7 @@  int ff_udp_get_local_port(URLContext *h);
 void ffio_init_checksum(AVIOContext *s,
                         unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
                         unsigned long checksum);
+unsigned long ffio_get_checksum(AVIOContext *s);
 unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
                                     unsigned int len);
 
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 0e47cbd..7b22578 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -431,6 +431,10 @@  void init_checksum(AVIOContext *s,
 {
     ffio_init_checksum(s, update_checksum, checksum);
 }
+unsigned long get_checksum(AVIOContext *s)
+{
+    return ffio_get_checksum(s);
+}
 #endif
 
 int avio_put_str(AVIOContext *s, const char *str)
@@ -573,7 +577,7 @@  unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
     return av_crc(av_crc_get_table(AV_CRC_32_IEEE), checksum, buf, len);
 }
 
-unsigned long get_checksum(AVIOContext *s)
+unsigned long ffio_get_checksum(AVIOContext *s)
 {
     s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_ptr - s->checksum_ptr);
     s->update_checksum= NULL;
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 9409011..5c1e435 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -108,7 +108,7 @@  static int get_packetheader(NUTContext *nut, AVIOContext *bc, int calculate_chec
     size= ffio_read_varlen(bc);
     if(size > 4096)
         avio_rb32(bc);
-    if(get_checksum(bc) && size > 4096)
+    if(ffio_get_checksum(bc) && size > 4096)
         return -1;
 
     ffio_init_checksum(bc, calculate_checksum ? ff_crc04C11DB7_update : NULL, 0);
@@ -285,7 +285,7 @@  static int decode_main_header(NUTContext *nut){
         assert(nut->header_len[0]==0);
     }
 
-    if(skip_reserved(bc, end) || get_checksum(bc)){
+    if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
         av_log(s, AV_LOG_ERROR, "main header checksum mismatch\n");
         return AVERROR_INVALIDDATA;
     }
@@ -374,7 +374,7 @@  static int decode_stream_header(NUTContext *nut){
         ffio_read_varlen(bc); // samplerate_den
         GET_V(st->codec->channels, tmp > 0)
     }
-    if(skip_reserved(bc, end) || get_checksum(bc)){
+    if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
         av_log(s, AV_LOG_ERROR, "stream header %d checksum mismatch\n", stream_id);
         return -1;
     }
@@ -469,7 +469,7 @@  static int decode_info_header(NUTContext *nut){
         }
     }
 
-    if(skip_reserved(bc, end) || get_checksum(bc)){
+    if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
         av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n");
         return -1;
     }
@@ -493,7 +493,7 @@  static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
 
     ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp / nut->time_base_count);
 
-    if(skip_reserved(bc, end) || get_checksum(bc)){
+    if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
         av_log(s, AV_LOG_ERROR, "sync point checksum mismatch\n");
         return -1;
     }
@@ -590,7 +590,7 @@  static int find_and_decode_index(NUTContext *nut){
         }
     }
 
-    if(skip_reserved(bc, end) || get_checksum(bc)){
+    if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
         av_log(s, AV_LOG_ERROR, "index checksum mismatch\n");
         goto fail;
     }
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 3d85aed..1a3b599 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -289,13 +289,13 @@  static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, in
     avio_wb64(bc, startcode);
     ff_put_v(bc, forw_ptr);
     if(forw_ptr > 4096)
-        avio_wl32(bc, get_checksum(bc));
+        avio_wl32(bc, ffio_get_checksum(bc));
 
     if(calculate_checksum)
         ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
     avio_write(bc, dyn_buf, dyn_size);
     if(calculate_checksum)
-        avio_wl32(bc, get_checksum(bc));
+        avio_wl32(bc, ffio_get_checksum(bc));
 
     av_free(dyn_buf);
 }
@@ -818,8 +818,8 @@  static int write_packet(AVFormatContext *s, AVPacket *pkt){
     if(flags & FLAG_SIZE_MSB)   ff_put_v(bc, pkt->size / fc->size_mul);
     if(flags & FLAG_HEADER_IDX) ff_put_v(bc, header_idx= best_header_idx);
 
-    if(flags & FLAG_CHECKSUM)   avio_wl32(bc, get_checksum(bc));
-    else                        get_checksum(bc);
+    if(flags & FLAG_CHECKSUM)   avio_wl32(bc, ffio_get_checksum(bc));
+    else                        ffio_get_checksum(bc);
 
     avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
     nus->last_flags= flags;
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index d1eda2e..f0251a6 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -68,7 +68,7 @@  typedef struct {
 static void ogg_update_checksum(AVFormatContext *s, AVIOContext *pb, int64_t crc_offset)
 {
     int64_t pos = avio_tell(pb);
-    uint32_t checksum = get_checksum(pb);
+    uint32_t checksum = ffio_get_checksum(pb);
     avio_seek(pb, crc_offset, SEEK_SET);
     avio_wb32(pb, checksum);
     avio_seek(pb, pos, SEEK_SET);