From 250f2433c6e1cf2727a79971fdc6ce0f8677037a Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Mon, 7 Dec 2009 14:22:35 -0800 Subject: Initial checkin of stagefright MP3 audio decoder based on PV source code. --- .../codecs/mp3dec/src/asm/pvmp3_dct_16_gcc.s | 474 ++++ .../codecs/mp3dec/src/asm/pvmp3_dct_9_arm.s | 210 ++ .../codecs/mp3dec/src/asm/pvmp3_dct_9_gcc.s | 193 ++ .../codecs/mp3dec/src/asm/pvmp3_mdct_18_arm.s | 369 +++ .../codecs/mp3dec/src/asm/pvmp3_mdct_18_gcc.s | 359 +++ .../codecs/mp3dec/src/asm/pvmp3_mdct_18_wm.asm | 366 +++ .../src/asm/pvmp3_polyphase_filter_window_arm.s | 237 ++ .../src/asm/pvmp3_polyphase_filter_window_gcc.s | 230 ++ .../src/asm/pvmp3_polyphase_filter_window_wm.asm | 231 ++ .../codecs/mp3dec/src/mp3_mem_funcs.h | 81 + .../codecs/mp3dec/src/pv_mp3_huffman.h | 115 + .../codecs/mp3dec/src/pv_mp3dec_fxd_op.h | 84 + .../codecs/mp3dec/src/pv_mp3dec_fxd_op_arm.h | 203 ++ .../codecs/mp3dec/src/pv_mp3dec_fxd_op_arm_gcc.h | 252 ++ .../mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h | 123 + .../codecs/mp3dec/src/pv_mp3dec_fxd_op_msc_evc.h | 132 + .../codecs/mp3dec/src/pvmp3_alias_reduction.cpp | 261 ++ .../codecs/mp3dec/src/pvmp3_alias_reduction.h | 100 + .../libstagefright/codecs/mp3dec/src/pvmp3_crc.cpp | 161 ++ media/libstagefright/codecs/mp3dec/src/pvmp3_crc.h | 110 + .../codecs/mp3dec/src/pvmp3_dct_16.cpp | 410 +++ .../codecs/mp3dec/src/pvmp3_dct_16.h | 102 + .../codecs/mp3dec/src/pvmp3_dct_6.cpp | 152 + .../codecs/mp3dec/src/pvmp3_dct_9.cpp | 167 ++ .../codecs/mp3dec/src/pvmp3_dec_defs.h | 199 ++ .../codecs/mp3dec/src/pvmp3_decode_header.cpp | 192 ++ .../codecs/mp3dec/src/pvmp3_decode_header.h | 101 + .../codecs/mp3dec/src/pvmp3_decode_huff_cw.cpp | 758 +++++ .../codecs/mp3dec/src/pvmp3_decode_huff_cw.h | 114 + .../codecs/mp3dec/src/pvmp3_dequantize_sample.cpp | 452 +++ .../codecs/mp3dec/src/pvmp3_dequantize_sample.h | 106 + .../codecs/mp3dec/src/pvmp3_equalizer.cpp | 415 +++ .../codecs/mp3dec/src/pvmp3_equalizer.h | 101 + .../codecs/mp3dec/src/pvmp3_framedecoder.cpp | 834 ++++++ .../codecs/mp3dec/src/pvmp3_framedecoder.h | 115 + .../codecs/mp3dec/src/pvmp3_get_main_data_size.cpp | 180 ++ .../codecs/mp3dec/src/pvmp3_get_main_data_size.h | 101 + .../codecs/mp3dec/src/pvmp3_get_scale_factors.cpp | 226 ++ .../codecs/mp3dec/src/pvmp3_get_scale_factors.h | 104 + .../codecs/mp3dec/src/pvmp3_get_side_info.cpp | 285 ++ .../codecs/mp3dec/src/pvmp3_get_side_info.h | 102 + .../codecs/mp3dec/src/pvmp3_getbits.cpp | 257 ++ .../codecs/mp3dec/src/pvmp3_getbits.h | 112 + .../codecs/mp3dec/src/pvmp3_huffman_decoding.cpp | 304 ++ .../codecs/mp3dec/src/pvmp3_huffman_parsing.cpp | 328 +++ .../codecs/mp3dec/src/pvmp3_imdct_synth.cpp | 376 +++ .../codecs/mp3dec/src/pvmp3_imdct_synth.h | 102 + .../codecs/mp3dec/src/pvmp3_mdct_18.cpp | 289 ++ .../codecs/mp3dec/src/pvmp3_mdct_18.h | 109 + .../codecs/mp3dec/src/pvmp3_mdct_6.cpp | 165 ++ .../codecs/mp3dec/src/pvmp3_mdct_6.h | 106 + .../mp3dec/src/pvmp3_mpeg2_get_scale_data.cpp | 247 ++ .../codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.h | 105 + .../mp3dec/src/pvmp3_mpeg2_get_scale_factors.cpp | 202 ++ .../mp3dec/src/pvmp3_mpeg2_get_scale_factors.h | 105 + .../codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp | 700 +++++ .../codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.h | 112 + .../codecs/mp3dec/src/pvmp3_normalize.cpp | 173 ++ .../codecs/mp3dec/src/pvmp3_normalize.h | 108 + .../mp3dec/src/pvmp3_poly_phase_synthesis.cpp | 187 ++ .../codecs/mp3dec/src/pvmp3_poly_phase_synthesis.h | 102 + .../mp3dec/src/pvmp3_polyphase_filter_window.cpp | 239 ++ .../mp3dec/src/pvmp3_polyphase_filter_window.h | 138 + .../codecs/mp3dec/src/pvmp3_reorder.cpp | 197 ++ .../codecs/mp3dec/src/pvmp3_reorder.h | 103 + .../codecs/mp3dec/src/pvmp3_seek_synch.cpp | 308 ++ .../codecs/mp3dec/src/pvmp3_seek_synch.h | 106 + .../codecs/mp3dec/src/pvmp3_stereo_proc.cpp | 676 +++++ .../codecs/mp3dec/src/pvmp3_stereo_proc.h | 114 + .../codecs/mp3dec/src/pvmp3_tables.cpp | 2934 ++++++++++++++++++++ .../codecs/mp3dec/src/pvmp3_tables.h | 124 + .../codecs/mp3dec/src/s_huffcodetab.h | 98 + media/libstagefright/codecs/mp3dec/src/s_mp3bits.h | 107 + .../codecs/mp3dec/src/s_tmp3dec_chan.h | 110 + .../codecs/mp3dec/src/s_tmp3dec_file.h | 118 + 75 files changed, 19068 insertions(+) create mode 100644 media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_16_gcc.s create mode 100644 media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_9_arm.s create mode 100644 media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_9_gcc.s create mode 100644 media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_arm.s create mode 100644 media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_gcc.s create mode 100644 media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_wm.asm create mode 100644 media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_arm.s create mode 100644 media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_gcc.s create mode 100644 media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_wm.asm create mode 100644 media/libstagefright/codecs/mp3dec/src/mp3_mem_funcs.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pv_mp3_huffman.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm_gcc.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_msc_evc.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_crc.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_crc.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_dct_6.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_dct_9.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_dec_defs.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_decode_header.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_decode_header.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_decode_huff_cw.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_decode_huff_cw.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_framedecoder.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_framedecoder.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_get_main_data_size.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_get_main_data_size.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_get_side_info.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_get_side_info.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_getbits.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_getbits.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_huffman_decoding.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_huffman_parsing.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_imdct_synth.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_imdct_synth.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_normalize.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_normalize.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_polyphase_filter_window.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_polyphase_filter_window.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_reorder.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_reorder.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_seek_synch.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_seek_synch.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.h create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_tables.cpp create mode 100644 media/libstagefright/codecs/mp3dec/src/pvmp3_tables.h create mode 100644 media/libstagefright/codecs/mp3dec/src/s_huffcodetab.h create mode 100644 media/libstagefright/codecs/mp3dec/src/s_mp3bits.h create mode 100644 media/libstagefright/codecs/mp3dec/src/s_tmp3dec_chan.h create mode 100644 media/libstagefright/codecs/mp3dec/src/s_tmp3dec_file.h (limited to 'media/libstagefright/codecs/mp3dec/src') diff --git a/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_16_gcc.s b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_16_gcc.s new file mode 100644 index 0000000..f83732b --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_16_gcc.s @@ -0,0 +1,474 @@ +@ ------------------------------------------------------------------ +@ Copyright (C) 1998-2009 PacketVideo +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ http://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +@ express or implied. +@ See the License for the specific language governing permissions +@ and limitations under the License. +@ ------------------------------------------------------------------- + +@ +@ +@ Filename: pvmp3_dct_16_gcc.s +@ +@ +@------------------------------------------------------------------------------ +@ REVISION HISTORY +@ +@ +@ Who: Date: MM/DD/YYYY +@ Description: +@ +@------------------------------------------------------------------------------ + +.arm + +.align 4 + +.text + +.extern pvmp3_dct_16 +.extern pvmp3_merge_in_place_N32 +.extern pvmp3_split + + + +@------------------------------------------------------------------------------ + +.global pvmp3_dct_16 + +pvmp3_dct_16: + stmfd sp!,{r0,r1,r4-r11,lr} + ldr r1,[r0] + ldr r3,[r0,#0x3c] + ldr r12,constant1 + sub r2,r1,r3 + smull lr,r2,r12,r2 + sub sp,sp,#0x1c + str r2,[sp,#0x14] + ldr r2,[r0,#0x1c] + ldr r12,[r0,#0x20] + add r1,r1,r3 + sub r3,r2,r12 + ldr lr,constant2 + mov r3,r3,lsl #3 + smull r4,r3,lr,r3 + ldr r6,constant5 + str r3,[sp] + add r3,r2,r12 + sub r2,r1,r3 + ldr r12,constant3 + add r3,r1,r3 + smull lr,r2,r12,r2 + ldr r12,[r0,#0x38] + ldr r1,[r0,#4] + ldr lr,constant4 + sub r4,r1,r12 + add r1,r1,r12 + ldr r12,[r0,#0x18] + smull r4,r5,lr,r4 + ldr lr,[r0,#0x24] + ldr r10,constant10 + sub r4,r12,lr + mov r4,r4,lsl #1 + smull r7,r4,r6,r4 + add r12,r12,lr + add r7,r1,r12 + sub r12,r1,r12 + ldr r1,constant6 + str r4,[sp,#4] + smull r12,r4,r1,r12 + ldr r1,[r0,#8] + ldr r12,[r0,#0x34] + ldr r6,constant7 + sub lr,r1,r12 + smull r8,lr,r6,lr + add r1,r1,r12 + str lr,[sp,#0x10] + ldr r12,[r0,#0x14] + ldr lr,[r0,#0x28] + ldr r8,constant8 + sub r6,r12,lr + mov r6,r6,lsl #1 + smull r9,r6,r8,r6 + add r12,r12,lr + ldr r9,constant9 + add r8,r1,r12 + sub r12,r1,r12 + smull r12,lr,r9,r12 + ldr r12,[r0,#0x30] + ldr r1,[r0,#0xc] + sub r9,r1,r12 + smull r11,r9,r10,r9 + add r12,r1,r12 + str r9,[sp,#0xc] + ldr r9,[r0,#0x10] + ldr r10,constant11 + str r9,[sp,#0x18] + ldr r1,[r0,#0x2c] + sub r9,r9,r1 + smull r11,r9,r10,r9 + ldr r10,constant12 + str r9,[sp,#8] + ldr r9,[sp,#0x18] + ldr r11,constant14 + add r9,r9,r1 + add r1,r12,r9 + sub r12,r12,r9 + mov r12,r12,lsl #2 + smull r9,r12,r10,r12 + ldr r10,constant13 + add r9,r3,r1 + sub r1,r3,r1 + smull r1,r3,r10,r1 + sub r1,r7,r8 + mov r1,r1,lsl #1 + smull r1,r10,r11,r1 + add r1,r7,r8 + add r8,r9,r1 + sub r7,r9,r1 + mov r8,r8,asr #1 + ldr r1,constant15 + str r8,[r0] + smull r7,r8,r1,r7 + sub r7,r3,r10 + str r8,[r0,#0x20] + mov r7,r7,lsl #1 + smull r8,r7,r1,r7 + add r3,r3,r10 + add r3,r3,r7 + str r3,[r0,#0x10] + sub r3,r2,r12 + str r7,[r0,#0x30] + add r2,r2,r12 + ldr r7,constant13 + sub r12,r4,lr + mov r3,r3,lsl #1 + smull r8,r3,r7,r3 + add lr,r4,lr + sub r4,r2,lr + mov r12,r12,lsl #2 + smull r7,r12,r11,r12 + add lr,lr,r2 + sub r2,r3,r12 + mov r2,r2,lsl #1 + smull r7,r2,r1,r2 + mov r4,r4,lsl #1 + add r12,r12,r2 + add r3,r12,r3 + smull r7,r4,r1,r4 + add r12,r3,lr + add r3,r3,r4 + str r3,[r0,#0x18] + add r3,r2,r4 + str r2,[r0,#0x38] + str r3,[r0,#0x28] + str r12,[r0,#8] + ldr r2,[sp,#0x14] + ldr r3,[sp,#0] + ldr lr,[sp,#4] + sub r2,r2,r3 + ldr r3,constant3 + mov r2,r2,lsl #1 + smull r12,r2,r3,r2 + ldr r3,[sp,#0x14] + ldr r12,[sp,#0] + ldr r4,constant6 + add r12,r3,r12 + ldr r3,[sp,#4] + sub lr,r5,lr + mov lr,lr,lsl #1 + add r3,r5,r3 + smull r5,lr,r4,lr + ldr r4,[sp,#0x10] + ldr r5,[sp,#0x10] + add r4,r4,r6 + sub r5,r5,r6 + ldr r6,constant9 + mov r5,r5,lsl #1 + smull r7,r5,r6,r5 + ldr r6,[sp,#8] + ldr r9,[sp,#0xc] + ldr r10,constant12 + sub r6,r9,r6 + mov r6,r6,lsl #3 + smull r7,r6,r10,r6 + ldr r8,[sp,#0x20] + ldr r7,[sp,#8] + cmp r8,#0 + add r7,r9,r7 + + bne no_flag_proc + rsb r12,r12,#0 + rsb r2,r2,#0 + rsb r3,r3,#0 + rsb lr,lr,#0 + rsb r4,r4,#0 + rsb r5,r5,#0 + rsb r7,r7,#0 + rsb r6,r6,#0 +no_flag_proc: + + sub r8,r2,r6 + add r2,r6,r2 + sub r6,r12,r7 + ldr r9,constant13 + add r12,r12,r7 + sub r7,r3,r4 + mov r6,r6,lsl #1 + mov r8,r8,lsl #1 + smull r10,r8,r9,r8 + add r3,r3,r4 + smull r10,r6,r9,r6 + sub r4,lr,r5 + mov r7,r7,lsl #2 + smull r9,r7,r11,r7 + add lr,lr,r5 + sub r5,r6,r7 + add r6,r6,r7 + sub r7,r12,r3 + add r3,r12,r3 + sub r12,r2,lr + mov r4,r4,lsl #2 + smull r9,r4,r11,r4 + add lr,r2,lr + sub r2,r8,r4 + mov r2,r2,lsl #1 + mov r5,r5,lsl #1 + mov r12,r12,lsl #1 + mov r7,r7,lsl #1 + smull r9,r5,r1,r5 + smull r9,r2,r1,r2 + add r6,r6,r5 + smull r9,r7,r1,r7 + smull r9,r12,r1,r12 + add r1,r4,r2 + add r1,r1,r8 + add lr,lr,r1 + add r3,r3,lr + str r3,[r0,#4] + add r3,r6,lr + str r3,[r0,#0xc] + add r1,r1,r12 + add r3,r6,r1 + add r1,r7,r1 + str r1,[r0,#0x1c] + str r3,[r0,#0x14] + add r1,r12,r2 + add r3,r7,r1 + add r1,r5,r1 + str r1,[r0,#0x2c] + str r3,[r0,#0x24]! + add r1,r5,r2 + str r1,[r0,#0x10] + str r2,[r0,#0x18] + add sp,sp,#0x24 + ldmfd sp!,{r4-r11,pc} + + + +@------------------------------------------------------------------------------ + +.global pvmp3_merge_in_place_N32 + + + +pvmp3_merge_in_place_N32: + stmfd sp!,{r4,lr} + ldr r1,[r0,#0x1c] + ldr r2,[r0,#0x38] + str r1,[r0,#0x38] + ldr r1,[r0,#0x18] + ldr r3,[r0,#0x30] + str r1,[r0,#0x30] + ldr r12,[r0,#0x14] + ldr r1,[r0,#0x28] + str r12,[r0,#0x28] + ldr r12,[r0,#0x10] + ldr lr,[r0,#0x20] + str r12,[r0,#0x20] + ldr r12,[r0,#0xc] + str r12,[r0,#0x18] + ldr r12,[r0,#8] + str r12,[r0,#0x10] + ldr r12,[r0,#4] + str r12,[r0,#8] + ldr r4,[r0,#0x40] + ldr r12,[r0,#0x44] + add r4,r4,r12 + str r4,[r0,#4] + str lr,[r0,#0x40] + ldr lr,[r0,#0x48] + add r12,lr,r12 + str r12,[r0,#0xc] + ldr r12,[r0,#0x4c] + add lr,r12,lr + str lr,[r0,#0x14] + ldr lr,[r0,#0x24] + str lr,[r0,#0x48] + ldr lr,[r0,#0x50] + add r12,lr,r12 + str r12,[r0,#0x1c] + ldr r12,[r0,#0x54] + str r1,[r0,#0x50] + add lr,r12,lr + str lr,[r0,#0x24] + ldr r1,[r0,#0x58] + ldr r4,[r0,#0x2c] + ldr lr,[r0,#0x34] + add r12,r1,r12 + str r12,[r0,#0x2c] + ldr r12,[r0,#0x5c] + add r1,r12,r1 + str r1,[r0,#0x34] + str r4,[r0,#0x58] + ldr r1,[r0,#0x60] + ldr r4,[r0,#0x3c] + add r12,r1,r12 + str r12,[r0,#0x3c] + ldr r12,[r0,#0x64] + add r1,r12,r1 + str r1,[r0,#0x44] + ldr r1,[r0,#0x68] + add r12,r1,r12 + str r12,[r0,#0x4c] + ldr r12,[r0,#0x6c] + add r1,r12,r1 + str r1,[r0,#0x54] + ldr r1,[r0,#0x70] + str r3,[r0,#0x60] + add r12,r1,r12 + str r12,[r0,#0x5c] + ldr r3,[r0,#0x74] + add r1,r3,r1 + str r1,[r0,#0x64] + str lr,[r0,#0x68] + ldr r1,[r0,#0x78] + str r2,[r0,#0x70] + add r3,r1,r3 + str r3,[r0,#0x6c] + ldr r2,[r0,#0x7c] + add r1,r1,r2 + str r1,[r0,#0x74] + str r4,[r0,#0x78] + ldmfd sp!,{r4,pc} + + +@------------------------------------------------------------------------------ + +.global pvmp3_split + + +pvmp3_split: + stmfd sp!,{r4,r5,lr} + ldr r2,constant16 + sub r1,r0,#4 + mov r3,#3 +loop1: + ldr r12,[r0] + ldr lr,[r1] + ldr r4,[r2],#-4 + add r5,lr,r12 + sub r12,lr,r12 + smull r12,lr,r4,r12 + str r5,[r1],#-4 + mov r12,r12,lsr #27 + add r12,r12,lr,lsl #5 + str r12,[r0],#4 + ldr r12,[r0] + ldr lr,[r1] + ldr r4,[r2],#-4 + add r5,lr,r12 + sub r12,lr,r12 + smull r12,lr,r4,r12 + str r5,[r1],#-4 + mov r12,r12,lsr #27 + add r12,r12,lr,lsl #5 + str r12,[r0],#4 + subs r3,r3,#1 + bne loop1 + mov r3,#5 +loop2: + ldr r12,[r0] + ldr lr,[r1] + ldr r4,[r2],#-4 + add r5,lr,r12 + sub r12,lr,r12 + mov r12,r12,lsl #1 + smull lr,r12,r4,r12 + str r5,[r1],#-4 + str r12,[r0],#4 + ldr r12,[r0] + ldr lr,[r1] + ldr r4,[r2],#-4 + add r5,lr,r12 + sub r12,lr,r12 + mov r12,r12,lsl #1 + smull lr,r12,r4,r12 + str r5,[r1],#-4 + str r12,[r0],#4 + subs r3,r3,#1 + bne loop2 + ldmfd sp!,{r4,r5,pc} +constant1: + .word 0x404f4680 +constant2: + .word 0x519e4e00 +constant3: + .word 0x4140fb80 +constant4: + .word 0x42e13c00 +constant5: + .word 0x6e3c9300 +constant6: + .word 0x4cf8de80 +constant7: + .word 0x48919f80 +constant8: + .word 0x43e22480 +constant9: + .word 0x73326b80 +constant10: + .word 0x52cb0e80 +constant11: + .word 0x64e24000 +constant12: + .word 0x52036780 +constant13: + .word 0x4545ea00 +constant14: + .word 0x539eba80 +constant15: + .word 0x5a827980 +constant16: + .word CosTable_dct32 + 60 + + + +CosTable_dct32: + .word 0x4013c280 + .word 0x40b34580 + .word 0x41fa2d80 + .word 0x43f93400 + .word 0x46cc1c00 + .word 0x4a9d9d00 + .word 0x4fae3700 + .word 0x56601e80 + .word 0x5f4cf700 + .word 0x6b6fcf00 + .word 0x07c7d1d8 + .word 0x095b0350 + .word 0x0bdf91b0 + .word 0x107655e0 + .word 0x1b42c840 + .word 0x51852300 + + diff --git a/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_9_arm.s b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_9_arm.s new file mode 100644 index 0000000..3a6dd4f --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_9_arm.s @@ -0,0 +1,210 @@ +; ------------------------------------------------------------------ +; Copyright (C) 1998-2009 PacketVideo +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +; express or implied. +; See the License for the specific language governing permissions +; and limitations under the License. +; ------------------------------------------------------------------- + +; +; +; Filename: pvmp3_dct_9.s +; +;------------------------------------------------------------------------------ +; REVISION HISTORY +; +; +; Who: Date: MM/DD/YYYY +; Description: +; +;------------------------------------------------------------------------------ + + AREA |.drectve|, DRECTVE + + DCB "-defaultlib:coredll.lib " + DCB "-defaultlib:corelibc.lib " + + IMPORT pvmp3_mdct_18 ; pvmp3_mdct_18.cpp + +;------------------------------------------------------------------------------ + + AREA |.rdata|, DATA, READONLY + % 4 + + +;------------------------------------------------------------------------------ + + AREA |.text|, CODE, READONLY + + +;------------------------------------------------------------------------------ + + EXPORT |pvmp3_dct_9| + +|pvmp3_dct_9| PROC + stmfd sp!,{r4-r10,lr} + ldr r2, [r0, #0x20] + ldr r3, [r0] + ldr r12,[r0, #4] + add r1,r2,r3 + sub lr,r2,r3 + ldr r3,[r0, #0x1c] + ldr r4,[r0, #0x18] + add r2,r3,r12 + ldr r5,[r0,#8] + sub r3,r3,r12 + add r12,r4,r5 + sub r4,r4,r5 + ldr r5,[r0, #0x14] + ldr r7,[r0, #0xc] + ldr r9,[r0, #0x10] + add r6,r5,r7 + sub r5,r5,r7 + add r7,r1,r12 + add r8,r9,r2 + add r7,r7,r6 + add r10,r7,r8 + rsb r7,r8,r7,asr #1 + str r7,[r0, #0x18] + rsb r2,r9,r2,asr #1 + str r10,[r0] + ldr r11,|cos_2pi_9| + rsb r7,r2,#0 + + mov r9,r1,lsl #1 + mov r1,r9 ;;;;;; !!!!!! + mov r8,r7 + +; vec[4] = fxp_mac32_Q32( vec[4], tmp0<<1, cos_2pi_9); + + smlal r1,r8,r11,r9 + ldr r10,|cos_4pi_9| + ldr r11,|cos_pi_9| + +; vec[8] = fxp_mac32_Q32( vec[8], tmp0<<1, cos_4pi_9); + + smlal r1,r7,r10,r9 + + + +; vec[2] = fxp_mac32_Q32( vec[2], tmp0<<1, cos_pi_9); + + smlal r9,r2,r11,r9 + mov r1,r12,lsl #1 + rsb r9,r10,#0 + ldr r11,|cos_5pi_9| + + smlal r12,r2,r9,r1 + + + +; vec[2] = fxp_mac32_Q32( vec[2], tmp2<<1, cos_5pi_9); + + ldr r9,|cos_2pi_9| + mov r12,r1 ;;;;;; !!!!!! + smlal r12,r8,r11,r1 + + +; vec[8] = fxp_mac32_Q32( vec[8], tmp2<<1, cos_2pi_9); + + smlal r1,r7,r9,r1 + mov r1,r6,lsl #1 + smlal r12,r7,r11,r1 + and r6,r10,r11,asr #14 + smlal r12,r8,r6,r1 + ldr r10,|cos_11pi_18| + add r12,r11,r6 + smlal r1,r2,r12,r1 + ldr r9,|cos_8pi_9| + str r2,[r0,#8] + mov r1,r5,lsl #1 + +; vec[8] = fxp_mac32_Q32( vec[8], tmp3<<1, cos_8pi_9); + + smull r2,r6,r9,r1 + str r7,[r0,#0x20] + mov r2,r4,lsl #1 + ldr r7,|cos_13pi_18| + smlal r12,r6,r10,r2 + + mov r3,r3,lsl #1 + +; vec[5] = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18); + + smlal r12,r6,r7,r3 + add r4,r5,r4 + mov r12,lr,lsl #1 + sub lr,r4,lr + ldr r7,|cos_17pi_18| + str r8,[r0, #0x10] + ldr r4,|cos_pi_6| + + mov lr,lr,lsl #1 + +; vec[1] = fxp_mac32_Q32( vec[1], tmp8<<1, cos_17pi_18); + + smlal r8,r6,r7,r12 + +; vec[3] = fxp_mul32_Q32((tmp5 + tmp6 - tmp8)<<1, cos_pi_6); + + smull r5,lr,r4,lr + str r6,[r0, #4] + str lr,[r0, #0xc] + + +; vec[5] = fxp_mul32_Q32(tmp5<<1, cos_17pi_18); + smull r5,lr,r7,r1 + rsb r6,r9,#0 +; vec[5] = fxp_mac32_Q32( vec[5], tmp6<<1, cos_7pi_18); + smlal r5,lr,r6,r2 +; vec[5] = fxp_mac32_Q32( vec[5], tmp7<<1, cos_pi_6); + smlal r5,lr,r4,r3 +; vec[5] = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18); + smlal r5,lr,r10,r12 + str lr,[r0, #0x14] + rsb lr,r10,#0 + +; vec[7] = fxp_mul32_Q32(tmp5<<1, cos_5pi_18); + smull r5,r1,lr,r1 +; vec[7] = fxp_mac32_Q32( vec[7], tmp6<<1, cos_17pi_18); + smlal r2,r1,r7,r2 +; vec[7] = fxp_mac32_Q32( vec[7], tmp7<<1, cos_pi_6); + smlal r3,r1,r4,r3 +; vec[7] = fxp_mac32_Q32( vec[7], tmp8<<1, cos_11pi_18); + smlal r12,r1,r9,r12 + str r1,[r0, #0x1c] + ldmfd sp!,{r4-r10,pc} +|cos_2pi_9| + DCD 0x620dbe80 +|cos_4pi_9| + DCD 0x163a1a80 +|cos_pi_9| + DCD 0x7847d900 +|cos_5pi_9| + DCD 0x87b82700 +|cos_8pi_9| + DCD 0xd438af00 +|cos_11pi_18| + DCD 0xadb92280 +|cos_13pi_18| + DCD 0x91261480 +|cos_17pi_18| + DCD 0x81f1d200 +|cos_pi_6| + DCD 0x6ed9eb80 + ENDP + + + + + + END diff --git a/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_9_gcc.s b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_9_gcc.s new file mode 100644 index 0000000..618c50e --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_dct_9_gcc.s @@ -0,0 +1,193 @@ +@ ------------------------------------------------------------------ +@ Copyright (C) 1998-2009 PacketVideo +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ http://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +@ express or implied. +@ See the License for the specific language governing permissions +@ and limitations under the License. +@ ------------------------------------------------------------------- + +@ +@ +@ Filename: pvmp3_dct_9_gcc.s +@ +@------------------------------------------------------------------------------ +@ REVISION HISTORY +@ +@ +@ Who: Date: MM/DD/YYYY +@ Description: +@ +@------------------------------------------------------------------------------ + +.arm + +.align 4 + +.text + + +@------------------------------------------------------------------------------ + +.global pvmp3_dct_9 + +pvmp3_dct_9: + stmfd sp!,{r4-r11,lr} + ldr r2, [r0, #0x20] + ldr r3, [r0, #0] + ldr r12,[r0, #4] + add r1,r2,r3 + sub lr,r2,r3 + ldr r3,[r0, #0x1c] + ldr r4,[r0, #0x18] + add r2,r3,r12 + ldr r5,[r0,#8] + sub r3,r3,r12 + add r12,r4,r5 + sub r4,r4,r5 + ldr r5,[r0, #0x14] + ldr r7,[r0, #0xc] + ldr r9,[r0, #0x10] + add r6,r5,r7 + sub r5,r5,r7 + add r7,r1,r12 + add r8,r9,r2 + add r7,r7,r6 + add r10,r7,r8 + rsb r7,r8,r7,asr #1 + str r7,[r0, #0x18] + rsb r2,r9,r2,asr #1 + str r10,[r0,#0] + ldr r11,cos_2pi_9 + rsb r7,r2,#0 + + ldr r10,cos_4pi_9 + mov r9,r1,lsl #1 + mov r8,r7 + +@ vec[4] = fxp_mac32_Q32( vec[4], tmp0<<1, cos_2pi_9)@ + + smlal r1,r8,r11,r9 + ldr r11,cos_pi_9 + mov r1,r9 @@@@@@ !!!!!! + +@ vec[8] = fxp_mac32_Q32( vec[8], tmp0<<1, cos_4pi_9)@ + + smlal r1,r7,r10,r9 + + mov r1,r12,lsl #1 + + +@ vec[2] = fxp_mac32_Q32( vec[2], tmp0<<1, cos_pi_9)@ + + smlal r9,r2,r11,r9 + rsb r9,r10,#0 + ldr r11,cos_5pi_9 + + smlal r12,r2,r9,r1 + + + +@ vec[2] = fxp_mac32_Q32( vec[2], tmp2<<1, cos_5pi_9)@ + + ldr r9,cos_2pi_9 + mov r12,r1 @@@@@@ !!!!!! + smlal r12,r8,r11,r1 + + +@ vec[8] = fxp_mac32_Q32( vec[8], tmp2<<1, cos_2pi_9)@ + + smlal r1,r7,r9,r1 + mov r1,r6,lsl #1 + smlal r12,r7,r11,r1 + and r6,r10,r11,asr #14 + smlal r12,r8,r6,r1 + ldr r10,cos_11pi_18 + add r12,r11,r6 + smlal r1,r2,r12,r1 + ldr r9,cos_8pi_9 + str r2,[r0,#8] + mov r1,r5,lsl #1 + +@ vec[8] = fxp_mac32_Q32( vec[8], tmp3<<1, cos_8pi_9)@ + + smull r2,r6,r9,r1 + str r7,[r0,#0x20] + mov r2,r4,lsl #1 + ldr r7,cos_13pi_18 + smlal r12,r6,r10,r2 + + mov r3,r3,lsl #1 + +@ vec[5] = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18)@ + + smlal r12,r6,r7,r3 + add r4,r5,r4 + mov r12,lr,lsl #1 + sub lr,r4,lr + ldr r7,cos_17pi_18 + str r8,[r0, #0x10] + ldr r4,cos_pi_6 + + mov lr,lr,lsl #1 + +@ vec[1] = fxp_mac32_Q32( vec[1], tmp8<<1, cos_17pi_18)@ + + smlal r8,r6,r7,r12 + +@ vec[3] = fxp_mul32_Q32((tmp5 + tmp6 - tmp8)<<1, cos_pi_6)@ + + smull r5,lr,r4,lr + str r6,[r0, #4] + str lr,[r0, #0xc] + + +@ vec[5] = fxp_mul32_Q32(tmp5<<1, cos_17pi_18)@ + smull r5,lr,r7,r1 + rsb r6,r9,#0 +@ vec[5] = fxp_mac32_Q32( vec[5], tmp6<<1, cos_7pi_18)@ + smlal r5,lr,r6,r2 +@ vec[5] = fxp_mac32_Q32( vec[5], tmp7<<1, cos_pi_6)@ + smlal r5,lr,r4,r3 +@ vec[5] = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18)@ + smlal r5,lr,r10,r12 + str lr,[r0, #0x14] + rsb lr,r10,#0 + +@ vec[7] = fxp_mul32_Q32(tmp5<<1, cos_5pi_18)@ + smull r5,r1,lr,r1 +@ vec[7] = fxp_mac32_Q32( vec[7], tmp6<<1, cos_17pi_18)@ + smlal r2,r1,r7,r2 +@ vec[7] = fxp_mac32_Q32( vec[7], tmp7<<1, cos_pi_6)@ + smlal r3,r1,r4,r3 +@ vec[7] = fxp_mac32_Q32( vec[7], tmp8<<1, cos_11pi_18)@ + smlal r12,r1,r9,r12 + str r1,[r0, #0x1c] + ldmfd sp!,{r4-r11,pc} +cos_2pi_9: + .word 0x620dbe80 +cos_4pi_9: + .word 0x163a1a80 +cos_pi_9: + .word 0x7847d900 +cos_5pi_9: + .word 0x87b82700 +cos_8pi_9: + .word 0xd438af00 +cos_11pi_18: + .word 0xadb92280 +cos_13pi_18: + .word 0x91261480 +cos_17pi_18: + .word 0x81f1d200 +cos_pi_6: + .word 0x6ed9eb80 + diff --git a/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_arm.s b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_arm.s new file mode 100644 index 0000000..9401d8c --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_arm.s @@ -0,0 +1,369 @@ +; ------------------------------------------------------------------ +; Copyright (C) 1998-2009 PacketVideo +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +; express or implied. +; See the License for the specific language governing permissions +; and limitations under the License. +; ------------------------------------------------------------------- + +; +; +; Filename: pvmp3_dct_18.s +; +;------------------------------------------------------------------------------ +; REVISION HISTORY +; +; +; Who: Date: MM/DD/YYYY +; Description: +; +;------------------------------------------------------------------------------ + + EXPORT pvmp3_mdct_18 + + IMPORT ||Lib$$Request$$armlib|| [WEAK] + IMPORT ||Lib$$Request$$cpplib|| [WEAK] + IMPORT pvmp3_dct_9 + + +;------------------------------------------------------------------------------ + + AREA |.text|, CODE, READONLY, ALIGN=2 + + +;------------------------------------------------------------------------------ + +|pvmp3_mdct_18| PROC + stmfd sp!,{r4-r10,lr} + mov r7,r2 + ldr r2,table + mov r6,r1 + add r3,r2,#0x24 + add r12,r3,#0x44 + add r1,r0,#0x44 + mov r5,r0 + +; for ( i=9; i!=0; i--) +; { + + mov r4,#9 +Loop_1 + +; tmp = *(pt_vec); +; tmp1 = *(pt_vec_o); + + ldr lr,[r0] ;; tmp == lr + ldr r8,[r3],#4 ;; tmp1 == r8 + +; tmp = fxp_mul32_Q32( tmp<<1, *(pt_cos++ )); +; tmp1 = fxp_mul32_Q27( tmp1, *(pt_cos_x--)); + + mov lr,lr,lsl #1 + smull r10,lr,r8,lr + ldr r8,[r12],#-4 + ldr r9,[r1] + subs r4,r4,#1 + smull r9,r10,r8,r9 + mov r8,r9,lsr #27 + add r8,r8,r10,lsl #5 + +; *(pt_vec++) = tmp + tmp1 ; +; *(pt_vec_o--) = fxp_mul32_Q28( (tmp - tmp1), *(pt_cos_split++)); + + add r9,lr,r8 + sub r8,lr,r8 + ldr lr,[r2],#4 + str r9,[r0],#4 + smull r8,r9,lr,r8 + mov lr,r8,lsr #28 + add lr,lr,r9,lsl #4 + str lr,[r1],#-4 + bne Loop_1 + +; } + + mov r0,r5 ;; r0 = vec + bl pvmp3_dct_9 + add r0,r5,#0x24 ;; r0 = &vec[9] + bl pvmp3_dct_9 + + ldr r0,[r5,#0x20] + ldr r2,[r5,#0x40] + str r0,[r5,#0x40] + ldr r0,[r5,#0x1c] + ldr r3,[r5,#0x38] + str r0,[r5,#0x38] + ldr r1,[r5,#0x18] + ldr r0,[r5,#0x30] + str r1,[r5,#0x30] + ldr r12,[r5,#0x14] + ldr r1,[r5,#0x28] + str r12,[r5,#0x28] + ldr r12,[r5,#0x10] + str r12,[r5,#0x20] + ldr r12,[r5,#0xc] + str r12,[r5,#0x18] + ldr r12,[r5,#8] + str r12,[r5,#0x10] + ldr r12,[r5,#4] + str r12,[r5,#8] + ldr r12,[r5,#0x24] + sub r12,r12,r1 + str r12,[r5,#4] + ldr r12,[r5,#0x2c] + sub r1,r12,r1 + str r1,[r5,#0xc] + sub r1,r12,r0 + str r1,[r5,#0x14] + ldr r1,[r5,#0x34] + sub r0,r1,r0 + str r0,[r5,#0x1c] + sub r0,r1,r3 + str r0,[r5,#0x24] + ldr r1,[r5,#0x3c] + sub r3,r1,r3 + sub r1,r1,r2 + str r1,[r5,#0x34] + str r3,[r5,#0x2c] + ldr r1,[r5,#0x44] + sub r1,r1,r2 + str r1,[r5,#0x3c] + ldr r12,[r5,#0] + +Loop_2 + add r1,r5,r4,lsl #2 + ldr r2,[r1,#0x28] + ldr r3,[r6,r4,lsl #2] + add r0,r0,r2 + str r0,[r1,#0x28] + ldr lr,[r7,r4,lsl #2] + ldr r1,[r1,#4] + smlal r0,r3,lr,r0 + mov r0,r2 + add r2,r12,r1 + rsb r2,r2,#0 + str r3,[r5,r4,lsl #2] + str r2,[r6,r4,lsl #2] + add r4,r4,#1 + cmp r4,#6 + mov r12,r1 + + blt Loop_2 + + ldr r1,[r5,#0x40] + ldr r2,[r6,#0x18] + add r3,r0,r1 + str r3,[r5,#0x40] + ldr lr,[r7,r4,lsl #2] + mov r3,r3,lsl #1 + ldr r0,[r5,#0x1c] + smlal r3,r2,lr,r3 + add r3,r12,r0 + str r2,[r5,#0x18] + ldr r2,[r6,#0x1c] + rsb r3,r3,#0 + str r3,[r6,#0x18] + ldr r3,[r5,#0x20] + add r0,r3,r0 + rsb r0,r0,#0 + str r0,[r6,#0x1c] + ldr r3,[r5,#0x44] + ldr r0,[r6,#0x20] + add r3,r3,r1 + mov r1,r2 + ldr r10,[r7,#0x1c] + mov r2,r3,lsl #1 + smlal r12,r1,r10,r2 + str r1,[r5,#0x1c] + ldr r1,[r5,#0x20] + ldr r3,[r5,#0x24] + add r1,r1,r3 + rsb r1,r1,#0 + str r1,[r6,#0x20] + ldr r1,[r5,#0x44] + ldr r3,[r7,#0x20] + mov r1,r1,lsl #1 + smlal r12,r0,r3,r1 + ldr lr,[r7,#0x24] + ldr r3,[r6,#0x24] + str r0,[r5,#0x20] + smlal r1,r3,lr,r1 + ldr r0,[r6,#0x40] + ldr r12,[r6,#0x44] + str r3,[r5,#0x24] + ldr r1,[r5,#0x28] + ldr r3,[r7,#0x44] + mov r1,r1,lsl #1 + smlal r1,r12,r3,r1 + ldr r1,[r5,#0x40] + str r12,[r5,#0x44] + rsb r8,r1,#0 + str r8,[r5,#0x28] + ldr r1,[r5,#0x2c] + ldr r3,[r7,#0x40] + mov r1,r1,lsl #1 + smlal r1,r0,r3,r1 + str r0,[r5,#0x40] + ldr r0,[r5,#0x3c] + ldr r1,[r6,#0x38] + ldr r3,[r6,#0x3c] + rsb r9,r0,#0 + str r9,[r5,#0x2c] + ldr r0,[r5,#0x30] + ldr r12,[r7,#0x3c] + mov r0,r0,lsl #1 + smlal r0,r3,r12,r0 + str r3,[r5,#0x3c] + ldr r0,[r5,#0x38] + rsb r0,r0,#0 + str r0,[r5,#0x30] + ldr r3,[r5,#0x34] + ldr r12,[r7,#0x38] + mov r3,r3,lsl #1 + smlal r3,r1,r12,r3 + mov r0,r0,lsl #1 + str r1,[r5,#0x38] + ldr r4,[r7,#0x34] + ldr r1,[r6,#0x34] + ldr r3,[r6,#0x30] + smlal r0,r1,r4,r0 + ldr r12,[r6,#0x2c] + ldr lr,[r6,#0x28] + str r1,[r5,#0x34] + ldr r1,[r7,#0x30] + mov r0,r9,lsl #1 + smlal r0,r3,r1,r0 + mov r0,r8,lsl #1 + ldr r1,[r7,#0x2c] + str r3,[r5,#0x30] + smlal r0,r12,r1,r0 + ldr r0,[r7,#0x28] + str r12,[r5,#0x2c] + smlal r2,lr,r0,r2 + str lr,[r5,#0x28] + ldr r1,[r6,#4] + ldr r12,[r7,#0x48] + mov r2,r1,lsl #1 + ldr r1,[r6,#0x20] + ldr r0,[r6] + mov r1,r1,lsl #1 + smull r4,lr,r12,r1 + ldr r3,[r6,#0x1c] + str lr,[r6] + ldr r12,[r7,#0x4c] + mov r3,r3,lsl #1 + smull r4,lr,r12,r3 + mov r0,r0,lsl #1 + ldr r12,[r7,#0x64] + str lr,[r6,#4] + smull r4,lr,r12,r2 + ldr r12,[r7,#0x68] + str lr,[r6,#0x1c] + smull r4,lr,r12,r0 + ldr r12,[r7,#0x6c] + str lr,[r6,#0x20] + smull lr,r0,r12,r0 + ldr r12,[r7,#0x70] + str r0,[r6,#0x24] + smull r0,r2,r12,r2 + ldr r0,[r7,#0x88] + str r2,[r6,#0x28] + smull r3,r2,r0,r3 + ldr r0,[r7,#0x8c] + str r2,[r6,#0x40] + smull r2,r1,r0,r1 + str r1,[r6,#0x44] + ldr r0,[r6,#0x18] + ldr lr,[r7,#0x50] + mov r1,r0,lsl #1 + ldr r0,[r6,#0x14] + smull r5,r4,lr,r1 + ldr r12,[r6,#0x10] + mov r3,r0,lsl #1 + ldr r0,[r6,#0xc] + mov r12,r12,lsl #1 + mov r2,r0,lsl #1 + ldr r0,[r6,#8] + str r4,[r6,#8] + ldr lr,[r7,#0x54] + mov r0,r0,lsl #1 + smull r5,r4,lr,r3 + ldr lr,[r7,#0x58] + str r4,[r6,#0xc] + smull r5,r4,lr,r12 + ldr lr,[r7,#0x5c] + str r4,[r6,#0x10] + smull r5,r4,lr,r2 + ldr lr,[r7,#0x60] + str r4,[r6,#0x14] + smull r5,r4,lr,r0 + ldr lr,[r7,#0x74] + str r4,[r6,#0x18] + smull r4,r0,lr,r0 + ldr lr,[r7,#0x78] + str r0,[r6,#0x2c] + smull r0,r2,lr,r2 + ldr r0,[r7,#0x7c] + str r2,[r6,#0x30] + smull r12,r2,r0,r12 + ldr r0,[r7,#0x80] + str r2,[r6,#0x34] + smull r3,r2,r0,r3 + ldr r0,[r7,#0x84] + str r2,[r6,#0x38] + smull r2,r1,r0,r1 + str r1,[r6,#0x3c] + ldmfd sp!,{r4-r10,pc} +table + DCD ||.constdata$1|| + ENDP + +;------------------------------------------------------------------------------ + + AREA |.constdata|, DATA, READONLY, ALIGN=2 + +;------------------------------------------------------------------------------ + +||.constdata$1|| +cosTerms_dct18 + DCD 0x0807d2b0 + DCD 0x08483ee0 + DCD 0x08d3b7d0 + DCD 0x09c42570 + DCD 0x0b504f30 + DCD 0x0df29440 + DCD 0x12edfb20 + DCD 0x1ee8dd40 + DCD 0x5bca2a00 +cosTerms_1_ov_cos_phi + DCD 0x400f9c00 + DCD 0x408d6080 + DCD 0x418dcb80 + DCD 0x431b1a00 + DCD 0x4545ea00 + DCD 0x48270680 + DCD 0x4be25480 + DCD 0x50ab9480 + DCD 0x56ce4d80 + DCD 0x05ebb630 + DCD 0x06921a98 + DCD 0x0771d3a8 + DCD 0x08a9a830 + DCD 0x0a73d750 + DCD 0x0d4d5260 + DCD 0x127b1ca0 + DCD 0x1ea52b40 + DCD 0x5bb3cc80 + + + + END diff --git a/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_gcc.s b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_gcc.s new file mode 100644 index 0000000..96230c5 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_gcc.s @@ -0,0 +1,359 @@ +@ ------------------------------------------------------------------ +@ Copyright (C) 1998-2009 PacketVideo +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ http://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +@ express or implied. +@ See the License for the specific language governing permissions +@ and limitations under the License. +@ ------------------------------------------------------------------- + +@ +@ +@ Filename: pvmp3_dct_18_gcc.s +@ +@------------------------------------------------------------------------------ +@ REVISION HISTORY +@ +@ +@ Who: Date: MM/DD/YYYY +@ Description: +@ +@------------------------------------------------------------------------------ + +.arm + +.align 4 + +.text + +.extern pvmp3_dct_9 + +@------------------------------------------------------------------------------ + +.global pvmp3_mdct_18 + +pvmp3_mdct_18: + stmfd sp!,{r4-r11,lr} + mov r7,r2 + ldr r2,table + mov r6,r1 + add r3,r2,#0x24 + add r12,r3,#0x44 + add r1,r0,#0x44 + mov r5,r0 + +@ for ( i=9@ i!=0@ i--) +@ { + + mov r4,#9 +Loop_1: + +@ tmp = *(pt_vec) +@ tmp1 = *(pt_vec_o) + + ldr lr,[r0] @@ tmp == lr + ldr r8,[r3],#4 @@ tmp1 == r8 + +@ tmp = fxp_mul32_Q32( tmp<<1, *(pt_cos++ )) +@ tmp1 = fxp_mul32_Q27( tmp1, *(pt_cos_x--)) + + mov lr,lr,lsl #1 + smull r10,lr,r8,lr + ldr r8,[r12],#-4 + ldr r9,[r1] + subs r4,r4,#1 + smull r9,r10,r8,r9 + mov r8,r9,lsr #27 + add r8,r8,r10,lsl #5 + +@ *(pt_vec++) = tmp + tmp1 +@ *(pt_vec_o--) = fxp_mul32_Q28( (tmp - tmp1), *(pt_cos_split++)) + + add r9,lr,r8 + sub r8,lr,r8 + ldr lr,[r2],#4 + str r9,[r0],#4 + smull r8,r9,lr,r8 + mov lr,r8,lsr #28 + add lr,lr,r9,lsl #4 + str lr,[r1],#-4 + bne Loop_1 + +@ } + + mov r0,r5 @@ r0 = vec + bl pvmp3_dct_9 + add r0,r5,#0x24 @@ r0 = &vec[9] + bl pvmp3_dct_9 + + ldr r0,[r5,#0x20] + ldr r2,[r5,#0x40] + str r0,[r5,#0x40] + ldr r0,[r5,#0x1c] + ldr r3,[r5,#0x38] + str r0,[r5,#0x38] + ldr r1,[r5,#0x18] + ldr r0,[r5,#0x30] + str r1,[r5,#0x30] + ldr r12,[r5,#0x14] + ldr r1,[r5,#0x28] + str r12,[r5,#0x28] + ldr r12,[r5,#0x10] + str r12,[r5,#0x20] + ldr r12,[r5,#0xc] + str r12,[r5,#0x18] + ldr r12,[r5,#8] + str r12,[r5,#0x10] + ldr r12,[r5,#4] + str r12,[r5,#8] + ldr r12,[r5,#0x24] + sub r12,r12,r1 + str r12,[r5,#4] + ldr r12,[r5,#0x2c] + sub r1,r12,r1 + str r1,[r5,#0xc] + sub r1,r12,r0 + str r1,[r5,#0x14] + ldr r1,[r5,#0x34] + sub r0,r1,r0 + str r0,[r5,#0x1c] + sub r0,r1,r3 + str r0,[r5,#0x24] + ldr r1,[r5,#0x3c] + sub r3,r1,r3 + sub r1,r1,r2 + str r1,[r5,#0x34] + str r3,[r5,#0x2c] + ldr r1,[r5,#0x44] + sub r1,r1,r2 + str r1,[r5,#0x3c] + ldr r12,[r5,#0] + +Loop_2: + add r1,r5,r4,lsl #2 + ldr r2,[r1,#0x28] + ldr r3,[r6,r4,lsl #2] + add r0,r0,r2 + str r0,[r1,#0x28] + ldr lr,[r7,r4,lsl #2] + ldr r1,[r1,#4] + smlal r0,r3,lr,r0 + mov r0,r2 + add r2,r12,r1 + rsb r2,r2,#0 + str r3,[r5,r4,lsl #2] + str r2,[r6,r4,lsl #2] + add r4,r4,#1 + cmp r4,#6 + mov r12,r1 + + blt Loop_2 + + ldr r1,[r5,#0x40] + ldr r2,[r6,#0x18] + add r3,r0,r1 + str r3,[r5,#0x40] + ldr lr,[r7,r4,lsl #2] + mov r3,r3,lsl #1 + ldr r0,[r5,#0x1c] + smlal r3,r2,lr,r3 + add r3,r12,r0 + str r2,[r5,#0x18] + ldr r2,[r6,#0x1c] + rsb r3,r3,#0 + str r3,[r6,#0x18] + ldr r3,[r5,#0x20] + add r0,r3,r0 + rsb r0,r0,#0 + str r0,[r6,#0x1c] + ldr r3,[r5,#0x44] + ldr r0,[r6,#0x20] + add r3,r3,r1 + mov r1,r2 + ldr r10,[r7,#0x1c] + mov r2,r3,lsl #1 + smlal r12,r1,r10,r2 + str r1,[r5,#0x1c] + ldr r1,[r5,#0x20] + ldr r3,[r5,#0x24] + add r1,r1,r3 + rsb r1,r1,#0 + str r1,[r6,#0x20] + ldr r1,[r5,#0x44] + ldr r3,[r7,#0x20] + mov r1,r1,lsl #1 + smlal r12,r0,r3,r1 + ldr lr,[r7,#0x24] + ldr r3,[r6,#0x24] + str r0,[r5,#0x20] + smlal r1,r3,lr,r1 + ldr r0,[r6,#0x40] + ldr r12,[r6,#0x44] + str r3,[r5,#0x24] + ldr r1,[r5,#0x28] + ldr r3,[r7,#0x44] + mov r1,r1,lsl #1 + smlal r1,r12,r3,r1 + ldr r1,[r5,#0x40] + str r12,[r5,#0x44] + rsb r8,r1,#0 + str r8,[r5,#0x28] + ldr r1,[r5,#0x2c] + ldr r3,[r7,#0x40] + mov r1,r1,lsl #1 + smlal r1,r0,r3,r1 + str r0,[r5,#0x40] + ldr r0,[r5,#0x3c] + ldr r1,[r6,#0x38] + ldr r3,[r6,#0x3c] + rsb r9,r0,#0 + str r9,[r5,#0x2c] + ldr r0,[r5,#0x30] + ldr r12,[r7,#0x3c] + mov r0,r0,lsl #1 + smlal r0,r3,r12,r0 + str r3,[r5,#0x3c] + ldr r0,[r5,#0x38] + rsb r0,r0,#0 + str r0,[r5,#0x30] + ldr r3,[r5,#0x34] + ldr r12,[r7,#0x38] + mov r3,r3,lsl #1 + smlal r3,r1,r12,r3 + mov r0,r0,lsl #1 + str r1,[r5,#0x38] + ldr r4,[r7,#0x34] + ldr r1,[r6,#0x34] + ldr r3,[r6,#0x30] + smlal r0,r1,r4,r0 + ldr r12,[r6,#0x2c] + ldr lr,[r6,#0x28] + str r1,[r5,#0x34] + ldr r1,[r7,#0x30] + mov r0,r9,lsl #1 + smlal r0,r3,r1,r0 + mov r0,r8,lsl #1 + ldr r1,[r7,#0x2c] + str r3,[r5,#0x30] + smlal r0,r12,r1,r0 + ldr r0,[r7,#0x28] + str r12,[r5,#0x2c] + smlal r2,lr,r0,r2 + str lr,[r5,#0x28] + ldr r1,[r6,#4] + ldr r12,[r7,#0x48] + mov r2,r1,lsl #1 + ldr r1,[r6,#0x20] + ldr r0,[r6,#0] + mov r1,r1,lsl #1 + smull r4,lr,r12,r1 + ldr r3,[r6,#0x1c] + str lr,[r6,#0] + ldr r12,[r7,#0x4c] + mov r3,r3,lsl #1 + smull r4,lr,r12,r3 + mov r0,r0,lsl #1 + ldr r12,[r7,#0x64] + str lr,[r6,#4] + smull r4,lr,r12,r2 + ldr r12,[r7,#0x68] + str lr,[r6,#0x1c] + smull r4,lr,r12,r0 + ldr r12,[r7,#0x6c] + str lr,[r6,#0x20] + smull lr,r0,r12,r0 + ldr r12,[r7,#0x70] + str r0,[r6,#0x24] + smull r0,r2,r12,r2 + ldr r0,[r7,#0x88] + str r2,[r6,#0x28] + smull r3,r2,r0,r3 + ldr r0,[r7,#0x8c] + str r2,[r6,#0x40] + smull r2,r1,r0,r1 + str r1,[r6,#0x44] + ldr r0,[r6,#0x18] + ldr lr,[r7,#0x50] + mov r1,r0,lsl #1 + ldr r0,[r6,#0x14] + smull r5,r4,lr,r1 + mov r3,r0,lsl #1 + ldr r0,[r6,#0x10] + mov r12,r0,lsl #1 + ldr r0,[r6,#0xc] + mov r2,r0,lsl #1 + ldr r0,[r6,#8] + str r4,[r6,#8] + ldr lr,[r7,#0x54] + mov r0,r0,lsl #1 + smull r5,r4,lr,r3 + ldr lr,[r7,#0x58] + str r4,[r6,#0xc] + smull r5,r4,lr,r12 + ldr lr,[r7,#0x5c] + str r4,[r6,#0x10] + smull r5,r4,lr,r2 + ldr lr,[r7,#0x60] + str r4,[r6,#0x14] + smull r5,r4,lr,r0 + ldr lr,[r7,#0x74] + str r4,[r6,#0x18] + smull r4,r0,lr,r0 + ldr lr,[r7,#0x78] + str r0,[r6,#0x2c] + smull r0,r2,lr,r2 + ldr r0,[r7,#0x7c] + str r2,[r6,#0x30] + smull r12,r2,r0,r12 + ldr r0,[r7,#0x80] + str r2,[r6,#0x34] + smull r3,r2,r0,r3 + ldr r0,[r7,#0x84] + str r2,[r6,#0x38] + smull r2,r1,r0,r1 + str r1,[r6,#0x3c] + ldmfd sp!,{r4-r11,pc} +table: + .word constdata$1 + +@------------------------------------------------------------------------------ + +constdata$1: +cosTerms_dct18: + .word 0x0807d2b0 + .word 0x08483ee0 + .word 0x08d3b7d0 + .word 0x09c42570 + .word 0x0b504f30 + .word 0x0df29440 + .word 0x12edfb20 + .word 0x1ee8dd40 + .word 0x5bca2a00 +cosTerms_1_ov_cos_phi: + .word 0x400f9c00 + .word 0x408d6080 + .word 0x418dcb80 + .word 0x431b1a00 + .word 0x4545ea00 + .word 0x48270680 + .word 0x4be25480 + .word 0x50ab9480 + .word 0x56ce4d80 + .word 0x05ebb630 + .word 0x06921a98 + .word 0x0771d3a8 + .word 0x08a9a830 + .word 0x0a73d750 + .word 0x0d4d5260 + .word 0x127b1ca0 + .word 0x1ea52b40 + .word 0x5bb3cc80 + diff --git a/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_wm.asm b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_wm.asm new file mode 100644 index 0000000..5be75d4 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_mdct_18_wm.asm @@ -0,0 +1,366 @@ +; ------------------------------------------------------------------ +; Copyright (C) 1998-2009 PacketVideo +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +; express or implied. +; See the License for the specific language governing permissions +; and limitations under the License. +; ------------------------------------------------------------------- + +; +; +; Filename: pvmp3_dct_18.s +; +;------------------------------------------------------------------------------ +; REVISION HISTORY +; +; +; Who: Date: MM/DD/YYYY +; Description: +; +;------------------------------------------------------------------------------ + + EXPORT |pvmp3_mdct_18| + + IMPORT pvmp3_dct_9 + + +;------------------------------------------------------------------------------ + + AREA |.text|, CODE, READONLY, ALIGN=2 + + +;------------------------------------------------------------------------------ + +|pvmp3_mdct_18| PROC + stmfd sp!,{r4-r10,lr} + mov r7,r2 + ldr r2,table + mov r6,r1 + add r3,r2,#0x24 + add r12,r3,#0x44 + add r1,r0,#0x44 + mov r5,r0 + +; for ( i=9; i!=0; i--) +; { + + mov r4,#9 +Loop_1 + +; tmp = *(pt_vec); +; tmp1 = *(pt_vec_o); + + ldr lr,[r0] ;; tmp == lr + ldr r8,[r3],#4 ;; tmp1 == r8 + +; tmp = fxp_mul32_Q32( tmp<<1, *(pt_cos++ )); +; tmp1 = fxp_mul32_Q27( tmp1, *(pt_cos_x--)); + + mov lr,lr,lsl #1 + smull r10,lr,r8,lr + ldr r8,[r12],#-4 + ldr r9,[r1] + subs r4,r4,#1 + smull r9,r10,r8,r9 + mov r8,r9,lsr #27 + add r8,r8,r10,lsl #5 + +; *(pt_vec++) = tmp + tmp1 ; +; *(pt_vec_o--) = fxp_mul32_Q28( (tmp - tmp1), *(pt_cos_split++)); + + add r9,lr,r8 + sub r8,lr,r8 + ldr lr,[r2],#4 + str r9,[r0],#4 + smull r8,r9,lr,r8 + mov lr,r8,lsr #28 + add lr,lr,r9,lsl #4 + str lr,[r1],#-4 + bne Loop_1 + +; } + + mov r0,r5 ;; r0 = vec + bl pvmp3_dct_9 + add r0,r5,#0x24 ;; r0 = &vec[9] + bl pvmp3_dct_9 + + ldr r0,[r5,#0x20] + ldr r2,[r5,#0x40] + str r0,[r5,#0x40] + ldr r0,[r5,#0x1c] + ldr r3,[r5,#0x38] + str r0,[r5,#0x38] + ldr r1,[r5,#0x18] + ldr r0,[r5,#0x30] + str r1,[r5,#0x30] + ldr r12,[r5,#0x14] + ldr r1,[r5,#0x28] + str r12,[r5,#0x28] + ldr r12,[r5,#0x10] + str r12,[r5,#0x20] + ldr r12,[r5,#0xc] + str r12,[r5,#0x18] + ldr r12,[r5,#8] + str r12,[r5,#0x10] + ldr r12,[r5,#4] + str r12,[r5,#8] + ldr r12,[r5,#0x24] + sub r12,r12,r1 + str r12,[r5,#4] + ldr r12,[r5,#0x2c] + sub r1,r12,r1 + str r1,[r5,#0xc] + sub r1,r12,r0 + str r1,[r5,#0x14] + ldr r1,[r5,#0x34] + sub r0,r1,r0 + str r0,[r5,#0x1c] + sub r0,r1,r3 + str r0,[r5,#0x24] + ldr r1,[r5,#0x3c] + sub r3,r1,r3 + sub r1,r1,r2 + str r1,[r5,#0x34] + str r3,[r5,#0x2c] + ldr r1,[r5,#0x44] + sub r1,r1,r2 + str r1,[r5,#0x3c] + ldr r12,[r5,#0] + +Loop_2 + add r1,r5,r4,lsl #2 + ldr r2,[r1,#0x28] + ldr r3,[r6,r4,lsl #2] + add r0,r0,r2 + str r0,[r1,#0x28] + ldr lr,[r7,r4,lsl #2] + ldr r1,[r1,#4] + smlal r0,r3,lr,r0 + mov r0,r2 + add r2,r12,r1 + rsb r2,r2,#0 + str r3,[r5,r4,lsl #2] + str r2,[r6,r4,lsl #2] + add r4,r4,#1 + cmp r4,#6 + mov r12,r1 + + blt Loop_2 + + ldr r1,[r5,#0x40] + ldr r2,[r6,#0x18] + add r3,r0,r1 + str r3,[r5,#0x40] + ldr lr,[r7,r4,lsl #2] + mov r3,r3,lsl #1 + ldr r0,[r5,#0x1c] + smlal r3,r2,lr,r3 + add r3,r12,r0 + str r2,[r5,#0x18] + ldr r2,[r6,#0x1c] + rsb r3,r3,#0 + str r3,[r6,#0x18] + ldr r3,[r5,#0x20] + add r0,r3,r0 + rsb r0,r0,#0 + str r0,[r6,#0x1c] + ldr r3,[r5,#0x44] + ldr r0,[r6,#0x20] + add r3,r3,r1 + mov r1,r2 + ldr r10,[r7,#0x1c] + mov r2,r3,lsl #1 + smlal r12,r1,r10,r2 + str r1,[r5,#0x1c] + ldr r1,[r5,#0x20] + ldr r3,[r5,#0x24] + add r1,r1,r3 + rsb r1,r1,#0 + str r1,[r6,#0x20] + ldr r1,[r5,#0x44] + ldr r3,[r7,#0x20] + mov r1,r1,lsl #1 + smlal r12,r0,r3,r1 + ldr lr,[r7,#0x24] + ldr r3,[r6,#0x24] + str r0,[r5,#0x20] + smlal r1,r3,lr,r1 + ldr r0,[r6,#0x40] + ldr r12,[r6,#0x44] + str r3,[r5,#0x24] + ldr r1,[r5,#0x28] + ldr r3,[r7,#0x44] + mov r1,r1,lsl #1 + smlal r1,r12,r3,r1 + ldr r1,[r5,#0x40] + str r12,[r5,#0x44] + rsb r8,r1,#0 + str r8,[r5,#0x28] + ldr r1,[r5,#0x2c] + ldr r3,[r7,#0x40] + mov r1,r1,lsl #1 + smlal r1,r0,r3,r1 + str r0,[r5,#0x40] + ldr r0,[r5,#0x3c] + ldr r1,[r6,#0x38] + ldr r3,[r6,#0x3c] + rsb r9,r0,#0 + str r9,[r5,#0x2c] + ldr r0,[r5,#0x30] + ldr r12,[r7,#0x3c] + mov r0,r0,lsl #1 + smlal r0,r3,r12,r0 + str r3,[r5,#0x3c] + ldr r0,[r5,#0x38] + rsb r0,r0,#0 + str r0,[r5,#0x30] + ldr r3,[r5,#0x34] + ldr r12,[r7,#0x38] + mov r3,r3,lsl #1 + smlal r3,r1,r12,r3 + mov r0,r0,lsl #1 + str r1,[r5,#0x38] + ldr r4,[r7,#0x34] + ldr r1,[r6,#0x34] + ldr r3,[r6,#0x30] + smlal r0,r1,r4,r0 + ldr r12,[r6,#0x2c] + ldr lr,[r6,#0x28] + str r1,[r5,#0x34] + ldr r1,[r7,#0x30] + mov r0,r9,lsl #1 + smlal r0,r3,r1,r0 + mov r0,r8,lsl #1 + ldr r1,[r7,#0x2c] + str r3,[r5,#0x30] + smlal r0,r12,r1,r0 + ldr r0,[r7,#0x28] + str r12,[r5,#0x2c] + smlal r2,lr,r0,r2 + str lr,[r5,#0x28] + ldr r1,[r6,#4] + ldr r12,[r7,#0x48] + mov r2,r1,lsl #1 + ldr r1,[r6,#0x20] + ldr r0,[r6] + mov r1,r1,lsl #1 + smull r4,lr,r12,r1 + ldr r3,[r6,#0x1c] + str lr,[r6] + ldr r12,[r7,#0x4c] + mov r3,r3,lsl #1 + smull r4,lr,r12,r3 + mov r0,r0,lsl #1 + ldr r12,[r7,#0x64] + str lr,[r6,#4] + smull r4,lr,r12,r2 + ldr r12,[r7,#0x68] + str lr,[r6,#0x1c] + smull r4,lr,r12,r0 + ldr r12,[r7,#0x6c] + str lr,[r6,#0x20] + smull lr,r0,r12,r0 + ldr r12,[r7,#0x70] + str r0,[r6,#0x24] + smull r0,r2,r12,r2 + ldr r0,[r7,#0x88] + str r2,[r6,#0x28] + smull r3,r2,r0,r3 + ldr r0,[r7,#0x8c] + str r2,[r6,#0x40] + smull r2,r1,r0,r1 + str r1,[r6,#0x44] + ldr r0,[r6,#0x18] + ldr lr,[r7,#0x50] + mov r1,r0,lsl #1 + ldr r0,[r6,#0x14] + smull r5,r4,lr,r1 + ldr r12,[r6,#0x10] + mov r3,r0,lsl #1 + ldr r0,[r6,#0xc] + mov r12,r12,lsl #1 + mov r2,r0,lsl #1 + ldr r0,[r6,#8] + str r4,[r6,#8] + ldr lr,[r7,#0x54] + mov r0,r0,lsl #1 + smull r5,r4,lr,r3 + ldr lr,[r7,#0x58] + str r4,[r6,#0xc] + smull r5,r4,lr,r12 + ldr lr,[r7,#0x5c] + str r4,[r6,#0x10] + smull r5,r4,lr,r2 + ldr lr,[r7,#0x60] + str r4,[r6,#0x14] + smull r5,r4,lr,r0 + ldr lr,[r7,#0x74] + str r4,[r6,#0x18] + smull r4,r0,lr,r0 + ldr lr,[r7,#0x78] + str r0,[r6,#0x2c] + smull r0,r2,lr,r2 + ldr r0,[r7,#0x7c] + str r2,[r6,#0x30] + smull r12,r2,r0,r12 + ldr r0,[r7,#0x80] + str r2,[r6,#0x34] + smull r3,r2,r0,r3 + ldr r0,[r7,#0x84] + str r2,[r6,#0x38] + smull r2,r1,r0,r1 + str r1,[r6,#0x3c] + ldmfd sp!,{r4-r10,pc} +table + DCD cosTerms_dct18 + ENDP + +;------------------------------------------------------------------------------ + + AREA |.constdata|, DATA, READONLY, ALIGN=2 + +;------------------------------------------------------------------------------ + +cosTerms_dct18 + DCD 0x0807d2b0 + DCD 0x08483ee0 + DCD 0x08d3b7d0 + DCD 0x09c42570 + DCD 0x0b504f30 + DCD 0x0df29440 + DCD 0x12edfb20 + DCD 0x1ee8dd40 + DCD 0x5bca2a00 +cosTerms_1_ov_cos_phi + DCD 0x400f9c00 + DCD 0x408d6080 + DCD 0x418dcb80 + DCD 0x431b1a00 + DCD 0x4545ea00 + DCD 0x48270680 + DCD 0x4be25480 + DCD 0x50ab9480 + DCD 0x56ce4d80 + DCD 0x05ebb630 + DCD 0x06921a98 + DCD 0x0771d3a8 + DCD 0x08a9a830 + DCD 0x0a73d750 + DCD 0x0d4d5260 + DCD 0x127b1ca0 + DCD 0x1ea52b40 + DCD 0x5bb3cc80 + + + + END diff --git a/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_arm.s b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_arm.s new file mode 100644 index 0000000..abec599 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_arm.s @@ -0,0 +1,237 @@ +; ------------------------------------------------------------------ +; Copyright (C) 1998-2009 PacketVideo +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +; express or implied. +; See the License for the specific language governing permissions +; and limitations under the License. +; ------------------------------------------------------------------- + +; +; +; Filename: pvmp3_polyphase_filter_window.s +; +;------------------------------------------------------------------------------ +; REVISION HISTORY +; +; +; Who: Date: MM/DD/YYYY +; Description: +; +;------------------------------------------------------------------------------ + + EXPORT pvmp3_polyphase_filter_window + + IMPORT ||Lib$$Request$$armlib|| [WEAK] + IMPORT ||Lib$$Request$$cpplib|| [WEAK] + IMPORT pqmfSynthWin + + + +;------------------------------------------------------------------------------ + + AREA |.text|, CODE, READONLY, ALIGN=2 + + +;------------------------------------------------------------------------------ + +|pvmp3_polyphase_filter_window| PROC + + stmfd sp!,{r0-r2,r4-r11,lr} + + sub sp,sp,#4 + ldr r2,[sp,#0xc] + ldr r1,PolyPh_filter_coeff + + sub r2,r2,#1 + mov r10,#1 + str r2,[sp] + +; Accumulators r9, r11::> Initialization + +Loop_j + mov r9, #0x20 + mov r11, #0x20 + mov r4, #0x10 +Loop_i + add r2,r4,r10 + add r3,r0,r2,lsl #2 + sub r2,r4,r10 + ldr r5,[r3] + ldr lr,[r1] + add r12,r0,r2,lsl #2 + ldr r6,[r12,#0x780] + smlal r2,r9,lr,r5 + smlal r2,r11,lr,r6 + ldr r2,[r1,#4] + ldr r7,[r12,#0x80] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + sub r9,r9,r5 + ldr r5,[r1,#8] + ldr r8,[r3,#0x700] + add r4,r4,#0x200 + smlal r6,r9,r5,r7 + smull r6,r2,r5,r8 + ldr r5,[r1,#0xc] + sub r11,r11,r2 + smlal r8,r9,r5,r8 + smlal r7,r11,r5,r7 + ldr r5,[r3,#0x100] + ldr r2,[r1,#0x10] + ldr r6,[r12,#0x680] + smlal lr,r9,r2,r5 + smlal lr,r11,r2,r6 + ldr r2,[r1,#0x14] + ldr r7,[r12,#0x180] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + ldr r6,[r1,#0x18] + ldr r8,[r3,#0x600] + sub r9,r9,r5 + smlal r5,r9,r6,r7 + smull r2,r5,r6,r8 + ldr r6,[r1,#0x1c] + sub r11,r11,r5 + smlal r8,r9,r6,r8 + ldr r2,[r1,#0x20] + ldr r5,[r3,#0x200] + smlal r7,r11,r6,r7 + ldr r6,[r12,#0x580] + smlal lr,r9,r2,r5 + smlal lr,r11,r2,r6 + ldr r2,[r1,#0x24] + ldr r7,[r12,#0x280] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + ldr r6,[r1,#0x28] + ldr r8,[r3,#0x500] + sub r9,r9,r5 + smlal r5,r9,r6,r7 + smull r2,r5,r6,r8 + ldr r6,[r1,#0x2c] + sub r11,r11,r5 + + smlal r8,r9,r6,r8 + smlal r7,r11,r6,r7 + ldr r5,[r3,#0x300] + ldr r8,[r1,#0x30] + ldr r6,[r12,#0x480] + smlal r7,r9,r8,r5 + smlal r7,r11,r8,r6 + ldr r8,[r1,#0x34] + ldr r12,[r12,#0x380] + smlal r5,r11,r8,r5 + smull r6,r5,r8,r6 + ldr r6,[r1,#0x38] + + + ldr r3,[r3,#0x400] + sub r9,r9,r5 + smlal r7,r9,r6,r12 + smull r8,r7,r6,r3 + cmp r4,#0x210 + sub r11,r11,r7 + + ldr r2,[r1,#0x3c] + add r1,r1,#0x40 + smlal r3,r9,r2,r3 + smlal r12,r11,r2,r12 + + blt Loop_i + + mov r3,r9, asr #6 + mov r4,r3, asr #15 + teq r4,r3, asr #31 + ldr r12,LOW_16BITS + ldr r2,[sp] + eorne r3,r12,r3,asr #31 + ldr r4,[sp,#8] + mov r2,r10,lsl r2 + add r4,r4,r2,lsl #1 + strh r3,[r4] + + mov r3,r11,asr #6 + mov r4,r3,asr #15 + teq r4,r3,asr #31 + eorne r3,r12,r3,asr #31 + ldr r12,[sp,#0xc] + ldr r11,[sp,#8] + rsb r2,r2,r12,lsl #5 + add r2,r11,r2,lsl #1 + strh r3,[r2] + + add r10,r10,#1 + cmp r10,#0x10 + blt Loop_j + +; Accumulators r4, r5 Initialization + + mov r4,#0x20 + mov r5,#0x20 + mov r3,#0x10 +PolyPh_filter_loop2 + add r2,r0,r3,lsl #2 + ldr r12,[r2] + ldr r8,[r1] + ldr r6,[r2,#0x80] + smlal r12,r4,r8,r12 + ldr r12,[r1,#4] + ldr r7,[r2,#0x40] + smlal r6,r4,r12,r6 + + ldr r12,[r1,#8] + ldr r6,[r2,#0x180] + smlal r7,r5,r12,r7 + ldr r12,[r2,#0x100] + ldr r7,[r1,#0xc] + ldr r2,[r2,#0x140] + smlal r12,r4,r7,r12 + ldr r12,[r1,#0x10] + add r3,r3,#0x80 + smlal r6,r4,r12,r6 + ldr r6,[r1,#0x14] + cmp r3,#0x210 + smlal r2,r5,r6,r2 + add r1,r1,#0x18 + + blt PolyPh_filter_loop2 + mov r0,r4,asr #6 + mov r2,r0,asr #15 + teq r2,r0,asr #31 + ldrne r12,LOW_16BITS + ldr r1,[sp,#8] + eorne r0,r12,r0,asr #31 + strh r0,[r1,#0] + mov r0,r5,asr #6 + mov r2,r0,asr #15 + teq r2,r0,asr #31 + ldrne r12,LOW_16BITS + ldr r2,[sp] + mov r1,#0x10 + eorne r0,r12,r0,asr #31 + ldr r12,[sp,#8] + mov r1,r1,lsl r2 + add r1,r12,r1,lsl #1 + strh r0,[r1] + add sp,sp,#0x10 + ldmfd sp!,{r4-r11,pc} + + +PolyPh_filter_coeff + DCD pqmfSynthWin +LOW_16BITS + DCD 0x00007fff + + ENDP + + + END diff --git a/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_gcc.s b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_gcc.s new file mode 100644 index 0000000..4f45737 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_gcc.s @@ -0,0 +1,230 @@ +@ ------------------------------------------------------------------ +@ Copyright (C) 1998-2009 PacketVideo +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ http://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +@ express or implied. +@ See the License for the specific language governing permissions +@ and limitations under the License. +@ ------------------------------------------------------------------- + +@ +@ +@ Filename: pvmp3_polyphase_filter_window.s +@ +@------------------------------------------------------------------------------ +@ REVISION HISTORY +@ +@ +@ Who: Date: MM/DD/YYYY +@ Description: +@ +@------------------------------------------------------------------------------ + +.arm + +.align 4 + +.text + +.extern pqmfSynthWin + + + +@------------------------------------------------------------------------------ + +.global pvmp3_polyphase_filter_window + +pvmp3_polyphase_filter_window: + stmfd sp!,{r0-r2,r4-r11,lr} + + sub sp,sp,#4 + ldr r2,[sp,#0xc] + ldr r1,PolyPh_filter_coeff + + sub r2,r2,#1 + mov r10,#1 + str r2,[sp] + +@ Accumulators r9, r11::> Initialization + +Loop_j: + mov r9, #0x20 + mov r11, #0x20 + mov r4, #0x10 +Loop_i: + add r2,r4,r10 + add r3,r0,r2,lsl #2 + sub r2,r4,r10 + ldr r5,[r3] + ldr lr,[r1] + add r12,r0,r2,lsl #2 + ldr r6,[r12,#0x780] + smlal r2,r9,lr,r5 + smlal r2,r11,lr,r6 + ldr r2,[r1,#4] + ldr r7,[r12,#0x80] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + sub r9,r9,r5 + ldr r5,[r1,#8] + ldr r8,[r3,#0x700] + add r4,r4,#0x200 + smlal r6,r9,r5,r7 + smull r6,r2,r5,r8 + ldr r5,[r1,#0xc] + sub r11,r11,r2 + smlal r8,r9,r5,r8 + smlal r7,r11,r5,r7 + ldr r5,[r3,#0x100] + ldr r2,[r1,#0x10] + ldr r6,[r12,#0x680] + smlal lr,r9,r2,r5 + smlal lr,r11,r2,r6 + ldr r2,[r1,#0x14] + ldr r7,[r12,#0x180] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + ldr r6,[r1,#0x18] + ldr r8,[r3,#0x600] + sub r9,r9,r5 + smlal r5,r9,r6,r7 + smull r2,r5,r6,r8 + ldr r6,[r1,#0x1c] + sub r11,r11,r5 + smlal r8,r9,r6,r8 + ldr r2,[r1,#0x20] + ldr r5,[r3,#0x200] + smlal r7,r11,r6,r7 + ldr r6,[r12,#0x580] + smlal lr,r9,r2,r5 + smlal lr,r11,r2,r6 + ldr r2,[r1,#0x24] + ldr r7,[r12,#0x280] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + ldr r6,[r1,#0x28] + ldr r8,[r3,#0x500] + sub r9,r9,r5 + smlal r5,r9,r6,r7 + smull r2,r5,r6,r8 + ldr r6,[r1,#0x2c] + sub r11,r11,r5 + + smlal r8,r9,r6,r8 + smlal r7,r11,r6,r7 + ldr r5,[r3,#0x300] + ldr r8,[r1,#0x30] + ldr r6,[r12,#0x480] + smlal r7,r9,r8,r5 + smlal r7,r11,r8,r6 + ldr r8,[r1,#0x34] + ldr r12,[r12,#0x380] + smlal r5,r11,r8,r5 + smull r6,r5,r8,r6 + ldr r6,[r1,#0x38] + + + ldr r3,[r3,#0x400] + sub r9,r9,r5 + smlal r7,r9,r6,r12 + smull r8,r7,r6,r3 + cmp r4,#0x210 + sub r11,r11,r7 + + ldr r2,[r1,#0x3c] + add r1,r1,#0x40 + smlal r3,r9,r2,r3 + smlal r12,r11,r2,r12 + + blt Loop_i + + mov r3,r9, asr #6 + mov r4,r3, asr #15 + teq r4,r3, asr #31 + ldr r12,LOW_16BITS + ldr r2,[sp] + eorne r3,r12,r3,asr #31 + ldr r4,[sp,#8] + mov r2,r10,lsl r2 + add r4,r4,r2,lsl #1 + strh r3,[r4] + + mov r3,r11,asr #6 + mov r4,r3,asr #15 + teq r4,r3,asr #31 + eorne r3,r12,r3,asr #31 + ldr r12,[sp,#0xc] + ldr r11,[sp,#8] + rsb r2,r2,r12,lsl #5 + add r2,r11,r2,lsl #1 + strh r3,[r2] + + add r10,r10,#1 + cmp r10,#0x10 + blt Loop_j + +@ Accumulators r4, r5 Initialization + + mov r4,#0x20 + mov r5,#0x20 + mov r3,#0x10 +PolyPh_filter_loop2: + add r2,r0,r3,lsl #2 + ldr r12,[r2] + ldr r8,[r1] + ldr r6,[r2,#0x80] + smlal r12,r4,r8,r12 + ldr r12,[r1,#4] + ldr r7,[r2,#0x40] + smlal r6,r4,r12,r6 + + ldr r12,[r1,#8] + ldr r6,[r2,#0x180] + smlal r7,r5,r12,r7 + ldr r12,[r2,#0x100] + ldr r7,[r1,#0xc] + ldr r2,[r2,#0x140] + smlal r12,r4,r7,r12 + ldr r12,[r1,#0x10] + add r3,r3,#0x80 + smlal r6,r4,r12,r6 + ldr r6,[r1,#0x14] + cmp r3,#0x210 + smlal r2,r5,r6,r2 + add r1,r1,#0x18 + + blt PolyPh_filter_loop2 + mov r0,r4,asr #6 + mov r2,r0,asr #15 + teq r2,r0,asr #31 + ldrne r12,LOW_16BITS + ldr r1,[sp,#8] + eorne r0,r12,r0,asr #31 + strh r0,[r1,#0] + mov r0,r5,asr #6 + mov r2,r0,asr #15 + teq r2,r0,asr #31 + ldrne r12,LOW_16BITS + ldr r2,[sp] + mov r1,#0x10 + eorne r0,r12,r0,asr #31 + ldr r12,[sp,#8] + mov r1,r1,lsl r2 + add r1,r12,r1,lsl #1 + strh r0,[r1] + add sp,sp,#0x10 + ldmfd sp!,{r4-r11,pc} + +PolyPh_filter_coeff: + .word pqmfSynthWin +LOW_16BITS: + .word 0x00007fff + diff --git a/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_wm.asm b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_wm.asm new file mode 100644 index 0000000..f957267 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_wm.asm @@ -0,0 +1,231 @@ +; ------------------------------------------------------------------ +; Copyright (C) 1998-2009 PacketVideo +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +; express or implied. +; See the License for the specific language governing permissions +; and limitations under the License. +; ------------------------------------------------------------------- + +; +; +; Filename: pvmp3_polyphase_filter_window.s +; +;------------------------------------------------------------------------------ +; REVISION HISTORY +; +; +; Who: Date: MM/DD/YYYY +; Description: +; +;------------------------------------------------------------------------------ + + CODE32 + + AREA |.drectve|, DRECTVE + + EXPORT |pvmp3_polyphase_filter_window| + IMPORT |pqmfSynthWin| + + AREA |.pdata|, PDATA + + AREA |.text|, CODE, ARM + +|pvmp3_polyphase_filter_window| PROC + stmfd sp!,{r0-r2,r4-r11,lr} + + sub sp,sp,#4 + ldr r2,[sp,#0xc] + ldr r1,PolyPh_filter_coeff + + sub r2,r2,#1 + mov r10,#1 + str r2,[sp] + +; Accumulators r9, r11::> Initialization + +Loop_j + mov r9, #0x20 + mov r11, #0x20 + mov r4, #0x10 +Loop_i + add r2,r4,r10 + add r3,r0,r2,lsl #2 + sub r2,r4,r10 + ldr r5,[r3] + ldr lr,[r1] + add r12,r0,r2,lsl #2 + ldr r6,[r12,#0x780] + smlal r2,r9,lr,r5 + smlal r2,r11,lr,r6 + ldr r2,[r1,#4] + ldr r7,[r12,#0x80] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + sub r9,r9,r5 + ldr r5,[r1,#8] + ldr r8,[r3,#0x700] + add r4,r4,#0x200 + smlal r6,r9,r5,r7 + smull r6,r2,r5,r8 + ldr r5,[r1,#0xc] + sub r11,r11,r2 + smlal r8,r9,r5,r8 + smlal r7,r11,r5,r7 + ldr r5,[r3,#0x100] + ldr r2,[r1,#0x10] + ldr r6,[r12,#0x680] + smlal lr,r9,r2,r5 + smlal lr,r11,r2,r6 + ldr r2,[r1,#0x14] + ldr r7,[r12,#0x180] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + ldr r6,[r1,#0x18] + ldr r8,[r3,#0x600] + sub r9,r9,r5 + smlal r5,r9,r6,r7 + smull r2,r5,r6,r8 + ldr r6,[r1,#0x1c] + sub r11,r11,r5 + smlal r8,r9,r6,r8 + ldr r2,[r1,#0x20] + ldr r5,[r3,#0x200] + smlal r7,r11,r6,r7 + ldr r6,[r12,#0x580] + smlal lr,r9,r2,r5 + smlal lr,r11,r2,r6 + ldr r2,[r1,#0x24] + ldr r7,[r12,#0x280] + smlal r5,r11,r2,r5 + smull r6,r5,r2,r6 + ldr r6,[r1,#0x28] + ldr r8,[r3,#0x500] + sub r9,r9,r5 + smlal r5,r9,r6,r7 + smull r2,r5,r6,r8 + ldr r6,[r1,#0x2c] + sub r11,r11,r5 + + smlal r8,r9,r6,r8 + smlal r7,r11,r6,r7 + ldr r5,[r3,#0x300] + ldr r8,[r1,#0x30] + ldr r6,[r12,#0x480] + smlal r7,r9,r8,r5 + smlal r7,r11,r8,r6 + ldr r8,[r1,#0x34] + ldr r12,[r12,#0x380] + smlal r5,r11,r8,r5 + smull r6,r5,r8,r6 + ldr r6,[r1,#0x38] + + + ldr r3,[r3,#0x400] + sub r9,r9,r5 + smlal r7,r9,r6,r12 + smull r8,r7,r6,r3 + cmp r4,#0x210 + sub r11,r11,r7 + + ldr r2,[r1,#0x3c] + add r1,r1,#0x40 + smlal r3,r9,r2,r3 + smlal r12,r11,r2,r12 + + blt Loop_i + + mov r3,r9, asr #6 + mov r4,r3, asr #15 + teq r4,r3, asr #31 + ldr r12,LOW_16BITS + ldr r2,[sp] + eorne r3,r12,r3,asr #31 + ldr r4,[sp,#8] + mov r2,r10,lsl r2 + add r4,r4,r2,lsl #1 + strh r3,[r4] + + mov r3,r11,asr #6 + mov r4,r3,asr #15 + teq r4,r3,asr #31 + eorne r3,r12,r3,asr #31 + ldr r12,[sp,#0xc] + ldr r11,[sp,#8] + rsb r2,r2,r12,lsl #5 + add r2,r11,r2,lsl #1 + strh r3,[r2] + + add r10,r10,#1 + cmp r10,#0x10 + blt Loop_j + +; Accumulators r4, r5 Initialization + + mov r4,#0x20 + mov r5,#0x20 + mov r3,#0x10 +PolyPh_filter_loop2 + add r2,r0,r3,lsl #2 + ldr r12,[r2] + ldr r8,[r1] + ldr r6,[r2,#0x80] + smlal r12,r4,r8,r12 + ldr r12,[r1,#4] + ldr r7,[r2,#0x40] + smlal r6,r4,r12,r6 + + ldr r12,[r1,#8] + ldr r6,[r2,#0x180] + smlal r7,r5,r12,r7 + ldr r12,[r2,#0x100] + ldr r7,[r1,#0xc] + ldr r2,[r2,#0x140] + smlal r12,r4,r7,r12 + ldr r12,[r1,#0x10] + add r3,r3,#0x80 + smlal r6,r4,r12,r6 + ldr r6,[r1,#0x14] + cmp r3,#0x210 + smlal r2,r5,r6,r2 + add r1,r1,#0x18 + + blt PolyPh_filter_loop2 + mov r0,r4,asr #6 + mov r2,r0,asr #15 + teq r2,r0,asr #31 + ldrne r12,LOW_16BITS + ldr r1,[sp,#8] + eorne r0,r12,r0,asr #31 + strh r0,[r1,#0] + mov r0,r5,asr #6 + mov r2,r0,asr #15 + teq r2,r0,asr #31 + ldrne r12,LOW_16BITS + ldr r2,[sp] + mov r1,#0x10 + eorne r0,r12,r0,asr #31 + ldr r12,[sp,#8] + mov r1,r1,lsl r2 + add r1,r12,r1,lsl #1 + strh r0,[r1] + add sp,sp,#0x10 + ldmfd sp!,{r4-r11,pc} + + +PolyPh_filter_coeff + DCD pqmfSynthWin +LOW_16BITS + DCD 0x00007fff + + ENDP ; |pvmp3_polyphase_filter_window| + END + diff --git a/media/libstagefright/codecs/mp3dec/src/mp3_mem_funcs.h b/media/libstagefright/codecs/mp3dec/src/mp3_mem_funcs.h new file mode 100644 index 0000000..46e8022 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/mp3_mem_funcs.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: mp3_mem_funcs.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ + +#ifndef MP3_MEM_FUNCS_H +#define MP3_MEM_FUNCS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include + +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + + +#define pv_memset(to, c, n) memset(to, c, n) + + +#define pv_memcpy(to, from, n) memcpy(to, from, n) +#define pv_memmove(to, from, n) memmove(to, from, n) +#define pv_memcmp(p, q, n) memcmp(p, q, n) + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + + +#endif diff --git a/media/libstagefright/codecs/mp3dec/src/pv_mp3_huffman.h b/media/libstagefright/codecs/mp3dec/src/pv_mp3_huffman.h new file mode 100644 index 0000000..31102ea --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pv_mp3_huffman.h @@ -0,0 +1,115 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pv_mp3_huffman.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ + +#ifndef PV_MP3_HUFFMAN_H +#define PV_MP3_HUFFMAN_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" +#include "s_tmp3dec_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + int32 pvmp3_huffman_parsing(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], + granuleInfo *grInfo, + tmp3dec_file *pVars, + int32 part2_start, + mp3Header *info); + + + void pvmp3_huffman_quad_decoding(struct huffcodetab *h, + int32 *is, + tmp3Bits *pMainData); + + void pvmp3_huffman_pair_decoding(struct huffcodetab *h, + int32 *is, + tmp3Bits *pMainData); + + + void pvmp3_huffman_pair_decoding_linbits(struct huffcodetab *h, + int32 *is, + tmp3Bits *pMainData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op.h b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op.h new file mode 100644 index 0000000..f14e2de --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pv_mp3dec_fxd_op.h + + Date: 09/21/2007 + + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file select the associated fixed point functions with the OS/ARCH. + + + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_MP3DEC_FXD_OP_H +#define PV_MP3DEC_FXD_OP_H + +#include "pvmp3_audio_type_defs.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#if (defined(PV_ARM_V5)||defined(PV_ARM_V4)) + +#include "pv_mp3dec_fxd_op_arm.h" + +#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4)) + +#include "pv_mp3dec_fxd_op_arm_gcc.h" + +#elif (defined(PV_ARM_MSC_EVC_V5)||defined(PV_ARM_MSC_EVC_V4)) + +#include "pv_mp3dec_fxd_op_msc_evc.h" + +#else + +#ifndef C_EQUIVALENT +#define C_EQUIVALENT +#endif + +#include "pv_mp3dec_fxd_op_c_equivalent.h" + +#endif + + +#ifdef __cplusplus +} +#endif + + + +#endif /* PV_MP3DEC_FXD_OP_H */ diff --git a/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm.h b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm.h new file mode 100644 index 0000000..76a8229 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm.h @@ -0,0 +1,203 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Pathname: ./cpp/include/pv_mp3dec_fxd_op_arm.h + + Date: 08/20/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file select the associated fixed point functions with the OS/ARCH. + + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_MP3DEC_FXD_OP_ARM +#define PV_MP3DEC_FXD_OP_ARM + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "pvmp3_audio_type_defs.h" + + +#if (defined(PV_ARM_V5)||defined(PV_ARM_V4)) + + + __inline Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2) + { + + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_lo, result64_lo, lsr #30 + add result64_hi, result64_lo, result64_hi, asl #2 + } + return (result64_hi); + } + + __inline Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + add L_add, L_add, result64_hi, asl #2 + add L_add, L_add, result64_lo, lsr #30 + } + return (L_add); + } + + + +#define Qfmt_31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) + + + + __inline Int32 fxp_mul32_Q32(Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + __asm + { + smull L_var1, result64_hi, L_var2, L_var1 + } + return (result64_hi); + } + + __inline Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2) + { + + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_lo, result64_lo, lsr #28 + add result64_hi, result64_lo, result64_hi, asl #4 + } + return (result64_hi); + } + + + __inline Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2) + { + + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_lo, result64_lo, lsr #27 + add result64_hi, result64_lo, result64_hi, asl #5 + } + return (result64_hi); + } + + + __inline Int32 fxp_mul32_Q26(Int32 L_var1, Int32 L_var2) + { + + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_lo, result64_lo, lsr #26 + add result64_hi, result64_lo, result64_hi, asl #6 + } + return (result64_hi); + } + + + + __inline Int32 fxp_mac32_Q32(Int32 L_add, Int32 L_var1, const Int32 L_var2) + { + __asm + { + smlal L_var1, L_add, L_var2, L_var1 + } + return L_add; + } + + + __inline Int32 fxp_msb32_Q32(Int32 L_sub, Int32 L_var1, Int32 L_var2) + { + + __asm + { + smull L_var2, L_var1, L_var2, L_var1 + sub L_sub, L_sub, L_var1 + } + return L_sub; + } + + + __inline Int32 fxp_mul32_Q29(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_lo, result64_lo, lsr #29 + add result64_hi, result64_lo, result64_hi, asl #3 + } + return (result64_hi); + } + + + __inline int32 pv_abs(int32 a) + { + Int32 b; + /* + b = a - (a<0); + a = b ^ sign(b) + */ + __asm + { + sub b, a, a, lsr #31 + eor a, b, b, asr #31 + } + return (a); + } + +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* PV_MP3DEC_FXD_OP_ARM */ + diff --git a/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm_gcc.h b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm_gcc.h new file mode 100644 index 0000000..71fbd20 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm_gcc.h @@ -0,0 +1,252 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Pathname: ./cpp/include/pv_mp3dec_fxd_op_arm_gcc.h + + Date: 08/20/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file select the associated fixed point functions with the OS/ARCH. + + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_MP3DEC_FXD_OP_ARM_GCC_H +#define PV_MP3DEC_FXD_OP_ARM_GCC_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "pvmp3_audio_type_defs.h" + + +#if (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4)) + +#define Qfmt_31(a) (int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) + +#define Qfmt15(x) (Int16)(x*((int32)1<<15) + (x>=0?0.5F:-0.5F)) + + static inline int32 fxp_mul32_Q30(const int32 a, const int32 b) + { + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %1, %1, lsr #30\n\t" + "add %0, %1, %0, asl #2" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + + static inline int32 fxp_mac32_Q30(const int32 a, const int32 b, int32 L_add) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + register int32 rc = (int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %4, %4, %0, asl #2\n\t" + "add %0, %4, %1, lsr #30" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + + static inline int32 fxp_mul32_Q32(const int32 a, const int32 b) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile( + "smull %1, %0, %2, %3" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline int32 fxp_mul32_Q29(const int32 a, const int32 b) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %1, %1, lsr #29\n\t" + "add %0, %1, %0, asl #3" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + + } + + static inline int32 fxp_mul32_Q28(const int32 a, const int32 b) +{ + + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %1, %1, lsr #28\n\t" + "add %0, %1, %0, asl #4" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + + } + + + static inline int32 fxp_mul32_Q27(const int32 a, const int32 b) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %1, %1, lsr #27\n\t" + "add %0, %1, %0, asl #5" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + + } + + + static inline int32 fxp_mul32_Q26(const int32 a, const int32 b) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %1, %1, lsr #26\n\t" + "add %0, %1, %0, asl #6" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + + } + + + + static inline int32 fxp_mac32_Q32(int32 L_add, const int32 a, const int32 b) +{ + + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + register int32 rc = (int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %0, %0, %4" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + static inline int32 fxp_msb32_Q32(int32 L_sub, const int32 a, const int32 b) +{ + int32 result64_hi; + int32 result64_lo; + register int32 ra = (int32)a; + register int32 rb = (int32)b; + register int32 rc = (int32)L_sub; + + asm volatile("smull %1, %0, %2, %3\n\t" + "sub %0, %4, %0" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + + return (result64_hi); + } + + + __inline int32 pv_abs(int32 x) +{ + register int32 z; + register int32 y; + register int32 ra = x; + asm volatile( + "sub %0, %2, %2, lsr #31\n\t" + "eor %1, %0, %0, asr #31" + : "=&r*i"(z), + "=&r*i"(y) + : "r"(ra)); + + return (y); + } + + +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* PV_MP3DEC_FXD_OP_ARM_GCC_H */ + diff --git a/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h new file mode 100644 index 0000000..ba43820 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h @@ -0,0 +1,123 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Pathname: ./cpp/include/pv_mp3dec_fxd_op_c_equivalent.h + + Date: 12/06/2005 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_MP3DEC_FXD_OP_C_EQUIVALENT +#define PV_MP3DEC_FXD_OP_C_EQUIVALENT + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "pvmp3_audio_type_defs.h" +#define Qfmt_31(a) (Int32)((float)a*0x7FFFFFFF) + +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + + + + __inline int32 pv_abs(int32 a) + { + int32 b = (a < 0) ? -a : a; + return b; + } + + + + + __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 30); + } + + __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) + { + return (L_add + (Int32)(((int64)(a) * b) >> 30)); + } + + __inline Int32 fxp_mul32_Q32(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 32); + } + + + __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 28); + } + + __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 27); + } + + __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 26); + } + + + __inline Int32 fxp_mac32_Q32(Int32 L_add, const Int32 a, const Int32 b) + { + return (L_add + (Int32)(((int64)(a) * b) >> 32)); + } + + __inline Int32 fxp_msb32_Q32(Int32 L_sub, const Int32 a, const Int32 b) + { + return (L_sub - ((Int32)(((int64)(a) * b) >> 32))); + } + + + __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) + { + return (Int32)(((int64)(a) * b) >> 29); + } + + + + + + +#ifdef __cplusplus +} +#endif + + +#endif /* PV_MP3DEC_FXD_OP_C_EQUIVALENT */ + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_msc_evc.h b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_msc_evc.h new file mode 100644 index 0000000..271e6b7 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pv_mp3dec_fxd_op_msc_evc.h @@ -0,0 +1,132 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Pathname: ./cpp/include/pv_mp3dec_fxd_op_msc_evc.h + + Date: 08/20/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file select the associated fixed point functions with the OS/ARCH. + + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_MP3DEC_FXD_OP_MSC_EVC_H +#define PV_MP3DEC_FXD_OP_MSC_EVC_H + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "pvmp3_audio_type_defs.h" + + +#if (defined(PV_ARM_MSC_EVC_V5)||defined(PV_ARM_MSC_EVC_V4)) +#include "armintr.h" +#include "cmnintrin.h" + + + __inline int32 fxp_mul32_Q30(const int32 a, const int32 b) + { + return (int32)(((int64)(a) * b) >> 30); + } + + + __inline int32 fxp_mac32_Q30(const int32 a, const int32 b, int32 L_add) + { + return (L_add + (int32)(((int64)(a) * b) >> 30)); + } + + +#define Qfmt_31(a) (int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) + +#define Qfmt15(x) (Int16)(x*((int32)1<<15) + (x>=0?0.5F:-0.5F)) + +#define fxp_mul32_Q32( a, b) _MulHigh( b, a) + + + + __inline int32 fxp_mul32_Q28(const int32 a, const int32 b) + { + return (int32)(((int64)(a) * b) >> 28); + } + + + __inline int32 fxp_mul32_Q27(const int32 a, const int32 b) + { + return (int32)(((int64)(a) * b) >> 27); + } + + + + __inline int32 fxp_mul32_Q26(const int32 a, const int32 b) + { + return (int32)(((int64)(a) * b) >> 26); + } + + + __inline int32 fxp_mac32_Q32(int32 L_add, const int32 a, const int32 b) + { + return (L_add + _MulHigh(b, a)); + } + + + __inline int32 fxp_msb32_Q32(int32 L_sub, const int32 a, const int32 b) + { + return (L_sub - _MulHigh(b, a)); + } + + + + __inline int32 fxp_mul32_Q29(const int32 a, const int32 b) + { + return (int32)(((int64)(a) * b) >> 29); + } + + + + __inline int32 pv_abs(int32 a) + { + int32 b = (a < 0) ? -a : a; + return b; + } + + + +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* PV_MP3DEC_FXD_OP_MSC_EVC_H */ + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.cpp new file mode 100644 index 0000000..32c76c6 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.cpp @@ -0,0 +1,261 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_alias_reduction.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + int32 *input_buffer, Ptr to fequency lines of current channel + struct gr_info_s *gr_info, structure with granuke information for the + input + mp3Header *info mp3 header information + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Alias Reduction + + + + Alias reduction before processing by the IMDCT + + Csi + + >---------0---------0--------> + \ / - + Cai \ / + \ / + \ / + \ + / \ + Cai / \ + / \ + + >--------0---------0----------> + Csi + + + Aliasing Butterfly + Alias reduction is not applied to short blocks + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + 1 ci + csi = ---------------- csi = ---------------- + sqrt( 1 + (ci^2)) sqrt( 1 + (ci^2)) + + + ci = -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037 + + ------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_alias_reduction.h" +#include "pv_mp3dec_fxd_op.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define NUM_BUTTERFLIES 8 + +#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*a)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 c_signal [ NUM_BUTTERFLIES ] = +{ + + Q31_fmt(0.85749292571254f), Q31_fmt(0.88174199731771f), + Q31_fmt(0.94962864910273f), Q31_fmt(0.98331459249179f), + Q31_fmt(0.99551781606759f), Q31_fmt(0.99916055817815f), + Q31_fmt(0.99989919524445f), Q31_fmt(0.99999315507028f) + +}; + + +const int32 c_alias [ NUM_BUTTERFLIES ] = +{ + + Q31_fmt(-0.51449575542753f), Q31_fmt(-0.47173196856497f), + Q31_fmt(-0.31337745420390f), Q31_fmt(-0.18191319961098f), + Q31_fmt(-0.09457419252642f), Q31_fmt(-0.04096558288530f), + Q31_fmt(-0.01419856857247f), Q31_fmt(-0.00369997467376f) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_alias_reduction(int32 *input_buffer, /* Ptr to spec values of current channel */ + granuleInfo *gr_info, + int32 *used_freq_lines, + mp3Header *info) +{ + int32 *ptr1; + int32 *ptr2; + int32 *ptr3; + int32 *ptr4; + const int32 *ptr_csi; + const int32 *ptr_csa; + int32 sblim; + + int32 i, j; + + *used_freq_lines = fxp_mul32_Q32(*used_freq_lines << 16, (int32)(0x7FFFFFFF / (float)18 - 1.0f)) >> 15; + + + if (gr_info->window_switching_flag && gr_info->block_type == 2) + { + if (gr_info->mixed_block_flag) + { + sblim = ((info->version_x == MPEG_2_5) && (info->sampling_frequency == 2)) ? 3 : 1; + } + else + { + return; /* illegal parameter */ + } + } + else + { + sblim = *used_freq_lines + 1; + + if (sblim > SUBBANDS_NUMBER - 1) + { + sblim = SUBBANDS_NUMBER - 1; /* default */ + } + + } + + + ptr3 = &input_buffer[17]; + ptr4 = &input_buffer[18]; + ptr_csi = c_signal; + ptr_csa = c_alias; + + /* NUM_BUTTERFLIES (=8) butterflies between each pair of sub-bands*/ + + for (i = NUM_BUTTERFLIES >> 1; i != 0; i--) + { + int32 csi1 = *ptr_csi++; + int32 csi2 = *ptr_csi++; + int32 csa1 = *ptr_csa++; + int32 csa2 = *ptr_csa++; + + ptr1 = ptr3; + ptr3 -= 2; + ptr2 = ptr4; + ptr4 += 2; + + /* + * "sblim" alias-reduction operations between each + * pair of sub-bands + */ + + for (j = sblim >> 1; j != 0; j--) + { + int32 y = *ptr2; + int32 x = *ptr1 << 1; + *ptr1-- = fxp_msb32_Q32(fxp_mul32_Q32(x, csi1), y << 1, csa1); + *ptr2++ = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi1), x, csa1); + y = *ptr2; + x = *ptr1 << 1; + *ptr1 = fxp_msb32_Q32(fxp_mul32_Q32(x, csi2), y << 1, csa2); + *ptr2 = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi2), x, csa2); + ptr1 += 19; + ptr2 += 17; + y = *ptr2; + x = *ptr1 << 1; + *ptr1-- = fxp_msb32_Q32(fxp_mul32_Q32(x, csi1), y << 1, csa1); + *ptr2++ = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi1), x, csa1); + y = *ptr2; + x = *ptr1 << 1; + *ptr1 = fxp_msb32_Q32(fxp_mul32_Q32(x, csi2), y << 1, csa2); + *ptr2 = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi2), x, csa2); + ptr1 += 19; + ptr2 += 17; + + } + + if (sblim & 1) + { + int32 x = *ptr1 << 1; + int32 y = *ptr2; + *ptr1-- = fxp_msb32_Q32(fxp_mul32_Q32(x, csi1), y << 1, csa1); + *ptr2++ = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi1), x, csa1); + + x = *ptr1 << 1; + y = *ptr2; + *ptr1 = fxp_msb32_Q32(fxp_mul32_Q32(x, csi2), y << 1, csa2); + *ptr2 = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi2), x, csa2); + } + } + +} diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.h new file mode 100644 index 0000000..2292d5f --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_alias_reduction.h @@ -0,0 +1,100 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_alias_reduction.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_ALIAS_REDUCTION_H +#define PVMP3_ALIAS_REDUCTION_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_alias_reduction(int32 *input_buffer, + granuleInfo *gr_info, + int32 *used_freq_lines, + mp3Header *info); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_crc.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_crc.cpp new file mode 100644 index 0000000..20d0d82 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_crc.cpp @@ -0,0 +1,161 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_crc.cpp + + Functions: + getbits_crc + calculate_crc + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +getbits_crc + +Input + tbits *inputStream, bit stream structure + int32 neededBits, number of bits to read from the bit stream + uint32 *crc, memory location holding calculated crc value + uint32 crc_enabled flag to enable/disable crc checking + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +calculate_crc + +Input + uint32 data, data vector + uint32 length, number of element upon the crc will be calculated + uint32 *crc, memory location holding calculated crc value + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + + ------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_getbits.h" +#include "pvmp3_crc.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint32 getbits_crc(tmp3Bits *inputStream, /* bit stream structure */ + int32 neededBits, /* number of bits to read from the bit stream */ + uint32 *crc, + uint32 crc_enabled) +{ + uint32 bits = getNbits(inputStream, neededBits); + + if (crc_enabled) + { + calculate_crc(bits, neededBits, crc); + } + return(bits); +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void calculate_crc(uint32 data, + uint32 length, + uint32 *crc) +{ + uint32 carry; + uint32 masking = 1 << length; + + while ((masking >>= 1)) + { + carry = *crc & 0x8000; + *crc <<= 1; + if (!carry ^ !(data & masking)) + { + *crc ^= CRC16_POLYNOMIAL; + } + } + *crc &= 0xffff; +} + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_crc.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_crc.h new file mode 100644 index 0000000..b7c277a --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_crc.h @@ -0,0 +1,110 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_crc.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_CRC_H +#define PVMP3_CRC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" +#include "pvmp3decoder_api.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define CRC16_POLYNOMIAL 0x8005 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + uint32 getbits_crc(tmp3Bits *inputStream, + int32 neededBits, + uint32 *crc, + uint32 crc_enabled); + + + void calculate_crc(uint32 data, + uint32 length, + uint32 *crc); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.cpp new file mode 100644 index 0000000..a71efc4 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.cpp @@ -0,0 +1,410 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dct_16.cpp + + Functions: + dct_16 + pv_merge_in_place_N32 + pv_split + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + dct_16 + +Input + int32 vec[], input vector length 16 + Int flag processing direction: forward (1), backward ( 0) + Returns + + int32 vec[], dct length 16 + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + pv_merge_in_place_N32 + +Input + int32 vec[], input vector length 16 + + Returns + + int32 vec[], merged output of two dct 16 to create a dct 32 + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + pv_split + +Input + int32 vec[], input vector length 16 + + Returns + + int32 vec[], splitted even/odd and pre processing rotation + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + dct 16 and tools to assemble a dct32 output + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) ) +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dct_16.h" +#include "pv_mp3dec_fxd_op.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define Qfmt(a) (int32)(a*((int32)1<<27)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 CosTable_dct32[16] = +{ + Qfmt_31(0.50060299823520F) , Qfmt_31(0.50547095989754F) , + Qfmt_31(0.51544730992262F) , Qfmt_31(0.53104259108978F) , + Qfmt_31(0.55310389603444F) , Qfmt_31(0.58293496820613F) , + Qfmt_31(0.62250412303566F) , Qfmt_31(0.67480834145501F) , + Qfmt_31(0.74453627100230F) , Qfmt_31(0.83934964541553F) , + + Qfmt(0.97256823786196F) , Qfmt(1.16943993343288F) , + Qfmt(1.48416461631417F) , Qfmt(2.05778100995341F) , + Qfmt(3.40760841846872F) , Qfmt(10.19000812354803F) +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_dct_16(int32 vec[], int32 flag) +{ + int32 tmp0; + int32 tmp1; + int32 tmp2; + int32 tmp3; + int32 tmp4; + int32 tmp5; + int32 tmp6; + int32 tmp7; + int32 tmp_o0; + int32 tmp_o1; + int32 tmp_o2; + int32 tmp_o3; + int32 tmp_o4; + int32 tmp_o5; + int32 tmp_o6; + int32 tmp_o7; + int32 itmp_e0; + int32 itmp_e1; + int32 itmp_e2; + + /* split input vector */ + + tmp_o0 = fxp_mul32_Q32((vec[ 0] - vec[15]), Qfmt_31(0.50241928618816F)); + tmp0 = vec[ 0] + vec[15]; + + tmp_o7 = fxp_mul32_Q32((vec[ 7] - vec[ 8]) << 3, Qfmt_31(0.63764357733614F)); + tmp7 = vec[ 7] + vec[ 8]; + + itmp_e0 = fxp_mul32_Q32((tmp0 - tmp7), Qfmt_31(0.50979557910416F)); + tmp7 = (tmp0 + tmp7); + + tmp_o1 = fxp_mul32_Q32((vec[ 1] - vec[14]), Qfmt_31(0.52249861493969F)); + tmp1 = vec[ 1] + vec[14]; + + tmp_o6 = fxp_mul32_Q32((vec[ 6] - vec[ 9]) << 1, Qfmt_31(0.86122354911916F)); + tmp6 = vec[ 6] + vec[ 9]; + + + + itmp_e1 = (tmp1 + tmp6); + tmp6 = fxp_mul32_Q32((tmp1 - tmp6), Qfmt_31(0.60134488693505F)); + + + + tmp_o2 = fxp_mul32_Q32((vec[ 2] - vec[13]), Qfmt_31(0.56694403481636F)); + tmp2 = vec[ 2] + vec[13]; + tmp_o5 = fxp_mul32_Q32((vec[ 5] - vec[10]) << 1, Qfmt_31(0.53033884299517F)); + tmp5 = vec[ 5] + vec[10]; + + itmp_e2 = (tmp2 + tmp5); + tmp5 = fxp_mul32_Q32((tmp2 - tmp5), Qfmt_31(0.89997622313642F)); + + tmp_o3 = fxp_mul32_Q32((vec[ 3] - vec[12]), Qfmt_31(0.64682178335999F)); + tmp3 = vec[ 3] + vec[12]; + tmp_o4 = fxp_mul32_Q32((vec[ 4] - vec[11]), Qfmt_31(0.78815462345125F)); + tmp4 = vec[ 4] + vec[11]; + + tmp1 = (tmp3 + tmp4); + tmp4 = fxp_mul32_Q32((tmp3 - tmp4) << 2, Qfmt_31(0.64072886193538F)); + + /* split even part of tmp_e */ + + tmp0 = (tmp7 + tmp1); + tmp1 = fxp_mul32_Q32((tmp7 - tmp1), Qfmt_31(0.54119610014620F)); + + tmp3 = fxp_mul32_Q32((itmp_e1 - itmp_e2) << 1, Qfmt_31(0.65328148243819F)); + tmp7 = (itmp_e1 + itmp_e2); + + vec[ 0] = (tmp0 + tmp7) >> 1; + vec[ 8] = fxp_mul32_Q32((tmp0 - tmp7), Qfmt_31(0.70710678118655F)); + tmp0 = fxp_mul32_Q32((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F)); + vec[ 4] = tmp1 + tmp3 + tmp0; + vec[12] = tmp0; + + /* split odd part of tmp_e */ + + tmp1 = fxp_mul32_Q32((itmp_e0 - tmp4) << 1, Qfmt_31(0.54119610014620F)); + tmp7 = itmp_e0 + tmp4; + + tmp3 = fxp_mul32_Q32((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F)); + tmp6 += tmp5; + + tmp4 = fxp_mul32_Q32((tmp7 - tmp6) << 1, Qfmt_31(0.70710678118655F)); + tmp6 += tmp7; + tmp7 = fxp_mul32_Q32((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F)); + + tmp1 += tmp3 + tmp7; + vec[ 2] = tmp1 + tmp6; + vec[ 6] = tmp1 + tmp4; + vec[10] = tmp7 + tmp4; + vec[14] = tmp7; + + + // dct8; + + tmp1 = fxp_mul32_Q32((tmp_o0 - tmp_o7) << 1, Qfmt_31(0.50979557910416F)); + tmp7 = tmp_o0 + tmp_o7; + + tmp6 = tmp_o1 + tmp_o6; + tmp_o1 = fxp_mul32_Q32((tmp_o1 - tmp_o6) << 1, Qfmt_31(0.60134488693505F)); + + tmp5 = tmp_o2 + tmp_o5; + tmp_o5 = fxp_mul32_Q32((tmp_o2 - tmp_o5) << 1, Qfmt_31(0.89997622313642F)); + + tmp0 = fxp_mul32_Q32((tmp_o3 - tmp_o4) << 3, Qfmt_31(0.6407288619354F)); + tmp4 = tmp_o3 + tmp_o4; + + if (!flag) + { + tmp7 = -tmp7; + tmp1 = -tmp1; + tmp6 = -tmp6; + tmp_o1 = -tmp_o1; + tmp5 = -tmp5; + tmp_o5 = -tmp_o5; + tmp4 = -tmp4; + tmp0 = -tmp0; + } + + + tmp2 = fxp_mul32_Q32((tmp1 - tmp0) << 1, Qfmt_31(0.54119610014620F)); + tmp0 += tmp1; + tmp1 = fxp_mul32_Q32((tmp7 - tmp4) << 1, Qfmt_31(0.54119610014620F)); + tmp7 += tmp4; + tmp4 = fxp_mul32_Q32((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F)); + tmp6 += tmp5; + tmp5 = fxp_mul32_Q32((tmp_o1 - tmp_o5) << 2, Qfmt_31(0.65328148243819F)); + tmp_o1 += tmp_o5; + + + vec[13] = fxp_mul32_Q32((tmp1 - tmp4) << 1, Qfmt_31(0.70710678118655F)); + vec[ 5] = tmp1 + tmp4 + vec[13]; + + vec[ 9] = fxp_mul32_Q32((tmp7 - tmp6) << 1, Qfmt_31(0.70710678118655F)); + vec[ 1] = tmp7 + tmp6; + + tmp4 = fxp_mul32_Q32((tmp0 - tmp_o1) << 1, Qfmt_31(0.70710678118655F)); + tmp0 += tmp_o1; + tmp6 = fxp_mul32_Q32((tmp2 - tmp5) << 1, Qfmt_31(0.70710678118655F)); + tmp2 += tmp5 + tmp6; + tmp0 += tmp2; + + vec[ 1] += tmp0; + vec[ 3] = tmp0 + vec[ 5]; + tmp2 += tmp4; + vec[ 5] = tmp2 + vec[ 5]; + vec[ 7] = tmp2 + vec[ 9]; + tmp4 += tmp6; + vec[ 9] = tmp4 + vec[ 9]; + vec[11] = tmp4 + vec[13]; + vec[13] = tmp6 + vec[13]; + vec[15] = tmp6; + +} +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void pvmp3_merge_in_place_N32(int32 vec[]) +{ + + + int32 temp0; + int32 temp1; + int32 temp2; + int32 temp3; + + temp0 = vec[14]; + vec[14] = vec[ 7]; + temp1 = vec[12]; + vec[12] = vec[ 6]; + temp2 = vec[10]; + vec[10] = vec[ 5]; + temp3 = vec[ 8]; + vec[ 8] = vec[ 4]; + vec[ 6] = vec[ 3]; + vec[ 4] = vec[ 2]; + vec[ 2] = vec[ 1]; + + vec[ 1] = (vec[16] + vec[17]); + vec[16] = temp3; + vec[ 3] = (vec[18] + vec[17]); + vec[ 5] = (vec[19] + vec[18]); + vec[18] = vec[9]; + + vec[ 7] = (vec[20] + vec[19]); + vec[ 9] = (vec[21] + vec[20]); + vec[20] = temp2; + temp2 = vec[13]; + temp3 = vec[11]; + vec[11] = (vec[22] + vec[21]); + vec[13] = (vec[23] + vec[22]); + vec[22] = temp3; + temp3 = vec[15]; + + vec[15] = (vec[24] + vec[23]); + vec[17] = (vec[25] + vec[24]); + vec[19] = (vec[26] + vec[25]); + vec[21] = (vec[27] + vec[26]); + vec[23] = (vec[28] + vec[27]); + vec[24] = temp1; + vec[25] = (vec[29] + vec[28]); + vec[26] = temp2; + vec[27] = (vec[30] + vec[29]); + vec[28] = temp0; + vec[29] = (vec[30] + vec[31]); + vec[30] = temp3; +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void pvmp3_split(int32 *vect) +{ + + int32 i; + const int32 *pt_cosTerms = &CosTable_dct32[15]; + int32 *pt_vect = vect; + int32 *pt_vect_2 = pt_vect - 1; + + for (i = 3; i != 0; i--) + { + int32 tmp2 = *(pt_vect); + int32 tmp1 = *(pt_vect_2); + int32 cosx = *(pt_cosTerms--); + *(pt_vect_2--) = (tmp1 + tmp2); + *(pt_vect++) = fxp_mul32_Q27((tmp1 - tmp2), cosx); + + tmp2 = *(pt_vect); + tmp1 = *(pt_vect_2); + cosx = *(pt_cosTerms--); + *(pt_vect_2--) = (tmp1 + tmp2); + *(pt_vect++) = fxp_mul32_Q27((tmp1 - tmp2), cosx); + + } + + for (i = 5; i != 0; i--) + { + int32 tmp2 = *(pt_vect); + int32 tmp1 = *(pt_vect_2); + int32 cosx = *(pt_cosTerms--); + *(pt_vect_2--) = (tmp1 + tmp2); + *(pt_vect++) = fxp_mul32_Q32((tmp1 - tmp2) << 1, cosx); + + tmp2 = *(pt_vect); + tmp1 = *(pt_vect_2); + cosx = *(pt_cosTerms--); + *(pt_vect_2--) = (tmp1 + tmp2); + *(pt_vect++) = fxp_mul32_Q32((tmp1 - tmp2) << 1, cosx); + } + +} + +#endif diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.h new file mode 100644 index 0000000..e8bf76e --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_16.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dct_16.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_DCT_16_H +#define PVMP3_DCT_16_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_dct_16(int32 vec[], int32 flag); + + void pvmp3_merge_in_place_N32(int32 vec[]); + + void pvmp3_split(int32 *vect); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_6.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_6.cpp new file mode 100644 index 0000000..4c5fb03 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_6.cpp @@ -0,0 +1,152 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dct6.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + Int32 vec[] vector of 6 32-bit integers +Returns + Int32 vec[] dct computation in-place + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Returns the dct of length 6 of the input vector + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_mdct_6.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define Qfmt30(a) (Int32)(a*((Int32)1<<30) + (a>=0?0.5F:-0.5F)) + +#define cos_pi_6 Qfmt30( 0.86602540378444f) +#define cos_2_pi_6 Qfmt30( 0.5f) +#define cos_7_pi_12 Qfmt30( -0.25881904510252f) +#define cos_3_pi_12 Qfmt30( 0.70710678118655f) +#define cos_11_pi_12 Qfmt30( -0.96592582628907f) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_dct_6(int32 vec[]) +{ + + Int32 tmp0; + Int32 tmp1; + Int32 tmp2; + Int32 tmp3; + Int32 tmp4; + Int32 tmp5; + + + /* split input vector */ + + tmp0 = vec[5] + vec[0]; + tmp5 = vec[5] - vec[0]; + tmp1 = vec[4] + vec[1]; + tmp4 = vec[4] - vec[1]; + tmp2 = vec[3] + vec[2]; + tmp3 = vec[3] - vec[2]; + + vec[0] = tmp0 + tmp2 ; + vec[2] = fxp_mul32_Q30(tmp0 - tmp2, cos_pi_6); + vec[4] = (vec[0] >> 1) - tmp1; + vec[0] += tmp1; + + tmp0 = fxp_mul32_Q30(tmp3, cos_7_pi_12); + tmp0 = fxp_mac32_Q30(tmp4, -cos_3_pi_12, tmp0); + vec[1] = fxp_mac32_Q30(tmp5, cos_11_pi_12, tmp0); + + vec[3] = fxp_mul32_Q30((tmp3 + tmp4 - tmp5), cos_3_pi_12); + tmp0 = fxp_mul32_Q30(tmp3, cos_11_pi_12); + tmp0 = fxp_mac32_Q30(tmp4, cos_3_pi_12, tmp0); + vec[5] = fxp_mac32_Q30(tmp5, cos_7_pi_12, tmp0); + +} + + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_9.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_9.cpp new file mode 100644 index 0000000..ce3ec64 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dct_9.cpp @@ -0,0 +1,167 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dct_9.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + int32 vec[] vector of 9 32-bit integers +Returns + int32 vec[] dct computation in-place + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Returns the dct of length 9 of the input vector + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) ) +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_mdct_18.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define Qfmt31(a) (int32)(a*(0x7FFFFFFF)) + +#define cos_pi_9 Qfmt31( 0.93969262078591f) +#define cos_2pi_9 Qfmt31( 0.76604444311898f) +#define cos_4pi_9 Qfmt31( 0.17364817766693f) +#define cos_5pi_9 Qfmt31(-0.17364817766693f) +#define cos_7pi_9 Qfmt31(-0.76604444311898f) +#define cos_8pi_9 Qfmt31(-0.93969262078591f) +#define cos_pi_6 Qfmt31( 0.86602540378444f) +#define cos_5pi_6 Qfmt31(-0.86602540378444f) +#define cos_5pi_18 Qfmt31( 0.64278760968654f) +#define cos_7pi_18 Qfmt31( 0.34202014332567f) +#define cos_11pi_18 Qfmt31(-0.34202014332567f) +#define cos_13pi_18 Qfmt31(-0.64278760968654f) +#define cos_17pi_18 Qfmt31(-0.98480775301221f) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_dct_9(int32 vec[]) +{ + + /* split input vector */ + + int32 tmp0 = vec[8] + vec[0]; + int32 tmp8 = vec[8] - vec[0]; + int32 tmp1 = vec[7] + vec[1]; + int32 tmp7 = vec[7] - vec[1]; + int32 tmp2 = vec[6] + vec[2]; + int32 tmp6 = vec[6] - vec[2]; + int32 tmp3 = vec[5] + vec[3]; + int32 tmp5 = vec[5] - vec[3]; + + vec[0] = (tmp0 + tmp2 + tmp3) + (tmp1 + vec[4]); + vec[6] = ((tmp0 + tmp2 + tmp3) >> 1) - (tmp1 + vec[4]); + vec[2] = (tmp1 >> 1) - vec[4]; + vec[4] = -vec[2]; + vec[8] = -vec[2]; + vec[4] = fxp_mac32_Q32(vec[4], tmp0 << 1, cos_2pi_9); + vec[8] = fxp_mac32_Q32(vec[8], tmp0 << 1, cos_4pi_9); + vec[2] = fxp_mac32_Q32(vec[2], tmp0 << 1, cos_pi_9); + vec[2] = fxp_mac32_Q32(vec[2], tmp2 << 1, cos_5pi_9); + vec[4] = fxp_mac32_Q32(vec[4], tmp2 << 1, cos_8pi_9); + vec[8] = fxp_mac32_Q32(vec[8], tmp2 << 1, cos_2pi_9); + vec[8] = fxp_mac32_Q32(vec[8], tmp3 << 1, cos_8pi_9); + vec[4] = fxp_mac32_Q32(vec[4], tmp3 << 1, cos_4pi_9); + vec[2] = fxp_mac32_Q32(vec[2], tmp3 << 1, cos_7pi_9); + + vec[1] = fxp_mul32_Q32(tmp5 << 1, cos_11pi_18); + vec[1] = fxp_mac32_Q32(vec[1], tmp6 << 1, cos_13pi_18); + vec[1] = fxp_mac32_Q32(vec[1], tmp7 << 1, cos_5pi_6); + vec[1] = fxp_mac32_Q32(vec[1], tmp8 << 1, cos_17pi_18); + vec[3] = fxp_mul32_Q32((tmp5 + tmp6 - tmp8) << 1, cos_pi_6); + vec[5] = fxp_mul32_Q32(tmp5 << 1, cos_17pi_18); + vec[5] = fxp_mac32_Q32(vec[5], tmp6 << 1, cos_7pi_18); + vec[5] = fxp_mac32_Q32(vec[5], tmp7 << 1, cos_pi_6); + vec[5] = fxp_mac32_Q32(vec[5], tmp8 << 1, cos_13pi_18); + vec[7] = fxp_mul32_Q32(tmp5 << 1, cos_5pi_18); + vec[7] = fxp_mac32_Q32(vec[7], tmp6 << 1, cos_17pi_18); + vec[7] = fxp_mac32_Q32(vec[7], tmp7 << 1, cos_pi_6); + vec[7] = fxp_mac32_Q32(vec[7], tmp8 << 1, cos_11pi_18); + +} + + + +#endif // If not assembly diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dec_defs.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_dec_defs.h new file mode 100644 index 0000000..6cf8e3e --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dec_defs.h @@ -0,0 +1,199 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dec_defs.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file has the mp3 decoder common defines. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_DEC_DEFS_H +#define PVMP3_DEC_DEFS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" +#include "pvmp3decoder_api.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#define module(x, POW2) ((x)&(POW2-1)) + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define BUFSIZE 8192 // big enough to hold 4608 bytes == biggest mp3 frame + +#define CHAN 2 +#define GRAN 2 + + +#define SUBBANDS_NUMBER 32 +#define FILTERBANK_BANDS 18 +#define HAN_SIZE 512 + + +/* MPEG Header Definitions - ID Bit Values */ + +#define MPEG_1 0 +#define MPEG_2 1 +#define MPEG_2_5 2 +#define INVALID_VERSION -1 + +/* MPEG Header Definitions - Mode Values */ + +#define MPG_MD_STEREO 0 +#define MPG_MD_JOINT_STEREO 1 +#define MPG_MD_DUAL_CHANNEL 2 +#define MPG_MD_MONO 3 + + + +#define LEFT 0 +#define RIGHT 1 + + +#define SYNC_WORD (int32)0x7ff +#define SYNC_WORD_LNGTH 11 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /* Header Information Structure */ + + typedef struct + { + int32 version_x; + int32 layer_description; + int32 error_protection; + int32 bitrate_index; + int32 sampling_frequency; + int32 padding; + int32 extension; + int32 mode; + int32 mode_ext; + int32 copyright; + int32 original; + int32 emphasis; + } mp3Header; + + + /* Layer III side information. */ + + typedef struct + { + uint32 part2_3_length; + uint32 big_values; + int32 global_gain; + uint32 scalefac_compress; + uint32 window_switching_flag; + uint32 block_type; + uint32 mixed_block_flag; + uint32 table_select[3]; + uint32 subblock_gain[3]; + uint32 region0_count; + uint32 region1_count; + uint32 preflag; + uint32 scalefac_scale; + uint32 count1table_select; + + } granuleInfo; + + typedef struct + { + uint32 scfsi[4]; + granuleInfo gran[2]; + + } channelInfo; + + /* Layer III side info. */ + + typedef struct + { + uint32 main_data_begin; + uint32 private_bits; + channelInfo ch[2]; + + } mp3SideInfo; + + /* Layer III scale factors. */ + typedef struct + { + int32 l[23]; /* [cb] */ + int32 s[3][13]; /* [window][cb] */ + + } mp3ScaleFactors; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_header.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_header.cpp new file mode 100644 index 0000000..8b0250a --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_header.cpp @@ -0,0 +1,192 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decode_header.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + tbits *inputStream, bit stream + mp3Header *info, + uint32 *crc + Returns + + mp3Header *info, structure holding the parsed mp3 header info + uint32 *crc initialized crc computation + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + gets mp3 header information + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_decode_header.h" +#include "pvmp3_crc.h" +#include "pvmp3_getbits.h" +#include "pvmp3_seek_synch.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +ERROR_CODE pvmp3_decode_header(tmp3Bits *inputStream, + mp3Header *info, + uint32 *crc) +{ + + ERROR_CODE err = NO_DECODING_ERROR; + uint32 temp; + + /* + * Verify that at least the header is complete + */ + if (inputStream->inputBufferCurrentLength < (SYNC_WORD_LNGTH + 21)) + { + return NO_ENOUGH_MAIN_DATA_ERROR; + } + + /* + * MPEG Audio Version ID + */ + temp = getUpTo17bits(inputStream, SYNC_WORD_LNGTH); + if ((temp & SYNC_WORD) != SYNC_WORD) + { + err = pvmp3_header_sync(inputStream); + + if (err != NO_DECODING_ERROR) + { + return err; + } + } + + temp = getNbits(inputStream, 21); // to avoid multiple bitstream accesses + + + switch (temp >> 19) /* 2 */ + { + case 0: + info->version_x = MPEG_2_5; + break; + case 2: + info->version_x = MPEG_2; + break; + case 3: + info->version_x = MPEG_1; + break; + default: + info->version_x = INVALID_VERSION; + err = UNSUPPORTED_LAYER; + break; + } + + info->layer_description = 4 - ((temp << 13) >> 30); /* 2 */ + info->error_protection = !((temp << 15) >> 31); /* 1 */ + + if (info->error_protection) + { + *crc = 0xffff; /* CRC start value */ + calculate_crc((temp << 16) >> 16, 16, crc); + } + + info->bitrate_index = (temp << 16) >> 28; /* 4 */ + info->sampling_frequency = (temp << 20) >> 30; /* 2 */ + info->padding = (temp << 22) >> 31; /* 1 */ + info->extension = (temp << 23) >> 31; /* 1 */ + info->mode = (temp << 24) >> 30; /* 2 */ + info->mode_ext = (temp << 26) >> 30; /* 2 */ + info->copyright = (temp << 27) >> 31; /* 1 */ + info->original = (temp << 28) >> 31; /* 1 */ + info->emphasis = (temp << 30) >> 30; /* 2 */ + + + if (!info->bitrate_index || info->sampling_frequency == 3) + { + err = UNSUPPORTED_FREE_BITRATE; + } + + return(err); +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_header.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_header.h new file mode 100644 index 0000000..2c2e89e --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_header.h @@ -0,0 +1,101 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decode_header.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_DECODE_HEADER_H +#define PVMP3_DECODE_HEADER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "pvmp3_dec_defs.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + ERROR_CODE pvmp3_decode_header(tmp3Bits *inputStream, + mp3Header *info, + uint32 *crc); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_huff_cw.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_huff_cw.cpp new file mode 100644 index 0000000..6e45a18 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_huff_cw.cpp @@ -0,0 +1,758 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decode_huff_cw.cpp + + Funtions: + pvmp3_decode_huff_cw_tab0 + pvmp3_decode_huff_cw_tab1 + pvmp3_decode_huff_cw_tab2 + pvmp3_decode_huff_cw_tab3 + pvmp3_decode_huff_cw_tab5 + pvmp3_decode_huff_cw_tab6 + pvmp3_decode_huff_cw_tab7 + pvmp3_decode_huff_cw_tab8 + pvmp3_decode_huff_cw_tab9 + pvmp3_decode_huff_cw_tab10 + pvmp3_decode_huff_cw_tab11 + pvmp3_decode_huff_cw_tab12 + pvmp3_decode_huff_cw_tab13 + pvmp3_decode_huff_cw_tab15 + pvmp3_decode_huff_cw_tab16 + pvmp3_decode_huff_cw_tab24 + pvmp3_decode_huff_cw_tab32 + pvmp3_decode_huff_cw_tab33 + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + BITS *pMainData = pointer to input mp3 Main data bit stream + + + Outputs: + cw = bit field extracted from a leaf entry of packed mp3 Huffman Tables + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + These functions are used to decode huffman codewords from the input + bitstream using combined binary search and look-up table approach. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + + [2] Introduction to Algorithms, + Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest. + The MIT press, 1990 + + [3] "Selecting an Optimal Huffman Decoder for AAC", + Vladimir Z. Mesarovic, et al. + AES 111th Convention, September 21-24, 2001, New York, USA + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_tables.h" +#include "pvmp3_getbits.h" +#include "pvmp3_decode_huff_cw.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint16 pvmp3_decode_huff_cw_tab0(tmp3Bits *pMainData) +{ + OSCL_UNUSED_ARG(pMainData); + return(0); + +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab1(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 3); /* hufftable1 */ + + cw = *(huffTable_1 + tmp); + pMainData->usedBits -= (3 - (cw & 0xFF)); + return(cw >> 8); + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab2(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 6); /* huffTable_2,3 */ + + if (tmp >> 3) + { + tmp = (tmp >> 3) - 1; + } + else + { + tmp = tmp + 7; + } + + cw = *(huffTable_2 + tmp); + pMainData->usedBits -= (6 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab3(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 6); /* huffTable_2,3 */ + + if (tmp >> 3) + { + tmp = (tmp >> 3) - 1; + } + else + { + tmp = tmp + 7; + } + + cw = *(huffTable_3 + tmp); + pMainData->usedBits -= (6 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab5(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 8); /* huffTable_5 */ + + if ((tmp >> 5)) + { + tmp = (tmp >> 5) - 1; + } + else if ((tmp >> 1) >= 2) + { + tmp = (tmp >> 1) - 2 + 7; + } + else + { + tmp = (tmp & 3) + 21; + } + + cw = *(huffTable_5 + tmp); + pMainData->usedBits -= (8 - (cw & 0xFF)); + + return(cw >> 8); +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab6(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 7); /* huffTable_6 */ + if ((tmp >> 3) >= 3) + { + tmp = (tmp >> 3) - 3; + } + else if (tmp >> 1) + { + tmp = (tmp >> 1) - 1 + 13; + } + else + { + tmp = tmp + 24; + } + + cw = *(huffTable_6 + tmp); + pMainData->usedBits -= (7 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab7(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 10); /* huffTable_7 */ + if ((tmp >> 7) >= 2) + { + tmp = (tmp >> 7) - 2; + } + else if ((tmp >> 4) >= 7) + { + tmp = (tmp >> 4) - 7 + 6; + } + else if ((tmp >> 1) >= 2) + { + tmp = (tmp >> 1) - 2 + 15; + } + else + { + tmp = (tmp & 3) + 69; + } + + cw = *(huffTable_7 + tmp); + pMainData->usedBits -= (10 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab8(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 11); /* huffTable_8 */ + if ((tmp >> 7) >= 2) + { + tmp = (tmp >> 7) - 2; + } + else if ((tmp >> 5) >= 5) + { + tmp = (tmp >> 5) - 5 + 14; + } + else if ((tmp >> 2) >= 3) + { + tmp = (tmp >> 2) - 3 + 17; + } + else + { + tmp = (tmp) + 54; + } + + cw = *(huffTable_8 + tmp); + pMainData->usedBits -= (11 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab9(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo9bits(pMainData, 9); /* huffTable_9 */ + if ((tmp >> 5) >= 5) + { + tmp = (tmp >> 5) - 5; + } + else if ((tmp >> 3) >= 6) + { + tmp = (tmp >> 3) - 6 + 11; + } + else if ((tmp >> 1) >= 4) + { + tmp = (tmp >> 1) - 4 + 25; + } + else + { + tmp = tmp + 45; + } + + cw = *(huffTable_9 + tmp); + pMainData->usedBits -= (9 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab10(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 11); /* huffTable_10 */ + if (tmp >> 10) + { + tmp = (tmp >> 10) - 1; + } + else if ((tmp >> 7) >= 3) + { + tmp = (tmp >> 7) - 3 + 1; + } + else if ((tmp >> 5) >= 8) + { + tmp = (tmp >> 5) - 8 + 6; + } + else if ((tmp >> 3) >= 18) + { + tmp = (tmp >> 3) - 18 + 10; + } + else if ((tmp >> 2) >= 24) + { + tmp = (tmp >> 2) - 24 + 24; + } + else if ((tmp >> 1) >= 12) + { + tmp = (tmp >> 1) - 12 + 36; + } + else + { + tmp = (tmp) + 72; + } + + cw = *(huffTable_10 + tmp); + pMainData->usedBits -= (11 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab11(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 11); /* huffTable_11 */ + if ((tmp >> 8) >= 3) + { + tmp = (tmp >> 8) - 3; + } + else if ((tmp >> 6) >= 7) + { + tmp = (tmp >> 6) - 7 + 5; + } + else if ((tmp >> 3) >= 32) + { + tmp = (tmp >> 3) - 32 + 10; + } + else if ((tmp >> 2) >= 10) + { + tmp = (tmp >> 2) - 10 + 34; + } + else if ((tmp >> 1) >= 8) + { + tmp = (tmp >> 1) - 8 + 88; + } + else + { + tmp = (tmp & 0xFF) + 100; + } + cw = *(huffTable_11 + tmp); + pMainData->usedBits -= (11 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab12(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 10); /* huffTable_12 */ + if ((tmp >> 7) >= 5) + { + tmp = (tmp >> 7) - 5; + } + else if ((tmp >> 5) >= 12) + { + tmp = (tmp >> 5) - 12 + 3; + } + else if ((tmp >> 4) >= 17) + { + tmp = (tmp >> 4) - 17 + 11; + } + else if ((tmp >> 2) >= 32) + { + tmp = (tmp >> 2) - 32 + 18; + } + else if ((tmp >> 1) >= 16) + { + tmp = (tmp >> 1) - 16 + 54; + } + else + { + tmp = (tmp & 0x1F) + 102; + + } + cw = *(huffTable_12 + tmp); + pMainData->usedBits -= (10 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab13(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getNbits(pMainData, 19); /* huffTable_13 */ + if (tmp >> 18) + { + tmp = 0; + } + else if ((tmp >> 15) >= 4) + { + tmp = (tmp >> 15) - 4 + 1; + } + else if ((tmp >> 11) >= 32) + { + tmp = (tmp >> 11) - 32 + 5; + } + else if ((tmp >> 9) >= 64) + { + tmp = (tmp >> 9) - 64 + 37; + } + else if ((tmp >> 8) >= 64) + { + tmp = (tmp >> 8) - 64 + 101; + } + else if ((tmp >> 7) >= 64) + { + tmp = (tmp >> 7) - 64 + 165; + } + else if ((tmp >> 6) >= 32) + { + tmp = (tmp >> 6) - 32 + 229; + } + else if ((tmp >> 5) >= 32) + { + tmp = (tmp >> 5) - 32 + 325; + } + else if ((tmp >> 4) >= 32) + { + tmp = (tmp >> 4) - 32 + 357; + } + else if ((tmp >> 3) >= 32) + { + tmp = (tmp >> 3) - 32 + 389; + } + else if ((tmp >> 2) >= 2) + { + tmp = (tmp >> 2) - 2 + 421; + } + else + { + tmp = (tmp & 0x7) + 483; + } + + cw = *(huffTable_13 + tmp); + pMainData->usedBits -= (19 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab15(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 13); /* huffTable_15 */ + if ((tmp >> 9) >= 10) + { + tmp = (tmp >> 9) - 10; + } + else if ((tmp >> 6) >= 39) + { + tmp = (tmp >> 6) - 39 + 6; + } + else if ((tmp >> 4) >= 62) + { + tmp = (tmp >> 4) - 62 + 47; + } + else if ((tmp >> 3) >= 60) + { + tmp = (tmp >> 3) - 60 + 141; + } + else if ((tmp >> 2) >= 64) + { + tmp = (tmp >> 2) - 64 + 205; + } + else if ((tmp >> 1) >= 32) + { + tmp = (tmp >> 1) - 32 + 261; + } + else + { + tmp = (tmp & 0x3f) + 357; + } + + cw = *(huffTable_15 + tmp); + pMainData->usedBits -= (13 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab16(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 17); /* huffTable_16 */ + if (tmp >> 16) + { + tmp = 0; + } + else if ((tmp >> 13) >= 4) + { + tmp = (tmp >> 13) - 4 + 1; + } + else if ((tmp >> 9) >= 38) + { + tmp = (tmp >> 9) - 38 + 5; + } + else if ((tmp >> 7) >= 94) + { + tmp = (tmp >> 7) - 94 + 31; + } + else if ((tmp >> 5) >= 214) + { + tmp = (tmp >> 5) - 214 + 89; + } + else if ((tmp >> 3) >= 704) + { + if ((tmp >> 4) >= 384) + { + tmp = (tmp >> 4) - 384 + 315; + } + else + { + tmp = (tmp >> 3) - 704 + 251; + } + } + else if ((tmp >> 8) >= 14) + { + tmp = (tmp >> 8) - 14 + 359; + } + else if ((tmp) >= 3456) + { + if ((tmp >> 2) >= 868) + { + tmp = (tmp >> 2) - 868 + 383; + } + else + { + tmp = (tmp) - 3456 + 367; + } + } + else + { + tmp = ((tmp >> 6) & 0x3f) + 411; + } + + cw = *(huffTable_16 + tmp); + pMainData->usedBits -= (17 - (cw & 0xFF)); + + return(cw >> 8); +} + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab24(tmp3Bits *pMainData) +{ + uint32 tmp; + uint16 cw; + + tmp = getUpTo17bits(pMainData, 12); /* huffTable_24 */ + if ((tmp >> 6) >= 41) + { + tmp = (tmp >> 6) - 41; + } + else if ((tmp >> 3) >= 218) + { + tmp = (tmp >> 3) - 218 + 23; + } + else if ((tmp >> 2) >= 336) + { + tmp = (tmp >> 2) - 336 + 133; + } + else if ((tmp >> 1) >= 520) + { + tmp = (tmp >> 1) - 520 + 233; + } + else if ((tmp) >= 1024) + { + tmp = (tmp) - 1024 + 385; + } + else if ((tmp >> 1) >= 352) + { + if ((tmp >> 8) == 3) + { + tmp = (tmp >> 8) - 3 + 433; + } + else + { + tmp = (tmp >> 1) - 352 + 401; + } + } + else + { + tmp = ((tmp >> 4) & 0x3f) + 434; + } + + cw = *(huffTable_24 + tmp); + pMainData->usedBits -= (12 - (cw & 0xFF)); + + return(cw >> 8); +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +uint16 pvmp3_decode_huff_cw_tab32(tmp3Bits *pMainData) +{ + uint32 tmp = getUpTo9bits(pMainData, 6); /* huffTable_32 */ + if ((tmp >> 5)) + { + pMainData->usedBits -= 5; + return(0); + } + else + { + uint16 cw = *(huffTable_32 + (tmp & 0x1f)); + pMainData->usedBits -= (6 - (cw & 0xFF)); + + return(cw >> 8); + } + +} + + +uint16 pvmp3_decode_huff_cw_tab33(tmp3Bits *pMainData) +{ + + uint16 tmp = getUpTo9bits(pMainData, 4); /* huffTable_33 */ + + return((0x0f - tmp)); +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_huff_cw.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_huff_cw.h new file mode 100644 index 0000000..941ca6d --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_decode_huff_cw.h @@ -0,0 +1,114 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decode_huff_cw.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_DECODE_HUFF_CW_H +#define PVMP3_DECODE_HUFF_CW_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "pvmp3_dec_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + uint16 pvmp3_decode_huff_cw_tab0(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab1(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab2(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab3(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab5(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab6(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab7(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab8(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab9(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab10(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab11(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab12(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab13(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab15(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab16(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab24(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab32(tmp3Bits *); + uint16 pvmp3_decode_huff_cw_tab33(tmp3Bits *); +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp new file mode 100644 index 0000000..69e1987 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp @@ -0,0 +1,452 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dequantize_sample.cpp + + Functions: + power_1_third + pvmp3_dequantize_sample + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +power_1_third +int32 power_1_third( int32 xx) + +Input + int32 xx, int32 in the [0, 8192] range + + Returns + + int32 xx^(1/3) int32 Q26 number representing + the 1/3 power of the input + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +pvmp3_dequantize_sample + +Input + int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, scale factor structure + struct gr_info_s *gr_info, granule structure informatiom + mp3Header *info mp3 header info + + Returns + + int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], dequantize output as (.)^(4/3) + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + dequantize sample + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_dequantize_sample.h" +#include "pvmp3_normalize.h" +#include "mp3_mem_funcs.h" +#include "pvmp3_tables.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define Q30_fmt(a)(int32(double(0x40000000)*a)) +#define Q29_fmt(a)(int32(double(0x20000000)*a)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 pretab[22] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0}; + +const int32 pow_2_1_fourth[4] = +{ + Q30_fmt(1.0), Q30_fmt(1.18920711500272), + Q30_fmt(1.41421356237310), Q30_fmt(1.68179283050743) +}; + +const int32 two_cubic_roots[7] = +{ + Q29_fmt(0), Q29_fmt(1.25992104989487), + Q29_fmt(1.58740105196820), Q29_fmt(2.00000000000000), + Q29_fmt(2.51984209978975), Q29_fmt(3.17480210393640), + Q29_fmt(3.99999999999999) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +int32 power_1_third(int32 xx) +{ + + if (xx <= 512) + { + return (power_one_third[xx] >> 1); + } + else + { + if (xx >> 15) + { + return 0x7FFFFFFF; /* saturate any value over 32767 */ + } + else + { + int32 x = xx; + int32 m = 22 - pvmp3_normalize(xx); + + xx >>= m; + xx = (power_one_third[xx]) + (((power_one_third[xx+1] - power_one_third[xx]) >> m) * (x & ((1 << m) - 1))); + return (fxp_mul32_Q30(xx, two_cubic_roots[m])); + } + + } +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void pvmp3_dequantize_sample(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, + granuleInfo *gr_info, + int32 used_freq_lines, + mp3Header *info) +{ + int32 ss; + int32 cb = 0; + int32 global_gain; + int32 sfreq = info->sampling_frequency + info->version_x + (info->version_x << 1); + + /* apply formula per block type */ + + if (gr_info->window_switching_flag && (gr_info->block_type == 2)) + { + int32 next_cb_boundary; + int32 cb_begin = 0; + int32 cb_width = 0; + int32 mixstart = 8; /* added 2003/08/21 efs */ + + if (info->version_x != MPEG_1) + { + mixstart = 6; /* different value in MPEG2 LSF */ + } + + if (gr_info->mixed_block_flag) + { + next_cb_boundary = mp3_sfBandIndex[sfreq].l[1]; /* LONG blocks: 0,1,3 */ + } + else + { + next_cb_boundary = mp3_sfBandIndex[sfreq].s[1] * 3; /* pure SHORT block */ + cb_width = 0; + } + + global_gain = gr_info->global_gain; + int32 two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3]; + global_gain = 12 + (global_gain >> 2); + + for (ss = 0 ; ss < used_freq_lines ; ss++) + { + if (ss == next_cb_boundary) + { + cb++; /* critical band counter */ + if (gr_info->mixed_block_flag) + { + if (next_cb_boundary == mp3_sfBandIndex[sfreq].l[mixstart]) + { + next_cb_boundary = mp3_sfBandIndex[sfreq].s[4] * 3; + + cb_begin = mp3_sfBandIndex[sfreq].s[3] * 3; + cb_width = 3; + cb = 3; + } + else if (ss < mp3_sfBandIndex[sfreq].l[mixstart]) + { + next_cb_boundary = mp3_sfBandIndex[sfreq].l[cb+1]; + } + else + { + next_cb_boundary = mp3_sfBandIndex[sfreq].s[cb+1] * 3; + + cb_width = cb; + cb_begin = mp3_sfBandIndex[sfreq].s[cb] * 3; + } + + if (ss < 2*FILTERBANK_BANDS) + { /* 1st 2 subbands of switched blocks */ + global_gain = (gr_info->global_gain); + global_gain -= (1 + gr_info->scalefac_scale) * + (scalefac->l[cb] + gr_info->preflag * pretab[cb]) << 1; + + two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3]; + global_gain = 12 + (global_gain >> 2); + } + } + else + { + next_cb_boundary = mp3_sfBandIndex[sfreq].s[cb+1] * 3; + cb_width = cb; + cb_begin = mp3_sfBandIndex[sfreq].s[cb] * 3; + } + + } /* end-if ( ss == next_cb_boundary) */ + + /* Do long/short dependent scaling operations. */ + if ((gr_info->mixed_block_flag == 0) || (gr_info->mixed_block_flag && (ss >= 2*FILTERBANK_BANDS))) + { + int32 temp2 = fxp_mul32_Q32((ss - cb_begin) << 16, mp3_shortwindBandWidths[sfreq][cb_width]); + temp2 = (temp2 + 1) >> 15; + + global_gain = (gr_info->global_gain); + global_gain -= gr_info->subblock_gain[temp2] << 3; + global_gain -= (1 + gr_info->scalefac_scale) * (scalefac->s[temp2][cb] << 1); + + two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3]; + global_gain = 12 + (global_gain >> 2); + + } + + + /* + * xr[sb][ss] = 2^(global_gain/4) + */ + + /* Scale quantized value. */ + + /* 0 < abs(is[ss]) < 8192 */ + + int32 tmp = fxp_mul32_Q30((is[ss] << 16), power_1_third(pv_abs(is[ ss]))); + + tmp = fxp_mul32_Q30(tmp, two_raise_one_fourth); + + if (global_gain < 0) + { + int32 temp = - global_gain; + if (temp < 32) + { + is[ss] = (tmp >> temp); + } + else + { + is[ss] = 0; + } + } + else + { + is[ss] = (tmp << global_gain); + } + + } /* for (ss=0 ; ss < used_freq_lines ; ss++) */ + + } + else + { + + for (cb = 0 ; cb < 22 ; cb++) + { + + /* Compute overall (global) scaling. */ + + global_gain = (gr_info->global_gain); + + global_gain -= (1 + gr_info->scalefac_scale) * + (scalefac->l[cb] + gr_info->preflag * pretab[cb]) << 1; + + + int32 two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3]; + global_gain = 12 + (global_gain >> 2); + + /* + * xr[sb][ss] = 2^(global_gain/4) + */ + + /* Scale quantized value. */ + + if (used_freq_lines >= mp3_sfBandIndex[sfreq].l[cb+1]) + { + if (global_gain <= 0) + { + global_gain = - global_gain; + if (global_gain < 32) + { + for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < mp3_sfBandIndex[sfreq].l[cb+1]; ss += 2) + { + int32 tmp = is[ss]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain; + } + tmp = is[ss+1]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss+1] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain; + } + } + } + else + { + pv_memset(&is[ mp3_sfBandIndex[sfreq].l[cb]], + 0, + (mp3_sfBandIndex[sfreq].l[cb+1] - mp3_sfBandIndex[sfreq].l[cb])*sizeof(*is)); + } + } + else + { + for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < mp3_sfBandIndex[sfreq].l[cb+1]; ss += 2) + { + int32 tmp = is[ss]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) << global_gain; + } + + tmp = is[ss+1]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss+1] = fxp_mul32_Q30(tmp, two_raise_one_fourth) << global_gain; + } + } + } + } + else + { + if (global_gain <= 0) + { + global_gain = - global_gain; + if (global_gain < 32) + { + for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < used_freq_lines; ss += 2) + { + int32 tmp = is[ss]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain; + } + tmp = is[ss+1]; + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss+1] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain; + } + } + + } + else + { + pv_memset(&is[ mp3_sfBandIndex[sfreq].l[cb]], + 0, + (mp3_sfBandIndex[sfreq].l[cb+1] - mp3_sfBandIndex[sfreq].l[cb])*sizeof(*is)); + } + } + else + { + for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < used_freq_lines; ss++) + { + int32 tmp = is[ss]; + + if (tmp) + { + tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp))); + is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) << global_gain; + } + } + } + + cb = 22; // force breaking out of the loop + + } /* if ( used_freq_lines >= mp3_sfBandIndex[sfreq].l[cb+1]) */ + + } /* for (cb=0 ; cb < 22 ; cb++) */ + + } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */ + + + pv_memset(&is[used_freq_lines], + 0, + (FILTERBANK_BANDS*SUBBANDS_NUMBER - used_freq_lines)*sizeof(*is)); + +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.h new file mode 100644 index 0000000..9393eb1 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_dequantize_sample.h @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_dequantize_sample.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_DEQUANTIZE_SAMPLE_H +#define PVMP3_DEQUANTIZE_SAMPLE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + int32 power_1_third(int32 xx); + + void pvmp3_dequantize_sample(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, + granuleInfo *gr_info, + int32 num_lines, + mp3Header *info); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.cpp new file mode 100644 index 0000000..f4a4efb --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.cpp @@ -0,0 +1,415 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_equalizer.cpp + + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Input + int32 *inData, pointer to the spectrum frequency-line + e_equalization equalizerType, equalization mode + int32 *pt_work_buff + + Output + int32 *pt_work_buff pointer to the equalized frequency-line + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Equalizer + Each subband sample is scaled according to a spectrum shape setting + defined by "equalizerType" + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_equalizer.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define LEVEL__0__dB 0.999999970f +#define LEVEL__1_5dB 0.841395142f +#define LEVEL__3__dB 0.707106781f +#define LEVEL__4_5dB 0.595662143f +#define LEVEL__6__dB 0.500000000f +#define LEVEL__7_5dB 0.421696503f +#define LEVEL__9__dB 0.353553393f +#define LEVEL_12__dB 0.250000000f +#define LEVEL_15__dB 0.176776695f +#define LEVEL_18__dB 0.125000000f +#define LEVEL_21__dB 0.088388347f +#define LEVEL_30__dB 0.031250000f +#define LEVEL_45__dB 0.005524271f +#define LEVEL_60__dB 0.000976562f + +#define Qmf31( x) (int32)(x*(float)0x7FFFFFFF) + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const int32 equalizerTbl[8][SUBBANDS_NUMBER] = +{ + /* FLAT */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB) + }, + /* BASS BOOST */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__1_5dB), Qmf31(LEVEL__3__dB), + + Qmf31(LEVEL__4_5dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB) + }, + /* ROCK */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__1_5dB), Qmf31(LEVEL__3__dB), + + Qmf31(LEVEL__4_5dB), Qmf31(LEVEL__6__dB), + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__1_5dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB) + }, + /* POP */ + { + Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + + Qmf31(LEVEL__1_5dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB) + }, + /* JAZZ */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__1_5dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB) + }, + /* CLASSICAL */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__1_5dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB) + }, + /* TALK */ + { + Qmf31(LEVEL__9__dB), + + Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__1_5dB), + + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB), + Qmf31(LEVEL__3__dB) + }, + /* FLAT */ + { + Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB), + Qmf31(LEVEL__0__dB) + } +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_equalizer(int32 *circ_buffer, + e_equalization equalizerType, + int32 *work_buff) +{ + + if (equalizerType == flat) + { + for (int32 band = 0; band < FILTERBANK_BANDS; band += 2) + { + + int32 *pt_work_buff = &work_buff[band]; + int32 *inData = &circ_buffer[544 - (band<<5)]; + + int32 i; + for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2) + { + int32 temp1 = (pt_work_buff[ i ]); + int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]); + int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]); + int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]); + *(inData++) = temp1; + *(inData++) = temp2; + *(inData++) = temp3; + *(inData++) = temp4; + } + + inData -= SUBBANDS_NUMBER << 1; + pt_work_buff++; + + for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2) + { + int32 temp1 = (pt_work_buff[ i ]); + int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]); + int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]); + int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]); + *(inData++) = temp1; + *(inData++) = temp2; + *(inData++) = temp3; + *(inData++) = temp4; + } + } + } + else + { + const int32 *pt_equalizer = equalizerTbl[equalizerType&7]; + + + for (int32 band = 0; band < FILTERBANK_BANDS; band += 3) + { + int32 *inData = &circ_buffer[544 - (band<<5)]; + + int32 *pt_work_buff = &work_buff[band]; + int32 i; + + for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2) + { + int32 temp1 = (pt_work_buff[ i ]); + int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]); + int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]); + int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]); + *(inData++) = fxp_mul32_Q32(temp1 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp2 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp3 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp4 << 1, *(pt_equalizer++)); + } + + pt_equalizer -= SUBBANDS_NUMBER; + + inData -= SUBBANDS_NUMBER << 1; + pt_work_buff++; + + for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2) + { + int32 temp1 = (pt_work_buff[ i ]); + int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]); + int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]); + int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]); + *(inData++) = fxp_mul32_Q32(temp1 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp2 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp3 << 1, *(pt_equalizer++)); + *(inData++) = fxp_mul32_Q32(temp4 << 1, *(pt_equalizer++)); + } + pt_equalizer -= SUBBANDS_NUMBER; + + } + } +} + + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.h new file mode 100644 index 0000000..bbf134f --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_equalizer.h @@ -0,0 +1,101 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_equalizer.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_EQUALIZER_H +#define PVMP3_EQUALIZER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "pvmp3decoder_api.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_equalizer(int32 *inData, + e_equalization equalizerType, + int32 *pt_work_buff); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_framedecoder.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_framedecoder.cpp new file mode 100644 index 0000000..26bc25c --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_framedecoder.cpp @@ -0,0 +1,834 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_framedecoder.cpp + + Functions: + pvmp3_framedecoder + pvmp3_InitDecoder + pvmp3_resetDecoder + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + pExt = pointer to the external interface structure. See the file + pvmp3decoder_api.h for a description of each field. + Data type of pointer to a tPVMP3DecoderExternal + structure. + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tmp3dec_file structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tmp3dec_file + structure. + + + Outputs: + status = ERROR condition. see structure ERROR_CODE + + Pointers and Buffers Modified: + pMem contents are modified. + pExt: (more detail in the file pvmp3decoder_api.h) + inputBufferUsedLength - number of array elements used up by the stream. + samplingRate - sampling rate in samples per sec + bitRate - bit rate in bits per second, varies frame to frame. + + + +------------------------------------------------------------------------------ + FUNCTIONS DESCRIPTION + + pvmp3_framedecoder + frame decoder library driver + pvmp3_InitDecoder + Decoder Initialization + pvmp3_resetDecoder + Reset Decoder + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + + +#include "pvmp3_framedecoder.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_poly_phase_synthesis.h" +#include "pvmp3_tables.h" +#include "pvmp3_imdct_synth.h" +#include "pvmp3_alias_reduction.h" +#include "pvmp3_reorder.h" +#include "pvmp3_dequantize_sample.h" +#include "pvmp3_stereo_proc.h" +#include "pvmp3_mpeg2_stereo_proc.h" +#include "pvmp3_get_side_info.h" +#include "pvmp3_get_scale_factors.h" +#include "pvmp3_mpeg2_get_scale_factors.h" +#include "pvmp3_decode_header.h" +#include "pvmp3_get_main_data_size.h" +#include "s_tmp3dec_file.h" +#include "pvmp3_getbits.h" +#include "mp3_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +ERROR_CODE pvmp3_framedecoder(tPVMP3DecoderExternal *pExt, + void *pMem) +{ + + ERROR_CODE errorCode = NO_DECODING_ERROR; + + int32 crc_error_count = 0; + uint32 sent_crc = 0; + uint32 computed_crc = 0; + + tmp3dec_chan *pChVars[CHAN]; + tmp3dec_file *pVars = (tmp3dec_file *)pMem; + + mp3Header info_data; + mp3Header *info = &info_data; + + pVars->inputStream.pBuffer = pExt->pInputBuffer; + + + pVars->inputStream.usedBits = pExt->inputBufferUsedLength << 3; + pVars->inputStream.inputBufferCurrentLength = pExt->inputBufferCurrentLength; + + + errorCode = pvmp3_decode_header(&pVars->inputStream, + info, + &computed_crc); + + if (errorCode != NO_DECODING_ERROR) + { + pExt->outputFrameSize = 0; + return errorCode; + } + + pVars->num_channels = (info->mode == MPG_MD_MONO) ? 1 : 2; + pExt->num_channels = pVars->num_channels; + + int32 outputFrameSize = (info->version_x == MPEG_1) ? + 2 * SUBBANDS_NUMBER * FILTERBANK_BANDS : + SUBBANDS_NUMBER * FILTERBANK_BANDS; + + outputFrameSize = (info->mode == MPG_MD_MONO) ? outputFrameSize : outputFrameSize << 1; + + + /* + * Check if output buffer has enough room to hold output PCM + */ + if (pExt->outputFrameSize >= outputFrameSize) + { + pExt->outputFrameSize = outputFrameSize; + } + else + { + pExt->outputFrameSize = 0; + return OUTPUT_BUFFER_TOO_SMALL; + } + + + pChVars[ LEFT] = &pVars->perChan[ LEFT]; + pChVars[RIGHT] = &pVars->perChan[RIGHT]; + + + + + if (info->error_protection) + { + /* + * Get crc content + */ + sent_crc = getUpTo17bits(&pVars->inputStream, 16); + } + + + if (info->layer_description == 3) + { + int32 gr; + int32 ch; + uint32 main_data_end; + int32 bytes_to_discard; + int16 *ptrOutBuffer = pExt->pOutputBuffer; + + /* + * Side Information must be extracted from the bitstream and store for use + * during the decoded of the associated frame + */ + + errorCode = pvmp3_get_side_info(&pVars->inputStream, + &pVars->sideInfo, + info, + &computed_crc); + + if (errorCode != NO_DECODING_ERROR) + { + pExt->outputFrameSize = 0; + return errorCode; + } + + /* + * If CRC was sent, check that matches the one got while parsing data + * disable crc if this is the desired mode + */ + if (info->error_protection) + { + if ((computed_crc != sent_crc) && pExt->crcEnabled) + { + crc_error_count++; + } + } + + /* + * main data (scalefactors, Huffman coded, etc,) are not necessarily located + * adjacent to the side-info. Beginning of main data is located using + * field "main_data_begin" of the current frame. The length does not include + * header and side info. + * "main_data_begin" points to the first bit of main data of a frame. It is a negative + * offset in bytes from the first byte of the sync word + * main_data_begin = 0 <===> main data start rigth after side info. + */ + + int32 temp = pvmp3_get_main_data_size(info, pVars); + + + /* + * Check if available data holds a full frame, if not flag an error + */ + + if ((uint32)pVars->predicted_frame_size > pVars->inputStream.inputBufferCurrentLength) + { + pExt->outputFrameSize = 0; + return NO_ENOUGH_MAIN_DATA_ERROR; + } + + /* + * Fill in internal circular buffer + */ + fillMainDataBuf(pVars, temp); + + + main_data_end = pVars->mainDataStream.usedBits >> 3; /* in bytes */ + if ((main_data_end << 3) < pVars->mainDataStream.usedBits) + { + main_data_end++; + pVars->mainDataStream.usedBits = main_data_end << 3; + } + + + bytes_to_discard = pVars->frame_start - pVars->sideInfo.main_data_begin - main_data_end; + + + if (main_data_end > BUFSIZE) /* check overflow on the buffer */ + { + pVars->frame_start -= BUFSIZE; + + pVars->mainDataStream.usedBits -= (BUFSIZE << 3); + } + + pVars->frame_start += temp; + + + if (bytes_to_discard < 0 || crc_error_count) + { + /* + * Not enough data to decode, then we should avoid reading this + * data ( getting/ignoring sido info and scale data) + * Main data could be located in the previous frame, so an unaccounted + * frame can cause incorrect processing + * Just run the polyphase filter to "clean" the history buffer + */ + errorCode = NO_ENOUGH_MAIN_DATA_ERROR; + + /* + * Clear the input to these filters + */ + + pv_memset((void*)pChVars[RIGHT]->work_buf_int32, + 0, + SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[RIGHT]->work_buf_int32[0])); + + pv_memset((void*)pChVars[LEFT]->work_buf_int32, + 0, + SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[LEFT]->work_buf_int32[0])); + + /* clear circular buffers, to avoid any glitch */ + pv_memset((void*)&pChVars[ LEFT]->circ_buffer[576], + 0, + 480*sizeof(pChVars[ LEFT]->circ_buffer[0])); + pv_memset((void*)&pChVars[RIGHT]->circ_buffer[576], + 0, + 480*sizeof(pChVars[RIGHT]->circ_buffer[0])); + + pChVars[ LEFT]->used_freq_lines = 575; + pChVars[RIGHT]->used_freq_lines = 575; + + } + else + { + pVars->mainDataStream.usedBits += (bytes_to_discard << 3); + } + + /* + * if (fr_ps->header->version_x == MPEG_1), use 2 granules, otherwise just 1 + */ + for (gr = 0; gr < (1 + !(info->version_x)); gr++) + { + if (errorCode != NO_ENOUGH_MAIN_DATA_ERROR) + { + for (ch = 0; ch < pVars->num_channels; ch++) + { + int32 part2_start = pVars->mainDataStream.usedBits; + + if (info->version_x == MPEG_1) + { + + pvmp3_get_scale_factors(&pVars->scaleFactors[ch], + &pVars->sideInfo, + gr, + ch, + &pVars->mainDataStream); + } + else + { + int32 * tmp = pVars->Scratch_mem; + pvmp3_mpeg2_get_scale_factors(&pVars->scaleFactors[ch], + &pVars->sideInfo, + gr, + ch, + info, + (uint32 *)tmp, + &pVars->mainDataStream); + } + + pChVars[ch]->used_freq_lines = pvmp3_huffman_parsing(pChVars[ch]->work_buf_int32, + &pVars->sideInfo.ch[ch].gran[gr], + pVars, + part2_start, + info); + + + pvmp3_dequantize_sample(pChVars[ch]->work_buf_int32, + &pVars->scaleFactors[ch], + &pVars->sideInfo.ch[ch].gran[gr], + pChVars[ch]->used_freq_lines, + info); + + + + + } /* for (ch=0; chnum_channels == 2) + { + + int32 used_freq_lines = (pChVars[ LEFT]->used_freq_lines > + pChVars[RIGHT]->used_freq_lines) ? + pChVars[ LEFT]->used_freq_lines : + pChVars[RIGHT]->used_freq_lines; + + pChVars[ LEFT]->used_freq_lines = used_freq_lines; + pChVars[RIGHT]->used_freq_lines = used_freq_lines; + + if (info->version_x == MPEG_1) + { + pvmp3_stereo_proc(pChVars[ LEFT]->work_buf_int32, + pChVars[RIGHT]->work_buf_int32, + &pVars->scaleFactors[RIGHT], + &pVars->sideInfo.ch[LEFT].gran[gr], + used_freq_lines, + info); + } + else + { + int32 * tmp = pVars->Scratch_mem; + pvmp3_mpeg2_stereo_proc(pChVars[ LEFT]->work_buf_int32, + pChVars[RIGHT]->work_buf_int32, + &pVars->scaleFactors[RIGHT], + &pVars->sideInfo.ch[ LEFT].gran[gr], + &pVars->sideInfo.ch[RIGHT].gran[gr], + (uint32 *)tmp, + used_freq_lines, + info); + } + } + + } /* if ( errorCode != NO_ENOUGH_MAIN_DATA_ERROR) */ + + for (ch = 0; ch < pVars->num_channels; ch++) + { + + pvmp3_reorder(pChVars[ch]->work_buf_int32, + &pVars->sideInfo.ch[ch].gran[gr], + &pChVars[ ch]->used_freq_lines, + info, + pVars->Scratch_mem); + + pvmp3_alias_reduction(pChVars[ch]->work_buf_int32, + &pVars->sideInfo.ch[ch].gran[gr], + &pChVars[ ch]->used_freq_lines, + info); + + + /* + * IMDCT + */ + /* set mxposition + * In case of mixed blocks, # of bands with long + * blocks (2 or 4) else 0 + */ + uint16 mixedBlocksLongBlocks = 0; /* 0 = long or short, 2=mixed, 4=mixed 2.5@8000 */ + if (pVars->sideInfo.ch[ch].gran[gr].mixed_block_flag && + pVars->sideInfo.ch[ch].gran[gr].window_switching_flag) + { + if ((info->version_x == MPEG_2_5) && (info->sampling_frequency == 2)) + { + mixedBlocksLongBlocks = 4; /* mpeg2.5 @ 8 KHz */ + } + else + { + mixedBlocksLongBlocks = 2; + } + } + + pvmp3_imdct_synth(pChVars[ch]->work_buf_int32, + pChVars[ch]->overlap, + pVars->sideInfo.ch[ch].gran[gr].block_type, + mixedBlocksLongBlocks, + pChVars[ ch]->used_freq_lines, + pVars->Scratch_mem); + + + /* + * Polyphase synthesis + */ + + pvmp3_poly_phase_synthesis(pChVars[ch], + pVars->num_channels, + pExt->equalizerType, + &ptrOutBuffer[ch]); + + + }/* end ch loop */ + + ptrOutBuffer += pVars->num_channels * SUBBANDS_NUMBER * FILTERBANK_BANDS; + } /* for (gr=0;grbitrate_index > 0) + { /* if not free-format */ + + int32 ancillary_data_lenght = pVars->predicted_frame_size << 3; + + ancillary_data_lenght -= pVars->inputStream.usedBits; + + /* skip ancillary data */ + if (ancillary_data_lenght > 0) + { + pVars->inputStream.usedBits += ancillary_data_lenght; + } + + } + + /* + * This overrides a possible NO_ENOUGH_MAIN_DATA_ERROR + */ + errorCode = NO_DECODING_ERROR; + + } + else + { + /* + * The info on the header leads to an unsupported layer, more data + * will not fix this, so this is a bad frame, + */ + + pExt->outputFrameSize = 0; + return UNSUPPORTED_LAYER; + } + + pExt->inputBufferUsedLength = pVars->inputStream.usedBits >> 3; + pExt->totalNumberOfBitsUsed += pVars->inputStream.usedBits; + pExt->version = info->version_x; + pExt->samplingRate = mp3_s_freq[info->version_x][info->sampling_frequency]; + pExt->bitRate = mp3_bitrate[pExt->version][info->bitrate_index]; + + + /* + * Always verify buffer overrun condition + */ + + if (pExt->inputBufferUsedLength > pExt->inputBufferCurrentLength) + { + pExt->outputFrameSize = 0; + errorCode = NO_ENOUGH_MAIN_DATA_ERROR; + } + + return errorCode; + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +__inline void fillDataBuf(tmp3Bits *pMainData, + uint32 val) /* val to write into the buffer */ +{ + pMainData->pBuffer[module(pMainData->offset++, BUFSIZE)] = (uint8)val; +} + + +void fillMainDataBuf(void *pMem, int32 temp) +{ + tmp3dec_file *pVars = (tmp3dec_file *)pMem; + + + int32 offset = (pVars->inputStream.usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + /* + * Check if input circular buffer boundaries need to be enforced + */ + if ((offset + temp) < BUFSIZE) + { + uint8 * ptr = pVars->inputStream.pBuffer + offset; + + offset = pVars->mainDataStream.offset; + + /* + * Check if main data circular buffer boundaries need to be enforced + */ + if ((offset + temp) < BUFSIZE) + { + pv_memcpy((pVars->mainDataStream.pBuffer + offset), ptr, temp*sizeof(uint8)); + pVars->mainDataStream.offset += temp; + } + else + { + int32 tmp1 = *(ptr++); + for (int32 nBytes = temp >> 1; nBytes != 0; nBytes--) /* read main data. */ + { + int32 tmp2 = *(ptr++); + fillDataBuf(&pVars->mainDataStream, tmp1); + fillDataBuf(&pVars->mainDataStream, tmp2); + tmp1 = *(ptr++); + } + + if (temp&1) + { + fillDataBuf(&pVars->mainDataStream, tmp1); + } + + /* adjust circular buffer counter */ + pVars->mainDataStream.offset = module(pVars->mainDataStream.offset, BUFSIZE); + } + } + else + { + for (int32 nBytes = temp >> 1; nBytes != 0; nBytes--) /* read main data. */ + { + fillDataBuf(&pVars->mainDataStream, *(pVars->inputStream.pBuffer + module(offset++ , BUFSIZE))); + fillDataBuf(&pVars->mainDataStream, *(pVars->inputStream.pBuffer + module(offset++ , BUFSIZE))); + } + if (temp&1) + { + fillDataBuf(&pVars->mainDataStream, *(pVars->inputStream.pBuffer + module(offset , BUFSIZE))); + } + } + + + pVars->inputStream.usedBits += (temp) << INBUF_ARRAY_INDEX_SHIFT; +} + + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint32 pvmp3_decoderMemRequirements(void) +{ + uint32 size; + + size = (uint32) sizeof(tmp3dec_file); + return (size); +} + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +#include "pvmp3_decode_huff_cw.h" + +void pvmp3_InitDecoder(tPVMP3DecoderExternal *pExt, + void *pMem) +{ + + tmp3dec_file *pVars; + huffcodetab *pHuff; + + pVars = (tmp3dec_file *)pMem; + + pVars->num_channels = 0; + + pExt->totalNumberOfBitsUsed = 0; + pExt->inputBufferCurrentLength = 0; + pExt->inputBufferUsedLength = 0; + + pVars->mainDataStream.offset = 0; + + pv_memset((void*)pVars->mainDataBuffer, + 0, + BUFSIZE*sizeof(*pVars->mainDataBuffer)); + + + pVars->inputStream.pBuffer = pExt->pInputBuffer; + + /* + * Initialize huffman decoding table + */ + + pHuff = pVars->ht; + pHuff[0].linbits = 0; + pHuff[0].pdec_huff_tab = pvmp3_decode_huff_cw_tab0; + pHuff[1].linbits = 0; + pHuff[1].pdec_huff_tab = pvmp3_decode_huff_cw_tab1; + pHuff[2].linbits = 0; + pHuff[2].pdec_huff_tab = pvmp3_decode_huff_cw_tab2; + pHuff[3].linbits = 0; + pHuff[3].pdec_huff_tab = pvmp3_decode_huff_cw_tab3; + pHuff[4].linbits = 0; + pHuff[4].pdec_huff_tab = pvmp3_decode_huff_cw_tab0; /* tbl 4 is not used */ + pHuff[5].linbits = 4; + pHuff[5].pdec_huff_tab = pvmp3_decode_huff_cw_tab5; + pHuff[6].linbits = 0; + pHuff[6].pdec_huff_tab = pvmp3_decode_huff_cw_tab6; + pHuff[7].linbits = 0; + pHuff[7].pdec_huff_tab = pvmp3_decode_huff_cw_tab7; + pHuff[8].linbits = 0; + pHuff[8].pdec_huff_tab = pvmp3_decode_huff_cw_tab8; + pHuff[9].linbits = 0; + pHuff[9].pdec_huff_tab = pvmp3_decode_huff_cw_tab9; + pHuff[10].linbits = 0; + pHuff[10].pdec_huff_tab = pvmp3_decode_huff_cw_tab10; + pHuff[11].linbits = 0; + pHuff[11].pdec_huff_tab = pvmp3_decode_huff_cw_tab11; + pHuff[12].linbits = 0; + pHuff[12].pdec_huff_tab = pvmp3_decode_huff_cw_tab12; + pHuff[13].linbits = 0; + pHuff[13].pdec_huff_tab = pvmp3_decode_huff_cw_tab13; + pHuff[14].linbits = 0; + pHuff[14].pdec_huff_tab = pvmp3_decode_huff_cw_tab0; /* tbl 14 is not used */ + pHuff[15].linbits = 0; + pHuff[15].pdec_huff_tab = pvmp3_decode_huff_cw_tab15; + pHuff[16].linbits = 1; + pHuff[16].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[17].linbits = 2; + pHuff[17].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[18].linbits = 3; + pHuff[18].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[19].linbits = 4; + pHuff[19].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[20].linbits = 6; + pHuff[20].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[21].linbits = 8; + pHuff[21].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[22].linbits = 10; + pHuff[22].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[23].linbits = 13; + pHuff[23].pdec_huff_tab = pvmp3_decode_huff_cw_tab16; + pHuff[24].linbits = 4; + pHuff[24].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[25].linbits = 5; + pHuff[25].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[26].linbits = 6; + pHuff[26].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[27].linbits = 7; + pHuff[27].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[28].linbits = 8; + pHuff[28].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[29].linbits = 9; + pHuff[29].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[30].linbits = 11; + pHuff[30].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[31].linbits = 13; + pHuff[31].pdec_huff_tab = pvmp3_decode_huff_cw_tab24; + pHuff[32].linbits = 0; + pHuff[32].pdec_huff_tab = pvmp3_decode_huff_cw_tab32; + pHuff[33].linbits = 0; + pHuff[33].pdec_huff_tab = pvmp3_decode_huff_cw_tab33; + + /* + * Initialize polysynthesis circular buffer mechanism + */ + /* clear buffers */ + + pvmp3_resetDecoder(pMem); + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void pvmp3_resetDecoder(void *pMem) +{ + + tmp3dec_file *pVars; + tmp3dec_chan *pChVars[CHAN]; + + pVars = (tmp3dec_file *)pMem; + pChVars[ LEFT] = &pVars->perChan[ LEFT]; + pChVars[RIGHT] = &pVars->perChan[RIGHT]; + + pVars->frame_start = 0; + + pVars->mainDataStream.offset = 0; + + pVars->mainDataStream.pBuffer = pVars->mainDataBuffer; + pVars->mainDataStream.usedBits = 0; + + + pVars->inputStream.usedBits = 0; // in bits + + + pChVars[ LEFT]->used_freq_lines = 575; + pChVars[RIGHT]->used_freq_lines = 575; + + + /* + * Initialize polysynthesis circular buffer mechanism + */ + + pv_memset((void*)&pChVars[ LEFT]->circ_buffer[576], + 0, + 480*sizeof(pChVars[ LEFT]->circ_buffer[0])); + pv_memset((void*)&pChVars[RIGHT]->circ_buffer[576], + 0, + 480*sizeof(pChVars[RIGHT]->circ_buffer[0])); + + + pv_memset((void*)pChVars[ LEFT]->overlap, + 0, + SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[ LEFT]->overlap[0])); + + + pv_memset((void*)pChVars[ RIGHT]->overlap, + 0, + SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[ RIGHT]->overlap[0])); + + + + + + /* + * Clear all the structures + */ + + + pv_memset((void*)&pVars->scaleFactors[RIGHT], + 0, + sizeof(mp3ScaleFactors)); + + pv_memset((void*)&pVars->scaleFactors[LEFT], + 0, + sizeof(mp3ScaleFactors)); + + pv_memset((void*)&pVars->sideInfo, + 0, + sizeof(mp3SideInfo)); + + pv_memset((void*)&pVars->sideInfo, + 0, + sizeof(mp3SideInfo)); + +} diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_framedecoder.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_framedecoder.h new file mode 100644 index 0000000..f6d4a35 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_framedecoder.h @@ -0,0 +1,115 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_framedecoder.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_FRAMEDECODER_H +#define PVMP3_FRAMEDECODER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "pvmp3decoder_api.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + + ERROR_CODE pvmp3_framedecoder(tPVMP3DecoderExternal *pExt, + void *pMem); + + + + uint32 pvmp3_decoderMemRequirements(void); + + void pvmp3_InitDecoder(tPVMP3DecoderExternal *pExt, + void *pMem); + + + void pvmp3_resetDecoder(void *pMem); + + + void fillMainDataBuf(void *pMem, int32 temp); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_get_main_data_size.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_main_data_size.cpp new file mode 100644 index 0000000..423a7b1 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_main_data_size.cpp @@ -0,0 +1,180 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_main_data_size.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Input + mp3Header *info, pointer to mp3 header info structure + tmp3dec_file *pVars + contains information that needs to persist + between calls to this function, or is too big to + be placed on the stack, even though the data is + only needed during execution of this function + + Returns + + main data frame size + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + get main data frame size + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_tables.h" +#include "pvmp3_get_main_data_size.h" +#include "pv_mp3dec_fxd_op.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +int32 pvmp3_get_main_data_size(mp3Header *info, + tmp3dec_file *pVars) +{ + + + int32 numBytes = fxp_mul32_Q28(mp3_bitrate[info->version_x][info->bitrate_index] << 20, + inv_sfreq[info->sampling_frequency]); + + + numBytes >>= (20 - info->version_x); + + /* + * Remove the size of the side information from the main data total + */ + if (info->version_x == MPEG_1) + { + pVars->predicted_frame_size = numBytes; + if (info->mode == MPG_MD_MONO) + { + numBytes -= 17; + } + else + { + numBytes -= 32; + } + } + else + { + numBytes >>= 1; + pVars->predicted_frame_size = numBytes; + + if (info->mode == MPG_MD_MONO) + { + numBytes -= 9; + } + else + { + numBytes -= 17; + } + } + + if (info->padding) + { + numBytes++; + pVars->predicted_frame_size++; + } + + if (info->error_protection) + { + numBytes -= 6; + } + else + { + numBytes -= 4; + } + + + if (numBytes < 0) + { + numBytes = 0; + } + + return(numBytes); +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_get_main_data_size.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_main_data_size.h new file mode 100644 index 0000000..8e9eaa8 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_main_data_size.h @@ -0,0 +1,101 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_main_data_size.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_GET_MAIN_DATA_SIZE_H +#define PVMP3_GET_MAIN_DATA_SIZE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "s_tmp3dec_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + int32 pvmp3_get_main_data_size(mp3Header *info, + tmp3dec_file *pVars); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp new file mode 100644 index 0000000..f1a3ff8 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp @@ -0,0 +1,226 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_scale_factors.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Input + mp3ScaleFactors *scalefac, + mp3SideInfo *si, side info + int32 gr, granule + int32 ch, channel + tbits *pMainData bit stream + + Returns + + mp3ScaleFactors *scalefac, scale factors + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + get scale factors + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_get_scale_factors.h" +#include "pvmp3_getbits.h" +#include "mp3_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define Qfmt_28(a)(int32(double(0x10000000)*a)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 slen[2][16] = +{ + {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4}, + {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3} +}; + +const struct +{ + int32 l[5]; + int32 s[3]; +} sfbtable = +{ + {0, 6, 11, 16, 21}, + {0, 6, 12} +}; + +const int32 long_sfbtable[4] = { 6, 5, 5, 5}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_get_scale_factors(mp3ScaleFactors *scalefac, + mp3SideInfo *si, + int32 gr, + int32 ch, + tmp3Bits *pMainData) +{ + int32 sfb; + int32 i; + int32 window; + granuleInfo *gr_info = &(si->ch[ch].gran[gr]); + + if (gr_info->window_switching_flag && (gr_info->block_type == 2)) + { + if (gr_info->mixed_block_flag) + { /* MIXED */ + for (sfb = 0; sfb < 8; sfb++) + { + scalefac->l[sfb] = getNbits(pMainData, slen[0][gr_info->scalefac_compress]); + } + + for (sfb = 3; sfb < 6; sfb++) + { + for (window = 0; window < 3; window++) + { + scalefac->s[window][sfb] = getNbits(pMainData, slen[0][gr_info->scalefac_compress]); + } + } + for (sfb = 6; sfb < 12; sfb++) + { + for (window = 0; window < 3; window++) + { + scalefac->s[window][sfb] = getNbits(pMainData, slen[1][gr_info->scalefac_compress]); + } + } + } + else + { /* SHORT*/ + for (i = 0; i < 2; i++) + { + for (sfb = sfbtable.s[i]; sfb < sfbtable.s[i+1]; sfb++) + { + for (window = 0; window < 3; window++) + { + scalefac->s[window][sfb] = getNbits(pMainData, slen[i][gr_info->scalefac_compress]); + } + } + } + } + + scalefac->s[0][12] = 0; /* sfb = 12 win= 0 */ + scalefac->s[1][12] = 0; /* sfb = 12 win= 1 */ + scalefac->s[2][12] = 0; /* sfb = 12 win= 2 */ + } + else + { /* LONG types 0,1,3 */ + + int32 *ptr = &scalefac->l[0]; + + for (i = 0; i < 4; i++) + { + int32 tmp4 = long_sfbtable[i]; + + if ((si->ch[ch].scfsi[i] == 0) || (gr == 0)) + { + int32 tmp1 = slen[(i>>1)][gr_info->scalefac_compress]; + + if (tmp1) + { + int32 tmp2 = tmp1 * tmp4; + uint32 tmp3 = getNbits(pMainData, tmp2); + tmp4 = 32 - tmp1; + for (; tmp2 > 0; tmp2 -= tmp1) + { + *(ptr++) = (tmp3 << (32 - tmp2)) >> tmp4; + } + } + else + { + for (sfb = tmp4; sfb != 0; sfb--) + { + *(ptr++) = 0; + } + + } + } + else + { + ptr += tmp4; + } + } + scalefac->l[21] = 0; + scalefac->l[22] = 0; + } +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.h new file mode 100644 index 0000000..d4f262b --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_scale_factors.h @@ -0,0 +1,104 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_scale_factors.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_GET_SCALE_FACTORS_H +#define PVMP3_GET_SCALE_FACTORS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_get_scale_factors(mp3ScaleFactors *scalefac, + mp3SideInfo *si, + int32 gr, + int32 ch, + tmp3Bits *pMainData); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_get_side_info.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_side_info.cpp new file mode 100644 index 0000000..7eaa860 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_side_info.cpp @@ -0,0 +1,285 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_side_info.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + mp3SideInfo *si, + mp3Header *info, mp3 header information + uint32 *crc initialized crc value (if enabled) + + + Returns + + mp3SideInfo *si, side information + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + acquires side information + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_get_side_info.h" +#include "pvmp3_crc.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +ERROR_CODE pvmp3_get_side_info(tmp3Bits *inputStream, + mp3SideInfo *si, + mp3Header *info, + uint32 *crc) +{ + int32 ch, gr; + uint32 tmp; + + int stereo = (info->mode == MPG_MD_MONO) ? 1 : 2; + + if (info->version_x == MPEG_1) + { + if (stereo == 1) + { + tmp = getbits_crc(inputStream, 14, crc, info->error_protection); + si->main_data_begin = (tmp << 18) >> 23; /* 9 */ + si->private_bits = (tmp << 23) >> 27; /* 5 */ + } + else + { + tmp = getbits_crc(inputStream, 12, crc, info->error_protection); + si->main_data_begin = (tmp << 20) >> 23; /* 9 */ + si->private_bits = (tmp << 23) >> 29; /* 3 */ + + } + + for (ch = 0; ch < stereo; ch++) + { + tmp = getbits_crc(inputStream, 4, crc, info->error_protection); + si->ch[ch].scfsi[0] = (tmp << 28) >> 31; /* 1 */ + si->ch[ch].scfsi[1] = (tmp << 29) >> 31; /* 1 */ + si->ch[ch].scfsi[2] = (tmp << 30) >> 31; /* 1 */ + si->ch[ch].scfsi[3] = tmp & 1; /* 1 */ + } + + for (gr = 0; gr < 2 ; gr++) + { + for (ch = 0; ch < stereo; ch++) + { + si->ch[ch].gran[gr].part2_3_length = getbits_crc(inputStream, 12, crc, info->error_protection); + tmp = getbits_crc(inputStream, 22, crc, info->error_protection); + + si->ch[ch].gran[gr].big_values = (tmp << 10) >> 23; /* 9 */ + si->ch[ch].gran[gr].global_gain = ((tmp << 19) >> 24) - 210; /* 8 */ + si->ch[ch].gran[gr].scalefac_compress = (tmp << 27) >> 28; /* 4 */ + si->ch[ch].gran[gr].window_switching_flag = tmp & 1; /* 1 */ + + if (si->ch[ch].gran[gr].window_switching_flag) + { + tmp = getbits_crc(inputStream, 22, crc, info->error_protection); + + si->ch[ch].gran[gr].block_type = (tmp << 10) >> 30; /* 2 */; + si->ch[ch].gran[gr].mixed_block_flag = (tmp << 12) >> 31; /* 1 */; + + si->ch[ch].gran[gr].table_select[0] = (tmp << 13) >> 27; /* 5 */; + si->ch[ch].gran[gr].table_select[1] = (tmp << 18) >> 27; /* 5 */; + + si->ch[ch].gran[gr].subblock_gain[0] = (tmp << 23) >> 29; /* 3 */; + si->ch[ch].gran[gr].subblock_gain[1] = (tmp << 26) >> 29; /* 3 */; + si->ch[ch].gran[gr].subblock_gain[2] = (tmp << 29) >> 29; /* 3 */; + + /* Set region_count parameters since they are implicit in this case. */ + + if (si->ch[ch].gran[gr].block_type == 0) + { + return(SIDE_INFO_ERROR); + } + else if ((si->ch[ch].gran[gr].block_type == 2) + && (si->ch[ch].gran[gr].mixed_block_flag == 0)) + { + si->ch[ch].gran[gr].region0_count = 8; /* MI 9; */ + si->ch[ch].gran[gr].region1_count = 12; + } + else + { + si->ch[ch].gran[gr].region0_count = 7; /* MI 8; */ + si->ch[ch].gran[gr].region1_count = 13; + } + } + else + { + tmp = getbits_crc(inputStream, 22, crc, info->error_protection); + + si->ch[ch].gran[gr].table_select[0] = (tmp << 10) >> 27; /* 5 */; + si->ch[ch].gran[gr].table_select[1] = (tmp << 15) >> 27; /* 5 */; + si->ch[ch].gran[gr].table_select[2] = (tmp << 20) >> 27; /* 5 */; + + si->ch[ch].gran[gr].region0_count = (tmp << 25) >> 28; /* 4 */; + si->ch[ch].gran[gr].region1_count = (tmp << 29) >> 29; /* 3 */; + + si->ch[ch].gran[gr].block_type = 0; + } + + tmp = getbits_crc(inputStream, 3, crc, info->error_protection); + si->ch[ch].gran[gr].preflag = (tmp << 29) >> 31; /* 1 */ + si->ch[ch].gran[gr].scalefac_scale = (tmp << 30) >> 31; /* 1 */ + si->ch[ch].gran[gr].count1table_select = tmp & 1; /* 1 */ + } + } + } + else /* Layer 3 LSF */ + { + si->main_data_begin = getbits_crc(inputStream, 8, crc, info->error_protection); + si->private_bits = getbits_crc(inputStream, stereo, crc, info->error_protection); + + for (ch = 0; ch < stereo; ch++) + { + tmp = getbits_crc(inputStream, 21, crc, info->error_protection); + si->ch[ch].gran[0].part2_3_length = (tmp << 11) >> 20; /* 12 */ + si->ch[ch].gran[0].big_values = (tmp << 23) >> 23; /* 9 */ + + tmp = getbits_crc(inputStream, 18, crc, info->error_protection); + si->ch[ch].gran[0].global_gain = ((tmp << 14) >> 24) - 210; /* 8 */ + si->ch[ch].gran[0].scalefac_compress = (tmp << 22) >> 23; /* 9 */ + si->ch[ch].gran[0].window_switching_flag = tmp & 1; /* 1 */ + + if (si->ch[ch].gran[0].window_switching_flag) + { + + tmp = getbits_crc(inputStream, 22, crc, info->error_protection); + + si->ch[ch].gran[0].block_type = (tmp << 10) >> 30; /* 2 */; + si->ch[ch].gran[0].mixed_block_flag = (tmp << 12) >> 31; /* 1 */; + + si->ch[ch].gran[0].table_select[0] = (tmp << 13) >> 27; /* 5 */; + si->ch[ch].gran[0].table_select[1] = (tmp << 18) >> 27; /* 5 */; + + si->ch[ch].gran[0].subblock_gain[0] = (tmp << 23) >> 29; /* 3 */; + si->ch[ch].gran[0].subblock_gain[1] = (tmp << 26) >> 29; /* 3 */; + si->ch[ch].gran[0].subblock_gain[2] = (tmp << 29) >> 29; /* 3 */; + + /* Set region_count parameters since they are implicit in this case. */ + + if (si->ch[ch].gran[0].block_type == 0) + { + return(SIDE_INFO_ERROR); + } + else if ((si->ch[ch].gran[0].block_type == 2) + && (si->ch[ch].gran[0].mixed_block_flag == 0)) + { + si->ch[ch].gran[0].region0_count = 8; /* MI 9; */ + si->ch[ch].gran[0].region1_count = 12; + } + else + { + si->ch[ch].gran[0].region0_count = 7; /* MI 8; */ + si->ch[ch].gran[0].region1_count = 13; + } + } + else + { + tmp = getbits_crc(inputStream, 22, crc, info->error_protection); + + si->ch[ch].gran[0].table_select[0] = (tmp << 10) >> 27; /* 5 */; + si->ch[ch].gran[0].table_select[1] = (tmp << 15) >> 27; /* 5 */; + si->ch[ch].gran[0].table_select[2] = (tmp << 20) >> 27; /* 5 */; + + si->ch[ch].gran[0].region0_count = (tmp << 25) >> 28; /* 4 */; + si->ch[ch].gran[0].region1_count = (tmp << 29) >> 29; /* 3 */; + + si->ch[ch].gran[0].block_type = 0; + } + + tmp = getbits_crc(inputStream, 2, crc, info->error_protection); + si->ch[ch].gran[0].scalefac_scale = tmp >> 1; /* 1 */ + si->ch[ch].gran[0].count1table_select = tmp & 1; /* 1 */ + + } + } + return (NO_DECODING_ERROR); +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_get_side_info.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_side_info.h new file mode 100644 index 0000000..2d6ccd8 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_get_side_info.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_get_side_info.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_GET_SIDE_INFO_H +#define PVMP3_GET_SIDE_INFO_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + ERROR_CODE pvmp3_get_side_info(tmp3Bits *inputStream, + mp3SideInfo *si, + mp3Header *info, + uint32 *crc); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_getbits.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_getbits.cpp new file mode 100644 index 0000000..8ff7953 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_getbits.cpp @@ -0,0 +1,257 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_getbits.cpp + + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + tmp3Bits *inputStream, structure holding the input stream parameters + int32 neededBits number of bits to read from the bit stream + + Outputs: + + word parsed from teh bitstream, with size neededBits-bits, + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint32 getNbits(tmp3Bits *ptBitStream, + int32 neededBits) /* number of bits to read from the bitstream (up to 25) */ +{ + + uint32 offset; + uint32 bitIndex; + uint8 Elem; /* Needs to be same type as pInput->pBuffer */ + uint8 Elem1; + uint8 Elem2; + uint8 Elem3; + uint32 returnValue = 0; + + if (!neededBits) + { + return (returnValue); + } + + offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + Elem = *(ptBitStream->pBuffer + module(offset , BUFSIZE)); + Elem1 = *(ptBitStream->pBuffer + module(offset + 1, BUFSIZE)); + Elem2 = *(ptBitStream->pBuffer + module(offset + 2, BUFSIZE)); + Elem3 = *(ptBitStream->pBuffer + module(offset + 3, BUFSIZE)); + + + returnValue = (((uint32)(Elem)) << 24) | + (((uint32)(Elem1)) << 16) | + (((uint32)(Elem2)) << 8) | + ((uint32)(Elem3)); + + /* Remove extra high bits by shifting up */ + bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH); + + /* This line is faster than to mask off the high bits. */ + returnValue <<= bitIndex; + + /* Move the field down. */ + returnValue >>= (32 - neededBits); + + ptBitStream->usedBits += neededBits; + + return (returnValue); +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint16 getUpTo9bits(tmp3Bits *ptBitStream, + int32 neededBits) /* number of bits to read from the bit stream 2 to 9 */ +{ + + uint32 offset; + uint32 bitIndex; + uint8 Elem; /* Needs to be same type as pInput->pBuffer */ + uint8 Elem1; + uint16 returnValue; + + offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + Elem = *(ptBitStream->pBuffer + module(offset , BUFSIZE)); + Elem1 = *(ptBitStream->pBuffer + module(offset + 1, BUFSIZE)); + + + returnValue = (((uint16)(Elem)) << 8) | + ((uint16)(Elem1)); + + /* Remove extra high bits by shifting up */ + bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH); + + ptBitStream->usedBits += neededBits; + /* This line is faster than to mask off the high bits. */ + returnValue = (returnValue << (bitIndex)); + + /* Move the field down. */ + + return (uint16)(returnValue >> (16 - neededBits)); + +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint32 getUpTo17bits(tmp3Bits *ptBitStream, + int32 neededBits) /* number of bits to read from the bit stream 2 to 8 */ +{ + + uint32 offset; + uint32 bitIndex; + uint8 Elem; /* Needs to be same type as pInput->pBuffer */ + uint8 Elem1; + uint8 Elem2; + uint32 returnValue; + + offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + Elem = *(ptBitStream->pBuffer + module(offset , BUFSIZE)); + Elem1 = *(ptBitStream->pBuffer + module(offset + 1, BUFSIZE)); + Elem2 = *(ptBitStream->pBuffer + module(offset + 2, BUFSIZE)); + + + returnValue = (((uint32)(Elem)) << 16) | + (((uint32)(Elem1)) << 8) | + ((uint32)(Elem2)); + + /* Remove extra high bits by shifting up */ + bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH); + + ptBitStream->usedBits += neededBits; + /* This line is faster than to mask off the high bits. */ + returnValue = 0xFFFFFF & (returnValue << (bitIndex)); + + /* Move the field down. */ + + return (uint32)(returnValue >> (24 - neededBits)); + +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +uint8 get1bit(tmp3Bits *ptBitStream) /* number of bits to read from the bit stream */ +{ + + uint32 offset; + uint32 bitIndex; + uint8 returnValue; + + offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + returnValue = *(ptBitStream->pBuffer + module(offset , BUFSIZE)); + + /* Remove extra high bits by shifting up */ + bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH); + ptBitStream->usedBits++; + + /* This line is faster than to mask off the high bits. */ + returnValue = (returnValue << (bitIndex)); + + return (uint8)(returnValue >> 7); + +} + + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_getbits.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_getbits.h new file mode 100644 index 0000000..b058b00 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_getbits.h @@ -0,0 +1,112 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_getbits.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_GETBITS_H +#define PVMP3_GETBITS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_dec_defs.h" +#include "s_mp3bits.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define INBUF_ARRAY_INDEX_SHIFT (3) +#define INBUF_BIT_WIDTH (1<<(INBUF_ARRAY_INDEX_SHIFT)) +#define INBUF_BIT_MODULO_MASK ((INBUF_BIT_WIDTH)-1) + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + uint32 getNbits(tmp3Bits *pMainData, + int32 neededBits); + + uint16 getUpTo9bits(tmp3Bits *pMainData, + int32 neededBits); + + uint32 getUpTo17bits(tmp3Bits *pMainData, + int32 neededBits); + + uint8 get1bit(tmp3Bits *pMainData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_huffman_decoding.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_huffman_decoding.cpp new file mode 100644 index 0000000..5d58cd2 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_huffman_decoding.cpp @@ -0,0 +1,304 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_huffman_decoding.cpp + + Funtions: + pvmp3_huffman_quad_decoding + pvmp3_huffman_pair_decoding + pvmp3_huffman_pair_decoding_linbits + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + struct huffcodetab *h, pointer to huffman code record + int32 *x, returns decoded x value + int32 *y, returns decoded y value + int32 *v, returns decoded v value (only in quad function) + int32 *w, returns decoded w value (only in quad function) + tbits *pMainData bit stream + + Outputs: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + These functions are used to decode huffman codewords from the input + bitstream using combined binary search and look-up table approach. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_dec_defs.h" +#include "pv_mp3_huffman.h" +#include "pvmp3_getbits.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void pvmp3_huffman_quad_decoding(struct huffcodetab *h, + int32 *is, + tmp3Bits *pMainData) +{ + + int32 x; + int32 y; + int32 v; + int32 w; + + y = (*h->pdec_huff_tab)(pMainData); + + + if (y) + { + v = (y >> 3); + + if (v) + { + if (get1bit(pMainData)) + { + v = -v; + } + } + w = (y >> 2) & 1; + if (w) + { + if (get1bit(pMainData)) + { + w = -w; + } + } + x = (y >> 1) & 1; + if (x) + { + if (get1bit(pMainData)) + { + x = -x; + } + } + y = y & 1; + if (y) + { + if (get1bit(pMainData)) + { + y = -y; + } + } + + } + else + { + v = 0; + w = 0; + x = 0; + + } + + *is = v; + *(is + 1) = w; + *(is + 2) = x; + *(is + 3) = y; + +} + + + +void pvmp3_huffman_pair_decoding(struct huffcodetab *h, /* pointer to huffman code record */ + int32 *is, + tmp3Bits *pMainData) +{ + /* Lookup in Huffman table. */ + int32 x; + int32 y; + + uint16 cw = (*h->pdec_huff_tab)(pMainData); + + /* Process sign and escape encodings for dual tables. */ + + + if (cw) + { + x = cw >> 4; + + if (x) + { + if (get1bit(pMainData)) + { + x = -x; + } + y = cw & 0xf; + if (y && get1bit(pMainData)) + { + y = -y; + } + + } + else + { + y = cw & 0xf; + if (get1bit(pMainData)) + { + y = -y; + } + } + + *is = x; + *(is + 1) = y; + } + else + { + *is = 0; + *(is + 1) = 0; + } + + + +} + + + + +void pvmp3_huffman_pair_decoding_linbits(struct huffcodetab *h, /* pointer to huffman code record */ + int32 *is, + tmp3Bits *pMainData) +{ + int32 x; + int32 y; + + uint16 cw; + /* Lookup in Huffman table. */ + + + cw = (*h->pdec_huff_tab)(pMainData); + x = cw >> 4; + + /* Process sign and escape encodings for dual tables. */ + + + if (15 == (uint32)x) + { + int32 tmp = getUpTo17bits(pMainData, (h->linbits + 1)); + x += tmp >> 1; + if (tmp&1) + { + x = -x; + } + } + else if (x) + { + if (get1bit(pMainData)) + { + x = -x; + } + } + + y = cw & 0xf; + if (15 == (uint32)y) + { + int32 tmp = getUpTo17bits(pMainData, (h->linbits + 1)); + y += tmp >> 1; + if (tmp&1) + { + y = -y; + } + } + else if (y) + { + if (get1bit(pMainData)) + { + y = -y; + } + } + + *is = x; + *(is + 1) = y; + +} + + + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_huffman_parsing.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_huffman_parsing.cpp new file mode 100644 index 0000000..ff815dc --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_huffman_parsing.cpp @@ -0,0 +1,328 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_huffman_decoding.cpp + + Funtions: + pvmp3_huffman_quad_decoding + pvmp3_huffman_pair_decoding + pvmp3_huffman_pair_decoding_linbits + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + int32 is[], + granuleInfo *grInfo, information for the given channel and granule + tmp3dec_file *pVars, decoder state structure + int32 part2_start, index to beginning of part 2 data + mp3Header *info mp3 header info + + Outputs: + int32 is[], uncompressed data + + Return: + non zero frequency lines + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + These functions are used to decode huffman codewords from the input + bitstream using combined binary search and look-up table approach. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_mp3_huffman.h" +#include "s_mp3bits.h" +#include "mp3_mem_funcs.h" +#include "pvmp3_tables.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +int32 pvmp3_huffman_parsing(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], + granuleInfo *grInfo, + tmp3dec_file *pVars, + int32 part2_start, + mp3Header *info) + + +{ + int32 i; + int32 region1Start; + int32 region2Start; + int32 sfreq; + uint32 grBits; + void(*pt_huff)(struct huffcodetab *, int32 *, tmp3Bits *); + struct huffcodetab *h; + + tmp3Bits *pMainData = &pVars->mainDataStream; + + + /*int32 bt = (*si).ch[ch].gr[gr].window_switching_flag && ((*si).ch[ch].gr[gr].block_type == 2);*/ + + sfreq = info->sampling_frequency + info->version_x + (info->version_x << 1); + + /* Find region boundary for short block case. */ + + + if ((grInfo->window_switching_flag) && (grInfo->block_type == 2)) + { + if (info->version_x == MPEG_1) + { + /* Region2. */ + region1Start = 12; + } + else + { + /* Region2. */ + i = grInfo->region0_count + 1; + region1Start = mp3_sfBandIndex[sfreq].s[i/3]; + } + + region1Start += region1Start << 1; + region2Start = 576; /* No Region2 for short block case. */ + } + else + { /* Find region boundary for long block case. */ + i = grInfo->region0_count + 1; + region1Start = mp3_sfBandIndex[sfreq].l[i]; + region2Start = mp3_sfBandIndex[sfreq].l[i + grInfo->region1_count + 1]; + } + + /* Read bigvalues area. */ + + + if (grInfo->big_values > (FILTERBANK_BANDS*SUBBANDS_NUMBER >> 1)) + { + grInfo->big_values = (FILTERBANK_BANDS * SUBBANDS_NUMBER >> 1); + } + + if ((grInfo->big_values << 1) > (uint32)region2Start) + { + h = &(pVars->ht[grInfo->table_select[0]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + + for (i = 0; i < region1Start; i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + + h = &(pVars->ht[grInfo->table_select[1]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + + for (; i < region2Start; i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + + h = &(pVars->ht[grInfo->table_select[2]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + + for (; (uint32)i < (grInfo->big_values << 1); i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + } + else if ((grInfo->big_values << 1) > (uint32)region1Start) + { + h = &(pVars->ht[grInfo->table_select[0]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + for (i = 0; i < region1Start; i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + + h = &(pVars->ht[grInfo->table_select[1]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + for (; (uint32)i < (grInfo->big_values << 1); i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + } + else + { + h = &(pVars->ht[grInfo->table_select[0]]); + if (h->linbits) + { + pt_huff = pvmp3_huffman_pair_decoding_linbits; + } + else + { + pt_huff = pvmp3_huffman_pair_decoding; + } + + for (i = 0; (uint32)i < (grInfo->big_values << 1); i += 2) + { + (*pt_huff)(h, &is[i], pMainData); + } + } + + + + /* Read count1 area. */ + h = &(pVars->ht[grInfo->count1table_select+32]); + + grBits = part2_start + grInfo->part2_3_length; + + while ((pMainData->usedBits < grBits) && + (i < FILTERBANK_BANDS*SUBBANDS_NUMBER - 4)) + { + pvmp3_huffman_quad_decoding(h, &is[i], pMainData); + i += 4; + } + + if ((pMainData->usedBits < grBits) && + (i < FILTERBANK_BANDS*SUBBANDS_NUMBER)) + { + pvmp3_huffman_quad_decoding(h, &is[i], pMainData); + i += 4; + + if ((i - 2) >= FILTERBANK_BANDS*SUBBANDS_NUMBER) + { + i -= 2; + is[i] = 0; + is[(i+1)] = 0; + } + } + + if (pMainData->usedBits > grBits) + { + i -= 4; + + if (i < 0 || i > FILTERBANK_BANDS*SUBBANDS_NUMBER - 4) + { + /* illegal parameters may cause invalid access, set i to 0 */ + i = 0; + } + + is[i] = 0; + is[(i+1)] = 0; + is[(i+2)] = 0; + is[(i+3)] = 0; + + } + + pMainData->usedBits = grBits; + + return (i); + +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_imdct_synth.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_imdct_synth.cpp new file mode 100644 index 0000000..11961d1 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_imdct_synth.cpp @@ -0,0 +1,376 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_imdct_synth.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Input + int32 in[], Pointer to spec values of current channel + int32 overlap[], Pointer to overlap values of current channel + uint32 blk_type, Block type + int16 mx_band, In case of mixed blocks, # of bands with long + blocks (2 or 4) else 0 + int32 *Scratch_mem + Returns + + int32 in[], + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + The frequency lines are preprocessed by the "alias reduction" scheme + and fed into the IMDCT matrix, each 18 into one transform block. + The first half of the output values are added to the stored overlap + values from the last block. These values are new output values and + are input values for the polyphase filterbank. The second half of the + output values is stored for overlap with the next data granule. + The number of windowed samples is 12 for short blocks, and 36 for long + blocks + +Windowing + + Depending on window_switching_flag[gr][ch], block_type[gr][ch] and + mixed_block_flag[gr][ch] different shapes of windows are used. + normal window + start window + stop window + short windows + Each of the three short blocks is windowed separately. + The windowed short blocks must be overlapped and concatenated. + +Overlapping and adding with previous block + + The first half (18 values) of the current block (36 values) has to be + overlapped with the second half of the previous block. The second half + of the current block has to be stored for overlapping with the next block + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_imdct_synth.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_mdct_18.h" +#include "pvmp3_mdct_6.h" +#include "mp3_mem_funcs.h" + + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define LONG 0 +#define START 1 +#define SHORT 2 +#define STOP 3 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/* + * sin(pi/36*(k+0.5)),k=0..35 + */ + +const int32 normal_win[36] = +{ + Qfmt_31(0.08723877473068f), Qfmt_31(0.26105238444010f), Qfmt_31(0.43287922787620f), + Qfmt_31(0.60141159900854f), Qfmt_31(0.76536686473018f), Qfmt_31(0.92349722647006f), + Qfmt_31(0.53729960834682f), Qfmt_31(0.60876142900872f), Qfmt_31(0.67559020761566f), + Qfmt_31(-0.73727733681012f), Qfmt_31(-0.79335334029124f), Qfmt_31(0.84339144581289f), + Qfmt_31(0.88701083317822f), Qfmt_31(0.92387953251129f), Qfmt_31(-0.95371695074823f), + Qfmt_31(-0.97629600711993f), Qfmt_31(-0.99144486137381f), Qfmt_31(-0.99904822158186f), + Qfmt_31(0.99904822158186f), Qfmt_31(0.99144486137381f), Qfmt_31(0.97629600711993f), + Qfmt_31(0.95371695074823f), Qfmt_31(0.92387953251129f), Qfmt_31(0.88701083317822f), + Qfmt_31(0.84339144581289f), Qfmt_31(0.79335334029124f), Qfmt_31(0.73727733681012f), + Qfmt_31(0.67559020761566f), Qfmt_31(0.60876142900872f), Qfmt_31(0.53729960834682f), + Qfmt_31(0.46174861323503f), Qfmt_31(0.38268343236509f), Qfmt_31(0.30070579950427f), + Qfmt_31(0.21643961393810f), Qfmt_31(0.13052619222005f), Qfmt_31(0.04361938736534f) +}; + + +const int32 start_win[36] = +{ + /* k=0..17 sin(pi/36*(k+0.5)), */ + Qfmt_31(0.08723877473068f), Qfmt_31(0.26105238444010f), Qfmt_31(0.43287922787620f), + Qfmt_31(0.60141159900854f), Qfmt_31(0.76536686473018f), Qfmt_31(0.92349722647006f), + Qfmt_31(0.53729960834682f), Qfmt_31(0.60876142900872f), Qfmt_31(0.67559020761566f), + Qfmt_31(-0.73727733681012f), Qfmt_31(-0.79335334029124f), Qfmt_31(0.84339144581289f), + Qfmt_31(0.88701083317822f), Qfmt_31(0.92387953251129f), Qfmt_31(-0.95371695074823f), + Qfmt_31(-0.97629600711993f), Qfmt_31(-0.99144486137381f), Qfmt_31(-0.99904822158186f), + + Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), + Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), + /* k=24..29; sin(pi/12*(k-18+0.5)) */ + Qfmt_31(0.99144486137381f), Qfmt_31(0.92387953251129f), Qfmt_31(0.79335334029124f), + Qfmt_31(0.60876142900872f), Qfmt_31(0.38268343236509f), Qfmt_31(0.13052619222005f), + + Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), + Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f) +}; + + +const int32 stop_win[36] = +{ + Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), + Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), + /* k=6..11; sin(pi/12*(k-6+0.5)) */ + Qfmt_31(0.13052619222005f), Qfmt_31(0.38268343236509f), Qfmt_31(0.60876142900872f), + Qfmt_31(-0.79335334029124f), Qfmt_31(-0.92387953251129f), Qfmt_31(0.99144486137381f), + + Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), Qfmt_31(-0.99999990000000f), + Qfmt_31(-0.99999990000000f), Qfmt_31(-0.99999990000000f), Qfmt_31(-0.99999990000000f), + /* k=18..35 sin(pi/36*(k+0.5)), */ + Qfmt_31(0.99904822158186f), Qfmt_31(0.99144486137381f), Qfmt_31(0.97629600711993f), + Qfmt_31(0.95371695074823f), Qfmt_31(0.92387953251129f), Qfmt_31(0.88701083317822f), + Qfmt_31(0.84339144581289f), Qfmt_31(0.79335334029124f), Qfmt_31(0.73727733681012f), + Qfmt_31(0.67559020761566f), Qfmt_31(0.60876142900872f), Qfmt_31(0.53729960834682f), + Qfmt_31(0.46174861323503f), Qfmt_31(0.38268343236509f), Qfmt_31(0.30070579950427f), + Qfmt_31(0.21643961393810f), Qfmt_31(0.13052619222005f), Qfmt_31(0.04361938736534f) +}; + + +const int32 short_win[12] = +{ + /* k=0..11; sin(pi/12*(k+0.5)) */ + Qfmt_31(0.13052619222005f), Qfmt_31(0.38268343236509f), Qfmt_31(0.60876142900872f), + Qfmt_31(0.79335334029124f), Qfmt_31(0.92387953251129f), Qfmt_31(0.99144486137381f), + Qfmt_31(0.99144486137381f), Qfmt_31(0.92387953251129f), Qfmt_31(0.79335334029124f), + Qfmt_31(0.60876142900872f), Qfmt_31(0.38268343236509f), Qfmt_31(0.13052619222005f), +}; +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_imdct_synth(int32 in[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 overlap[SUBBANDS_NUMBER*FILTERBANK_BANDS], + uint32 blk_type, + int16 mx_band, + int32 used_freq_lines, + int32 *Scratch_mem) +{ + + int32 band; + int32 bands2process = used_freq_lines + 2; + + if (bands2process > SUBBANDS_NUMBER) + { + bands2process = SUBBANDS_NUMBER; /* default */ + } + + + /* + * in case of mx_poly_band> 0, do + * long transforms + */ + + + for (band = 0; band < bands2process; band++) + { + uint32 current_blk_type = (band < mx_band) ? LONG : blk_type; + + int32 * out = in + (band * FILTERBANK_BANDS); + int32 * history = overlap + (band * FILTERBANK_BANDS); + + switch (current_blk_type) + { + case LONG: + + pvmp3_mdct_18(out, history, normal_win); + + break; + + case START: + + pvmp3_mdct_18(out, history, start_win); + + break; + + case STOP: + + pvmp3_mdct_18(out, history, stop_win); + + break; + + case SHORT: + { + int32 *tmp_prev_ovr = &Scratch_mem[FILTERBANK_BANDS]; + int32 i; + + for (i = 0; i < 6; i++) + { + Scratch_mem[i ] = out[(i*3)]; + Scratch_mem[6 +i] = out[(i*3) + 1]; + Scratch_mem[12 +i] = out[(i*3) + 2]; + } + + pvmp3_mdct_6(&Scratch_mem[ 0], &tmp_prev_ovr[ 0]); + pvmp3_mdct_6(&Scratch_mem[ 6], &tmp_prev_ovr[ 6]); + pvmp3_mdct_6(&Scratch_mem[12], &tmp_prev_ovr[12]); + + for (i = 0; i < 6; i++) + { + int32 temp = history[i]; + /* next iteration overlap */ + history[i] = fxp_mul32_Q32(tmp_prev_ovr[ 6+i] << 1, short_win[6+i]); + history[i] += fxp_mul32_Q32(Scratch_mem[12+i] << 1, short_win[ i]); + out[i] = temp; + } + + for (i = 0; i < 6; i++) + { + out[i+6] = fxp_mul32_Q32(Scratch_mem[i] << 1, short_win[i]); + out[i+6] += history[i+6]; + /* next iteration overlap */ + history[i+6] = fxp_mul32_Q32(tmp_prev_ovr[12+i] << 1, short_win[6+i]); + + } + for (i = 0; i < 6; i++) + { + out[i+12] = fxp_mul32_Q32(tmp_prev_ovr[ i] << 1, short_win[6+i]); + out[i+12] += fxp_mul32_Q32(Scratch_mem[6+i] << 1, short_win[ i]); + out[i+12] += history[i+12]; + history[12+i] = 0; + } + } + + break; + } + + /* + * Compensation for frequency inversion of polyphase filterbank + * every odd time sample of every odd odd subband is mulitplied by -1 before + * processing by the polyphase filter + */ + + if (band & 1) + { + for (int32 slot = 1; slot < FILTERBANK_BANDS; slot += 6) + { + int32 temp1 = out[slot ]; + int32 temp2 = out[slot+2]; + int32 temp3 = out[slot+4]; + out[slot ] = -temp1; + out[slot+2] = -temp2; + out[slot+4] = -temp3; + } + } + } + + + for (band = bands2process; band < SUBBANDS_NUMBER; band++) + { + int32 * out = in + (band * FILTERBANK_BANDS); + int32 * history = overlap + (band * FILTERBANK_BANDS); + int32 slot; + + if (band & 1) + { + for (slot = 0; slot < FILTERBANK_BANDS; slot += 6) + { + int32 temp1 = history[slot ]; + int32 temp2 = history[slot+1]; + int32 temp3 = history[slot+2]; + out[slot ] = temp1; + out[slot+1] = -temp2; + out[slot+2] = temp3; + + temp1 = history[slot+3]; + temp2 = history[slot+4]; + temp3 = history[slot+5]; + out[slot+3] = -temp1; + out[slot+4] = temp2; + out[slot+5] = -temp3; + } + } + else + { + for (slot = 0; slot < FILTERBANK_BANDS; slot += 3) + { + int32 temp1 = history[slot ]; + int32 temp2 = history[slot+1]; + int32 temp3 = history[slot+2]; + out[slot ] = temp1; + out[slot+1] = temp2; + out[slot+2] = temp3; + } + } + + pv_memset(history, 0, FILTERBANK_BANDS*sizeof(*overlap)); + } +} + + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_imdct_synth.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_imdct_synth.h new file mode 100644 index 0000000..ea42e49 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_imdct_synth.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_imdct_synth.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ + +#ifndef PVMP3_IMDCT_SYNTH_H +#define PVMP3_IMDCT_SYNTH_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_imdct_synth(int32 in[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 overlap[SUBBANDS_NUMBER*FILTERBANK_BANDS], + uint32 blk_type, + int16 mx_band, + int32 used_freq_lines, + int32 *Scratch_mem); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.cpp new file mode 100644 index 0000000..09a735b --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.cpp @@ -0,0 +1,289 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: mdct_18.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + int32 vec[], input vector of length 18 + int32 *history input for overlap and add, vector updated with + next overlap and add values + const int32 *window sine window used in the mdct, three types are allowed + noraml, start and stop +Returns + none mdct computation in-place + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Returns the mdct of length 18 of the input vector, as well as the overlap + vector for next iteration ( on history[]) + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) ) +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_mdct_18.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 cosTerms_dct18[9] = +{ + Qfmt(0.50190991877167f), Qfmt(0.51763809020504f), Qfmt(0.55168895948125f), + Qfmt(0.61038729438073f), Qfmt(0.70710678118655f), Qfmt(0.87172339781055f), + Qfmt(1.18310079157625f), Qfmt(1.93185165257814f), Qfmt(5.73685662283493f) +}; + + +const int32 cosTerms_1_ov_cos_phi[18] = +{ + + Qfmt1(0.50047634258166f), Qfmt1(0.50431448029008f), Qfmt1(0.51213975715725f), + Qfmt1(0.52426456257041f), Qfmt1(0.54119610014620f), Qfmt1(0.56369097343317f), + Qfmt1(0.59284452371708f), Qfmt1(0.63023620700513f), Qfmt1(0.67817085245463f), + + Qfmt2(0.74009361646113f), Qfmt2(0.82133981585229f), Qfmt2(0.93057949835179f), + Qfmt2(1.08284028510010f), Qfmt2(1.30656296487638f), Qfmt2(1.66275476171152f), + Qfmt2(2.31011315767265f), Qfmt2(3.83064878777019f), Qfmt2(11.46279281302667f) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void pvmp3_mdct_18(int32 vec[], int32 *history, const int32 *window) +{ + int32 i; + int32 tmp; + int32 tmp1; + int32 tmp2; + int32 tmp3; + int32 tmp4; + + + + const int32 *pt_cos_split = cosTerms_dct18; + const int32 *pt_cos = cosTerms_1_ov_cos_phi; + const int32 *pt_cos_x = &cosTerms_1_ov_cos_phi[17]; + int32 *pt_vec = vec; + int32 *pt_vec_o = &vec[17]; + + + for (i = 9; i != 0; i--) + { + tmp = *(pt_vec); + tmp1 = *(pt_vec_o); + tmp = fxp_mul32_Q32(tmp << 1, *(pt_cos++)); + tmp1 = fxp_mul32_Q27(tmp1, *(pt_cos_x--)); + *(pt_vec++) = tmp + tmp1 ; + *(pt_vec_o--) = fxp_mul32_Q28((tmp - tmp1), *(pt_cos_split++)); + } + + + pvmp3_dct_9(vec); // Even terms + pvmp3_dct_9(&vec[9]); // Odd terms + + + tmp3 = vec[16]; // + vec[16] = vec[ 8]; + tmp4 = vec[14]; // + vec[14] = vec[ 7]; + tmp = vec[12]; + vec[12] = vec[ 6]; + tmp2 = vec[10]; // vec[10] + vec[10] = vec[ 5]; + vec[ 8] = vec[ 4]; + vec[ 6] = vec[ 3]; + vec[ 4] = vec[ 2]; + vec[ 2] = vec[ 1]; + vec[ 1] = vec[ 9] - tmp2; // vec[9] + vec[10] + vec[ 3] = vec[11] - tmp2; + vec[ 5] = vec[11] - tmp; + vec[ 7] = vec[13] - tmp; + vec[ 9] = vec[13] - tmp4; + vec[11] = vec[15] - tmp4; + vec[13] = vec[15] - tmp3; + vec[15] = vec[17] - tmp3; + + + /* overlap and add */ + + tmp2 = vec[0]; + tmp3 = vec[9]; + + for (i = 0; i < 6; i++) + { + tmp = history[ i]; + tmp4 = vec[i+10]; + vec[i+10] = tmp3 + tmp4; + tmp1 = vec[i+1]; + vec[ i] = fxp_mac32_Q32(tmp, (vec[i+10]), window[ i]); + tmp3 = tmp4; + history[i ] = -(tmp2 + tmp1); + tmp2 = tmp1; + } + + tmp = history[ 6]; + tmp4 = vec[16]; + vec[16] = tmp3 + tmp4; + tmp1 = vec[7]; + vec[ 6] = fxp_mac32_Q32(tmp, vec[16] << 1, window[ i]); + tmp = history[ 7]; + history[6] = -(tmp2 + tmp1); + history[7] = -(tmp1 + vec[8]); + + tmp1 = history[ 8]; + tmp4 = vec[17] + tmp4; + vec[ 7] = fxp_mac32_Q32(tmp, tmp4 << 1, window[ 7]); + history[8] = -(vec[8] + vec[9]); + vec[ 8] = fxp_mac32_Q32(tmp1, vec[17] << 1, window[ 8]); + + tmp = history[9]; + tmp1 = history[17]; + tmp2 = history[16]; + vec[ 9] = fxp_mac32_Q32(tmp, vec[17] << 1, window[ 9]); + + vec[17] = fxp_mac32_Q32(tmp1, vec[10] << 1, window[17]); + vec[10] = -vec[ 16]; + vec[16] = fxp_mac32_Q32(tmp2, vec[11] << 1, window[16]); + tmp1 = history[15]; + tmp2 = history[14]; + vec[11] = -vec[ 15]; + vec[15] = fxp_mac32_Q32(tmp1, vec[12] << 1, window[15]); + vec[12] = -vec[ 14]; + vec[14] = fxp_mac32_Q32(tmp2, vec[13] << 1, window[14]); + + tmp = history[13]; + tmp1 = history[12]; + tmp2 = history[11]; + tmp3 = history[10]; + vec[13] = fxp_mac32_Q32(tmp, vec[12] << 1, window[13]); + vec[12] = fxp_mac32_Q32(tmp1, vec[11] << 1, window[12]); + vec[11] = fxp_mac32_Q32(tmp2, vec[10] << 1, window[11]); + vec[10] = fxp_mac32_Q32(tmp3, tmp4 << 1, window[10]); + + + /* next iteration overlap */ + + tmp1 = history[ 8]; + tmp3 = history[ 7]; + tmp2 = history[ 1]; + tmp = history[ 0]; + tmp1 <<= 1; + tmp3 <<= 1; + + history[ 0] = fxp_mul32_Q32(tmp1, window[18]); + history[17] = fxp_mul32_Q32(tmp1, window[35]); + history[ 1] = fxp_mul32_Q32(tmp3, window[19]); + history[16] = fxp_mul32_Q32(tmp3, window[34]); + + tmp2 <<= 1; + tmp <<= 1; + history[ 7] = fxp_mul32_Q32(tmp2, window[25]); + history[10] = fxp_mul32_Q32(tmp2, window[28]); + history[ 8] = fxp_mul32_Q32(tmp, window[26]); + history[ 9] = fxp_mul32_Q32(tmp, window[27]); + + tmp1 = history[ 6]; + tmp3 = history[ 5]; + tmp4 = history[ 4]; + tmp2 = history[ 3]; + tmp = history[ 2]; + + tmp1 <<= 1; + tmp3 <<= 1; + tmp4 <<= 1; + + history[ 2] = fxp_mul32_Q32(tmp1, window[20]); + history[15] = fxp_mul32_Q32(tmp1, window[33]); + history[ 3] = fxp_mul32_Q32(tmp3, window[21]); + history[14] = fxp_mul32_Q32(tmp3, window[32]); + history[ 4] = fxp_mul32_Q32(tmp4, window[22]); + history[13] = fxp_mul32_Q32(tmp4, window[31]); + tmp2 <<= 1; + tmp <<= 1; + history[ 5] = fxp_mul32_Q32(tmp2, window[23]); + history[12] = fxp_mul32_Q32(tmp2, window[30]); + history[ 6] = fxp_mul32_Q32(tmp, window[24]); + history[11] = fxp_mul32_Q32(tmp, window[29]); +} + +#endif // If not assembly diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.h new file mode 100644 index 0000000..e497aee --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_18.h @@ -0,0 +1,109 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Pathname: ./include/pvmp3_mdct_18.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines function mdct_18, dct9, mdct_6 and dct_6 + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef MDCT_18_H +#define MDCT_18_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define Qfmt(a) (Int32)(a*((Int32)1<<28) ) +#define Qfmt1(a) (Int32)(a*((Int32)0x7FFFFFFF)) +#define Qfmt2(a) (Int32)(a*((Int32)1<<27)) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_mdct_18(int32 vec[], int32 *history, const int32 *window); + + void pvmp3_dct_9(int32 vec[]); + + void pvmp3_mdct_6(int32 vec[], int32 *overlap); + + void pvmp3_dct_6(int32 vec[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.cpp new file mode 100644 index 0000000..6a72aad --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.cpp @@ -0,0 +1,165 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + Filename: mdct_18.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + int32 vec[], input vector of length 6 + int32 *history input for overlap and add, vector updated with + next overlap and add values +Returns + none mdct computation in-place + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Returns the mdct of length 6 of the input vector, as well as the overlap + vector for next iteration ( on history[]) + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_mdct_6.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define QFORMAT 29 +#define Qfmt29(a) (int32)(a*((int32)1<=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/* + * (1./(2*cos((pi/(2*N))*(2*i+1)))), N = 12, i = [0:N/2-1] + */ + +const int32 cosTerms_1_ov_cos_phi_N6[6] = +{ + + Qfmt29(0.50431448029008f), Qfmt29(0.54119610014620f), + Qfmt29(0.63023620700513f), Qfmt29(0.82133981585229f), + Qfmt29(1.30656296487638f), Qfmt29(3.83064878777019f) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void pvmp3_mdct_6(int32 vec[], int32 *history) +{ + int32 i; + int32 tmp; + int32 tmp1; + int32 tmp2; + + int32 *pt_vec = vec; + int32 *pt_vec_o = vec; + const int32 *pt_cos = cosTerms_1_ov_cos_phi_N6; + + for (i = 2; i != 0; i--) + { + tmp = *(pt_vec++); + tmp1 = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_vec_o++) = fxp_mul32_Q29(tmp, *(pt_cos++)); + *(pt_vec_o++) = fxp_mul32_Q29(tmp1, *(pt_cos++)); + *(pt_vec_o++) = fxp_mul32_Q29(tmp2, *(pt_cos++)); + } + + + pvmp3_dct_6(vec); // Even terms + + + tmp = -(vec[0] + vec[1]); + history[3] = tmp; + history[2] = tmp; + tmp = -(vec[1] + vec[2]); + vec[0] = vec[3] + vec[4]; + vec[1] = vec[4] + vec[5]; + history[4] = tmp; + history[1] = tmp; + tmp = -(vec[2] + vec[3]); + vec[4] = -vec[1]; + history[5] = tmp; + history[0] = tmp; + + vec[2] = vec[5]; + vec[3] = -vec[5]; + vec[5] = -vec[0]; + +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.h new file mode 100644 index 0000000..6ba53d7 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mdct_6.h @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Pathname: ./include/pvmp3_mdct_6.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines function mdct_18, dct9, mdct_6 and dct_6 + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_MDCT_6_H +#define PVMP3_MDCT_6_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define Qfmt(a) (Int32)(a*((Int32)1<<28) ) +#define Qfmt1(a) (Int32)(a*((Int32)0x7FFFFFFF)) +#define Qfmt2(a) (Int32)(a*((Int32)1<<27)) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + void pvmp3_mdct_6(int32 vec[], int32 *overlap); + + void pvmp3_dct_6(int32 vec[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.cpp new file mode 100644 index 0000000..ee42dc5 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.cpp @@ -0,0 +1,247 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_get_scale_data.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + mp3SideInfo *si, side information + int32 gr, granule + int32 ch, channel + mp3Header *info, mp3 header information + uint32 *scalefac_buffer, + uint32 *scalefac_IIP_buffer, + tbits *pMainData bit stream Data + + Returns + + uint32 *scalefac_buffer, acquired scale band data + uint32 *scalefac_IIP_buffer, auxiliary scale data + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + get scale data for mpeg2 layer III LSF extension + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_mpeg2_get_scale_data.h" +#include "pvmp3_getbits.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const uint32 nr_of_sfb_block[6][3][4] = +{ {{ 6, 5, 5, 5}, { 9, 9, 9, 9}, { 6, 9, 9, 9}}, + {{ 6, 5, 7, 3}, { 9, 9, 12, 6}, { 6, 9, 12, 6}}, + {{11, 10, 0, 0}, { 18, 18, 0, 0}, {15, 18, 0, 0}}, + {{ 7, 7, 7, 0}, { 12, 12, 12, 0}, { 6, 15, 12, 0}}, + {{ 6, 6, 6, 3}, { 12, 9, 9, 6}, { 6, 12, 9, 6}}, + {{ 8, 8, 5, 0}, { 15, 12, 9, 0}, { 6, 18, 9, 0}} +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_mpeg2_get_scale_data(mp3SideInfo *si, + int32 gr, + int32 ch, + mp3Header *info, + uint32 *scalefac_buffer, + uint32 *scalefac_IIP_buffer, + tmp3Bits *pMainData) +{ + int16 i; + int16 j; + int16 k; + int16 blocktypenumber = 0; + int16 blocknumber = 0; + + granuleInfo *gr_info = &(si->ch[ch].gran[gr]); + uint32 scalefac_comp, int_scalefac_comp, new_slen[4]; + + scalefac_comp = gr_info->scalefac_compress; + + + + if ((((info->mode_ext &1)) && (ch == 1))) + { + /* intensity_scale = scalefac_comp %2; */ + int_scalefac_comp = scalefac_comp >> 1; + + if (int_scalefac_comp < 180) + { + new_slen[0] = int_scalefac_comp / 36; + new_slen[1] = (int_scalefac_comp % 36) / 6; + new_slen[2] = int_scalefac_comp % 6; + blocknumber = 3; + } + else if (int_scalefac_comp < 244) + { + int_scalefac_comp -= 180; + new_slen[0] = (int_scalefac_comp & 63) >> 4; + new_slen[1] = (int_scalefac_comp & 15) >> 2; + new_slen[2] = int_scalefac_comp & 3; + blocknumber = 4; + } + else if (int_scalefac_comp <= 255) + { + int_scalefac_comp -= 244; + new_slen[0] = (int_scalefac_comp) / 3; + new_slen[1] = (int_scalefac_comp) % 3; + new_slen[2] = 0; + blocknumber = 5; + } + new_slen[3] = 0; + si->ch[ch].gran[gr].preflag = 0; + } + else + { + if (scalefac_comp < 400) + { + new_slen[0] = (scalefac_comp >> 4) / 5; + new_slen[1] = (scalefac_comp >> 4) % 5; + new_slen[2] = (scalefac_comp & 15) >> 2 ; + new_slen[3] = (scalefac_comp & 3); + si->ch[ch].gran[gr].preflag = 0; + + blocknumber = 0; + } + else if (scalefac_comp < 500) + { + scalefac_comp -= 400; + new_slen[0] = (scalefac_comp >> 2) / 5; + new_slen[1] = (scalefac_comp >> 2) % 5; + new_slen[2] = scalefac_comp & 3; + new_slen[3] = 0; + si->ch[ch].gran[gr].preflag = 0; + blocknumber = 1; + } + else if (scalefac_comp < 512) + { + scalefac_comp -= 500; + new_slen[0] = scalefac_comp / 3; + new_slen[1] = scalefac_comp % 3; + new_slen[2] = 0 ; + new_slen[3] = 0; + si->ch[ch].gran[gr].preflag = 1; + blocknumber = 2; + } + } + + if (gr_info->block_type == 2) + { + if (gr_info->mixed_block_flag) + { + blocktypenumber = 2; + } + else + { + blocktypenumber = 1; + } + } + + k = 0; + for (i = 0; i < 4; i++) + { + if (new_slen[i]) + { + for (j = 0; j < (int16)nr_of_sfb_block[blocknumber][blocktypenumber][i]; j++) + { + scalefac_buffer[k] = getNbits(pMainData, new_slen[i]); + scalefac_IIP_buffer[k] = (1L << new_slen[i]) - 1; + k++; + } + } + else + { + for (j = 0; j < (int16)nr_of_sfb_block[blocknumber][blocktypenumber][i]; j++) + { + scalefac_buffer[k] = 0; + scalefac_IIP_buffer[k] = 0; + k++; + } + } + } +} diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.h new file mode 100644 index 0000000..630ed61 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.h @@ -0,0 +1,105 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_get_scale_data.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_MPEG2_GET_SCALE_DATA_H +#define PVMP3_MPEG2_GET_SCALE_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_mpeg2_get_scale_data(mp3SideInfo *si, + int32 gr, + int32 ch, + mp3Header *info, + uint32 *scalefac_buffer, + uint32 *scalefac_IIP_buffer, + tmp3Bits *pMainData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.cpp new file mode 100644 index 0000000..e4d29d6 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.cpp @@ -0,0 +1,202 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_get_scale_factors.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + + mp3ScaleFactors *scalefac, + mp3SideInfo *si, side information + int32 gr, granule + int32 ch, channel + mp3Header *info, mp3 header information + uint32 *scalefac_IIP_buffer, auxiliary scale data + tbits *pMainData bit stream Data + + Returns + + III_scalefac_t *scalefac, scale factor + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + get scale factor for mpe2 layer III LSF extension + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_mpeg2_get_scale_factors.h" +#include "pvmp3_mpeg2_get_scale_data.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_mpeg2_get_scale_factors(mp3ScaleFactors *scalefac, + mp3SideInfo *si, + int32 gr, + int32 ch, + mp3Header *info, + uint32 *scalefac_IIP_buffer, + tmp3Bits *pMainData) +{ + + int32 sfb; + int32 k = 0; + int32 window; + uint32 *scalefac_buffer = &scalefac_IIP_buffer[56]; + + granuleInfo *gr_info = &(si->ch[ch].gran[gr]); + + pvmp3_mpeg2_get_scale_data(si, + gr, + ch, + info, + (uint32 *)scalefac_buffer, + (uint32 *)scalefac_IIP_buffer, + pMainData); + + + if (gr_info->window_switching_flag && (gr_info->block_type == 2)) + { + if (gr_info->mixed_block_flag) + { + for (sfb = 0; sfb < 6; sfb++) + { + scalefac->l[sfb] = scalefac_buffer[sfb]; + } + + + k = 6; + for (sfb = 3; sfb < 12; sfb++) + { + for (window = 0; window < 3; window++) + { + scalefac->s[window][sfb] = scalefac_buffer[k]; + k++; + } + } + + + /* adjust position of "illegal position" information in scalefac_IIP_buffer[] */ + /* in mixed blocks mode for short sfb, move them 3 places up. efs 3002-07-04 */ + for (sfb = 11; sfb >= 3; sfb--) + { + scalefac_IIP_buffer[3*sfb + 2] = scalefac_IIP_buffer[3*sfb - 1]; + scalefac_IIP_buffer[3*sfb + 1] = scalefac_IIP_buffer[3*sfb - 2]; + scalefac_IIP_buffer[3*sfb ] = scalefac_IIP_buffer[3*sfb - 3]; + + } + } + else + { /* SHORT*/ + for (sfb = 0; sfb < 12; sfb++) + { + for (window = 0; window < 3; window++) + { + scalefac->s[window][sfb] = scalefac_buffer[k]; + k++; + } + } + } + + scalefac->s[0][12] = 0; + scalefac->s[1][12] = 0; + scalefac->s[2][12] = 0; + + } + else + { /* LONG types 0,1,3 */ + for (sfb = 0; sfb < 21; sfb++) + { + scalefac->l[sfb] = scalefac_buffer[sfb]; + } + scalefac->l[21] = 0; + scalefac->l[22] = 0; + + } +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.h new file mode 100644 index 0000000..46d16b3 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.h @@ -0,0 +1,105 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_get_scale_factors.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_MPEG2_GET_SCALE_FACTORS_H +#define PVMP3_MPEG2_GET_SCALE_FACTORS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" +#include "s_mp3bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_mpeg2_get_scale_factors(mp3ScaleFactors *scalefac, + mp3SideInfo *si, + int32 gr, + int32 ch, + mp3Header *info, + uint32 *scalefac_IIP_buffer, + tmp3Bits *pMainData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp new file mode 100644 index 0000000..c79062c --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp @@ -0,0 +1,700 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_stereo_proc.cpp + + Functions: + + pvmp3_st_intensity_ver2 + pvmp3_mpeg2_stereo_proc + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + + +------------------------------------------------------------------------------ + +pvmp3_st_intensity_ver2 + + INPUT AND OUTPUT DEFINITIONS + +Input + + int32 xr[], input channel + int32 xl[], + int32 m, selecting index: io = 2(1/4) (m=0), io = 2(1/8) (m=1) + int32 is_pos, index on table is_pos_pow_eitgh_root_of_2 + int32 Start, Location of first element where stereo intensity is applied + int32 Number number of elements affected + + Returns + + int32 xl[], generated stereo channel + + + + +------------------------------------------------------------------------------ + +pvmp3_mpeg2_stereo_proc + + INPUT AND OUTPUT DEFINITIONS + +Input + + int32 xr[], input channel + int32 xl[], + mp3ScaleFactors *scalefac, scale factors structure for Right channel + granuleInfo *gr_info_l, granule structure for the left channel + granuleInfo *gr_info_r, granule structure for the rigth channel + uint32 *scalefac_IIP_buffer, auxiliary scale factor vector + mp3Header *info mp3 header info + Returns + + int32 xl[], generated stereo channel + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + stereo processing for mpeg2 layer III LSF extension + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_mpeg2_stereo_proc.h" +#include "pvmp3_stereo_proc.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_tables.h" +#include "mp3_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*a)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const int32 is_pos_pow_eitgh_root_of_2[8] = +{ + /* --- 2^(1/8) ----- */ + Q31_fmt(1.00000000000000), Q31_fmt(0.91700404320467), Q31_fmt(0.84089641525371), + Q31_fmt(0.77110541270397), Q31_fmt(0.70710678118655), Q31_fmt(0.64841977732550), + Q31_fmt(0.59460355750136), Q31_fmt(0.54525386633263) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_st_intensity_ver2(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 m, + int32 is_pos, + int32 Start, + int32 Number) +{ + int32 k[2]; + + /* pow(io, ((is_pos + 1)>>1)); io = 2(1/4) (m=0), io = 2(1/8) (m=1) */ + k[0] = is_pos_pow_eitgh_root_of_2[((is_pos+1)&(3+(m<<2)))<<(1-m)] >> ((is_pos + 1) >> (2 + m)); + /* pow(io, (is_pos>>1)); io = 2(1/4) (m=0), io = 2(1/8) (m=1) */ + k[1] = is_pos_pow_eitgh_root_of_2[(is_pos&(3+(m<<2)))<<(1-m)] >> (is_pos >> (2 + m)); + + + int32 *pt_xr = &xr[Start]; + int32 *pt_xl = &xl[Start]; + + if (is_pos == 0) /* 0 < is_pos < 31 */ + { + pv_memcpy(pt_xl, pt_xr, Number*sizeof(*pt_xr)); + } + else if (is_pos & 1) + { + for (int32 i = Number >> 1; i != 0; i--) + { + *(pt_xl++) = (*pt_xr); + *(pt_xr) = fxp_mul32_Q32((*pt_xr) << 1, k[0]); + pt_xr++; + *(pt_xl++) = (*pt_xr); + *(pt_xr) = fxp_mul32_Q32((*pt_xr) << 1, k[0]); + pt_xr++; + } + if (Number&1) + { + *(pt_xl) = (*pt_xr); + *(pt_xr) = fxp_mul32_Q32((*pt_xr) << 1, k[0]); + } + } + else + { + for (int32 i = Number >> 1; i != 0; i--) + { + *(pt_xl++) = fxp_mul32_Q32((*(pt_xr++)) << 1, k[1]); + *(pt_xl++) = fxp_mul32_Q32((*(pt_xr++)) << 1, k[1]); + } + if (Number&1) + { + *(pt_xl) = fxp_mul32_Q32((*pt_xr) << 1, k[1]); + } + } + +} + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void pvmp3_mpeg2_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac_R, + granuleInfo *gr_info_l, + granuleInfo *gr_info_r, + uint32 *scalefac_IIP_buffer, + int32 used_freq_lines, + mp3Header *info) +{ + + int32 sfreq; + int32 sb; + int32 ss; + int32 sfbNo; + int32 sfbStart; + int32 sfb; + int32 sfbTemp; + int32 i; + int32 j; + int32 io; + + + int32 i_stereo = (info->mode == MPG_MD_JOINT_STEREO) && + (info->mode_ext & 0x1); + + int32 ms_stereo = (info->mode == MPG_MD_JOINT_STEREO) && + (info->mode_ext & 0x2); + + + if (i_stereo) + { + if (gr_info_r->scalefac_compress & 1) + { + io = 0; /* 2^(-1/4) */ + } + else + { + io = 1; /* 2^(-1/8) */ + } + + sfreq = info->version_x + (info->version_x << 1); + sfreq += info->sampling_frequency; + + if (gr_info_l->window_switching_flag && (gr_info_l->block_type == 2)) + { + if (gr_info_l->mixed_block_flag) + { + /* + * mixed blocks processing + */ + i = 31; + ss = 17; + sb = -1; + + while (i >= 0) + { + if (xl[(i*FILTERBANK_BANDS) + ss]) + { + sb = (i << 4) + (i << 1) + ss; + i = -1; + } + else + { + ss--; + if (ss < 0) + { + i--; + ss = 17; + } + } + } /* now sb is the number of highest line with value != 0 */ + /* can be between -1 (all lines zero) and 575 (no line zero) */ + + if (sb < 36) /* was (sb <= 36) */ + { + /* + * mixed blocks processing: intensity bound inside long blocks + */ + /* 1. long blocks up to intensity border: Stereo or M/S */ + if (mp3_sfBandIndex[sfreq].l[4] <= sb) + { + i = 4; + } + else + { + i = 0; + } + + while (mp3_sfBandIndex[sfreq].l[i] <= sb) + { + i++; + } + sfbTemp = i; /* from that (long) sfb on we have intensity stereo */ + + sfbNo = mp3_sfBandIndex[sfreq].l[sfbTemp]; /* number of lines to process */ + + /* from sfbStart up sfbNo lines do ms_stereo or normal stereo */ + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, sfbNo); + } + + /* 2. long blocks from intensity border up to sfb band 6: intensity */ + /* calc. MPEG_1_2_Factor[0], MPEG_1_2_Factor[1] */ + + for (sfb = sfbTemp; sfb < 6; sfb++) + { + sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; /* = Start in 0 ... 575 */ + sfbNo = mp3_sfBandIndex[sfreq].l[sfb+1] - mp3_sfBandIndex[sfreq].l[sfb]; /* No of lines to process */ + + if ((uint32)(scalefac_R->l[sfb]) != scalefac_IIP_buffer[sfb]) + { + pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->l[sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + + /* 3. now process all sfb with short blocks (3...12), all in intensity mode */ + + for (j = 0; j < 3; j++) + { + /* first calculate directional factors for intensity stereo, + * for all sfb in intensity mode, but only + * if they do not have "illegal" position: + */ + /* to do this for all sfb we have to get information for last scale factor band: + * here we clearly have more than one sfb in intensity mode, + * so copy factors and legal/illegal information from sfb11 to sfb12 + */ + (scalefac_R->s[j][12]) = (scalefac_R->s[j][11]); + scalefac_IIP_buffer[36 + j] = scalefac_IIP_buffer[33 + j]; /* legal/illegal in sfb 12 same as in sfb 11 */ + + for (sfb = 3; sfb < 13; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo; + + if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j]) + { + pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + } /* for (j = 0; j < 3; j++) */ + } + else /* else then (sb >= 36) */ + { + /* + * mixed blocks processing: intensity bound outside long blocks + */ + + /* 2. short blocks, do for all 3 */ + /* ------------------------------ */ + for (j = 0; j < 3; j++) + { + int32 sfbcnt = -1; + + for (sfb = 12; sfb >= 3; sfb--) + { + int32 lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + + i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1; + + while (lines > 0) + { + if (xl[i]) + { + sfbcnt = sfb; + sfb = -10; + lines = -10; + } + lines--; + i--; + } + } + + sfbcnt += 1; + if (sfbcnt < 3) + { + sfbcnt = 3; /* should not be necessary */ + } + + sfbTemp = sfbcnt; /* from this (short) sfb on we have intensity mode */ + /* can have values between 3 (all short sfb in intensity) */ + /* and 13 (no short sfb in intensity mode) */ + + /* 3. from sfbTemp to last sfb calculate is_ratio values: */ + /* first calculate directional factors for intensity stereo, */ + /* for all sfb in intensity mode, but only */ + /* if they do not have "illegal" position: */ + + /* to do this for all sfb we have to get information for last scale factor band: */ + /* get factors for last scale factor band: */ + /* more than one sfb in intensity mode, + copy factors and legal/illegal information from sfb11 to sfb12 */ + if (sfbTemp < 12) + { + (scalefac_R->s[j][12]) = (scalefac_R->s[j][11]); + scalefac_IIP_buffer[36 + j] = scalefac_IIP_buffer[33 + j]; /* legal/illegal in sfb 12 same as in sfb 11 */ + } + else if (sfbTemp == sfb) + /* only sfb 12 in intensity mode, use factors corresponding to is_pos[12] == 0 */ + { + (scalefac_R->s[j][12]) = 0; + scalefac_IIP_buffer[36 + j] = 1; /* the scf value 0 in sfb12 is "legal" */ + } + /* if sfbTemp > sfb (no sfb in intensity mode): do nothing */ + + + /* 4. do normal stereo or MS stereo from sfb 3 to < sfbTemp: */ + for (sfb = 3; sfb < sfbTemp; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + + /* 5. now intensity stereo processing of the remaining sfb's: */ + + for (sfb = sfbTemp; sfb < 13; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo; + if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j]) + { + pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + /* end of correction by efs 2003-07-04 */ + } /* for (j = 0; j < 3; j++) */ + + + /* long blocks 0 up to sfb band 6: no intensity */ + + sfbNo = mp3_sfBandIndex[sfreq].l[6]; /* number of lines to process */ + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, sfbNo); + } + + } /* if intensity bound inside or outside long blocks */ + } /* if (gr_info->mixed_block_flag) */ + else + { + /* + * short block processing + */ + for (j = 0; j < 3; j++) + { + int32 sfbcnt = -1; + + for (sfb = 12; sfb >= 0; sfb--) + { + int32 lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1; + + while (lines > 0) + { + if (xl[i]) + { + sfbcnt = sfb; + sfb = -10; + lines = -10; + } + lines--; + i--; + } + } + + sfbcnt += 1; + + /* start of corrected version by efs 2003-07-04 */ + sfbTemp = sfbcnt; /* from this (short) sfb on we have intensity mode */ + /* can have values between 3 (all short sfb in intensity) */ + /* and 13 (no short sfb in intensity mode) */ + + /* first calculate directional factors for intensity stereo, + for all sfb in intensity mode, but only + if they do not have "illegal" position: */ + + /* to do this for all sfb we have to get information for last scale factor band: */ + /* get factors for last scale factor band: */ + /* more than one sfb in intensity mode, + copy factors and legal/illegal information from sfb11 to sfb12 */ + if (sfbTemp < 12) + { + (scalefac_R->s[j][12]) = (scalefac_R->s[j][11]); + scalefac_IIP_buffer[36 + j] = scalefac_IIP_buffer[33 + j]; /* legal/illegal in sfb 12 same as in sfb 11 */ + } + else if (sfbTemp == 12) + /* only sfb 12 in intensity mode, use factors corresponding to is_pos[12] == 0 */ + { + (scalefac_R->s[j][12]) = 0; + scalefac_IIP_buffer[36 + j] = 1; /* the scf value 0 in sfb12 is "legal" */ + } + /* if sfbTemp > sfb (no sfb in intensity mode): do nothing */ + + + /* Now process audio samples */ + /* first process lower sfb's not in intensity mode */ + for (sfb = 0; sfb < sfbTemp; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + + /* now intensity stereo processing of the remaining sfb's: */ + for (sfb = sfbTemp; sfb < 13; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo; + + if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j]) + { + pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + + } /* for (j = 0; j < 3; j++) */ + + } /* end of else ( gr_info->mixed_block_flag) */ + + } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */ + else + { + /* + * long block processing + */ + i = 31; + ss = 17; + sb = 0; + + while (i >= 0) + { + if (xl[(i*FILTERBANK_BANDS) + ss]) + { + sb = (i << 4) + (i << 1) + ss; + /* i = -1 patched RF 24-09-2002 */ + i = -2; + } + else + { + ss--; + if (ss < 0) + { + i--; + ss = 17; + } + } + } + + /* patched RF 24-09-2002 */ + if (sb) + { + if (mp3_sfBandIndex[sfreq].l[14] <= sb) + { + i = 14; + } + else if (mp3_sfBandIndex[sfreq].l[7] <= sb) + { + i = 7; + } + else + { + i = 0; + } + + while (mp3_sfBandIndex[sfreq].l[i] <= sb) + { + i++; + } + } + + else + { + if (i == -1) + { + /* all xr[1][][] are 0: set IS bound sfb to 0 */ + i = 0; + } + else + { + /* xr[1][0][0] is unequal 0 and all others are 0: set IS bound sfb to 1 */ + i = 1; + } + } + /* corrected version by efs 2003-07-04 */ + sfbTemp = i; /* from this (long) sfb on we have intensity mode */ + /* can have values between 0 (all long sfb in intensity) */ + /* and 22 (no long sfb in intensity mode) */ + + /* first calculate directional factors for intensity stereo, + for all sfb in intensity mode, but only if they + do not have "illegal" position: */ + + /* to do this for all sfb we have to get information for last scale factor band: */ + if (sfbTemp < 21) + /* more than one sfb in intensity mode, */ + /* copy factors and legal/illegal information from sfb20 to sfb21 */ + { + (scalefac_R->l[21]) = (scalefac_R->l[20]); + scalefac_IIP_buffer[21] = scalefac_IIP_buffer[20]; /* legal/illegal in sfb 21 same as in sfb 20 */ + } + else if (sfbTemp == 21) + /* only sfb 21 in intensity mode, is_pos[21] = 0 */ + { + (scalefac_R->l[21]) = 0; + scalefac_IIP_buffer[21] = 1; /* the scf value 0 in sfb21 is "legal" */ + } + /* if sfbTemp > 21 (no sfb in intensity mode): do nothing */ + + + /* Now process audio samples */ + /* first process lower sfb's not in intensity mode */ + + sfbNo = mp3_sfBandIndex[sfreq].l[sfbTemp] - mp3_sfBandIndex[sfreq].l[0]; + sfbStart = mp3_sfBandIndex[sfreq].l[0]; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + /* now intensity stereo processing of the remaining sfb's: */ + for (sfb = sfbTemp; sfb < 22; sfb++) + { + sfbNo = mp3_sfBandIndex[sfreq].l[sfb+1] - mp3_sfBandIndex[sfreq].l[sfb]; /* number of lines to process */ + sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; /* start of sfb */ + + if ((uint32)(scalefac_R->l[sfb]) != scalefac_IIP_buffer[sfb]) /* "legal" position ? */ + { + pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->l[sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (sfb = sfbTemp; sfb < 22; sfb++) */ + + } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */ + + } /* if (i_stereo) */ + else + { + /* + * normal or ms stereo processing + */ + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, used_freq_lines); + } + + } /* if (i_stereo) */ + +} + + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.h new file mode 100644 index 0000000..7db0c53 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.h @@ -0,0 +1,112 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_mpeg2_stereo_proc.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_MPEG2_STEREO_PROC_H +#define PVMP3_MPEG2_STEREO_PROC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_mpeg2_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, + granuleInfo *gr_info_l, + granuleInfo *gr_info_r, + uint32 *scalefac_IIP_buffer, + int32 used_freq_lines, + mp3Header *info); + + + void pvmp3_st_intensity_ver2(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 m, + int32 is_pos, + int32 Start, + int32 Number); +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_normalize.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_normalize.cpp new file mode 100644 index 0000000..e579bbd --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_normalize.cpp @@ -0,0 +1,173 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_normalize.cpp + + Date: 10/02/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + Int32 x 32-bit integer non-zero input +Returns + Int32 i number of leading zeros on x + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Returns number of leading zeros on the non-zero input + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "pvmp3_normalize.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +#if (defined(PV_ARM_V5)||defined(PV_ARM_V4)) +#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4)) + + +/* function is inlined in header file */ + + +#else + +int32 pvmp3_normalize(int32 x) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + int32 i; + + + if (x > 0x0FFFFFFF) + { + i = 0; /* most likely case */ + } + else if (x > 0x00FFFFFF) + { + i = 3; /* second most likely case */ + } + else if (x > 0x0000FFFF) + { + i = x > 0x000FFFFF ? 7 : 11; + } + else + { + if (x > 0x000000FF) + { + i = x > 0x00000FFF ? 15 : 19; + } + else + { + i = x > 0x0000000F ? 23 : 27; + } + } + + + x <<= i; + + switch (x & 0x78000000) + { + case 0x08000000: + i += 3; + break; + + case 0x18000000: + case 0x10000000: + i += 2; + break; + case 0x28000000: + case 0x20000000: + case 0x38000000: + case 0x30000000: + i++; + + default: + ; + } + + return i; + +} + +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_normalize.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_normalize.h new file mode 100644 index 0000000..5471771 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_normalize.h @@ -0,0 +1,108 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_normalize.h + + Date: 10/02/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PVMP3_NORMALIZE_H +#define PVMP3_NORMALIZE_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +#if (defined(PV_ARM_V5)||defined(PV_ARM_V4)) + +__inline int32 pvmp3_normalize(int32 x) +{ + int32 y; + __asm + { + clz y, x; + sub y, y, #1 + } + return (y); +} + + +#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4)) + +__inline int32 pvmp3_normalize(int32 x) +{ + register int32 y; + register int32 ra = x; + + + asm volatile( + "clz %0, %1\n\t" + "sub %0, %0, #1" + : "=&r*i"(y) + : "r"(ra)); + return (y); + +} + +#else + +#ifdef __cplusplus +extern "C" +{ +#endif + + int32 pvmp3_normalize(int32 x); + +#ifdef __cplusplus +} +#endif + +#endif + + + +#endif /* PV_NORMALIZE_H */ diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.cpp new file mode 100644 index 0000000..33c8e61 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.cpp @@ -0,0 +1,187 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_poly_phase_synthesis.cpp + + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Input + tmp3dec_chan *pChVars, decoder state structure per channel + int32 numChannels, number of channels + e_equalization equalizerType, equalization mode + int16 *outPcm pointer to the PCM output data + + Output + int16 *outPcm pointer to the PCM output data + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + polyphase synthesis + Each time the subband samples for all 32 polyphase subbands of one + channel have been calculated, they can be applied to the synthesis + subband filter and 32 consecutive audio samples can be calculated + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_poly_phase_synthesis.h" +#include "pvmp3_polyphase_filter_window.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_dct_16.h" +#include "pvmp3_equalizer.h" +#include "mp3_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_poly_phase_synthesis(tmp3dec_chan *pChVars, + int32 numChannels, + e_equalization equalizerType, + int16 *outPcm) +{ + /* + * Equalizer + */ + pvmp3_equalizer(pChVars->circ_buffer, + equalizerType, + pChVars->work_buf_int32); + + + int16 * ptr_out = outPcm; + + + for (int32 band = 0; band < FILTERBANK_BANDS; band += 2) + { + int32 *inData = &pChVars->circ_buffer[544 - (band<<5)]; + + /* + * DCT 32 + */ + + pvmp3_split(&inData[16]); + + pvmp3_dct_16(&inData[16], 0); + pvmp3_dct_16(inData, 1); // Even terms + + pvmp3_merge_in_place_N32(inData); + + pvmp3_polyphase_filter_window(inData, + ptr_out, + numChannels); + + inData -= SUBBANDS_NUMBER; + + /* + * DCT 32 + */ + + pvmp3_split(&inData[16]); + + pvmp3_dct_16(&inData[16], 0); + pvmp3_dct_16(inData, 1); // Even terms + + pvmp3_merge_in_place_N32(inData); + + pvmp3_polyphase_filter_window(inData, + ptr_out + (numChannels << 5), + numChannels); + + ptr_out += (numChannels << 6); + + inData -= SUBBANDS_NUMBER; + + }/* end band loop */ + + pv_memmove(&pChVars->circ_buffer[576], + pChVars->circ_buffer, + 480*sizeof(*pChVars->circ_buffer)); + +} + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.h new file mode 100644 index 0000000..166cffd --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_poly_phase_synthesis.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_POLY_PHASE_SYNTHESIS_H +#define PVMP3_POLY_PHASE_SYNTHESIS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "s_tmp3dec_chan.h" +#include "pvmp3decoder_api.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_poly_phase_synthesis(tmp3dec_chan *pChVars, + int32 numChannels, + e_equalization equalizerType, + int16 *outPcm); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_polyphase_filter_window.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_polyphase_filter_window.cpp new file mode 100644 index 0000000..8380437 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_polyphase_filter_window.cpp @@ -0,0 +1,239 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_polyphase_filter_window.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + +Input + int32 *synth_buffer, synthesis input buffer + int16 *outPcm, generated output ( 32 values) + int32 numChannels number of channels + Returns + + int16 *outPcm + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + apply polyphase filter window + Input 32 subband samples + Calculate 64 values +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) ) +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_polyphase_filter_window.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_tables.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module1 specific macros here +----------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module1 +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module_x +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module_x but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_polyphase_filter_window(int32 *synth_buffer, + int16 *outPcm, + int32 numChannels) +{ + int32 sum1; + int32 sum2; + const int32 *winPtr = pqmfSynthWin; + int32 i; + + + for (int16 j = 1; j < SUBBANDS_NUMBER / 2; j++) + { + sum1 = 0x00000020; + sum2 = 0x00000020; + + + for (i = (SUBBANDS_NUMBER >> 1); + i < HAN_SIZE + (SUBBANDS_NUMBER >> 1); + i += SUBBANDS_NUMBER << 4) + { + int32 *pt_1 = &synth_buffer[ i+j]; + int32 *pt_2 = &synth_buffer[ i-j]; + int32 temp1 = pt_1[ 0]; + int32 temp3 = pt_2[ SUBBANDS_NUMBER*15 ]; + int32 temp2 = pt_2[ SUBBANDS_NUMBER* 1 ]; + int32 temp4 = pt_1[ SUBBANDS_NUMBER*14 ]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[ 0]); + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[ 0]); + sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[ 1]); + sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[ 1]); + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[ 2]); + sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[ 2]); + sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[ 3]); + sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[ 3]); + + temp1 = pt_1[ SUBBANDS_NUMBER* 2]; + temp3 = pt_2[ SUBBANDS_NUMBER*13]; + temp2 = pt_2[ SUBBANDS_NUMBER* 3]; + temp4 = pt_1[ SUBBANDS_NUMBER*12]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[ 4]); + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[ 4]); + sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[ 5]); + sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[ 5]); + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[ 6]); + sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[ 6]); + sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[ 7]); + sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[ 7]); + + temp1 = pt_1[ SUBBANDS_NUMBER* 4 ]; + temp3 = pt_2[ SUBBANDS_NUMBER*11 ]; + temp2 = pt_2[ SUBBANDS_NUMBER* 5 ]; + temp4 = pt_1[ SUBBANDS_NUMBER*10 ]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[ 8]); + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[ 8]); + sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[ 9]); + sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[ 9]); + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[10]); + sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[10]); + sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[11]); + sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[11]); + + temp1 = pt_1[ SUBBANDS_NUMBER*6 ]; + temp3 = pt_2[ SUBBANDS_NUMBER*9 ]; + temp2 = pt_2[ SUBBANDS_NUMBER*7 ]; + temp4 = pt_1[ SUBBANDS_NUMBER*8 ]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[12]); + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[12]); + sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[13]); + sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[13]); + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[14]); + sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[14]); + sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[15]); + sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[15]); + + winPtr += 16; + } + + + + int32 k = j << (numChannels - 1); + outPcm[k] = saturate16(sum1 >> 6); + outPcm[(numChannels<<5) - k] = saturate16(sum2 >> 6); + } + + + + sum1 = 0x00000020; + sum2 = 0x00000020; + + + for (i = 16; i < HAN_SIZE + 16; i += (SUBBANDS_NUMBER << 2)) + { + int32 *pt_synth = &synth_buffer[i]; + int32 temp1 = pt_synth[ 0 ]; + int32 temp2 = pt_synth[ SUBBANDS_NUMBER ]; + int32 temp3 = pt_synth[ SUBBANDS_NUMBER/2]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[0]) ; + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[1]) ; + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[2]) ; + + temp1 = pt_synth[ SUBBANDS_NUMBER<<1 ]; + temp2 = pt_synth[ 3*SUBBANDS_NUMBER ]; + temp3 = pt_synth[ SUBBANDS_NUMBER*5/2]; + + sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[3]) ; + sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[4]) ; + sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[5]) ; + + winPtr += 6; + } + + + outPcm[0] = saturate16(sum1 >> 6); + outPcm[(SUBBANDS_NUMBER/2)<<(numChannels-1)] = saturate16(sum2 >> 6); + + +} + +#endif // If not assembly + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_polyphase_filter_window.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_polyphase_filter_window.h new file mode 100644 index 0000000..b9eccad --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_polyphase_filter_window.h @@ -0,0 +1,138 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_decode_header.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_POLYPHASE_FILTER_WINDOW_H +#define PVMP3_POLYPHASE_FILTER_WINDOW_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_audio_type_defs.h" +#include "s_tmp3dec_chan.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define MAX_16BITS_INT 0x7FFF + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#if (defined(PV_ARM_V5)||defined(PV_ARM_V4)) + + + __inline int16 saturate16(int32 sample) + { + int32 a; + int32 b = 31; + __asm + { + mov a, sample, asr#15 + teq a, sample, asr b + eorne sample, MAX_16BITS_INT, sample, asr#31 + } + return sample ; + } + +#else + + inline int16 saturate16(int32 sample) + { + + if ((sample >> 15) ^(sample >> 31)) + { + sample = MAX_16BITS_INT ^(sample >> 31); + } + return sample; + + } +#endif + + + void pvmp3_polyphase_filter_window(int32 *synth_buffer, + int16 *outPcm, + int32 numChannels); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_reorder.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_reorder.cpp new file mode 100644 index 0000000..35b6475 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_reorder.cpp @@ -0,0 +1,197 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_reorder.cpp + + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + int32 xr[ ], rescaled data + struct gr_info_s *gr_info, granule structure + mp3Header *info, mp3 header info + int32 Scratch_mem[168] for temporary usage + + Outputs: + + int32 xr[ ], reordered data + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + If short blocks are used (block_type[gr][ch]=='10'), the rescaled data + xr[scf_band][window][freq_line] shall be reordered in polyphase subband + order, xr[subband][window][freq_line], prior to the IMDCT operation. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_dec_defs.h" +#include "pvmp3_reorder.h" +#include "pvmp3_tables.h" +#include "mp3_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_reorder(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + granuleInfo *gr_info, + int32 *used_freq_lines, + mp3Header *info, + int32 Scratch_mem[168]) +{ + int32 sfreq = info->version_x + (info->version_x << 1); + sfreq += info->sampling_frequency; + + if (gr_info->window_switching_flag && (gr_info->block_type == 2)) + { + int32 sfb_lines; + int32 freq; + int32 src_line; + int32 sfb; + if (gr_info->mixed_block_flag) + { + /* REORDERING FOR REST SWITCHED SHORT */ + sfb = 3; /* no reorder for low 2 subbands */ + src_line = 36; + } + else + { /* pure short */ + sfb = 0; + src_line = 0; + } + int16 ct = src_line; + + for (; sfb < 13; sfb++) + { + if (*used_freq_lines > 3*mp3_sfBandIndex[sfreq].s[sfb+1]) + { + sfb_lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + + for (freq = 0; freq < 3*sfb_lines; freq += 3) + { + int32 tmp1 = xr[src_line]; + int32 tmp2 = xr[src_line+(sfb_lines)]; + int32 tmp3 = xr[src_line+(sfb_lines<<1)]; + src_line++; + Scratch_mem[freq ] = tmp1; + Scratch_mem[freq+1] = tmp2; + Scratch_mem[freq+2] = tmp3; + } + src_line += (sfb_lines << 1); + + pv_memcpy(&xr[ct], Scratch_mem, sfb_lines*3*sizeof(int32)); + ct += sfb_lines + (sfb_lines << 1); + + } + else + { + + sfb_lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + + for (freq = 0; freq < 3*sfb_lines; freq += 3) + { + int32 tmp1 = xr[src_line]; + int32 tmp2 = xr[src_line+(sfb_lines)]; + int32 tmp3 = xr[src_line+(sfb_lines<<1)]; + src_line++; + Scratch_mem[freq ] = tmp1; + Scratch_mem[freq+1] = tmp2; + Scratch_mem[freq+2] = tmp3; + } + + pv_memcpy(&xr[ct], Scratch_mem, sfb_lines*3*sizeof(int32)); + + *used_freq_lines = mp3_sfBandIndex[sfreq].s[sfb+1] * 3; + + sfb = 13; /* force out of the for-loop */ + } + } + } +} + + + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_reorder.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_reorder.h new file mode 100644 index 0000000..ba6ec16 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_reorder.h @@ -0,0 +1,103 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_reorder.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_REORDER_H +#define PVMP3_REORDER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pvmp3_reorder(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + granuleInfo *gr_info, + int32 *used_freq_lines, + mp3Header *info, + int32 Scratch_mem[168]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_seek_synch.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_seek_synch.cpp new file mode 100644 index 0000000..82faafd --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_seek_synch.cpp @@ -0,0 +1,308 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_seek_synch.cpp + + Functions: + pvmp3_seek_synch + pvmp3_header_sync + + + Date: 9/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +pvmp3_frame_synch + +Input + pExt = pointer to the external interface structure. See the file + pvmp3decoder_api.h for a description of each field. + Data type of pointer to a tPVMP3DecoderExternal + structure. + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tmp3dec_file structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tmp3dec_file + structure. + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + search mp3 sync word, when found, it verifies, based on header parameters, + the locations of the very next sync word, + - if fails, then indicates a false sync, + - otherwise, it confirm synchronization of at least 2 consecutives frames + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_seek_synch.h" +#include "pvmp3_getbits.h" +#include "s_tmp3dec_file.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_tables.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +ERROR_CODE pvmp3_frame_synch(tPVMP3DecoderExternal *pExt, + void *pMem) /* bit stream structure */ +{ + uint16 val; + ERROR_CODE err; + + tmp3dec_file *pVars; + + pVars = (tmp3dec_file *)pMem; + + pVars->inputStream.pBuffer = pExt->pInputBuffer; + pVars->inputStream.usedBits = (pExt->inputBufferUsedLength << 3); // in bits + + + pVars->inputStream.inputBufferCurrentLength = (pExt->inputBufferCurrentLength); // in bits + + err = pvmp3_header_sync(&pVars->inputStream); + + if (err == NO_DECODING_ERROR) + { + /* validate synchronization by checking two consecutive sync words */ + + // to avoid multiple bitstream accesses + uint32 temp = getNbits(&pVars->inputStream, 21); + // put back whole header + pVars->inputStream.usedBits -= 21 + SYNC_WORD_LNGTH; + + int32 version; + + switch (temp >> 19) /* 2 */ + { + case 0: + version = MPEG_2_5; + break; + case 2: + version = MPEG_2; + break; + case 3: + version = MPEG_1; + break; + default: + version = INVALID_VERSION; + break; + } + + int32 freq_index = (temp << 20) >> 30; + + if (version != INVALID_VERSION && (freq_index != 3)) + { + int32 numBytes = fxp_mul32_Q28(mp3_bitrate[version][(temp<<16)>>28] << 20, + inv_sfreq[freq_index]); + + numBytes >>= (20 - version); + + if (version != MPEG_1) + { + numBytes >>= 1; + } + if ((temp << 22) >> 31) + { + numBytes++; + } + + if (numBytes > (int32)pVars->inputStream.inputBufferCurrentLength) + { + /* frame should account for padding and 2 bytes to check sync */ + pExt->CurrentFrameLength = numBytes + 3; + return (SYNCH_LOST_ERROR); + } + else if (numBytes == (int32)pVars->inputStream.inputBufferCurrentLength) + { + /* No enough data to validate, but current frame appears to be correct ( EOF case) */ + pExt->inputBufferUsedLength = pVars->inputStream.usedBits >> 3; + return (NO_DECODING_ERROR); + } + else + { + + int32 offset = pVars->inputStream.usedBits + ((numBytes) << 3); + + offset >>= INBUF_ARRAY_INDEX_SHIFT; + uint8 *pElem = pVars->inputStream.pBuffer + offset; + uint16 tmp1 = *(pElem++); + uint16 tmp2 = *(pElem); + + val = (tmp1 << 3); + val |= (tmp2 >> 5); + } + } + else + { + val = 0; // force mismatch + } + + if (val == SYNC_WORD) + { + pExt->inputBufferUsedLength = pVars->inputStream.usedBits >> 3; /// !!!!! + err = NO_DECODING_ERROR; + } + else + { + pExt->inputBufferCurrentLength = 0; + err = SYNCH_LOST_ERROR; + } + } + else + { + pExt->inputBufferCurrentLength = 0; + } + + return(err); + +} + +/* +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +pvmp3_header_sync + +Input + tmp3Bits *inputStream, structure holding the input stream parameters + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + search mp3 sync word + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +ERROR_CODE pvmp3_header_sync(tmp3Bits *inputStream) +{ + uint16 val; + uint32 availableBits = (inputStream->inputBufferCurrentLength << 3); // in bits + + // byte aligment + inputStream->usedBits = (inputStream->usedBits + 7) & 8; + + val = (uint16)getUpTo17bits(inputStream, SYNC_WORD_LNGTH); + + while (((val&SYNC_WORD) != SYNC_WORD) && (inputStream->usedBits < availableBits)) + { + val <<= 8; + val |= getUpTo9bits(inputStream, 8); + } + + if ((val&SYNC_WORD) == SYNC_WORD && (inputStream->usedBits < availableBits)) + { + return(NO_DECODING_ERROR); + } + else + { + return(SYNCH_LOST_ERROR); + } + +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_seek_synch.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_seek_synch.h new file mode 100644 index 0000000..8097cee --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_seek_synch.h @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_seek_synch.h + + Date: 09/21/2007 +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_SEEK_SYNCH_H +#define PVMP3_SEEK_SYNCH_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" +#include "pvmp3decoder_api.h" +#include "s_tmp3dec_file.h" +#include "pvmp3_dec_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + ERROR_CODE pvmp3_frame_synch(tPVMP3DecoderExternal *pExt, + void *pMem); + + ERROR_CODE pvmp3_header_sync(tmp3Bits *inputStream); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* DECODE_READ_INPUT_H */ + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.cpp new file mode 100644 index 0000000..d69a46d --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.cpp @@ -0,0 +1,676 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_stereo_proc.cpp + + Functions: + + pvmp3_st_mid_side + pvmp3_st_intensity + pvmp3_stereo_proc + +------------------------------------------------------------------------------ + +pvmp3_st_mid_side + + INPUT AND OUTPUT DEFINITIONS + +Input + + int32 xr[], input channel + int32 xl[], + int32 Start, Location of first element where stereo intensity is applied + int32 Number number of elements affected + + Returns + + int32 xl[], generated stereo channel + + +------------------------------------------------------------------------------ + +pvmp3_st_intensity + + INPUT AND OUTPUT DEFINITIONS + +Input + + int32 xr[], input channel + int32 xl[], + int32 is_pos, index to table is_ratio_factor[] + int32 Start, Location of first element where stereo intensity is applied + int32 Number number of elements affected + + Returns + + int32 xl[], generated stereo channel + + +------------------------------------------------------------------------------ + +pvmp3_stereo_proc + + INPUT AND OUTPUT DEFINITIONS + +Input + + int32 xr[], input channel + int32 xl[], + mp3ScaleFactors *scalefac, scale factors structure + struct gr_info_s *gr_info, granule structure + mp3Header *info mp3 header info + Returns + + int32 xl[], generated stereo channel + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + stereo processing for mpeg1 layer III + After requantization, the reconstructed values are processed for ms_stereo + or intensity_stereo modes or both, before passing them to the synthesis + filterbank + + In ms_stereo mode the values of the normalized middle/side channels + M[l] and S[l] are transmitted instead of the left/right channel values + L[l] and R[l]. From here, L[l] and R[l] are reconstructed + + Intensity_stereo is done by specifying the magnitude (via the + scalefactors of the left channel) and a stereo position is_pos[sfb], + which is transmitted instead of scalefactors of the right channel. + The stereo position is used to derive the left and right channel signals + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_stereo_proc.h" +#include "pv_mp3dec_fxd_op.h" +#include "pvmp3_tables.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define N31 31 + +#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*a)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/* + * TmpFac= tan(is_pos * (PI /12)); + * + * TmpFac /= (1 + TmpFac); + * + */ + +const int32 is_ratio_factor[8] = {0, + Q31_fmt(0.21132486540519), Q31_fmt(0.36602540378444), Q31_fmt(0.50000000000000), + Q31_fmt(0.63397459621556), Q31_fmt(0.78867513459481), Q31_fmt(1.00000000000000), + 0 + }; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_st_mid_side(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 Start, + int32 Number) +{ + + int32 *pt_xr = &xr[Start]; + int32 *pt_xl = &xl[Start]; + + for (int32 i = Number >> 1; i != 0; i--) + { + int32 xxr = *(pt_xr) << 1; + int32 xxl = *(pt_xl) << 1; + *(pt_xr++) = fxp_mul32_Q32((xxr + xxl), Q31_fmt(0.70710678118655)); /* Sum */ + *(pt_xl++) = fxp_mul32_Q32((xxr - xxl), Q31_fmt(0.70710678118655)); /* Diff */ + xxr = *(pt_xr) << 1; + xxl = *(pt_xl) << 1; + *(pt_xr++) = fxp_mul32_Q32((xxr + xxl), Q31_fmt(0.70710678118655)); /* Sum */ + *(pt_xl++) = fxp_mul32_Q32((xxr - xxl), Q31_fmt(0.70710678118655)); /* Diff */ + } + + + if (Number&1) + { + int32 xxr = *(pt_xr) << 1; + int32 xxl = *(pt_xl) << 1; + *(pt_xr) = fxp_mul32_Q32((xxr + xxl), Q31_fmt(0.70710678118655)); /* Sum */ + *(pt_xl) = fxp_mul32_Q32((xxr - xxl), Q31_fmt(0.70710678118655)); /* Diff */ + } + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pvmp3_st_intensity(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 is_pos, + int32 Start, + int32 Number) +{ + + int32 TmpFac = is_ratio_factor[ is_pos & 7]; + + int32 *pt_xr = &xr[Start]; + int32 *pt_xl = &xl[Start]; + + for (int32 i = Number >> 1; i != 0; i--) + { + int32 tmp = fxp_mul32_Q32((*pt_xr) << 1, TmpFac); + *(pt_xl++) = (*pt_xr) - tmp; + *(pt_xr++) = tmp; + tmp = fxp_mul32_Q32((*pt_xr) << 1, TmpFac); + *(pt_xl++) = (*pt_xr) - tmp; + *(pt_xr++) = tmp; + } + + if (Number&1) + { + int32 tmp = fxp_mul32_Q32((*pt_xr) << 1, TmpFac); + *(pt_xl) = (*pt_xr) - tmp; + *(pt_xr) = tmp; + } + +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void pvmp3_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, + granuleInfo *gr_info, + int32 used_freq_lines, + mp3Header *info) +{ + + + int32 sb; + int32 ss; + int32 sfbNo; + int32 sfbStart; + + int32 sfb; + int32 sfbTemp; + int32 i; + int32 j; + + + int32 i_stereo = (info->mode == MPG_MD_JOINT_STEREO) && + (info->mode_ext & 0x1); + + int32 ms_stereo = (info->mode == MPG_MD_JOINT_STEREO) && + (info->mode_ext & 0x2); + + int32 sfreq = info->version_x + (info->version_x << 1); + sfreq += info->sampling_frequency; + + + + + if (i_stereo) + { + if (gr_info->window_switching_flag && (gr_info->block_type == 2)) + { + if (gr_info->mixed_block_flag) + { + /* + * mixed blocks processing + */ + i = 31; + ss = 17; + sb = 0; + while (i >= 0) + { + if (xl[(i*FILTERBANK_BANDS) + ss]) + { + sb = (i << 4) + (i << 1) + ss; + i = -1; + } + else + { + ss--; + if (ss < 0) + { + i--; + ss = 17; + } + } + } + + if (sb < 36) + { + /* + * mixed blocks processing: intensity bound inside long blocks + */ + /* 1. long blocks up to intensity border: not intensity */ + + if (mp3_sfBandIndex[sfreq].l[4] <= sb) + { + sfb = 4; + } + else + { + sfb = 0; + } + + while (mp3_sfBandIndex[sfreq].l[sfb] < sb) + { + sfb++; + } + + /* from that sfb on intensity stereo */ + sfbTemp = sfb; /* save for later use */ + + sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; + + /* from 0 up to sfbStart do ms_stereo or normal stereo */ + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, sfbStart); + } + + /* 2. long blocks from intensity border up to sfb band 8: intensity */ + /* calc. is_ratio */ + + + /* Start of intensity stereo of remaining sfc bands: */ + for (; sfbTemp < 8; sfbTemp++) + { + sfbStart = mp3_sfBandIndex[sfreq].l[sfbTemp]; /* = Start in 0 ... 575 */ + sfbNo = mp3_sfBandIndex[sfreq].l[sfbTemp+1] - mp3_sfBandIndex[sfreq].l[sfbTemp]; /* No of lines to process */ + + if (scalefac->l[sfbTemp] != 7) + { + pvmp3_st_intensity(xr, xl, scalefac->l[sfbTemp], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (; sfbTemp < 8; sfbTemp++) */ + + for (j = 0; j < 3; j++) + { + /* 3. short blocks from sfbcnt to last sfb do intensity stereo */ + for (sfbTemp = 3; sfbTemp < 13; sfbTemp++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo; + + if (scalefac->s[j][sfbTemp] != 7) + { + pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (; sfbTemp < 22; sfbTemp++) */ + } /* for (j = 0; j < 3; j++) */ + } + else /* else for (sb >= 36) */ + { + /* + * mixed blocks processing: intensity bound outside long blocks + */ + + + /* + * 2. short blocks from sfb band 3 up to intensity border: normal stereo, ms stereo and intensity + */ + for (j = 0; j < 3; j++) + { + int32 sfbcnt; + sfbcnt = -1; + + for (sfb = 12; sfb >= 3; sfb--) + { + int32 lines; + lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1; + + while (lines > 0) + { + if (xl[i]) + { + sfbcnt = sfb; + sfb = -10; + lines = -10; + } + lines--; + i--; + } + } + + sfbcnt += 1; + if (sfbcnt < 3) + { + sfbcnt = 3; + } + + sfbTemp = sfbcnt; /* for later use */ + + + /* + * do normal stereo or MS stereo from sfb 3 to < sfbcnt: + */ + for (sb = 3; sb < sfbcnt; sb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sb+1] - mp3_sfBandIndex[sfreq].s[sb]; + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sb] + j * sfbNo; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } + + /* from sfbcnt to last sfb do intensity stereo */ + for (; sfbTemp < 13; sfbTemp++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo; + + if (scalefac->s[j][sfbTemp] != 7) + { + pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (; sfbTemp < 22; sfbTemp++) */ + + } /* for (j = 0; j < 3; j++) */ + + /* 1. long blocks up to sfb band 8: not intensity */ + /* from 0 to sfb 8 ms_stereo or normal stereo */ + + sfbStart = mp3_sfBandIndex[sfreq].l[8]; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, sfbStart); + } + + } + } /* if (gr_info->mixed_block_flag) */ + else + { + /* + * short block processing + */ + for (j = 0; j < 3; j++) + { + int32 sfbcnt = -1; + + for (sfb = 12; sfb >= 0; sfb--) + { + int32 lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; + i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1; + + while (lines > 0) + { + if (xl[i]) + { + sfbcnt = sfb; + sfb = -10; + lines = -10; + } + lines--; + i--; + } + } + + sfbcnt += 1; + sfbTemp = sfbcnt; /* for later use */ + + /* do normal stereo or MS stereo from 0 to sfbcnt */ + for (sb = 0; sb < sfbcnt; sb++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sb+1] - mp3_sfBandIndex[sfreq].s[sb]; + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sb] + j * sfbNo; + + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + } + + + /* from sfbcnt to last sfb do intensity stereo */ + for (; sfbTemp < 13; sfbTemp++) + { + sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */ + sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo; + + if (scalefac->s[j][sfbTemp] != 7) + { + pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (; sfbTemp < 22; sfbTemp++) */ + + } /* for (j = 0; j < 3; j++) */ + + } /* if( gr_info->mixed_block_flag) */ + + + + } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */ + else + { + /* + * long block processing + */ + i = 31; + ss = 17; + sb = 0; + + while (i >= 0) + { + if (xl[(i*FILTERBANK_BANDS) + ss] != 0) + { + sb = (i << 4) + (i << 1) + ss; + i = -2; + } + else + { + ss--; + if (ss < 0) + { + i--; + ss = 17; + } + } + } + + if (sb) + { + if (mp3_sfBandIndex[sfreq].l[14] <= sb) + { + sfb = 14; + } + else if (mp3_sfBandIndex[sfreq].l[7] <= sb) + { + sfb = 7; + } + else + { + sfb = 0; + } + + + while (mp3_sfBandIndex[sfreq].l[sfb] <= sb) + { + sfb++; + } + } + else + { + if (i == -1) + { + /* all xr[1][][] are 0: set IS bound sfb to 0 */ + sfb = 0; + } + else + { + /* xr[1][0][0] is unequal 0 and all others are 0: set IS bound sfb to 1 */ + sfb = 1; + } + } + + sfbTemp = sfb; /* save for later use */ + + + sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; + + /* from 0 to sfbStart ms_stereo or normal stereo */ + if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, 0, sfbStart); + } + + /* now intensity stereo of the remaining sfb's: */ + for (; sfb < 21; sfb++) + { + sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; + sfbNo = mp3_sfBandIndex[sfreq].l[sfb+1] - mp3_sfBandIndex[sfreq].l[sfb]; /* No of lines to process */ + + if (scalefac->l[sfb] != 7) + { + pvmp3_st_intensity(xr, xl, scalefac->l[sfb], sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* for (; sfbTemp < 22; sfbTemp++) */ + + + + sfbStart = mp3_sfBandIndex[sfreq].l[21]; + sfbNo = mp3_sfBandIndex[sfreq].l[22] - mp3_sfBandIndex[sfreq].l[21]; /* No of lines to process */ + + if (scalefac->l[21] != 7) + { + if (sfbTemp < 21) + { + sfbTemp = scalefac->l[20]; + } + else + { + sfbTemp = 0; /* if scalefac[20] is not an intensity position, is_pos = 0 */ + } + + pvmp3_st_intensity(xr, xl, sfbTemp, sfbStart, sfbNo); + } + else if (ms_stereo) + { + pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo); + } + + } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */ + + + } /* if (i_stereo) */ + else + { + /* + * normal or ms stereo processing + */ + if (ms_stereo) + { + + pvmp3_st_mid_side(xr, xl, 0, used_freq_lines); + + } + + } /* if (i_stereo) */ + +} + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.h new file mode 100644 index 0000000..bfaf1a1 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_stereo_proc.h @@ -0,0 +1,114 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_stereo_proc.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP3_STEREO_PROC_H +#define PVMP3_STEREO_PROC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + + void pvmp3_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + mp3ScaleFactors *scalefac, + granuleInfo *gr_info, + int32 used_freq_lines, + mp3Header *info); + + void pvmp3_st_intensity(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 is_pos, + int32 Start, + int32 Number); + + void pvmp3_st_mid_side(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS], + int32 Start, + int32 Number); +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.cpp b/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.cpp new file mode 100644 index 0000000..90e524a --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.cpp @@ -0,0 +1,2934 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: pvmp3_tables.cpp + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + + Description: + + +------------------------------------------------------------------------------ + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_tables.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const int32 mp3_s_freq[4][4] = +{ + {44100, 48000, 32000, 0}, + {22050, 24000, 16000, 0}, + {11025, 12000, 8000, 0} +}; // MPEG-2.5 + + +/* + * 144000./s_freq + */ +const int32 inv_sfreq[4] = +{ + Qfmt_28(3.26530612244898), + Qfmt_28(3.0), + Qfmt_28(4.5), + 0 +}; + + +/* 1: MPEG-1, 0: MPEG-2 LSF, 1995-07-11 shn */ + + +const int16 mp3_bitrate[3][15] = +{ + {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320}, + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}, + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160} +}; + + +const mp3_scaleFactorBandIndex mp3_sfBandIndex[9] = +{ + + /* MPEG 1 */ + + {{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418, 576}, + {0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192}}, + {{0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330, 384, 576}, + {0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192}}, + {{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448, 550, 576}, + {0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192}}, + + /* MPEG 2 - LSF */ + + {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, + {0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192}}, + {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 332, 394, 464, 540, 576}, + {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192}}, + {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, + {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}}, + + /* MPEG 2.5 extension */ + + {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, + {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}}, + {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, + {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}}, + {{0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568, 570, 572, 574, 576}, + {0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164, 166, 192}} + +}; + +#define INV_Q31( x) (int32)(0x7FFFFFFF/(float)x - 1.0f) + +const int32 mp3_shortwindBandWidths[9][13] = +{ + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), + INV_Q31(12), INV_Q31(14), INV_Q31(18), INV_Q31(22), INV_Q31(30), INV_Q31(56)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(6), INV_Q31(10), + INV_Q31(12), INV_Q31(14), INV_Q31(16), INV_Q31(20), INV_Q31(26), INV_Q31(66)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(12), + INV_Q31(16), INV_Q31(20), INV_Q31(26), INV_Q31(34), INV_Q31(42), INV_Q31(12)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(6), INV_Q31(8), INV_Q31(10), + INV_Q31(14), INV_Q31(18), INV_Q31(26), INV_Q31(32), INV_Q31(42), INV_Q31(18)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12), + INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(32), INV_Q31(44), INV_Q31(12)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12), + INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(30), INV_Q31(40), INV_Q31(18)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12), + INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(30), INV_Q31(40), INV_Q31(18)}, + { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12), + INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(30), INV_Q31(40), INV_Q31(18)}, + { INV_Q31(8), INV_Q31(8), INV_Q31(8), INV_Q31(12), INV_Q31(16), INV_Q31(20), INV_Q31(24), + INV_Q31(28), INV_Q31(36), INV_Q31(2), INV_Q31(2), INV_Q31(2), INV_Q31(26)} +}; + + +#define Q30_fmt(a) (int32((0x40000000)*a)) + +const int32 pqmfSynthWin[(HAN_SIZE/2) + 8] = +{ + Q30_fmt(-0.000015259F), Q30_fmt(0.000396729F), Q30_fmt(0.000473022F), Q30_fmt(0.003173828F), + Q30_fmt(0.003326416F), Q30_fmt(0.006118770F), Q30_fmt(0.007919310F), Q30_fmt(0.031478880F), + Q30_fmt(0.030517578F), Q30_fmt(0.073059080F), Q30_fmt(0.084182740F), Q30_fmt(0.108856200F), + Q30_fmt(0.090927124F), Q30_fmt(0.543823240F), Q30_fmt(0.600219727F), Q30_fmt(1.144287109F), + + Q30_fmt(-0.000015259F), Q30_fmt(0.000366211F), Q30_fmt(0.000534058F), Q30_fmt(0.003082275F), + Q30_fmt(0.003387451F), Q30_fmt(0.005294800F), Q30_fmt(0.008865360F), Q30_fmt(0.031738280F), + Q30_fmt(0.029785160F), Q30_fmt(0.067520140F), Q30_fmt(0.089706420F), Q30_fmt(0.116577150F), + Q30_fmt(0.080688480F), Q30_fmt(0.515609740F), Q30_fmt(0.628295900F), Q30_fmt(1.142211914F), + + Q30_fmt(-0.000015259F), Q30_fmt(0.000320435F), Q30_fmt(0.000579834F), Q30_fmt(0.002990723F), + Q30_fmt(0.003433228F), Q30_fmt(0.004486080F), Q30_fmt(0.009841920F), Q30_fmt(0.031845090F), + Q30_fmt(0.028884890F), Q30_fmt(0.061996460F), Q30_fmt(0.095169070F), Q30_fmt(0.123474120F), + Q30_fmt(0.069595340F), Q30_fmt(0.487472530F), Q30_fmt(0.656219480F), Q30_fmt(1.138763428F), + + Q30_fmt(-0.000015259F), Q30_fmt(0.000289917F), Q30_fmt(0.000625610F), Q30_fmt(0.002899170F), + Q30_fmt(0.003463745F), Q30_fmt(0.003723140F), Q30_fmt(0.010849000F), Q30_fmt(0.031814580F), + Q30_fmt(0.027801510F), Q30_fmt(0.056533810F), Q30_fmt(0.100540160F), Q30_fmt(0.129577640F), + Q30_fmt(0.057617190F), Q30_fmt(0.459472660F), Q30_fmt(0.683914180F), Q30_fmt(1.133926392F), + + Q30_fmt(-0.000015259F), Q30_fmt(0.000259399F), Q30_fmt(0.000686646F), Q30_fmt(0.002792358F), + Q30_fmt(0.003479004F), Q30_fmt(0.003005981F), Q30_fmt(0.011886600F), Q30_fmt(0.031661990F), + Q30_fmt(0.026535030F), Q30_fmt(0.051132200F), Q30_fmt(0.105819700F), Q30_fmt(0.134887700F), + Q30_fmt(0.044784550F), Q30_fmt(0.431655880F), Q30_fmt(0.711318970F), Q30_fmt(1.127746582F), + + Q30_fmt(-0.000015259F), Q30_fmt(0.000244141F), Q30_fmt(0.000747681F), Q30_fmt(0.002685547F), + Q30_fmt(0.003479004F), Q30_fmt(0.002334595F), Q30_fmt(0.012939450F), Q30_fmt(0.031387330F), + Q30_fmt(0.025085450F), Q30_fmt(0.045837400F), Q30_fmt(0.110946660F), Q30_fmt(0.139450070F), + Q30_fmt(0.031082153F), Q30_fmt(0.404083250F), Q30_fmt(0.738372800F), Q30_fmt(1.120223999F), + + Q30_fmt(-0.000030518F), Q30_fmt(0.000213623F), Q30_fmt(0.000808716F), Q30_fmt(0.002578735F), + Q30_fmt(0.003463745F), Q30_fmt(0.001693726F), Q30_fmt(0.014022830F), Q30_fmt(0.031005860F), + Q30_fmt(0.023422240F), Q30_fmt(0.040634160F), Q30_fmt(0.115921020F), Q30_fmt(0.143264770F), + Q30_fmt(0.016510010F), Q30_fmt(0.376800540F), Q30_fmt(0.765029907F), Q30_fmt(1.111373901F), + + Q30_fmt(-0.000030518F), Q30_fmt(0.000198364F), Q30_fmt(0.000885010F), Q30_fmt(0.002456665F), + Q30_fmt(0.003417969F), Q30_fmt(0.001098633F), Q30_fmt(0.015121460F), Q30_fmt(0.030532840F), + Q30_fmt(0.021575930F), Q30_fmt(0.035552980F), Q30_fmt(0.120697020F), Q30_fmt(0.146362300F), + Q30_fmt(0.001068120F), Q30_fmt(0.349868770F), Q30_fmt(0.791213990F), Q30_fmt(1.101211548F), + + Q30_fmt(-0.000030518F), Q30_fmt(0.000167847F), Q30_fmt(0.000961304F), Q30_fmt(0.002349854F), + Q30_fmt(0.003372192F), Q30_fmt(0.000549316F), Q30_fmt(0.016235350F), Q30_fmt(0.029937740F), + Q30_fmt(0.019531250F), Q30_fmt(0.030609130F), Q30_fmt(0.125259400F), Q30_fmt(0.148773190F), + Q30_fmt(-0.015228270F), Q30_fmt(0.323318480F), Q30_fmt(0.816864010F), Q30_fmt(1.089782715F), + + Q30_fmt(-0.000030518F), Q30_fmt(0.000152588F), Q30_fmt(0.001037598F), Q30_fmt(0.002243042F), + Q30_fmt(0.003280640F), Q30_fmt(0.000030518F), Q30_fmt(0.017349240F), Q30_fmt(0.029281620F), + Q30_fmt(0.017257690F), Q30_fmt(0.025817870F), Q30_fmt(0.129562380F), Q30_fmt(0.150497440F), + Q30_fmt(-0.032379150F), Q30_fmt(0.297210693F), Q30_fmt(0.841949463F), Q30_fmt(1.077117920F), + + Q30_fmt(-0.000045776F), Q30_fmt(0.000137329F), Q30_fmt(0.001113892F), Q30_fmt(0.002120972F), + Q30_fmt(0.003173828F), Q30_fmt(-0.000442505F), Q30_fmt(0.018463130F), Q30_fmt(0.028533940F), + Q30_fmt(0.014801030F), Q30_fmt(0.021179200F), Q30_fmt(0.133590700F), Q30_fmt(0.151596070F), + Q30_fmt(-0.050354000F), Q30_fmt(0.271591190F), Q30_fmt(0.866363530F), Q30_fmt(1.063217163F), + + Q30_fmt(-0.000045776F), Q30_fmt(0.000122070F), Q30_fmt(0.001205444F), Q30_fmt(0.002014160F), + Q30_fmt(0.003051758F), Q30_fmt(-0.000869751F), Q30_fmt(0.019577030F), Q30_fmt(0.027725220F), + Q30_fmt(0.012115480F), Q30_fmt(0.016708370F), Q30_fmt(0.137298580F), Q30_fmt(0.152069090F), + Q30_fmt(-0.069168090F), Q30_fmt(0.246505740F), Q30_fmt(0.890090940F), Q30_fmt(1.048156738F), + + Q30_fmt(-0.000061035F), Q30_fmt(0.000106812F), Q30_fmt(0.001296997F), Q30_fmt(0.001907349F), + Q30_fmt(0.002883911F), Q30_fmt(-0.001266479F), Q30_fmt(0.020690920F), Q30_fmt(0.026840210F), + Q30_fmt(0.009231570F), Q30_fmt(0.012420650F), Q30_fmt(0.140670780F), Q30_fmt(0.151962280F), + Q30_fmt(-0.088775630F), Q30_fmt(0.221984860F), Q30_fmt(0.913055420F), Q30_fmt(1.031936646F), + + Q30_fmt(-0.000061035F), Q30_fmt(0.000106812F), Q30_fmt(0.001388550F), Q30_fmt(0.001785278F), + Q30_fmt(0.002700806F), Q30_fmt(-0.001617432F), Q30_fmt(0.021789550F), Q30_fmt(0.025909420F), + Q30_fmt(0.006134030F), Q30_fmt(0.008316040F), Q30_fmt(0.143676760F), Q30_fmt(0.151306150F), + Q30_fmt(-0.109161380F), Q30_fmt(0.198059080F), Q30_fmt(0.935195920F), Q30_fmt(1.014617920F), + + Q30_fmt(-0.000076294F), Q30_fmt(0.000091553F), Q30_fmt(0.001480103F), Q30_fmt(0.001693726F), + Q30_fmt(0.002487183F), Q30_fmt(-0.001937866F), Q30_fmt(0.022857670F), Q30_fmt(0.024932860F), + Q30_fmt(0.002822880F), Q30_fmt(0.004394530F), Q30_fmt(0.146255490F), Q30_fmt(0.150115970F), + Q30_fmt(-0.130310060F), Q30_fmt(0.174789430F), Q30_fmt(0.956481930F), Q30_fmt(0.996246338F), + + Q30_fmt(0.000000000F), Q30_fmt(0.000442505F), Q30_fmt(0.001586910F), Q30_fmt(0.003250122F), + Q30_fmt(0.007003780F), Q30_fmt(0.023910525F), Q30_fmt(0.031082153F), Q30_fmt(0.078628545F), + Q30_fmt(0.148422240F), Q30_fmt(0.100311279F), Q30_fmt(0.572036740F), Q30_fmt(0.976852417F), + Q30_fmt(1.144989014F), Q30_fmt(-0.572036745F), Q30_fmt(-0.152206421F), Q30_fmt(0.100311279F), + + Q30_fmt(-0.078628540F), Q30_fmt(-0.000686646F), Q30_fmt(0.031082153F), Q30_fmt(-0.007003785F), + Q30_fmt(0.002227783F), Q30_fmt(0.003250122F), Q30_fmt(-0.000442500F), Q30_fmt(-0.000076294F), +}; + + + + + +const uint16 huffTable_1[8] = +{ + 0x1103, 0x0103, 0x1002, 0x1002, + 0x0001, 0x0001, 0x0001, 0x0001 +}; + +const uint16 huffTable_2[15] = +{ + 0x1103, 0x0103, 0x1003, 0x0001, + 0x0001, 0x0001, 0x0001, 0x2206, + 0x0206, 0x1205, 0x1205, 0x2105, + 0x2105, 0x2005, 0x2005 +}; + +const uint16 huffTable_3[15] = +{ + + 0x1003, 0x1102, 0x1102, 0x0102, + 0x0102, 0x0002, 0x0002, 0x2206, + 0x0206, 0x1205, 0x1205, 0x2105, + 0x2105, 0x2005, 0x2005 +}; + +const uint16 huffTable_5[25] = +{ + + 0x1103, 0x0103, 0x1003, 0x0001, + 0x0001, 0x0001, 0x0001, 0x3106, + 0x3106, 0x1307, 0x0307, 0x3007, + 0x2207, 0x1206, 0x1206, 0x2106, + 0x2106, 0x0206, 0x0206, 0x2006, + 0x2006, 0x3308, 0x2308, 0x3207, + 0x3207 +}; + + +const uint16 huffTable_6[26] = +{ + + 0x1204, 0x2104, 0x2004, 0x0103, + 0x0103, 0x1102, 0x1102, 0x1102, + 0x1102, 0x1003, 0x1003, 0x0003, + 0x0003, 0x2306, 0x3206, 0x3006, + 0x1305, 0x1305, 0x3105, 0x3105, + 0x2205, 0x2205, 0x0205, 0x0205, + 0x3307, 0x0307 +}; + + + +const uint16 huffTable_7[73] = +{ + 0x0103, + 0x1003, + 0x0001, + 0x0001, + 0x0001, + 0x0001, + 0x1206, + 0x2105, + 0x2105, + 0x0206, + 0x2006, + 0x1104, + 0x1104, + 0x1104, + 0x1104, + 0x3509, + 0x4409, + 0x2509, + 0x5209, + 0x1508, + 0x1508, + 0x5108, + 0x5108, + 0x0509, + 0x3409, + 0x5008, + 0x5008, + 0x4309, + 0x3309, + 0x2408, + 0x2408, + 0x4208, + 0x4208, + 0x1407, + 0x1407, + 0x1407, + 0x1407, + 0x4107, + 0x4107, + 0x4107, + 0x4107, + 0x4007, + 0x4007, + 0x4007, + 0x4007, + 0x0408, + 0x0408, + 0x2308, + 0x2308, + 0x3208, + 0x3208, + 0x0308, + 0x0308, + 0x1307, + 0x1307, + 0x1307, + 0x1307, + 0x3107, + 0x3107, + 0x3107, + 0x3107, + 0x3007, + 0x3007, + 0x3007, + 0x3007, + 0x2207, + 0x2207, + 0x2207, + 0x2207, + 0x550a, + 0x450a, + 0x540a, + 0x530a +}; + +const uint16 huffTable_8[66] = +{ + 0x1204, + 0x2104, + 0x1102, + 0x1102, + 0x1102, + 0x1102, + 0x0103, + 0x0103, + 0x1003, + 0x1003, + 0x0002, + 0x0002, + 0x0002, + 0x0002, + 0x2206, + 0x0206, + 0x2006, + 0x2509, + 0x5209, + 0x0509, + 0x1508, + 0x1508, + 0x5108, + 0x5108, + 0x3409, + 0x4309, + 0x5009, + 0x3309, + 0x2408, + 0x2408, + 0x4208, + 0x4208, + 0x1408, + 0x1408, + 0x4107, + 0x4107, + 0x4107, + 0x4107, + 0x0408, + 0x0408, + 0x4008, + 0x4008, + 0x2308, + 0x2308, + 0x3208, + 0x3208, + 0x1308, + 0x1308, + 0x3108, + 0x3108, + 0x0308, + 0x0308, + 0x3008, + 0x3008, + 0x550b, + 0x540b, + 0x450a, + 0x450a, + 0x5309, + 0x5309, + 0x5309, + 0x5309, + 0x350a, + 0x350a, + 0x440a, + 0x440a + +}; + + +const uint16 huffTable_9[53] = +{ + 0x1204, + 0x2104, + 0x2004, + 0x1103, + 0x1103, + 0x0103, + 0x0103, + 0x1003, + 0x1003, + 0x0003, + 0x0003, + 0x1406, + 0x4106, + 0x2306, + 0x3206, + 0x1305, + 0x1305, + 0x3105, + 0x3105, + 0x0306, + 0x3006, + 0x2205, + 0x2205, + 0x0205, + 0x0205, + 0x4408, + 0x2508, + 0x5208, + 0x1508, + 0x5107, + 0x5107, + 0x3407, + 0x3407, + 0x4307, + 0x4307, + 0x5008, + 0x0408, + 0x2407, + 0x2407, + 0x4207, + 0x4207, + 0x3307, + 0x3307, + 0x4007, + 0x4007, + 0x5509, + 0x4509, + 0x3508, + 0x3508, + 0x5308, + 0x5308, + 0x5409, + 0x0509 + +}; + + +const uint16 huffTable_10[96] = +{ + 0x0001, + 0x1104, + 0x0103, + 0x0103, + 0x1003, + 0x1003, + 0x1206, + 0x2106, + 0x0206, + 0x2006, + 0x1408, + 0x4108, + 0x4008, + 0x2308, + 0x3208, + 0x0308, + 0x1307, + 0x1307, + 0x3107, + 0x3107, + 0x3007, + 0x3007, + 0x2207, + 0x2207, + 0x1608, + 0x1608, + 0x6108, + 0x6108, + 0x6008, + 0x6008, + 0x0509, + 0x5009, + 0x2409, + 0x4209, + 0x3309, + 0x0409, + 0x2709, + 0x2709, + 0x7209, + 0x7209, + 0x640a, + 0x070a, + 0x7009, + 0x7009, + 0x6209, + 0x6209, + 0x450a, + 0x350a, + 0x0609, + 0x0609, + 0x530a, + 0x440a, + 0x1708, + 0x1708, + 0x1708, + 0x1708, + 0x7108, + 0x7108, + 0x7108, + 0x7108, + 0x3609, + 0x3609, + 0x2609, + 0x2609, + 0x250a, + 0x520a, + 0x1509, + 0x1509, + 0x5109, + 0x5109, + 0x340a, + 0x430a, + 0x770b, + 0x670b, + 0x760b, + 0x570b, + 0x750b, + 0x660b, + 0x470a, + 0x470a, + 0x740a, + 0x740a, + 0x560a, + 0x560a, + 0x650a, + 0x650a, + 0x370a, + 0x370a, + 0x730a, + 0x730a, + 0x460a, + 0x460a, + 0x550b, + 0x540b, + 0x630a, + 0x630a +}; + + +const uint16 huffTable_11[116] = +{ + 0x1103, + 0x0103, + 0x1003, + 0x0002, + 0x0002, + 0x2105, + 0x1204, /* 0100 */ + 0x1204, /* 010 */ + 0x0205, /* 01010 */ + 0x2005, /* 01011 */ + 0x1408, /* 10 */ + 0x4108, /* 00 */ + 0x0408, /* 0 0 */ + 0x4008, /* 0 1 */ + 0x2307, /* 0 */ + 0x2307, /* */ + 0x3207, /* 1 */ + 0x3207, /* */ + 0x1306, /* 010 */ + 0x1306, /* 01 */ + 0x1306, /* 01 */ + 0x1306, /* 01 */ + 0x3106, /* 011 */ + 0x3106, /* 01 */ + 0x3106, /* 01 */ + 0x3106, /* 01 */ + 0x0307, /* 1000 */ + 0x0307, /* 100 */ + 0x3007, /* 1 */ + 0x3007, /* 100 */ + 0x2206, /* 101 */ + 0x2206, /* 10 */ + 0x2206, /* 10 */ + 0x2206, /* 10 */ + 0x2708, + 0x2708, /* 000 0 */ + 0x7208, /* 000 10 */ + 0x7208, /* 000 1 */ + 0x6409, /* 000 110 */ + 0x0709, + 0x7107, + 0x7107, + 0x7107, /* 00 0 */ + 0x7107, /* 00 0 */ + 0x1708, + 0x1708, /* 00 01 */ + 0x7008, + 0x7008, + 0x3608, + 0x3608, /* 00 10 */ + 0x6308, /* 00 101 */ + 0x6308, /* 00 10 */ + 0x6008, + 0x6008, /* 00 11 */ + 0x4409, + 0x2509, + 0x5209, /* 0 */ + 0x0509, /* 0 00 */ + 0x1508, /* 0 0 */ + 0x1508, /* 0 000 */ + 0x6207, /* 0 */ + 0x6207, /* 0 00 */ + 0x6207, /* 0 00 */ + 0x6207, /* 0 00 */ + 0x2608, + 0x2608, /* 0 010 */ + 0x0608, + 0x0608, + 0x1607, + 0x1607, + 0x1607, + 0x1607, + 0x6107, + 0x6107, + 0x6107, + 0x6107, + 0x5108, + 0x5108, + 0x3408, + 0x3408, + 0x5008, + 0x5008, + 0x4309, + 0x3309, + 0x2408, + 0x2408, /* 0 111 */ + 0x4208, /* 0 1111 */ + 0x4208, /* 0 111 */ + 0x560a, + 0x650a, + 0x3709, + 0x3709, + 0x7309, + 0x7309, + 0x4609, + 0x4609, + 0x450a, + 0x540a, /* 000 0 */ + 0x350a, /* 000 0 */ + 0x530a, /* 000 1 */ + 0x770a, + 0x770a, + 0x670a, + 0x670a, + 0x760a, /* 0 */ + 0x760a, /* */ + 0x750a, /* 1 */ + 0x750a, /* */ + 0x660a, /* 00 */ + 0x660a, /* 0 */ + 0x470a, /* 01 */ + 0x470a, /* 0 */ + 0x740a, /* 10 */ + 0x740a, /* 1 */ + 0x570b, /* 110 */ + 0x550b /* 111 */ + +}; + +const uint16 huffTable_12[134] = +{ + + 0x1103, /* 101 */ + 0x0103, /* 110 */ + 0x1003, /* 111 */ + 0x1204, + 0x1204, /* 011 */ + 0x2104, /* 0111 */ + 0x2104, /* 011 */ + 0x0205, /* 10000 */ + 0x2005, /* 10 */ + 0x0004, /* 1 */ + 0x0004, /* 100 */ + 0x3006, + 0x1305, /* 01 */ + 0x1305, /* 0100 */ + 0x3105, + 0x3105, + 0x2205, + 0x2205, /* 0101 */ + 0x1507, + 0x1507, /* 000 */ + 0x5107, /* 0 */ + 0x5107, /* 000 */ + 0x3407, /* 0 */ + 0x3407, /* */ + 0x4307, /* 1 */ + 0x4307, /* */ + 0x5008, + 0x0408, + 0x2407, + 0x2407, /* 010 */ + 0x4207, + 0x4207, + 0x1407, /* 0111 */ + 0x1407, /* 011 */ + 0x3306, + 0x3306, + 0x3306, + 0x3306, + 0x4106, + 0x4106, + 0x4106, + 0x4106, + 0x2306, + 0x2306, + 0x2306, + 0x2306, + 0x3206, + 0x3206, + 0x3206, + 0x3206, + 0x4007, + 0x4007, + 0x0307, + 0x0307, /* 010000 */ + 0x7208, + 0x7208, /* 00 00 */ + 0x4608, /* 00 */ + 0x4608, /* 00 00 */ + 0x6408, + 0x6408, /* 00 01 */ + 0x1708, /* 00 011 */ + 0x1708, + 0x7108, /* 00 100 */ + 0x7108, + 0x0709, + 0x7009, + 0x3608, + 0x3608, /* 00 11 */ + 0x6308, + 0x6308, + 0x4508, + 0x4508, + 0x5408, /* 0 0 */ + 0x5408, /* 0 000 */ + 0x4408, /* 0 0 */ + 0x4408, /* 0 */ + 0x0609, /* 0 10 */ + 0x0509, /* 0 11 */ + 0x2607, + 0x2607, + 0x2607, + 0x2607, + 0x6207, + 0x6207, + 0x6207, + 0x6207, + 0x6107, + 0x6107, + 0x6107, + 0x6107, + 0x1608, /* 0 1010 */ + 0x1608, /* 0 101 */ + 0x6008, /* 0 1011 */ + 0x6008, /* 0 101 */ + 0x3508, + 0x3508, /* 0 110 */ + 0x5308, /* 0 1101 */ + 0x5308, /* 0 110 */ + 0x2508, + 0x2508, /* 0 111 */ + 0x5208, /* 0 1111 */ + 0x5208, /* 0 111 */ + 0x770a, + 0x670a, + 0x7609, /* */ + 0x7609, + 0x5709, /* 0 */ + 0x5709, /* */ + 0x7509, /* 1 */ + 0x7509, /* */ + 0x6609, + 0x6609, + 0x4709, /* 0000 01 */ + 0x4709, /* 0000 0 */ + 0x7409, + 0x7409, /* 0000 1 */ + 0x6509, + 0x6509, /* 0000 1 */ + 0x5608, + 0x5608, + 0x5608, + 0x5608, + 0x3708, + 0x3708, + 0x3708, + 0x3708, + 0x7309, /* 000 100 */ + 0x7309, /* 000 10 */ + 0x5509, + 0x5509, /* 000 10 */ + 0x2708, + 0x2708, + 0x2708, + 0x2708, +}; + + + +const uint16 huffTable_13[491] = +{ + 0x0001, + 0x1104, + 0x0104, + 0x1003, + 0x1003, + 0x4107, + 0x4107, + 0x0408, + 0x4008, + 0x2308, + 0x3208, + 0x1307, + 0x1307, + 0x3107, + 0x3107, + 0x0307, + 0x0307, + 0x3007, + 0x3007, + 0x2207, + 0x2207, + 0x1206, + 0x1206, + 0x1206, + 0x1206, + 0x2106, + 0x2106, + 0x2106, + 0x2106, + 0x0206, + 0x0206, + 0x0206, + 0x0206, + 0x2006, + 0x2006, + 0x2006, + 0x2006, + 0x370a, + 0x270a, /* 0 000 */ + 0x1709, /* 0 00 */ + 0x1709, + 0x7109, + 0x7109, /* 0 0 */ + 0x550a, + 0x070a, /* 0 0 11 */ + 0x700a, + 0x360a, /* 0 */ + 0x630a, + 0x450a, /* 0 011 */ + 0x540a, + 0x260a, /* 0 101 */ + 0x620a, + 0x350a, /* 0 111 */ + 0x8108, + 0x8108, /* 0 010 */ + 0x8108, + 0x8108, /* 0 010 */ + 0x0809, + 0x0809, /* 0 0101 */ + 0x8009, + 0x8009, /* 0 0101 */ + 0x1609, + 0x1609, /* 0 0110 */ + 0x6109, + 0x6109, /* 0 0110 */ + 0x0609, + 0x0609, /* 0 0111 */ + 0x6009, + 0x6009, /* 0 0111 */ + 0x530a, + 0x440a, /* 0 100 */ + 0x2509, + 0x2509, /* 0 1000 */ + 0x5209, + 0x5209, /* 0 1 */ + 0x0509, + 0x0509, /* 0 1 */ + 0x1508, + 0x1508, /* 0 101 */ + 0x1508, + 0x1508, /* 0 101 */ + 0x5108, + 0x5108, /* 0 101 */ + 0x5108, + 0x5108, /* 0 101 */ + 0x3409, + 0x3409, /* 0 1100 */ + 0x4309, + 0x4309, /* 0 1100 */ + 0x5009, + 0x5009, /* 0 1101 */ + 0x2409, + 0x2409, /* 0 1101 */ + 0x4209, + 0x4209, /* 0 1110 */ + 0x3309, + 0x3309, /* 0 1110 */ + 0x1408, + 0x1408, /* 0 111 */ + 0x1408, + 0x1408, /* 0 111 */ + 0x1a0a, + 0x1a0a, + 0xa10a, /* 00 00 */ + 0xa10a, + 0x0a0b, + 0x680b, + 0xa00a, + 0xa00a, + 0x860b, + 0x490b, + 0x930a, + 0x930a, + 0x390b, + 0x580b, + 0x850b, + 0x670b, + 0x290a, + 0x290a, + 0x920a, + 0x920a, + 0x570b, + 0x750b, + 0x380a, + 0x380a, + 0x830a, + 0x830a, + 0x660b, + 0x470b, + 0x740b, + 0x560b, + 0x650b, + 0x730b, + 0x1909, + 0x1909, + 0x1909, + 0x1909, + 0x9109, + 0x9109, + 0x9109, + 0x9109, + 0x090a, /* 00 10100 */ + 0x090a, + 0x900a, /* 00 10101 */ + 0x900a, + 0x480a, /* 00 10110 */ + 0x480a, + 0x840a, /* 00 10111 */ + 0x840a, + 0x720a, /* 00 11000 */ + 0x720a, + 0x460b, /* 00 11 0 */ + 0x640b, + 0x2809, + 0x2809, + 0x2809, + 0x2809, + 0x8209, + 0x8209, + 0x8209, + 0x8209, + 0x1809, + 0x1809, + 0x1809, + 0x1809, + 0xc10b, + 0xc10b, /* 000 0000 */ + 0x980c, + 0x0c0c, /* 000 00 1 */ + 0xc00b, + 0xc00b, /* 000 0 */ + 0xb40c, + 0x6a0c, /* 000 0 11 */ + 0xa60c, + 0x790c, /* 000 */ + 0x3b0b, + 0x3b0b, /* 000 0 */ + 0xb30b, + 0xb30b, /* 000 1 */ + 0x880c, + 0x5a0c, /* 000 111 */ + 0x2b0b, + 0x2b0b, /* 000 0100 */ + 0xa50c, + 0x690c, /* 000 01 1 */ + 0xa40b, + 0xa40b, /* 000 0101 */ + 0x780c, + 0x870c, + 0x940b, + 0x940b, /* 000 0110 */ + 0x770c, + 0x760c, /* 000 011011 */ + 0xb20a, + 0xb20a, /* 000 011 */ + 0xb20a, + 0xb20a, /* 000 011 */ + 0x1b0a, + 0x1b0a, /* 000 100 */ + 0x1b0a, + 0x1b0a, /* 000 100 */ + 0xb10a, + 0xb10a, + 0xb10a, /* 000 100 */ + 0xb10a, /* 000 100 */ + 0x0b0b, /* 000 10100 */ + 0x0b0b, /* 000 1010 */ + 0xb00b, + 0xb00b, /* 000 1010 */ + 0x960b, /* 000 10110 */ + 0x960b, /* 000 1011 */ + 0x4a0b, + 0x4a0b, /* 000 1011 */ + 0x3a0b, /* 000 11000 */ + 0x3a0b, /* 000 1100 */ + 0xa30b, /* 000 11 */ + 0xa30b, /* 000 1100 */ + 0x590b, + 0x590b, /* 000 1101 */ + 0x950b, /* 000 11011 */ + 0x950b, /* 000 1101 */ + 0x2a0a, + 0x2a0a, + 0x2a0a, + 0x2a0a, + 0xa20a, + 0xa20a, + 0xa20a, + 0xa20a, + 0xf00c, + 0xf00c, /* 000 */ + 0xba0d, + 0xe50d, /* 0 1 */ + 0xe40d, + 0x8c0d, /* 01 */ + 0x6d0d, + 0xe30d, /* 11 */ + 0xe20c, /* 0100 */ + 0xe20c, + 0x2e0d, /* 01010 */ + 0x0e0d, + 0x1e0c, /* 0110 */ + 0x1e0c, + 0xe10c, /* 0111 */ + 0xe10c, + 0xe00d, /* 10000 */ + 0x5d0d, + 0xd50d, /* 1 0 */ + 0x7c0d, + 0xc70d, + 0x4d0d, + 0x8b0d, + 0xb80d, + 0xd40d, + 0x9a0d, + 0xa90d, + 0x6c0d, + 0xc60c, + 0xc60c, + 0x3d0c, + 0x3d0c, /* 111 */ + 0xd30d, /* 0000 */ + 0x7b0d, + 0x2d0c, + 0x2d0c, + 0xd20c, + 0xd20c, + 0x1d0c, + 0x1d0c, + 0xb70c, + 0xb70c, /* 0000 0 */ + 0x5c0d, + 0xc50d, /* 0000 011 */ + 0x990d, + 0x7a0d, + 0xc30c, + 0xc30c, /* 0000 1 */ + 0xa70d, + 0x970d, + 0x4b0c, + 0x4b0c, + 0xd10b, + 0xd10b, + 0xd10b, /* 0000 010 */ + 0xd10b, + 0x0d0c, + 0x0d0c, + 0xd00c, + 0xd00c, + 0x8a0c, + 0x8a0c, + 0xa80c, + 0xa80c, + 0x4c0c, + 0x4c0c, + 0xc40c, + 0xc40c, + 0x6b0c, + 0x6b0c, /* 0000 1 */ + 0xb60c, /* 0000 1 1 */ + 0xb60c, /* 0000 1 */ + 0x3c0b, + 0x3c0b, + 0x3c0b, + 0x3c0b, + 0x2c0b, /* 0000 1011 */ + 0x2c0b, /* 0000 101 */ + 0x2c0b, /* 0000 101 */ + 0x2c0b, /* 0000 101 */ + 0xc20b, + 0xc20b, + 0xc20b, + 0xc20b, + 0x5b0b, /* 0000 1101 */ + 0x5b0b, + 0x5b0b, /* 0000 110 */ + 0x5b0b, /* 0000 110 */ + 0xb50c, + 0xb50c, + 0x890c, + 0x890c, /* 0000 1110 */ + 0x1c0b, + 0x1c0b, + 0x1c0b, + 0x1c0b, + 0x2f0d, + 0x2f0d, /* 000 */ + 0xf20d, /* 0 */ + 0xf20d, /* 000 */ + 0x6e0e, /* 00 */ + 0x9c0e, /* 01 */ + 0x0f0d, /* 1 */ + 0x0f0d, /* */ + 0xc90e, + 0x5e0e, /* 01 */ + 0xab0d, /* 0101 */ + 0xab0d, + 0x7d0e, /* 01100 */ + 0xd70e, + 0x4e0d, /* 0111 */ + 0x4e0d, + 0xc80e, + 0xd60e, /* 10 */ + 0x3e0d, + 0x3e0d, /* 100 */ + 0xb90d, + 0xb90d, /* 101 */ + 0x9b0e, + 0xaa0e, /* 10111 */ + 0x1f0c, + 0x1f0c, /* 11 */ + 0x1f0c, /* 11 */ + 0x1f0c, + 0xf10c, /* 111 */ + 0xf10c, /* 11 */ + 0xf10c, /* 11 */ + 0xf10c, /* 11 */ + 0xe80e, + 0xe80e, + 0x5f0e, + 0x5f0e, + 0x9d0e, + 0x9d0e, + 0xd90e, + 0xd90e, /* 0000000 */ + 0xf50e, + 0xf50e, + 0xe70e, + 0xe70e, + 0xac0e, + 0xac0e, + 0xbb0e, + 0xbb0e, + 0x4f0e, + 0x4f0e, + 0xf40e, /* 0000000 1 */ + 0xf40e, + 0xca0f, + 0xe60f, + 0xf30e, + 0xf30e, /* 0000000 101 */ + 0x3f0d, + 0x3f0d, /* 0000000 11 */ + 0x3f0d, + 0x3f0d, /* 0000000 11 */ + 0x8d0e, + 0x8d0e, + 0xd80e, /* 0000000 1111 */ + 0xd80e, + 0x8f0f, + 0x8f0f, /* 00000000 000 */ + 0xf80f, /* 00000000 0 */ + 0xf80f, + 0xcc0f, /* 00000000 0 */ + 0xcc0f, + 0xae10, + 0x9e10, /* 00000000 11 */ + 0x8e0f, + 0x8e0f, + 0x7f10, + 0x7e10, + 0xf70e, /* 00000000 011 */ + 0xf70e, + 0xf70e, + 0xf70e, /* 00000000 01 */ + 0xda0e, + 0xda0e, /* 00000000 10 */ + 0xda0e, + 0xda0e, /* 00000000 10 */ + 0xad0f, + 0xad0f, /* 00000000 101 */ + 0xbc0f, + 0xbc0f, /* 00000000 101 */ + 0xcb0f, + 0xcb0f, /* 00000000 110 */ + 0xf60f, + 0xf60f, /* 00000000 110 */ + 0x6f0e, + 0x6f0e, /* 00000000 11 */ + 0x6f0e, /* 00000000 11 */ + 0x6f0e, /* 00000000 11 */ + 0xff10, + 0xff10, + 0xef10, + 0xef10, /* 000000000000 */ + 0xdf10, /* 000000000000 1 */ + 0xdf10, /* 000000000000 */ + 0xee10, /* 00000000000 00 */ + 0xee10, /* 00000000000 0 */ + 0xcf10, /* 00000000000 01 */ + 0xcf10, + 0xde10, /* 00000000000 10 */ + 0xde10, + 0xbf10, /* 00000000000 11 */ + 0xbf10, /* 00000000000 1 */ + 0xfb10, + 0xfb10, + 0xce10, + 0xce10, /* 0000000000 00 */ + 0xdc10, /* 0000000000 010 */ + 0xdc10, + 0xaf11, + 0xe911, + 0xec0f, /* 0000000000 10 */ + 0xec0f, /* 0000000000 1 */ + 0xec0f, /* 0000000000 1 */ + 0xec0f, /* 0000000000 1 */ + 0xdd0f, /* 0000000000 11 */ + 0xdd0f, /* 0000000000 1 */ + 0xdd0f, /* 0000000000 1 */ + 0xdd0f, /* 0000000000 1 */ + 0xfa10, /* 000000000 0000 */ + 0xfa10, /* 000000000 000 */ + 0xcd10, /* 000000000 0 */ + 0xcd10, /* 000000000 000 */ + 0xbe0f, /* 000000000 */ + 0xbe0f, + 0xbe0f, + 0xbe0f, + 0xeb0f, + 0xeb0f, + 0xeb0f, + 0xeb0f, /* 000000000 01 */ + 0x9f0f, /* 000000000 011 */ + 0x9f0f, /* 000000000 01 */ + 0x9f0f, + 0x9f0f, + 0xf90f, /* 000000000 100 */ + 0xf90f, /* 000000000 10 */ + 0xf90f, /* 000000000 10 */ + 0xf90f, /* 000000000 10 */ + 0xea0f, /* 000000000 101 */ + 0xea0f, /* 000000000 10 */ + 0xea0f, /* 000000000 10 */ + 0xea0f, /* 000000000 10 */ + 0xbd0f, /* 000000000 110 */ + 0xbd0f, /* 000000000 11 */ + 0xbd0f, /* 000000000 11 */ + 0xbd0f, /* 000000000 11 */ + 0xdb0f, /* 000000000 111 */ + 0xdb0f, /* 000000000 11 */ + 0xdb0f, /* 000000000 11 */ + 0xdb0f, /* 000000000 11 */ + 0xfe13, + 0xfc13, + 0xfd12, + 0xfd12, + 0xed11, + 0xed11, + 0xed11, + 0xed11 + +}; + + + +const uint16 huffTable_15[421] = +{ + 0x1103, + 0x1103, + 0x0104, + 0x1004, + 0x0003, /* 111 */ + 0x0003, /* 11 */ + 0x3407, + 0x4307, + 0x2407, /* 0101 */ + 0x4207, /* 0101010 */ + 0x3307, + 0x4106, /* 010110 */ + 0x4106, + 0x1407, /* 0101110 */ + 0x0407, + 0x2306, /* 011000 */ + 0x2306, + 0x3206, /* 011 */ + 0x3206, + 0x4007, + 0x0307, + 0x1306, /* 011011 */ + 0x1306, /* 01101 */ + 0x3106, /* 011100 */ + 0x3106, /* 01110 */ + 0x3006, /* 011101 */ + 0x3006, /* 01110 */ + 0x2205, /* 01111 */ + 0x2205, /* 0111 */ + 0x2205, /* 0111 */ + 0x2205, /* 0111 */ + 0x1205, /* 10000 */ + 0x1205, /* 1000 */ + 0x1205, /* 1000 */ + 0x1205, /* 1000 */ + 0x2105, /* 10 */ + 0x2105, /* 1000 */ + 0x2105, /* 1000 */ + 0x2105, /* 1000 */ + 0x0205, + 0x0205, /* 1 */ + 0x0205, /* 1 */ + 0x0205, /* 1 */ + 0x2005, /* 1 1 */ + 0x2005, /* 1 */ + 0x2005, /* 1 */ + 0x2005, /* 1 */ + 0x5809, + 0x8509, + 0x2909, /* */ + 0x6709, /* 000 */ + 0x7609, /* 00 0 */ + 0x9209, /* 00 1 */ + 0x9108, /* 0 0 */ + 0x9108, /* 0 */ + 0x1909, /* 0 10 */ + 0x9009, /* 0 11 */ + 0x4809, /* 000 */ + 0x8409, /* */ + 0x5709, /* 010 */ + 0x7509, /* 011 */ + 0x3809, /* 100 */ + 0x8309, /* 101 */ + 0x6609, /* 110 */ + 0x4709, /* 111 */ + 0x2808, + 0x2808, /* 0100 */ + 0x8208, /* 01 */ + 0x8208, /* 0100 */ + 0x1808, /* 01010 */ + 0x1808, /* 0101 */ + 0x8108, /* 01011 */ + 0x8108, /* 0101 */ + 0x7409, + 0x0809, /* 011 */ + 0x8009, /* 011010 */ + 0x5609, + 0x6509, /* 011100 */ + 0x3709, + 0x7309, /* 011110 */ + 0x4609, + 0x2708, /* 10000 */ + 0x2708, /* 1000 */ + 0x7208, /* 10 */ + 0x7208, /* 1000 */ + 0x6408, /* 1 0 */ + 0x6408, /* 1 */ + 0x1708, /* 1 1 */ + 0x1708, /* 1 */ + 0x5508, /* 10100 */ + 0x5508, + 0x7108, /* 10101 */ + 0x7108, + 0x0709, /* 101100 */ + 0x7009, /* 101101 */ + 0x3608, /* 10111 */ + 0x3608, /* 1011 */ + 0x6308, /* 11000 */ + 0x6308, /* 1100 */ + 0x4508, /* 11 */ + 0x4508, /* 1100 */ + 0x5408, /* 11010 */ + 0x5408, /* 1101 */ + 0x2608, /* 11011 */ + 0x2608, /* 1101 */ + 0x6208, /* 11100 */ + 0x6208, /* 1110 */ + 0x1608, /* 11101 */ + 0x1608, /* 1110 */ + 0x0609, /* 111100 */ + 0x6009, /* 111101 */ + 0x3508, /* 11111 */ + 0x3508, /* 1111 */ + 0x6107, + 0x6107, + 0x6107, + 0x6107, + 0x5308, /* 0100 0 */ + 0x5308, /* 0100 */ + 0x4408, /* 0100 1 */ + 0x4408, /* 0100 */ + 0x2507, /* 010 0 */ + 0x2507, /* 010 */ + 0x2507, /* 010 */ + 0x2507, /* 010 */ + 0x5207, /* 010 1 */ + 0x5207, /* 010 */ + 0x5207, /* 010 */ + 0x5207, /* 010 */ + 0x1507, /* 01 00 */ + 0x1507, /* 01 0 */ + 0x1507, /* 01 0 */ + 0x1507, /* 01 0 */ + 0x5107, /* 01 01 */ + 0x5107, /* 01 0 */ + 0x5107, /* 01 0 */ + 0x5107, /* 01 0 */ + 0x0508, /* 01 100 */ + 0x0508, /* 01 10 */ + 0x5008, /* 01 101 */ + 0x5008, /* 01 10 */ + 0xc209, + 0xc209, + 0x2c0a, /* 00 11110 */ + 0x5b0a, + 0xb50a, /* 0 */ + 0x1c0a, /* 0 000 */ + 0x890a, /* 0 00 0 */ + 0x980a, + 0xc10a, /* 0 0 00 */ + 0x4b0a, /* 0 0 01 */ + 0xb40a, /* 0 0 10 */ + 0x6a0a, /* 0 0 11 */ + 0x3b0a, /* 0 000 */ + 0x790a, /* 0 */ + 0xb309, /* 0 01 */ + 0xb309, /* 0 0 */ + 0x970a, /* 0 100 */ + 0x880a, /* 0 101 */ + 0x2b0a, /* 0 110 */ + 0x5a0a, /* 0 111 */ + 0xb209, /* 0 01000 */ + 0xb209, /* 0 0100 */ + 0xa50a, /* 0 01 0 */ + 0x1b0a, /* 0 01 1 */ + 0xb109, /* 0 01010 */ + 0xb109, /* 0 0101 */ + 0xb00a, /* 0 010110 */ + 0x690a, /* 0 010111 */ + 0x960a, /* 0 011000 */ + 0x4a0a, /* 0 011 */ + 0xa40a, /* 0 011010 */ + 0x780a, /* 0 011011 */ + 0x870a, /* 0 011100 */ + 0x3a0a, /* 0 011101 */ + 0xa309, /* 0 01111 */ + 0xa309, /* 0 0111 */ + 0x5909, /* 0 10000 */ + 0x5909, /* 0 1000 */ + 0x9509, /* 0 10 */ + 0x9509, /* 0 1000 */ + 0x2a09, /* 0 1 0 */ + 0x2a09, /* 0 1 */ + 0xa209, /* 0 1 1 */ + 0xa209, /* 0 1 */ + 0x1a09, /* 0 10100 */ + 0x1a09, /* 0 1010 */ + 0xa109, /* 0 10101 */ + 0xa109, /* 0 1010 */ + 0x0a0a, /* 0 101100 */ + 0xa00a, /* 0 101101 */ + 0x6809, /* 0 10111 */ + 0x6809, /* 0 1011 */ + 0x8609, /* 0 11000 */ + 0x8609, /* 0 1100 */ + 0x4909, /* 0 11 */ + 0x4909, /* 0 1100 */ + 0x9409, /* 0 11010 */ + 0x9409, /* 0 1101 */ + 0x3909, /* 0 11011 */ + 0x3909, /* 0 1101 */ + 0x9309, /* 0 11100 */ + 0x9309, /* 0 1110 */ + 0x770a, /* 0 111010 */ + 0x090a, /* 0 111011 */ + 0x7c0b, + 0xc70b, /* 00 000 */ + 0x4d0b, /* 00 00 0 */ + 0x8b0b, /* 00 00 1 */ + 0xd40a, /* 00 0 0 */ + 0xd40a, /* 00 0 */ + 0xb80b, /* 00 0 10 */ + 0x9a0b, /* 00 0 11 */ + 0xa90b, /* 00 000 */ + 0x6c0b, /* 00 */ + 0xc60b, /* 00 010 */ + 0x3d0b, /* 00 011 */ + 0xd30a, /* 00 10 */ + 0xd30a, /* 00 1 */ + 0xd20a, /* 00 11 */ + 0xd20a, /* 00 1 */ + 0x2d0b, /* 00 010000 */ + 0x0d0b, /* 00 010 */ + 0x1d0a, /* 00 01 */ + 0x1d0a, /* 00 0100 */ + 0x7b0a, /* 00 01010 */ + 0x7b0a, /* 00 0101 */ + 0xb70a, /* 00 01011 */ + 0xb70a, /* 00 0101 */ + 0xd10a, /* 00 01100 */ + 0xd10a, /* 00 0110 */ + 0x5c0b, /* 00 011010 */ + 0xd00b, /* 00 011011 */ + 0xc50a, /* 00 01110 */ + 0xc50a, /* 00 0111 */ + 0x8a0a, /* 00 01111 */ + 0x8a0a, /* 00 0111 */ + 0xa80a, /* 00 10000 */ + 0xa80a, /* 00 1000 */ + 0x4c0a, /* 00 10 */ + 0x4c0a, /* 00 1000 */ + 0xc40a, /* 00 1 0 */ + 0xc40a, /* 00 1 */ + 0x6b0a, /* 00 1 1 */ + 0x6b0a, /* 00 1 */ + 0xb60a, /* 00 10100 */ + 0xb60a, /* 00 1010 */ + 0x990b, /* 00 101010 */ + 0x0c0b, /* 00 101011 */ + 0x3c0a, /* 00 10110 */ + 0x3c0a, /* 00 1011 */ + 0xc30a, /* 00 10111 */ + 0xc30a, /* 00 1011 */ + 0x7a0a, /* 00 11000 */ + 0x7a0a, /* 00 1100 */ + 0xa70a, /* 00 11 */ + 0xa70a, /* 00 1100 */ + 0xa60a, /* 00 11010 */ + 0xa60a, /* 00 1101 */ + 0xc00b, /* 00 110110 */ + 0x0b0b, /* 00 110111 */ + 0xcb0b, + 0xcb0b, /* 0000 000 */ + 0xf60b, /* 0000 0 */ + 0xf60b, /* 0000 000 */ + 0x8e0c, /* 0000 00 */ + 0xe80c, /* 0000 01 */ + 0x5f0c, /* 0000 10 */ + 0x9d0c, /* 0000 11 */ + 0xf50b, /* 0000 0100 */ + 0xf50b, /* 0000 010 */ + 0x7e0b, /* 0000 0101 */ + 0x7e0b, /* 0000 010 */ + 0xe70b, /* 0000 0110 */ + 0xe70b, /* 0000 011 */ + 0xac0b, /* 0000 0111 */ + 0xac0b, /* 0000 011 */ + 0xca0b, /* 0000 1000 */ + 0xca0b, /* 0000 100 */ + 0xbb0b, /* 0000 1 */ + 0xbb0b, /* 0000 100 */ + 0xd90c, /* 0000 10100 */ + 0x8d0c, /* 0000 10101 */ + 0x4f0b, /* 0000 1011 */ + 0x4f0b, /* 0000 101 */ + 0xf40b, /* 0000 1100 */ + 0xf40b, /* 0000 110 */ + 0x3f0b, /* 0000 1101 */ + 0x3f0b, /* 0000 110 */ + 0xf30b, /* 0000 1110 */ + 0xf30b, /* 0000 111 */ + 0xd80b, /* 0000 1111 */ + 0xd80b, /* 0000 111 */ + 0xe60b, /* 000 */ + 0xe60b, /* 000 0000 */ + 0x2f0b, /* 000 00 */ + 0x2f0b, /* 000 0000 */ + 0xf20b, /* 000 0 0 */ + 0xf20b, /* 000 0 */ + 0x6e0c, /* 000 0 10 */ + 0xf00c, /* 000 0 11 */ + 0x1f0b, /* 000 00 */ + 0x1f0b, /* 000 0 */ + 0xf10b, /* 000 01 */ + 0xf10b, /* 000 0 */ + 0x9c0b, /* 000 10 */ + 0x9c0b, /* 000 1 */ + 0xc90b, /* 000 11 */ + 0xc90b, /* 000 1 */ + 0x5e0b, /* 000 01000 */ + 0x5e0b, /* 000 0100 */ + 0xab0b, /* 000 01 */ + 0xab0b, /* 000 0100 */ + 0xba0b, /* 000 01010 */ + 0xba0b, /* 000 0101 */ + 0xe50b, /* 000 01011 */ + 0xe50b, /* 000 0101 */ + 0x7d0b, /* 000 01100 */ + 0x7d0b, /* 000 0110 */ + 0xd70b, /* 000 01101 */ + 0xd70b, + 0x4e0b, /* 000 01110 */ + 0x4e0b, + 0xe40b, /* 000 01111 */ + 0xe40b, /* 000 0111 */ + 0x8c0b, + 0x8c0b, /* 000 1000 */ + 0xc80b, /* 000 10 */ + 0xc80b, + 0x3e0b, /* 000 1 0 */ + 0x3e0b, /* 000 1 */ + 0x6d0b, + 0x6d0b, /* 000 1 */ + 0xd60b, /* 000 10100 */ + 0xd60b, /* 000 1010 */ + 0xe30b, + 0xe30b, /* 000 1010 */ + 0x9b0b, /* 000 10110 */ + 0x9b0b, /* 000 1011 */ + 0xb90b, + 0xb90b, /* 000 1011 */ + 0x2e0b, /* 000 11000 */ + 0x2e0b, /* 000 1100 */ + 0xaa0b, + 0xaa0b, /* 000 1100 */ + 0xe20b, + 0xe20b, /* 000 1101 */ + 0x1e0b, + 0x1e0b, /* 000 1101 */ + 0xe10b, + 0xe10b, /* 000 1110 */ + 0x0e0c, + 0xe00c, /* 000 111011 */ + 0x5d0b, + 0x5d0b, /* 000 1111 */ + 0xd50b, + 0xd50b, /* 000 1111 */ + 0xff0d, + 0xef0d, + 0xfe0d, + 0xdf0d, + 0xee0c, + 0xee0c, + 0xfd0d, + 0xcf0d, + 0xfc0d, + 0xde0d, + 0xed0d, + 0xbf0d, + 0xfb0c, + 0xfb0c, + 0xce0d, + 0xec0d, + 0xdd0c, /* 000 */ + 0xdd0c, /* 00 */ + 0xaf0c, /* */ + 0xaf0c, /* 00 */ + 0xfa0c, /* 010 */ + 0xfa0c, /* 01 */ + 0xbe0c, /* 011 */ + 0xbe0c, /* 01 */ + 0xeb0c, /* 100 */ + 0xeb0c, /* 10 */ + 0xcd0c, /* 101 */ + 0xcd0c, /* 10 */ + 0xdc0c, /* 110 */ + 0xdc0c, /* 11 */ + 0x9f0c, /* 111 */ + 0x9f0c, /* 11 */ + 0xf90c, /* 0000 */ + 0xf90c, /* 000 */ + 0xea0c, /* 0 */ + 0xea0c, /* 000 */ + 0xbd0c, /* 0 */ + 0xbd0c, /* */ + 0xdb0c, /* 1 */ + 0xdb0c, /* */ + 0x8f0c, /* 0100 */ + 0x8f0c, /* 010 */ + 0xf80c, /* 0101 */ + 0xf80c, /* 010 */ + 0xcc0c, + 0xcc0c, /* 011 */ + 0x9e0c, /* 0111 */ + 0x9e0c, /* 011 */ + 0xe90c, /* 1000 */ + 0xe90c, /* 100 */ + 0x7f0c, /* 1 */ + 0x7f0c, + 0xf70c, /* 1010 */ + 0xf70c, /* 101 */ + 0xad0c, /* 1011 */ + 0xad0c, /* 101 */ + 0xda0c, /* 1100 */ + 0xda0c, /* 110 */ + 0xbc0c, + 0xbc0c, /* 110 */ + 0x6f0c, /* 1110 */ + 0x6f0c, /* 111 */ + 0xae0d, /* 11110 */ + 0x0f0d +}; + +const uint16 huffTable_16[465] = +{ + 0x0001, + 0x1104, + 0x0104, + 0x1003, + 0x1003, + 0x2308, + 0x3208, /* 11 */ + 0x1307, /* 0100 */ + 0x1307, /* 010 */ + 0x3107, + 0x3107, + 0x0308, + 0x3008, + 0x2207, /* 0111 */ + 0x2207, /* 011 */ + 0x1206, /* 100 */ + 0x1206, /* 10 */ + 0x1206, /* 10 */ + 0x1206, /* 10 */ + 0x2106, /* 101 */ + 0x2106, /* 10 */ + 0x2106, /* 10 */ + 0x2106, /* 10 */ + 0x0206, + 0x0206, + 0x0206, + 0x0206, + 0x2006, + 0x2006, + 0x2006, + 0x2006, + 0x1709, + 0x1709, /* 0 0111 */ + 0x7109, /* 0 10000 */ + 0x7109, /* 0 1000 */ + 0x700a, /* 0 10 0 */ + 0x360a, /* 0 10 1 */ + 0x630a, /* 0 1 00 */ + 0x450a, /* 0 1 01 */ + 0x540a, /* 0 1 10 */ + 0x260a, /* 0 1 11 */ + 0x6209, /* 0 10100 */ + 0x6209, /* 0 1010 */ + 0x1609, + 0x1609, + 0x6109, /* 0 10110 */ + 0x6109, /* 0 1011 */ + 0x060a, /* 0 101110 */ + 0x600a, + 0x5309, + 0x5309, /* 0 1100 */ + 0x350a, /* 0 11 0 */ + 0x440a, /* 0 11 1 */ + 0x2509, /* 0 11010 */ + 0x2509, /* 0 1101 */ + 0x5209, /* 0 11011 */ + 0x5209, /* 0 1101 */ + 0x5108, + 0x5108, + 0x5108, + 0x5108, + 0x1509, + 0x1509, /* 0 1111 */ + 0x0509, /* 0 11111 */ + 0x0509, /* 0 1111 */ + 0x3409, /* */ + 0x3409, /* */ + 0x4309, /* 000 */ + 0x4309, /* */ + 0x5009, /* 00 0 */ + 0x5009, /* 00 */ + 0x2409, /* 00 1 */ + 0x2409, /* 00 */ + 0x4209, /* 0 00 */ + 0x4209, /* 0 0 */ + 0x3309, /* 0 01 */ + 0x3309, /* 0 0 */ + 0x1408, /* 0 1 */ + 0x1408, /* 0 */ + 0x1408, /* 0 */ + 0x1408, /* 0 */ + 0x4108, /* 00 */ + 0x4108, /* 0 */ + 0x4108, /* 0 */ + 0x4108, /* 0 */ + 0x0409, /* 010 */ + 0x0409, /* 01 */ + 0x4009, /* 011 */ + 0x4009, /* 01 */ + 0x1d0b, + 0x1d0b, /* 00 10101 */ + 0xc40c, /* 00 1011000 */ + 0x6b0c, /* 00 1011 */ + 0xc30c, /* 00 1011010 */ + 0xa70c, /* 00 1011011 */ + 0x2c0b, /* 00 101110 */ + 0x2c0b, /* 00 10111 */ + 0xc20c, /* 00 1011110 */ + 0xb50c, /* 00 1011111 */ + 0xc10c, /* 00 1100000 */ + 0x0c0c, /* 00 1100 */ + 0x4b0c, /* 00 110 0 */ + 0xb40c, /* 00 110 1 */ + 0x6a0c, /* 00 11 00 */ + 0xa60c, /* 00 11 01 */ + 0xb30b, /* 00 11 1 */ + 0xb30b, /* 00 11 */ + 0x5a0c, /* 00 1101000 */ + 0xa50c, /* 00 1101 */ + 0x2b0b, /* 00 110101 */ + 0x2b0b, /* 00 11010 */ + 0xb20b, /* 00 110110 */ + 0xb20b, /* 00 11011 */ + 0x1b0b, /* 00 110111 */ + 0x1b0b, /* 00 11011 */ + 0xb10b, /* 00 111000 */ + 0xb10b, /* 00 11100 */ + 0x0b0c, /* 00 111 0 */ + 0xb00c, /* 00 111 1 */ + 0x690c, /* 00 1110100 */ + 0x960c, /* 00 1110101 */ + 0x4a0c, /* 00 1110110 */ + 0xa40c, /* 00 1110111 */ + 0x780c, /* 00 1111000 */ + 0x870c, /* 00 1111 */ + 0xa30b, /* 00 111101 */ + 0xa30b, /* 00 11110 */ + 0x3a0c, /* 00 1111100 */ + 0x590c, /* 00 1111101 */ + 0x2a0b, /* 00 111111 */ + 0x2a0b, /* 00 11111 */ + 0x950c, /* 0 00000000 */ + 0x680c, /* 0 */ + 0xa10b, /* 0 0000 */ + 0xa10b, /* 0 */ + 0x860c, /* 0 000 00 */ + 0x770c, /* 0 000 01 */ + 0x940b, /* 0 000 1 */ + 0x940b, /* 0 000 */ + 0x490c, /* 0 00 000 */ + 0x570c, /* 0 00 */ + 0x670b, /* 0 00 01 */ + 0x670b, /* 0 00 0 */ + 0xa20a, /* 0 00 1 */ + 0xa20a, /* 0 00 */ + 0xa20a, /* 0 00 */ + 0xa20a, /* 0 00 */ + 0x1a0a, /* 0 0 00 */ + 0x1a0a, /* 0 0 0 */ + 0x1a0a, /* 0 0 0 */ + 0x1a0a, /* 0 0 0 */ + 0x0a0b, /* 0 0 010 */ + 0x0a0b, /* 0 0 01 */ + 0xa00b, /* 0 0 011 */ + 0xa00b, /* 0 0 01 */ + 0x390b, /* 0 0 100 */ + 0x390b, /* 0 0 10 */ + 0x930b, /* 0 0 101 */ + 0x930b, /* 0 0 10 */ + 0x580b, /* 0 0 110 */ + 0x580b, /* 0 0 11 */ + 0x850b, /* 0 0 111 */ + 0x850b, /* 0 0 11 */ + 0x290a, /* 0 000 */ + 0x290a, /* 0 00 */ + 0x290a, /* 0 00 */ + 0x290a, /* 0 00 */ + 0x920a, /* 0 */ + 0x920a, /* 0 00 */ + 0x920a, /* 0 00 */ + 0x920a, /* 0 00 */ + 0x760b, /* 0 0100 */ + 0x760b, /* 0 010 */ + 0x090b, /* 0 0101 */ + 0x090b, /* 0 010 */ + 0x190a, /* 0 011 */ + 0x190a, /* 0 01 */ + 0x190a, /* 0 01 */ + 0x190a, /* 0 01 */ + 0x910a, /* 0 100 */ + 0x910a, /* 0 10 */ + 0x910a, /* 0 10 */ + 0x910a, /* 0 10 */ + 0x900b, /* 0 1010 */ + 0x900b, /* 0 101 */ + 0x480b, /* 0 1011 */ + 0x480b, /* 0 101 */ + 0x840b, /* 0 1100 */ + 0x840b, /* 0 110 */ + 0x750b, /* 0 1101 */ + 0x750b, /* 0 110 */ + 0x380b, /* 0 1110 */ + 0x380b, /* 0 111 */ + 0x830b, /* 0 1111 */ + 0x830b, /* 0 111 */ + 0x660b, /* 0 0100000 */ + 0x660b, /* 0 010000 */ + 0x280b, /* 0 0100 */ + 0x280b, /* 0 010000 */ + 0x820a, /* 0 010 */ + 0x820a, /* 0 01000 */ + 0x820a, /* 0 01000 */ + 0x820a, /* 0 01000 */ + 0x470b, /* 0 01 00 */ + 0x470b, /* 0 01 0 */ + 0x740b, /* 0 01 01 */ + 0x740b, /* 0 01 0 */ + 0x180a, /* 0 01 1 */ + 0x180a, /* 0 01 */ + 0x180a, /* 0 01 */ + 0x180a, /* 0 01 */ + 0x810a, /* 0 010100 */ + 0x810a, /* 0 01010 */ + 0x810a, /* 0 01010 */ + 0x810a, /* 0 01010 */ + 0x800a, /* 0 010101 */ + 0x800a, /* 0 01010 */ + 0x800a, /* 0 01010 */ + 0x800a, /* 0 01010 */ + 0x080b, /* 0 0101100 */ + 0x080b, /* 0 010110 */ + 0x560b, /* 0 0101101 */ + 0x560b, /* 0 010110 */ + 0x370a, /* 0 010111 */ + 0x370a, /* 0 01011 */ + 0x370a, /* 0 01011 */ + 0x370a, /* 0 01011 */ + 0x730a, /* 0 011000 */ + 0x730a, /* 0 01100 */ + 0x730a, /* 0 01100 */ + 0x730a, /* 0 01100 */ + 0x650b, /* 0 011 0 */ + 0x650b, /* 0 011 */ + 0x460b, /* 0 011 1 */ + 0x460b, /* 0 011 */ + 0x270a, /* 0 011010 */ + 0x270a, /* 0 01101 */ + 0x270a, /* 0 01101 */ + 0x270a, /* 0 01101 */ + 0x720a, /* 0 011011 */ + 0x720a, /* 0 01101 */ + 0x720a, /* 0 01101 */ + 0x720a, /* 0 01101 */ + 0x640b, /* 0 0111000 */ + 0x640b, /* 0 011100 */ + 0x550b, /* 0 0111 */ + 0x550b, /* 0 011100 */ + 0x070a, /* 0 011101 */ + 0x070a, /* 0 01110 */ + 0x070a, /* 0 01110 */ + 0x070a, /* 0 01110 */ + 0x9e0d, + 0x9e0d, /* 00 0110000 */ + 0xbc0e, /* 00 01100 0 */ + 0xcb0e, /* 00 01100 1 */ + 0x8e0e, /* 00 0110 00 */ + 0xe80e, /* 00 0110 01 */ + 0x9d0e, /* 00 0110 10 */ + 0xe70e, /* 00 0110 11 */ + 0xbb0e, /* 00 011 000 */ + 0x8d0e, /* 00 011 */ + 0xd80e, /* 00 011 010 */ + 0x6e0e, /* 00 011 011 */ + 0xe60d, /* 00 011 10 */ + 0xe60d, /* 00 011 1 */ + 0x9c0d, /* 00 011 11 */ + 0x9c0d, /* 00 011 1 */ + 0xab0e, /* 00 011010000 */ + 0xba0e, /* 00 011010 */ + 0xe50e, /* 00 01101 0 */ + 0xd70e, /* 00 01101 1 */ + 0x4e0d, /* 00 01101010 */ + 0x4e0d, /* 00 0110101 */ + 0xe40e, /* 00 011010110 */ + 0x8c0e, /* 00 011010111 */ + 0xc80d, /* 00 01101100 */ + 0xc80d, /* 00 0110110 */ + 0x3e0d, /* 00 01101101 */ + 0x3e0d, /* 00 0110110 */ + 0x6d0d, /* 00 01101110 */ + 0x6d0d, /* 00 0110111 */ + 0xd60e, /* 00 011011110 */ + 0x9b0e, /* 00 011011111 */ + 0xb90e, /* 00 011100000 */ + 0xaa0e, /* 00 011100 */ + 0xe10d, /* 00 01110 */ + 0xe10d, /* 00 0111000 */ + 0xd40d, /* 00 0111 0 */ + 0xd40d, /* 00 0111 */ + 0xb80e, /* 00 0111 10 */ + 0xa90e, /* 00 0111 11 */ + 0x7b0d, /* 00 01110100 */ + 0x7b0d, /* 00 0111010 */ + 0xb70e, /* 00 011101010 */ + 0xd00e, /* 00 011101011 */ + 0xe30c, /* 00 0111011 */ + 0xe30c, /* 00 011101 */ + 0xe30c, /* 00 011101 */ + 0xe30c, /* 00 011101 */ + 0x0e0d, /* 00 01111000 */ + 0x0e0d, /* 00 0111100 */ + 0xe00d, /* 00 01111 */ + 0xe00d, /* 00 0111100 */ + 0x5d0d, /* 00 01111010 */ + 0x5d0d, /* 00 0111101 */ + 0xd50d, /* 00 01111011 */ + 0xd50d, /* 00 0111101 */ + 0x7c0d, /* 00 01111100 */ + 0x7c0d, /* 00 0111110 */ + 0xc70d, /* 00 01111101 */ + 0xc70d, /* 00 0111110 */ + 0x4d0d, /* 00 01111110 */ + 0x4d0d, /* 00 0111111 */ + 0x8b0d, /* 00 01111111 */ + 0x8b0d, /* 00 0111111 */ + 0x9a0d, + 0x6c0d, /* 00 10000 */ + 0xc60d, /* 00 1000 0 */ + 0x3d0d, /* 00 1000 1 */ + 0x5c0d, /* 00 100 00 */ + 0xc50d, /* 00 100 01 */ + 0x0d0c, /* 00 100 1 */ + 0x0d0c, /* 00 100 */ + 0x8a0d, /* 00 10 000 */ + 0xa80d, /* 00 10 */ + 0x990d, /* 00 10 010 */ + 0x4c0d, /* 00 10 011 */ + 0xb60d, /* 00 10 100 */ + 0x7a0d, /* 00 10 101 */ + 0x3c0c, /* 00 10 11 */ + 0x3c0c, /* 00 10 1 */ + 0x5b0d, /* 00 1 0000 */ + 0x890d, /* 00 1 0 */ + 0x1c0c, /* 00 1 */ + 0x1c0c, /* 00 1 00 */ + 0xc00c, /* 00 1 010 */ + 0xc00c, /* 00 1 01 */ + 0x980d, /* 00 1 0110 */ + 0x790d, /* 00 1 0111 */ + 0xe20b, /* 00 1 10 */ + 0xe20b, /* 00 1 1 */ + 0xe20b, /* 00 1 1 */ + 0xe20b, /* 00 1 1 */ + 0x2e0c, /* 00 1 110 */ + 0x2e0c, /* 00 1 11 */ + 0x1e0c, /* 00 1 111 */ + 0x1e0c, /* 00 1 11 */ + 0xd30c, /* 00 1010000 */ + 0xd30c, /* 00 101000 */ + 0x2d0c, /* 00 1010 */ + 0x2d0c, /* 00 101000 */ + 0xd20c, /* 00 101 0 */ + 0xd20c, /* 00 101 */ + 0xd10c, /* 00 101 1 */ + 0xd10c, /* 00 101 */ + 0x3b0c, /* 00 1010100 */ + 0x3b0c, /* 00 101010 */ + 0x970d, /* 00 10101010 */ + 0x880d, /* 00 10101011 */ + 0xf208, + 0xf208, /* 000 1 */ + 0x2f09, /* 00 0000 */ + 0x0f09, /* 00 0 */ + 0x1f08, /* 00 */ + 0x1f08, /* 00 00 */ + 0xf108, /* 00 010 */ + 0xf108, /* 00 01 */ + 0xce10, + 0xce10, /* 000 101100000 */ + 0xec11, /* 000 1011000 0 */ + 0xdd11, /* 000 1011000 1 */ + 0xde0f, /* 000 101100 */ + 0xde0f, /* 000 10110000 */ + 0xde0f, /* 000 10110000 */ + 0xde0f, /* 000 10110000 */ + 0xe90f, /* 000 10110 0 */ + 0xe90f, /* 000 10110 */ + 0xe90f, /* 000 10110 */ + 0xe90f, /* 000 10110 */ + 0xea10, /* 000 10110 10 */ + 0xea10, /* 000 10110 1 */ + 0xd910, /* 000 10110 11 */ + 0xd910, /* 000 10110 1 */ + 0xee0e, + 0xee0e, /* 000 1011 */ + 0xed0f, /* 000 1011 10 */ + 0xeb0f, /* 000 1011 11 */ + 0xbe0e, /* 000 10110100 */ + 0xbe0e, /* 000 1011010 */ + 0xcd0e, /* 000 10110101 */ + 0xcd0e, /* 000 1011010 */ + 0xdc0f, /* 000 101101100 */ + 0xdb0f, /* 000 101101101 */ + 0xae0e, /* 000 10110111 */ + 0xae0e, /* 000 1011011 */ + 0xcc0e, /* 000 10111000 */ + 0xcc0e, /* 000 1011100 */ + 0xad0f, /* 000 10111 0 */ + 0xda0f, /* 000 10111 1 */ + 0x7e0f, /* 000 101110100 */ + 0xac0f, /* 000 101110101 */ + 0xca0e, /* 000 10111011 */ + 0xca0e, /* 000 1011101 */ + 0xc90f, /* 000 101111000 */ + 0x7d0f, /* 000 101111 */ + 0x5e0e, /* 000 10111101 */ + 0x5e0e, /* 000 1011110 */ + 0xbd0d, /* 000 1011111 */ + 0xbd0d, /* 000 101111 */ + 0xbd0d, /* 000 101111 */ + 0xbd0d, /* 000 101111 */ + 0xef0b, + 0xfe0b, /* 00000000 */ + 0xdf0b, /* 0000000 0 */ + 0xfd0b, /* 0000000 1 */ + 0xcf0b, /* 00 */ + 0xfc0b, /* 01 */ + 0xbf0b, /* 10 */ + 0xfb0b, /* 11 */ + 0xaf0a, /* 00 */ + 0xaf0a, /* 0 */ + 0xfa0b, /* 010 */ + 0x9f0b, /* 011 */ + 0xf90b, /* 100 */ + 0xf80b, /* 101 */ + 0x8f0a, /* 11 */ + 0x8f0a, /* 1 */ + 0x7f0a, /* 0000 000 */ + 0x7f0a, /* 0000 00 */ + 0xf70a, /* 0000 */ + 0xf70a, /* 0000 00 */ + 0x6f0a, /* 0000 010 */ + 0x6f0a, /* 0000 01 */ + 0xf60a, /* 0000 011 */ + 0xf60a, /* 0000 01 */ + 0xff08, /* 0000 1 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0xff08, /* 0000 */ + 0x5f0a, /* 000 0000 */ + 0x5f0a, /* 000 000 */ + 0xf50a, /* 000 0 */ + 0xf50a, /* 000 000 */ + 0x4f09, /* 000 */ + 0x4f09, /* 000 00 */ + 0x4f09, /* 000 00 */ + 0x4f09, /* 000 00 */ + 0xf409, /* 000 010 */ + 0xf409, /* 000 01 */ + 0xf409, /* 000 01 */ + 0xf409, /* 000 01 */ + 0xf309, /* 000 011 */ + 0xf309, /* 000 01 */ + 0xf309, /* 000 01 */ + 0xf309, /* 000 01 */ + 0xf009, /* 000 100 */ + 0xf009, /* 000 10 */ + 0xf009, /* 000 10 */ + 0xf009, /* 000 10 */ + 0x3f0a, + 0x3f0a +}; + + + +const uint16 huffTable_24[478] = +{ + + 0x2206, /* 101 */ + 0x1205, /* 10101 */ + 0x1205, /* 1010 */ + 0x2105, /* 10110 */ + 0x2105, /* 1011 */ + 0x0206, /* 101110 */ + 0x2006, /* 101111 */ + 0x1104, + 0x1104, + 0x1104, + 0x1104, + 0x0104, + 0x0104, + 0x0104, + 0x0104, + 0x1004, + 0x1004, + 0x1004, + 0x1004, + 0x0004, + 0x0004, + 0x0004, + 0x0004, + 0x7308, + 0x7308, + 0x3709, + 0x2709, + 0x7208, + 0x7208, + 0x4608, /* 01110000 */ + 0x4608, /* 0111000 */ + 0x6408, /* 01110 */ + 0x6408, /* 0111000 */ + 0x5508, /* 0111 0 */ + 0x5508, /* 0111 */ + 0x7108, /* 0111 1 */ + 0x7108, /* 0111 */ + 0x3608, /* 01110100 */ + 0x3608, /* 0111010 */ + 0x6308, /* 01110101 */ + 0x6308, /* 0111010 */ + 0x4508, /* 01110110 */ + 0x4508, /* 0111011 */ + 0x5408, /* 01110111 */ + 0x5408, /* 0111011 */ + 0x2608, /* 01111000 */ + 0x2608, /* 0111100 */ + 0x6208, /* 01111 */ + 0x6208, /* 0111100 */ + 0x1608, /* 01111010 */ + 0x1608, /* 0111101 */ + 0x6108, /* 01111011 */ + 0x6108, /* 0111101 */ + 0x0609, /* 011111000 */ + 0x6009, /* 011111 */ + 0x3508, /* 01111101 */ + 0x3508, /* 0111110 */ + 0x5308, /* 01111110 */ + 0x5308, /* 0111111 */ + 0x4408, /* 01111111 */ + 0x4408, /* 0111111 */ + 0x2508, /* 10000000 */ + 0x2508, /* 1000000 */ + 0x5208, /* 10000 */ + 0x5208, /* 1000000 */ + 0x1508, /* 1000 0 */ + 0x1508, /* 1000 */ + 0x0509, /* 1000 10 */ + 0x5009, /* 1000 11 */ + 0x5107, /* 100 0 */ + 0x5107, /* 100 */ + 0x5107, /* 100 */ + 0x5107, /* 100 */ + 0x3408, /* 100 10 */ + 0x3408, /* 100 1 */ + 0x4308, /* 100 11 */ + 0x4308, /* 100 1 */ + 0x2407, /* 10 00 */ + 0x2407, /* 10 0 */ + 0x2407, /* 10 0 */ + 0x2407, /* 10 0 */ + 0x4207, /* 10 01 */ + 0x4207, /* 10 0 */ + 0x4207, /* 10 0 */ + 0x4207, /* 10 0 */ + 0x3307, /* 10 10 */ + 0x3307, /* 10 1 */ + 0x3307, /* 10 1 */ + 0x3307, /* 10 1 */ + 0x1407, /* 10 11 */ + 0x1407, /* 10 1 */ + 0x1407, /* 10 1 */ + 0x1407, /* 10 1 */ + 0x4107, /* 1 000 */ + 0x4107, /* 1 00 */ + 0x4107, /* 1 00 */ + 0x4107, /* 1 00 */ + 0x0408, /* 1 0 */ + 0x0408, /* 1 */ + 0x4008, /* 1 1 */ + 0x4008, /* 1 */ + 0x2307, /* 1 010 */ + 0x2307, /* 1 01 */ + 0x2307, /* 1 01 */ + 0x2307, /* 1 01 */ + 0x3207, /* 1 011 */ + 0x3207, /* 1 01 */ + 0x3207, /* 1 01 */ + 0x3207, /* 1 01 */ + 0x1306, /* 1 10 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x1306, /* 1 1 */ + 0x3106, /* 1 11 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x3106, /* 1 1 */ + 0x0307, /* 1010000 */ + 0x0307, /* 101000 */ + 0x0307, /* 101000 */ + 0x0307, /* 101000 */ + 0x3007, /* 1010 */ + 0x3007, /* 101000 */ + 0x3007, /* 101000 */ + 0x3007, /* 101000 */ + 0xb309, + 0xb309, + 0x8809, /* 010101 */ + 0x8809, /* 01010100 */ + 0x2b0a, /* 0101010100 */ + 0x5a0a, /* 0101010101 */ + 0xb209, /* 010101011 */ + 0xb209, /* 01010101 */ + 0xa50a, /* 0101011000 */ + 0x1b0a, /* 0101011 */ + 0xb10a, /* 0101011010 */ + 0x690a, /* 0101011011 */ + 0x9609, /* 010101110 */ + 0x9609, /* 01010111 */ + 0xa409, /* 010101111 */ + 0xa409, /* 01010111 */ + 0x4a0a, /* 0101100000 */ + 0x780a, /* 0101100 */ + 0x8709, /* 010110 */ + 0x8709, /* 01011000 */ + 0x3a09, /* 01011 0 */ + 0x3a09, /* 01011 */ + 0xa309, /* 01011 1 */ + 0xa309, /* 01011 */ + 0x5909, /* 010110100 */ + 0x5909, /* 01011010 */ + 0x9509, /* 010110101 */ + 0x9509, /* 01011010 */ + 0x2a09, /* 010110110 */ + 0x2a09, /* 01011011 */ + 0xa209, /* 010110111 */ + 0xa209, /* 01011011 */ + 0xa109, /* 010111000 */ + 0xa109, /* 01011100 */ + 0x6809, /* 010111 */ + 0x6809, /* 01011100 */ + 0x8609, /* 010111010 */ + 0x8609, /* 01011101 */ + 0x7709, /* 010111011 */ + 0x7709, /* 01011101 */ + 0x4909, /* 010111100 */ + 0x4909, /* 01011110 */ + 0x9409, /* 010111101 */ + 0x9409, /* 01011110 */ + 0x3909, /* 010111110 */ + 0x3909, /* 01011111 */ + 0x9309, /* 010111111 */ + 0x9309, /* 01011111 */ + 0x5809, /* 011000000 */ + 0x5809, /* 01100000 */ + 0x8509, /* 011000 */ + 0x8509, /* 01100000 */ + 0x2909, /* 01100 0 */ + 0x2909, /* 01100 */ + 0x6709, /* 01100 1 */ + 0x6709, /* 01100 */ + 0x7609, /* 0110 00 */ + 0x7609, /* 0110 0 */ + 0x9209, /* 0110 01 */ + 0x9209, /* 0110 0 */ + 0x1909, /* 0110 10 */ + 0x1909, /* 0110 1 */ + 0x9109, /* 0110 11 */ + 0x9109, /* 0110 1 */ + 0x4809, /* 011 000 */ + 0x4809, /* 011 00 */ + 0x8409, /* 011 */ + 0x8409, /* 011 00 */ + 0x5709, /* 011 010 */ + 0x5709, /* 011 01 */ + 0x7509, /* 011 011 */ + 0x7509, /* 011 01 */ + 0x3809, /* 011 100 */ + 0x3809, /* 011 10 */ + 0x8309, /* 011 101 */ + 0x8309, /* 011 10 */ + 0x6609, /* 011 110 */ + 0x6609, /* 011 11 */ + 0x2809, /* 011 111 */ + 0x2809, /* 011 11 */ + 0x8209, /* 011010000 */ + 0x8209, /* 01101000 */ + 0x1809, /* 011010 */ + 0x1809, /* 01101000 */ + 0x4709, /* 01101 0 */ + 0x4709, /* 01101 */ + 0x7409, /* 01101 1 */ + 0x7409, /* 01101 */ + 0x8109, /* 011010100 */ + 0x8109, /* 01101010 */ + 0x080a, /* 0110101010 */ + 0x800a, /* 0110101011 */ + 0x5609, /* 011010110 */ + 0x5609, /* 01101011 */ + 0x6509, /* 011010111 */ + 0x6509, /* 01101011 */ + 0x1709, /* 011011000 */ + 0x1709, /* 01101100 */ + 0x070a, /* 011011 0 */ + 0x700a, /* 011011 1 */ + 0x6e0b, + 0x9c0b, + 0xc90a, /* 01000 01 */ + 0xc90a, /* 01000 0 */ + 0x5e0a, /* 01000 10 */ + 0x5e0a, /* 01000 1 */ + 0xba0a, /* 01000 11 */ + 0xba0a, /* 01000 1 */ + 0xe50a, /* 0100 000 */ + 0xe50a, /* 0100 00 */ + 0xab0b, /* 0100 0 */ + 0x7d0b, /* 0100 1 */ + 0xd70a, /* 0100 010 */ + 0xd70a, /* 0100 01 */ + 0xe40a, /* 0100 011 */ + 0xe40a, /* 0100 01 */ + 0x8c0a, /* 0100 100 */ + 0x8c0a, + 0xc80a, + 0xc80a, + 0x4e0b, /* 0100 1100 */ + 0x2e0b, /* 0100 1101 */ + 0x3e0a, /* 0100 111 */ + 0x3e0a, /* 0100 11 */ + 0x6d0a, /* 010 0000 */ + 0x6d0a, /* 010 000 */ + 0xd60a, /* 010 0 */ + 0xd60a, /* 010 000 */ + 0xe30a, /* 010 0 */ + 0xe30a, /* 010 */ + 0x9b0a, /* 010 1 */ + 0x9b0a, /* 010 */ + 0xb90a, /* 010 0100 */ + 0xb90a, /* 010 010 */ + 0xaa0a, /* 010 0101 */ + 0xaa0a, + 0xe20a, + 0xe20a, + 0x1e0a, + 0x1e0a, + 0xe10a, + 0xe10a, + 0x5d0a, + 0x5d0a, + 0xd50a, + 0xd50a, + 0x7c0a, + 0x7c0a, + 0xc70a, + 0xc70a, + 0x4d0a, + 0x4d0a, + 0x8b0a, + 0x8b0a, + 0xb80a, + 0xb80a, + 0xd40a, + 0xd40a, + 0x9a0a, + 0x9a0a, + 0xa90a, /* 01 0 0 */ + 0xa90a, /* 01 0 */ + 0x6c0a, /* 01 0 1 */ + 0x6c0a, /* 01 0 */ + 0xc60a, /* 01 00 */ + 0xc60a, /* 01 0 */ + 0x3d0a, /* 01 01 */ + 0x3d0a, /* 01 0 */ + 0xd30a, /* 01 10 */ + 0xd30a, /* 01 1 */ + 0x2d0a, /* 01 11 */ + 0x2d0a, /* 01 1 */ + 0xd20a, + 0xd20a, + 0x1d0a, /* 01 01 */ + 0x1d0a, /* 01 0100 */ + 0x7b0a, /* 01 01010 */ + 0x7b0a, /* 01 0101 */ + 0xb70a, /* 01 01011 */ + 0xb70a, + 0xd10a, + 0xd10a, /* 01 0110 */ + 0x5c0a, /* 01 01101 */ + 0x5c0a, /* 01 0110 */ + 0xc50a, /* 01 01110 */ + 0xc50a, /* 01 0111 */ + 0x8a0a, /* 01 01111 */ + 0x8a0a, /* 01 0111 */ + 0xa80a, /* 01 10000 */ + 0xa80a, /* 01 1000 */ + 0x990a, /* 01 10 */ + 0x990a, /* 01 1000 */ + 0x4c0a, /* 01 1 0 */ + 0x4c0a, /* 01 1 */ + 0xc40a, /* 01 1 1 */ + 0xc40a, /* 01 1 */ + 0x6b0a, /* 01 10100 */ + 0x6b0a, /* 01 1010 */ + 0xb60a, /* 01 10101 */ + 0xb60a, /* 01 1010 */ + 0xd00b, /* 01 101100 */ + 0x0c0b, /* 01 101101 */ + 0x3c0a, /* 01 10111 */ + 0x3c0a, /* 01 1011 */ + 0xc30a, /* 01 11000 */ + 0xc30a, /* 01 1100 */ + 0x7a0a, /* 01 11 */ + 0x7a0a, /* 01 1100 */ + 0xa70a, /* 01 11010 */ + 0xa70a, /* 01 1101 */ + 0x2c0a, /* 01 11011 */ + 0x2c0a, /* 01 1101 */ + 0xc20a, /* 01 11100 */ + 0xc20a, /* 01 1110 */ + 0x5b0a, /* 01 11101 */ + 0x5b0a, /* 01 1110 */ + 0xb50a, /* 01 11110 */ + 0xb50a, /* 01 1111 */ + 0x1c0a, + 0x1c0a, + 0x890a, + 0x890a, + 0x980a, + 0x980a, + 0xc10a, /* 010100 0 */ + 0xc10a, /* 010100 */ + 0x4b0a, /* 010100 1 */ + 0x4b0a, /* 010100 */ + 0xc00b, /* 01010 000 */ + 0x0b0b, /* 01010 */ + 0x3b0a, /* 01010 01 */ + 0x3b0a, /* 01010 0 */ + 0xb00b, /* 01010 100 */ + 0x0a0b, /* 01010 101 */ + 0x1a0a, /* 01010 11 */ + 0x1a0a, /* 01010 1 */ + 0xb409, /* 0101 00 */ + 0xb409, /* 0101 0 */ + 0xb409, /* 0101 0 */ + 0xb409, /* 0101 0 */ + 0x6a0a, /* 0101 010 */ + 0x6a0a, /* 0101 01 */ + 0xa60a, /* 0101 011 */ + 0xa60a, /* 0101 01 */ + 0x790a, /* 0101 100 */ + 0x790a, /* 0101 10 */ + 0x970a, /* 0101 101 */ + 0x970a, /* 0101 10 */ + 0xa00b, /* 0101 1100 */ + 0x090b, /* 0101 1101 */ + 0x900a, /* 0101 111 */ + 0x900a, /* 0101 11 */ + 0xca0b, + 0xca0b, + 0xbb0b, + 0xbb0b, + 0x8d0b, + 0x8d0b, /* 0100000 */ + 0xd80b, /* 0100000 1 */ + 0xd80b, /* 0100000 */ + 0x0e0c, /* 010000 000 */ + 0xe00c, /* 010000 */ + 0x0d0b, /* 010000 01 */ + 0x0d0b, /* 010000 0 */ + 0xe60a, /* 010000 1 */ + 0xe60a, /* 010000 */ + 0xe60a, /* 010000 */ + 0xe60a, /* 010000 */ + 0x0f09, /* 011000 401 */ + 0x0f09, /* 01100 */ + 0x0f09, /* 01100 */ + 0x0f09, /* 01100 */ + 0xee0b, /* 011 00 */ + 0xde0b, /* 011 01 */ + 0xed0b, /* 011 10 */ + 0xce0b, /* 011 11 */ + 0xec0b, /* 01101000 */ + 0xdd0b, /* 01101 */ + 0xbe0b, /* 01101010 */ + 0xeb0b, /* 01101011 */ + 0xcd0b, /* 01101100 */ + 0xdc0b, /* 01101101 */ + 0xae0b, /* 01101110 */ + 0xea0b, /* 01101111 */ + 0xbd0b, /* 01110000 */ + 0xdb0b, /* 01110 */ + 0xcc0b, /* 0111 0 */ + 0x9e0b, /* 0111 1 */ + 0xe90b, /* 01110100 */ + 0xad0b, /* 01110101 */ + 0xda0b, /* 01110110 */ + 0xbc0b, /* 01110111 */ + 0xcb0b, /* 01111000 */ + 0x8e0b, + 0xe80b, + 0x9d0b, + 0xd90b, + 0x7e0b, + 0xe70b, + 0xac0b, + 0xff04, + 0xef08, + 0xfe08, + 0xdf08, /* 0000 0 */ + 0xfd08, /* 0000 1 */ + 0xcf08, /* 000 00 */ + 0xfc08, /* 000 01 */ + 0xbf08, /* 000 10 */ + 0xfb08, /* 000 11 */ + 0xfa07, /* 00 00 */ + 0xfa07, /* 00 0 */ + 0xaf08, /* 00 010 */ + 0x9f08, /* 00 011 */ + 0xf907, /* 00 10 */ + 0xf907, /* 00 1 */ + 0xf807, /* 00 11 */ + 0xf807, /* 00 1 */ + 0x8f08, + 0x7f08, /* 0 0 */ + 0xf707, /* 0 */ + 0xf707, /* 0 00 */ + 0x6f07, /* 0 010 */ + 0x6f07, /* 0 01 */ + 0xf607, /* 0 011 */ + 0xf607, /* 0 01 */ + 0x5f07, + 0x5f07, /* 0 10 */ + 0xf507, /* 0 101 */ + 0xf507, /* 0 10 */ + 0x4f07, /* 0 110 */ + 0x4f07, /* 0 11 */ + 0xf407, /* 0 111 */ + 0xf407, /* 0 11 */ + 0x3f07, + 0x3f07, + 0xf307, /* 0 */ + 0xf307, + 0x2f07, /* 0 */ + 0x2f07, /* */ + 0xf207, /* 1 */ + 0xf207, /* */ + 0xf107, + 0xf107, + 0x1f08, + 0xf008 + +}; + + +const uint16 huffTable_32[33] = +{ + + 0x0b06, + 0x0f06, + 0x0d06, + 0x0e06, + 0x0706, + 0x0506, + 0x0905, + 0x0905, + 0x0605, + 0x0605, + 0x0305, + 0x0305, + 0x0a05, + 0x0a05, + 0x0c05, + 0x0c05, + 0x0204, + 0x0204, + 0x0204, + 0x0204, + 0x0104, + 0x0104, + 0x0104, + 0x0104, + 0x0404, + 0x0404, + 0x0404, + 0x0404, + 0x0804, + 0x0804, + 0x0804, + 0x0804, + 0x0001 + +}; + + +/* + * MM = 512; z = [0:(MM)]; a = z.^(1/3); + * Table is in Q27 + */ +const int32 power_one_third[513] = +{ + + 0x00000000, 0x08000000, 0x0A14517D, 0x0B89BA25, + 0x0CB2FF53, 0x0DAE07DE, 0x0E897685, 0x0F4DAEDD, + 0x10000000, 0x10A402FD, 0x113C4841, 0x11CAB613, + 0x1250BFE2, 0x12CF8890, 0x1347F8AB, 0x13BACD65, + 0x1428A2FA, 0x1491FC15, 0x14F74744, 0x1558E2F7, + 0x15B72095, 0x161246D7, 0x166A9399, 0x16C03D55, + 0x17137449, 0x17646369, 0x17B33124, 0x18000000, + 0x184AEF29, 0x18941AD8, 0x18DB9CB7, 0x19218C2E, + 0x1965FEA5, 0x19A907C2, 0x19EAB998, 0x1A2B24D0, + 0x1A6A58D5, 0x1AA863EE, 0x1AE5535D, 0x1B213377, + 0x1B5C0FBD, 0x1B95F2EC, 0x1BCEE70F, 0x1C06F590, + 0x1C3E2745, 0x1C74847A, 0x1CAA1501, 0x1CDEE035, + 0x1D12ED0B, 0x1D464212, 0x1D78E582, 0x1DAADD3A, + 0x1DDC2ECF, 0x1E0CDF8C, 0x1E3CF476, 0x1E6C7257, + 0x1E9B5DBA, 0x1EC9BAF6, 0x1EF78E2C, 0x1F24DB4E, + 0x1F51A620, 0x1F7DF23C, 0x1FA9C314, 0x1FD51BF2, + 0x20000000, 0x202A7244, 0x205475A6, 0x207E0CEE, + 0x20A73ACA, 0x20D001CC, 0x20F8646D, 0x2120650E, + 0x214805FA, 0x216F4963, 0x2196316C, 0x21BCC020, + 0x21E2F77A, 0x2208D961, 0x222E67AD, 0x2253A425, + 0x22789082, 0x229D2E6E, 0x22C17F82, 0x22E5854F, + 0x23094155, 0x232CB509, 0x234FE1D5, 0x2372C918, + 0x23956C26, 0x23B7CC47, 0x23D9EABB, 0x23FBC8B9, + 0x241D676E, 0x243EC7FF, 0x245FEB86, 0x2480D319, + 0x24A17FC3, 0x24C1F28B, 0x24E22C6C, 0x25022E5F, + 0x2521F954, 0x25418E33, 0x2560EDE2, 0x2580193E, + 0x259F111F, 0x25BDD657, 0x25DC69B4, 0x25FACBFE, + 0x2618FDF8, 0x26370060, 0x2654D3EF, 0x2672795C, + 0x268FF156, 0x26AD3C8A, 0x26CA5BA2, 0x26E74F41, + 0x27041808, 0x2720B695, 0x273D2B81, 0x27597762, + 0x27759ACB, 0x2791964B, 0x27AD6A6F, 0x27C917C0, + 0x27E49EC5, 0x28000000, 0x281B3BF3, 0x2836531B, + 0x285145F3, 0x286C14F5, 0x2886C096, 0x28A1494B, + 0x28BBAF85, 0x28D5F3B3, 0x28F01641, 0x290A179B, + 0x2923F82A, 0x293DB854, 0x2957587E, 0x2970D90A, + 0x298A3A59, 0x29A37CCA, 0x29BCA0BB, 0x29D5A687, + 0x29EE8E87, 0x2A075914, 0x2A200684, 0x2A38972C, + 0x2A510B5F, 0x2A696370, 0x2A819FAE, 0x2A99C069, + 0x2AB1C5ED, 0x2AC9B088, 0x2AE18085, 0x2AF9362C, + 0x2B10D1C6, 0x2B28539B, 0x2B3FBBEF, 0x2B570B09, + 0x2B6E412B, 0x2B855E97, 0x2B9C6390, 0x2BB35056, + 0x2BCA2527, 0x2BE0E242, 0x2BF787E4, 0x2C0E1649, + 0x2C248DAD, 0x2C3AEE4A, 0x2C513859, 0x2C676C13, + 0x2C7D89AF, 0x2C939164, 0x2CA98368, 0x2CBF5FF1, + 0x2CD52731, 0x2CEAD95E, 0x2D0076A9, 0x2D15FF45, + 0x2D2B7363, 0x2D40D332, 0x2D561EE4, 0x2D6B56A7, + 0x2D807AAA, 0x2D958B19, 0x2DAA8823, 0x2DBF71F4, + 0x2DD448B7, 0x2DE90C98, 0x2DFDBDC0, 0x2E125C5C, + 0x2E26E892, 0x2E3B628D, 0x2E4FCA75, 0x2E642070, + 0x2E7864A8, 0x2E8C9741, 0x2EA0B862, 0x2EB4C831, + 0x2EC8C6D3, 0x2EDCB46C, 0x2EF09121, 0x2F045D14, + 0x2F18186A, 0x2F2BC345, 0x2F3F5DC7, 0x2F52E812, + 0x2F666247, 0x2F79CC88, 0x2F8D26F4, 0x2FA071AC, + 0x2FB3ACD0, 0x2FC6D87F, 0x2FD9F4D7, 0x2FED01F8, + 0x30000000, 0x3012EF0C, 0x3025CF39, 0x3038A0A6, + 0x304B636D, 0x305E17AD, 0x3070BD81, 0x30835504, + 0x3095DE51, 0x30A85985, 0x30BAC6B9, 0x30CD2609, + 0x30DF778D, 0x30F1BB60, 0x3103F19C, 0x31161A59, + 0x312835B0, 0x313A43BA, 0x314C4490, 0x315E3849, + 0x31701EFD, 0x3181F8C4, 0x3193C5B4, 0x31A585E6, + 0x31B7396F, 0x31C8E066, 0x31DA7AE1, 0x31EC08F6, + 0x31FD8ABC, 0x320F0047, 0x322069AC, 0x3231C702, + 0x3243185C, 0x32545DCF, 0x32659770, 0x3276C552, + 0x3287E78A, 0x3298FE2C, 0x32AA094A, 0x32BB08F9, + 0x32CBFD4A, 0x32DCE652, 0x32EDC423, 0x32FE96D0, + 0x330F5E6A, 0x33201B04, 0x3330CCB0, 0x33417380, + 0x33520F85, 0x3362A0D0, 0x33732774, 0x3383A380, + 0x33941506, 0x33A47C17, 0x33B4D8C4, 0x33C52B1B, + 0x33D5732F, 0x33E5B10F, 0x33F5E4CA, 0x34060E71, + 0x34162E14, 0x342643C1, 0x34364F88, 0x34465178, + 0x345649A1, 0x34663810, 0x34761CD6, 0x3485F800, + 0x3495C99D, 0x34A591BB, 0x34B55069, 0x34C505B4, + 0x34D4B1AB, 0x34E4545B, 0x34F3EDD2, 0x35037E1D, + 0x3513054B, 0x35228367, 0x3531F881, 0x354164A3, + 0x3550C7DC, 0x35602239, 0x356F73C5, 0x357EBC8E, + 0x358DFCA0, 0x359D3408, 0x35AC62D1, 0x35BB8908, + 0x35CAA6B9, 0x35D9BBF0, 0x35E8C8B9, 0x35F7CD20, + 0x3606C92F, 0x3615BCF3, 0x3624A878, 0x36338BC8, + 0x364266EE, 0x365139F6, 0x366004EC, 0x366EC7D9, + 0x367D82C9, 0x368C35C6, 0x369AE0DC, 0x36A98414, + 0x36B81F7A, 0x36C6B317, 0x36D53EF7, 0x36E3C323, + 0x36F23FA5, 0x3700B488, 0x370F21D5, 0x371D8797, + 0x372BE5D7, 0x373A3CA0, 0x37488BF9, 0x3756D3EF, + 0x37651489, 0x37734DD1, 0x37817FD1, 0x378FAA92, + 0x379DCE1D, 0x37ABEA7C, 0x37B9FFB7, 0x37C80DD7, + 0x37D614E6, 0x37E414EC, 0x37F20DF1, 0x38000000, + 0x380DEB20, 0x381BCF5A, 0x3829ACB6, 0x3837833D, + 0x384552F8, 0x38531BEE, 0x3860DE28, 0x386E99AF, + 0x387C4E89, 0x3889FCC0, 0x3897A45B, 0x38A54563, + 0x38B2DFDF, 0x38C073D7, 0x38CE0152, 0x38DB885A, + 0x38E908F4, 0x38F68329, 0x3903F701, 0x39116483, + 0x391ECBB6, 0x392C2CA1, 0x3939874D, 0x3946DBC0, + 0x39542A01, 0x39617218, 0x396EB40C, 0x397BEFE4, + 0x398925A7, 0x3996555C, 0x39A37F09, 0x39B0A2B7, + 0x39BDC06A, 0x39CAD82B, 0x39D7EA01, 0x39E4F5F0, + 0x39F1FC01, 0x39FEFC3A, 0x3A0BF6A2, 0x3A18EB3E, + 0x3A25DA16, 0x3A32C32F, 0x3A3FA691, 0x3A4C8441, + 0x3A595C46, 0x3A662EA6, 0x3A72FB67, 0x3A7FC28F, + 0x3A8C8425, 0x3A99402E, 0x3AA5F6B1, 0x3AB2A7B3, + 0x3ABF533A, 0x3ACBF94D, 0x3AD899F1, 0x3AE5352C, + 0x3AF1CB03, 0x3AFE5B7D, 0x3B0AE6A0, 0x3B176C70, + 0x3B23ECF3, 0x3B306830, 0x3B3CDE2C, 0x3B494EEB, + 0x3B55BA74, 0x3B6220CC, 0x3B6E81F9, 0x3B7ADE00, + 0x3B8734E5, 0x3B9386B0, 0x3B9FD364, 0x3BAC1B07, + 0x3BB85D9E, 0x3BC49B2F, 0x3BD0D3BE, 0x3BDD0751, + 0x3BE935ED, 0x3BF55F97, 0x3C018453, 0x3C0DA427, + 0x3C19BF17, 0x3C25D52A, 0x3C31E662, 0x3C3DF2C6, + 0x3C49FA5B, 0x3C55FD24, 0x3C61FB27, 0x3C6DF468, + 0x3C79E8ED, 0x3C85D8B9, 0x3C91C3D2, 0x3C9DAA3C, + 0x3CA98BFC, 0x3CB56915, 0x3CC1418E, 0x3CCD156A, + 0x3CD8E4AE, 0x3CE4AF5E, 0x3CF0757F, 0x3CFC3714, + 0x3D07F423, 0x3D13ACB0, 0x3D1F60BF, 0x3D2B1055, + 0x3D36BB75, 0x3D426224, 0x3D4E0466, 0x3D59A23F, + 0x3D653BB4, 0x3D70D0C8, 0x3D7C6180, 0x3D87EDE0, + 0x3D9375EC, 0x3D9EF9A8, 0x3DAA7918, 0x3DB5F43F, + 0x3DC16B23, 0x3DCCDDC7, 0x3DD84C2E, 0x3DE3B65D, + 0x3DEF1C58, 0x3DFA7E22, 0x3E05DBC0, 0x3E113535, + 0x3E1C8A85, 0x3E27DBB3, 0x3E3328C4, 0x3E3E71BB, + 0x3E49B69C, 0x3E54F76B, 0x3E60342B, 0x3E6B6CE0, + 0x3E76A18D, 0x3E81D237, 0x3E8CFEE0, 0x3E98278D, + 0x3EA34C40, 0x3EAE6CFE, 0x3EB989CA, 0x3EC4A2A8, + 0x3ECFB79A, 0x3EDAC8A5, 0x3EE5D5CB, 0x3EF0DF10, + 0x3EFBE478, 0x3F06E606, 0x3F11E3BE, 0x3F1CDDA2, + 0x3F27D3B6, 0x3F32C5FD, 0x3F3DB47B, 0x3F489F32, + 0x3F538627, 0x3F5E695C, 0x3F6948D5, 0x3F742494, + 0x3F7EFC9D, 0x3F89D0F3, 0x3F94A19A, 0x3F9F6E94, + 0x3FAA37E4, 0x3FB4FD8E, 0x3FBFBF94, 0x3FCA7DFB, + 0x3FD538C4, 0x3FDFEFF3, 0x3FEAA38A, 0x3FF5538E, + 0x40000000 +}; + + diff --git a/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.h b/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.h new file mode 100644 index 0000000..b54c5bf --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/pvmp3_tables.h @@ -0,0 +1,124 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: pvmp3_tables.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PVMP3_TABLES_H +#define PVMP3_TABLES_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pvmp3_dec_defs.h" +#include "pv_mp3_huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ +#define Qfmt_28(a) (int32(double(0x10000000)*a)) + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +typedef struct +{ + int16 l[23]; + int16 s[14]; +} mp3_scaleFactorBandIndex; + + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + extern const int32 mp3_s_freq[4][4]; + extern const int32 inv_sfreq[4]; + extern const int16 mp3_bitrate[3][15]; + extern const int32 power_one_third[513]; + + extern const mp3_scaleFactorBandIndex mp3_sfBandIndex[9]; + extern const int32 mp3_shortwindBandWidths[9][13]; + extern const int32 pqmfSynthWin[(HAN_SIZE/2) + 8]; + + + extern const uint16 huffTable_1[]; + extern const uint16 huffTable_2[]; + extern const uint16 huffTable_3[]; + extern const uint16 huffTable_5[]; + extern const uint16 huffTable_6[]; + extern const uint16 huffTable_7[]; + extern const uint16 huffTable_8[]; + extern const uint16 huffTable_9[]; + extern const uint16 huffTable_10[]; + extern const uint16 huffTable_11[]; + extern const uint16 huffTable_12[]; + extern const uint16 huffTable_13[]; + extern const uint16 huffTable_15[]; + extern const uint16 huffTable_16[]; + extern const uint16 huffTable_24[]; + extern const uint16 huffTable_32[]; + extern const uint16 huffTable_33[]; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif diff --git a/media/libstagefright/codecs/mp3dec/src/s_huffcodetab.h b/media/libstagefright/codecs/mp3dec/src/s_huffcodetab.h new file mode 100644 index 0000000..874943d --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/s_huffcodetab.h @@ -0,0 +1,98 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + + PacketVideo Corp. + MP3 Decoder Library + + Filename: s_huffcodetab.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO MPEG Audio Subgroup Software Simulation Group (1996) + ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension + +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_HUFFCODETAB_H +#define S_HUFFCODETAB_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define HUFF_TBL 34 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +struct huffcodetab +{ + uint32 linbits; /*number of linbits */ + uint16(*pdec_huff_tab)(tmp3Bits *); +}; + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/s_mp3bits.h b/media/libstagefright/codecs/mp3dec/src/s_mp3bits.h new file mode 100644 index 0000000..b905b9a --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/s_mp3bits.h @@ -0,0 +1,107 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: s_mp3bits.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, BITS + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_MP3BITS_H +#define S_MP3BITS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +/* + * Name: BITS + * Description: Holds information for processing the input data buffer + * as a "stream". The data is in packed format. + * Fields: + * pBuffer - pointer to the beginning of the buffer. If the data type of + * this changes, make sure to update the constants in ibstream.h + * usedBits - number of bits read thus far from the buffer. Bit 0 is + * the LSB of pBuffer[0]. + */ + + +typedef struct +{ + uint8 *pBuffer; + uint32 usedBits; + uint32 inputBufferCurrentLength; + uint32 offset; +} tmp3Bits; + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/media/libstagefright/codecs/mp3dec/src/s_tmp3dec_chan.h b/media/libstagefright/codecs/mp3dec/src/s_tmp3dec_chan.h new file mode 100644 index 0000000..6eb8835 --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/s_tmp3dec_chan.h @@ -0,0 +1,110 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: s_tmp3dec_chan.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, tmp3dec_chan. + This structure contains information per channel that needs to persist + between calls + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_TMP3DEC_CHAN_H +#define S_TMP3DEC_CHAN_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pvmp3_audio_type_defs.h" +#include "pvmp3_dec_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct + { + int32 used_freq_lines; + int32 overlap[SUBBANDS_NUMBER*FILTERBANK_BANDS]; + int32 work_buf_int32[SUBBANDS_NUMBER*FILTERBANK_BANDS]; /* working buffer */ + int32 circ_buffer[480 + 576]; + + } tmp3dec_chan; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + diff --git a/media/libstagefright/codecs/mp3dec/src/s_tmp3dec_file.h b/media/libstagefright/codecs/mp3dec/src/s_tmp3dec_file.h new file mode 100644 index 0000000..805cedb --- /dev/null +++ b/media/libstagefright/codecs/mp3dec/src/s_tmp3dec_file.h @@ -0,0 +1,118 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + PacketVideo Corp. + MP3 Decoder Library + + Filename: s_tmp3dec_file.h + + Date: 09/21/2007 + +------------------------------------------------------------------------------ + REVISION HISTORY + + Description: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, tmp3dec_file. + This structure contains information that needs to persist between calls + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_TMP3DEC_FILE_H +#define S_TMP3DEC_FILE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_tmp3dec_chan.h" +#include "s_mp3bits.h" +#include "s_huffcodetab.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct + { + int32 num_channels; + int32 predicted_frame_size; + int32 frame_start; + int32 Scratch_mem[168]; + tmp3dec_chan perChan[CHAN]; + mp3ScaleFactors scaleFactors[CHAN]; + mp3SideInfo sideInfo; + tmp3Bits mainDataStream; + uint8 mainDataBuffer[BUFSIZE]; + tmp3Bits inputStream; + huffcodetab ht[HUFF_TBL]; + } tmp3dec_file; + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ + +#endif + + + + -- cgit v1.1