Browse code

rename av_crc04C11DB7_update to ff_crc04C11DB7_update and move it to aviobuf.c so it can be reused by other (de)muxers

Originally committed as revision 10873 to svn://svn.ffmpeg.org/ffmpeg/trunk

Baptiste Coudurier authored on 2007/10/30 09:01:25
Showing 6 changed files
... ...
@@ -258,6 +258,7 @@ int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size);
258 258
  */
259 259
 int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
260 260
 
261
+unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len);
261 262
 unsigned long get_checksum(ByteIOContext *s);
262 263
 void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum);
263 264
 
... ...
@@ -20,6 +20,7 @@
20 20
  */
21 21
 #include "avformat.h"
22 22
 #include "avio.h"
23
+#include "crc.h"
23 24
 #include <stdarg.h>
24 25
 
25 26
 #define IO_BUFFER_SIZE 32768
... ...
@@ -286,6 +287,10 @@ static void fill_buffer(ByteIOContext *s)
286 286
     }
287 287
 }
288 288
 
289
+unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len){
290
+    return av_crc(av_crc04C11DB7, checksum, buf, len);
291
+}
292
+
289 293
 unsigned long get_checksum(ByteIOContext *s){
290 294
     s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_ptr - s->checksum_ptr);
291 295
     s->update_checksum= NULL;
... ...
@@ -22,10 +22,6 @@
22 22
 #include "nut.h"
23 23
 #include "tree.h"
24 24
 
25
-unsigned long av_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len){
26
-    return av_crc(av_crc04C11DB7, checksum, buf, len);
27
-}
28
-
29 25
 void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val){
30 26
     int i;
31 27
     for(i=0; i<nut->avf->nb_streams; i++){
... ...
@@ -24,7 +24,6 @@
24 24
 
25 25
 //#include <limits.h>
26 26
 #include "avformat.h"
27
-#include "crc.h"
28 27
 //#include "mpegaudio.h"
29 28
 #include "riff.h"
30 29
 //#include "adler32.h"
... ...
@@ -93,7 +92,6 @@ typedef struct {
93 93
     struct AVTreeNode *syncpoints;
94 94
 } NUTContext;
95 95
 
96
-unsigned long av_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len);
97 96
 void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val);
98 97
 int64_t ff_lsb2full(StreamContext *stream, int64_t lsb);
99 98
 int ff_nut_sp_pos_cmp(syncpoint_t *a, syncpoint_t *b);
... ...
@@ -104,16 +104,16 @@ static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_ch
104 104
 //    start= url_ftell(bc) - 8;
105 105
 
106 106
     startcode= be2me_64(startcode);
107
-    startcode= av_crc04C11DB7_update(0, &startcode, 8);
107
+    startcode= ff_crc04C11DB7_update(0, &startcode, 8);
108 108
 
109
-    init_checksum(bc, av_crc04C11DB7_update, startcode);
109
+    init_checksum(bc, ff_crc04C11DB7_update, startcode);
110 110
     size= get_v(bc);
111 111
     if(size > 4096)
112 112
         get_be32(bc);
113 113
     if(get_checksum(bc) && size > 4096)
114 114
         return -1;
115 115
 
116
-    init_checksum(bc, calculate_checksum ? av_crc04C11DB7_update : NULL, 0);
116
+    init_checksum(bc, calculate_checksum ? ff_crc04C11DB7_update : NULL, 0);
117 117
 
118 118
     return size;
119 119
 }
... ...
@@ -196,14 +196,14 @@ static void put_packet(NUTContext *nut, ByteIOContext *bc, ByteIOContext *dyn_bc
196 196
     int forw_ptr= dyn_size + 4*calculate_checksum;
197 197
 
198 198
     if(forw_ptr > 4096)
199
-        init_checksum(bc, av_crc04C11DB7_update, 0);
199
+        init_checksum(bc, ff_crc04C11DB7_update, 0);
200 200
     put_be64(bc, startcode);
201 201
     put_v(bc, forw_ptr);
202 202
     if(forw_ptr > 4096)
203 203
         put_le32(bc, get_checksum(bc));
204 204
 
205 205
     if(calculate_checksum)
206
-        init_checksum(bc, av_crc04C11DB7_update, 0);
206
+        init_checksum(bc, ff_crc04C11DB7_update, 0);
207 207
     put_buffer(bc, dyn_buf, dyn_size);
208 208
     if(calculate_checksum)
209 209
         put_le32(bc, get_checksum(bc));
... ...
@@ -535,7 +535,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){
535 535
     flags= fc->flags;
536 536
     needed_flags= get_needed_flags(nut, nus, fc, pkt);
537 537
 
538
-    init_checksum(bc, av_crc04C11DB7_update, 0);
538
+    init_checksum(bc, ff_crc04C11DB7_update, 0);
539 539
     put_byte(bc, frame_code);
540 540
     if(flags & FLAG_CODED){
541 541
         put_v(bc, (flags^needed_flags) & ~(FLAG_CODED));