diff options
author | Mohamed Tarek <mt@rockbox.org> | 2009-05-12 13:21:34 +0000 |
---|---|---|
committer | Mohamed Tarek <mt@rockbox.org> | 2009-05-12 13:21:34 +0000 |
commit | f2c18d6922257c6610f4c01ed09ce318295bee68 (patch) | |
tree | b71ccdd43d0213c1b78bebbe7593ebb4d25306af /apps/codecs/libcook/cook.c | |
parent | 950c4747e3c519372382e6b5a7e84bfd22e12d5c (diff) | |
download | rockbox-f2c18d6922257c6610f4c01ed09ce318295bee68.tar.gz rockbox-f2c18d6922257c6610f4c01ed09ce318295bee68.zip |
-Remove calls to av_log() and use DEBUGF/printf instead, thuse removing
libavutil/log.[c/h] and libavutil/avutil.h.
-Take necessary defines to bitstream.h from libavutil/intreadwrite.h to
remove the latter.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20918 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libcook/cook.c')
-rw-r--r-- | apps/codecs/libcook/cook.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/apps/codecs/libcook/cook.c b/apps/codecs/libcook/cook.c index 5b2c59a6c5..fd80c1bd2e 100644 --- a/apps/codecs/libcook/cook.c +++ b/apps/codecs/libcook/cook.c | |||
@@ -70,7 +70,11 @@ const uint8_t ff_log2_tab[256]={ | |||
70 | #define SUBBAND_SIZE 20 | 70 | #define SUBBAND_SIZE 20 |
71 | #define MAX_SUBPACKETS 5 | 71 | #define MAX_SUBPACKETS 5 |
72 | //#define COOKDEBUG | 72 | //#define COOKDEBUG |
73 | #define DEBUGF(message,args ...) av_log(NULL,AV_LOG_ERROR,message,## args) | 73 | #if 0 |
74 | #define DEBUGF(message,args ...) printf | ||
75 | #else | ||
76 | #define DEBUGF(...) | ||
77 | #endif | ||
74 | 78 | ||
75 | /** | 79 | /** |
76 | * Random bit stream generator. | 80 | * Random bit stream generator. |
@@ -89,19 +93,19 @@ static int inline cook_random(COOKContext *q) | |||
89 | #ifdef COOKDEBUG | 93 | #ifdef COOKDEBUG |
90 | static void dump_int_table(int* table, int size, int delimiter) { | 94 | static void dump_int_table(int* table, int size, int delimiter) { |
91 | int i=0; | 95 | int i=0; |
92 | av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i); | 96 | DEBUGF("\n[%d]: ",i); |
93 | for (i=0 ; i<size ; i++) { | 97 | for (i=0 ; i<size ; i++) { |
94 | av_log(NULL, AV_LOG_ERROR, "%d, ", table[i]); | 98 | DEBUGF("%d, ", table[i]); |
95 | if ((i+1)%delimiter == 0) av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i+1); | 99 | if ((i+1)%delimiter == 0) DEBUGF("\n[%d]: ",i+1); |
96 | } | 100 | } |
97 | } | 101 | } |
98 | 102 | ||
99 | static void dump_short_table(short* table, int size, int delimiter) { | 103 | static void dump_short_table(short* table, int size, int delimiter) { |
100 | int i=0; | 104 | int i=0; |
101 | av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i); | 105 | DEBUGF("\n[%d]: ",i); |
102 | for (i=0 ; i<size ; i++) { | 106 | for (i=0 ; i<size ; i++) { |
103 | av_log(NULL, AV_LOG_ERROR, "%d, ", table[i]); | 107 | DEBUGF("%d, ", table[i]); |
104 | if ((i+1)%delimiter == 0) av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i+1); | 108 | if ((i+1)%delimiter == 0) DEBUGF("\n[%d]: ",i+1); |
105 | } | 109 | } |
106 | } | 110 | } |
107 | 111 | ||
@@ -117,7 +121,7 @@ static av_cold int init_cook_vlc_tables(COOKContext *q) { | |||
117 | envelope_quant_index_huffbits[i], 1, 1, | 121 | envelope_quant_index_huffbits[i], 1, 1, |
118 | envelope_quant_index_huffcodes[i], 2, 2, 0); | 122 | envelope_quant_index_huffcodes[i], 2, 2, 0); |
119 | } | 123 | } |
120 | av_log(NULL,AV_LOG_DEBUG,"sqvh VLC init\n"); | 124 | DEBUGF("sqvh VLC init\n"); |
121 | for (i=0 ; i<7 ; i++) { | 125 | for (i=0 ; i<7 ; i++) { |
122 | result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i], | 126 | result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i], |
123 | cvh_huffbits[i], 1, 1, | 127 | cvh_huffbits[i], 1, 1, |
@@ -128,10 +132,10 @@ static av_cold int init_cook_vlc_tables(COOKContext *q) { | |||
128 | result |= init_vlc (&q->ccpl, 6, (1<<q->js_vlc_bits)-1, | 132 | result |= init_vlc (&q->ccpl, 6, (1<<q->js_vlc_bits)-1, |
129 | ccpl_huffbits[q->js_vlc_bits-2], 1, 1, | 133 | ccpl_huffbits[q->js_vlc_bits-2], 1, 1, |
130 | ccpl_huffcodes[q->js_vlc_bits-2], 2, 2, 0); | 134 | ccpl_huffcodes[q->js_vlc_bits-2], 2, 2, 0); |
131 | av_log(NULL,AV_LOG_DEBUG,"Joint-stereo VLC used.\n"); | 135 | DEBUGF("Joint-stereo VLC used.\n"); |
132 | } | 136 | } |
133 | 137 | ||
134 | av_log(NULL,AV_LOG_ERROR,"VLC tables initialized. Result = %d\n",result); | 138 | DEBUGF("VLC tables initialized. Result = %d\n",result); |
135 | return result; | 139 | return result; |
136 | } | 140 | } |
137 | /*************** init functions end ***********/ | 141 | /*************** init functions end ***********/ |
@@ -188,7 +192,7 @@ av_cold int cook_decode_close(COOKContext *q) | |||
188 | { | 192 | { |
189 | int i; | 193 | int i; |
190 | //COOKContext *q = avctx->priv_data; | 194 | //COOKContext *q = avctx->priv_data; |
191 | av_log(NULL,AV_LOG_ERROR, "Deallocating memory.\n"); | 195 | DEBUGF( "Deallocating memory.\n"); |
192 | 196 | ||
193 | /* Free allocated memory buffers. */ | 197 | /* Free allocated memory buffers. */ |
194 | av_free(q->decoded_bytes_buffer); | 198 | av_free(q->decoded_bytes_buffer); |
@@ -204,7 +208,7 @@ av_cold int cook_decode_close(COOKContext *q) | |||
204 | free_vlc(&q->ccpl); | 208 | free_vlc(&q->ccpl); |
205 | } | 209 | } |
206 | 210 | ||
207 | av_log(NULL,AV_LOG_ERROR,"Memory deallocated.\n"); | 211 | DEBUGF("Memory deallocated.\n"); |
208 | 212 | ||
209 | return 0; | 213 | return 0; |
210 | } | 214 | } |
@@ -650,9 +654,9 @@ static int decode_subpacket(COOKContext *q, const uint8_t *inbuffer, | |||
650 | int sub_packet_size, int16_t *outbuffer) { | 654 | int sub_packet_size, int16_t *outbuffer) { |
651 | /* packet dump */ | 655 | /* packet dump */ |
652 | // for (i=0 ; i<sub_packet_size ; i++) { | 656 | // for (i=0 ; i<sub_packet_size ; i++) { |
653 | // av_log(NULL, AV_LOG_ERROR, "%02x", inbuffer[i]); | 657 | // DEBUGF("%02x", inbuffer[i]); |
654 | // } | 658 | // } |
655 | // av_log(NULL, AV_LOG_ERROR, "\n"); | 659 | // DEBUGF("\n"); |
656 | 660 | ||
657 | decode_bytes_and_gain(q, inbuffer, &q->gains1); | 661 | decode_bytes_and_gain(q, inbuffer, &q->gains1); |
658 | 662 | ||
@@ -710,9 +714,9 @@ int cook_decode_frame(RMContext *rmctx,COOKContext *q, | |||
710 | static void dump_cook_context(COOKContext *q) | 714 | static void dump_cook_context(COOKContext *q) |
711 | { | 715 | { |
712 | //int i=0; | 716 | //int i=0; |
713 | #define PRINT(a,b) av_log(NULL,AV_LOG_ERROR," %s = %d\n", a, b); | 717 | #define PRINT(a,b) DEBUGF(" %s = %d\n", a, b); |
714 | av_log(NULL,AV_LOG_ERROR,"COOKextradata\n"); | 718 | DEBUGF("COOKextradata\n"); |
715 | av_log(NULL,AV_LOG_ERROR,"cookversion=%x\n",q->cookversion); | 719 | DEBUGF("cookversion=%x\n",q->cookversion); |
716 | if (q->cookversion > STEREO) { | 720 | if (q->cookversion > STEREO) { |
717 | PRINT("js_subband_start",q->js_subband_start); | 721 | PRINT("js_subband_start",q->js_subband_start); |
718 | PRINT("js_vlc_bits",q->js_vlc_bits); | 722 | PRINT("js_vlc_bits",q->js_vlc_bits); |
@@ -764,28 +768,28 @@ av_cold int cook_decode_init(RMContext *rmctx, COOKContext *q) | |||
764 | q->total_subbands = q->subbands; | 768 | q->total_subbands = q->subbands; |
765 | 769 | ||
766 | /* Initialize version-dependent variables */ | 770 | /* Initialize version-dependent variables */ |
767 | av_log(NULL,AV_LOG_DEBUG,"q->cookversion=%x\n",q->cookversion); | 771 | DEBUGF("q->cookversion=%x\n",q->cookversion); |
768 | q->joint_stereo = 0; | 772 | q->joint_stereo = 0; |
769 | switch (q->cookversion) { | 773 | switch (q->cookversion) { |
770 | case MONO: | 774 | case MONO: |
771 | if (q->nb_channels != 1) { | 775 | if (q->nb_channels != 1) { |
772 | av_log(NULL,AV_LOG_ERROR,"Container channels != 1, report sample!\n"); | 776 | DEBUGF("Container channels != 1, report sample!\n"); |
773 | return -1; | 777 | return -1; |
774 | } | 778 | } |
775 | av_log(NULL,AV_LOG_DEBUG,"MONO\n"); | 779 | DEBUGF("MONO\n"); |
776 | break; | 780 | break; |
777 | case STEREO: | 781 | case STEREO: |
778 | if (q->nb_channels != 1) { | 782 | if (q->nb_channels != 1) { |
779 | q->bits_per_subpacket = q->bits_per_subpacket/2; | 783 | q->bits_per_subpacket = q->bits_per_subpacket/2; |
780 | } | 784 | } |
781 | av_log(NULL,AV_LOG_DEBUG,"STEREO\n"); | 785 | DEBUGF("STEREO\n"); |
782 | break; | 786 | break; |
783 | case JOINT_STEREO: | 787 | case JOINT_STEREO: |
784 | if (q->nb_channels != 2) { | 788 | if (q->nb_channels != 2) { |
785 | av_log(NULL,AV_LOG_ERROR,"Container channels != 2, report sample!\n"); | 789 | DEBUGF("Container channels != 2, report sample!\n"); |
786 | return -1; | 790 | return -1; |
787 | } | 791 | } |
788 | av_log(NULL,AV_LOG_ERROR,"JOINT_STEREO\n"); | 792 | DEBUGF("JOINT_STEREO\n"); |
789 | if (q->extradata_size >= 16){ | 793 | if (q->extradata_size >= 16){ |
790 | q->total_subbands = q->subbands + q->js_subband_start; | 794 | q->total_subbands = q->subbands + q->js_subband_start; |
791 | q->joint_stereo = 1; | 795 | q->joint_stereo = 1; |
@@ -798,11 +802,11 @@ av_cold int cook_decode_init(RMContext *rmctx, COOKContext *q) | |||
798 | } | 802 | } |
799 | break; | 803 | break; |
800 | case MC_COOK: | 804 | case MC_COOK: |
801 | av_log(NULL,AV_LOG_ERROR,"MC_COOK not supported!\n"); | 805 | DEBUGF("MC_COOK not supported!\n"); |
802 | return -1; | 806 | return -1; |
803 | break; | 807 | break; |
804 | default: | 808 | default: |
805 | av_log(NULL,AV_LOG_ERROR,"Unknown Cook version, report sample!\n"); | 809 | DEBUGF("Unknown Cook version, report sample!\n"); |
806 | return -1; | 810 | return -1; |
807 | break; | 811 | break; |
808 | } | 812 | } |
@@ -851,20 +855,20 @@ av_cold int cook_decode_init(RMContext *rmctx, COOKContext *q) | |||
851 | 855 | ||
852 | /* Try to catch some obviously faulty streams, othervise it might be exploitable */ | 856 | /* Try to catch some obviously faulty streams, othervise it might be exploitable */ |
853 | if (q->total_subbands > 53) { | 857 | if (q->total_subbands > 53) { |
854 | av_log(NULL,AV_LOG_ERROR,"total_subbands > 53, report sample!\n"); | 858 | DEBUGF("total_subbands > 53, report sample!\n"); |
855 | return -1; | 859 | return -1; |
856 | } | 860 | } |
857 | if (q->subbands > 50) { | 861 | if (q->subbands > 50) { |
858 | av_log(NULL,AV_LOG_ERROR,"subbands > 50, report sample!\n"); | 862 | DEBUGF("subbands > 50, report sample!\n"); |
859 | return -1; | 863 | return -1; |
860 | } | 864 | } |
861 | if ((q->samples_per_channel == 256) || (q->samples_per_channel == 512) || (q->samples_per_channel == 1024)) { | 865 | if ((q->samples_per_channel == 256) || (q->samples_per_channel == 512) || (q->samples_per_channel == 1024)) { |
862 | } else { | 866 | } else { |
863 | av_log(NULL,AV_LOG_ERROR,"unknown amount of samples_per_channel = %d, report sample!\n",q->samples_per_channel); | 867 | DEBUGF("unknown amount of samples_per_channel = %d, report sample!\n",q->samples_per_channel); |
864 | return -1; | 868 | return -1; |
865 | } | 869 | } |
866 | if ((q->js_vlc_bits > 6) || (q->js_vlc_bits < 0)) { | 870 | if ((q->js_vlc_bits > 6) || (q->js_vlc_bits < 0)) { |
867 | av_log(NULL,AV_LOG_ERROR,"q->js_vlc_bits = %d, only >= 0 and <= 6 allowed!\n",q->js_vlc_bits); | 871 | DEBUGF("q->js_vlc_bits = %d, only >= 0 and <= 6 allowed!\n",q->js_vlc_bits); |
868 | return -1; | 872 | return -1; |
869 | } | 873 | } |
870 | 874 | ||