diff options
author | Mohamed Tarek <mt@rockbox.org> | 2009-05-12 20:50:35 +0000 |
---|---|---|
committer | Mohamed Tarek <mt@rockbox.org> | 2009-05-12 20:50:35 +0000 |
commit | 49ba646d579a89d5ff0e4f3d5eea237eea22aafd (patch) | |
tree | 32aa872eb82b16c22f1915543c1512b116513209 | |
parent | 49fccaf2d925def5cc57fff4a09b98a8fe318cc8 (diff) | |
download | rockbox-49ba646d579a89d5ff0e4f3d5eea237eea22aafd.tar.gz rockbox-49ba646d579a89d5ff0e4f3d5eea237eea22aafd.zip |
-Remove all dynamic allocations, hence remove cook_decode_close() which was basically
needed for freeing allocated memory.
-Remove any ffmpeg-specific attributes (av_const,av_always_inline .. etc.).
-Move some math functions to cook_fixpoint.h - libavutil/common.h is no longer
needed.
-Remove libavutil/mem.[c/h], libavutil/common.h and libavutil/internal.h.
-Fix a warning in cookdata_fixpoint.h.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20922 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs/libcook/Makefile.test | 2 | ||||
-rw-r--r-- | apps/codecs/libcook/bitstream.c | 24 | ||||
-rw-r--r-- | apps/codecs/libcook/bitstream.h | 7 | ||||
-rw-r--r-- | apps/codecs/libcook/cook.c | 81 | ||||
-rw-r--r-- | apps/codecs/libcook/cook.h | 7 | ||||
-rw-r--r-- | apps/codecs/libcook/cook_fixpoint.h | 49 | ||||
-rw-r--r-- | apps/codecs/libcook/cookdata_fixpoint.h | 4 | ||||
-rw-r--r-- | apps/codecs/libcook/libavutil/bswap.h | 8 | ||||
-rw-r--r-- | apps/codecs/libcook/libavutil/common.h | 286 | ||||
-rw-r--r-- | apps/codecs/libcook/libavutil/internal.h | 328 | ||||
-rw-r--r-- | apps/codecs/libcook/libavutil/mem.c | 158 | ||||
-rw-r--r-- | apps/codecs/libcook/libavutil/mem.h | 104 | ||||
-rw-r--r-- | apps/codecs/libcook/main.c | 4 |
13 files changed, 91 insertions, 971 deletions
diff --git a/apps/codecs/libcook/Makefile.test b/apps/codecs/libcook/Makefile.test index d90cda2543..d5d91708fd 100644 --- a/apps/codecs/libcook/Makefile.test +++ b/apps/codecs/libcook/Makefile.test | |||
@@ -1,5 +1,5 @@ | |||
1 | CFLAGS = -Wall -O3 | 1 | CFLAGS = -Wall -O3 |
2 | OBJS = main.o bitstream.o cook.o libavutil/mem.o rm2wav.o | 2 | OBJS = main.o bitstream.o cook.o rm2wav.o |
3 | cooktest: $(OBJS) | 3 | cooktest: $(OBJS) |
4 | gcc -o cooktest $(OBJS) | 4 | gcc -o cooktest $(OBJS) |
5 | 5 | ||
diff --git a/apps/codecs/libcook/bitstream.c b/apps/codecs/libcook/bitstream.c index 3b0c0a7b55..4bc706ffb7 100644 --- a/apps/codecs/libcook/bitstream.c +++ b/apps/codecs/libcook/bitstream.c | |||
@@ -45,6 +45,8 @@ const uint8_t ff_log2_run[32]={ | |||
45 | * @deprecated. Code which uses ff_realloc_static is broken/misdesigned | 45 | * @deprecated. Code which uses ff_realloc_static is broken/misdesigned |
46 | * and should correctly use static arrays | 46 | * and should correctly use static arrays |
47 | */ | 47 | */ |
48 | |||
49 | #if 0 | ||
48 | attribute_deprecated av_alloc_size(2) | 50 | attribute_deprecated av_alloc_size(2) |
49 | static void *ff_realloc_static(void *ptr, unsigned int size); | 51 | static void *ff_realloc_static(void *ptr, unsigned int size); |
50 | 52 | ||
@@ -61,6 +63,7 @@ void align_put_bits(PutBitContext *s) | |||
61 | put_bits(s,s->bit_left & 7,0); | 63 | put_bits(s,s->bit_left & 7,0); |
62 | #endif | 64 | #endif |
63 | } | 65 | } |
66 | #endif | ||
64 | 67 | ||
65 | void ff_put_string(PutBitContext * pbc, const char *s, int put_zero) | 68 | void ff_put_string(PutBitContext * pbc, const char *s, int put_zero) |
66 | { | 69 | { |
@@ -123,15 +126,11 @@ static int alloc_table(VLC *vlc, int size, int use_static) | |||
123 | index = vlc->table_size; | 126 | index = vlc->table_size; |
124 | vlc->table_size += size; | 127 | vlc->table_size += size; |
125 | if (vlc->table_size > vlc->table_allocated) { | 128 | if (vlc->table_size > vlc->table_allocated) { |
126 | if(use_static>1) | 129 | if(use_static>1){ |
130 | printf("init_vlc() used with too little memory : table_size > allocated_memory\n"); | ||
127 | abort(); //cant do anything, init_vlc() is used with too little memory | 131 | abort(); //cant do anything, init_vlc() is used with too little memory |
128 | vlc->table_allocated += (1 << vlc->bits); | 132 | } |
129 | if(use_static) | 133 | |
130 | vlc->table = ff_realloc_static(vlc->table, | ||
131 | sizeof(VLC_TYPE) * 2 * vlc->table_allocated); | ||
132 | else | ||
133 | vlc->table = av_realloc(vlc->table, | ||
134 | sizeof(VLC_TYPE) * 2 * vlc->table_allocated); | ||
135 | if (!vlc->table) | 134 | if (!vlc->table) |
136 | return -1; | 135 | return -1; |
137 | } | 136 | } |
@@ -305,10 +304,13 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, | |||
305 | codes, codes_wrap, codes_size, | 304 | codes, codes_wrap, codes_size, |
306 | symbols, symbols_wrap, symbols_size, | 305 | symbols, symbols_wrap, symbols_size, |
307 | 0, 0, flags) < 0) { | 306 | 0, 0, flags) < 0) { |
308 | av_freep(&vlc->table); | 307 | free(&vlc->table); |
309 | return -1; | 308 | return -1; |
310 | } | 309 | } |
311 | if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size != vlc->table_allocated) | 310 | /* Changed the following condition to be true if table_size > table_allocated. * |
311 | * This would be more sensible for static tables since we want warnings for * | ||
312 | * memory shortages only. */ | ||
313 | if((flags & INIT_VLC_USE_NEW_STATIC) && vlc->table_size > vlc->table_allocated) | ||
312 | printf("needed %d had %d\n", vlc->table_size, vlc->table_allocated); | 314 | printf("needed %d had %d\n", vlc->table_size, vlc->table_allocated); |
313 | return 0; | 315 | return 0; |
314 | } | 316 | } |
@@ -316,6 +318,6 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, | |||
316 | 318 | ||
317 | void free_vlc(VLC *vlc) | 319 | void free_vlc(VLC *vlc) |
318 | { | 320 | { |
319 | av_freep(&vlc->table); | 321 | free(&vlc->table); |
320 | } | 322 | } |
321 | 323 | ||
diff --git a/apps/codecs/libcook/bitstream.h b/apps/codecs/libcook/bitstream.h index 2319a4d672..caef254f0d 100644 --- a/apps/codecs/libcook/bitstream.h +++ b/apps/codecs/libcook/bitstream.h | |||
@@ -29,10 +29,9 @@ | |||
29 | #include <stdint.h> | 29 | #include <stdint.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <assert.h> | 31 | #include <assert.h> |
32 | #include <string.h> | ||
33 | #include <stdio.h> | ||
32 | #include "libavutil/bswap.h" | 34 | #include "libavutil/bswap.h" |
33 | #include "libavutil/common.h" | ||
34 | //#include "libavutil/log.h" | ||
35 | //#include "mathops.h" | ||
36 | 35 | ||
37 | /* The following 2 defines are taken from libavutil/intreadwrite.h */ | 36 | /* The following 2 defines are taken from libavutil/intreadwrite.h */ |
38 | #define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ | 37 | #define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ |
@@ -881,7 +880,7 @@ void free_vlc(VLC *vlc); | |||
881 | * read the longest vlc code | 880 | * read the longest vlc code |
882 | * = (max_vlc_length + bits - 1) / bits | 881 | * = (max_vlc_length + bits - 1) / bits |
883 | */ | 882 | */ |
884 | static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], | 883 | static inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], |
885 | int bits, int max_depth) | 884 | int bits, int max_depth) |
886 | { | 885 | { |
887 | int code; | 886 | int code; |
diff --git a/apps/codecs/libcook/cook.c b/apps/codecs/libcook/cook.c index fd80c1bd2e..8caa3992bd 100644 --- a/apps/codecs/libcook/cook.c +++ b/apps/codecs/libcook/cook.c | |||
@@ -45,22 +45,12 @@ | |||
45 | #include <math.h> | 45 | #include <math.h> |
46 | #include <stddef.h> | 46 | #include <stddef.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <limits.h> | ||
49 | #include <string.h> | ||
48 | 50 | ||
49 | #include "cook.h" | 51 | #include "cook.h" |
50 | #include "cookdata.h" | 52 | #include "cookdata.h" |
51 | 53 | ||
52 | /* The following table is taken from libavutil/mathematics.c */ | ||
53 | const uint8_t ff_log2_tab[256]={ | ||
54 | 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | ||
55 | 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, | ||
56 | 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, | ||
57 | 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, | ||
58 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
59 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
60 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
61 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 | ||
62 | }; | ||
63 | |||
64 | /* the different Cook versions */ | 54 | /* the different Cook versions */ |
65 | #define MONO 0x1000001 | 55 | #define MONO 0x1000001 |
66 | #define STEREO 0x1000002 | 56 | #define STEREO 0x1000002 |
@@ -112,26 +102,35 @@ static void dump_short_table(short* table, int size, int delimiter) { | |||
112 | #endif | 102 | #endif |
113 | 103 | ||
114 | /*************** init functions ***************/ | 104 | /*************** init functions ***************/ |
115 | static av_cold int init_cook_vlc_tables(COOKContext *q) { | 105 | #define VLCBUFSIZE 1500 |
106 | VLC_TYPE vlcbuf[21][VLCBUFSIZE][2]; | ||
107 | |||
108 | static int init_cook_vlc_tables(COOKContext *q) { | ||
116 | int i, result; | 109 | int i, result; |
117 | 110 | ||
118 | result = 0; | 111 | result = 0; |
119 | for (i=0 ; i<13 ; i++) { | 112 | for (i=0 ; i<13 ; i++) { |
113 | q->envelope_quant_index[i].table = vlcbuf[i]; | ||
114 | q->envelope_quant_index[i].table_allocated = VLCBUFSIZE; | ||
120 | result |= init_vlc (&q->envelope_quant_index[i], 9, 24, | 115 | result |= init_vlc (&q->envelope_quant_index[i], 9, 24, |
121 | envelope_quant_index_huffbits[i], 1, 1, | 116 | envelope_quant_index_huffbits[i], 1, 1, |
122 | envelope_quant_index_huffcodes[i], 2, 2, 0); | 117 | envelope_quant_index_huffcodes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
123 | } | 118 | } |
124 | DEBUGF("sqvh VLC init\n"); | 119 | DEBUGF("sqvh VLC init\n"); |
125 | for (i=0 ; i<7 ; i++) { | 120 | for (i=0 ; i<7 ; i++) { |
121 | q->sqvh[i].table = vlcbuf[i+13]; | ||
122 | q->sqvh[i].table_allocated = VLCBUFSIZE; | ||
126 | result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i], | 123 | result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i], |
127 | cvh_huffbits[i], 1, 1, | 124 | cvh_huffbits[i], 1, 1, |
128 | cvh_huffcodes[i], 2, 2, 0); | 125 | cvh_huffcodes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
129 | } | 126 | } |
130 | 127 | ||
131 | if (q->nb_channels==2 && q->joint_stereo==1){ | 128 | if (q->nb_channels==2 && q->joint_stereo==1){ |
129 | q->ccpl.table = vlcbuf[20]; | ||
130 | q->ccpl.table_allocated = VLCBUFSIZE; | ||
132 | result |= init_vlc (&q->ccpl, 6, (1<<q->js_vlc_bits)-1, | 131 | result |= init_vlc (&q->ccpl, 6, (1<<q->js_vlc_bits)-1, |
133 | ccpl_huffbits[q->js_vlc_bits-2], 1, 1, | 132 | ccpl_huffbits[q->js_vlc_bits-2], 1, 1, |
134 | ccpl_huffcodes[q->js_vlc_bits-2], 2, 2, 0); | 133 | ccpl_huffcodes[q->js_vlc_bits-2], 2, 2, INIT_VLC_USE_NEW_STATIC); |
135 | DEBUGF("Joint-stereo VLC used.\n"); | 134 | DEBUGF("Joint-stereo VLC used.\n"); |
136 | } | 135 | } |
137 | 136 | ||
@@ -185,35 +184,6 @@ static inline int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes) | |||
185 | } | 184 | } |
186 | 185 | ||
187 | /** | 186 | /** |
188 | * Cook uninit | ||
189 | */ | ||
190 | |||
191 | av_cold int cook_decode_close(COOKContext *q) | ||
192 | { | ||
193 | int i; | ||
194 | //COOKContext *q = avctx->priv_data; | ||
195 | DEBUGF( "Deallocating memory.\n"); | ||
196 | |||
197 | /* Free allocated memory buffers. */ | ||
198 | av_free(q->decoded_bytes_buffer); | ||
199 | |||
200 | /* Free the VLC tables. */ | ||
201 | for (i=0 ; i<13 ; i++) { | ||
202 | free_vlc(&q->envelope_quant_index[i]); | ||
203 | } | ||
204 | for (i=0 ; i<7 ; i++) { | ||
205 | free_vlc(&q->sqvh[i]); | ||
206 | } | ||
207 | if(q->nb_channels==2 && q->joint_stereo==1 ){ | ||
208 | free_vlc(&q->ccpl); | ||
209 | } | ||
210 | |||
211 | DEBUGF("Memory deallocated.\n"); | ||
212 | |||
213 | return 0; | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * Fill the gain array for the timedomain quantization. | 187 | * Fill the gain array for the timedomain quantization. |
218 | * | 188 | * |
219 | * @param q pointer to the COOKContext | 189 | * @param q pointer to the COOKContext |
@@ -739,7 +709,7 @@ static void dump_cook_context(COOKContext *q) | |||
739 | * Cook initialization | 709 | * Cook initialization |
740 | */ | 710 | */ |
741 | 711 | ||
742 | av_cold int cook_decode_init(RMContext *rmctx, COOKContext *q) | 712 | int cook_decode_init(RMContext *rmctx, COOKContext *q) |
743 | { | 713 | { |
744 | /* cook extradata */ | 714 | /* cook extradata */ |
745 | q->cookversion = rmctx->cook_version; | 715 | q->cookversion = rmctx->cook_version; |
@@ -822,25 +792,6 @@ av_cold int cook_decode_init(RMContext *rmctx, COOKContext *q) | |||
822 | if(q->block_align >= UINT_MAX/2) | 792 | if(q->block_align >= UINT_MAX/2) |
823 | return -1; | 793 | return -1; |
824 | 794 | ||
825 | /* Pad the databuffer with: | ||
826 | DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(), | ||
827 | INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */ | ||
828 | |||
829 | #define INPUT_BUFFER_PADDING_SIZE 8 | ||
830 | if (q->nb_channels==2 && q->joint_stereo==0) { | ||
831 | q->decoded_bytes_buffer = | ||
832 | av_mallocz(rmctx->block_align/2 | ||
833 | + DECODE_BYTES_PAD2(q->block_align/2) | ||
834 | + INPUT_BUFFER_PADDING_SIZE); | ||
835 | } else { | ||
836 | q->decoded_bytes_buffer = | ||
837 | av_mallocz(rmctx->block_align | ||
838 | + DECODE_BYTES_PAD1(q->block_align) | ||
839 | + INPUT_BUFFER_PADDING_SIZE); | ||
840 | } | ||
841 | if (q->decoded_bytes_buffer == NULL) | ||
842 | return -1; | ||
843 | |||
844 | q->gains1.now = q->gain_1; | 795 | q->gains1.now = q->gain_1; |
845 | q->gains1.previous = q->gain_2; | 796 | q->gains1.previous = q->gain_2; |
846 | q->gains2.now = q->gain_3; | 797 | q->gains2.now = q->gain_3; |
diff --git a/apps/codecs/libcook/cook.h b/apps/codecs/libcook/cook.h index 8fcc6f86cd..da3c03f1d0 100644 --- a/apps/codecs/libcook/cook.h +++ b/apps/codecs/libcook/cook.h | |||
@@ -34,7 +34,7 @@ typedef struct { | |||
34 | 34 | ||
35 | typedef struct cook { | 35 | typedef struct cook { |
36 | /* | 36 | /* |
37 | * The following 5 functions provide the lowlevel arithmetic on | 37 | * The following 2 functions provide the lowlevel arithmetic on |
38 | * the internal audio buffers. | 38 | * the internal audio buffers. |
39 | */ | 39 | */ |
40 | void (* scalar_dequant)(struct cook *q, int index, int quant_index, | 40 | void (* scalar_dequant)(struct cook *q, int index, int quant_index, |
@@ -86,7 +86,7 @@ typedef struct cook { | |||
86 | 86 | ||
87 | /* data buffers */ | 87 | /* data buffers */ |
88 | 88 | ||
89 | uint8_t* decoded_bytes_buffer; | 89 | uint8_t decoded_bytes_buffer[1024]; |
90 | REAL_T mono_mdct_output[2048] __attribute__ ((aligned(16))); | 90 | REAL_T mono_mdct_output[2048] __attribute__ ((aligned(16))); |
91 | REAL_T mono_previous_buffer1[1024]; | 91 | REAL_T mono_previous_buffer1[1024]; |
92 | REAL_T mono_previous_buffer2[1024]; | 92 | REAL_T mono_previous_buffer2[1024]; |
@@ -95,9 +95,8 @@ typedef struct cook { | |||
95 | REAL_T decode_buffer_0[1060]; /* static allocation for joint decode */ | 95 | REAL_T decode_buffer_0[1060]; /* static allocation for joint decode */ |
96 | } COOKContext; | 96 | } COOKContext; |
97 | 97 | ||
98 | av_cold int cook_decode_init(RMContext *rmctx, COOKContext *q); | 98 | int cook_decode_init(RMContext *rmctx, COOKContext *q); |
99 | int cook_decode_frame(RMContext *rmctx,COOKContext *q, | 99 | int cook_decode_frame(RMContext *rmctx,COOKContext *q, |
100 | int16_t *outbuffer, int *data_size, | 100 | int16_t *outbuffer, int *data_size, |
101 | const uint8_t *inbuffer, int buf_size); | 101 | const uint8_t *inbuffer, int buf_size); |
102 | av_cold int cook_decode_close(COOKContext *q); | ||
103 | #endif | 102 | #endif |
diff --git a/apps/codecs/libcook/cook_fixpoint.h b/apps/codecs/libcook/cook_fixpoint.h index 83c054c527..0f12b1340a 100644 --- a/apps/codecs/libcook/cook_fixpoint.h +++ b/apps/codecs/libcook/cook_fixpoint.h | |||
@@ -35,6 +35,24 @@ | |||
35 | * in C using two 32 bit integer multiplications. | 35 | * in C using two 32 bit integer multiplications. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | /* The following table is taken from libavutil/mathematics.c */ | ||
39 | const uint8_t ff_log2_tab[256]={ | ||
40 | 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | ||
41 | 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, | ||
42 | 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, | ||
43 | 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, | ||
44 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
45 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
46 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
47 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 | ||
48 | }; | ||
49 | |||
50 | /* cplscales was moved from cookdata_fixpoint.h since only * | ||
51 | * cook_fixpoint.h should see/use it. */ | ||
52 | static const FIXPU* cplscales[5] = { | ||
53 | cplscale2, cplscale3, cplscale4, cplscale5, cplscale6 | ||
54 | }; | ||
55 | |||
38 | /** | 56 | /** |
39 | * Initialise fixed point implementation. | 57 | * Initialise fixed point implementation. |
40 | * Nothing to do for fixed point. | 58 | * Nothing to do for fixed point. |
@@ -86,6 +104,37 @@ static inline FIXP fixp_mult_su(FIXP a, FIXPU b) | |||
86 | return hb + (lb >> 16) + ((lb & 0x8000) >> 15); | 104 | return hb + (lb >> 16) + ((lb & 0x8000) >> 15); |
87 | } | 105 | } |
88 | 106 | ||
107 | /* math functions taken from libavutil/common.h */ | ||
108 | |||
109 | static inline int av_log2(unsigned int v) | ||
110 | { | ||
111 | int n = 0; | ||
112 | if (v & 0xffff0000) { | ||
113 | v >>= 16; | ||
114 | n += 16; | ||
115 | } | ||
116 | if (v & 0xff00) { | ||
117 | v >>= 8; | ||
118 | n += 8; | ||
119 | } | ||
120 | n += ff_log2_tab[v]; | ||
121 | |||
122 | return n; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * Clips a signed integer value into the amin-amax range. | ||
127 | * @param a value to clip | ||
128 | * @param amin minimum value of the clip range | ||
129 | * @param amax maximum value of the clip range | ||
130 | * @return clipped value | ||
131 | */ | ||
132 | static inline int av_clip(int a, int amin, int amax) | ||
133 | { | ||
134 | if (a < amin) return amin; | ||
135 | else if (a > amax) return amax; | ||
136 | else return a; | ||
137 | } | ||
89 | 138 | ||
90 | /** | 139 | /** |
91 | * The real requantization of the mltcoefs | 140 | * The real requantization of the mltcoefs |
diff --git a/apps/codecs/libcook/cookdata_fixpoint.h b/apps/codecs/libcook/cookdata_fixpoint.h index 10f5d35c07..b394c46a27 100644 --- a/apps/codecs/libcook/cookdata_fixpoint.h +++ b/apps/codecs/libcook/cookdata_fixpoint.h | |||
@@ -427,7 +427,3 @@ static const FIXPU cplscale6[63] = { | |||
427 | 0x450d, 0x408b, 0x3bcd, 0x36c1, 0x314d, 0x2b4a, 0x246e, 0x1c1a, 0x1029 | 427 | 0x450d, 0x408b, 0x3bcd, 0x36c1, 0x314d, 0x2b4a, 0x246e, 0x1c1a, 0x1029 |
428 | }; | 428 | }; |
429 | 429 | ||
430 | static const FIXPU* cplscales[5] = { | ||
431 | cplscale2, cplscale3, cplscale4, cplscale5, cplscale6 | ||
432 | }; | ||
433 | |||
diff --git a/apps/codecs/libcook/libavutil/bswap.h b/apps/codecs/libcook/libavutil/bswap.h index 9175cb24a5..443cd1c3f9 100644 --- a/apps/codecs/libcook/libavutil/bswap.h +++ b/apps/codecs/libcook/libavutil/bswap.h | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #include <stdint.h> | 29 | #include <stdint.h> |
30 | //#include "ffmpeg_config.h" | 30 | //#include "ffmpeg_config.h" |
31 | #include "common.h" | 31 | //#include "common.h" |
32 | 32 | ||
33 | #if ARCH_ARM | 33 | #if ARCH_ARM |
34 | # include "arm/bswap.h" | 34 | # include "arm/bswap.h" |
@@ -41,7 +41,7 @@ | |||
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #ifndef bswap_16 | 43 | #ifndef bswap_16 |
44 | static av_always_inline av_const uint16_t bswap_16(uint16_t x) | 44 | static inline uint16_t bswap_16(uint16_t x) |
45 | { | 45 | { |
46 | x= (x>>8) | (x<<8); | 46 | x= (x>>8) | (x<<8); |
47 | return x; | 47 | return x; |
@@ -49,7 +49,7 @@ static av_always_inline av_const uint16_t bswap_16(uint16_t x) | |||
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #ifndef bswap_32 | 51 | #ifndef bswap_32 |
52 | static av_always_inline av_const uint32_t bswap_32(uint32_t x) | 52 | static inline uint32_t bswap_32(uint32_t x) |
53 | { | 53 | { |
54 | x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); | 54 | x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); |
55 | x= (x>>16) | (x<<16); | 55 | x= (x>>16) | (x<<16); |
@@ -58,7 +58,7 @@ static av_always_inline av_const uint32_t bswap_32(uint32_t x) | |||
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #ifndef bswap_64 | 60 | #ifndef bswap_64 |
61 | static inline uint64_t av_const bswap_64(uint64_t x) | 61 | static inline uint64_t bswap_64(uint64_t x) |
62 | { | 62 | { |
63 | #if 0 | 63 | #if 0 |
64 | x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); | 64 | x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); |
diff --git a/apps/codecs/libcook/libavutil/common.h b/apps/codecs/libcook/libavutil/common.h deleted file mode 100644 index 949f093d35..0000000000 --- a/apps/codecs/libcook/libavutil/common.h +++ /dev/null | |||
@@ -1,286 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/common.h | ||
23 | * common internal and external API header | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_COMMON_H | ||
27 | #define AVUTIL_COMMON_H | ||
28 | |||
29 | #include <ctype.h> | ||
30 | #include <errno.h> | ||
31 | #include <inttypes.h> | ||
32 | #include <limits.h> | ||
33 | #include <math.h> | ||
34 | #include <stdio.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <string.h> | ||
37 | |||
38 | #ifdef __GNUC__ | ||
39 | # define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) | ||
40 | #else | ||
41 | # define AV_GCC_VERSION_AT_LEAST(x,y) 0 | ||
42 | #endif | ||
43 | |||
44 | #ifndef av_always_inline | ||
45 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
46 | # define av_always_inline __attribute__((always_inline)) inline | ||
47 | #else | ||
48 | # define av_always_inline inline | ||
49 | #endif | ||
50 | #endif | ||
51 | |||
52 | #ifndef av_noinline | ||
53 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
54 | # define av_noinline __attribute__((noinline)) | ||
55 | #else | ||
56 | # define av_noinline | ||
57 | #endif | ||
58 | #endif | ||
59 | |||
60 | #ifndef av_pure | ||
61 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
62 | # define av_pure __attribute__((pure)) | ||
63 | #else | ||
64 | # define av_pure | ||
65 | #endif | ||
66 | #endif | ||
67 | |||
68 | #ifndef av_const | ||
69 | #if AV_GCC_VERSION_AT_LEAST(2,6) | ||
70 | # define av_const __attribute__((const)) | ||
71 | #else | ||
72 | # define av_const | ||
73 | #endif | ||
74 | #endif | ||
75 | |||
76 | #ifndef av_cold | ||
77 | #if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,3) | ||
78 | # define av_cold __attribute__((cold)) | ||
79 | #else | ||
80 | # define av_cold | ||
81 | #endif | ||
82 | #endif | ||
83 | |||
84 | #ifndef av_flatten | ||
85 | #if AV_GCC_VERSION_AT_LEAST(4,1) | ||
86 | # define av_flatten __attribute__((flatten)) | ||
87 | #else | ||
88 | # define av_flatten | ||
89 | #endif | ||
90 | #endif | ||
91 | |||
92 | #ifndef attribute_deprecated | ||
93 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
94 | # define attribute_deprecated __attribute__((deprecated)) | ||
95 | #else | ||
96 | # define attribute_deprecated | ||
97 | #endif | ||
98 | #endif | ||
99 | |||
100 | #ifndef av_unused | ||
101 | #if defined(__GNUC__) | ||
102 | # define av_unused __attribute__((unused)) | ||
103 | #else | ||
104 | # define av_unused | ||
105 | #endif | ||
106 | #endif | ||
107 | |||
108 | #ifndef av_uninit | ||
109 | #if defined(__GNUC__) && !defined(__ICC) | ||
110 | # define av_uninit(x) x=x | ||
111 | #else | ||
112 | # define av_uninit(x) x | ||
113 | #endif | ||
114 | #endif | ||
115 | |||
116 | //rounded division & shift | ||
117 | #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) | ||
118 | /* assume b>0 */ | ||
119 | #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) | ||
120 | #define FFABS(a) ((a) >= 0 ? (a) : (-(a))) | ||
121 | #define FFSIGN(a) ((a) > 0 ? 1 : -1) | ||
122 | |||
123 | #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) | ||
124 | #define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) | ||
125 | #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) | ||
126 | #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) | ||
127 | |||
128 | #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) | ||
129 | #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) | ||
130 | |||
131 | /* misc math functions */ | ||
132 | extern const uint8_t ff_log2_tab[256]; | ||
133 | |||
134 | static inline av_const int av_log2(unsigned int v) | ||
135 | { | ||
136 | int n = 0; | ||
137 | if (v & 0xffff0000) { | ||
138 | v >>= 16; | ||
139 | n += 16; | ||
140 | } | ||
141 | if (v & 0xff00) { | ||
142 | v >>= 8; | ||
143 | n += 8; | ||
144 | } | ||
145 | n += ff_log2_tab[v]; | ||
146 | |||
147 | return n; | ||
148 | } | ||
149 | |||
150 | static inline av_const int av_log2_16bit(unsigned int v) | ||
151 | { | ||
152 | int n = 0; | ||
153 | if (v & 0xff00) { | ||
154 | v >>= 8; | ||
155 | n += 8; | ||
156 | } | ||
157 | n += ff_log2_tab[v]; | ||
158 | |||
159 | return n; | ||
160 | } | ||
161 | |||
162 | /** | ||
163 | * Clips a signed integer value into the amin-amax range. | ||
164 | * @param a value to clip | ||
165 | * @param amin minimum value of the clip range | ||
166 | * @param amax maximum value of the clip range | ||
167 | * @return clipped value | ||
168 | */ | ||
169 | static inline av_const int av_clip(int a, int amin, int amax) | ||
170 | { | ||
171 | if (a < amin) return amin; | ||
172 | else if (a > amax) return amax; | ||
173 | else return a; | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * Clips a signed integer value into the 0-255 range. | ||
178 | * @param a value to clip | ||
179 | * @return clipped value | ||
180 | */ | ||
181 | static inline av_const uint8_t av_clip_uint8(int a) | ||
182 | { | ||
183 | if (a&(~255)) return (-a)>>31; | ||
184 | else return a; | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * Clips a signed integer value into the -32768,32767 range. | ||
189 | * @param a value to clip | ||
190 | * @return clipped value | ||
191 | */ | ||
192 | static inline av_const int16_t av_clip_int16(int a) | ||
193 | { | ||
194 | if ((a+32768) & ~65535) return (a>>31) ^ 32767; | ||
195 | else return a; | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * Clips a float value into the amin-amax range. | ||
200 | * @param a value to clip | ||
201 | * @param amin minimum value of the clip range | ||
202 | * @param amax maximum value of the clip range | ||
203 | * @return clipped value | ||
204 | */ | ||
205 | static inline av_const float av_clipf(float a, float amin, float amax) | ||
206 | { | ||
207 | if (a < amin) return amin; | ||
208 | else if (a > amax) return amax; | ||
209 | else return a; | ||
210 | } | ||
211 | |||
212 | #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) | ||
213 | #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) | ||
214 | |||
215 | /*! | ||
216 | * \def GET_UTF8(val, GET_BYTE, ERROR) | ||
217 | * Converts a UTF-8 character (up to 4 bytes long) to its 32-bit UCS-4 encoded form | ||
218 | * \param val is the output and should be of type uint32_t. It holds the converted | ||
219 | * UCS-4 character and should be a left value. | ||
220 | * \param GET_BYTE gets UTF-8 encoded bytes from any proper source. It can be | ||
221 | * a function or a statement whose return value or evaluated value is of type | ||
222 | * uint8_t. It will be executed up to 4 times for values in the valid UTF-8 range, | ||
223 | * and up to 7 times in the general case. | ||
224 | * \param ERROR action that should be taken when an invalid UTF-8 byte is returned | ||
225 | * from GET_BYTE. It should be a statement that jumps out of the macro, | ||
226 | * like exit(), goto, return, break, or continue. | ||
227 | */ | ||
228 | #define GET_UTF8(val, GET_BYTE, ERROR)\ | ||
229 | val= GET_BYTE;\ | ||
230 | {\ | ||
231 | int ones= 7 - av_log2(val ^ 255);\ | ||
232 | if(ones==1)\ | ||
233 | ERROR\ | ||
234 | val&= 127>>ones;\ | ||
235 | while(--ones > 0){\ | ||
236 | int tmp= GET_BYTE - 128;\ | ||
237 | if(tmp>>6)\ | ||
238 | ERROR\ | ||
239 | val= (val<<6) + tmp;\ | ||
240 | }\ | ||
241 | } | ||
242 | |||
243 | /*! | ||
244 | * \def PUT_UTF8(val, tmp, PUT_BYTE) | ||
245 | * Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). | ||
246 | * \param val is an input-only argument and should be of type uint32_t. It holds | ||
247 | * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If | ||
248 | * val is given as a function it is executed only once. | ||
249 | * \param tmp is a temporary variable and should be of type uint8_t. It | ||
250 | * represents an intermediate value during conversion that is to be | ||
251 | * output by PUT_BYTE. | ||
252 | * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. | ||
253 | * It could be a function or a statement, and uses tmp as the input byte. | ||
254 | * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be | ||
255 | * executed up to 4 times for values in the valid UTF-8 range and up to | ||
256 | * 7 times in the general case, depending on the length of the converted | ||
257 | * Unicode character. | ||
258 | */ | ||
259 | #define PUT_UTF8(val, tmp, PUT_BYTE)\ | ||
260 | {\ | ||
261 | int bytes, shift;\ | ||
262 | uint32_t in = val;\ | ||
263 | if (in < 0x80) {\ | ||
264 | tmp = in;\ | ||
265 | PUT_BYTE\ | ||
266 | } else {\ | ||
267 | bytes = (av_log2(in) + 4) / 5;\ | ||
268 | shift = (bytes - 1) * 6;\ | ||
269 | tmp = (256 - (256 >> bytes)) | (in >> shift);\ | ||
270 | PUT_BYTE\ | ||
271 | while (shift >= 6) {\ | ||
272 | shift -= 6;\ | ||
273 | tmp = 0x80 | ((in >> shift) & 0x3f);\ | ||
274 | PUT_BYTE\ | ||
275 | }\ | ||
276 | }\ | ||
277 | } | ||
278 | |||
279 | #include "mem.h" | ||
280 | |||
281 | //#ifdef HAVE_AV_CONFIG_H | ||
282 | //# include "ffmpeg_config.h" | ||
283 | # include "internal.h" | ||
284 | //#endif /* HAVE_AV_CONFIG_H */ | ||
285 | |||
286 | #endif /* AVUTIL_COMMON_H */ | ||
diff --git a/apps/codecs/libcook/libavutil/internal.h b/apps/codecs/libcook/libavutil/internal.h deleted file mode 100644 index c28b6f9a5e..0000000000 --- a/apps/codecs/libcook/libavutil/internal.h +++ /dev/null | |||
@@ -1,328 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/internal.h | ||
23 | * common internal API header | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_INTERNAL_H | ||
27 | #define AVUTIL_INTERNAL_H | ||
28 | |||
29 | #if !defined(DEBUG) && !defined(NDEBUG) | ||
30 | # define NDEBUG | ||
31 | #endif | ||
32 | |||
33 | #include <limits.h> | ||
34 | #include <stdint.h> | ||
35 | #include <stddef.h> | ||
36 | #include <assert.h> | ||
37 | //#include "ffmpeg_config.h" | ||
38 | #include "common.h" | ||
39 | #include "mem.h" | ||
40 | //#include "timer.h" | ||
41 | |||
42 | #ifndef attribute_align_arg | ||
43 | #if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,2) | ||
44 | # define attribute_align_arg __attribute__((force_align_arg_pointer)) | ||
45 | #else | ||
46 | # define attribute_align_arg | ||
47 | #endif | ||
48 | #endif | ||
49 | |||
50 | #ifndef attribute_used | ||
51 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
52 | # define attribute_used __attribute__((used)) | ||
53 | #else | ||
54 | # define attribute_used | ||
55 | #endif | ||
56 | #endif | ||
57 | |||
58 | #ifndef INT16_MIN | ||
59 | #define INT16_MIN (-0x7fff-1) | ||
60 | #endif | ||
61 | |||
62 | #ifndef INT16_MAX | ||
63 | #define INT16_MAX 0x7fff | ||
64 | #endif | ||
65 | |||
66 | #ifndef INT32_MIN | ||
67 | #define INT32_MIN (-0x7fffffff-1) | ||
68 | #endif | ||
69 | |||
70 | #ifndef INT32_MAX | ||
71 | #define INT32_MAX 0x7fffffff | ||
72 | #endif | ||
73 | |||
74 | #ifndef UINT32_MAX | ||
75 | #define UINT32_MAX 0xffffffff | ||
76 | #endif | ||
77 | |||
78 | #ifndef INT64_MIN | ||
79 | #define INT64_MIN (-0x7fffffffffffffffLL-1) | ||
80 | #endif | ||
81 | |||
82 | #ifndef INT64_MAX | ||
83 | #define INT64_MAX INT64_C(9223372036854775807) | ||
84 | #endif | ||
85 | |||
86 | #ifndef UINT64_MAX | ||
87 | #define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) | ||
88 | #endif | ||
89 | |||
90 | #ifndef INT_BIT | ||
91 | # define INT_BIT (CHAR_BIT * sizeof(int)) | ||
92 | #endif | ||
93 | |||
94 | #if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC) | ||
95 | # define PIC | ||
96 | #endif | ||
97 | |||
98 | #ifndef offsetof | ||
99 | # define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F)) | ||
100 | #endif | ||
101 | |||
102 | // Use rip-relative addressing if compiling PIC code on x86-64. | ||
103 | #if ARCH_X86_64 && defined(PIC) | ||
104 | # define LOCAL_MANGLE(a) #a "(%%rip)" | ||
105 | #else | ||
106 | # define LOCAL_MANGLE(a) #a | ||
107 | #endif | ||
108 | |||
109 | #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) | ||
110 | |||
111 | /* debug stuff */ | ||
112 | |||
113 | /* dprintf macros */ | ||
114 | #ifdef DEBUG | ||
115 | # define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) | ||
116 | #else | ||
117 | # define dprintf(pctx, ...) | ||
118 | #endif | ||
119 | |||
120 | #define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) | ||
121 | |||
122 | /* math */ | ||
123 | |||
124 | extern const uint32_t ff_inverse[256]; | ||
125 | |||
126 | #if ARCH_X86 | ||
127 | # define FASTDIV(a,b) \ | ||
128 | ({\ | ||
129 | int ret,dmy;\ | ||
130 | __asm__ volatile(\ | ||
131 | "mull %3"\ | ||
132 | :"=d"(ret),"=a"(dmy)\ | ||
133 | :"1"(a),"g"(ff_inverse[b])\ | ||
134 | );\ | ||
135 | ret;\ | ||
136 | }) | ||
137 | #elif HAVE_ARMV6 && HAVE_INLINE_ASM | ||
138 | static inline av_const int FASTDIV(int a, int b) | ||
139 | { | ||
140 | int r, t; | ||
141 | __asm__ volatile("cmp %3, #2 \n\t" | ||
142 | "ldr %1, [%4, %3, lsl #2] \n\t" | ||
143 | "lsrle %0, %2, #1 \n\t" | ||
144 | "smmulgt %0, %1, %2 \n\t" | ||
145 | : "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse)); | ||
146 | return r; | ||
147 | } | ||
148 | #elif ARCH_ARM && HAVE_INLINE_ASM | ||
149 | static inline av_const int FASTDIV(int a, int b) | ||
150 | { | ||
151 | int r, t; | ||
152 | __asm__ volatile ("umull %1, %0, %2, %3" | ||
153 | : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); | ||
154 | return r; | ||
155 | } | ||
156 | #elif CONFIG_FASTDIV | ||
157 | # define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*ff_inverse[b])>>32)) | ||
158 | #else | ||
159 | # define FASTDIV(a,b) ((a)/(b)) | ||
160 | #endif | ||
161 | |||
162 | extern const uint8_t ff_sqrt_tab[256]; | ||
163 | |||
164 | static inline av_const unsigned int ff_sqrt(unsigned int a) | ||
165 | { | ||
166 | unsigned int b; | ||
167 | |||
168 | if(a<255) return (ff_sqrt_tab[a+1]-1)>>4; | ||
169 | else if(a<(1<<12)) b= ff_sqrt_tab[a>>4 ]>>2; | ||
170 | #if !CONFIG_SMALL | ||
171 | else if(a<(1<<14)) b= ff_sqrt_tab[a>>6 ]>>1; | ||
172 | else if(a<(1<<16)) b= ff_sqrt_tab[a>>8 ] ; | ||
173 | #endif | ||
174 | else{ | ||
175 | int s= av_log2_16bit(a>>16)>>1; | ||
176 | unsigned int c= a>>(s+2); | ||
177 | b= ff_sqrt_tab[c>>(s+8)]; | ||
178 | b= FASTDIV(c,b) + (b<<s); | ||
179 | } | ||
180 | |||
181 | return b - (a<b*b); | ||
182 | } | ||
183 | |||
184 | #if ARCH_X86 | ||
185 | #define MASK_ABS(mask, level)\ | ||
186 | __asm__ volatile(\ | ||
187 | "cltd \n\t"\ | ||
188 | "xorl %1, %0 \n\t"\ | ||
189 | "subl %1, %0 \n\t"\ | ||
190 | : "+a" (level), "=&d" (mask)\ | ||
191 | ); | ||
192 | #else | ||
193 | #define MASK_ABS(mask, level)\ | ||
194 | mask= level>>31;\ | ||
195 | level= (level^mask)-mask; | ||
196 | #endif | ||
197 | |||
198 | #if HAVE_CMOV | ||
199 | #define COPY3_IF_LT(x,y,a,b,c,d)\ | ||
200 | __asm__ volatile (\ | ||
201 | "cmpl %0, %3 \n\t"\ | ||
202 | "cmovl %3, %0 \n\t"\ | ||
203 | "cmovl %4, %1 \n\t"\ | ||
204 | "cmovl %5, %2 \n\t"\ | ||
205 | : "+&r" (x), "+&r" (a), "+r" (c)\ | ||
206 | : "r" (y), "r" (b), "r" (d)\ | ||
207 | ); | ||
208 | #else | ||
209 | #define COPY3_IF_LT(x,y,a,b,c,d)\ | ||
210 | if((y)<(x)){\ | ||
211 | (x)=(y);\ | ||
212 | (a)=(b);\ | ||
213 | (c)=(d);\ | ||
214 | } | ||
215 | #endif | ||
216 | |||
217 | /* avoid usage of dangerous/inappropriate system functions */ | ||
218 | #undef malloc | ||
219 | #define malloc please_use_av_malloc | ||
220 | #undef free | ||
221 | #define free please_use_av_free | ||
222 | #undef realloc | ||
223 | #define realloc please_use_av_realloc | ||
224 | #undef time | ||
225 | #define time time_is_forbidden_due_to_security_issues | ||
226 | //#undef rand | ||
227 | //#define rand rand_is_forbidden_due_to_state_trashing_use_av_random | ||
228 | //#undef srand | ||
229 | //#define srand srand_is_forbidden_due_to_state_trashing_use_av_random_init | ||
230 | #undef random | ||
231 | #define random random_is_forbidden_due_to_state_trashing_use_av_random | ||
232 | #undef sprintf | ||
233 | #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf | ||
234 | #undef strcat | ||
235 | #define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat | ||
236 | #undef exit | ||
237 | #define exit exit_is_forbidden | ||
238 | #ifndef LIBAVFORMAT_BUILD | ||
239 | //#undef printf | ||
240 | //#define printf please_use_av_log_instead_of_printf | ||
241 | #undef fprintf | ||
242 | #define fprintf please_use_av_log_instead_of_fprintf | ||
243 | #undef puts | ||
244 | #define puts please_use_av_log_instead_of_puts | ||
245 | #undef perror | ||
246 | #define perror please_use_av_log_instead_of_perror | ||
247 | #endif | ||
248 | |||
249 | #define CHECKED_ALLOCZ(p, size)\ | ||
250 | {\ | ||
251 | p= av_mallocz(size);\ | ||
252 | if(p==NULL && (size)!=0){\ | ||
253 | av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory.");\ | ||
254 | goto fail;\ | ||
255 | }\ | ||
256 | } | ||
257 | |||
258 | #if defined(__ICC) || defined(__SUNPRO_C) | ||
259 | #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) | ||
260 | #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v | ||
261 | #elif defined(__GNUC__) | ||
262 | #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) | ||
263 | #define DECLARE_ASM_CONST(n,t,v) static const t v attribute_used __attribute__ ((aligned (n))) | ||
264 | #elif defined(_MSC_VER) | ||
265 | #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v | ||
266 | #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v | ||
267 | #elif HAVE_INLINE_ASM | ||
268 | #error The asm code needs alignment, but we do not know how to do it for this compiler. | ||
269 | #else | ||
270 | #define DECLARE_ALIGNED(n,t,v) t v | ||
271 | #define DECLARE_ASM_CONST(n,t,v) static const t v | ||
272 | #endif | ||
273 | |||
274 | |||
275 | #if !HAVE_LLRINT | ||
276 | static av_always_inline av_const long long llrint(double x) | ||
277 | { | ||
278 | return rint(x); | ||
279 | } | ||
280 | #endif /* HAVE_LLRINT */ | ||
281 | |||
282 | #if !HAVE_LRINT | ||
283 | static av_always_inline av_const long int lrint(double x) | ||
284 | { | ||
285 | return rint(x); | ||
286 | } | ||
287 | #endif /* HAVE_LRINT */ | ||
288 | |||
289 | #if !HAVE_LRINTF | ||
290 | static av_always_inline av_const long int lrintf(float x) | ||
291 | { | ||
292 | return (int)(rint(x)); | ||
293 | } | ||
294 | #endif /* HAVE_LRINTF */ | ||
295 | |||
296 | #if !HAVE_ROUND | ||
297 | static av_always_inline av_const double round(double x) | ||
298 | { | ||
299 | return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); | ||
300 | } | ||
301 | #endif /* HAVE_ROUND */ | ||
302 | |||
303 | #if !HAVE_ROUNDF | ||
304 | static av_always_inline av_const float roundf(float x) | ||
305 | { | ||
306 | return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); | ||
307 | } | ||
308 | #endif /* HAVE_ROUNDF */ | ||
309 | |||
310 | #if !HAVE_TRUNCF | ||
311 | static av_always_inline av_const float truncf(float x) | ||
312 | { | ||
313 | return (x > 0) ? floor(x) : ceil(x); | ||
314 | } | ||
315 | #endif /* HAVE_TRUNCF */ | ||
316 | |||
317 | /** | ||
318 | * Returns NULL if CONFIG_SMALL is true, otherwise the argument | ||
319 | * without modification. Used to disable the definition of strings | ||
320 | * (for example AVCodec long_names). | ||
321 | */ | ||
322 | #if CONFIG_SMALL | ||
323 | # define NULL_IF_CONFIG_SMALL(x) NULL | ||
324 | #else | ||
325 | # define NULL_IF_CONFIG_SMALL(x) x | ||
326 | #endif | ||
327 | |||
328 | #endif /* AVUTIL_INTERNAL_H */ | ||
diff --git a/apps/codecs/libcook/libavutil/mem.c b/apps/codecs/libcook/libavutil/mem.c deleted file mode 100644 index 7307df2384..0000000000 --- a/apps/codecs/libcook/libavutil/mem.c +++ /dev/null | |||
@@ -1,158 +0,0 @@ | |||
1 | /* | ||
2 | * default memory allocator for libavutil | ||
3 | * Copyright (c) 2002 Fabrice Bellard | ||
4 | * | ||
5 | * This file is part of FFmpeg. | ||
6 | * | ||
7 | * FFmpeg is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * FFmpeg is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with FFmpeg; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * @file libavutil/mem.c | ||
24 | * default memory allocator for libavutil | ||
25 | */ | ||
26 | |||
27 | |||
28 | #include <limits.h> | ||
29 | #include <stdlib.h> | ||
30 | #include <string.h> | ||
31 | #if HAVE_MALLOC_H | ||
32 | #include <malloc.h> | ||
33 | #endif | ||
34 | |||
35 | #include "mem.h" | ||
36 | |||
37 | /* here we can use OS-dependent allocation functions */ | ||
38 | #undef free | ||
39 | #undef malloc | ||
40 | #undef realloc | ||
41 | |||
42 | /* You can redefine av_malloc and av_free in your project to use your | ||
43 | memory allocator. You do not need to suppress this file because the | ||
44 | linker will do it automatically. */ | ||
45 | |||
46 | void *av_malloc(unsigned int size) | ||
47 | { | ||
48 | void *ptr = NULL; | ||
49 | #if CONFIG_MEMALIGN_HACK | ||
50 | long diff; | ||
51 | #endif | ||
52 | |||
53 | /* let's disallow possible ambiguous cases */ | ||
54 | if(size > (INT_MAX-16) ) | ||
55 | return NULL; | ||
56 | |||
57 | #if CONFIG_MEMALIGN_HACK | ||
58 | ptr = malloc(size+16); | ||
59 | if(!ptr) | ||
60 | return ptr; | ||
61 | diff= ((-(long)ptr - 1)&15) + 1; | ||
62 | ptr = (char*)ptr + diff; | ||
63 | ((char*)ptr)[-1]= diff; | ||
64 | #elif HAVE_POSIX_MEMALIGN | ||
65 | if (posix_memalign(&ptr,16,size)) | ||
66 | ptr = NULL; | ||
67 | #elif HAVE_MEMALIGN | ||
68 | ptr = memalign(16,size); | ||
69 | /* Why 64? | ||
70 | Indeed, we should align it: | ||
71 | on 4 for 386 | ||
72 | on 16 for 486 | ||
73 | on 32 for 586, PPro - K6-III | ||
74 | on 64 for K7 (maybe for P3 too). | ||
75 | Because L1 and L2 caches are aligned on those values. | ||
76 | But I don't want to code such logic here! | ||
77 | */ | ||
78 | /* Why 16? | ||
79 | Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs | ||
80 | it will just trigger an exception and the unaligned load will be done in the | ||
81 | exception handler or it will just segfault (SSE2 on P4). | ||
82 | Why not larger? Because I did not see a difference in benchmarks ... | ||
83 | */ | ||
84 | /* benchmarks with P3 | ||
85 | memalign(64)+1 3071,3051,3032 | ||
86 | memalign(64)+2 3051,3032,3041 | ||
87 | memalign(64)+4 2911,2896,2915 | ||
88 | memalign(64)+8 2545,2554,2550 | ||
89 | memalign(64)+16 2543,2572,2563 | ||
90 | memalign(64)+32 2546,2545,2571 | ||
91 | memalign(64)+64 2570,2533,2558 | ||
92 | |||
93 | BTW, malloc seems to do 8-byte alignment by default here. | ||
94 | */ | ||
95 | #else | ||
96 | ptr = malloc(size); | ||
97 | #endif | ||
98 | return ptr; | ||
99 | } | ||
100 | |||
101 | void *av_realloc(void *ptr, unsigned int size) | ||
102 | { | ||
103 | #if CONFIG_MEMALIGN_HACK | ||
104 | int diff; | ||
105 | #endif | ||
106 | |||
107 | /* let's disallow possible ambiguous cases */ | ||
108 | if(size > (INT_MAX-16) ) | ||
109 | return NULL; | ||
110 | |||
111 | #if CONFIG_MEMALIGN_HACK | ||
112 | //FIXME this isn't aligned correctly, though it probably isn't needed | ||
113 | if(!ptr) return av_malloc(size); | ||
114 | diff= ((char*)ptr)[-1]; | ||
115 | return (char*)realloc((char*)ptr - diff, size + diff) + diff; | ||
116 | #else | ||
117 | return realloc(ptr, size); | ||
118 | #endif | ||
119 | } | ||
120 | |||
121 | void av_free(void *ptr) | ||
122 | { | ||
123 | /* XXX: this test should not be needed on most libcs */ | ||
124 | if (ptr) | ||
125 | #if CONFIG_MEMALIGN_HACK | ||
126 | free((char*)ptr - ((char*)ptr)[-1]); | ||
127 | #else | ||
128 | free(ptr); | ||
129 | #endif | ||
130 | } | ||
131 | |||
132 | void av_freep(void *arg) | ||
133 | { | ||
134 | void **ptr= (void**)arg; | ||
135 | av_free(*ptr); | ||
136 | *ptr = NULL; | ||
137 | } | ||
138 | |||
139 | void *av_mallocz(unsigned int size) | ||
140 | { | ||
141 | void *ptr = av_malloc(size); | ||
142 | if (ptr) | ||
143 | memset(ptr, 0, size); | ||
144 | return ptr; | ||
145 | } | ||
146 | |||
147 | char *av_strdup(const char *s) | ||
148 | { | ||
149 | char *ptr= NULL; | ||
150 | if(s){ | ||
151 | int len = strlen(s) + 1; | ||
152 | ptr = av_malloc(len); | ||
153 | if (ptr) | ||
154 | memcpy(ptr, s, len); | ||
155 | } | ||
156 | return ptr; | ||
157 | } | ||
158 | |||
diff --git a/apps/codecs/libcook/libavutil/mem.h b/apps/codecs/libcook/libavutil/mem.h deleted file mode 100644 index e50553aefe..0000000000 --- a/apps/codecs/libcook/libavutil/mem.h +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/mem.h | ||
23 | * memory handling functions | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_MEM_H | ||
27 | #define AVUTIL_MEM_H | ||
28 | |||
29 | #include "common.h" | ||
30 | |||
31 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
32 | #define av_malloc_attrib __attribute__((__malloc__)) | ||
33 | #else | ||
34 | #define av_malloc_attrib | ||
35 | #endif | ||
36 | |||
37 | #if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,3) | ||
38 | #define av_alloc_size(n) __attribute__((alloc_size(n))) | ||
39 | #else | ||
40 | #define av_alloc_size(n) | ||
41 | #endif | ||
42 | |||
43 | /** | ||
44 | * Allocates a block of \p size bytes with alignment suitable for all | ||
45 | * memory accesses (including vectors if available on the CPU). | ||
46 | * @param size Size in bytes for the memory block to be allocated. | ||
47 | * @return Pointer to the allocated block, NULL if the block cannot | ||
48 | * be allocated. | ||
49 | * @see av_mallocz() | ||
50 | */ | ||
51 | void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); | ||
52 | |||
53 | /** | ||
54 | * Allocates or reallocates a block of memory. | ||
55 | * If \p ptr is NULL and \p size > 0, allocates a new block. If \p | ||
56 | * size is zero, frees the memory block pointed to by \p ptr. | ||
57 | * @param size Size in bytes for the memory block to be allocated or | ||
58 | * reallocated. | ||
59 | * @param ptr Pointer to a memory block already allocated with | ||
60 | * av_malloc(z)() or av_realloc() or NULL. | ||
61 | * @return Pointer to a newly reallocated block or NULL if the block | ||
62 | * cannot be reallocated or the function is used to free the memory block. | ||
63 | * @see av_fast_realloc() | ||
64 | */ | ||
65 | void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); | ||
66 | |||
67 | /** | ||
68 | * Frees a memory block which has been allocated with av_malloc(z)() or | ||
69 | * av_realloc(). | ||
70 | * @param ptr Pointer to the memory block which should be freed. | ||
71 | * @note ptr = NULL is explicitly allowed. | ||
72 | * @note It is recommended that you use av_freep() instead. | ||
73 | * @see av_freep() | ||
74 | */ | ||
75 | void av_free(void *ptr); | ||
76 | |||
77 | /** | ||
78 | * Allocates a block of \p size bytes with alignment suitable for all | ||
79 | * memory accesses (including vectors if available on the CPU) and | ||
80 | * zeroes all the bytes of the block. | ||
81 | * @param size Size in bytes for the memory block to be allocated. | ||
82 | * @return Pointer to the allocated block, NULL if it cannot be allocated. | ||
83 | * @see av_malloc() | ||
84 | */ | ||
85 | void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); | ||
86 | |||
87 | /** | ||
88 | * Duplicates the string \p s. | ||
89 | * @param s string to be duplicated | ||
90 | * @return Pointer to a newly allocated string containing a | ||
91 | * copy of \p s or NULL if the string cannot be allocated. | ||
92 | */ | ||
93 | char *av_strdup(const char *s) av_malloc_attrib; | ||
94 | |||
95 | /** | ||
96 | * Frees a memory block which has been allocated with av_malloc(z)() or | ||
97 | * av_realloc() and set the pointer pointing to it to NULL. | ||
98 | * @param ptr Pointer to the pointer to the memory block which should | ||
99 | * be freed. | ||
100 | * @see av_free() | ||
101 | */ | ||
102 | void av_freep(void *ptr); | ||
103 | |||
104 | #endif /* AVUTIL_MEM_H */ | ||
diff --git a/apps/codecs/libcook/main.c b/apps/codecs/libcook/main.c index 8b180b249d..3c671e0c3f 100644 --- a/apps/codecs/libcook/main.c +++ b/apps/codecs/libcook/main.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <sys/stat.h> | 23 | #include <sys/stat.h> |
24 | #include <fcntl.h> | 24 | #include <fcntl.h> |
25 | #include <unistd.h> | 25 | #include <unistd.h> |
26 | #include <string.h> | ||
26 | 27 | ||
27 | #include "rm2wav.h" | 28 | #include "rm2wav.h" |
28 | #include "cook.h" | 29 | #include "cook.h" |
@@ -111,8 +112,7 @@ int main(int argc, char *argv[]) | |||
111 | } | 112 | } |
112 | packet_count -= rmctx.audio_pkt_cnt; | 113 | packet_count -= rmctx.audio_pkt_cnt; |
113 | rmctx.audio_pkt_cnt = 0; | 114 | rmctx.audio_pkt_cnt = 0; |
114 | } | 115 | } |
115 | cook_decode_close(&q); | ||
116 | close_wav(fd_dec,&rmctx); | 116 | close_wav(fd_dec,&rmctx); |
117 | close(fd); | 117 | close(fd); |
118 | 118 | ||