[6/9] avio: make init_checksum() internal.

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

Commit Message

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

Patch

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 2d96801..0d75d30 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -464,6 +464,10 @@  attribute_deprecated int url_ferror(AVIOContext *s);
 
 attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri);
 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);
 #endif
 
 AVIOContext *avio_alloc_context(
@@ -692,9 +696,6 @@  int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
 unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
                                     unsigned int len);
 unsigned long get_checksum(AVIOContext *s);
-void init_checksum(AVIOContext *s,
-                   unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
-                   unsigned long checksum);
 
 #if FF_API_UDP_GET_FILE
 int udp_get_file_handle(URLContext *h);
diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index 7568935..f65798e 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -74,5 +74,8 @@  int64_t ffio_read_seek( AVIOContext *h,    int stream_index,
 int ff_udp_set_remote_url(URLContext *h, const char *uri);
 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);
 
 #endif // AVFORMAT_AVIO_INTERNAL_H
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index a7c5d28..0e47cbd 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -425,6 +425,12 @@  int url_fdopen(AVIOContext **s, URLContext *h)
 {
     return avio_fdopen(s, h);
 }
+void init_checksum(AVIOContext *s,
+                   unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
+                   unsigned long checksum)
+{
+    ffio_init_checksum(s, update_checksum, checksum);
+}
 #endif
 
 int avio_put_str(AVIOContext *s, const char *str)
@@ -574,7 +580,7 @@  unsigned long get_checksum(AVIOContext *s)
     return s->checksum;
 }
 
-void init_checksum(AVIOContext *s,
+void ffio_init_checksum(AVIOContext *s,
                    unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
                    unsigned long checksum)
 {
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index b46f410..9409011 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -104,14 +104,14 @@  static int get_packetheader(NUTContext *nut, AVIOContext *bc, int calculate_chec
     startcode= av_be2ne64(startcode);
     startcode= ff_crc04C11DB7_update(0, (uint8_t*)&startcode, 8);
 
-    init_checksum(bc, ff_crc04C11DB7_update, startcode);
+    ffio_init_checksum(bc, ff_crc04C11DB7_update, startcode);
     size= ffio_read_varlen(bc);
     if(size > 4096)
         avio_rb32(bc);
     if(get_checksum(bc) && size > 4096)
         return -1;
 
-    init_checksum(bc, calculate_checksum ? ff_crc04C11DB7_update : NULL, 0);
+    ffio_init_checksum(bc, calculate_checksum ? ff_crc04C11DB7_update : NULL, 0);
 
     return size;
 }
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index e55517a..3d85aed 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -24,6 +24,7 @@ 
 #include "libavcodec/mpegaudiodata.h"
 #include "nut.h"
 #include "internal.h"
+#include "avio_internal.h"
 
 static int find_expected_header(AVCodecContext *c, int size, int key_frame, uint8_t out[64]){
     int sample_rate= c->sample_rate;
@@ -284,14 +285,14 @@  static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, in
     int forw_ptr= dyn_size + 4*calculate_checksum;
 
     if(forw_ptr > 4096)
-        init_checksum(bc, ff_crc04C11DB7_update, 0);
+        ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
     avio_wb64(bc, startcode);
     ff_put_v(bc, forw_ptr);
     if(forw_ptr > 4096)
         avio_wl32(bc, get_checksum(bc));
 
     if(calculate_checksum)
-        init_checksum(bc, ff_crc04C11DB7_update, 0);
+        ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
     avio_write(bc, dyn_buf, dyn_size);
     if(calculate_checksum)
         avio_wl32(bc, get_checksum(bc));
@@ -806,7 +807,7 @@  static int write_packet(AVFormatContext *s, AVPacket *pkt){
     needed_flags= get_needed_flags(nut, nus, fc, pkt);
     header_idx= fc->header_idx;
 
-    init_checksum(bc, ff_crc04C11DB7_update, 0);
+    ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
     avio_w8(bc, frame_code);
     if(flags & FLAG_CODED){
         ff_put_v(bc, (flags^needed_flags) & ~(FLAG_CODED));
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 21e4614..d1eda2e 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -85,7 +85,7 @@  static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
     ret = avio_open_dyn_buf(&pb);
     if (ret < 0)
         return ret;
-    init_checksum(pb, ff_crc04C11DB7_update, 0);
+    ffio_init_checksum(pb, ff_crc04C11DB7_update, 0);
     ffio_wfourcc(pb, "OggS");
     avio_w8(pb, 0);
     avio_w8(pb, page->flags | extra_flags);