diff --git a/Android.bp b/Android.bp index 48b0ccc..dfb86d0 100644 --- a/Android.bp +++ b/Android.bp @@ -11,7 +11,8 @@ cc_library_static { ], export_include_dirs: [ - "decoder" + "decoder", + "decoder/drc_src" ], srcs: [ @@ -215,7 +216,8 @@ cc_library_static { "decoder/armv7/ixheaacd_fft_15_ld.s", "decoder/armv7/ixheaacd_aac_ld_dec_rearrange.s", "decoder/armv7/ixheaacd_fft32x32_ld2_armv7.s", - "decoder/armv7/ixheaacd_apply_scale_fac.s" + "decoder/armv7/ixheaacd_apply_scale_fac.s", + "decoder/armv7/ixheaacd_tns_ar_filter_fixed.s" ], } }, @@ -248,6 +250,7 @@ cc_library_static { "decoder/armv8/ixheaacd_apply_scale_factors.s", "decoder/armv8/ixheaacd_cos_sin_mod_loop1.s", "decoder/armv8/ixheaacd_cos_sin_mod_loop2.s", + "decoder/armv8/ixheaacd_post_twiddle_overlap.s", ], }, diff --git a/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c b/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c index 9cc568a..8b4efcc 100644 --- a/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c +++ b/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c @@ -134,7 +134,7 @@ VOID(*ixheaacd_harm_idx_zerotwolp) VOID(*ixheaacd_tns_ar_filter_fixed) (WORD32 *spectrum, WORD32 size, WORD32 inc, WORD32 *lpc, WORD32 order, - WORD32 shift_value, WORD scale_spec) = &ixheaacd_tns_ar_filter_fixed_armv7; + WORD32 shift_value, WORD scale_spec) = &ixheaacd_tns_ar_filter_fixed_non_neon_armv7; VOID(*ixheaacd_tns_ar_filter) (WORD32 *spectrum, WORD32 size, WORD32 inc, WORD16 *lpc, WORD32 order, diff --git a/decoder/armv7/ixheaacd_post_twiddle.s b/decoder/armv7/ixheaacd_post_twiddle.s index 79144da..4d9d2dd 100644 --- a/decoder/armv7/ixheaacd_post_twiddle.s +++ b/decoder/armv7/ixheaacd_post_twiddle.s @@ -212,7 +212,7 @@ NEON_PROLOGUE: -CORE_LOOP: +CORE_LOOP_PT: VMULL.U16 Q15, D2, D13 VST2.32 {Q12, Q13}, [R7], R8 VMULL.U16 Q14, D0, D13 @@ -315,7 +315,7 @@ CORE_LOOP: VADD.I32 Q8, Q11, Q8 SUBS R3, R3, #1 - BNE CORE_LOOP + BNE CORE_LOOP_PT diff --git a/decoder/armv7/ixheaacd_post_twiddle_overlap.s b/decoder/armv7/ixheaacd_post_twiddle_overlap.s index f04f3fc..391e1c6 100644 --- a/decoder/armv7/ixheaacd_post_twiddle_overlap.s +++ b/decoder/armv7/ixheaacd_post_twiddle_overlap.s @@ -445,7 +445,7 @@ PROLOGUE_NEON: VUZP.16 D22, D23 VMOV D23, D30 -CORE_LOOP: +CORE_LOOP_PTO: VST1.16 D14[0], [R0, : 16], R9 VMULL.U16 Q15, D0, D9 @@ -709,7 +709,7 @@ CORE_LOOP: VMOV D23, D30 SUBS R3, R3, #1 - BNE CORE_LOOP + BNE CORE_LOOP_PTO diff --git a/decoder/armv7/ixheaacd_pre_twiddle_compute.s b/decoder/armv7/ixheaacd_pre_twiddle_compute.s index 4e586c0..6cc22aa 100644 --- a/decoder/armv7/ixheaacd_pre_twiddle_compute.s +++ b/decoder/armv7/ixheaacd_pre_twiddle_compute.s @@ -186,7 +186,7 @@ NEON_PROLOGUE: SUB R4, R4, #2 -CORE_LOOP: +CORE_LOOP_PTC: VMULL.U16 Q15, D2, D9 VST2.32 {Q8, Q9}, [R2]! VMULL.U16 Q14, D4, D9 @@ -248,7 +248,7 @@ CORE_LOOP: VSHL.S32 Q8, Q14, Q7 SUBS R4, R4, #1 - BNE CORE_LOOP + BNE CORE_LOOP_PTC NEON_EPILOGUE: VMULL.U16 Q15, D2, D9 diff --git a/decoder/armv7/ixheaacd_tns_ar_filter_fixed.s b/decoder/armv7/ixheaacd_tns_ar_filter_fixed.s new file mode 100644 index 0000000..d0b2dd2 --- /dev/null +++ b/decoder/armv7/ixheaacd_tns_ar_filter_fixed.s @@ -0,0 +1,553 @@ + +@/****************************************************************************** +@ * +@ * Copyright (C) 2018 The Android Open Source Project +@ * +@ * 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. +@ * +@ ***************************************************************************** +@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +@*/ + + +.text +.p2align 2 + +.text +.p2align 2 + .global ixheaacd_tns_ar_filter_fixed_armv7 + +ixheaacd_tns_ar_filter_fixed_armv7: + STMFD r13! , {r4 - r12, r14} + vpush {d8-d15} + SUB sp, sp, #128 @ state[MaximumOrder] + one more + LDR r4, [sp,#232] @order + LDR r6, [sp,#236] @shift_value + STR r1, [sp] + ADD r12, sp, #4 @ r12 = state + ANDS r5, r4, #3 + BEQ FILTER_LOOP + MOV r8, #0 + ADD r14, r3, r4,LSL #2 + RSBS r7, r5, #3 + BEQ ORDER_LOOPEND +ORDER_LOOP: + STR r8, [r14,#4]! @lpc[i] = 0 + SUBS r7, r7, #1 + BGT ORDER_LOOP +ORDER_LOOPEND: + STR r8, [r14,#4] @lpc[i] = 0 + BIC r4, r4, #3 + ADD r4, r4, #4 @order = ( (order & 0xfffffffc) +4 ) + + +FILTER_LOOP: + LDR r1, [sp,#240] @scaleSpec +@filtering loop here + CMP r2, #1 @ inc =1 or -1 + MOV r7, r4 @loop_count + BNE NEG_INC + + LDR r8 , [r0] @r8 =*spectrum + SUBS r7 , r7 , #1 + MOV r8, r8, lsl r1 + MOV r9, r8, asr r1 + MOV r8 , r8 ,lsl r6 + STR r8 , [r12] @state[0] = sp[top] + STR r9, [r0], #4 + BEQ FILTER_LOOP2 +FILTER_LOOP1: @siva 16 times loop run + LDR r8 , [r0] @r8 =*spectrum + SUB r5 , r4 , r7 @ + MOV r5 , r5 ,lsl #2 + MOV r11 , #0 @accu = 0 + ADD r14, r12, r5 @state[j] +INNER_LOOP1: + LDR r10 , [r14,#-4] @state[j-1] + LDR r9 , [r3 , r5] @lpc[j] + SUBS r5 , r5 , #4 + + MOV r2, #0 + SMLAL r2 , r11, r10, r9 + STR r10 , [r14], #-4 @state[j] = state[j - 1] + BGT INNER_LOOP1 + + MOV r8, r8, lsl r1 + SUB r8 , r8 , r11,lsl #1 + MOV r9, r8, asr r1 + STR r9 , [r0], #4 @*spectrum = y@ + SUBS r7 , r7 , #1 @i-- + MOV r8 , r8 ,lsl r6 + STR r8 , [r12] @state[0] + BGT FILTER_LOOP1 + + + +@inc=1,order=4 + + + +FILTER_LOOP2: + LDR R1, [sp] @size + ADD R8, R3, #4 + + SUBS R7 , R1 , r4 @size-order + BEQ EXIT + + LDR R1, [sp,#240] @scaleSpec + + MOV R5 , R4 ,LSL #2 @count for inner loop = order + VLD1.32 {D10, D11}, [R8]! @lpc[j] + MOV R14,#0 + VLD1.32 {D12, D13}, [R12]! @state[j - 1] + + CMP R4,#4 + VLD1.32 {D18, D19}, [R8]! + BEQ ORDER4 + VLD1.32 {D22, D23}, [R12]! + + CMP R4,#8 + VLD1.32 {D20, D21}, [R8]! + BEQ ORDER8 + CMP R4,#12 + VLD1.32 {D24, D25}, [R12]! + BEQ ORDER12 + + VLD1.32 {D26, D27},[R8]! + CMP R4,#16 + VLD1.32 {D28, D29},[R12]! + BEQ ORDER16 @order16 added + + VLD1.32 {D4, D5},[R8]! + CMP R4,#20 + VLD1.32 {D8, D9},[R12]! + BEQ ORDER20 @order20 added + +ORDER4: + LDR r8 , [r0] @r8 = y = *spectrum +OUTER_LOOP2_4: + + VDUP.32 Q1,R14 @Q1= accu = 0 + + VMLAL.S32 Q1, D10, D12 + + VMLAL.S32 Q1, D11, D13 + + MOV r8, r8, lsl r1 @y = (*spectrum) << scaleSpec + SUBS r7 , r7 , #1 + + VADD.I64 D6,D2,D3 + + VSHR.S64 D6,#32 @acc1=acc>>32 @acc = mac32_tns_neon(state[j - 1],lpc[j],acc, temp_lo)@ + @VMOV R11,D6[0] + VST1.32 D6[0],[SP] + LDR R11,[SP] + + SUB r8 , r8 , r11,lsl #1 @y=sub32(y,(acc<<1)) + MOV r2 , r8 ,lsl r6 @ shl32(y, shift_value) + + MOV r9, r8, asr r1 + VMOV.32 D15[1], R2 @state[0] + + + STR r9 , [r0],#4 @*spectrum = y@ + VEXT.32 Q6,Q7,Q6,#3 + LDRGT r8 , [r0] @r8 = y = *spectrum + + BGT OUTER_LOOP2_4 + + B EXIT +ORDER8: + + LDR r8 , [r0] @r8 = y = *spectrum + +OUTER_LOOP2_8: + + VDUP.32 Q1,R14 @Q1= accu = 0 + + + + VMLAL.S32 Q1, D10, D12 + VMLAL.S32 Q1, D11, D13 + VMLAL.S32 Q1, D22, D18 + VMLAL.S32 Q1, D23, D19 + + MOV r8, r8, lsl r1 @y = (*spectrum) << scaleSpec + VEXT.32 Q11,Q6,Q11,#3 + SUBS r7 , r7 , #1 + + VADD.I64 D6,D2,D3 + VSHR.S64 D6,#32 @acc = mac32_tns_neon(state[j - 1],lpc[j],acc, temp_lo)@ + + @VMOV R11,D6[0] + VST1.32 D6[0],[SP] + LDR R11,[SP] + SUB r8 , r8 , r11,lsl #1 @y=sub32(y,(acc<<1)) + + MOV r2 , r8 ,lsl r6 @ shl32(y, shift_value) + + MOV r9, r8, asr r1 + VMOV.32 D15[1], R2 @state[0] + + STR r9 , [r0],#4 @*spectrum = y@ + VEXT.32 Q6,Q7,Q6,#3 + LDRGT r8 , [r0] @r8 = y = *spectrum + + + BGT OUTER_LOOP2_8 + + B EXIT + + + + +ORDER12: + LDR r8 , [r0] @r8 = y = *spectrum +OUTER_LOOP2_12: + + + VDUP.32 Q1,R14 @Q1= accu = 0 + + + VMLAL.S32 Q1, D10, D12 + VMLAL.S32 Q1, D11, D13 + VMLAL.S32 Q1, D22, D18 + VMLAL.S32 Q1, D23, D19 + VMLAL.S32 Q1, D24, D20 + VMLAL.S32 Q1, D25, D21 + + MOV r8, r8, lsl r1 @y = (*spectrum) << scaleSpec + VEXT.32 Q12,Q11,Q12,#3 + SUBS r7 , r7 , #1 + + VADD.I64 D6,D2,D3 + VEXT.32 Q11,Q6,Q11,#3 + VSHR.S64 D6,#32 + + @VMOV R11,D6[0] + VST1.32 D6[0],[SP] + LDR R11,[SP] + SUB r8 , r8 , r11,lsl #1 @y=sub32(y,(acc<<1)) + + MOV r2 , r8 ,lsl r6 @ shl32(y, shift_value) + + + MOV r9, r8, asr r1 + VMOV.32 D15[1], R2 @state[0] + + + STR r9 , [r0],#4 @*spectrum = y@ + VEXT.32 Q6,Q7,Q6,#3 + LDRGT r8 , [r0] @r8 = y = *spectrum + + BGT OUTER_LOOP2_12 + + B EXIT + + +ORDER16: + LDR r8 , [r0] @r8 = y = *spectrum +OUTER_LOOP2_16: + + + VDUP.32 Q1,R14 @Q1= accu = 0 + + + VMLAL.S32 Q1, D10, D12 + VMLAL.S32 Q1, D11, D13 + VMLAL.S32 Q1, D22, D18 + VMLAL.S32 Q1, D23, D19 + VMLAL.S32 Q1, D24, D20 + VMLAL.S32 Q1, D25, D21 + VMLAL.S32 Q1, D28, D26 @ + VMLAL.S32 Q1, D29, D27 @ @order16 + + VEXT.32 Q14,Q12,Q14,#3 + MOV r8, r8, lsl r1 @y = (*spectrum) << scaleSpec + VEXT.32 Q12,Q11,Q12,#3 + SUBS r7 , r7 , #1 + + VADD.I64 D6,D2,D3 + VEXT.32 Q11,Q6,Q11,#3 + VSHR.S64 D6,#32 + + @VMOV R11,D6[0] + VST1.32 D6[0],[SP] + LDR R11,[SP] + SUB r8 , r8 , r11,lsl #1 @y=sub32(y,(acc<<1)) + + MOV r2 , r8 ,lsl r6 @ shl32(y, shift_value) + + + MOV r9, r8, asr r1 + VMOV.32 D15[1], R2 @state[0] + + + STR r9 , [r0],#4 @*spectrum = y@ + VEXT.32 Q6,Q7,Q6,#3 + LDRGT r8 , [r0] @r8 = y = *spectrum + + BGT OUTER_LOOP2_16 + + B EXIT + +ORDER20: + LDR r8 , [r0] @r8 = y = *spectrum +OUTER_LOOP2_20: + + + VDUP.32 Q1,R14 @Q1= accu = 0 + + + VMLAL.S32 Q1, D10, D12 + VMLAL.S32 Q1, D11, D13 + VMLAL.S32 Q1, D22, D18 + VMLAL.S32 Q1, D23, D19 + VMLAL.S32 Q1, D24, D20 + VMLAL.S32 Q1, D25, D21 + VMLAL.S32 Q1, D28, D26 @ + VMLAL.S32 Q1, D29, D27 @ @order16 + VMLAL.S32 Q1, D8, D4 @order20 + VMLAL.S32 Q1, D9, D5 @order20 + + + VEXT.32 Q4,Q14,Q4,#3 @ @for order20 + VEXT.32 Q14,Q12,Q14,#3 @ @for order16 + MOV r8, r8, lsl r1 @y = (*spectrum) << scaleSpec + VEXT.32 Q12,Q11,Q12,#3 @order12 + SUBS r7 , r7 , #1 + + VADD.I64 D6,D2,D3 + VEXT.32 Q11,Q6,Q11,#3 @order8 + VSHR.S64 D6,#32 + + @VMOV R11,D6[0] + VST1.32 D6[0],[SP] + LDR R11,[SP] + SUB r8 , r8 , r11,lsl #1 @y=sub32(y,(acc<<1)) + + MOV r2 , r8 ,lsl r6 @ shl32(y, shift_value) + + + MOV r9, r8, asr r1 + VMOV.32 D15[1], R2 @state[0] + + + STR r9 , [r0],#4 @*spectrum = y@ + VEXT.32 Q6,Q7,Q6,#3 + LDRGT r8 , [r0] @r8 = y = *spectrum + + BGT OUTER_LOOP2_20 + + B EXIT + +NEG_INC: +@ filtering loop for inc = -1 + + LDR r8 , [r0] @r8 =*spectrum + SUBS r7 , r7 , #1 + MOV r8, r8, lsl r1 + MOV r9, r8, asr r1 + MOV r8 , r8 ,lsl r6 + STR r8 , [r12] @state[0] = sp[top] + STR r9, [r0], #-4 + BEQ NEGFILTER_LOOP2 +NEGFILTER_LOOP1: + LDR r8 , [r0] @r8 =*spectrum + SUB r5 , r4 , r7 @ + MOV r5 , r5 ,lsl #2 + MOV r11 , #0 @accu = 0 + ADD r14, r12, r5 @state[j] +NEGINNER_LOOP1: + LDR r10 , [r14,#-4] @state[j-1] + LDR r9 , [r3 , r5] @lpc[j] + SUBS r5 , r5 , #4 + + MOV r2, #0 + SMLAL r2 , r11, r10, r9 + STR r10 , [r14], #-4 @state[j] = state[j - 1] + BGT NEGINNER_LOOP1 + + MOV r8, r8, lsl r1 + SUB r8 , r8 , r11,lsl #1 + MOV r9, r8, asr r1 + STR r9 , [r0], #-4 @*spectrum = y@ + SUBS r7 , r7 , #1 @i-- + MOV r8 , r8 ,lsl r6 + STR r8 , [r12] @state[0] + BGT NEGFILTER_LOOP1 + +NEGFILTER_LOOP2: + LDR R1, [sp] @size + SUBS R7 , R1 , r4 @size-order + BEQ EXIT + + ADD R8, R3, #4 + + MOV R14,#0 + VLD1.32 {D10, D11}, [R8]! @lpc[j] + MOV R5 , R4 ,LSL #2 @count for inner loop = order + + LDR R1, [sp,#240] @scaleSpec + + CMP R4,#4 + VLD1.32 {D12, D13}, [R12]! @state[j - 1] + BEQ NEGORDER4 + + VLD1.32 {D18, D19}, [R8]! + CMP R4,#8 + + VLD1.32 {D22, D23}, [R12]! + BEQ NEGORDER8 + + VLD1.32 {D20, D21}, [R8]! + CMP R4,#12 + + VLD1.32 {D24, D25}, [R12]! + BEQ NEGORDER12 + + + + + +NEGORDER4: + LDR r8 , [r0] @r8 = y = *spectrum + +NEGOUTER_LOOP2_4: + + VDUP.32 Q1,R14 @Q1= accu = 0 + + + VMLAL.S32 Q1, D10, D12 + VMLAL.S32 Q1, D11, D13 + MOV r8, r8, lsl r1 @y = (*spectrum) << scaleSpec + SUBS r7 , r7 , #1 + + VADD.I64 D6,D2,D3 + VSHR.S64 D6,#32 + + + + @VMOV R11,D6[0] + VST1.32 D6[0],[SP] + LDR R11,[SP] + SUB r8 , r8 , r11,lsl #1 @y=sub32(y,(acc<<1)) + + MOV r2 , r8 ,lsl r6 + + VMOV.32 D15[1], R2 + MOV r9, r8, asr r1 + + + STR r9 , [r0],#-4 @*spectrum = y@ + VEXT.32 Q6,Q7,Q6,#3 + LDRGT r8 , [r0] @r8 = y = *spectrum + + BGT NEGOUTER_LOOP2_4 + + B EXIT +NEGORDER8: + + LDR r8 , [r0] @r8 = y = *spectrum + +NEGOUTER_LOOP2_8: + + VDUP.32 Q1,R14 @Q1= accu = 0 + + + + VMLAL.S32 Q1, D10, D12 + VMLAL.S32 Q1, D11, D13 + VMLAL.S32 Q1, D22, D18 + VMLAL.S32 Q1, D23, D19 + + MOV r8, r8, lsl r1 @y = (*spectrum) << scaleSpec + VEXT.32 Q11,Q6,Q11,#3 + SUBS r7 , r7 , #1 + + VADD.I64 D6,D2,D3 + + VSHR.S64 D6,#32 + + + @VMOV R11,D6[0] + VST1.32 D6[0],[SP] + LDR R11,[SP] + SUB r8 , r8 , r11,lsl #1 @y=sub32(y,(acc<<1)) + MOV r2 , r8 ,lsl r6 @ shl32(y, shift_value) + + VMOV.32 D15[1], R2 @state[0] + MOV r9, r8, asr r1 + + + STR r9 , [r0],#-4 @*spectrum = y@ + VEXT.32 Q6,Q7,Q6,#3 + LDRGT r8 , [r0] @r8 = y = *spectrum + + + BGT NEGOUTER_LOOP2_8 + + B EXIT + + + + +NEGORDER12: + LDR r8 , [r0] @r8 = y = *spectrum + +NEGOUTER_LOOP2_12: + + VDUP.32 Q1,R14 @Q1= accu = 0 + + + + VMLAL.S32 Q1, D10, D12 + VMLAL.S32 Q1, D11, D13 + VMLAL.S32 Q1, D22, D18 + VMLAL.S32 Q1, D23, D19 + VMLAL.S32 Q1, D24, D20 + VMLAL.S32 Q1, D25, D21 + + MOV r8, r8, lsl r1 @y = (*spectrum) << scaleSpec + VEXT.32 Q12,Q11,Q12,#3 + SUBS r7 , r7 , #1 + + VADD.I64 D6,D2,D3 + VEXT.32 Q11,Q6,Q11,#3 + VSHR.S64 D6,#32 + + + @VMOV R11,D6[0] + VST1.32 D6[0],[SP] + LDR R11,[SP] + SUB r8 , r8 , r11,lsl #1 @y=sub32(y,(acc<<1)) + + MOV r2 , r8 ,lsl r6 @ shl32(y, shift_value) + + VMOV.32 D15[1], R2 @state[0] + MOV r9, r8, asr r1 + + + + STR r9 , [r0],#-4 @*spectrum = y@ + VEXT.32 Q6,Q7,Q6,#3 + LDRGT r8 , [r0] @r8 = y = *spectrum + + + BGT NEGOUTER_LOOP2_12 + + +EXIT: + ADD sp, sp ,#128 + vpop {d8-d15} + LDMFD r13!, {r4 - r12, r15} diff --git a/decoder/armv8/ixheaacd_post_twiddle_overlap.s b/decoder/armv8/ixheaacd_post_twiddle_overlap.s new file mode 100644 index 0000000..aa6b70f --- /dev/null +++ b/decoder/armv8/ixheaacd_post_twiddle_overlap.s @@ -0,0 +1,2033 @@ +.macro push_v_regs + stp q8, q9, [sp, #-32]! + stp q10, q11, [sp, #-32]! + stp q12, q13, [sp, #-32]! + stp q14, q15, [sp, #-32]! +//st1 { v8.2d, v9.2d, v10.2d, v11.2d}, [sp, #-64]! +//st1 {v12.2d, v13.2d, v14.2d, v15.2d}, [sp, #-64]! + stp X8, X9, [sp, #-16]! + stp X10, X11, [sp, #-16]! + stp X12, X13, [sp, #-16]! + stp X14, X15, [sp, #-16]! + stp X16, X17, [sp, #-16]! + stp X18, X19, [sp, #-16]! + stp X20, X21, [sp, #-16]! + stp X22, X23, [sp, #-16]! + stp X24, X25, [sp, #-16]! + stp X26, X27, [sp, #-16]! + stp X28, X29, [sp, #-16]! + stp X30, X29, [sp, #-16]! +.endm + +.macro pop_v_regs + ldp X30, X29, [sp], #16 + ldp X28, X29, [sp], #16 + ldp X26, X27, [sp], #16 + ldp X24, X25, [sp], #16 + ldp X22, X23, [sp], #16 + ldp X20, X21, [sp], #16 + ldp X18, X19, [sp], #16 + ldp X16, X17, [sp], #16 + ldp X14, X15, [sp], #16 + ldp X12, X13, [sp], #16 + ldp X10, X11, [sp], #16 + ldp X8, X9, [sp], #16 +//ld1 {v12.2d, v13.2d, v14.2d, v15.2d}, [sp], #64 +//ld1 { v8.2d, v9.2d, v10.2d, v11.2d}, [sp], #64 + ldp q14, q15, [sp], #32 + ldp q12, q13, [sp], #32 + ldp q10, q11, [sp], #32 + ldp q8, q9, [sp], #32 +.endm + + +.text +.p2align 2 +.global ixheaacd_post_twid_overlap_add_armv8 + +ixheaacd_post_twid_overlap_add_armv8: + + // STMFD sp!, {x4-x12} + push_v_regs + //stp x19, x20,[sp,#-16]! + //VPUSH {d8 - d15} + + //LDR w4, [sp, #100] + //sxtw x4,w4 + //LDR w5, [sp, #104] + //sxtw x5,w5 + //LDR w6, [sp, #108] + //sxtw x6,w6 + MOV x16, x5 + MOV x17, x7 + LSL x9, x3, #2 + ASR x9, x9, #1 + ADD x6, x6, x9 + SUB x6, x6, #4 + + LDR w8, =7500 + sxtw x8,w8 + ADD x2, x2, x8 + + + + movi v18.4h, #50 + sub x20, x5, #15 + neg x9, x20 + movi v20.4s, #0x80, LSL #8 + dup v16.4s,w5 + SUB x5, x5, #16 + //STR w5, [sp, #116] + MOV w25, w5 + sxtw x25,w25 + MOV x8, #1 + LSL x8, x8, x9 + //STR w8, [sp, #120] + MOV w26, w8 + + //sxtw x8,w8 + + +ARM_PROLOGUE: + + + LDR w8, [x1], #4 + sxtw x8,w8 + LDR w9, [x1], #4 + sxtw x9,w9 + + LDR w10, [x2], #4 + sxtw x10,w10 + + AND w19,w10,0xFFFF + sxth x19,w19 + ASR w10,w10,#16 +// SMULWT x11, x8, x10 +// +// SMULWB x12, x9, x10 +// SMULWB x5, x8, x10 +// SMLAWT x7, x9, x10, x5 + + SMULL x11, w8, w10 + ASR x11,x11,#16 + SMULL x12, w9, w19 + ASR x12,x12,#16 + SMULL x5, w8, w19 + ASR x5,x5,#16 + SMULL x7, w9, w10 + ASR x7, x7, #16 + ADD x7, x7, x5 + + SUB x8, x12, x11 + MVN x5, x7 + ADD x5, x5, #1 + + + MOV x9, #50 + MOV x12, #-50 + AND w19,w9,0xFFFF + sxth x19,w19 + SMULL x10, w5, w19 + ASR x10,x10,#16 + AND w19,w12,0xFFFF + sxth x19,w19 + SMULL x11, w8, w19 + ASR x11,x11,#16 + + ADD x8, x8, x10 + ADD x5, x5, x11 + + //LDR w11, [sp, #104] + MOV w11, w16 + sxth x11,w11 + LDR w10, [x6], #-32 + sxtw x10,w10 + + AND w19,w10,0xFFFF + sxth x19,w19 + ASR w20,w10,#16 + + //SMULWB x7, x8, x10 + SMULL x7, w8, w19 + ASR x7, x7, #16 + MVN x8, x8 + ADD x8, x8, #1 + //SMULWT x12, x8, x10 + SMULL x12, w8, w20 + ASR x12, x12, #16 + + CMP x11, #0 + BLT NEXT + + SUB x9, x11, #16 + negs x9,x9 + + + + + // LDR w8, [sp, #120] + //sxtw x8,w8 + MOV v1.s[0], w26 + MOV v2.s[0], w5 + + //sQADD w5, w5, w8 + //ASR w5, w5, w9 + + SQADD v2.2s, v2.2s, v1.2s + MOV w5, v2.s[0] + ASR w5, w5, w9 + + SUB x9, x11, #31 + negs x9,x9 + ASR x20, x7, x9 + //MOV x8, x20 + ADDS x8, x20, #0 + BGE NEXT2 + CMN x8, #1 +NEXT2: + LDR x20,=0x80000000 + csel x7, x20, x7,LT + LDR x20,=0x7fffffff + csel x7, x20, x7,GT + LSL x20, x7, x11 + csel x7,x20,x7,EQ + + SUB x9, x11, #31 + negs x9,x9 + ASR x20, x12, x9 + //MOV x8, x20 + ADDS x8, x20, #0 + BGE NEXT3 + CMN x8, #1 +NEXT3: + LDR x20,=0x80000000 + csel x12, x20, x12,LT + LDR x20,=0x7fffffff + csel x12, x20, x12,GT + LSL x20, x12, x11 + csel x12,x20,x12,EQ + + B NEXT1 +NEXT: + MVN w11, w11 + ADD w11, w11, #1 + ASR w5, w5, w11 + MOV w8, #0x8000 + + MOV v1.s[0], w8 + MOV v2.s[0], w5 + + //QADD x5, x5, x8 + + SQADD v2.2s, v2.2s, v1.2s + MOV w5, v2.s[0] + + ASR w5, w5, #16 + ASR w7, w7, w11 + ASR w12, w12, w11 + +NEXT1: + LDR w9, [x4] + sxtw x9,w9 + MOV w8, #0x8000 + //sxtw x8,w8 + + STR w5, [x4], #4 + sxtw x5,w5 + + + ROR w20, w10, #16 + //UXTH x5, x10, ROR #16 + UXTH w5, w20 + UXTH w10, w10 + + + dup v0.2s,w9 + dup v2.2s,w10 + dup v3.2s,w5 + //VZIP.32 D2, D3 + ZIP1 v28.2s, v2.2s, v3.2s + ZIP2 v3.2s, v2.2s, v3.2s + MOV v2.8b, v28.8b + sMULL v0.2d, v2.2s, v0.2s + Sqxtn v8.2s, v0.2d + + + dup v0.2s,w12 + dup v1.2s,w7 + + //VZIP.32 D0, D1 + + ZIP1 v28.2s, v0.2s, v1.2s + ZIP2 v1.2s, v0.2s, v1.2s + MOV v0.8b, v28.8b + + SQSUB v8.2s, v0.2s , v8.2s + + + sQshL v8.2s, v8.2s,#2 + dup v0.2s,w8 + SQADD v8.2s, v8.2s , v0.2s + sshR v8.2s, v8.2s,#16 + + + + MOV x7, x17 + //sxtw x7,w7 + LSL x10, x7, #1 + + ASR x5, x3, #1 + //SMULBB x5, x10, x5 + AND w5,w5,0xFFFF + sxth x5,w5 + AND w19,w10,0xFFFF + sxth x19,w19 + SMULL x5, w19, w5 + + ADD x5, x5, x0 + SUB x0, x5, x10 + MVN x9, x10 + ADD x9, x9, #1 + + ST1 {v8.h}[2],[x0], x9 + ST1 {v8.h}[0],[x5], x10 + + + MOV x8, x1 + LSL x12, x3, #2 + + ADD x1, x1, x12 + + SUB x1, x1, #40 + + MOV x12, #-32 + + + +PROLOGUE_NEON: + + ASR x3, x3, #2 + SUB x3, x3, #4 + ASR x3, x3, #2 + SUB x3, x3, #2 + + LD2 { v0.4s, v1.4s}, [x1] + MOV v2.16b, v1.16b + ADD x1, x1, x12 + + //VUZP.16 D0, D1 + UZP1 v28.8h, v0.8h, v0.8h + UZP2 v29.8h, v0.8h, v0.8h + MOV v0.d[0], v28.d[0] + MOV v0.d[1], v29.d[0] + + //VUZP.16 D2, D3 + + UZP1 v28.8h, v2.8h, v2.8h + UZP2 v29.8h, v2.8h, v2.8h + MOV v2.d[0], v28.d[0] + MOV v2.d[1], v29.d[0] + + + //rev64 v0.8h, v0.8h + rev64 v0.8h, v0.8h + MOV v1.d[0], v0.d[1] + rev64 v2.8h, v2.8h + MOV v3.d[0], v2.d[1] + LD2 {v8.4h, v9.4h}, [x2] + ADD x2, x2, #16 + + LD2 { v4.4s, v5.4s}, [x8] + MOV v6.16b, v5.16b + ADD x8, x8,#32 + uMULL v30.4s, v0.4h, v9.4h + +// VUZP.16 D4, D5 + + UZP1 v28.8h, v4.8h, v4.8h + UZP2 v29.8h, v4.8h, v4.8h + MOV v4.d[0], v28.d[0] + MOV v5.d[0], v29.d[0] + + uMULL v28.4s, v2.4h, v8.4h + +// VUZP.16 D6, D7 + UZP1 v26.8h, v6.8h, v6.8h + UZP2 v27.8h, v6.8h, v6.8h + MOV v6.d[0], v26.d[0] + MOV v7.d[0], v27.d[0] + + uMULL v26.4s, v0.4h, v8.4h + + + uMULL v24.4s, v2.4h, v9.4h + + LD2 { v10.4s, v11.4s}, [x6] + MOV v12.16b, v11.16b + ADD x6, x6, x12 + ushR v30.4s, v30.4s,#16 + + //VUZP.16 D10, D11 + + UZP1 v22.8h, v10.8h, v10.8h + UZP2 v23.8h, v10.8h, v10.8h + MOV v10.d[0], v22.d[0] + MOV v10.d[1], v23.d[0] + + ushR v28.4s, v28.4s,#16 + + //VUZP.16 D12, D13 + + UZP1 v22.8h, v12.8h, v12.8h + UZP2 v23.8h, v12.8h, v12.8h + MOV v12.d[0], v22.d[0] + MOV v12.d[1], v23.d[0] + + sMLAL v30.4s, v1.4h, v9.4h + + rev64 v10.8h, v10.8h + MOV v11.d[0], v10.d[1] + sMLAL v28.4s, v3.4h, v8.4h + + rev64 v12.8h, v12.8h + MOV v13.d[0], v12.d[1] + ushR v26.4s, v26.4s,#16 + + + ushR v24.4s, v24.4s,#16 + + sMLAL v26.4s, v1.4h, v8.4h + sMLAL v24.4s, v3.4h, v9.4h + + + + ADD v30.4s, v30.4s , v28.4s + NEG v30.4s, v30.4s + + uMULL v22.4s, v4.4h, v8.4h + + SUB v28.4s, v24.4s , v26.4s + + + mov v26.16b, v30.16b + mov v24.16b, v28.16b + +// VUZP.16 D24, D25 + + UZP1 v19.8h, v24.8h, v24.8h + UZP2 v21.8h, v24.8h, v24.8h + MOV v24.d[0], v19.d[0] + MOV v25.d[0], v21.d[0] + + +// VUZP.16 D26, D27 + + UZP1 v19.8h, v26.8h, v26.8h + UZP2 v21.8h, v26.8h, v26.8h + MOV v26.d[0], v19.d[0] + MOV v27.d[0], v21.d[0] + + uMULL v2.4s, v24.4h, v18.4h + + uMULL v0.4s, v26.4h, v18.4h + + ushR v22.4s, v22.4s,#16 + sMLAL v22.4s, v5.4h, v8.4h + + ushR v2.4s, v2.4s,#16 + ushR v0.4s, v0.4s,#16 + sMLAL v2.4s, v25.4h, v18.4h + sMLAL v0.4s, v27.4h, v18.4h + + uMULL v24.4s, v4.4h, v9.4h + uMULL v26.4s, v6.4h, v8.4h + + NEG v2.4s, v2.4s + ADD v28.4s, v28.4s , v0.4s + ADD v30.4s, v30.4s , v2.4s + + uMULL v0.4s, v6.4h, v9.4h + sshR v24.4s, v24.4s,#16 + sMLAL v24.4s, v5.4h, v9.4h + sshR v26.4s, v26.4s,#16 + sshR v0.4s, v0.4s,#16 + sMLAL v26.4s, v7.4h, v8.4h + sMLAL v0.4s, v7.4h, v9.4h + + + + + ADD v22.4s, v22.4s , v0.4s + NEG v22.4s, v22.4s + SUB v24.4s, v26.4s , v24.4s + + + + //LDR w11, [sp, #120] + //sxtw x11,w11 + MOV w11, w26 + dup v14.4s,w11 + SQADD v28.4s, v28.4s , v14.4s + //LDR w11, [sp, #116] + MOV w11, w25 + //sxtw x11,w11 + dup v0.4s,w11 + sQshL v28.4s, v28.4s, v0.4s + + mov v0.16b, v22.16b + mov v14.16b, v24.16b + + +// VUZP.16 D24, D25 + + UZP1 v19.8h, v24.8h, v24.8h + UZP2 v21.8h, v24.8h, v24.8h + MOV v24.d[0], v19.d[0] + MOV v25.d[0], v21.d[0] + + +// VUZP.16 D22, D23 + + UZP1 v19.8h, v22.8h, v22.8h + UZP2 v21.8h, v22.8h, v22.8h + MOV v22.d[0], v19.d[0] + MOV v23.d[0], v21.d[0] + + uMULL v8.4s, v24.4h, v18.4h + uMULL v26.4s, v22.4h, v18.4h + + NEG v2.4s, v30.4s +// VUZP.16 D30, D31 + + UZP1 v19.8h, v30.8h, v30.8h + UZP2 v21.8h, v30.8h, v30.8h + MOV v30.d[0], v19.d[0] + MOV v30.d[1], v21.d[0] + +// VUZP.16 D2, D3 + + UZP1 v19.8h, v2.8h, v2.8h + UZP2 v21.8h, v2.8h, v2.8h + MOV v2.d[0], v19.d[0] + MOV v3.d[0], v21.d[0] + + uMULL v4.4s, v30.4h, v12.4h + + uMULL v6.4s, v2.4h, v13.4h + + ushR v8.4s, v8.4s,#16 + ushR v26.4s, v26.4s,#16 + + sMLAL v8.4s, v25.4h, v18.4h + sMLAL v26.4s, v23.4h, v18.4h + + ushR v4.4s, v4.4s,#16 + ushR v6.4s, v6.4s,#16 + + MOV v19.d[0], v30.d[1] + + sMLAL v4.4s, v19.4h, v12.4h + sMLAL v6.4s, v3.4h, v13.4h + + NEG v8.4s, v8.4s + ADD v14.4s, v14.4s , v26.4s + ADD v0.4s, v0.4s , v8.4s + + //LDR w11, [sp, #120] + //sxtw x11,w11 + MOV w11, w26 + dup v8.4s,w11 + SQADD v0.4s, v0.4s , v8.4s + //LDR w11, [sp, #116] + //sxtw x11,w11 + MOV w11, w25 + dup v26.4s,w11 + sQshL v0.4s, v0.4s, v26.4s + + mov v26.16b, v28.16b + + LD2 { v28.4s, v29.4s}, [x4] + MOV v30.16b, v29.16b + MOV v29.d[0], v28.d[1] + // VZIP.32 Q13, Q0 + + ZIP1 v19.4s, v26.4s, v0.4s + ZIP2 v0.4s, v26.4s, v0.4s + MOV v26.16b, v19.16b + + ST1 { v26.4s}, [x4],#16 + ST1 { v0.4s}, [x4],#16 + + movi v1.2s, #0 + //VADDL.S16 Q0, D13, D1 + + SADDL v0.4s, v13.4h, v1.4h + MOV v1.d[0], v0.d[1] + sMULL v26.2d, v28.2s, v0.2s + Sqxtn v8.2s, v26.2d + sMULL v26.2d, v29.2s, v1.2s + Sqxtn v9.2s, v26.2d + MOV v8.d[1], v9.d[0] + movi v1.2s, #0 +// VADDL.S16 Q0, D12, D1 + SADDL v0.4s, v12.4h, v1.4h + MOV v1.d[0], v0.d[1] + sMULL v24.2d, v28.2s, v0.2s + Sqxtn v26.2s, v24.2d + sMULL v24.2d, v29.2s, v1.2s + Sqxtn v27.2s, v24.2d + MOV v26.d[1], v27.d[0] + + sQshL v4.4s, v4.4s, v16.4s + sQshL v6.4s, v6.4s, v16.4s + + SQSUB v4.4s, v4.4s , v8.4s + SQSUB v6.4s, v6.4s , v26.4s + + NEG v26.4s, v14.4s +// VUZP.16 D14, D15 + + + UZP1 v19.8h, v14.8h, v14.8h + UZP2 v21.8h, v14.8h, v14.8h + MOV v14.d[0], v19.d[0] + MOV v15.d[0], v21.d[0] + +// VUZP.16 D26, D27 + + + UZP1 v19.8h, v26.8h, v26.8h + UZP2 v21.8h, v26.8h, v26.8h + MOV v26.d[0], v19.d[0] + MOV v27.d[0], v21.d[0] + + + movi v1.2s, #0 +// VADDL.S16 Q0, D10, D1 + SADDL v0.4s, v10.4h, v1.4h + MOV v1.d[0], v0.d[0] + sMULL v22.2d, v30.2s, v0.2s + Sqxtn v24.2s, v22.2d + sMULL2 v22.2d, v30.4s, v0.4s + Sqxtn v25.2s, v22.2d + MOV v24.d[1], v25.d[0] + movi v1.2s, #0 +// VADDL.S16 Q0, D11, D1 + SADDL v0.4s, v11.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v8.2d, v30.2s, v0.2s + Sqxtn v22.2s, v8.2d + sMULL2 v8.2d, v30.4s, v0.4s + Sqxtn v23.2s, v8.2d + MOV v22.d[1], v23.d[0] + uMULL v8.4s, v26.4h, v11.4h + uMULL v30.4s, v14.4h, v10.4h + + LD2 { v0.4s, v1.4s}, [x1] + MOV v2.16b, v1.16b + ADD x1, x1, x12 + +// VUZP.16 D0, D1 + + UZP1 v19.8h, v0.8h, v0.8h + UZP2 v21.8h, v0.8h, v0.8h + MOV v0.d[0], v19.d[0] + MOV v0.d[1], v21.d[0] + +// VUZP.16 D2, D3 + + UZP1 v19.8h, v2.8h, v2.8h + UZP2 v21.8h, v2.8h, v2.8h + MOV v2.d[0], v19.d[0] + MOV v2.d[1], v21.d[0] + + ushR v8.4s, v8.4s,#16 + + rev64 v0.8h, v0.8h + MOV v1.d[0], v0.d[1] + ushR v30.4s, v30.4s,#16 + + rev64 v2.8h, v2.8h + MOV v3.d[0], v2.d[1] + sMLAL v8.4s, v27.4h, v11.4h + + sMLAL v30.4s, v15.4h, v10.4h + + LD2 { v10.4s, v11.4s}, [x6] + ADD x6, x6, x12 + MOV v12.16b, v11.16b + sQshL v4.4s, v4.4s,#2 + + // VUZP.16 D10, D11 + + UZP1 v19.8h, v10.8h, v10.8h + UZP2 v21.8h, v10.8h, v10.8h + MOV v10.d[0], v19.d[0] + MOV v10.d[1], v21.d[0] + + sQshL v6.4s, v6.4s,#2 + +// VUZP.16 D12, D13 + + UZP1 v19.8h, v12.8h, v12.8h + UZP2 v21.8h, v12.8h, v12.8h + MOV v12.d[0], v19.d[0] + MOV v12.d[1], v21.d[0] + + SQADD v14.4s, v4.4s , v20.4s + + rev64 v10.8h, v10.8h + MOV v11.d[0], v10.d[1] + SQADD v6.4s, v6.4s , v20.4s + + rev64 v12.8h, v12.8h + MOV v13.d[0], v12.d[1] + sshR v14.4s, v14.4s,#16 + +// VUZP.16 D14, D15 + + UZP1 v19.8h, v14.8h, v14.8h + UZP2 v21.8h, v14.8h, v14.8h + MOV v14.d[0], v19.d[0] + MOV v15.d[0], v21.d[0] + + sshR v6.4s, v6.4s,#16 + +// VUZP.16 D6, D7 + + UZP1 v19.8h, v6.8h, v6.8h + UZP2 v21.8h, v6.8h, v6.8h + MOV v6.d[0], v19.d[0] + MOV v7.d[0], v21.d[0] + + mov v15.8b, v6.8b + sQshL v8.4s, v8.4s, v16.4s + + LD2 { v4.4s, v5.4s}, [x8] + ADD x8, x8,#32 + MOV v6.16b, v5.16b + sQshL v30.4s, v30.4s, v16.4s + +// VUZP.16 D4, D5 + + UZP1 v19.8h, v4.8h, v4.8h + UZP2 v21.8h, v4.8h, v4.8h + MOV v4.d[0], v19.d[0] + MOV v5.d[0], v21.d[0] + + SQSUB v8.4s, v8.4s , v24.4s + +// VUZP.16 D6, D7 + + UZP1 v19.8h, v6.8h, v6.8h + UZP2 v21.8h, v6.8h, v6.8h + MOV v6.d[0], v19.d[0] + MOV v7.d[0], v21.d[0] + + SQSUB v22.4s, v30.4s , v22.4s + + sQshL v30.4s, v8.4s,#2 + + LD2 {v8.4h, v9.4h}, [x2] + ADD x2, x2, #16 + sQshL v22.4s, v22.4s,#2 + + SQADD v30.4s, v30.4s , v20.4s + SQADD v22.4s, v22.4s , v20.4s + + sshR v30.4s, v30.4s,#16 + +// VUZP.16 D30, D31 + + UZP1 v19.8h, v30.8h, v30.8h + UZP2 v21.8h, v30.8h, v30.8h + MOV v30.d[0], v19.d[0] + MOV v30.d[1], v21.d[0] + + sshR v22.4s, v22.4s,#16 + + +// VUZP.16 D22, D23 + + UZP1 v19.8h, v22.8h, v22.8h + UZP2 v21.8h, v22.8h, v22.8h + MOV v22.d[0], v19.d[0] + MOV v23.d[0], v21.d[0] + + + mov v23.8b, v30.8b + +CORE_LOOP: + ST1 {v14.h}[0], [x0] + ADD x0, x0, x9 + uMULL v30.4s, v0.4h, v9.4h + + ST1 {v22.h}[0], [x0] + ADD x0, x0, x9 + uMULL v28.4s, v2.4h, v8.4h + + ST1 {v14.h}[1], [x0] + ADD x0, x0, x9 + uMULL v26.4s, v0.4h, v8.4h + + ST1 {v22.h}[1], [x0] + ADD x0, x0, x9 + uMULL v24.4s, v2.4h, v9.4h + + ST1 {v14.h}[2], [x0] + ADD x0, x0, x9 + ushR v30.4s, v30.4s,#16 + + ST1 {v22.h}[2], [x0] + ADD x0, x0, x9 + ushR v28.4s, v28.4s,#16 + + ST1 {v14.h}[3], [x0] + ADD x0, x0, x9 + sMLAL v30.4s, v1.4h, v9.4h + + ST1 {v22.h}[3], [x0] + ADD x0, x0, x9 + sMLAL v28.4s, v3.4h, v8.4h + + ST1 {v15.h}[0], [x5] + ADD x5, x5, x10 + ushR v26.4s, v26.4s,#16 + + ST1 {v23.h}[0], [x5] + ADD x5, x5, x10 + ushR v24.4s, v24.4s,#16 + + ST1 {v15.h}[1], [x5] + ADD x5, x5, x10 + sMLAL v26.4s, v1.4h, v8.4h + + ST1 {v23.h}[1], [x5] + ADD x5, x5, x10 + sMLAL v24.4s, v3.4h, v9.4h + + ST1 {v15.h}[2], [x5] + ADD x5, x5, x10 + ADD v30.4s, v30.4s , v28.4s + + ST1 {v23.h}[2], [x5] + ADD x5, x5, x10 + NEG v30.4s, v30.4s + + ST1 {v15.h}[3], [x5] + ADD x5, x5, x10 + + ST1 {v23.h}[3], [x5] + ADD x5, x5, x10 + SUB v28.4s, v24.4s , v26.4s + + + mov v26.16b, v30.16b + uMULL v22.4s, v4.4h, v8.4h + + mov v24.16b, v28.16b + +// VUZP.16 D24, D25 + + UZP1 v19.8h, v24.8h, v24.8h + UZP2 v21.8h, v24.8h, v24.8h + MOV v24.d[0], v19.d[0] + MOV v25.d[0], v21.d[0] + + +// VUZP.16 D26, D27 + + UZP1 v19.8h, v26.8h, v26.8h + UZP2 v21.8h, v26.8h, v26.8h + MOV v26.d[0], v19.d[0] + MOV v27.d[0], v21.d[0] + + uMULL v2.4s, v24.4h, v18.4h + uMULL v0.4s, v26.4h, v18.4h + + ushR v22.4s, v22.4s,#16 + sMLAL v22.4s, v5.4h, v8.4h + + ushR v2.4s, v2.4s,#16 + ushR v0.4s, v0.4s,#16 + sMLAL v2.4s, v25.4h, v18.4h + sMLAL v0.4s, v27.4h, v18.4h + + uMULL v24.4s, v4.4h, v9.4h + uMULL v26.4s, v6.4h, v8.4h + + NEG v2.4s, v2.4s + ADD v28.4s, v28.4s , v0.4s + ADD v30.4s, v30.4s , v2.4s + + uMULL v0.4s, v6.4h, v9.4h + sshR v24.4s, v24.4s,#16 + sMLAL v24.4s, v5.4h, v9.4h + sshR v26.4s, v26.4s,#16 + sshR v0.4s, v0.4s,#16 + sMLAL v26.4s, v7.4h, v8.4h + sMLAL v0.4s, v7.4h, v9.4h + + + + ADD v22.4s, v22.4s , v0.4s + + NEG v22.4s, v22.4s + SUB v24.4s, v26.4s , v24.4s + + + //LDR w11, [sp, #120] + //sxtw x11,w11 + MOV w11, w26 + dup v14.4s,w11 + SQADD v28.4s, v28.4s , v14.4s + //LDR w11, [sp, #116] + //sxtw x11,w11 + MOV w11, w25 + dup v0.4s,w11 + sQshL v28.4s, v28.4s, v0.4s + + + mov v0.16b, v22.16b + mov v14.16b, v24.16b + +// VUZP.16 D24, D25 + + UZP1 v19.8h, v24.8h, v24.8h + UZP2 v21.8h, v24.8h, v24.8h + MOV v24.d[0], v19.d[0] + MOV v25.d[0], v21.d[0] + + +// VUZP.16 D22, D23 + + UZP1 v19.8h, v22.8h, v22.8h + UZP2 v21.8h, v22.8h, v22.8h + MOV v22.d[0], v19.d[0] + MOV v23.d[0], v21.d[0] + + uMULL v8.4s, v24.4h, v18.4h + uMULL v26.4s, v22.4h, v18.4h + + NEG v2.4s, v30.4s + +// VUZP.16 D30, D31 + + UZP1 v19.8h, v30.8h, v30.8h + UZP2 v21.8h, v30.8h, v30.8h + MOV v30.d[0], v19.d[0] + MOV v30.d[1], v21.d[0] + + +// VUZP.16 D2, D3 + + UZP1 v19.8h, v2.8h, v2.8h + UZP2 v21.8h, v2.8h, v2.8h + MOV v2.d[0], v19.d[0] + MOV v3.d[0], v21.d[0] + + uMULL v4.4s, v30.4h, v12.4h + uMULL v6.4s, v2.4h, v13.4h + + ushR v8.4s, v8.4s,#16 + ushR v26.4s, v26.4s,#16 + + sMLAL v8.4s, v25.4h, v18.4h + sMLAL v26.4s, v23.4h, v18.4h + + ushR v4.4s, v4.4s,#16 + ushR v6.4s, v6.4s,#16 + + MOV v19.d[0], v30.d[1] + + sMLAL v4.4s, v19.4h, v12.4h + sMLAL v6.4s, v3.4h, v13.4h + + NEG v8.4s, v8.4s + ADD v14.4s, v14.4s , v26.4s + ADD v0.4s, v0.4s , v8.4s + + + + //LDR w11, [sp, #120] + //sxtw x11,w11 + MOV w11, w26 + dup v8.4s,w11 + SQADD v0.4s, v0.4s , v8.4s + //LDR w11, [sp, #116] + //sxtw x11,w11 + MOV w11, w25 + dup v26.4s,w11 + sQshL v0.4s, v0.4s, v26.4s + mov v26.16b, v28.16b + + LD2 { v28.4s, v29.4s}, [x4] + MOV v30.16b, v29.16b + MOV v29.d[0], v28.d[1] +// VZIP.32 Q13, Q0 + + ZIP1 v19.4s, v26.4s, v0.4s + ZIP2 v0.4s, v26.4s, v0.4s + MOV v26.16b, v19.16b + + ST1 { v26.4s}, [x4] + ADD x4, x4,#16 + ST1 { v0.4s}, [x4] + ADD x4, x4,#16 + + movi v1.2s, #0 +// VADDL.S16 Q0, D13, D1 + SADDL v0.4s, v13.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v26.2d, v28.2s, v0.2s + Sqxtn v8.2s, v26.2d + sMULL v26.2d, v29.2s, v1.2s + Sqxtn v9.2s, v26.2d + MOV v8.d[1], v9.d[0] + movi v1.2s, #0 + //VADDL.S16 Q0, D12, D1 + SADDL v0.4s, v12.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v24.2d, v28.2s, v0.2s + Sqxtn v26.2s, v24.2d + sMULL v24.2d, v29.2s, v1.2s + Sqxtn v27.2s, v24.2d + MOV v26.d[1], v27.d[0] + sQshL v4.4s, v4.4s, v16.4s + sQshL v6.4s, v6.4s, v16.4s + + + + SQSUB v4.4s, v4.4s , v8.4s + SQSUB v6.4s, v6.4s , v26.4s + + NEG v26.4s, v14.4s +// VUZP.16 D26, D27 + UZP1 v19.8h, v26.8h, v26.8h + UZP2 v21.8h, v26.8h, v26.8h + MOV v26.d[0], v19.d[0] + MOV v27.d[0], v21.d[0] + + movi v1.2s, #0 + //VADDL.S16 Q0, D10, D1 + SADDL v0.4s, v10.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v22.2d, v30.2s, v0.2s + Sqxtn v24.2s, v22.2d + sMULL2 v22.2d, v30.4s, v0.4s + Sqxtn v25.2s, v22.2d + MOV v24.d[1], v25.d[0] + movi v1.2s, #0 + //VADDL.S16 Q0, D11, D1 + SADDL v0.4s, v11.4h, v1.4h + + sMULL v8.2d, v30.2s, v0.2s + Sqxtn v22.2s, v8.2d + sMULL2 v8.2d, v30.4s, v0.4s + Sqxtn v23.2s, v8.2d + MOV v22.d[1], v23.d[0] + +// VUZP.16 D14, D15 + + UZP1 v19.8h, v14.8h, v14.8h + UZP2 v21.8h, v14.8h, v14.8h + MOV v14.d[0], v19.d[0] + MOV v15.d[0], v21.d[0] + + uMULL v8.4s, v26.4h, v11.4h + uMULL v30.4s, v14.4h, v10.4h + + + LD2 { v0.4s, v1.4s}, [x1] + MOV v2.16b, v1.16b + ADD X1, X1, x12 + +// VUZP.16 D0, D1 + UZP1 v19.8h, v0.8h, v0.8h + UZP2 v21.8h, v0.8h, v0.8h + MOV v0.d[0], v19.d[0] + MOV v0.d[1], v21.d[0] + +// VUZP.16 D2, D3 + + UZP1 v19.8h, v2.8h, v2.8h + UZP2 v21.8h, v2.8h, v2.8h + MOV v2.d[0], v19.d[0] + MOV v2.d[1], v21.d[0] + + ushR v8.4s, v8.4s,#16 + + rev64 v0.8h, v0.8h + MOV v1.d[0], v0.d[1] + ushR v30.4s, v30.4s,#16 + + rev64 v2.8h, v2.8h + MOV v3.d[0], v2.d[1] + sMLAL v8.4s, v27.4h, v11.4h + + sMLAL v30.4s, v15.4h, v10.4h + + LD2 { v10.4s, v11.4s}, [x6] + add X6, x6, x12 + MOV v12.16b, v11.16b + sQshL v4.4s, v4.4s,#2 + + //VUZP.16 D10, D11 + + UZP1 v19.8h, v10.8h, v10.8h + UZP2 v21.8h, v10.8h, v10.8h + MOV v10.d[0], v19.d[0] + MOV v10.d[1], v21.d[0] + + sQshL v6.4s, v6.4s,#2 + +// VUZP.16 D12, D13 + + UZP1 v19.8h, v12.8h, v12.8h + UZP2 v21.8h, v12.8h, v12.8h + MOV v12.d[0], v19.d[0] + MOV v12.d[1], v21.d[0] + + + SQADD v14.4s, v4.4s , v20.4s + + rev64 v10.8h, v10.8h + MOV v11.d[0], v10.d[1] + SQADD v6.4s, v6.4s , v20.4s + + rev64 v12.8h, v12.8h + MOV v13.d[0], v12.d[1] + sshR v14.4s, v14.4s,#16 + +// VUZP.16 D14, D15 + + UZP1 v19.8h, v14.8h, v14.8h + UZP2 v21.8h, v14.8h, v14.8h + MOV v14.d[0], v19.d[0] + MOV v15.d[0], v21.d[0] + + + sshR v6.4s, v6.4s,#16 + +// VUZP.16 D6, D7 + + UZP1 v19.8h, v6.8h, v6.8h + UZP2 v21.8h, v6.8h, v6.8h + MOV v6.d[0], v19.d[0] + MOV v7.d[0], v21.d[0] + + + mov v15.8b, v6.8b + sQshL v8.4s, v8.4s, v16.4s + + LD2 { v4.4s, v5.4s}, [x8] + ADD x8, x8, #32 + MOV v6.16b, v5.16b + + sQshL v30.4s, v30.4s, v16.4s + +// VUZP.16 D4, D5 + + UZP1 v19.8h, v4.8h, v4.8h + UZP2 v21.8h, v4.8h, v4.8h + MOV v4.d[0], v19.d[0] + MOV v5.d[0], v21.d[0] + + + SQSUB v8.4s, v8.4s , v24.4s + +// VUZP.16 D6, D7 + + UZP1 v19.8h, v6.8h, v6.8h + UZP2 v21.8h, v6.8h, v6.8h + MOV v6.d[0], v19.d[0] + MOV v7.d[0], v21.d[0] + + + SQSUB v22.4s, v30.4s , v22.4s + + sQshL v30.4s, v8.4s,#2 + + LD2 {v8.4h, v9.4h}, [x2] + ADD x2, x2,#16 + sQshL v22.4s, v22.4s,#2 + + SQADD v30.4s, v30.4s , v20.4s + SQADD v22.4s, v22.4s , v20.4s + + sshR v30.4s, v30.4s,#16 + + // VUZP.16 D30, D31 + + UZP1 v19.8h, v30.8h, v30.8h + UZP2 v21.8h, v30.8h, v30.8h + MOV v30.d[0], v19.d[0] + MOV v30.d[1], v21.d[0] + + + sshR v22.4s, v22.4s,#16 + + +// VUZP.16 D22, D23 + UZP1 v19.8h, v22.8h, v22.8h + UZP2 v21.8h, v22.8h, v22.8h + MOV v22.d[0], v19.d[0] + MOV v23.d[0], v21.d[0] + + + mov v23.8b, v30.8b + + SUBS x3, x3, #1 + BNE CORE_LOOP + + + + + +EPILOGUE: + + ST1 {v14.h}[0],[x0] + ADD x0, x0, x9 + uMULL v30.4s, v0.4h, v9.4h + + ST1 {v22.h}[0],[x0] + ADD x0, x0, x9 + uMULL v28.4s, v2.4h, v8.4h + + ST1 {v14.h}[1],[x0] + ADD x0, x0, x9 + uMULL v26.4s, v0.4h, v8.4h + + ST1 {v22.h}[1],[x0] + ADD x0, x0, x9 + uMULL v24.4s, v2.4h, v9.4h + + ST1 {v14.h}[2],[x0] + ADD x0, x0, x9 + ushR v30.4s, v30.4s,#16 + + ST1 {v22.h}[2],[x0] + ADD x0, x0, x9 + ushR v28.4s, v28.4s,#16 + + ST1 {v14.h}[3],[x0] + ADD x0, x0, x9 + sMLAL v30.4s, v1.4h, v9.4h + + ST1 {v22.h}[3],[x0] + ADD x0, x0, x9 + sMLAL v28.4s, v3.4h, v8.4h + + ST1 {v15.h}[0],[x5] + ADD x5, x5, x10 + ushR v26.4s, v26.4s,#16 + + ST1 {v23.h}[0],[x5] + ADD x5, x5, x10 + ushR v24.4s, v24.4s,#16 + + ST1 {v15.h}[1],[x5] + ADD x5, x5, x10 + sMLAL v26.4s, v1.4h, v8.4h + + ST1 {v23.h}[1],[x5] + ADD x5, x5, x10 + sMLAL v24.4s, v3.4h, v9.4h + + ST1 {v15.h}[2],[x5] + ADD x5, x5, x10 + ADD v30.4s, v30.4s , v28.4s + + ST1 {v23.h}[2],[x5] + ADD x5, x5, x10 + NEG v30.4s, v30.4s + + ST1 {v15.h}[3],[x5] + ADD x5, x5, x10 + + + ST1 {v23.h}[3],[x5] + ADD x5, x5, x10 + SUB v28.4s, v24.4s , v26.4s + + + uMULL v22.4s, v4.4h, v8.4h + mov v26.16b, v30.16b + mov v24.16b, v28.16b + + mov v26.16b, v30.16b + mov v24.16b, v28.16b + + //VUZP.16 D26, D27 + + UZP1 v19.8h, v26.8h, v26.8h + UZP2 v21.8h, v26.8h, v26.8h + MOV v26.d[0], v19.d[0] + MOV v27.d[0], v21.d[0] + +// VUZP.16 D24, D25 + + UZP1 v19.8h, v24.8h, v24.8h + UZP2 v21.8h, v24.8h, v24.8h + MOV v24.d[0], v19.d[0] + MOV v25.d[0], v21.d[0] + + uMULL v2.4s, v24.4h, v18.4h + uMULL v0.4s, v26.4h, v18.4h + + ushR v22.4s, v22.4s,#16 + sMLAL v22.4s, v5.4h, v8.4h + + ushR v2.4s, v2.4s,#16 + ushR v0.4s, v0.4s,#16 + sMLAL v2.4s, v25.4h, v18.4h + sMLAL v0.4s, v27.4h, v18.4h + + uMULL v24.4s, v4.4h, v9.4h + uMULL v26.4s, v6.4h, v8.4h + + NEG v2.4s, v2.4s + ADD v28.4s, v28.4s , v0.4s + ADD v30.4s, v30.4s , v2.4s + + uMULL v0.4s, v6.4h, v9.4h + sshR v24.4s, v24.4s,#16 + sMLAL v24.4s, v5.4h, v9.4h + sshR v26.4s, v26.4s,#16 + sshR v0.4s, v0.4s,#16 + sMLAL v26.4s, v7.4h, v8.4h + sMLAL v0.4s, v7.4h, v9.4h + + + + + + ADD v22.4s, v22.4s , v0.4s + NEG v22.4s, v22.4s + SUB v24.4s, v26.4s , v24.4s + + + + + //LDR w11, [sp, #120] + //sxtw x11,w11 + MOV w11, w26 + dup v14.4s,w11 + SQADD v28.4s, v28.4s , v14.4s + //LDR w11, [sp, #116] + //sxtw x11,w11 + MOV w11, w25 + dup v0.4s,w11 + sQshL v28.4s, v28.4s, v0.4s + + + mov v0.16b, v22.16b + mov v14.16b, v24.16b + + +// VUZP.16 D22, D23 + + UZP1 v19.8h, v22.8h, v22.8h + UZP2 v21.8h, v22.8h, v22.8h + MOV v22.d[0], v19.d[0] + MOV v23.d[0], v21.d[0] + +// VUZP.16 D24, D25 + + UZP1 v19.8h, v24.8h, v24.8h + UZP2 v21.8h, v24.8h, v24.8h + MOV v24.d[0], v19.d[0] + MOV v25.d[0], v21.d[0] + + uMULL v8.4s, v24.4h, v18.4h + uMULL v26.4s, v22.4h, v18.4h + + NEG v2.4s, v30.4s + +// VUZP.16 D30, D31 + + UZP1 v19.8h, v30.8h, v30.8h + UZP2 v21.8h, v30.8h, v30.8h + MOV v30.d[0], v19.d[0] + MOV v30.d[1], v21.d[0] + +// VUZP.16 D2, D3 + + UZP1 v19.8h, v2.8h, v2.8h + UZP2 v21.8h, v2.8h, v2.8h + MOV v2.d[0], v19.d[0] + MOV v3.d[0], v21.d[0] + + uMULL v4.4s, v30.4h, v12.4h + uMULL v6.4s, v2.4h, v13.4h + + ushR v8.4s, v8.4s,#16 + ushR v26.4s, v26.4s,#16 + + sMLAL v8.4s, v25.4h, v18.4h + sMLAL v26.4s, v23.4h, v18.4h + + ushR v4.4s, v4.4s,#16 + ushR v6.4s, v6.4s,#16 + + MOV v19.d[0], v30.d[1] + + sMLAL v4.4s, v19.4h, v12.4h + sMLAL v6.4s, v3.4h, v13.4h + + NEG v8.4s, v8.4s + ADD v14.4s, v14.4s , v26.4s + ADD v0.4s, v0.4s , v8.4s + + //LDR w11, [sp, #120] + //sxtw x11,w11 + MOV w11, w26 + dup v8.4s,w11 + SQADD v0.4s, v0.4s , v8.4s + //LDR w11, [sp, #116] + //sxtw x11,w11 + MOV w11, w25 + dup v26.4s,w11 + sQshL v0.4s, v0.4s, v26.4s + + + mov v26.16b, v28.16b + + LD2 { v28.4s, v29.4s}, [x4] + MOV v30.16b, v29.16b + MOV v29.d[0], v28.d[1] +// VZIP.32 Q13, Q0 + + ZIP1 v19.4s, v26.4s, v0.4s + ZIP2 v0.4s, v26.4s, v0.4s + MOV v26.16b, v19.16b + + ST1 { v26.4s}, [x4],#16 + ST1 { v0.4s}, [x4],#16 + + movi v1.2s, #0 +// VADDL.S16 Q0, D13, D1 + SADDL v0.4s, v13.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v26.2d, v28.2s, v0.2s + Sqxtn v8.2s, v26.2d + sMULL v26.2d, v29.2s, v1.2s + Sqxtn v9.2s, v26.2d + MOV v8.d[1], v9.d[0] + movi v1.2s, #0 +// VADDL.S16 Q0, D12, D1 + SADDL v0.4s, v12.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v24.2d, v28.2s, v0.2s + Sqxtn v26.2s, v24.2d + sMULL v24.2d, v29.2s, v1.2s + Sqxtn v27.2s, v24.2d + MOV v26.d[1], v27.d[0] + + sQshL v4.4s, v4.4s, v16.4s + sQshL v6.4s, v6.4s, v16.4s + + SQSUB v4.4s, v4.4s , v8.4s + SQSUB v6.4s, v6.4s , v26.4s + + NEG v26.4s, v14.4s +// VUZP.16 D14, D15 + + UZP1 v19.8h, v14.8h, v14.8h + UZP2 v21.8h, v14.8h, v14.8h + MOV v14.d[0], v19.d[0] + MOV v15.d[0], v21.d[0] + + + // VUZP.16 D26, D27 + + UZP1 v19.8h, v26.8h, v26.8h + UZP2 v21.8h, v26.8h, v26.8h + MOV v26.d[0], v19.d[0] + MOV v27.d[0], v21.d[0] + + + movi v1.2s, #0 + //VADDL.S16 Q0, D10, D1 + SADDL v0.4s, v10.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v22.2d, v30.2s, v0.2s + Sqxtn v24.2s, v22.2d + sMULL2 v22.2d, v30.4s, v0.4s + Sqxtn v25.2s, v22.2d + MOV v24.d[1], v25.d[0] + movi v1.2s, #0 + //VADDL.S16 Q0, D11, D1 + SADDL v0.4s, v11.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v8.2d, v30.2s, v0.2s + Sqxtn v22.2s, v8.2d + sMULL2 v8.2d, v30.4s, v0.4s + Sqxtn v23.2s, v8.2d + MOV v22.d[1], v23.d[0] + + uMULL v8.4s, v26.4h, v11.4h + uMULL v30.4s, v14.4h, v10.4h + + ushR v8.4s, v8.4s,#16 + + ushR v30.4s, v30.4s,#16 + + sMLAL v8.4s, v27.4h, v11.4h + + sMLAL v30.4s, v15.4h, v10.4h + + sQshL v4.4s, v4.4s,#2 + + sQshL v6.4s, v6.4s,#2 + + SQADD v14.4s, v4.4s , v20.4s + + SQADD v6.4s, v6.4s , v20.4s + + sshR v14.4s, v14.4s,#16 + +// VUZP.16 D14, D15 + + UZP1 v19.8h, v14.8h, v14.8h + UZP2 v21.8h, v14.8h, v14.8h + MOV v14.d[0], v19.d[0] + MOV v15.d[0], v21.d[0] + + sshR v6.4s, v6.4s,#16 + +// VUZP.16 D6, D7 + + UZP1 v19.8h, v6.8h, v6.8h + UZP2 v21.8h, v6.8h, v6.8h + MOV v6.d[0], v19.d[0] + MOV v7.d[0], v21.d[0] + + mov v15.8b, v6.8b + sQshL v8.4s, v8.4s, v16.4s + + sQshL v30.4s, v30.4s, v16.4s + + SQSUB v8.4s, v8.4s , v24.4s + + SQSUB v22.4s, v30.4s , v22.4s + + sQshL v30.4s, v8.4s,#2 + + sQshL v22.4s, v22.4s,#2 + + SQADD v30.4s, v30.4s , v20.4s + SQADD v22.4s, v22.4s , v20.4s + + sshR v30.4s, v30.4s,#16 + + //VUZP.16 D30, D31 + + UZP1 v19.8h, v30.8h, v30.8h + UZP2 v21.8h, v30.8h, v30.8h + MOV v30.d[0], v19.d[0] + MOV v30.d[1], v21.d[0] + + sshR v22.4s, v22.4s,#16 + +// VUZP.16 D22, D23 + UZP1 v19.8h, v22.8h, v22.8h + UZP2 v21.8h, v22.8h, v22.8h + MOV v22.d[0], v19.d[0] + MOV v23.d[0], v21.d[0] + + mov v23.8b, v30.8b + + + + + ST1 {v14.h}[0],[x0] + ADD x0, x0, x9 + ST1 {v22.h}[0],[x0] + ADD x0, x0, x9 + ST1 {v14.h}[1],[x0] + ADD x0, x0, x9 + ST1 {v22.h}[1],[x0] + ADD x0, x0, x9 + ST1 {v14.h}[2],[x0] + ADD x0, x0, x9 + ST1 {v22.h}[2],[x0] + ADD x0, x0, x9 + ST1 {v14.h}[3],[x0] + ADD x0, x0, x9 + ST1 {v22.h}[3],[x0] + ADD x0, x0, x9 + ST1 {v15.h}[0],[x5] + ADD x5, x5, x10 + ST1 {v23.h}[0],[x5] + ADD x5, x5, x10 + ST1 {v15.h}[1],[x5] + ADD x5, x5, x10 + ST1 {v23.h}[1],[x5] + ADD x5, x5, x10 + ST1 {v15.h}[2],[x5] + ADD x5, x5, x10 + ST1 {v23.h}[2],[x5] + ADD x5, x5, x10 + ST1 {v15.h}[3],[x5] + ADD x5, x5, x10 + ST1 {v23.h}[3],[x5] + ADD x5, x5, x10 + +ARM_EPILOGUE: + +ARM_LOOP: + + LD2 { v0.4s, v1.4s}, [x1] + MOV v2.16b, v1.16b + + //VUZP.16 D0, D1 + UZP1 v19.8h, v0.8h, v0.8h + UZP2 v21.8h, v0.8h, v0.8h + MOV v0.d[0], v19.d[0] + MOV v0.d[1], v21.d[0] + + //VUZP.16 D2, D3 + UZP1 v19.8h, v2.8h, v2.8h + UZP2 v21.8h, v2.8h, v2.8h + MOV v2.d[0], v19.d[0] + MOV v2.d[1], v21.d[0] + + + rev64 v0.8h, v0.8h + MOV v1.d[0], v0.d[1] + rev64 v2.8h, v2.8h + MOV v3.d[0], v2.d[1] + + LD2 {v8.4h, v9.4h}, [x2] + ADD x2, x2,#16 + + LD2 {v4.2s, v5.2s}, [x8] + ADD x8, x8,#16 + MOV v6.16b, v5.16b + movi v5.2s, #0x00000000 + movi v7.2s, #0x00000000 + + LD1 {v5.s}[0],[x8],#4 + LD1 {v7.s}[0],[x8] + + MOV x12, #16 + MOV v4.d[1], v5.d[0] + MOV v6.d[1], v7.d[0] +// VUZP.16 D4, D5 + + UZP1 v19.8h, v4.8h, v4.8h + UZP2 v21.8h, v4.8h, v4.8h + MOV v4.d[0], v19.d[0] + MOV v5.d[0], v21.d[0] + +// VUZP.16 D6, D7 + + UZP1 v19.8h, v6.8h, v6.8h + UZP2 v21.8h, v6.8h, v6.8h + MOV v6.d[0], v19.d[0] + MOV v7.d[0], v21.d[0] + + ADD x6, x6, #16 + + MOV x12, #-4 + LD2 {v11.2s, v12.2s}, [x6] + ADD x6, x6, x12 + MOV v13.16b, v12.16b + + + movi v10.2s, #0x00000000 + + LD1 {v12.s}[1],[x6] + ADD x6, x6, x12 + LD1 {v10.s}[1],[x6] + ADD x6, x6, x12 + LD1 {v12.s}[0],[x6] + ADD x6, x6, x12 + + MOV v10.d[1], v11.d[0] + MOV v12.d[1], v13.d[0] + + //VUZP.16 D10, D11 + + UZP1 v19.8h, v10.8h, v10.8h + UZP2 v21.8h, v10.8h, v10.8h + MOV v10.d[0], v19.d[0] + MOV v10.d[1], v21.d[0] + + //VUZP.16 D12, D13 + + UZP1 v19.8h, v12.8h, v12.8h + UZP2 v21.8h, v12.8h, v12.8h + MOV v12.d[0], v19.d[0] + MOV v12.d[1], v21.d[0] + + + rev64 v10.8h, v10.8h + MOV v11.d[0], v10.d[1] + rev64 v12.8h, v12.8h + MOV v13.d[0], v12.d[1] + + uMULL v30.4s, v0.4h, v9.4h + uMULL v28.4s, v2.4h, v8.4h + uMULL v26.4s, v0.4h, v8.4h + uMULL v24.4s, v2.4h, v9.4h + + ushR v30.4s, v30.4s,#16 + ushR v28.4s, v28.4s,#16 + + sMLAL v30.4s, v1.4h, v9.4h + sMLAL v28.4s, v3.4h, v8.4h + + ushR v26.4s, v26.4s,#16 + ushR v24.4s, v24.4s,#16 + + sMLAL v26.4s, v1.4h, v8.4h + sMLAL v24.4s, v3.4h, v9.4h + + ADD v30.4s, v30.4s , v28.4s + NEG v30.4s, v30.4s + + uMULL v22.4s, v4.4h, v8.4h + + SUB v28.4s, v24.4s , v26.4s + + + mov v26.16b, v30.16b + mov v24.16b, v28.16b + +// VUZP.16 D26, D27 + + UZP1 v19.8h, v26.8h, v26.8h + UZP2 v21.8h, v26.8h, v26.8h + MOV v26.d[0], v19.d[0] + MOV v27.d[0], v21.d[0] + + //VUZP.16 D24, D25 + + UZP1 v19.8h, v24.8h, v24.8h + UZP2 v21.8h, v24.8h, v24.8h + MOV v24.d[0], v19.d[0] + MOV v25.d[0], v21.d[0] + + uMULL v2.4s, v24.4h, v18.4h + uMULL v0.4s, v26.4h, v18.4h + + ushR v22.4s, v22.4s,#16 + sMLAL v22.4s, v5.4h, v8.4h + + ushR v2.4s, v2.4s,#16 + ushR v0.4s, v0.4s,#16 + sMLAL v2.4s, v25.4h, v18.4h + sMLAL v0.4s, v27.4h, v18.4h + + uMULL v24.4s, v4.4h, v9.4h + uMULL v26.4s, v6.4h, v8.4h + + NEG v2.4s, v2.4s + ADD v28.4s, v28.4s , v0.4s + ADD v30.4s, v30.4s , v2.4s + + uMULL v0.4s, v6.4h, v9.4h + sshR v24.4s, v24.4s,#16 + sMLAL v24.4s, v5.4h, v9.4h + sshR v26.4s, v26.4s,#16 + sshR v0.4s, v0.4s,#16 + sMLAL v26.4s, v7.4h, v8.4h + sMLAL v0.4s, v7.4h, v9.4h + + ADD v22.4s, v22.4s , v0.4s + NEG v22.4s, v22.4s + SUB v24.4s, v26.4s , v24.4s + + //LDR w11, [sp, #120] + //sxtw x11,w11 + MOV w11, w26 + dup v14.4s,w11 + SQADD v28.4s, v28.4s , v14.4s + //LDR w11, [sp, #116] + //sxtw x11,w11 + MOV w11, w25 + dup v0.4s,w11 + sQshL v28.4s, v28.4s, v0.4s + + mov v0.16b, v22.16b + mov v14.16b, v24.16b + +// VUZP.16 D22, D23 + + UZP1 v19.8h, v22.8h, v22.8h + UZP2 v21.8h, v22.8h, v22.8h + MOV v22.d[0], v19.d[0] + MOV v23.d[0], v21.d[0] + + // VUZP.16 D24, D25 + + UZP1 v19.8h, v24.8h, v24.8h + UZP2 v21.8h, v24.8h, v24.8h + MOV v24.d[0], v19.d[0] + MOV v25.d[0], v21.d[0] + + uMULL v8.4s, v24.4h, v18.4h + uMULL v26.4s, v22.4h, v18.4h + + NEG v2.4s, v30.4s +// VUZP.16 D30, D31 + + UZP1 v19.8h, v30.8h, v30.8h + UZP2 v21.8h, v30.8h, v30.8h + MOV v30.d[0], v19.d[0] + MOV v30.d[1], v21.d[0] + +// VUZP.16 D2, D3 + + UZP1 v19.8h, v2.8h, v2.8h + UZP2 v21.8h, v2.8h, v2.8h + MOV v2.d[0], v19.d[0] + MOV v3.d[0], v21.d[0] + + uMULL v4.4s, v30.4h, v12.4h + uMULL v6.4s, v2.4h, v13.4h + + ushR v8.4s, v8.4s,#16 + ushR v26.4s, v26.4s,#16 + + sMLAL v8.4s, v25.4h, v18.4h + sMLAL v26.4s, v23.4h, v18.4h + + ushR v4.4s, v4.4s,#16 + ushR v6.4s, v6.4s,#16 + + MOV v19.d[0], v30.d[1] + + sMLAL v4.4s, v19.4h, v12.4h + sMLAL v6.4s, v3.4h, v13.4h + + NEG v8.4s, v8.4s + ADD v14.4s, v14.4s , v26.4s + ADD v0.4s, v0.4s , v8.4s + + //LDR w11, [sp, #120] + //sxtw x11,w11 + MOV w11, w26 + dup v8.4s,w11 + SQADD v0.4s, v0.4s , v8.4s + //LDR w11, [sp, #116] + //sxtw x11,w11 + MOV w11, w25 + dup v26.4s,w11 + sQshL v0.4s, v0.4s, v26.4s + + mov v26.16b, v28.16b + + MOV x6, x4 + + LD1 {v28.2s, v29.2s}, [x4],#16 + movi v19.2s, #0x00000000 + LD1 {v30.s}[0],[x4],#4 + LD1 {v30.s}[1],[x4],#4 + LD1 {v19.s}[0],[x4],#4 + + MOV v28.d[1], v29.d[0] + MOV v30.d[1], v19.d[0] + + //VUZP.32 Q14, Q15 + + UZP1 v19.4s, v28.4s, v30.4s + UZP2 v30.4s, v28.4s, v30.4s + MOV v28.16b, v19.16b + MOV v29.d[0], v28.d[1] + + ST1 {v26.s}[0],[x6],#4 + ST1 {v0.s}[0],[x6],#4 + ST1 {v26.s}[1],[x6],#4 + ST1 {v0.s}[1],[x6],#4 + ST1 {v26.s}[2],[x6],#4 + ST1 {v0.s}[2],[x6],#4 + ST1 {v26.s}[3],[x6],#4 + + movi v1.2s, #0 + //VADDL.S16 Q0, D13, D1 + SADDL v0.4s, v13.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v26.2d, v28.2s, v0.2s + Sqxtn v8.2s, v26.2d + sMULL v26.2d, v29.2s, v1.2s + Sqxtn v9.2s, v26.2d + MOV v8.d[1], v9.d[0] + movi v1.2s, #0 + //VADDL.S16 Q0, D12, D1 + SADDL v0.4s, v12.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v24.2d, v28.2s, v0.2s + Sqxtn v26.2s, v24.2d + sMULL v24.2d, v29.2s, v1.2s + Sqxtn v27.2s, v24.2d + MOV v26.d[1], v27.d[0] + + sQshL v4.4s, v4.4s, v16.4s + sQshL v6.4s, v6.4s, v16.4s + + SQSUB v4.4s, v4.4s , v8.4s + SQSUB v6.4s, v6.4s , v26.4s + + NEG v26.4s, v14.4s + //VUZP.16 D14, D15 + + UZP1 v19.8h, v14.8h, v14.8h + UZP2 v21.8h, v14.8h, v14.8h + MOV v14.d[0], v19.d[0] + MOV v15.d[0], v21.d[0] + +// VUZP.16 D26, D27 + + UZP1 v19.8h, v26.8h, v26.8h + UZP2 v21.8h, v26.8h, v26.8h + MOV v26.d[0], v19.d[0] + MOV v27.d[0], v21.d[0] + + + movi v1.2s, #0 + //VADDL.S16 Q0, D10, D1 + SADDL v0.4s, v10.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v22.2d, v30.2s, v0.2s + Sqxtn v24.2s, v22.2d + sMULL2 v22.2d, v30.4s, v0.4s + Sqxtn v25.2s, v22.2d + MOV v24.d[1], v25.d[0] + + movi v1.2s, #0 +// VADDL.S16 Q0, D11, D1 + SADDL v0.4s, v11.4h, v1.4h + MOV v1.d[0], v0.d[1] + + sMULL v8.2d, v30.2s, v0.2s + Sqxtn v22.2s, v8.2d + sMULL2 v8.2d, v30.4s, v0.4s + Sqxtn v23.2s, v8.2d + MOV v22.d[1], v23.d[0] + + uMULL v8.4s, v26.4h, v11.4h + uMULL v30.4s, v14.4h, v10.4h + + ushR v8.4s, v8.4s,#16 + + ushR v30.4s, v30.4s,#16 + + sMLAL v8.4s, v27.4h, v11.4h + + sMLAL v30.4s, v15.4h, v10.4h + + sQshL v4.4s, v4.4s,#2 + + sQshL v6.4s, v6.4s,#2 + + SQADD v14.4s, v4.4s , v20.4s + + SQADD v6.4s, v6.4s , v20.4s + + sshR v14.4s, v14.4s,#16 + +// VUZP.16 D14, D15 + + UZP1 v19.8h, v14.8h, v14.8h + UZP2 v21.8h, v14.8h, v14.8h + MOV v14.d[0], v19.d[0] + MOV v15.d[0], v21.d[0] + + sshR v6.4s, v6.4s,#16 + + //VUZP.16 D6, D7 + + UZP1 v19.8h, v6.8h, v6.8h + UZP2 v21.8h, v6.8h, v6.8h + MOV v6.d[0], v19.d[0] + MOV v7.d[0], v21.d[0] + + mov v15.8b, v6.8b + sQshL v8.4s, v8.4s, v16.4s + + sQshL v30.4s, v30.4s, v16.4s + + SQSUB v8.4s, v8.4s , v24.4s + + SQSUB v22.4s, v30.4s , v22.4s + + sQshL v30.4s, v8.4s,#2 + + sQshL v22.4s, v22.4s,#2 + + SQADD v30.4s, v30.4s , v20.4s + SQADD v22.4s, v22.4s , v20.4s + + sshR v30.4s, v30.4s,#16 + +// VUZP.16 D30, D31 + + UZP1 v19.8h, v30.8h, v30.8h + UZP2 v21.8h, v30.8h, v30.8h + MOV v30.d[0], v19.d[0] + MOV v30.d[1], v21.d[0] + + sshR v22.4s, v22.4s,#16 + +// VUZP.16 D22, D23 + + UZP1 v19.8h, v22.8h, v22.8h + UZP2 v21.8h, v22.8h, v22.8h + MOV v22.d[0], v19.d[0] + MOV v23.d[0], v21.d[0] + + mov v23.8b, v30.8b + + + + + ST1 {v14.h}[0],[x0] + ADD x0, x0, x9 + ST1 {v22.h}[0],[x0] + ADD x0, x0, x9 + ST1 {v14.h}[1],[x0] + ADD x0, x0, x9 + ST1 {v22.h}[1],[x0] + ADD x0, x0, x9 + ST1 {v14.h}[2],[x0] + ADD x0, x0, x9 + ST1 {v22.h}[2],[x0] + ADD x0, x0, x9 + ST1 {v14.h}[3],[x0] + ADD x0, x0, x9 + + ST1 {v15.h}[0],[x5] + ADD x5, x5, x10 + ST1 {v23.h}[0],[x5] + ADD x5, x5, x10 + ST1 {v15.h}[1],[x5] + ADD x5, x5, x10 + ST1 {v23.h}[1],[x5] + ADD x5, x5, x10 + ST1 {v15.h}[2],[x5] + ADD x5, x5, x10 + ST1 {v23.h}[2],[x5] + ADD x5, x5, x10 + ST1 {v15.h}[3],[x5] + ADD x5, x5, x10 + + // VPOP {d8 - d15} + // LDMFD sp!, {x4-x12} + //ldp x19, x20,[sp],#16 + pop_v_regs + ret + //BX x14 diff --git a/decoder/drc_src/impd_apicmd_standards.h b/decoder/drc_src/impd_apicmd_standards.h index 94316c2..7d511f2 100644 --- a/decoder/drc_src/impd_apicmd_standards.h +++ b/decoder/drc_src/impd_apicmd_standards.h @@ -1,21 +1,21 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #ifndef IMPD_API_CMD_STANDARDS_H @@ -24,67 +24,70 @@ /*****************************************************************************/ /* Ittiam standard API commands */ /*****************************************************************************/ -#define IA_API_CMD_GET_LIB_ID_STRINGS 0x0001 +#define IA_API_CMD_GET_LIB_ID_STRINGS 0x0001 -#define IA_API_CMD_GET_API_SIZE 0x0002 -#define IA_API_CMD_INIT 0x0003 +#define IA_API_CMD_GET_API_SIZE 0x0002 +#define IA_API_CMD_INIT 0x0003 -#define IA_API_CMD_SET_CONFIG_PARAM 0x0004 -#define IA_API_CMD_GET_CONFIG_PARAM 0x0005 +#define IA_API_CMD_SET_CONFIG_PARAM 0x0004 +#define IA_API_CMD_GET_CONFIG_PARAM 0x0005 -#define IA_API_CMD_GET_MEMTABS_SIZE 0x0006 -#define IA_API_CMD_SET_MEMTABS_PTR 0x0007 -#define IA_API_CMD_GET_N_MEMTABS 0x0008 +#define IA_API_CMD_GET_MEMTABS_SIZE 0x0006 +#define IA_API_CMD_SET_MEMTABS_PTR 0x0007 +#define IA_API_CMD_GET_N_MEMTABS 0x0008 -#define IA_API_CMD_EXECUTE 0x0009 +#define IA_API_CMD_EXECUTE 0x0009 -#define IA_API_CMD_PUT_INPUT_QUERY 0x000A -#define IA_API_CMD_GET_CURIDX_INPUT_BUF 0x000B -#define IA_API_CMD_SET_INPUT_BYTES 0x000C -#define IA_API_CMD_GET_OUTPUT_BYTES 0x000D -#define IA_API_CMD_RESET 0x0010 +#define IA_API_CMD_PUT_INPUT_QUERY 0x000A +#define IA_API_CMD_GET_CURIDX_INPUT_BUF 0x000B +#define IA_API_CMD_SET_INPUT_BYTES 0x000C +#define IA_API_CMD_GET_OUTPUT_BYTES 0x000D +#define IA_API_CMD_INPUT_OVER 0x000E -#define IA_API_CMD_GET_MEM_INFO_SIZE 0x0011 -#define IA_API_CMD_GET_MEM_INFO_ALIGNMENT 0x0012 -#define IA_API_CMD_GET_MEM_INFO_TYPE 0x0013 -#define IA_API_CMD_GET_MEM_INFO_PLACEMENT 0x0014 -#define IA_API_CMD_GET_MEM_INFO_PRIORITY 0x0015 -#define IA_API_CMD_SET_MEM_PTR 0x0016 -#define IA_API_CMD_SET_MEM_INFO_SIZE 0x0017 -#define IA_API_CMD_SET_MEM_PLACEMENT 0x0018 -#define IA_API_CMD_GET_N_TABLES 0x0019 -#define IA_API_CMD_GET_TABLE_INFO_SIZE 0x001A -#define IA_API_CMD_GET_TABLE_INFO_ALIGNMENT 0x001B -#define IA_API_CMD_GET_TABLE_INFO_PRIORITY 0x001C -#define IA_API_CMD_SET_TABLE_PTR 0x001D -#define IA_API_CMD_GET_TABLE_PTR 0x001E +#define IA_API_CMD_RESET 0x0010 -#define IA_API_CMD_INPUT_OVER 0x0020 -#define IA_API_CMD_INPUT_OVER_BS 0x0021 -#define IA_API_CMD_INPUT_OVER_IC_BS 0x0022 -#define IA_API_CMD_INPUT_OVER_IG_BS 0x0023 -#define IA_API_CMD_INPUT_OVER_IL_BS 0x0024 -#define IA_API_CMD_INPUT_OVER_IN_BS 0x0025 +#define IA_API_CMD_GET_MEM_INFO_SIZE 0x0011 +#define IA_API_CMD_GET_MEM_INFO_ALIGNMENT 0x0012 +#define IA_API_CMD_GET_MEM_INFO_TYPE 0x0013 +#define IA_API_CMD_GET_MEM_INFO_PLACEMENT 0x0014 +#define IA_API_CMD_GET_MEM_INFO_PRIORITY 0x0015 +#define IA_API_CMD_SET_MEM_PTR 0x0016 +#define IA_API_CMD_SET_MEM_INFO_SIZE 0x0017 +#define IA_API_CMD_SET_MEM_PLACEMENT 0x0018 -#define IA_API_CMD_SET_INPUT_BYTES_BS 0x0026 -#define IA_API_CMD_SET_INPUT_BYTES_IC_BS 0x0027 -#define IA_API_CMD_SET_INPUT_BYTES_IG_BS 0x0028 -#define IA_API_CMD_SET_INPUT_BYTES_IL_BS 0x0029 -#define IA_API_CMD_SET_INPUT_BYTES_IN_BS 0x002A +#define IA_API_CMD_GET_N_TABLES 0x0019 +#define IA_API_CMD_GET_TABLE_INFO_SIZE 0x001A +#define IA_API_CMD_GET_TABLE_INFO_ALIGNMENT 0x001B +#define IA_API_CMD_GET_TABLE_INFO_PRIORITY 0x001C +#define IA_API_CMD_SET_TABLE_PTR 0x001D +#define IA_API_CMD_GET_TABLE_PTR 0x001E + + +#define IA_API_CMD_INPUT_OVER_BS 0x0021 +#define IA_API_CMD_INPUT_OVER_IC_BS 0x0022 +#define IA_API_CMD_INPUT_OVER_IG_BS 0x0023 +#define IA_API_CMD_INPUT_OVER_IL_BS 0x0024 +#define IA_API_CMD_INPUT_OVER_IN_BS 0x0025 + +#define IA_API_CMD_SET_INPUT_BYTES_BS 0x0026 +#define IA_API_CMD_SET_INPUT_BYTES_IC_BS 0x0027 +#define IA_API_CMD_SET_INPUT_BYTES_IG_BS 0x0028 +#define IA_API_CMD_SET_INPUT_BYTES_IL_BS 0x0029 +#define IA_API_CMD_SET_INPUT_BYTES_IN_BS 0x002A /*****************************************************************************/ /* Ittiam standard API command indices */ /*****************************************************************************/ /* IA_API_CMD_GET_LIB_ID_STRINGS indices */ -#define IA_CMD_TYPE_LIB_NAME 0x0100 -#define IA_CMD_TYPE_LIB_VERSION 0x0200 -#define IA_CMD_TYPE_API_VERSION 0x0300 +#define IA_CMD_TYPE_LIB_NAME 0x0100 +#define IA_CMD_TYPE_LIB_VERSION 0x0200 +#define IA_CMD_TYPE_API_VERSION 0x0300 /* IA_API_CMD_INIT indices */ -#define IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS 0x0100 -#define IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS 0x0200 -#define IA_CMD_TYPE_INIT_PROCESS 0x0300 -#define IA_CMD_TYPE_INIT_DONE_QUERY 0x0400 +#define IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS 0x0100 +#define IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS 0x0200 +#define IA_CMD_TYPE_INIT_PROCESS 0x0300 +#define IA_CMD_TYPE_INIT_DONE_QUERY 0x0400 #define IA_CMD_TYPE_INIT_CPY_BSF_BUFF 0x0201 #define IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF 0x0202 @@ -100,7 +103,7 @@ #define IA_CMD_TYPE_INIT_SET_BUFF_PTR 0x020B /* IA_API_CMD_EXECUTE indices */ -#define IA_CMD_TYPE_DO_EXECUTE 0x0100 -#define IA_CMD_TYPE_DONE_QUERY 0x0200 +#define IA_CMD_TYPE_DO_EXECUTE 0x0100 +#define IA_CMD_TYPE_DONE_QUERY 0x0200 -#endif +#endif diff --git a/decoder/drc_src/impd_drc_api.c b/decoder/drc_src/impd_drc_api.c index d38c97e..e16cb58 100644 --- a/decoder/drc_src/impd_drc_api.c +++ b/decoder/drc_src/impd_drc_api.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include @@ -53,7 +53,7 @@ WORD32 impd_init_process_audio_main_stft(ia_drc_api_struct *p_obj_drc); WORD32 impd_init_process_audio_main_td_qmf(ia_drc_api_struct *p_obj_drc); IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, - WORD32 i_cmd, WORD32 i_idx, pVOID pv_value); + WORD32 i_cmd, WORD32 i_idx, pVOID pv_value); IA_ERRORCODE impd_drc_fill_mem_tables(ia_drc_api_struct *p_obj_drc); @@ -74,555 +74,571 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc); IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, - WORD32 i_cmd, - WORD32 i_idx, - pVOID pv_value) + WORD32 i_cmd, + WORD32 i_idx, + pVOID pv_value) { - ia_drc_api_struct *p_obj_drc = p_ia_drc_dec_obj; - IA_ERRORCODE error_code=IA_NO_ERROR; - LOOPIDX i; + ia_drc_api_struct *p_obj_drc = p_ia_drc_dec_obj; + IA_ERRORCODE error_code=IA_NO_ERROR; + LOOPIDX i; - pUWORD32 pui_value = pv_value; - pUWORD32 pus_value = pv_value; - pWORD8 pb_value = pv_value; - SIZE_T *ps_value = pv_value; + pUWORD32 pui_value = pv_value; + pUWORD32 pus_value = pv_value; + pWORD8 pb_value = pv_value; + SIZE_T *ps_value = pv_value; - switch(i_cmd) - { - case IA_API_CMD_GET_MEM_INFO_SIZE: - case IA_API_CMD_GET_MEM_INFO_ALIGNMENT: - case IA_API_CMD_GET_MEM_INFO_TYPE: - case IA_API_CMD_GET_MEM_INFO_PLACEMENT: - case IA_API_CMD_GET_MEM_INFO_PRIORITY: - case IA_API_CMD_SET_MEM_PTR: - case IA_API_CMD_SET_MEM_PLACEMENT: - { - return impd_drc_mem_api(p_ia_drc_dec_obj, i_cmd, i_idx, pv_value); - } - }; + switch(i_cmd) + { + case IA_API_CMD_GET_MEM_INFO_SIZE: + case IA_API_CMD_GET_MEM_INFO_ALIGNMENT: + case IA_API_CMD_GET_MEM_INFO_TYPE: + case IA_API_CMD_GET_MEM_INFO_PLACEMENT: + case IA_API_CMD_GET_MEM_INFO_PRIORITY: + case IA_API_CMD_SET_MEM_PTR: + case IA_API_CMD_SET_MEM_PLACEMENT: + { + return impd_drc_mem_api(p_ia_drc_dec_obj, i_cmd, i_idx, pv_value); + } + }; - switch(i_cmd) - { - case IA_API_CMD_GET_LIB_ID_STRINGS: - { - switch(i_idx) - { - case IA_CMD_TYPE_LIB_NAME: - { - WORD8 lib_name[] = LIBNAME; - for(i = 0; i < IA_API_STR_LEN && lib_name[i -1] != 0; i++) - { - pb_value[i] = lib_name[i]; - } - break; - } + switch(i_cmd) + { + case IA_API_CMD_GET_LIB_ID_STRINGS: + { + switch(i_idx) + { + case IA_CMD_TYPE_LIB_NAME: + { + WORD8 lib_name[] = LIBNAME; + for(i = 0; i < IA_API_STR_LEN && lib_name[i -1] != 0; i++) + { + pb_value[i] = lib_name[i]; + } + break; + } case IA_CMD_TYPE_LIB_VERSION: { - break; + break; } - case IA_CMD_TYPE_API_VERSION: - { + case IA_CMD_TYPE_API_VERSION: + { - } - default: - { - return -1; - } - }; - break; - } - case IA_API_CMD_GET_API_SIZE: - { - *pui_value = sizeof(ia_drc_api_struct)+(sizeof(ia_drc_state_struct)+8)+8080*1024; - - break; - } - case IA_API_CMD_INIT: - { - switch(i_idx) - { + } + default: + { + return -1; + } + }; + break; + } + case IA_API_CMD_GET_API_SIZE: + { + *pui_value = sizeof(ia_drc_api_struct)+(sizeof(ia_drc_state_struct)+8)+8080*1024; + + break; + } + case IA_API_CMD_INIT: + { + switch(i_idx) + { case IA_CMD_TYPE_INIT_SET_BUFF_PTR: - { + { p_obj_drc->p_state->persistant_ptr=p_obj_drc->pp_mem[IA_DRC_PERSIST_IDX]; - impd_drc_set_struct_pointer(p_obj_drc); + impd_drc_set_struct_pointer(p_obj_drc); - break; - } - case IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS: - { - impd_drc_set_default_config(p_obj_drc); - break; - } - case IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS: - { + break; + } + case IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS: + { + impd_drc_set_default_config(p_obj_drc); + break; + } + case IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS: + { p_obj_drc->p_state=(ia_drc_state_struct *)((SIZE_T)p_obj_drc+8000*1024); - p_obj_drc->p_mem_info=(ia_mem_info_struct *)((SIZE_T)p_obj_drc+8002*1024); - p_obj_drc->pp_mem=(pVOID)((SIZE_T)p_obj_drc+8006*1024); - impd_drc_fill_mem_tables(p_obj_drc); - break; - } - case IA_CMD_TYPE_INIT_PROCESS: - { - IA_ERRORCODE Error=0; + p_obj_drc->p_mem_info=(ia_mem_info_struct *)((SIZE_T)p_obj_drc+8002*1024); + p_obj_drc->pp_mem=(pVOID)((SIZE_T)p_obj_drc+8006*1024); + impd_drc_fill_mem_tables(p_obj_drc); + break; + } + case IA_CMD_TYPE_INIT_PROCESS: + { + IA_ERRORCODE Error=0; - if(p_obj_drc->pp_mem[IA_DRC_PERSIST_IDX] == 0) - { - return(-1); - } - - - Error = impd_drc_init(p_obj_drc); - if(Error) - return Error; - p_obj_drc->p_state->ui_init_done = 1; - return Error; - break; - } + if(p_obj_drc->pp_mem[IA_DRC_PERSIST_IDX] == 0) + { + return(-1); + } + + + Error = impd_drc_init(p_obj_drc); + if(Error) + return Error; + p_obj_drc->p_state->ui_init_done = 1; + return Error; + break; + } case IA_CMD_TYPE_INIT_DONE_QUERY: { if(p_obj_drc->p_state->ui_init_done == 1) - { - *pui_value = 1; - } - else - { - *pui_value = 0; - } + { + *pui_value = 1; + } + else + { + *pui_value = 0; + } break; } case IA_CMD_TYPE_INIT_CPY_BSF_BUFF_OVER_QUERY: { - *pui_value = p_obj_drc->str_bit_handler.cpy_over; + *pui_value = p_obj_drc->str_bit_handler.cpy_over; break; } case IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF_OVER_QUERY: { - *pui_value = p_obj_drc->str_bit_handler.cpy_over_ic; + *pui_value = p_obj_drc->str_bit_handler.cpy_over_ic; break; } - + case IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF_OVER_QUERY: { - *pui_value = p_obj_drc->str_bit_handler.cpy_over_il; + *pui_value = p_obj_drc->str_bit_handler.cpy_over_il; break; } case IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF_OVER_QUERY: { - *pui_value = p_obj_drc->str_bit_handler.cpy_over_in; + *pui_value = p_obj_drc->str_bit_handler.cpy_over_in; break; } - case IA_CMD_TYPE_INIT_CPY_BSF_BUFF: - { - memcpy(p_obj_drc->str_bit_handler.it_bit_buf+p_obj_drc->str_bit_handler.num_bytes_bs, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur); - p_obj_drc->str_bit_handler.num_bytes_bs=p_obj_drc->str_bit_handler.num_bytes_bs+p_obj_drc->str_bit_handler.num_byts_cur; + case IA_CMD_TYPE_INIT_CPY_BSF_BUFF: + { + memcpy(p_obj_drc->str_bit_handler.it_bit_buf+p_obj_drc->str_bit_handler.num_bytes_bs, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur); + p_obj_drc->str_bit_handler.num_bytes_bs=p_obj_drc->str_bit_handler.num_bytes_bs+p_obj_drc->str_bit_handler.num_byts_cur; break; - } + } case IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF: - { - memcpy(p_obj_drc->str_bit_handler.bitstream_drc_config+p_obj_drc->str_bit_handler.num_bytes_bs_drc_config, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur_ic); - p_obj_drc->str_bit_handler.num_bytes_bs_drc_config=p_obj_drc->str_bit_handler.num_bytes_bs_drc_config+p_obj_drc->str_bit_handler.num_byts_cur_ic; + { + memcpy(p_obj_drc->str_bit_handler.bitstream_drc_config+p_obj_drc->str_bit_handler.num_bytes_bs_drc_config, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur_ic); + p_obj_drc->str_bit_handler.num_bytes_bs_drc_config=p_obj_drc->str_bit_handler.num_bytes_bs_drc_config+p_obj_drc->str_bit_handler.num_byts_cur_ic; break; - } + } case IA_CMD_TYPE_INIT_CPY_IL_BSF_BUFF: - { - memcpy(p_obj_drc->str_bit_handler.bitstream_loudness_info+p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur_il); - p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info=p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info+p_obj_drc->str_bit_handler.num_byts_cur_il; + { + memcpy(p_obj_drc->str_bit_handler.bitstream_loudness_info+p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur_il); + p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info=p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info+p_obj_drc->str_bit_handler.num_byts_cur_il; break; - } + } case IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF: - { - memcpy(p_obj_drc->str_bit_handler.bitstream_unidrc_interface+p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur_in); - p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface=p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface+p_obj_drc->str_bit_handler.num_byts_cur_in; + { + memcpy(p_obj_drc->str_bit_handler.bitstream_unidrc_interface+p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface, p_obj_drc->pp_mem[2],p_obj_drc->str_bit_handler.num_byts_cur_in); + p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface=p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface+p_obj_drc->str_bit_handler.num_byts_cur_in; break; - } - default: - { - return -1; - } - }; - break; - } - case IA_API_CMD_GET_CONFIG_PARAM: - { - switch(i_idx) - { - - case IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ: - { + } + default: + { + return -1; + } + }; + break; + } + case IA_API_CMD_GET_CONFIG_PARAM: + { + switch(i_idx) + { - *pus_value=p_obj_drc->str_config.sampling_rate; - break; - } + case IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ: + { - case IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS: - { + *pus_value=p_obj_drc->str_config.sampling_rate; + break; + } + + case IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS: + { *pus_value=p_obj_drc->str_config.num_ch_out; - break; - } - case IA_DRC_DEC_CONFIG_PROC_OUT_PTR: - { + break; + } + case IA_DRC_DEC_CONFIG_PROC_OUT_PTR: + { *ps_value=(SIZE_T)p_obj_drc->str_payload.pstr_drc_sel_proc_output; - break; - } - - } - break; - } - case IA_API_CMD_SET_CONFIG_PARAM: - { - switch(i_idx) - { - case IA_DRC_DEC_CONFIG_PARAM_DEC_TYPE: - { - if(*pus_value==1){ + break; + } + + } + break; + } + case IA_API_CMD_SET_CONFIG_PARAM: + { + switch(i_idx) + { + case IA_DRC_DEC_CONFIG_PARAM_DEC_TYPE: + { + if(*pus_value==1){ p_obj_drc->str_config.dec_type = DEC_TYPE_TD_QMF64; p_obj_drc->str_config.sub_band_domain_mode = SUBBAND_DOMAIN_MODE_QMF64; p_obj_drc->str_config.sub_band_down_sampling_factor = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; p_obj_drc->str_config.sub_band_count = AUDIO_CODEC_SUBBAND_COUNT_QMF64; - } - else if(*pus_value==2){ + } + else if(*pus_value==2){ p_obj_drc->str_config.dec_type = DEC_TYPE_QMF64; p_obj_drc->str_config.sub_band_domain_mode = SUBBAND_DOMAIN_MODE_QMF64; p_obj_drc->str_config.sub_band_down_sampling_factor = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; p_obj_drc->str_config.sub_band_count = AUDIO_CODEC_SUBBAND_COUNT_QMF64; - } - else if(*pus_value==3){ + } + else if(*pus_value==3){ p_obj_drc->str_config.dec_type = DEC_TYPE_STFT256; p_obj_drc->str_config.sub_band_domain_mode = SUBBAND_DOMAIN_MODE_STFT256; p_obj_drc->str_config.sub_band_down_sampling_factor = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256; p_obj_drc->str_config.sub_band_count = AUDIO_CODEC_SUBBAND_COUNT_STFT256; - } - else{ - p_obj_drc->str_config.dec_type = DEC_TYPE_TD; - p_obj_drc->str_config.sub_band_domain_mode = SUBBAND_DOMAIN_MODE_OFF; - } + } + else{ + p_obj_drc->str_config.dec_type = DEC_TYPE_TD; + p_obj_drc->str_config.sub_band_domain_mode = SUBBAND_DOMAIN_MODE_OFF; + } - if(*pus_value<0 || *pus_value >3) - { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DECODE_TYPE; - } - break; - } - case IA_DRC_DEC_CONFIG_PARAM_CTRL_PARAM: - { - if(*pus_value<1 || *pus_value>39) - { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_CTRL_PARAM_IDX; - } + if(*pus_value<0 || *pus_value >3) + { + return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DECODE_TYPE; + } + break; + } + case IA_DRC_DEC_CONFIG_PARAM_CTRL_PARAM: + { + if(*pus_value<1 || *pus_value>39) + { + return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_CTRL_PARAM_IDX; + } p_obj_drc->str_config.control_parameter_index = *pus_value; - break; - } + break; + } case IA_DRC_DEC_CONFIG_PARAM_PEAK_LIMITER: - { - if(*pus_value<0 || *pus_value>1) - { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PEAK_LIM_FLAG; - } + { + if(*pus_value<0 || *pus_value>1) + { + return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PEAK_LIM_FLAG; + } p_obj_drc->str_config.peak_limiter = *pus_value; - break; - } - - case IA_DRC_DEC_CONFIG_PARAM_VER_MODE: - { - break; - } - case IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ: - { - if(*pus_value<8000 || *pus_value>96000) - { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_SAMP_FREQ; - } - p_obj_drc->str_config.sampling_rate = *pus_value; - break; - } - case IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS: - { - p_obj_drc->str_config.num_ch_in = *pus_value; + break; + } + + case IA_DRC_DEC_CONFIG_PARAM_VER_MODE: + { + break; + } + case IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ: + { + if(*pus_value<8000 || *pus_value>96000) + { + return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_SAMP_FREQ; + } + p_obj_drc->str_config.sampling_rate = *pus_value; + break; + } + case IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS: + { + p_obj_drc->str_config.num_ch_in = *pus_value; if(*pus_value < 1 || *pus_value > MAX_CHANNEL_COUNT) { return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_NUM_OF_CHANNELS; } - break; - } + break; + } - case IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ: - { + case IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ: + { if((*pus_value!=16) && (*pus_value!=32)) { return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PCM_SIZE; } - p_obj_drc->str_config.pcm_size = *pus_value; + p_obj_drc->str_config.pcm_size = *pus_value; - - break; - } - case IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT: - { + break; + } + + case IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT: + { if((*pus_value!=1)&&(*pus_value!=0)) { return -1; } - p_obj_drc->str_config.bitstream_file_format = *pus_value; - - break; - } - case IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT: - { + p_obj_drc->str_config.bitstream_file_format = *pus_value; + + break; + } + case IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT: + { if((*pus_value!=1)&&(*pus_value!=0)) { return -1; } - p_obj_drc->str_config.interface_bitstream_present = *pus_value; - - break; - } - case IA_DRC_DEC_CONFIG_PARAM_DELAY_MODE: - { + p_obj_drc->str_config.interface_bitstream_present = *pus_value; + + break; + } + case IA_DRC_DEC_CONFIG_PARAM_DELAY_MODE: + { if((*pus_value!=1)&&(*pus_value!=0)) { return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DELAY_MODE; } - p_obj_drc->str_config.delay_mode = *pus_value; - - break; - } - case IA_DRC_DEC_CONFIG_PARAM_GAIN_DELAY: - { - if ((*pus_value > MAX_SIGNAL_DELAY) || (*pus_value < 0)) - { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_GAIN_DELAY; - } + p_obj_drc->str_config.delay_mode = *pus_value; - p_obj_drc->str_config.gain_delay_samples = *pus_value; + break; + } + case IA_DRC_DEC_CONFIG_PARAM_GAIN_DELAY: + { + if ((*pus_value > MAX_SIGNAL_DELAY) || (*pus_value < 0)) + { + return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_GAIN_DELAY; + } - - break; - } + p_obj_drc->str_config.gain_delay_samples = *pus_value; - /*Sujith: introduce error*/ - case IA_DRC_DEC_CONFIG_PARAM_AUDIO_DELAY: - { - break; - } - case IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE: - { + + break; + } + + /*Sujith: introduce error*/ + case IA_DRC_DEC_CONFIG_PARAM_AUDIO_DELAY: + { + break; + } + case IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE: + { if(*pus_value<0 || *pus_value>1) { return IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE; } - p_obj_drc->str_config.constant_delay_on = *pus_value; - - break; - } - case IA_DRC_DEC_CONFIG_PARAM_ABSO_DELAY_OFF: - { - p_obj_drc->str_config.absorb_delay_on = *pus_value; - - break; - } - case IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE: - { + p_obj_drc->str_config.constant_delay_on = *pus_value; + + break; + } + case IA_DRC_DEC_CONFIG_PARAM_ABSO_DELAY_OFF: + { + p_obj_drc->str_config.absorb_delay_on = *pus_value; + + break; + } + case IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE: + { if(*pus_value<1 || *pus_value>4096) { return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_FRAME_SIZE; } - p_obj_drc->str_config.frame_size = *pus_value; + p_obj_drc->str_config.frame_size = *pus_value; - - break; - } - case IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG: - { - p_obj_drc->str_bit_handler.gain_stream_flag = *pus_value; - break; - } - - default: - { - return -1; - } - } - break; - } - case IA_API_CMD_GET_MEMTABS_SIZE: - { - break; - } - case IA_API_CMD_SET_MEMTABS_PTR: - { + break; + } + case IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG: + { + p_obj_drc->str_bit_handler.gain_stream_flag = *pus_value; + break; + } - break; - } - case IA_API_CMD_GET_N_MEMTABS: - { - - *pui_value = NUM_DRC_TABLES; - break; - } + case IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE: + { + p_obj_drc->str_config.effect_type = *pus_value; + break; + } + case IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS: + { + p_obj_drc->str_config.target_loudness = *pus_value; + break; + } + case IA_DRC_DEC_CONFIG_DRC_LOUD_NORM: + { + p_obj_drc->str_config.loud_norm_flag = *pus_value; + break; + } + + default: + { + return -1; + } + } + break; + } + case IA_API_CMD_GET_MEMTABS_SIZE: + { + + break; + } + case IA_API_CMD_SET_MEMTABS_PTR: + { + + break; + } + case IA_API_CMD_GET_N_MEMTABS: + { + + *pui_value = NUM_DRC_TABLES; + break; + } case IA_API_CMD_GET_N_TABLES: { break; } - case IA_API_CMD_EXECUTE: - { - switch(i_idx) - { - case IA_CMD_TYPE_DO_EXECUTE: - { - if(p_obj_drc->str_config.dec_type==DEC_TYPE_TD){ - error_code=impd_process_time_domain(p_obj_drc);} - else if(p_obj_drc->str_config.dec_type==DEC_TYPE_QMF64){ - error_code=impd_init_process_audio_main_qmf(p_obj_drc); - } - else if(p_obj_drc->str_config.dec_type==DEC_TYPE_STFT256){ - error_code=impd_init_process_audio_main_stft(p_obj_drc); - } - else if(p_obj_drc->str_config.dec_type==DEC_TYPE_TD_QMF64){ - error_code=impd_init_process_audio_main_td_qmf(p_obj_drc); - } - break; - } - case IA_CMD_TYPE_DONE_QUERY: - { + case IA_API_CMD_EXECUTE: + { + switch(i_idx) + { + case IA_CMD_TYPE_DO_EXECUTE: + { + if(p_obj_drc->str_config.dec_type==DEC_TYPE_TD){ + error_code=impd_process_time_domain(p_obj_drc);} + else if(p_obj_drc->str_config.dec_type==DEC_TYPE_QMF64){ + error_code=impd_init_process_audio_main_qmf(p_obj_drc); + } + else if(p_obj_drc->str_config.dec_type==DEC_TYPE_STFT256){ + error_code=impd_init_process_audio_main_stft(p_obj_drc); + } + else if(p_obj_drc->str_config.dec_type==DEC_TYPE_TD_QMF64){ + error_code=impd_init_process_audio_main_td_qmf(p_obj_drc); + } + break; + } + case IA_CMD_TYPE_DONE_QUERY: + { - *pui_value = p_obj_drc->p_state->ui_exe_done; - break; - } - default: - { - return -1; - } - }; - break; - } - case IA_API_CMD_PUT_INPUT_QUERY: - { - *pui_value = 1; - break; - } - case IA_API_CMD_GET_CURIDX_INPUT_BUF: - { - UWORD32 ui_in_buf_size = - p_obj_drc->p_mem_info[IA_DRC_INPUT_IDX].ui_size; - UWORD32 ui_in_bytes = p_obj_drc->p_state->ui_in_bytes; - *pui_value = ui_in_buf_size > ui_in_bytes ? ui_in_bytes : ui_in_buf_size; - break; - } - case IA_API_CMD_SET_INPUT_BYTES: - { - p_obj_drc->p_state->ui_in_bytes = *pui_value; - break; - } + *pui_value = p_obj_drc->p_state->ui_exe_done; + break; + } + default: + { + return -1; + } + }; + break; + } + case IA_API_CMD_PUT_INPUT_QUERY: + { + *pui_value = 1; + break; + } + case IA_API_CMD_GET_CURIDX_INPUT_BUF: + { + UWORD32 ui_in_buf_size = + p_obj_drc->p_mem_info[IA_DRC_INPUT_IDX].ui_size; + UWORD32 ui_in_bytes = p_obj_drc->p_state->ui_in_bytes; + *pui_value = ui_in_buf_size > ui_in_bytes ? ui_in_bytes : ui_in_buf_size; + break; + } + case IA_API_CMD_SET_INPUT_BYTES: + { + p_obj_drc->p_state->ui_in_bytes = *pui_value; + break; + } - case IA_API_CMD_GET_OUTPUT_BYTES: - { - *pui_value = p_obj_drc->p_state->ui_out_bytes; - break; - } - case IA_API_CMD_INPUT_OVER: - { - p_obj_drc->p_state->ui_exe_done=1; - break; - } - case IA_API_CMD_INPUT_OVER_BS: - { - p_obj_drc->str_bit_handler.cpy_over = 1; - break; - } + case IA_API_CMD_GET_OUTPUT_BYTES: + { + *pui_value = p_obj_drc->p_state->ui_out_bytes; + break; + } + case IA_API_CMD_INPUT_OVER: + { + p_obj_drc->p_state->ui_exe_done=1; + break; + } + case IA_API_CMD_INPUT_OVER_BS: + { + p_obj_drc->str_bit_handler.cpy_over = 1; + break; + } case IA_API_CMD_INPUT_OVER_IC_BS: - { - p_obj_drc->str_bit_handler.cpy_over_ic = 1; - break; - } + { + p_obj_drc->str_bit_handler.cpy_over_ic = 1; + break; + } case IA_API_CMD_INPUT_OVER_IL_BS: - { - p_obj_drc->str_bit_handler.cpy_over_il = 1; - break; - } + { + p_obj_drc->str_bit_handler.cpy_over_il = 1; + break; + } case IA_API_CMD_INPUT_OVER_IN_BS: - { - p_obj_drc->str_bit_handler.cpy_over_in = 1; - break; - } - case IA_API_CMD_SET_INPUT_BYTES_BS: - { - p_obj_drc->str_bit_handler.num_byts_cur=*pus_value; - break; - } + { + p_obj_drc->str_bit_handler.cpy_over_in = 1; + break; + } + case IA_API_CMD_SET_INPUT_BYTES_BS: + { + p_obj_drc->str_bit_handler.num_byts_cur=*pus_value; + break; + } case IA_API_CMD_SET_INPUT_BYTES_IC_BS: - { - p_obj_drc->str_bit_handler.num_byts_cur_ic=*pus_value; - break; - } + { + p_obj_drc->str_bit_handler.num_byts_cur_ic=*pus_value; + break; + } case IA_API_CMD_SET_INPUT_BYTES_IL_BS: - { - p_obj_drc->str_bit_handler.num_byts_cur_il=*pus_value; - break; - } + { + p_obj_drc->str_bit_handler.num_byts_cur_il=*pus_value; + break; + } case IA_API_CMD_SET_INPUT_BYTES_IN_BS: - { - p_obj_drc->str_bit_handler.num_byts_cur_in=*pus_value; - break; - } - default: - { - return -1; - } - }; - return error_code; + { + p_obj_drc->str_bit_handler.num_byts_cur_in=*pus_value; + break; + } + default: + { + return -1; + } + }; + return error_code; } IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, - WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) + WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) { - pUWORD32 pui_value = pv_value; + pUWORD32 pui_value = pv_value; - switch(i_cmd) - { - case IA_API_CMD_GET_MEM_INFO_SIZE: - { - *pui_value = p_obj_drc->p_mem_info[i_idx].ui_size; - break; - } - case IA_API_CMD_GET_MEM_INFO_ALIGNMENT: - { - *pui_value = p_obj_drc->p_mem_info[i_idx].ui_alignment; - break; - } - case IA_API_CMD_GET_MEM_INFO_TYPE: - { - *pui_value = p_obj_drc->p_mem_info[i_idx].ui_type; - break; - } - case IA_API_CMD_GET_MEM_INFO_PLACEMENT: - { - *pui_value = p_obj_drc->p_mem_info[i_idx].ui_placement[0]; - *(pui_value + 1) = p_obj_drc->p_mem_info[i_idx].ui_placement[1]; - break; - } - case IA_API_CMD_GET_MEM_INFO_PRIORITY: - { - *pui_value = p_obj_drc->p_mem_info[i_idx].ui_priority; - break; - } - case IA_API_CMD_SET_MEM_PTR: - { + switch(i_cmd) + { + case IA_API_CMD_GET_MEM_INFO_SIZE: + { + *pui_value = p_obj_drc->p_mem_info[i_idx].ui_size; + break; + } + case IA_API_CMD_GET_MEM_INFO_ALIGNMENT: + { + *pui_value = p_obj_drc->p_mem_info[i_idx].ui_alignment; + break; + } + case IA_API_CMD_GET_MEM_INFO_TYPE: + { + *pui_value = p_obj_drc->p_mem_info[i_idx].ui_type; + break; + } + case IA_API_CMD_GET_MEM_INFO_PLACEMENT: + { + *pui_value = p_obj_drc->p_mem_info[i_idx].ui_placement[0]; + *(pui_value + 1) = p_obj_drc->p_mem_info[i_idx].ui_placement[1]; + break; + } + case IA_API_CMD_GET_MEM_INFO_PRIORITY: + { + *pui_value = p_obj_drc->p_mem_info[i_idx].ui_priority; + break; + } + case IA_API_CMD_SET_MEM_PTR: + { pWORD8 pbtemp; UWORD32 sz; @@ -635,65 +651,65 @@ IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, return(-1); } p_obj_drc->pp_mem[i_idx] = pv_value; - pbtemp = p_obj_drc->pp_mem[i_idx]; - sz = p_obj_drc->p_mem_info[i_idx].ui_size; + pbtemp = p_obj_drc->pp_mem[i_idx]; + sz = p_obj_drc->p_mem_info[i_idx].ui_size; memset(pbtemp,0,sz); - } - case IA_API_CMD_SET_MEM_PLACEMENT: - { + } + case IA_API_CMD_SET_MEM_PLACEMENT: + { - } - }; - return IA_NO_ERROR; + } + }; + return IA_NO_ERROR; } IA_ERRORCODE impd_drc_fill_mem_tables(ia_drc_api_struct *p_obj_drc) { - ia_mem_info_struct *p_mem_info; - { - p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_PERSIST_IDX]; - p_mem_info->ui_size = 64*1024*1024; - p_mem_info->ui_alignment = 8; - p_mem_info->ui_type = IA_MEMTYPE_PERSIST; - p_mem_info->ui_placement[0] = 0; - p_mem_info->ui_placement[1] = 0; - p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; - p_mem_info->ui_placed[0] = 0; - p_mem_info->ui_placed[1] = 0; - } - { - p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_INPUT_IDX]; - p_mem_info->ui_size = p_obj_drc->str_config.frame_size*(p_obj_drc->str_config.pcm_size>>3)*p_obj_drc->str_config.num_ch_in; - p_mem_info->ui_alignment = 4; - p_mem_info->ui_type = IA_MEMTYPE_INPUT; - p_mem_info->ui_placement[0] = 0; - p_mem_info->ui_placement[1] = 0; - p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; - p_mem_info->ui_placed[0] = 0; - p_mem_info->ui_placed[1] = 0; - } - { - p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_OUTPUT_IDX]; - p_mem_info->ui_size = p_obj_drc->str_config.frame_size*(p_obj_drc->str_config.pcm_size>>3)*p_obj_drc->str_config.num_ch_in; - p_mem_info->ui_alignment = 4; - p_mem_info->ui_type = IA_MEMTYPE_OUTPUT; - p_mem_info->ui_placement[0] = 0; - p_mem_info->ui_placement[1] = 0; - p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; - p_mem_info->ui_placed[0] = 0; - p_mem_info->ui_placed[1] = 0; - } - { - p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_SCRATCH_IDX]; - p_mem_info->ui_size = SCRATCH_MEM_SIZE; - p_mem_info->ui_alignment = 8; - p_mem_info->ui_type = IA_MEMTYPE_SCRATCH; - p_mem_info->ui_placement[0] = 0; - p_mem_info->ui_placement[1] = 0; - p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; - p_mem_info->ui_placed[0] = 0; - p_mem_info->ui_placed[1] = 0; - } - return IA_NO_ERROR; + ia_mem_info_struct *p_mem_info; + { + p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_PERSIST_IDX]; + p_mem_info->ui_size = 64*1024*1024; + p_mem_info->ui_alignment = 8; + p_mem_info->ui_type = IA_MEMTYPE_PERSIST; + p_mem_info->ui_placement[0] = 0; + p_mem_info->ui_placement[1] = 0; + p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; + p_mem_info->ui_placed[0] = 0; + p_mem_info->ui_placed[1] = 0; + } + { + p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_INPUT_IDX]; + p_mem_info->ui_size = p_obj_drc->str_config.frame_size*(p_obj_drc->str_config.pcm_size>>3)*p_obj_drc->str_config.num_ch_in; + p_mem_info->ui_alignment = 4; + p_mem_info->ui_type = IA_MEMTYPE_INPUT; + p_mem_info->ui_placement[0] = 0; + p_mem_info->ui_placement[1] = 0; + p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; + p_mem_info->ui_placed[0] = 0; + p_mem_info->ui_placed[1] = 0; + } + { + p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_OUTPUT_IDX]; + p_mem_info->ui_size = p_obj_drc->str_config.frame_size*(p_obj_drc->str_config.pcm_size>>3)*p_obj_drc->str_config.num_ch_in; + p_mem_info->ui_alignment = 4; + p_mem_info->ui_type = IA_MEMTYPE_OUTPUT; + p_mem_info->ui_placement[0] = 0; + p_mem_info->ui_placement[1] = 0; + p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; + p_mem_info->ui_placed[0] = 0; + p_mem_info->ui_placed[1] = 0; + } + { + p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_SCRATCH_IDX]; + p_mem_info->ui_size = SCRATCH_MEM_SIZE; + p_mem_info->ui_alignment = 8; + p_mem_info->ui_type = IA_MEMTYPE_SCRATCH; + p_mem_info->ui_placement[0] = 0; + p_mem_info->ui_placement[1] = 0; + p_mem_info->ui_priority = IA_MEMPRIORITY_ANYWHERE; + p_mem_info->ui_placed[0] = 0; + p_mem_info->ui_placed[1] = 0; + } + return IA_NO_ERROR; } diff --git a/decoder/drc_src/impd_drc_api_defs.h b/decoder/drc_src/impd_drc_api_defs.h index 9b7cd9f..5885a45 100644 --- a/decoder/drc_src/impd_drc_api_defs.h +++ b/decoder/drc_src/impd_drc_api_defs.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_API_DEFS_H @@ -26,26 +26,26 @@ /* Constant hash defines */ /*****************************************************************************/ /* A constant to let API copy small strings to buffers outside */ -#define IA_API_STR_LEN 30 -#define IA_APIVERSION_MAJOR 1 -#define IA_APIVERSION_MINOR 10 +#define IA_API_STR_LEN 30 +#define IA_APIVERSION_MAJOR 1 +#define IA_APIVERSION_MINOR 10 /* last compatible version */ /* sometimes a new API version is just for a bugfix, or a added feature in */ /* this case it is better to use a newer version even though a library was */ /* made for an older version, library API can then be upgraded to newer API */ /* version after checking for compatibility or by adding features */ -#define IA_LASTCOMP_APIVERSION_MAJOR 1 -#define IA_LASTCOMP_APIVERSION_MINOR 10 +#define IA_LASTCOMP_APIVERSION_MAJOR 1 +#define IA_LASTCOMP_APIVERSION_MINOR 10 -#define IA_STR(str) #str -#define IA_MAKE_VERSION_STR(maj, min) IA_STR(maj) "." IA_STR(min) -#define IA_APIVERSION IA_MAKE_VERSION_STR(\ - IA_APIVERSION_MAJOR, \ - IA_APIVERSION_MINOR) +#define IA_STR(str) #str +#define IA_MAKE_VERSION_STR(maj, min) IA_STR(maj) "." IA_STR(min) +#define IA_APIVERSION IA_MAKE_VERSION_STR(\ + IA_APIVERSION_MAJOR, \ + IA_APIVERSION_MINOR) -#define IA_LAST_COMP_APIVERSION IA_MAKE_VERSION_STR(\ - IA_LASTCOMP_APIVERSION_MAJOR, \ - IA_LASTCOMP_APIVERSION_MINOR) +#define IA_LAST_COMP_APIVERSION IA_MAKE_VERSION_STR(\ + IA_LASTCOMP_APIVERSION_MAJOR, \ + IA_LASTCOMP_APIVERSION_MINOR) #endif diff --git a/decoder/drc_src/impd_drc_api_struct_def.h b/decoder/drc_src/impd_drc_api_struct_def.h index 40aeed5..abe6cc3 100644 --- a/decoder/drc_src/impd_drc_api_struct_def.h +++ b/decoder/drc_src/impd_drc_api_struct_def.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_API_STRUCT_DEF_H #define IMPD_DRC_API_STRUCT_DEF_H @@ -52,7 +52,11 @@ typedef struct ia_drc_config_struct WORD32 delay_line_samples; WORD32 constant_delay_on; WORD32 audio_delay_samples; - + + WORD32 effect_type; + WORD32 target_loudness; + WORD32 loud_norm_flag; + }ia_drc_config_struct; /* DRC bitsteam handler */ @@ -79,7 +83,7 @@ typedef struct bits_handler WORD32 cpy_over_ic; WORD32 cpy_over_il; WORD32 cpy_over_in; - WORD32 gain_stream_flag; + WORD32 gain_stream_flag; }ia_drc_bits_handler_struct; typedef struct @@ -93,25 +97,25 @@ typedef struct ia_drc_interface_struct *pstr_drc_interface; ia_drc_peak_limiter_struct *pstr_peak_limiter; - ia_drc_qmf_filt_struct *pstr_qmf_filter; + ia_drc_qmf_filt_struct *pstr_qmf_filter; ia_drc_sel_proc_params_struct *pstr_drc_sel_proc_params; ia_drc_sel_proc_output_struct *pstr_drc_sel_proc_output; - + }ia_drc_payload_struct; typedef struct ia_drc_state_struct { - UWORD32 ui_out_bytes; - UWORD32 ui_in_bytes; - UWORD32 ui_ir_bytes; + UWORD32 ui_out_bytes; + UWORD32 ui_in_bytes; + UWORD32 ui_ir_bytes; UWORD32 total_num_out_samples; UWORD32 frame_no; UWORD32 out_size; - UWORD32 ui_init_done; - UWORD32 ui_exe_done; - UWORD32 ui_ir_used; + UWORD32 ui_init_done; + UWORD32 ui_exe_done; + UWORD32 ui_ir_used; WORD32 delay_in_output; - WORD32 delay_adjust_samples; + WORD32 delay_adjust_samples; pVOID persistant_ptr; }ia_drc_state_struct; @@ -120,10 +124,10 @@ typedef struct IA_PSM_API_Struct ia_drc_state_struct *p_state; ia_drc_config_struct str_config; ia_drc_payload_struct str_payload; - ia_drc_bits_handler_struct str_bit_handler; + ia_drc_bits_handler_struct str_bit_handler; ia_mem_info_struct *p_mem_info; pVOID *pp_mem; - struct ia_bit_buf_struct str_bit_buf, *pstr_bit_buf; + struct ia_bit_buf_struct str_bit_buf, *pstr_bit_buf; } ia_drc_api_struct; diff --git a/decoder/drc_src/impd_drc_bitbuffer.c b/decoder/drc_src/impd_drc_bitbuffer.c index cea9296..2791192 100644 --- a/decoder/drc_src/impd_drc_bitbuffer.c +++ b/decoder/drc_src/impd_drc_bitbuffer.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -31,261 +31,261 @@ #include "impd_drc_parser.h" -WORD32 impd_read_bits_buf(ia_bit_buf_struct* it_bit_buff, - WORD no_of_bits) +WORD32 impd_read_bits_buf(ia_bit_buf_struct* it_bit_buff, + WORD no_of_bits) { - - UWORD32 ret_val; - UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; - WORD bit_pos = it_bit_buff->bit_pos; - it_bit_buff->error = 0; - - if(it_bit_buff->cnt_bits <= 0) - { - it_bit_buff->error = 1; - return -1; - } - - if (no_of_bits==0){ - return 0; - } - - it_bit_buff->cnt_bits -= no_of_bits; - ret_val = (UWORD32)*ptr_read_next; - - bit_pos -= no_of_bits; - while (bit_pos < 0) { - bit_pos += 8; - ptr_read_next++; - - if(ptr_read_next > it_bit_buff->ptr_bit_buf_end) { - ptr_read_next = it_bit_buff->ptr_bit_buf_base; - } - - ret_val <<= 8; - - ret_val |= (UWORD32)*ptr_read_next; - } - - ret_val = ret_val << ((31 - no_of_bits) - bit_pos) >> (32 - no_of_bits); - it_bit_buff->ptr_read_next = ptr_read_next; - it_bit_buff->bit_pos = (WORD16)bit_pos; - return ret_val; + + UWORD32 ret_val; + UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; + WORD bit_pos = it_bit_buff->bit_pos; + it_bit_buff->error = 0; + + if(it_bit_buff->cnt_bits <= 0) + { + it_bit_buff->error = 1; + return -1; + } + + if (no_of_bits==0){ + return 0; + } + + it_bit_buff->cnt_bits -= no_of_bits; + ret_val = (UWORD32)*ptr_read_next; + + bit_pos -= no_of_bits; + while (bit_pos < 0) { + bit_pos += 8; + ptr_read_next++; + + if(ptr_read_next > it_bit_buff->ptr_bit_buf_end) { + ptr_read_next = it_bit_buff->ptr_bit_buf_base; + } + + ret_val <<= 8; + + ret_val |= (UWORD32)*ptr_read_next; + } + + ret_val = ret_val << ((31 - no_of_bits) - bit_pos) >> (32 - no_of_bits); + it_bit_buff->ptr_read_next = ptr_read_next; + it_bit_buff->bit_pos = (WORD16)bit_pos; + return ret_val; } -ia_bit_buf_struct* impd_create_bit_buf(ia_bit_buf_struct* it_bit_buff, - UWORD8 *ptr_bit_buf_base, - WORD32 bit_buf_size) +ia_bit_buf_struct* impd_create_bit_buf(ia_bit_buf_struct* it_bit_buff, + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size) { - - it_bit_buff->ptr_bit_buf_base = ptr_bit_buf_base; - it_bit_buff->ptr_bit_buf_end = ptr_bit_buf_base + bit_buf_size - 1; - - it_bit_buff->ptr_read_next = ptr_bit_buf_base; - it_bit_buff->bit_pos = 7; - - it_bit_buff->cnt_bits = 0; - it_bit_buff->size = bit_buf_size << 3; - - return it_bit_buff; + + it_bit_buff->ptr_bit_buf_base = ptr_bit_buf_base; + it_bit_buff->ptr_bit_buf_end = ptr_bit_buf_base + bit_buf_size - 1; + + it_bit_buff->ptr_read_next = ptr_bit_buf_base; + it_bit_buff->bit_pos = 7; + + it_bit_buff->cnt_bits = 0; + it_bit_buff->size = bit_buf_size << 3; + + return it_bit_buff; } ia_bit_buf_struct* impd_create_init_bit_buf(ia_bit_buf_struct* it_bit_buff, - UWORD8 *ptr_bit_buf_base, - WORD32 bit_buf_size) + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size) { - impd_create_bit_buf(it_bit_buff,ptr_bit_buf_base,bit_buf_size); - it_bit_buff->cnt_bits = (bit_buf_size << 3); - return (it_bit_buff); + impd_create_bit_buf(it_bit_buff,ptr_bit_buf_base,bit_buf_size); + it_bit_buff->cnt_bits = (bit_buf_size << 3); + return (it_bit_buff); } WORD32 impd_init_drc_bitstream_dec(ia_drc_bits_dec_struct* p_drc_bs_dec_struct, - WORD32 sample_rate, - WORD32 frame_size, - WORD32 delay_mode, - WORD32 lfe_channel_map_count, - WORD32* lfe_channel_map) + WORD32 sample_rate, + WORD32 frame_size, + WORD32 delay_mode, + WORD32 lfe_channel_map_count, + WORD32* lfe_channel_map) { WORD32 i, err_code = 0; - + ia_drc_params_bs_dec_struct* ia_drc_params_struct = &p_drc_bs_dec_struct->ia_drc_params_struct; ia_drc_params_struct->drc_frame_size = frame_size; ia_drc_params_struct->delta_tmin_default = impd_get_delta_tmin(sample_rate); ia_drc_params_struct->num_gain_values_max_default = ia_drc_params_struct->drc_frame_size / ia_drc_params_struct->delta_tmin_default; - ia_drc_params_struct->delay_mode = delay_mode; - + ia_drc_params_struct->delay_mode = delay_mode; + if ((frame_size < 1)||(frame_size > AUDIO_CODEC_FRAME_SIZE_MAX)||(ia_drc_params_struct->drc_frame_size < 0.001f * sample_rate)) - { + { return -1; - } + } if (sample_rate < 1000) { return -1; } - + if (ia_drc_params_struct->delta_tmin_default > ia_drc_params_struct->drc_frame_size) { return -1; } - - if (lfe_channel_map_count >= 0) - { + + if (lfe_channel_map_count >= 0) + { if ((lfe_channel_map == NULL) || (lfe_channel_map_count > MAX_CHANNEL_COUNT)) - { + { return(-1); - } - + } + ia_drc_params_struct->lfe_channel_map_count = lfe_channel_map_count; - - for (i=0; ilfe_channel_map[i] = lfe_channel_map[i]; } - } - else - { + } + else + { ia_drc_params_struct->lfe_channel_map_count = -1; - - for (i=0; ilfe_channel_map[i] = 0; } } - + err_code = impd_init_tbls(ia_drc_params_struct->num_gain_values_max_default, &p_drc_bs_dec_struct->tables_default); - + return err_code; } WORD32 impd_process_drc_bitstream_dec(ia_drc_bits_dec_struct* p_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, - ia_drc_config *pstr_drc_config, - ia_drc_loudness_info_set_struct *pstr_loudness_info, - UWORD8* bitstream_config, - WORD32 num_bytes, - WORD32 num_bits_offset, - WORD32* num_bits_read) + ia_bit_buf_struct* it_bit_buff, + ia_drc_config *pstr_drc_config, + ia_drc_loudness_info_set_struct *pstr_loudness_info, + UWORD8* bitstream_config, + WORD32 num_bytes, + WORD32 num_bits_offset, + WORD32* num_bits_read) { WORD32 err_code = 0; - + WORD32 loudness_info_set_present, drc_config_present, dummy; - - + + if (bitstream_config == NULL) { *num_bits_read = 0; } else { - - it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bitstream_config, num_bytes); - - dummy = impd_read_bits_buf(it_bit_buff, num_bits_offset); - if(it_bit_buff->error) - return it_bit_buff->error; - - loudness_info_set_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - + + it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bitstream_config, num_bytes); + + dummy = impd_read_bits_buf(it_bit_buff, num_bits_offset); + if(it_bit_buff->error) + return it_bit_buff->error; + + loudness_info_set_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (loudness_info_set_present) { - drc_config_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - + drc_config_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (drc_config_present) { err_code = impd_parse_drc_config(it_bit_buff, &p_drc_bs_dec_struct->ia_drc_params_struct, pstr_drc_config); - + if (err_code) return (err_code); - + } - + err_code = impd_parse_loudness_info_set(it_bit_buff, pstr_loudness_info); - - if (err_code) + + if (err_code) return (err_code); } - + *num_bits_read = it_bit_buff->size - it_bit_buff->cnt_bits; } - + return err_code; } WORD32 impd_process_drc_bitstream_dec_config(ia_drc_bits_dec_struct* p_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, - ia_drc_config *pstr_drc_config, - UWORD8* bitstream_config, - WORD32 num_bytes) + ia_bit_buf_struct* it_bit_buff, + ia_drc_config *pstr_drc_config, + UWORD8* bitstream_config, + WORD32 num_bytes) { WORD32 err_code = 0; - - it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bitstream_config, num_bytes); - + + it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bitstream_config, num_bytes); + err_code = impd_parse_drc_config( it_bit_buff, &p_drc_bs_dec_struct->ia_drc_params_struct, pstr_drc_config); if (err_code) return (err_code); - - return err_code; + + return err_code; } - + WORD32 impd_process_drc_bitstream_dec_gain(ia_drc_bits_dec_struct* p_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, - ia_drc_config *pstr_drc_config, - ia_drc_gain_struct *pstr_drc_gain, - UWORD8* bitstream_gain, - WORD32 num_bytes, - WORD32 num_bits_offset, - WORD32* num_bits_read) + ia_bit_buf_struct* it_bit_buff, + ia_drc_config *pstr_drc_config, + ia_drc_gain_struct *pstr_drc_gain, + UWORD8* bitstream_gain, + WORD32 num_bytes, + WORD32 num_bits_offset, + WORD32* num_bits_read) { WORD32 err_code = 0; - + WORD32 dummy; - - it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bitstream_gain, num_bytes); - - dummy = impd_read_bits_buf(it_bit_buff, num_bits_offset); - if(it_bit_buff->error) - return it_bit_buff->error; - + + it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bitstream_gain, num_bytes); + + dummy = impd_read_bits_buf(it_bit_buff, num_bits_offset); + if(it_bit_buff->error) + return it_bit_buff->error; + err_code = impd_drc_uni_gain_read( - it_bit_buff, - p_drc_bs_dec_struct, - pstr_drc_config, - pstr_drc_gain); - - if (err_code > PROC_COMPLETE) + it_bit_buff, + p_drc_bs_dec_struct, + pstr_drc_config, + pstr_drc_gain); + + if (err_code > PROC_COMPLETE) return (err_code); - + *num_bits_read = (it_bit_buff->size) - it_bit_buff->cnt_bits; - + if (err_code == PROC_COMPLETE) { return err_code; } - + return 0; } WORD32 impd_process_drc_bitstream_dec_loudness_info_set(ia_bit_buf_struct* it_bit_buff, - ia_drc_loudness_info_set_struct *pstr_loudness_info, - UWORD8* bit_stream_loudness, - WORD32 num_bytes_loudness) + ia_drc_loudness_info_set_struct *pstr_loudness_info, + UWORD8* bit_stream_loudness, + WORD32 num_bytes_loudness) { WORD32 err_code = 0; - - it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bit_stream_loudness, num_bytes_loudness); - + + it_bit_buff = impd_create_init_bit_buf(it_bit_buff, bit_stream_loudness, num_bytes_loudness); + err_code = impd_parse_loudness_info_set(it_bit_buff, pstr_loudness_info); if (err_code) - return(err_code); - - + return(err_code); + + return 0; } diff --git a/decoder/drc_src/impd_drc_bitbuffer.h b/decoder/drc_src/impd_drc_bitbuffer.h index ab0b2c7..89e7044 100644 --- a/decoder/drc_src/impd_drc_bitbuffer.h +++ b/decoder/drc_src/impd_drc_bitbuffer.h @@ -1,53 +1,53 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_BITBUFFER_H #define IMPD_DRC_BITBUFFER_H -typedef struct ia_bit_buf_struct +typedef struct ia_bit_buf_struct { - UWORD8 *ptr_bit_buf_base; - UWORD8 *ptr_bit_buf_end; - - UWORD8 *ptr_read_next; - - WORD32 bit_pos; - WORD32 cnt_bits; - - WORD32 size; - WORD32 error; - - + UWORD8 *ptr_bit_buf_base; + UWORD8 *ptr_bit_buf_end; + + UWORD8 *ptr_read_next; + + WORD32 bit_pos; + WORD32 cnt_bits; + + WORD32 size; + WORD32 error; + + }ia_bit_buf_struct; ia_bit_buf_struct * impd_create_bit_buf(ia_bit_buf_struct* it_bit_buff, - UWORD8 *ptr_bit_buf_base, - WORD32 bit_buf_size); + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size); ia_bit_buf_struct * impd_create_init_bit_buf(ia_bit_buf_struct* it_bit_buff, - UWORD8 *ptr_bit_buf_base, - WORD32 bit_buf_size); + UWORD8 *ptr_bit_buf_base, + WORD32 bit_buf_size); WORD32 impd_read_bits_buf(ia_bit_buf_struct* it_bit_buff, - WORD no_of_bits); + WORD no_of_bits); #endif diff --git a/decoder/drc_src/impd_drc_bitstream_dec_api.h b/decoder/drc_src/impd_drc_bitstream_dec_api.h index d110d73..f4e45fb 100644 --- a/decoder/drc_src/impd_drc_bitstream_dec_api.h +++ b/decoder/drc_src/impd_drc_bitstream_dec_api.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_BITSTREAM_DEC_API_H #define IMPD_DRC_BITSTREAM_DEC_API_H @@ -25,37 +25,37 @@ WORD32 impd_init_drc_bitstream_dec(ia_drc_bits_dec_struct* p_uni_drc_bs_dec_stru WORD32 sample_rate, WORD32 frame_size, WORD32 delay_mode, - WORD32 lfe_channel_map_count, + WORD32 lfe_channel_map_count, WORD32* lfe_channel_map); - + WORD32 impd_process_drc_bitstream_dec(ia_drc_bits_dec_struct* p_uni_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_config* pstr_drc_config, ia_drc_loudness_info_set_struct* pstr_loudness_info, UWORD8* bitstream_config, WORD32 num_bytes, WORD32 num_bits_offset, WORD32* num_bits_read); - + WORD32 impd_process_drc_bitstream_dec_config(ia_drc_bits_dec_struct* p_uni_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_config* pstr_drc_config, UWORD8* bitstream_config, WORD32 num_bytes); WORD32 impd_process_drc_bitstream_dec_gain(ia_drc_bits_dec_struct* p_uni_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_config* pstr_drc_config, ia_drc_gain_struct* pstr_drc_gain, UWORD8* bitstream_gain, WORD32 num_bytes, WORD32 num_bits_offset, WORD32* num_bits_read); - + WORD32 impd_process_drc_bitstream_dec_loudness_info_set(ia_bit_buf_struct* it_bit_buff, - ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_drc_loudness_info_set_struct* pstr_loudness_info, UWORD8* bitstream_loudness, - WORD32 num_bytes_loudness + WORD32 num_bytes_loudness ); #endif diff --git a/decoder/drc_src/impd_drc_common.h b/decoder/drc_src/impd_drc_common.h index 2ae6873..79bdbcf 100644 --- a/decoder/drc_src/impd_drc_common.h +++ b/decoder/drc_src/impd_drc_common.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_COMMON_H #define IMPD_DRC_COMMON_H @@ -25,41 +25,41 @@ extern "C" { #endif - -#define EQ_IS_SUPPORTED 1 - + +#define EQ_IS_SUPPORTED 1 + #define MEASURE_AVERAGE_BITRATE 0 #define ENABLE_ADDITIONAL_TESTS 1 #define SPEAKER_POS_COUNT_MAX 128 -#define DOWNMIX_COEFF_COUNT_MAX 32*32 +#define DOWNMIX_COEFF_COUNT_MAX 32*32 #define MAX_CHANNEL_COUNT 128 -#define BAND_COUNT_MAX 8 -#define SEQUENCE_COUNT_MAX 24 +#define BAND_COUNT_MAX 8 +#define SEQUENCE_COUNT_MAX 24 #define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX #define MEASUREMENT_COUNT_MAX 16 #define DOWNMIX_INSTRUCTION_COUNT_MAX 16 #define DRC_COEFF_COUNT_MAX 8 -#define DRC_INSTRUCTIONS_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) -#define LOUDNESS_INFO_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) -#define AUDIO_CODEC_FRAME_SIZE_MAX 4096 -#define DRC_CODEC_FRAME_SIZE_MAX (AUDIO_CODEC_FRAME_SIZE_MAX/8) +#define DRC_INSTRUCTIONS_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) +#define LOUDNESS_INFO_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) +#define AUDIO_CODEC_FRAME_SIZE_MAX 4096 +#define DRC_CODEC_FRAME_SIZE_MAX (AUDIO_CODEC_FRAME_SIZE_MAX/8) #define NODE_COUNT_MAX DRC_CODEC_FRAME_SIZE_MAX #define CHANNEL_GROUP_COUNT_MAX SEQUENCE_COUNT_MAX #define SUB_DRC_COUNT 4 #define SEL_DRC_COUNT 3 #define DOWNMIX_ID_COUNT_MAX 8 -#define MAX_SIGNAL_DELAY 4500 - +#define MAX_SIGNAL_DELAY 4500 + #define DRC_BAND_COUNT_MAX BAND_COUNT_MAX -#define SPLIT_CHARACTERISTIC_COUNT_MAX 8 +#define SPLIT_CHARACTERISTIC_COUNT_MAX 8 #define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX -#define SHAPE_FILTER_COUNT_MAX 8 +#define SHAPE_FILTER_COUNT_MAX 8 #define DRC_SET_ID_COUNT_MAX 16 #define EQ_SET_ID_COUNT_MAX 8 #define LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX 4 -#define FILTER_ELEMENT_COUNT_MAX 16 +#define FILTER_ELEMENT_COUNT_MAX 16 #define REAL_ZERO_RADIUS_ONE_COUNT_MAX 14 #define REAL_ZERO_COUNT_MAX 64 #define COMPLEX_ZERO_COUNT_MAX 64 @@ -68,13 +68,13 @@ extern "C" #define FIR_ORDER_MAX 128 #define EQ_NODE_COUNT_MAX 33 #define EQ_SUBBAND_GAIN_COUNT_MAX 135 -#define UNIQUE_SUBBAND_GAIN_COUNT_MAX 16 +#define UNIQUE_SUBBAND_GAIN_COUNT_MAX 16 #define FILTER_BLOCK_COUNT_MAX 16 -#define FILTER_ELEMENT_COUNT_MAX 16 -#define UNIQUE_SUBBAND_GAINS_COUNT_MAX 8 -#define EQ_CHANNEL_GROUP_COUNT_MAX 4 -#define EQ_FILTER_BLOCK_COUNT_MAX 4 -#define LOUD_EQ_INSTRUCTIONS_COUNT_MAX 8 +#define FILTER_ELEMENT_COUNT_MAX 16 +#define UNIQUE_SUBBAND_GAINS_COUNT_MAX 8 +#define EQ_CHANNEL_GROUP_COUNT_MAX 4 +#define EQ_FILTER_BLOCK_COUNT_MAX 4 +#define LOUD_EQ_INSTRUCTIONS_COUNT_MAX 8 #define EQ_INSTRUCTIONS_COUNT_MAX 8 #define SELECTED_EQ_SET_COUNT_MAX 2 #define SUB_EQ_COUNT 2 @@ -85,7 +85,7 @@ extern "C" #define FEATURE_REQUEST_COUNT_MAX 10 #define EFFECT_TYPE_REQUEST_COUNT_MAX 10 - + #define SELECTION_CANDIDATE_COUNT_MAX 32 #define PROC_COMPLETE 1 @@ -101,11 +101,11 @@ extern "C" #define ID_FOR_NO_DRC 0x0 #define ID_FOR_ANY_DRC 0x3F #define ID_FOR_ANY_EQ 0x3F - + #define LOCATION_MP4_INSTREAM_UNIDRC 0x1 #define LOCATION_MP4_DYN_RANGE_INFO 0x2 #define LOCATION_MP4_COMPRESSION_VALUE 0x3 -#define LOCATION_SELECTED LOCATION_MP4_INSTREAM_UNIDRC +#define LOCATION_SELECTED LOCATION_MP4_INSTREAM_UNIDRC #define AUDIO_CODEC_SUBBAND_COUNT_MAX 256 @@ -113,19 +113,19 @@ extern "C" #define SUBBAND_DOMAIN_MODE_QMF64 1 #define SUBBAND_DOMAIN_MODE_QMF71 2 #define SUBBAND_DOMAIN_MODE_STFT256 3 - + #define AUDIO_CODEC_SUBBAND_COUNT_QMF64 64 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64 64 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF64 320 - + #define AUDIO_CODEC_SUBBAND_COUNT_QMF71 71 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71 64 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF71 320+384 - + #define AUDIO_CODEC_SUBBAND_COUNT_STFT256 256 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256 256 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_STFT256 256 - + #define MAX_NUM_DOWNMIX_ID_REQUESTS 15 #define MAX_NUM_DRC_FEATURE_REQUESTS 7 #define MAX_NUM_DRC_EFFECT_TYPE_REQUESTS 15 @@ -142,21 +142,21 @@ extern "C" #define PARAM_DRC_INSTRUCTIONS_COUNT_MAX 8 #define PARAM_DRC_INSTANCE_COUNT_MAX 8 - + #define PARAM_DRC_TYPE_FF 0x0 #define PARAM_DRC_TYPE_FF_NODE_COUNT_MAX 9 #define PARAM_DRC_TYPE_FF_LEVEL_ESTIM_FRAME_COUNT_MAX 64 - + #define PARAM_DRC_TYPE_LIM 0x1 #define PARAM_DRC_TYPE_LIM_THRESHOLD_DEFAULT (-1.f) #define PARAM_DRC_TYPE_LIM_ATTACK_DEFAULT 5 #define PARAM_DRC_TYPE_LIM_RELEASE_DEFAULT 50 - - + + #define UNIDRCCONFEXT_V1 0x2 #define UNIDRCLOUDEXT_EQ 0x1 #define UNIDRCINTERFACEEXT_EQ 0x1 - + #define LOUD_EQ_REQUEST_OFF 0x0 #define LOUD_EQ_REQUEST_LIGHT 0x1 #define LOUD_EQ_REQUEST_REGULAR 0x2 @@ -170,12 +170,12 @@ extern "C" #define EQ_PURPOSE_CAR_CABIN (1<<4) #define EQ_PURPOSE_HEADPHONES (1<<5) #define EQ_PURPOSE_LATE_NIGHT (1<<6) - - - + + + #define MAXPACKETLOSSTIME 2.5f -#define SLOPE_FACTOR_DB_TO_LINEAR 0.1151f +#define SLOPE_FACTOR_DB_TO_LINEAR 0.1151f #ifndef min #define min(a, b) ((a) < (b) ? (a) : (b)) @@ -187,17 +187,17 @@ extern "C" #ifndef bool #define bool WORD32 #endif - + typedef struct ia_drc_sel_proc_output_struct -{ +{ FLOAT32 output_peak_level_db; FLOAT32 loudness_normalization_gain_db; FLOAT32 output_loudness; - + WORD32 sel_drc_set_ids[SUB_DRC_COUNT]; WORD32 sel_downmix_ids[SUB_DRC_COUNT]; WORD32 num_sel_drc_sets; - + WORD32 active_downmix_id; WORD32 base_channel_count; WORD32 target_channel_count; @@ -208,7 +208,7 @@ typedef struct ia_drc_sel_proc_output_struct FLOAT32 boost; FLOAT32 compress; WORD32 drc_characteristic_target; - + FLOAT32 mixing_level; WORD32 sel_eq_set_ids[SELECTED_EQ_SET_COUNT_MAX]; diff --git a/decoder/drc_src/impd_drc_config_params.h b/decoder/drc_src/impd_drc_config_params.h index 252dcce..b23ed36 100644 --- a/decoder/drc_src/impd_drc_config_params.h +++ b/decoder/drc_src/impd_drc_config_params.h @@ -1,42 +1,45 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #ifndef IMPD_DRC_CONFIG_PARAMS_H #define IMPD_DRC_CONFIG_PARAMS_H -#define IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ 0x0000 -#define IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ 0x0001 -#define IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS 0x0002 -#define IA_DRC_DEC_CONFIG_PARAM_DEC_TYPE 0x0003 -#define IA_DRC_DEC_CONFIG_PARAM_PEAK_LIMITER 0x0004 -#define IA_DRC_DEC_CONFIG_PARAM_CTRL_PARAM 0x0005 -#define IA_DRC_DEC_CONFIG_PARAM_VER_MODE 0x0006 -#define IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT 0x0007 +#define IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ 0x0000 +#define IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ 0x0001 +#define IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS 0x0002 +#define IA_DRC_DEC_CONFIG_PARAM_DEC_TYPE 0x0003 +#define IA_DRC_DEC_CONFIG_PARAM_PEAK_LIMITER 0x0004 +#define IA_DRC_DEC_CONFIG_PARAM_CTRL_PARAM 0x0005 +#define IA_DRC_DEC_CONFIG_PARAM_VER_MODE 0x0006 +#define IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT 0x0007 #define IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT 0x0008 -#define IA_DRC_DEC_CONFIG_PARAM_DELAY_MODE 0x0009 +#define IA_DRC_DEC_CONFIG_PARAM_DELAY_MODE 0x0009 #define IA_DRC_DEC_CONFIG_PARAM_GAIN_DELAY 0x000A #define IA_DRC_DEC_CONFIG_PARAM_AUDIO_DELAY 0x000B #define IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE 0x000C #define IA_DRC_DEC_CONFIG_PARAM_ABSO_DELAY_OFF 0x000D #define IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE 0x000E -#define IA_DRC_DEC_CONFIG_PROC_OUT_PTR 0x000F -#define IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG 0x0010 +#define IA_DRC_DEC_CONFIG_PROC_OUT_PTR 0x000F +#define IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG 0x0010 +#define IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE 0x0011 +#define IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS 0x0012 +#define IA_DRC_DEC_CONFIG_DRC_LOUD_NORM 0x0013 #endif diff --git a/decoder/drc_src/impd_drc_dec.c b/decoder/drc_src/impd_drc_dec.c index be4347d..0e32e46 100644 --- a/decoder/drc_src/impd_drc_dec.c +++ b/decoder/drc_src/impd_drc_dec.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include "impd_type_def.h" #include "impd_drc_extr_delta_coded_info.h" @@ -40,45 +40,45 @@ WORD32 impd_init_drc_params(WORD32 frame_size, { return -1; } - + if (sample_rate < 1000) { return -1; } - + ia_drc_params_struct->drc_frame_size = frame_size; - + if (ia_drc_params_struct->drc_frame_size < 0.001f * sample_rate) { return -1; } - + ia_drc_params_struct->sample_rate = sample_rate; - + ia_drc_params_struct->delta_tmin_default = impd_get_delta_tmin(sample_rate); - + if (ia_drc_params_struct->delta_tmin_default > ia_drc_params_struct->drc_frame_size) { return -1; } - + if ((delay_mode != DELAY_MODE_REGULAR_DELAY) && (delay_mode != DELAY_MODE_LOW_DELAY)) { return -1; } - + ia_drc_params_struct->delay_mode = delay_mode; - + ia_drc_params_struct->drc_set_counter = 0; ia_drc_params_struct->multiband_sel_drc_idx = -1; - + for (k = 0; k < SEL_DRC_COUNT; k++) { ia_drc_params_struct->sel_drc_array[k].drc_instructions_index = -1; ia_drc_params_struct->sel_drc_array[k].dwnmix_instructions_index = -1; ia_drc_params_struct->sel_drc_array[k].drc_coeff_idx = -1; } - + if ((gain_delay_samples > MAX_SIGNAL_DELAY) || (gain_delay_samples < 0)) { return -1; @@ -87,23 +87,23 @@ WORD32 impd_init_drc_params(WORD32 frame_size, { ia_drc_params_struct->gain_delay_samples = gain_delay_samples; } - - switch (sub_band_domain_mode) - { - case SUBBAND_DOMAIN_MODE_OFF: - case SUBBAND_DOMAIN_MODE_QMF64: - case SUBBAND_DOMAIN_MODE_QMF71: - case SUBBAND_DOMAIN_MODE_STFT256: - ia_drc_params_struct->sub_band_domain_mode = sub_band_domain_mode; - break; - default: - return -1; - break; + + switch (sub_band_domain_mode) + { + case SUBBAND_DOMAIN_MODE_OFF: + case SUBBAND_DOMAIN_MODE_QMF64: + case SUBBAND_DOMAIN_MODE_QMF71: + case SUBBAND_DOMAIN_MODE_STFT256: + ia_drc_params_struct->sub_band_domain_mode = sub_band_domain_mode; + break; + default: + return -1; + break; } - + ia_drc_params_struct->parametric_drc_delay = 0; ia_drc_params_struct->eq_delay = 0; - + return 0; } @@ -132,7 +132,7 @@ WORD32 impd_select_drc_coefficients(ia_drc_config* drc_config, } } - + if (cof1 >= 0) { *drc_coefficients_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[cof1]); } @@ -140,10 +140,10 @@ WORD32 impd_select_drc_coefficients(ia_drc_config* drc_config, *drc_coefficients_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[cof0]); } else { - *drc_coefficients_drc = NULL; + *drc_coefficients_drc = NULL; } - + return 0; } @@ -162,8 +162,8 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, { WORD32 g, n, c, err = 0; WORD32 channel_count = 0; - WORD32 i; - + WORD32 i; + ia_drc_instructions_struct* drc_instructions_uni_drc = NULL; ia_uni_drc_coeffs_struct* drc_coefficients_uni_drc = NULL; WORD32 selected_drc_is_multiband = 0; @@ -171,19 +171,19 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, WORD32 downmix_instructions_selected = -1; WORD32 drc_coefficients_selected = -1; p_parametric_drc_params->parametric_drc_instance_count = 0; - + if (drc_config->drc_coefficients_drc_count && drc_config->str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present) { if (drc_config->str_p_loc_drc_coefficients_uni_drc->drc_frame_size != ia_drc_params_struct->drc_frame_size) { - return -1; + return -1; } } - - + + for(n=0; ndrc_instructions_count_plus; n++) { - if (drc_config->str_drc_instruction_str[n].drc_set_id == drc_set_id_selected) + if (drc_config->str_drc_instruction_str[n].drc_set_id == drc_set_id_selected) break; } if (n == drc_config->drc_instructions_count_plus) @@ -192,21 +192,21 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, } drc_instructions_selected = n; drc_instructions_uni_drc = &(drc_config->str_drc_instruction_str[drc_instructions_selected]); - - if (downmix_id_selected == ID_FOR_BASE_LAYOUT) - { + + if (downmix_id_selected == ID_FOR_BASE_LAYOUT) + { channel_count = drc_config->channel_layout.base_channel_count; - } - else if (downmix_id_selected == ID_FOR_ANY_DOWNMIX) - { + } + else if (downmix_id_selected == ID_FOR_ANY_DOWNMIX) + { channel_count = audio_num_chan; - } - else - { + } + else + { for(n=0; ndwnmix_instructions_count; n++) { - if (drc_config->dwnmix_instructions[n].downmix_id == downmix_id_selected) - break; + if (drc_config->dwnmix_instructions[n].downmix_id == downmix_id_selected) + break; } if (n == drc_config->dwnmix_instructions_count) { @@ -215,9 +215,9 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, channel_count = drc_config->dwnmix_instructions[n].target_channel_count; downmix_instructions_selected = n; - } + } drc_instructions_uni_drc->audio_num_chan = channel_count; - + if (drc_instructions_uni_drc->drc_set_id <= 0) { drc_coefficients_selected = 0; @@ -226,20 +226,20 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, { err = impd_select_drc_coefficients(drc_config, &drc_coefficients_uni_drc, &drc_coefficients_selected); } - + ia_drc_params_struct->sel_drc_array[ia_drc_params_struct->drc_set_counter].drc_instructions_index = drc_instructions_selected; ia_drc_params_struct->sel_drc_array[ia_drc_params_struct->drc_set_counter].dwnmix_instructions_index = downmix_instructions_selected; ia_drc_params_struct->sel_drc_array[ia_drc_params_struct->drc_set_counter].drc_coeff_idx = drc_coefficients_selected; - - if ((drc_instructions_uni_drc->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (drc_instructions_uni_drc->dwnmix_id_count > 1)) - { + + if ((drc_instructions_uni_drc->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (drc_instructions_uni_drc->dwnmix_id_count > 1)) + { WORD32 idx = drc_instructions_uni_drc->gain_set_index[0]; - for (c=0; caudio_num_chan; c++) - { + for (c=0; caudio_num_chan; c++) + { drc_instructions_uni_drc->channel_group_of_ch[c] = (idx >= 0) ? 0 : -1; } } - + for (g=0; gnum_drc_ch_groups; g++) { drc_instructions_uni_drc->num_chan_per_ch_group[g] = 0; for (c=0; caudio_num_chan; c++) { @@ -248,7 +248,7 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, } } } - + if (drc_instructions_uni_drc->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) { drc_instructions_uni_drc->multiband_audio_sig_count = drc_instructions_uni_drc->audio_num_chan; } else { @@ -262,7 +262,7 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, } } } - + for (g=0; gnum_drc_ch_groups; g++) { if (g==0) { @@ -272,9 +272,9 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, if (drc_instructions_uni_drc->band_count_of_ch_group[g] > 1) { if (ia_drc_params_struct->multiband_sel_drc_idx != -1) - { - return (UNEXPECTED_ERROR); - } + { + return (UNEXPECTED_ERROR); + } selected_drc_is_multiband = 1; } } else { @@ -282,17 +282,17 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, WORD32 parametric_drc_id = drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].parametric_drc_id; WORD32 parametric_drc_look_ahead_samples = 0; ia_parametric_drc_instructions_struct* str_parametric_drc_instructions; - + for(i=0; istr_drc_config_ext.parametric_drc_instructions_count; i++) { if (parametric_drc_id == drc_config->str_drc_config_ext.str_parametric_drc_instructions[i].parametric_drc_id) break; } if (i == drc_config->str_drc_config_ext.parametric_drc_instructions_count) - { - return (UNEXPECTED_ERROR); - } + { + return (UNEXPECTED_ERROR); + } str_parametric_drc_instructions = &drc_config->str_drc_config_ext.str_parametric_drc_instructions[i]; - + p_parametric_drc_params->parametric_drc_idx[p_parametric_drc_params->parametric_drc_instance_count] = i; p_parametric_drc_params->gain_set_index[p_parametric_drc_params->parametric_drc_instance_count] = gain_set_index; if (drc_instructions_uni_drc->drc_apply_to_dwnmix == 0) { @@ -316,21 +316,21 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, if (str_parametric_drc_instructions->parametric_drc_look_ahead_flag) { parametric_drc_look_ahead_samples = (WORD32)((FLOAT32)str_parametric_drc_instructions->parametric_drc_look_ahead*(FLOAT32)p_parametric_drc_params->sampling_rate*0.001f); } else { - if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_FF) - { + if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_FF) + { parametric_drc_look_ahead_samples = (WORD32)(10.0f*(FLOAT32)p_parametric_drc_params->sampling_rate*0.001f); - } - else if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_LIM) - { + } + else if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_LIM) + { parametric_drc_look_ahead_samples = (WORD32)(5.0f*(FLOAT32)p_parametric_drc_params->sampling_rate*0.001f); - } else - { - return (UNEXPECTED_ERROR); - } + } else + { + return (UNEXPECTED_ERROR); + } } drc_instructions_uni_drc->parametric_drc_look_ahead_samples[g] = parametric_drc_look_ahead_samples; - if (drc_instructions_uni_drc->parametric_drc_look_ahead_samples_max < drc_instructions_uni_drc->parametric_drc_look_ahead_samples[g]) - { + if (drc_instructions_uni_drc->parametric_drc_look_ahead_samples_max < drc_instructions_uni_drc->parametric_drc_look_ahead_samples[g]) + { drc_instructions_uni_drc->parametric_drc_look_ahead_samples_max = drc_instructions_uni_drc->parametric_drc_look_ahead_samples[g]; } p_parametric_drc_params->parametric_drc_instance_count += 1; @@ -338,22 +338,22 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, } } ia_drc_params_struct->parametric_drc_delay += drc_instructions_uni_drc->parametric_drc_look_ahead_samples_max; - + if (selected_drc_is_multiband == 1) { ia_drc_params_struct->multiband_sel_drc_idx = ia_drc_params_struct->drc_set_counter; err = impd_init_all_filter_banks(drc_coefficients_uni_drc, - &(drc_config->str_drc_instruction_str[drc_instructions_selected]), - ia_filter_banks_struct); - if (err) - return (err); - + &(drc_config->str_drc_instruction_str[drc_instructions_selected]), + ia_filter_banks_struct); + if (err) + return (err); + err = impd_init_overlap_weight (drc_coefficients_uni_drc, - &(drc_config->str_drc_instruction_str[drc_instructions_selected]), - ia_drc_params_struct->sub_band_domain_mode, - pstr_overlap_params); - if (err) - return (err); + &(drc_config->str_drc_instruction_str[drc_instructions_selected]), + ia_drc_params_struct->sub_band_domain_mode, + pstr_overlap_params); + if (err) + return (err); } else { @@ -363,7 +363,7 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, if (gain_modifiers[g].shape_filter_flag == 1) { impd_shape_filt_block_init(&drc_coefficients_uni_drc->str_shape_filter_block_params[gain_modifiers[g].shape_filter_idx], - &shape_filter_block[g]); + &shape_filter_block[g]); } else { @@ -371,8 +371,8 @@ WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, } } } - + ia_drc_params_struct->drc_set_counter++; - + return (0); } diff --git a/decoder/drc_src/impd_drc_dec.h b/decoder/drc_src/impd_drc_dec.h index c44cf14..5e93e4b 100644 --- a/decoder/drc_src/impd_drc_dec.h +++ b/decoder/drc_src/impd_drc_dec.h @@ -1,54 +1,54 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_DEC_H #define IMPD_DRC_DEC_H WORD32 impd_init_drc_params(WORD32 frame_size, - WORD32 sample_rate, - WORD32 gain_delay_samples, - WORD32 delay_mode, - WORD32 sub_band_domain_mode, - ia_drc_params_struct* ia_drc_params_struct); + WORD32 sample_rate, + WORD32 gain_delay_samples, + WORD32 delay_mode, + WORD32 sub_band_domain_mode, + ia_drc_params_struct* ia_drc_params_struct); WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, - ia_drc_params_struct* ia_drc_params_struct, - ia_parametric_drc_params_struct* p_parametricdrc_params, - WORD32 audio_num_chan, - WORD32 drc_set_id_selected, - WORD32 downmix_id_selected, - ia_filter_banks_struct* ia_filter_banks_struct, - ia_overlap_params_struct* pstr_overlap_params - - , shape_filter_block* shape_filter_block - ); + ia_drc_params_struct* ia_drc_params_struct, + ia_parametric_drc_params_struct* p_parametricdrc_params, + WORD32 audio_num_chan, + WORD32 drc_set_id_selected, + WORD32 downmix_id_selected, + ia_filter_banks_struct* ia_filter_banks_struct, + ia_overlap_params_struct* pstr_overlap_params + + , shape_filter_block* shape_filter_block + ); WORD32 impd_apply_gains_and_add(ia_drc_instructions_struct* pstr_drc_instruction_arr, - const WORD32 drc_instructions_index, - ia_drc_params_struct* ia_drc_params_struct, - ia_gain_buffer_struct* pstr_gain_buf, - shape_filter_block shape_filter_block[], - FLOAT32* deinterleaved_audio[], - - FLOAT32* channel_audio[], - WORD32 impd_apply_gains); + const WORD32 drc_instructions_index, + ia_drc_params_struct* ia_drc_params_struct, + ia_gain_buffer_struct* pstr_gain_buf, + shape_filter_block shape_filter_block[], + FLOAT32* deinterleaved_audio[], + + FLOAT32* channel_audio[], + WORD32 impd_apply_gains); #endif diff --git a/decoder/drc_src/impd_drc_definitions.h b/decoder/drc_src/impd_drc_definitions.h index 9ca6a2f..f1dd0bc 100644 --- a/decoder/drc_src/impd_drc_definitions.h +++ b/decoder/drc_src/impd_drc_definitions.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_DEFINITIONS_H @@ -28,10 +28,10 @@ #define LIB_APIVERSION 1 -#define IA_DRC_PERSIST_IDX (0) -#define IA_DRC_SCRATCH_IDX (1) -#define IA_DRC_INPUT_IDX (2) -#define IA_DRC_OUTPUT_IDX (3) +#define IA_DRC_PERSIST_IDX (0) +#define IA_DRC_SCRATCH_IDX (1) +#define IA_DRC_INPUT_IDX (2) +#define IA_DRC_OUTPUT_IDX (3) #define FRAME_SIZE 512 diff --git a/decoder/drc_src/impd_drc_dynamic_payload.c b/decoder/drc_src/impd_drc_dynamic_payload.c index 99661e7..0ac55c0 100644 --- a/decoder/drc_src/impd_drc_dynamic_payload.c +++ b/decoder/drc_src/impd_drc_dynamic_payload.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -30,59 +30,59 @@ #include "impd_drc_rom.h" WORD32 impd_parse_loud_eq_instructions(ia_bit_buf_struct* it_bit_buff, - ia_loud_eq_instructions_struct* loud_eq_instructions); + ia_loud_eq_instructions_struct* loud_eq_instructions); WORD32 impd_parse_eq_coefficients(ia_bit_buf_struct* it_bit_buff, - ia_eq_coeff_struct* str_eq_coeff); + ia_eq_coeff_struct* str_eq_coeff); WORD32 impd_parse_eq_instructions(ia_bit_buf_struct* it_bit_buff, - ia_drc_config* drc_config, - ia_eq_instructions_struct* str_eq_instructions); + ia_drc_config* drc_config, + ia_eq_instructions_struct* str_eq_instructions); WORD32 impd_dec_initial_gain(ia_bit_buf_struct* it_bit_buff, - const WORD32 gain_coding_profile, - FLOAT32* initial_gain) + const WORD32 gain_coding_profile, + FLOAT32* initial_gain) { WORD32 sign, magn,bit_2_extract; switch (gain_coding_profile) { - case GAIN_CODING_PROFILE_REGULAR: - sign = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - magn = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - *initial_gain = magn * 0.125f; - if (sign) *initial_gain = - *initial_gain; - break; - case GAIN_CODING_PROFILE_FADING: + case GAIN_CODING_PROFILE_REGULAR: + sign = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + magn = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + *initial_gain = magn * 0.125f; + if (sign) *initial_gain = - *initial_gain; + break; + case GAIN_CODING_PROFILE_FADING: case GAIN_CODING_PROFILE_CLIPPING: - bit_2_extract= (gain_coding_profile==GAIN_CODING_PROFILE_FADING )?10:8; - sign = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (sign==0) *initial_gain = 0.0f; - else - { - magn = impd_read_bits_buf(it_bit_buff, bit_2_extract); - if(it_bit_buff->error) - return it_bit_buff->error; - *initial_gain = - (magn + 1) * 0.125f; - } - break; - - case GAIN_CODING_PROFILE_CONSTANT: - break; - default: - return(UNEXPECTED_ERROR); + bit_2_extract= (gain_coding_profile==GAIN_CODING_PROFILE_FADING )?10:8; + sign = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (sign==0) *initial_gain = 0.0f; + else + { + magn = impd_read_bits_buf(it_bit_buff, bit_2_extract); + if(it_bit_buff->error) + return it_bit_buff->error; + *initial_gain = - (magn + 1) * 0.125f; + } + break; + + case GAIN_CODING_PROFILE_CONSTANT: + break; + default: + return(UNEXPECTED_ERROR); } return (0); } WORD32 impd_dec_gains(ia_bit_buf_struct* it_bit_buff, - WORD32 no_nodes, - WORD32 gain_coding_profile, - ia_node_struct* str_node) + WORD32 no_nodes, + WORD32 gain_coding_profile, + ia_node_struct* str_node) { WORD32 err = 0, k, e, m; WORD32 bit; @@ -92,11 +92,11 @@ WORD32 impd_dec_gains(ia_bit_buf_struct* it_bit_buff, FLOAT32 drc_gain_delta = 0; const ia_delta_gain_code_table_struct *ptr_delta_gain_code_table; WORD32 no_delta_gain_entries; - + err = impd_dec_initial_gain(it_bit_buff, gain_coding_profile, &(str_node[0].loc_db_gain)); if (err) return(err); - - impd_get_delta_gain_code_tbl(gain_coding_profile, &ptr_delta_gain_code_table, &no_delta_gain_entries); + + impd_get_delta_gain_code_tbl(gain_coding_profile, &ptr_delta_gain_code_table, &no_delta_gain_entries); for (k=1; kerror) - return it_bit_buff->error; + bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; code = (code << 1) + bit; num_bits_read++; } @@ -134,9 +134,9 @@ WORD32 impd_dec_gains(ia_bit_buf_struct* it_bit_buff, } WORD32 impd_dec_slopes(ia_bit_buf_struct* it_bit_buff, - WORD32* no_nodes, - WORD32 gain_interpolation_type, - ia_node_struct* str_node) + WORD32* no_nodes, + WORD32 gain_interpolation_type, + ia_node_struct* str_node) { WORD32 k, e, m, bit; WORD32 code; @@ -147,22 +147,22 @@ WORD32 impd_dec_slopes(ia_bit_buf_struct* it_bit_buff, const ia_slope_code_table_struct* ptr_slope_code_table; WORD32 no_slope_code_entries; - ptr_slope_code_table = &(slope_code_tbl_entries_by_size[0]); + ptr_slope_code_table = &(slope_code_tbl_entries_by_size[0]); no_slope_code_entries = NUM_SLOPE_TBL_ENTRIES; - + k=0; while(end_marker != 1) { k++; - end_marker = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + end_marker = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; } *no_nodes = k; - - if (gain_interpolation_type == GAIN_INTERPOLATION_TYPE_SPLINE) - { + + if (gain_interpolation_type == GAIN_INTERPOLATION_TYPE_SPLINE) + { for (k=0; k<*no_nodes; k++) { num_bits_read = 0; @@ -173,9 +173,9 @@ WORD32 impd_dec_slopes(ia_bit_buf_struct* it_bit_buff, { for (m=0; merror) - return it_bit_buff->error; + bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; code = (code << 1) + bit; num_bits_read++; } @@ -193,24 +193,24 @@ WORD32 impd_dec_slopes(ia_bit_buf_struct* it_bit_buff, str_node[k].slope = slope_value; } } - else - { + else + { for (k=0; k<*no_nodes; k++) { - str_node[k].slope = 0.0f; + str_node[k].slope = 0.0f; } } return(0); } WORD32 impd_dec_times(ia_bit_buf_struct* it_bit_buff, - ia_tables_struct* str_tables, - WORD32 num_nodes, - WORD32 delta_tmin, - WORD32 drc_frame_size, - WORD32 full_frame, - WORD32 time_offset, - ia_node_struct* str_node) + ia_tables_struct* str_tables, + WORD32 num_nodes, + WORD32 delta_tmin, + WORD32 drc_frame_size, + WORD32 full_frame, + WORD32 time_offset, + ia_node_struct* str_node) { WORD32 k, e, m; WORD32 bit; @@ -226,15 +226,15 @@ WORD32 impd_dec_times(ia_bit_buf_struct* it_bit_buff, WORD32 exit_cnt; if (full_frame == 0) { - frame_end_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + frame_end_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; } else { frame_end_flag = 1; } - + if (frame_end_flag == 1) { node_res_flag = 0; @@ -253,9 +253,9 @@ WORD32 impd_dec_times(ia_bit_buf_struct* it_bit_buff, } for (m=0; merror) - return it_bit_buff->error; + bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; code = (code << 1) + bit; num_bits_read++; } @@ -308,9 +308,9 @@ WORD32 impd_dec_times(ia_bit_buf_struct* it_bit_buff, } for (m=0; merror) - return it_bit_buff->error; + bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; code = (code << 1) + bit; num_bits_read++; } @@ -333,18 +333,18 @@ WORD32 impd_dec_times(ia_bit_buf_struct* it_bit_buff, } WORD32 impd_drc_uni_gain_read(ia_bit_buf_struct* it_bit_buff, - ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, - ia_drc_config* drc_config, - ia_drc_gain_struct* pstr_uni_drc_gain) + ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, + ia_drc_config* drc_config, + ia_drc_gain_struct* pstr_uni_drc_gain) { WORD32 err = 0; - WORD32 seq; + WORD32 seq; static WORD32 pkt_loss_frame_cnt = 0; ia_spline_nodes_struct* str_spline_nodes = {0}; - + { WORD32 gain_sequence_count = drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_sequence_count; - + for (seq=0; seqstr_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[seq]; @@ -364,11 +364,11 @@ WORD32 impd_drc_uni_gain_read(ia_bit_buf_struct* it_bit_buff, } } } - + if (it_bit_buff->ptr_bit_buf_base == NULL) { pkt_loss_frame_cnt++; - + if (pkt_loss_frame_cnt*(FLOAT32)pstr_drc_uni_bs_dec->ia_drc_params_struct.drc_frame_size/drc_config->sampling_rate > MAXPACKETLOSSTIME) { drc_config->apply_drc = 0; @@ -376,9 +376,9 @@ WORD32 impd_drc_uni_gain_read(ia_bit_buf_struct* it_bit_buff, } else { - pstr_uni_drc_gain->uni_drc_gain_ext_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + pstr_uni_drc_gain->uni_drc_gain_ext_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (pstr_uni_drc_gain->uni_drc_gain_ext_flag == 1) { err = impd_parse_uni_drc_gain_ext(it_bit_buff, &(pstr_uni_drc_gain->uni_drc_gain_ext)); @@ -387,56 +387,56 @@ WORD32 impd_drc_uni_gain_read(ia_bit_buf_struct* it_bit_buff, pkt_loss_frame_cnt = 0; drc_config->apply_drc = 1; } - + return(0); } WORD32 impd_parse_uni_drc_gain_ext(ia_bit_buf_struct* it_bit_buff, - ia_uni_drc_gain_ext_struct* uni_drc_gain_ext) + ia_uni_drc_gain_ext_struct* uni_drc_gain_ext) { WORD32 i, k; WORD32 bit_size_len, ext_size_bits, bit_size, other_bit; - + k = 0; - uni_drc_gain_ext->uni_drc_gain_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - while(uni_drc_gain_ext->uni_drc_gain_ext_type[k] != UNIDRCGAINEXT_TERM) - { - bit_size_len = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; - ext_size_bits = bit_size_len + 4; - - bit_size = impd_read_bits_buf(it_bit_buff, ext_size_bits); - if(it_bit_buff->error) - return it_bit_buff->error; - uni_drc_gain_ext->ext_bit_size[k] = bit_size + 1; - - switch(uni_drc_gain_ext->uni_drc_gain_ext_type[k]) - { - default: - for(i = 0; iext_bit_size[k]; i++) - { - other_bit = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - } - break; - } - k++; - uni_drc_gain_ext->uni_drc_gain_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - } - - return (0); + uni_drc_gain_ext->uni_drc_gain_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + while(uni_drc_gain_ext->uni_drc_gain_ext_type[k] != UNIDRCGAINEXT_TERM) + { + bit_size_len = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + ext_size_bits = bit_size_len + 4; + + bit_size = impd_read_bits_buf(it_bit_buff, ext_size_bits); + if(it_bit_buff->error) + return it_bit_buff->error; + uni_drc_gain_ext->ext_bit_size[k] = bit_size + 1; + + switch(uni_drc_gain_ext->uni_drc_gain_ext_type[k]) + { + default: + for(i = 0; iext_bit_size[k]; i++) + { + other_bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + break; + } + k++; + uni_drc_gain_ext->uni_drc_gain_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + + return (0); } WORD32 impd_parse_spline_nodes(ia_bit_buf_struct* it_bit_buff, - ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, - ia_gain_set_params_struct* gain_set_params, - ia_spline_nodes_struct* str_spline_nodes) + ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, + ia_gain_set_params_struct* gain_set_params, + ia_spline_nodes_struct* str_spline_nodes) { WORD32 err = 0; WORD32 time_offset; @@ -447,22 +447,22 @@ WORD32 impd_parse_spline_nodes(ia_bit_buf_struct* it_bit_buff, { if (gain_set_params->time_delt_min_flag) { - time_offset = - gain_set_params->time_delt_min_val + (gain_set_params->time_delt_min_val-1)/2; + time_offset = - gain_set_params->time_delt_min_val + (gain_set_params->time_delt_min_val-1)/2; } else { - time_offset = - pstr_drc_uni_bs_dec->ia_drc_params_struct.delta_tmin_default + (pstr_drc_uni_bs_dec->ia_drc_params_struct.delta_tmin_default-1)/2; + time_offset = - pstr_drc_uni_bs_dec->ia_drc_params_struct.delta_tmin_default + (pstr_drc_uni_bs_dec->ia_drc_params_struct.delta_tmin_default-1)/2; } } - + if(it_bit_buff->ptr_bit_buf_base == NULL) { FLOAT32 prev_db_gain = str_spline_nodes->str_node[str_spline_nodes->num_nodes-1].loc_db_gain; str_spline_nodes->drc_gain_coding_mode = 0; str_spline_nodes->num_nodes = 1; - + if (prev_db_gain < 0) { str_spline_nodes->str_node[0].loc_db_gain = prev_db_gain; @@ -477,27 +477,27 @@ WORD32 impd_parse_spline_nodes(ia_bit_buf_struct* it_bit_buff, } else { - str_spline_nodes->drc_gain_coding_mode = impd_read_bits_buf(it_bit_buff, 1); + str_spline_nodes->drc_gain_coding_mode = impd_read_bits_buf(it_bit_buff, 1); if (it_bit_buff->error == PROC_COMPLETE) { str_spline_nodes->drc_gain_coding_mode = 0; str_spline_nodes->str_node[0].slope = 0.0; str_spline_nodes->str_node[0].time = (pstr_drc_uni_bs_dec->ia_drc_params_struct).drc_frame_size + time_offset; - str_spline_nodes->str_node[0].loc_db_gain = str_spline_nodes->str_node[str_spline_nodes->num_nodes-1].loc_db_gain; + str_spline_nodes->str_node[0].loc_db_gain = str_spline_nodes->str_node[str_spline_nodes->num_nodes-1].loc_db_gain; str_spline_nodes->num_nodes = 1; } else { - if (it_bit_buff->error) - return(it_bit_buff->error); + if (it_bit_buff->error) + return(it_bit_buff->error); } if (str_spline_nodes->drc_gain_coding_mode == 0) { str_spline_nodes->num_nodes = 1; - + err = impd_dec_initial_gain(it_bit_buff, gain_set_params->gain_coding_profile, &(str_spline_nodes->str_node[0].loc_db_gain)); if (err) return(err); - + str_spline_nodes->str_node[0].slope = 0.0; str_spline_nodes->str_node[0].time = (pstr_drc_uni_bs_dec->ia_drc_params_struct).drc_frame_size + time_offset; } @@ -510,9 +510,9 @@ WORD32 impd_parse_spline_nodes(ia_bit_buf_struct* it_bit_buff, err = impd_dec_times(it_bit_buff, &gain_set_params->str_tables, str_spline_nodes->num_nodes, gain_set_params->time_delt_min_val, (pstr_drc_uni_bs_dec->ia_drc_params_struct).drc_frame_size, gain_set_params->full_frame, time_offset, str_spline_nodes->str_node); if (err) return(err); err = impd_dec_gains(it_bit_buff, - str_spline_nodes->num_nodes, - gain_set_params->gain_coding_profile, - str_spline_nodes->str_node); + str_spline_nodes->num_nodes, + gain_set_params->gain_coding_profile, + str_spline_nodes->str_node); if (err) return(err); } else @@ -520,21 +520,21 @@ WORD32 impd_parse_spline_nodes(ia_bit_buf_struct* it_bit_buff, err = impd_dec_times(it_bit_buff, &pstr_drc_uni_bs_dec->tables_default, str_spline_nodes->num_nodes, (pstr_drc_uni_bs_dec->ia_drc_params_struct).delta_tmin_default, (pstr_drc_uni_bs_dec->ia_drc_params_struct).drc_frame_size, gain_set_params->full_frame, time_offset, str_spline_nodes->str_node); if (err) return(err); err = impd_dec_gains(it_bit_buff, - str_spline_nodes->num_nodes, - gain_set_params->gain_coding_profile, - str_spline_nodes->str_node); + str_spline_nodes->num_nodes, + gain_set_params->gain_coding_profile, + str_spline_nodes->str_node); if (err) return(err); } - + } } return(0); } WORD32 impd_parse_drc_gain_sequence(ia_bit_buf_struct* it_bit_buff, - ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, - ia_gain_set_params_struct* gain_set_params, - ia_drc_gain_sequence_struct* drc_gain_sequence) + ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, + ia_gain_set_params_struct* gain_set_params, + ia_drc_gain_sequence_struct* drc_gain_sequence) { WORD32 err = 0, i; WORD32 prev_frame_time_buf[NODE_COUNT_MAX], cur_frame_time_buf[NODE_COUNT_MAX]; @@ -542,13 +542,13 @@ WORD32 impd_parse_drc_gain_sequence(ia_bit_buf_struct* it_bit_buff, if (((pstr_drc_uni_bs_dec->ia_drc_params_struct).delay_mode == DELAY_MODE_LOW_DELAY) && (gain_set_params->full_frame == 0)) { - return (PARAM_ERROR); + return (PARAM_ERROR); } i=0; { err = impd_parse_spline_nodes( it_bit_buff, pstr_drc_uni_bs_dec, gain_set_params, &(drc_gain_sequence->str_spline_nodes[i])); if (err) return(err); - + num_nodes_node_reservoir = 0; num_nodes_cur = 0; for (k = 0; k < drc_gain_sequence->str_spline_nodes[i].num_nodes; k++){ @@ -556,7 +556,7 @@ WORD32 impd_parse_drc_gain_sequence(ia_bit_buf_struct* it_bit_buff, prev_frame_time_buf[num_nodes_node_reservoir] = drc_gain_sequence->str_spline_nodes[i].str_node[k].time; num_nodes_node_reservoir++; } - else{ + else{ cur_frame_time_buf[num_nodes_cur] = drc_gain_sequence->str_spline_nodes[i].str_node[k].time; num_nodes_cur++; } @@ -571,957 +571,957 @@ WORD32 impd_parse_drc_gain_sequence(ia_bit_buf_struct* it_bit_buff, return(0); } WORD32 impd_parse_drc_ext_v1(ia_bit_buf_struct* it_bit_buff, - ia_drc_params_bs_dec_struct* ia_drc_params_struct, - ia_drc_config* drc_config, - ia_drc_config_ext* str_drc_config_ext) + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_config* drc_config, + ia_drc_config_ext* str_drc_config_ext) { WORD32 dwnmix_instructions_v1_flag; WORD32 dwnmix_instructions_v1_count; WORD32 drc_coeffs_and_instructions_uni_drc_v1_flag; WORD32 drc_coefficients_uni_drc_v1_count; WORD32 drc_instructions_uni_drc_v1_count; - + WORD32 i = 0, err = 0; const WORD32 version = 1; - - dwnmix_instructions_v1_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (dwnmix_instructions_v1_flag == 1) - { - dwnmix_instructions_v1_count = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - for (i=0; ichannel_layout, &drc_config->dwnmix_instructions[i + drc_config->dwnmix_instructions_count]); - if (err) return(err); - } - drc_config->dwnmix_instructions_count += dwnmix_instructions_v1_count; - } - - drc_coeffs_and_instructions_uni_drc_v1_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (drc_coeffs_and_instructions_uni_drc_v1_flag == 1) - { - drc_coefficients_uni_drc_v1_count = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; - for (i=0; istr_p_loc_drc_coefficients_uni_drc[i + drc_config->drc_coefficients_drc_count]); - if (err) return(err); - } - drc_config->drc_coefficients_drc_count += drc_coefficients_uni_drc_v1_count; - - drc_instructions_uni_drc_v1_count = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - for (i=0; istr_drc_instruction_str[i + drc_config->drc_instructions_uni_drc_count]); - if (err) return(err); - } - drc_config->drc_instructions_uni_drc_count += drc_instructions_uni_drc_v1_count; - } - - str_drc_config_ext->loud_eq_instructions_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (str_drc_config_ext->loud_eq_instructions_flag == 1) - { - str_drc_config_ext->loud_eq_instructions_count = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - for (i=0; iloud_eq_instructions_count; i++) - { - err = impd_parse_loud_eq_instructions(it_bit_buff, &str_drc_config_ext->loud_eq_instructions[i]); - if (err) return(err); - } - } - else - { - str_drc_config_ext->loud_eq_instructions_count = 0; - } - - str_drc_config_ext->eq_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (str_drc_config_ext->eq_flag == 1) - { - err = impd_parse_eq_coefficients( it_bit_buff, &str_drc_config_ext->str_eq_coeff); - if (err) return(err); - str_drc_config_ext->eq_instructions_count = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - for (i=0; ieq_instructions_count; i++) - { - err = impd_parse_eq_instructions(it_bit_buff, drc_config, &str_drc_config_ext->str_eq_instructions[i]); - if (err) return(err); - } - } - return 0; + + dwnmix_instructions_v1_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (dwnmix_instructions_v1_flag == 1) + { + dwnmix_instructions_v1_count = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; ichannel_layout, &drc_config->dwnmix_instructions[i + drc_config->dwnmix_instructions_count]); + if (err) return(err); + } + drc_config->dwnmix_instructions_count += dwnmix_instructions_v1_count; + } + + drc_coeffs_and_instructions_uni_drc_v1_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (drc_coeffs_and_instructions_uni_drc_v1_flag == 1) + { + drc_coefficients_uni_drc_v1_count = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; istr_p_loc_drc_coefficients_uni_drc[i + drc_config->drc_coefficients_drc_count]); + if (err) return(err); + } + drc_config->drc_coefficients_drc_count += drc_coefficients_uni_drc_v1_count; + + drc_instructions_uni_drc_v1_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; istr_drc_instruction_str[i + drc_config->drc_instructions_uni_drc_count]); + if (err) return(err); + } + drc_config->drc_instructions_uni_drc_count += drc_instructions_uni_drc_v1_count; + } + + str_drc_config_ext->loud_eq_instructions_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_drc_config_ext->loud_eq_instructions_flag == 1) + { + str_drc_config_ext->loud_eq_instructions_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; iloud_eq_instructions_count; i++) + { + err = impd_parse_loud_eq_instructions(it_bit_buff, &str_drc_config_ext->loud_eq_instructions[i]); + if (err) return(err); + } + } + else + { + str_drc_config_ext->loud_eq_instructions_count = 0; + } + + str_drc_config_ext->eq_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_drc_config_ext->eq_flag == 1) + { + err = impd_parse_eq_coefficients( it_bit_buff, &str_drc_config_ext->str_eq_coeff); + if (err) return(err); + str_drc_config_ext->eq_instructions_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; ieq_instructions_count; i++) + { + err = impd_parse_eq_instructions(it_bit_buff, drc_config, &str_drc_config_ext->str_eq_instructions[i]); + if (err) return(err); + } + } + return 0; } WORD32 impd_parse_filt_block(ia_bit_buf_struct* it_bit_buff, - ia_filt_block_struct* str_filter_block, - WORD32 block_count) + ia_filt_block_struct* str_filter_block, + WORD32 block_count) { -// WORD32 err = 0; +// WORD32 err = 0; WORD32 k,j,temp; - ia_filt_ele_struct* str_filter_element; + ia_filt_ele_struct* str_filter_element; - for (j=0; jfilter_element_count = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - - str_filter_element=&str_filter_block->str_filter_element[0]; - for (k=0; kfilter_element_count; k++) - { - temp = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - - str_filter_element->filt_ele_idx= (temp&0x7E)>>1; - str_filter_element->filt_ele_gain_flag = temp&1;; - - if (str_filter_element->filt_ele_gain_flag) - { - WORD32 bs_filter_element_gain; - bs_filter_element_gain = impd_read_bits_buf(it_bit_buff, 10); - if(it_bit_buff->error) - return it_bit_buff->error; - str_filter_element->filt_ele_gain = bs_filter_element_gain * 0.125f - 96.0f; - } + for (j=0; jfilter_element_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_filter_element=&str_filter_block->str_filter_element[0]; + for (k=0; kfilter_element_count; k++) + { + temp = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_filter_element->filt_ele_idx= (temp&0x7E)>>1; + str_filter_element->filt_ele_gain_flag = temp&1;; + + if (str_filter_element->filt_ele_gain_flag) + { + WORD32 bs_filter_element_gain; + bs_filter_element_gain = impd_read_bits_buf(it_bit_buff, 10); + if(it_bit_buff->error) + return it_bit_buff->error; + str_filter_element->filt_ele_gain = bs_filter_element_gain * 0.125f - 96.0f; + } + + str_filter_element++; + } + str_filter_block++; + } + return(0); } WORD32 impd_parse_unique_td_filt_ele(ia_bit_buf_struct* it_bit_buff, - ia_unique_td_filt_element* unique_td_filt_ele, - WORD32 td_filter_element_count) + ia_unique_td_filt_element* unique_td_filt_ele, + WORD32 td_filter_element_count) { WORD32 m, sign, j, temp; FLOAT32 tmp; - - for (j=0; jeq_filter_format = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (unique_td_filt_ele->eq_filter_format == 0) - { - WORD32 bs_real_zero_radius, bs_generic_zero_radius, bs_generic_zero_angle; - WORD32 bs_real_pole_radius, bs_cmplx_pole_radius, bs_cmplx_pole_angle; - WORD32 bs_real_zero_radius_one_count; + for (j=0; jeq_filter_format = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; - temp = impd_read_bits_buf(it_bit_buff, 23); + if (unique_td_filt_ele->eq_filter_format == 0) + { + WORD32 bs_real_zero_radius, bs_generic_zero_radius, bs_generic_zero_angle; + WORD32 bs_real_pole_radius, bs_cmplx_pole_radius, bs_cmplx_pole_angle; + WORD32 bs_real_zero_radius_one_count; + + temp = impd_read_bits_buf(it_bit_buff, 23); if(it_bit_buff->error) - return it_bit_buff->error; - - bs_real_zero_radius_one_count=(temp>>20)&7; - - unique_td_filt_ele->bs_real_zero_radius_one_count = 2 * bs_real_zero_radius_one_count; - unique_td_filt_ele->real_zero_count = (temp&0xFC000)>>14; - - unique_td_filt_ele->generic_zero_count = (temp& 0x3F00)>>8; - - unique_td_filt_ele->real_pole_count = (temp&0xF0)>>4; - - unique_td_filt_ele->cmplx_pole_count = temp& 0xF; - - - temp= impd_read_bits_buf(it_bit_buff, unique_td_filt_ele->bs_real_zero_radius_one_count); - if(it_bit_buff->error) - return it_bit_buff->error; - - for (m=unique_td_filt_ele->bs_real_zero_radius_one_count-1; m>=0; m--) - { - unique_td_filt_ele->zero_sign[m] =(temp &1); - temp=temp>>1; - } - - - for (m=0; mreal_zero_count; m++) - { - temp= impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + return it_bit_buff->error; - bs_real_zero_radius = (temp&0xFE)>>1; + bs_real_zero_radius_one_count=(temp>>20)&7; - sign = temp&0x01; + unique_td_filt_ele->bs_real_zero_radius_one_count = 2 * bs_real_zero_radius_one_count; + unique_td_filt_ele->real_zero_count = (temp&0xFC000)>>14; - tmp = 1.0f - zero_pole_radius_tbl[bs_real_zero_radius]; - - sign=sign<<1; + unique_td_filt_ele->generic_zero_count = (temp& 0x3F00)>>8; - unique_td_filt_ele->real_zero_radius[m] = (1-sign)*tmp; - } - for (m=0; mgeneric_zero_count; m++) - { - temp=impd_read_bits_buf(it_bit_buff, 14); - if(it_bit_buff->error) - return it_bit_buff->error; + unique_td_filt_ele->real_pole_count = (temp&0xF0)>>4; - bs_generic_zero_radius = (temp&0x3F80)>>7; + unique_td_filt_ele->cmplx_pole_count = temp& 0xF; - unique_td_filt_ele->generic_zero_radius[m] = 1.0f - zero_pole_radius_tbl[bs_generic_zero_radius]; - - bs_generic_zero_angle = (temp&0x7F); - unique_td_filt_ele->generic_zero_angle[m] = zero_pole_angle_tbl[bs_generic_zero_angle]; - } - for (m=0; mreal_pole_count; m++) - { - temp=impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + temp= impd_read_bits_buf(it_bit_buff, unique_td_filt_ele->bs_real_zero_radius_one_count); + if(it_bit_buff->error) + return it_bit_buff->error; - bs_real_pole_radius = (temp&0xFE)>>1; + for (m=unique_td_filt_ele->bs_real_zero_radius_one_count-1; m>=0; m--) + { + unique_td_filt_ele->zero_sign[m] =(temp &1); + temp=temp>>1; + } - sign = temp&0x01; - tmp = 1.0f - zero_pole_radius_tbl[bs_real_pole_radius]; - - sign=sign<<1; + for (m=0; mreal_zero_count; m++) + { + temp= impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - unique_td_filt_ele->real_pole_radius[m] = (1-sign)*tmp; - } - for (m=0; mcmplx_pole_count; m++) - { - temp= impd_read_bits_buf(it_bit_buff, 14); + bs_real_zero_radius = (temp&0xFE)>>1; - if(it_bit_buff->error) - return it_bit_buff->error; + sign = temp&0x01; - bs_cmplx_pole_radius = (temp&0x3F80)>>7; + tmp = 1.0f - zero_pole_radius_tbl[bs_real_zero_radius]; - unique_td_filt_ele->complex_pole_radius[m] = 1.0f - zero_pole_radius_tbl[bs_cmplx_pole_radius]; - - bs_cmplx_pole_angle = (temp&0x7F); + sign=sign<<1; - unique_td_filt_ele->complex_pole_angle[m] = zero_pole_angle_tbl[bs_cmplx_pole_angle]; - } - } - else - { - temp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + unique_td_filt_ele->real_zero_radius[m] = (1-sign)*tmp; + } + for (m=0; mgeneric_zero_count; m++) + { + temp=impd_read_bits_buf(it_bit_buff, 14); + if(it_bit_buff->error) + return it_bit_buff->error; - unique_td_filt_ele->fir_filt_order = (temp&0xFE)>>1; + bs_generic_zero_radius = (temp&0x3F80)>>7; - unique_td_filt_ele->fir_symmetry = temp&0x01; + unique_td_filt_ele->generic_zero_radius[m] = 1.0f - zero_pole_radius_tbl[bs_generic_zero_radius]; - for (m=0; mfir_filt_order/2+1; m++) - { - WORD32 sign, bs_fir_coeff; - FLOAT32 tmp; + bs_generic_zero_angle = (temp&0x7F); - temp= impd_read_bits_buf(it_bit_buff, 11); - if(it_bit_buff->error) - return it_bit_buff->error; - sign = (temp>>10)&0x01; + unique_td_filt_ele->generic_zero_angle[m] = zero_pole_angle_tbl[bs_generic_zero_angle]; + } + for (m=0; mreal_pole_count; m++) + { + temp=impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - bs_fir_coeff = temp&0x03FF; + bs_real_pole_radius = (temp&0xFE)>>1; - tmp = (FLOAT32)pow(10.0f, -0.05f * bs_fir_coeff * 0.0625f); - - sign=sign<<1; + sign = temp&0x01; - unique_td_filt_ele->fir_coeff[m] = (1-sign)*tmp; - } - } - unique_td_filt_ele++; - } - return(0); + tmp = 1.0f - zero_pole_radius_tbl[bs_real_pole_radius]; + + sign=sign<<1; + + unique_td_filt_ele->real_pole_radius[m] = (1-sign)*tmp; + } + for (m=0; mcmplx_pole_count; m++) + { + temp= impd_read_bits_buf(it_bit_buff, 14); + + if(it_bit_buff->error) + return it_bit_buff->error; + + bs_cmplx_pole_radius = (temp&0x3F80)>>7; + + unique_td_filt_ele->complex_pole_radius[m] = 1.0f - zero_pole_radius_tbl[bs_cmplx_pole_radius]; + + bs_cmplx_pole_angle = (temp&0x7F); + + unique_td_filt_ele->complex_pole_angle[m] = zero_pole_angle_tbl[bs_cmplx_pole_angle]; + } + } + else + { + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + unique_td_filt_ele->fir_filt_order = (temp&0xFE)>>1; + + unique_td_filt_ele->fir_symmetry = temp&0x01; + + for (m=0; mfir_filt_order/2+1; m++) + { + WORD32 sign, bs_fir_coeff; + FLOAT32 tmp; + + temp= impd_read_bits_buf(it_bit_buff, 11); + if(it_bit_buff->error) + return it_bit_buff->error; + sign = (temp>>10)&0x01; + + bs_fir_coeff = temp&0x03FF; + + tmp = (FLOAT32)pow(10.0f, -0.05f * bs_fir_coeff * 0.0625f); + + sign=sign<<1; + + unique_td_filt_ele->fir_coeff[m] = (1-sign)*tmp; + } + } + unique_td_filt_ele++; + } + return(0); } WORD32 impd_decode_eq_slope_code(ia_bit_buf_struct* it_bit_buff, - FLOAT32* eq_slope, - WORD32 num_eq_nodes) + FLOAT32* eq_slope, + WORD32 num_eq_nodes) { WORD32 bits = 0; - WORD32 k; + WORD32 k; - for (k=0; kerror) - return it_bit_buff->error; - if (bits == 0x1) { - *eq_slope = 0.0f; - } - else { - bits = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - *eq_slope = eq_slope_tbl[bits]; - } - eq_slope++; - - } - return(0); + for (k=0; kerror) + return it_bit_buff->error; + if (bits == 0x1) { + *eq_slope = 0.0f; + } + else { + bits = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + *eq_slope = eq_slope_tbl[bits]; + } + eq_slope++; + + } + return(0); } WORD32 impd_decode_gain_initial_code(ia_bit_buf_struct* it_bit_buff, - FLOAT32* eq_gain_initial) + FLOAT32* eq_gain_initial) { WORD32 bits,bits1; - - bits1 = impd_read_bits_buf(it_bit_buff, 2); - if(it_bit_buff->error) - return it_bit_buff->error; - switch (bits1) { - case 0x0: - bits = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - *eq_gain_initial = 0.5f * bits - 8.0f; - break; - case 0x1: + bits1 = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; + + switch (bits1) { + case 0x0: + bits = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + *eq_gain_initial = 0.5f * bits - 8.0f; + break; + case 0x1: case 0x2: - - bits = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - if (bits<8) { - *eq_gain_initial = bits1*bits - bits1*16.0f; - } - else { - *eq_gain_initial = (FLOAT32)bits1*bits; - } - break; - - case 0x3: - bits = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; - *eq_gain_initial = 4.0f * bits - 64.0f; - break; - - default: - break; - } - return(0); + + bits = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + if (bits<8) { + *eq_gain_initial = bits1*bits - bits1*16.0f; + } + else { + *eq_gain_initial = (FLOAT32)bits1*bits; + } + break; + + case 0x3: + bits = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + *eq_gain_initial = 4.0f * bits - 64.0f; + break; + + default: + break; + } + return(0); } WORD32 impd_parse_eq_subband_gain_spline(ia_bit_buf_struct* it_bit_buff, - ia_eq_subband_gain_spline_struct* str_eq_subband_gain_spline, - WORD32 eq_subband_gains_count) + ia_eq_subband_gain_spline_struct* str_eq_subband_gain_spline, + WORD32 eq_subband_gains_count) { WORD32 err=0, eq_nodes_cnt, j,k, bits, *eq_freq_delta; - FLOAT32 *peq_gain_delta; - - for (j=0; jerror) - return it_bit_buff->error; - - str_eq_subband_gain_spline->num_eq_nodes = eq_nodes_cnt + 2; - - - err = impd_decode_eq_slope_code(it_bit_buff, &(str_eq_subband_gain_spline->eq_slope[0]),str_eq_subband_gain_spline->num_eq_nodes); - if (err) return (err); - - eq_freq_delta=&(str_eq_subband_gain_spline->eq_freq_delta[1]); - for (k=1; knum_eq_nodes; k++) - { - - bits = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - *eq_freq_delta = bits+1; - eq_freq_delta++; - - } - - err = impd_decode_gain_initial_code( it_bit_buff, &(str_eq_subband_gain_spline->eq_gain_initial)); - if (err) - return (err); - - peq_gain_delta=&(str_eq_subband_gain_spline->eq_gain_delta[1]); - for (k=1; knum_eq_nodes; k++) - { - - bits = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - - *peq_gain_delta = eq_gain_delta_tbl[bits]; - peq_gain_delta++; - - } - str_eq_subband_gain_spline++; - } - return (0); + FLOAT32 *peq_gain_delta; + + for (j=0; jerror) + return it_bit_buff->error; + + str_eq_subband_gain_spline->num_eq_nodes = eq_nodes_cnt + 2; + + + err = impd_decode_eq_slope_code(it_bit_buff, &(str_eq_subband_gain_spline->eq_slope[0]),str_eq_subband_gain_spline->num_eq_nodes); + if (err) return (err); + + eq_freq_delta=&(str_eq_subband_gain_spline->eq_freq_delta[1]); + for (k=1; knum_eq_nodes; k++) + { + + bits = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + *eq_freq_delta = bits+1; + eq_freq_delta++; + + } + + err = impd_decode_gain_initial_code( it_bit_buff, &(str_eq_subband_gain_spline->eq_gain_initial)); + if (err) + return (err); + + peq_gain_delta=&(str_eq_subband_gain_spline->eq_gain_delta[1]); + for (k=1; knum_eq_nodes; k++) + { + + bits = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + *peq_gain_delta = eq_gain_delta_tbl[bits]; + peq_gain_delta++; + + } + str_eq_subband_gain_spline++; + } + return (0); } WORD32 impd_parse_eq_subband_gain_vector(ia_bit_buf_struct* it_bit_buff, - const WORD32 eq_subband_gain_count, - ia_eq_subband_gain_vector* str_eq_subband_gain_vector, - WORD32 eq_subband_gains_count) + const WORD32 eq_subband_gain_count, + ia_eq_subband_gain_vector* str_eq_subband_gain_vector, + WORD32 eq_subband_gains_count) { WORD32 m,k,temp; - - for (k=0; kerror) - return it_bit_buff->error; - - sign= (temp>>8)&1; - bs_eq_subband_gain = temp & 0x7F; - - sign=sign<<1; - str_eq_subband_gain_vector->eq_subband_gain[m] = ((1-sign)*bs_eq_subband_gain) * 0.125f; - } - str_eq_subband_gain_vector++; - } + + for (k=0; kerror) + return it_bit_buff->error; + + sign= (temp>>8)&1; + bs_eq_subband_gain = temp & 0x7F; + + sign=sign<<1; + str_eq_subband_gain_vector->eq_subband_gain[m] = ((1-sign)*bs_eq_subband_gain) * 0.125f; + } + str_eq_subband_gain_vector++; + } return (0); } WORD32 impd_parse_eq_coefficients(ia_bit_buf_struct* it_bit_buff, - ia_eq_coeff_struct* str_eq_coeff) + ia_eq_coeff_struct* str_eq_coeff) { WORD32 err = 0; WORD32 eq_gain_cnt, mu, nu,temp; - WORD32 subband_gain_len_tbl[7]={0,32,39,64,71,128,135}; - - str_eq_coeff->eq_delay_max_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (str_eq_coeff->eq_delay_max_present) - { - mu = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - nu = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; - str_eq_coeff->eq_delay_max = 16 * mu * (1<unique_filter_block_count = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - - - err = impd_parse_filt_block (it_bit_buff, &(str_eq_coeff->str_filter_block[0]),str_eq_coeff->unique_filter_block_count); - if (err) - return(err); - - str_eq_coeff->unique_td_filter_element_count = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - - - err = impd_parse_unique_td_filt_ele ( it_bit_buff, &(str_eq_coeff->unique_td_filt_ele[0]),str_eq_coeff->unique_td_filter_element_count); - if (err) - return(err); - - str_eq_coeff->unique_eq_subband_gains_count = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (str_eq_coeff->unique_eq_subband_gains_count>0) - { - temp=impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - str_eq_coeff->eq_subband_gain_representation = (temp>>4)&0x01; - - str_eq_coeff->eq_subband_gain_format = temp&0x0F; - - if (str_eq_coeff->eq_subband_gain_format==GAINFORMAT_UNIFORM) - { - eq_gain_cnt = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - str_eq_coeff->eq_subband_gain_count = eq_gain_cnt + 1; - - } - else - str_eq_coeff->eq_subband_gain_count=subband_gain_len_tbl[str_eq_coeff->eq_subband_gain_format]; - - - - if (str_eq_coeff->eq_subband_gain_representation == 1) - { - - err = impd_parse_eq_subband_gain_spline( it_bit_buff, &(str_eq_coeff->str_eq_subband_gain_spline[0]),str_eq_coeff->unique_eq_subband_gains_count); - if (err) - return(err); - } - else - { - - err = impd_parse_eq_subband_gain_vector( it_bit_buff, str_eq_coeff->eq_subband_gain_count, &(str_eq_coeff->str_eq_subband_gain_vector[0]),str_eq_coeff->unique_eq_subband_gains_count); - if (err) - return(err); - - } - } - - return(0); + WORD32 subband_gain_len_tbl[7]={0,32,39,64,71,128,135}; + + str_eq_coeff->eq_delay_max_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_eq_coeff->eq_delay_max_present) + { + mu = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + nu = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + str_eq_coeff->eq_delay_max = 16 * mu * (1<unique_filter_block_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + + err = impd_parse_filt_block (it_bit_buff, &(str_eq_coeff->str_filter_block[0]),str_eq_coeff->unique_filter_block_count); + if (err) + return(err); + + str_eq_coeff->unique_td_filter_element_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + + err = impd_parse_unique_td_filt_ele ( it_bit_buff, &(str_eq_coeff->unique_td_filt_ele[0]),str_eq_coeff->unique_td_filter_element_count); + if (err) + return(err); + + str_eq_coeff->unique_eq_subband_gains_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_eq_coeff->unique_eq_subband_gains_count>0) + { + temp=impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + str_eq_coeff->eq_subband_gain_representation = (temp>>4)&0x01; + + str_eq_coeff->eq_subband_gain_format = temp&0x0F; + + if (str_eq_coeff->eq_subband_gain_format==GAINFORMAT_UNIFORM) + { + eq_gain_cnt = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + str_eq_coeff->eq_subband_gain_count = eq_gain_cnt + 1; + + } + else + str_eq_coeff->eq_subband_gain_count=subband_gain_len_tbl[str_eq_coeff->eq_subband_gain_format]; + + + + if (str_eq_coeff->eq_subband_gain_representation == 1) + { + + err = impd_parse_eq_subband_gain_spline( it_bit_buff, &(str_eq_coeff->str_eq_subband_gain_spline[0]),str_eq_coeff->unique_eq_subband_gains_count); + if (err) + return(err); + } + else + { + + err = impd_parse_eq_subband_gain_vector( it_bit_buff, str_eq_coeff->eq_subband_gain_count, &(str_eq_coeff->str_eq_subband_gain_vector[0]),str_eq_coeff->unique_eq_subband_gains_count); + if (err) + return(err); + + } + } + + return(0); } - + WORD32 impd_parser_td_filter_cascade (ia_bit_buf_struct* it_bit_buff, - ia_eq_instructions_struct* str_eq_instructions, - ia_td_filter_cascade_struct* str_td_filter_cascade) + ia_eq_instructions_struct* str_eq_instructions, + ia_td_filter_cascade_struct* str_td_filter_cascade) { - //WORD32 err=0, - WORD32 i, ii, k; + //WORD32 err=0, + WORD32 i, ii, k; WORD32 eq_cascade_gain; - ia_filter_block_refs_struct* str_filter_block_refs=&(str_td_filter_cascade->str_filter_block_refs[0]); - - for (i=0; ieq_ch_group_count; i++) - { - str_td_filter_cascade->eq_cascade_gain_present[i] = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + ia_filter_block_refs_struct* str_filter_block_refs=&(str_td_filter_cascade->str_filter_block_refs[0]); + + for (i=0; ieq_ch_group_count; i++) + { + str_td_filter_cascade->eq_cascade_gain_present[i] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (str_td_filter_cascade->eq_cascade_gain_present[i]) { - eq_cascade_gain = impd_read_bits_buf(it_bit_buff, 10); - if(it_bit_buff->error) - return it_bit_buff->error; + eq_cascade_gain = impd_read_bits_buf(it_bit_buff, 10); + if(it_bit_buff->error) + return it_bit_buff->error; str_td_filter_cascade->eq_cascade_gain[i] = 0.125f * eq_cascade_gain - 96.0f; } else { str_td_filter_cascade->eq_cascade_gain[i] = 0.0f; } - - - str_filter_block_refs->filter_block_count = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - for (ii=0; iifilter_block_count; ii++) - { - str_filter_block_refs->filter_block_index[ii] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - } - str_filter_block_refs++; + + + str_filter_block_refs->filter_block_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (ii=0; iifilter_block_count; ii++) + { + str_filter_block_refs->filter_block_index[ii] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + str_filter_block_refs++; } - - str_td_filter_cascade->eq_phase_alignment_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (str_td_filter_cascade->eq_phase_alignment_present) - { - - for (i=0; ieq_ch_group_count; i++) - { - for (k=i+1; keq_ch_group_count; k++) - { - str_td_filter_cascade->eq_phase_alignment[i][k] = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - } - } - - } - else - { - for (i=0; ieq_ch_group_count; i++) - { - for (k=i+1; keq_ch_group_count; k++) - str_td_filter_cascade->eq_phase_alignment[i][k] = 1; - - } - } - - - return(0); + + str_td_filter_cascade->eq_phase_alignment_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_td_filter_cascade->eq_phase_alignment_present) + { + + for (i=0; ieq_ch_group_count; i++) + { + for (k=i+1; keq_ch_group_count; k++) + { + str_td_filter_cascade->eq_phase_alignment[i][k] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + } + } + + } + else + { + for (i=0; ieq_ch_group_count; i++) + { + for (k=i+1; keq_ch_group_count; k++) + str_td_filter_cascade->eq_phase_alignment[i][k] = 1; + + } + } + + + return(0); } WORD32 impd_parse_eq_instructions(ia_bit_buf_struct* it_bit_buff, - ia_drc_config* drc_config, - ia_eq_instructions_struct* str_eq_instructions) + ia_drc_config* drc_config, + ia_eq_instructions_struct* str_eq_instructions) { WORD32 i, k, channel_count, temp; WORD32 dmix_id_present, additional_dmix_id_present, additional_dmix_id_cnt=0; WORD32 additional_drc_set_id_present, additional_drc_set_id_cnt; - - temp=impd_read_bits_buf(it_bit_buff, 11); - if(it_bit_buff->error) - return it_bit_buff->error; - str_eq_instructions->eq_set_id = (temp>>5)&0x3F; + temp=impd_read_bits_buf(it_bit_buff, 11); + if(it_bit_buff->error) + return it_bit_buff->error; - str_eq_instructions->eq_set_complexity_level = (temp>>1)&0x0F; + str_eq_instructions->eq_set_id = (temp>>5)&0x3F; - dmix_id_present = temp&0x01; + str_eq_instructions->eq_set_complexity_level = (temp>>1)&0x0F; - if (dmix_id_present) - { - temp=impd_read_bits_buf(it_bit_buff, 9); - if(it_bit_buff->error) - return it_bit_buff->error; + dmix_id_present = temp&0x01; - str_eq_instructions->downmix_id[0] = (temp>>2)&0x7F; + if (dmix_id_present) + { + temp=impd_read_bits_buf(it_bit_buff, 9); + if(it_bit_buff->error) + return it_bit_buff->error; - str_eq_instructions->eq_apply_to_downmix = (temp>>1)&0x01; + str_eq_instructions->downmix_id[0] = (temp>>2)&0x7F; - additional_dmix_id_present = temp&0x01; + str_eq_instructions->eq_apply_to_downmix = (temp>>1)&0x01; - if (additional_dmix_id_present) - { - additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + additional_dmix_id_present = temp&0x01; - for (i=1; idownmix_id[i] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - } - } - } - else - { - str_eq_instructions->downmix_id[0] = 0; - } + if (additional_dmix_id_present) + { + additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; - str_eq_instructions->dwnmix_id_count = 1 + additional_dmix_id_cnt; - - temp=impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + for (i=1; idownmix_id[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + } + else + { + str_eq_instructions->downmix_id[0] = 0; + } - str_eq_instructions->drc_set_id[0] = (temp>>1)&0x3F; + str_eq_instructions->dwnmix_id_count = 1 + additional_dmix_id_cnt; - additional_drc_set_id_present = temp&0x01; + temp=impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; - if (additional_drc_set_id_present) - { - additional_drc_set_id_cnt = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + str_eq_instructions->drc_set_id[0] = (temp>>1)&0x3F; - for (i=1; idrc_set_id[i] = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - } - } - else - { - additional_drc_set_id_cnt = 0; - } - str_eq_instructions->drc_set_id_count = 1 + additional_drc_set_id_cnt; + additional_drc_set_id_present = temp&0x01; - temp=impd_read_bits_buf(it_bit_buff, 17); - if(it_bit_buff->error) - return it_bit_buff->error; + if (additional_drc_set_id_present) + { + additional_drc_set_id_cnt = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; - str_eq_instructions->eq_set_purpose =(temp>>1)&0xFFFF; + for (i=1; idrc_set_id[i] = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + else + { + additional_drc_set_id_cnt = 0; + } + str_eq_instructions->drc_set_id_count = 1 + additional_drc_set_id_cnt; - str_eq_instructions->depends_on_eq_set_present = temp&0x01; + temp=impd_read_bits_buf(it_bit_buff, 17); + if(it_bit_buff->error) + return it_bit_buff->error; - if (str_eq_instructions->depends_on_eq_set_present) - { - str_eq_instructions->depends_on_eq_set = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - } - else - { - str_eq_instructions->no_independent_eq_use = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - } - - str_eq_instructions->eq_channel_count = channel_count = drc_config->channel_layout.base_channel_count; + str_eq_instructions->eq_set_purpose =(temp>>1)&0xFFFF; - if ((dmix_id_present == 1) && (str_eq_instructions->eq_apply_to_downmix == 1) && - (str_eq_instructions->downmix_id[0] != 0) && (str_eq_instructions->downmix_id[0] != ID_FOR_ANY_DOWNMIX) && (str_eq_instructions->dwnmix_id_count==1)) - { - for(i=0; idwnmix_instructions_count; i++) - { - if (str_eq_instructions->downmix_id[0] == drc_config->dwnmix_instructions[i].downmix_id) - break; - } - if (i == drc_config->dwnmix_instructions_count) - { - return UNEXPECTED_ERROR; - } + str_eq_instructions->depends_on_eq_set_present = temp&0x01; - str_eq_instructions->eq_channel_count = channel_count = drc_config->dwnmix_instructions[i].target_channel_count; - } - else if ((str_eq_instructions->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (str_eq_instructions->dwnmix_id_count > 1)) - { - channel_count = 1; - } - - str_eq_instructions->eq_ch_group_count = 0; + if (str_eq_instructions->depends_on_eq_set_present) + { + str_eq_instructions->depends_on_eq_set = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + str_eq_instructions->no_independent_eq_use = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } - for (i=0; ieq_ch_group_of_channel[i] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + str_eq_instructions->eq_channel_count = channel_count = drc_config->channel_layout.base_channel_count; - for (k=0; keq_ch_group_of_channel[i] == str_eq_instructions->eq_ch_group_of_channel[k]) - { - new_group = 0; - break; - } - } + if ((dmix_id_present == 1) && (str_eq_instructions->eq_apply_to_downmix == 1) && + (str_eq_instructions->downmix_id[0] != 0) && (str_eq_instructions->downmix_id[0] != ID_FOR_ANY_DOWNMIX) && (str_eq_instructions->dwnmix_id_count==1)) + { + for(i=0; idwnmix_instructions_count; i++) + { + if (str_eq_instructions->downmix_id[0] == drc_config->dwnmix_instructions[i].downmix_id) + break; + } + if (i == drc_config->dwnmix_instructions_count) + { + return UNEXPECTED_ERROR; + } - if (new_group == 1) - { - str_eq_instructions->eq_ch_group_count += 1; - } - } + str_eq_instructions->eq_channel_count = channel_count = drc_config->dwnmix_instructions[i].target_channel_count; + } + else if ((str_eq_instructions->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (str_eq_instructions->dwnmix_id_count > 1)) + { + channel_count = 1; + } - str_eq_instructions->td_filter_cascade_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + str_eq_instructions->eq_ch_group_count = 0; - if (str_eq_instructions->td_filter_cascade_present) - { - impd_parser_td_filter_cascade (it_bit_buff, str_eq_instructions, &(str_eq_instructions->str_td_filter_cascade)); - } + for (i=0; ieq_ch_group_of_channel[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; - str_eq_instructions->subband_gains_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + for (k=0; keq_ch_group_of_channel[i] == str_eq_instructions->eq_ch_group_of_channel[k]) + { + new_group = 0; + break; + } + } - if (str_eq_instructions->subband_gains_present) - { - for (i=0; ieq_ch_group_count; i++) - { - str_eq_instructions->subband_gains_index[i] = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - } - } + if (new_group == 1) + { + str_eq_instructions->eq_ch_group_count += 1; + } + } - str_eq_instructions->eq_transition_duration_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + str_eq_instructions->td_filter_cascade_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; - if (str_eq_instructions->eq_transition_duration_present) - { - WORD32 bs_eq_transition_duration; - bs_eq_transition_duration = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; + if (str_eq_instructions->td_filter_cascade_present) + { + impd_parser_td_filter_cascade (it_bit_buff, str_eq_instructions, &(str_eq_instructions->str_td_filter_cascade)); + } - str_eq_instructions->eq_transition_duration = (WORD32)(0.001f * (FLOAT32)pow(2.0f, 2.0f + bs_eq_transition_duration * 0.0625f)); - } - return(0); + str_eq_instructions->subband_gains_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_eq_instructions->subband_gains_present) + { + for (i=0; ieq_ch_group_count; i++) + { + str_eq_instructions->subband_gains_index[i] = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + + str_eq_instructions->eq_transition_duration_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_eq_instructions->eq_transition_duration_present) + { + WORD32 bs_eq_transition_duration; + bs_eq_transition_duration = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_eq_instructions->eq_transition_duration = (WORD32)(0.001f * (FLOAT32)pow(2.0f, 2.0f + bs_eq_transition_duration * 0.0625f)); + } + return(0); } WORD32 impd_parse_loud_eq_instructions(ia_bit_buf_struct* it_bit_buff, - ia_loud_eq_instructions_struct* loud_eq_instructions) + ia_loud_eq_instructions_struct* loud_eq_instructions) { WORD32 i, bs_loud_eq_scaling, bs_loud_eq_offset, temp; WORD32 dmix_id_present, additional_dmix_id_present, additional_dmix_id_cnt = 0; WORD32 drc_set_id_present, additional_drc_set_id_present, additional_drc_set_id_cnt = 0; WORD32 eq_set_id_present, additional_eq_set_id_present, additional_eq_set_id_cnt = 0; - - temp=impd_read_bits_buf(it_bit_buff, 9); - if(it_bit_buff->error) - return it_bit_buff->error; - loud_eq_instructions->loud_eq_set_id = (temp>>5)&0x0F; - loud_eq_instructions->drc_location = (temp>>1)&0x0F; + temp=impd_read_bits_buf(it_bit_buff, 9); + if(it_bit_buff->error) + return it_bit_buff->error; + loud_eq_instructions->loud_eq_set_id = (temp>>5)&0x0F; - dmix_id_present = temp&0x01; + loud_eq_instructions->drc_location = (temp>>1)&0x0F; - if (dmix_id_present) - { - temp=impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + dmix_id_present = temp&0x01; - loud_eq_instructions->downmix_id[0] = (temp>>1)&0x7F; + if (dmix_id_present) + { + temp=impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - additional_dmix_id_present = temp&0x01; + loud_eq_instructions->downmix_id[0] = (temp>>1)&0x7F; - if (additional_dmix_id_present) - { - additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + additional_dmix_id_present = temp&0x01; - for (i=1; idownmix_id[i] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - } - } - } - else - { - loud_eq_instructions->downmix_id[0] = 0; - } + if (additional_dmix_id_present) + { + additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; - loud_eq_instructions->dwnmix_id_count = 1 + additional_dmix_id_cnt; - - drc_set_id_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + for (i=1; idownmix_id[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + } + else + { + loud_eq_instructions->downmix_id[0] = 0; + } - if (drc_set_id_present) - { - temp=impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + loud_eq_instructions->dwnmix_id_count = 1 + additional_dmix_id_cnt; - loud_eq_instructions->drc_set_id[0] = (temp>>1)&0x3F; + drc_set_id_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; - additional_drc_set_id_present = temp&0x01; + if (drc_set_id_present) + { + temp=impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; - if (additional_drc_set_id_present) - { - additional_drc_set_id_cnt = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + loud_eq_instructions->drc_set_id[0] = (temp>>1)&0x3F; - for (i=1; idrc_set_id[i] = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - } - } - } - else - { - loud_eq_instructions->drc_set_id[0] = 0; - } + additional_drc_set_id_present = temp&0x01; - loud_eq_instructions->drc_set_id_count = 1 + additional_drc_set_id_cnt; - - eq_set_id_present = impd_read_bits_buf(it_bit_buff, 1); + if (additional_drc_set_id_present) + { + additional_drc_set_id_cnt = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; - if(it_bit_buff->error) - return it_bit_buff->error; + for (i=1; idrc_set_id[i] = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + } + else + { + loud_eq_instructions->drc_set_id[0] = 0; + } - if (eq_set_id_present) - { - temp=impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + loud_eq_instructions->drc_set_id_count = 1 + additional_drc_set_id_cnt; - loud_eq_instructions->eq_set_id[0] = (temp>>1)&0x3F; + eq_set_id_present = impd_read_bits_buf(it_bit_buff, 1); - additional_eq_set_id_present = temp&0x01; + if(it_bit_buff->error) + return it_bit_buff->error; - if (additional_eq_set_id_present) - { - additional_eq_set_id_cnt = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + if (eq_set_id_present) + { + temp=impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; - for (i=0; ieq_set_id[i+1] = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - } - } - } - else - { - loud_eq_instructions->eq_set_id[0] = 0; - } - loud_eq_instructions->eq_set_id_count = 1 + additional_eq_set_id_cnt; - - temp=impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + loud_eq_instructions->eq_set_id[0] = (temp>>1)&0x3F; - loud_eq_instructions->loudness_after_drc = (temp>>7)&0x01; + additional_eq_set_id_present = temp&0x01; - loud_eq_instructions->loudness_after_eq = (temp>>6)&0x01; + if (additional_eq_set_id_present) + { + additional_eq_set_id_cnt = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; - loud_eq_instructions->loud_eq_gain_sequence_count = temp&0x3F; + for (i=0; ieq_set_id[i+1] = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + } + else + { + loud_eq_instructions->eq_set_id[0] = 0; + } + loud_eq_instructions->eq_set_id_count = 1 + additional_eq_set_id_cnt; - for (i=0; iloud_eq_gain_sequence_count; i++) - { - temp=impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + temp=impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - loud_eq_instructions->gain_seq_idx[i] = (temp>>1)&0x3F; + loud_eq_instructions->loudness_after_drc = (temp>>7)&0x01; - loud_eq_instructions->drc_characteristic_format_is_cicp[i] = temp&0x01; + loud_eq_instructions->loudness_after_eq = (temp>>6)&0x01; - if (loud_eq_instructions->drc_characteristic_format_is_cicp[i]) - { - loud_eq_instructions->drc_characteristic[i] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - } - else - { - temp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + loud_eq_instructions->loud_eq_gain_sequence_count = temp&0x3F; - loud_eq_instructions->drc_characteristic_left_index[i] = (temp>>4)&0x0F; + for (i=0; iloud_eq_gain_sequence_count; i++) + { + temp=impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; - loud_eq_instructions->drc_characteristic_right_index[i] = temp&0x0F; + loud_eq_instructions->gain_seq_idx[i] = (temp>>1)&0x3F; - } + loud_eq_instructions->drc_characteristic_format_is_cicp[i] = temp&0x01; - temp=impd_read_bits_buf(it_bit_buff, 9); - if(it_bit_buff->error) - return it_bit_buff->error; + if (loud_eq_instructions->drc_characteristic_format_is_cicp[i]) + { + loud_eq_instructions->drc_characteristic[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - loud_eq_instructions->frequency_range_index[i] = (temp>>3)&0x3F; + loud_eq_instructions->drc_characteristic_left_index[i] = (temp>>4)&0x0F; - bs_loud_eq_scaling = temp&0x07; + loud_eq_instructions->drc_characteristic_right_index[i] = temp&0x0F; - loud_eq_instructions->loud_eq_scaling[i] = (FLOAT32)pow (2.0f, -0.5f * bs_loud_eq_scaling); + } - bs_loud_eq_offset = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; + temp=impd_read_bits_buf(it_bit_buff, 9); + if(it_bit_buff->error) + return it_bit_buff->error; - loud_eq_instructions->loud_eq_offset[i] = 1.5f * bs_loud_eq_offset - 16.0f; - - } - return(0); + loud_eq_instructions->frequency_range_index[i] = (temp>>3)&0x3F; + + bs_loud_eq_scaling = temp&0x07; + + loud_eq_instructions->loud_eq_scaling[i] = (FLOAT32)pow (2.0f, -0.5f * bs_loud_eq_scaling); + + bs_loud_eq_offset = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + loud_eq_instructions->loud_eq_offset[i] = 1.5f * bs_loud_eq_offset - 16.0f; + + } + return(0); } diff --git a/decoder/drc_src/impd_drc_eq.c b/decoder/drc_src/impd_drc_eq.c index b46d94c..7519526 100644 --- a/decoder/drc_src/impd_drc_eq.c +++ b/decoder/drc_src/impd_drc_eq.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -48,14 +48,14 @@ #endif WORD32 impd_derive_subband_center_freq(WORD32 eq_subband_gain_count, - WORD32 eq_subband_gain_format, - FLOAT32 sample_rate, - FLOAT32* subband_center_freq) + WORD32 eq_subband_gain_format, + FLOAT32 sample_rate, + FLOAT32* subband_center_freq) { WORD32 i; FLOAT32 width, offset; - switch (eq_subband_gain_format) - { + switch (eq_subband_gain_format) + { case GAINFORMAT_QMF32: case GAINFORMAT_QMF64: case GAINFORMAT_QMF128: @@ -65,7 +65,7 @@ WORD32 impd_derive_subband_center_freq(WORD32 eq_subband_gain_count, for (i=0; ieq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) { for (i=0; ibs_real_zero_radius_one_count; i++) { - part_response = 1.0f + 1.0f - 2.0f * 1.0f * (FLOAT32)cos(frequency_radian - (FLOAT32) element->zero_sign[i]); + part_response = 1.0f + 1.0f - 2.0f * 1.0f * (FLOAT32)cos(frequency_radian - (FLOAT32) element->zero_sign[i]); total_response *= part_response; } for (i=0; ireal_zero_count; i++) @@ -162,20 +162,20 @@ VOID impd_calc_filt_ele_response(ia_unique_td_filt_element* element, radius = element->real_zero_radius[i]; angle_radian = 0.0f; } - part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - angle_radian); + part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - angle_radian); total_response *= part_response; - part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - angle_radian); + part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - angle_radian); total_response *= part_response; } - + total_response = sqrt(total_response); - + for (i=0; igeneric_zero_count; i++) { radius = element->generic_zero_radius[i]; - part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - element->generic_zero_angle[i]); + part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - element->generic_zero_angle[i]); total_response *= part_response; - part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - element->generic_zero_angle[i]); + part_response = 1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - element->generic_zero_angle[i]); total_response *= part_response; } for (i=0; ireal_pole_count; i++) @@ -190,12 +190,12 @@ VOID impd_calc_filt_ele_response(ia_unique_td_filt_element* element, radius = element->real_pole_radius[i]; angle_radian = 0.0f; } - part_response = 1/(1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - angle_radian)); + part_response = 1/(1.0f + radius * radius - 2.0f * radius * (FLOAT32)cos(frequency_radian - angle_radian)); total_response *= part_response; } for (i=0; icmplx_pole_count; i++) { - part_response = 1/(1.0f + element->real_pole_radius[i] * element->real_pole_radius[i] - 2.0f * element->real_pole_radius[i] * (FLOAT32)cos(frequency_radian - element->complex_pole_angle[i])); + part_response = 1/(1.0f + element->real_pole_radius[i] * element->real_pole_radius[i] - 2.0f * element->real_pole_radius[i] * (FLOAT32)cos(frequency_radian - element->complex_pole_angle[i])); total_response *= part_response * part_response; } } @@ -254,11 +254,11 @@ WORD32 impd_calc_subband_gains_td_cascade(ia_unique_td_filt_element* unique_td_f FLOAT64 total_response; WORD32 eq_subband_gain_count = subband_filt->coeff_count; - + err = impd_derive_subband_center_freq(eq_subband_gain_count, eq_subband_gain_format, sample_rate, subband_center_freq); - if (err) - return(err); - + if (err) + return(err); + for (g=0; gmember_count; m++) { @@ -296,11 +296,11 @@ VOID impd_add_cascade(ia_cascade_align_group_struct* pstr_cascade_align_grp, { if (pstr_cascade_align_grp->member_idx[n] == c2) { - *done = 1; + *done = 1; } } if (*done == 0) - { + { pstr_cascade_align_grp->member_idx[pstr_cascade_align_grp->member_count] = c2; pstr_cascade_align_grp->member_count++; *done = 1; @@ -317,9 +317,9 @@ VOID impd_calc_cascade_align_groups(WORD32 eq_ch_group_count, ia_cascade_align_group_struct* pstr_cascade_align_grp) { WORD32 i, k, g, group_count, done; - + group_count = 0; - + if (eq_phase_alignment_present == 0) { if (eq_ch_group_count > 1) @@ -344,14 +344,14 @@ VOID impd_calc_cascade_align_groups(WORD32 eq_ch_group_count, for (g=0; gsection_count; ia_filt_sect_struct* filt_section = &ph_alignment_filt->filt_section[section]; - switch (config) - { + switch (config) + { case CONFIG_REAL_POLE: ph_alignment_filt->gain *= (-radius); filt_section->a1 = - radius; @@ -416,8 +416,8 @@ VOID impd_calc_phase_filt_delay(ia_unique_td_filt_element* element, ia_ph_alignment_filt_struct* ph_alignment_filt) { WORD32 i, delay=0, channel; - if (element->eq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) - { + if (element->eq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) + { if (element->bs_real_zero_radius_one_count == 0) { delay = element->real_zero_count + 2 * element->generic_zero_count - element->real_pole_count - 2 * element->cmplx_pole_count; @@ -442,10 +442,10 @@ VOID impd_calc_phase_filt(ia_unique_td_filt_element* element, ia_matching_ph_filt_struct* matching_ph_filt) { WORD32 i; - + memset(matching_ph_filt, 0, sizeof(ia_matching_ph_filt_struct)); matching_ph_filt->gain = 1.0f; - + if (element->eq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) { for (i=0; ireal_pole_count; i++) @@ -464,10 +464,10 @@ VOID impd_calc_phase_filt(ia_unique_td_filt_element* element, } } impd_calc_phase_filt_delay(element, matching_ph_filt); - + matching_ph_filt->num_matches_filter = 1; matching_ph_filt->matches_filter[0] = filt_ele_idx; - + return; } @@ -476,43 +476,43 @@ WORD32 impd_calc_filt_params(ia_unique_td_filt_element* element, { FLOAT32 zReal; FLOAT32* coeff; - //WORD32 offset_idx = 0; - WORD32 i; - WORD32 param_idx = 0; + //WORD32 offset_idx = 0; + WORD32 i; + WORD32 param_idx = 0; - ia_2nd_order_filt_params_struct *pstr_2nd_oder_filt_params = &interm_filt_params->ord_2_filt_params_of_zeros[0]; + ia_2nd_order_filt_params_struct *pstr_2nd_oder_filt_params = &interm_filt_params->ord_2_filt_params_of_zeros[0]; - for (i=0; ibs_real_zero_radius_one_count; i+=2) - { - FLOAT32 radius = (FLOAT32)element->zero_sign[i + 0]; - FLOAT32 angle = (FLOAT32)element->zero_sign[i + 1]; - FLOAT32 angle1 = radius; - FLOAT32 angle2 = angle; - pstr_2nd_oder_filt_params->radius = 1.0f; - coeff = pstr_2nd_oder_filt_params->coeff; + for (i=0; ibs_real_zero_radius_one_count; i+=2) + { + FLOAT32 radius = (FLOAT32)element->zero_sign[i + 0]; + FLOAT32 angle = (FLOAT32)element->zero_sign[i + 1]; + FLOAT32 angle1 = radius; + FLOAT32 angle2 = angle; + pstr_2nd_oder_filt_params->radius = 1.0f; + coeff = pstr_2nd_oder_filt_params->coeff; - if (angle1 != angle2) - { - coeff[0] = 0.0f; - coeff[1] = -1.0f; - } - else if (angle1 == 1.0f) - { - coeff[0] = -2.0f; - coeff[1] = 1.0f; - } - else - { - coeff[0] = 2.0f; - coeff[1] = 1.0f; - } - pstr_2nd_oder_filt_params += 1; - param_idx += 1; - } + if (angle1 != angle2) + { + coeff[0] = 0.0f; + coeff[1] = -1.0f; + } + else if (angle1 == 1.0f) + { + coeff[0] = -2.0f; + coeff[1] = 1.0f; + } + else + { + coeff[0] = 2.0f; + coeff[1] = 1.0f; + } + pstr_2nd_oder_filt_params += 1; + param_idx += 1; + } for (i=0; ireal_zero_count; i++) { - FLOAT32 radius = element->real_zero_radius[i]; - //FLOAT32 angle = 0.0f; + FLOAT32 radius = element->real_zero_radius[i]; + //FLOAT32 angle = 0.0f; pstr_2nd_oder_filt_params->radius = radius; if (fabs(radius) == 1.0f) @@ -526,20 +526,20 @@ WORD32 impd_calc_filt_params(ia_unique_td_filt_element* element, coeff[1] = 1.0f; } pstr_2nd_oder_filt_params += 1; - param_idx += 1; + param_idx += 1; } for (i=0; igeneric_zero_count; i++) { - FLOAT32 radius = element->generic_zero_radius[i]; - FLOAT32 angle = element->generic_zero_angle[i]; + FLOAT32 radius = element->generic_zero_radius[i]; + FLOAT32 angle = element->generic_zero_angle[i]; zReal = radius * (FLOAT32)cos(M_PI * angle); pstr_2nd_oder_filt_params->radius = radius; coeff = pstr_2nd_oder_filt_params->coeff; coeff[0] = -2.0f * zReal; coeff[1] = radius * radius; - pstr_2nd_oder_filt_params += 1; + pstr_2nd_oder_filt_params += 1; zReal = (FLOAT32)cos(M_PI * angle) / radius; pstr_2nd_oder_filt_params->radius = radius; @@ -547,31 +547,31 @@ WORD32 impd_calc_filt_params(ia_unique_td_filt_element* element, coeff[0] = -2.0f * zReal; coeff[1] = 1.0f / (radius * radius); - pstr_2nd_oder_filt_params += 1; + pstr_2nd_oder_filt_params += 1; - param_idx += 2; + param_idx += 2; } interm_filt_params->filter_param_count_of_zeros = param_idx; - param_idx = 0; - + param_idx = 0; + pstr_2nd_oder_filt_params = &interm_filt_params->ord_2_filt_params_of_poles[0]; for (i=0; ireal_pole_count; i++) { - FLOAT32 radius = element->real_pole_radius[i]; + FLOAT32 radius = element->real_pole_radius[i]; pstr_2nd_oder_filt_params->radius = radius; coeff = pstr_2nd_oder_filt_params->coeff; coeff[0] = -2.0f * radius; coeff[1] = radius * radius; param_idx += 1; - pstr_2nd_oder_filt_params += 1; + pstr_2nd_oder_filt_params += 1; } for (i=0; icmplx_pole_count; i++) { - FLOAT32 radius = element->complex_pole_radius[i]; - FLOAT32 angle = element->complex_pole_angle[i]; + FLOAT32 radius = element->complex_pole_radius[i]; + FLOAT32 angle = element->complex_pole_angle[i]; zReal = radius * (FLOAT32)cos(M_PI * angle); pstr_2nd_oder_filt_params->radius = radius; @@ -579,17 +579,17 @@ WORD32 impd_calc_filt_params(ia_unique_td_filt_element* element, coeff[0] = -2.0f * zReal; coeff[1] = radius * radius; - pstr_2nd_oder_filt_params += 1; + pstr_2nd_oder_filt_params += 1; pstr_2nd_oder_filt_params->radius = radius; pstr_2nd_oder_filt_params->coeff[0] = coeff[0]; pstr_2nd_oder_filt_params->coeff[1] = coeff[1]; - pstr_2nd_oder_filt_params += 1; - param_idx += 2; + pstr_2nd_oder_filt_params += 1; + param_idx += 2; } - interm_filt_params->filter_param_count_of_poles = param_idx; - return 0; + interm_filt_params->filter_param_count_of_poles = param_idx; + return 0; } VOID impd_convert_fir_filt_params(WORD32 fir_filt_order, @@ -599,31 +599,31 @@ VOID impd_convert_fir_filt_params(WORD32 fir_filt_order, { WORD32 i, channel; FLOAT32* coeff = fir_filter->coeff; - + fir_filter->coeff_count = fir_filt_order + 1; for (i=0; ifilter_format = element->eq_filter_format; if (element->eq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) { - err = impd_calc_filt_params(element, - interm_filt_params); - if(err) - return err; + err = impd_calc_filt_params(element, + interm_filt_params); + if(err) + return err; } else { interm_filt_params->filter_param_count_of_zeros = 0; interm_filt_params->filter_param_count_of_poles = 0; - + impd_convert_fir_filt_params (element->fir_filt_order, element->fir_symmetry, element->fir_coeff, @@ -669,7 +669,7 @@ VOID impd_calc_eq_filt_elements(ia_interm_filt_params_struct* interm_filt_params FLOAT32 max_radius, diff_radius; WORD32 coeff_count; FLOAT32* coeff; - + for (i=0; iord_2_filt_params_of_zeros[i].coeff[1] != 0.0f) { - if (diff_radius > fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius)) - { + if (diff_radius > fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius)) + { diff_radius = (FLOAT32)fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius); zeros_idx = i; } @@ -729,8 +729,8 @@ VOID impd_calc_eq_filt_elements(ia_interm_filt_params_struct* interm_filt_params { if (interm_filt_params->ord_2_filt_params_of_zeros[i].coeff[1] == 0.0f) { - if (diff_radius > (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius))) - { + if (diff_radius > (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius))) + { diff_radius = (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius)); zeros_idx = i; } @@ -739,7 +739,7 @@ VOID impd_calc_eq_filt_elements(ia_interm_filt_params_struct* interm_filt_params } } } - if (zeros_idx == -1) + if (zeros_idx == -1) { for (i=0; ifilter_param_count_of_zeros; i++) { @@ -750,8 +750,8 @@ VOID impd_calc_eq_filt_elements(ia_interm_filt_params_struct* interm_filt_params if (pole_order == 2) { if (interm_filt_params->ord_2_filt_params_of_zeros[i].coeff[1] == 0.0f) { - if (diff_radius > (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius))) - { + if (diff_radius > (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius))) + { diff_radius = (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius)); zeros_idx = i; } @@ -761,8 +761,8 @@ VOID impd_calc_eq_filt_elements(ia_interm_filt_params_struct* interm_filt_params { if (interm_filt_params->ord_2_filt_params_of_zeros[i].coeff[1] != 0.0f) { - if (diff_radius > (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius))) - { + if (diff_radius > (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius))) + { diff_radius = (FLOAT32)(fabs(fabs(interm_filt_params->ord_2_filt_params_of_zeros[i].radius) - max_radius)); zeros_idx = i; } @@ -783,8 +783,8 @@ VOID impd_calc_eq_filt_elements(ia_interm_filt_params_struct* interm_filt_params { eq_filt_element->pstr_pole_zero_filt.filt_section[section].b1 = 0.0f; eq_filt_element->pstr_pole_zero_filt.filt_section[section].b2 = 0.0f; - eq_filt_element->pstr_pole_zero_filt.audio_delay.delay++; - } + eq_filt_element->pstr_pole_zero_filt.audio_delay.delay++; + } for (channel=0; channelpstr_pole_zero_filt.filt_section[section].filt_sect_state[channel].in_state_1 = 0.0f; @@ -797,7 +797,7 @@ VOID impd_calc_eq_filt_elements(ia_interm_filt_params_struct* interm_filt_params section++; } } while (poles_idx >= 0); - + eq_filt_element->pstr_pole_zero_filt.section_count = section; coeff_count = 1; @@ -846,7 +846,7 @@ VOID impd_calc_eq_filt_elements(ia_interm_filt_params_struct* interm_filt_params eq_filt_element->pstr_pole_zero_filt.filt_coeffs_flag = 0; eq_filt_element->pstr_pole_zero_filt.fir_filter.coeff_count = 0; } - + return; } @@ -870,16 +870,16 @@ WORD32 impd_calc_filt_block(ia_unique_td_filt_element* unique_td_filt_ele, ia_eq_filt_ele_struct* eq_filt_element = &pstr_eq_filt_block->eq_filt_element[i]; ia_filt_ele_struct* str_filter_element = &str_filter_block->str_filter_element[i]; WORD32 filterIndex = str_filter_element->filt_ele_idx; - + if (unique_td_filt_ele[filterIndex].eq_filter_format == FILTER_ELEMENT_FORMAT_POLE_ZERO) { err = impd_calc_filt_params_all(&(unique_td_filt_ele[filterIndex]), &interm_filt_params); - if (err) - return (err); + if (err) + return (err); impd_calc_eq_filt_elements(&interm_filt_params, eq_filt_element); - + eq_filt_element->format = FILTER_ELEMENT_FORMAT_POLE_ZERO; } else @@ -906,14 +906,14 @@ WORD32 impd_calc_filt_block(ia_unique_td_filt_element* unique_td_filt_ele, eq_filt_element->elementGainLinear = - eq_filt_element->elementGainLinear; } } - impd_calc_phase_filt(&(unique_td_filt_ele[filterIndex]), - i, + impd_calc_phase_filt(&(unique_td_filt_ele[filterIndex]), + i, &matching_ph_filt[i]); } pstr_eq_filt_block->element_count = str_filter_block->filter_element_count; - - pstr_eq_filt_block->matching_ph_filt_ele_0 = matching_ph_filt[0]; - + + pstr_eq_filt_block->matching_ph_filt_ele_0 = matching_ph_filt[0]; + return(0); } @@ -940,7 +940,7 @@ WORD32 impd_calc_filt_cascade(ia_unique_td_filt_element* unique_td_filt_ele, ia_filt_cascade_td_struct filt_cascade_td[]) { WORD32 i, err, g; - + for (g=0; gstr_filter_block_refs[g].filter_block_count; i++) @@ -948,8 +948,8 @@ WORD32 impd_calc_filt_cascade(ia_unique_td_filt_element* unique_td_filt_ele, err = impd_calc_filt_block(unique_td_filt_ele, &(str_filter_block[str_td_filter_cascade->str_filter_block_refs[g].filter_block_index[i]]), &(filt_cascade_td[g].pstr_eq_filt_block[i])); - if (err) - return(err); + if (err) + return(err); } filt_cascade_td[g].block_count = i; filt_cascade_td[g].cascade_gain_linear = (FLOAT32)(pow(10.0f, 0.05f * str_td_filter_cascade->eq_cascade_gain[g])); @@ -966,7 +966,7 @@ VOID impd_calc_subband_eq(ia_eq_subband_gain_vector* str_eq_subband_gain_vector, ia_subband_filt_struct* subband_filt) { WORD32 i; - + for (i=0; isubband_coeff[i] = str_eq_subband_gain_vector->eq_subband_gain[i]; @@ -977,8 +977,8 @@ VOID impd_calc_subband_eq(ia_eq_subband_gain_vector* str_eq_subband_gain_vector, FLOAT32 impd_decode_eq_node_freq(WORD32 eq_node_freq_idx) { - /*((FLOAT32)((log10(STEP_RATIO_F_HI) / log10(STEP_RATIO_F_LO) - 1.0f) / (STEP_RATIO_EQ_NODE_COUNT_MAX - 1.0f)))*/ - FLOAT32 step_ratio = 0.0739601809794f; + /*((FLOAT32)((log10(STEP_RATIO_F_HI) / log10(STEP_RATIO_F_LO) - 1.0f) / (STEP_RATIO_EQ_NODE_COUNT_MAX - 1.0f)))*/ + FLOAT32 step_ratio = 0.0739601809794f; return((FLOAT32)(pow(STEP_RATIO_F_LO, 1.0f + eq_node_freq_idx * step_ratio))); } @@ -987,7 +987,7 @@ FLOAT32 impd_calc_warp_freq_delta(FLOAT32 fsubband, WORD32 eq_node_freq_idx) { /*((FLOAT32)((log10(STEP_RATIO_F_HI) / log10(STEP_RATIO_F_LO) - 1.0f) / (STEP_RATIO_EQ_NODE_COUNT_MAX - 1.0f)))*/ - FLOAT32 step_ratio = 0.0739601809794f; + FLOAT32 step_ratio = 0.0739601809794f; return((FLOAT32)((log10(fsubband)/log10(node_freq) - 1.0f) / step_ratio - (FLOAT32) eq_node_freq_idx)); } @@ -1000,10 +1000,10 @@ VOID impd_interpolate_eq_gain(WORD32 band_step, FLOAT32* interpolated_gain) { FLOAT32 k1, k2, a, b, c, d; - FLOAT32 inv_band_step =(FLOAT32)( 1.0 / (FLOAT32)band_step); + FLOAT32 inv_band_step =(FLOAT32)( 1.0 / (FLOAT32)band_step); FLOAT32 inv_band_step_sqr = inv_band_step * inv_band_step; k1 = (right_gain - left_gain) * inv_band_step_sqr; - left_slope = (FLOAT32) (left_slope / 3.128f); - right_slope = (FLOAT32) (right_slope / 3.128f); + left_slope = (FLOAT32) (left_slope / 3.128f); + right_slope = (FLOAT32) (right_slope / 3.128f); k2 = right_slope + left_slope; a = inv_band_step * (inv_band_step * k2 - 2.0f * k1); b = 3.0f * k1 - inv_band_step * (k2 + left_slope); @@ -1026,7 +1026,7 @@ WORD32 impd_interpolate_subband_spline(ia_eq_subband_gain_spline_struct* str_eq_ FLOAT32 eq_node_freq[32]; FLOAT32 subband_center_freq[256]; WORD32 num_eq_nodes = str_eq_subband_gain_spline->num_eq_nodes; - + FLOAT32* eq_slope = str_eq_subband_gain_spline->eq_slope; WORD32* eq_freq_delta = str_eq_subband_gain_spline->eq_freq_delta; FLOAT32 eq_gain_initial = str_eq_subband_gain_spline->eq_gain_initial; @@ -1050,20 +1050,20 @@ WORD32 impd_interpolate_subband_spline(ia_eq_subband_gain_spline_struct* str_eq_ eq_node_freq_idx[num_eq_nodes] = max_eq_node_idx; eq_node_freq [num_eq_nodes] = impd_decode_eq_node_freq(eq_node_freq_idx[num_eq_nodes]); num_eq_nodes += 1; } - + err = impd_derive_subband_center_freq(eq_subband_gain_count, eq_subband_gain_format, sample_rate, subband_center_freq); - if (err) - return (err); - - for (n=0; n= eq_node_freq[n]) && (fSub <= eq_node_freq[n+1])) - { + if ((fSub >= eq_node_freq[n]) && (fSub <= eq_node_freq[n+1])) + { FLOAT32 warpedDeltaFreq = impd_calc_warp_freq_delta (fSub, eq_node_freq[0], eq_node_freq_idx[n]); FLOAT32 gEqSubbandDb; impd_interpolate_eq_gain(eq_freq_delta[n+1], eq_gain[n], eq_gain[n+1], @@ -1088,7 +1088,7 @@ WORD32 impd_calc_subband_gains(ia_eq_coeff_struct* str_eq_coeff, WORD32 eq_subband_gain_representation = str_eq_coeff->eq_subband_gain_representation; WORD32 eq_subband_gain_count = str_eq_coeff->eq_subband_gain_count; WORD32 eq_subband_gain_format = str_eq_coeff->eq_subband_gain_format; - + for (g=0; gaudio_num_chan; c++) { @@ -1210,9 +1210,9 @@ WORD32 impd_derive_eq_set(ia_eq_coeff_struct* str_eq_coeff, ia_eq_set_struct* eq_set) { WORD32 err, i, eq_frame_size_subband; - + eq_set->domain = EQ_FILTER_DOMAIN_NONE; - + if (sub_band_domain_mode == SUBBAND_DOMAIN_MODE_OFF) { if (str_eq_instructions->td_filter_cascade_present== 1) @@ -1222,16 +1222,16 @@ WORD32 impd_derive_eq_set(ia_eq_coeff_struct* str_eq_coeff, &str_eq_instructions->str_td_filter_cascade, str_eq_instructions->eq_ch_group_count, eq_set->filt_cascade_td); - if (err) - return (err); + if (err) + return (err); } eq_set->domain |= EQ_FILTER_DOMAIN_TIME; } if (sub_band_domain_mode != SUBBAND_DOMAIN_MODE_OFF) { - switch (sub_band_domain_mode) - { + switch (sub_band_domain_mode) + { case SUBBAND_DOMAIN_MODE_QMF64: if (str_eq_coeff->eq_subband_gain_count != AUDIO_CODEC_SUBBAND_COUNT_QMF64) { @@ -1262,11 +1262,11 @@ WORD32 impd_derive_eq_set(ia_eq_coeff_struct* str_eq_coeff, err = impd_calc_subband_gains(str_eq_coeff, str_eq_instructions->eq_ch_group_count, str_eq_instructions->subband_gains_index, - sample_rate, + sample_rate, eq_frame_size_subband, eq_set->subband_filt); - if (err) - return (err); + if (err) + return (err); } else { @@ -1280,8 +1280,8 @@ WORD32 impd_derive_eq_set(ia_eq_coeff_struct* str_eq_coeff, sample_rate, eq_frame_size_subband, eq_set->subband_filt); - if (err) - return (err); + if (err) + return (err); } } @@ -1289,7 +1289,7 @@ WORD32 impd_derive_eq_set(ia_eq_coeff_struct* str_eq_coeff, } eq_set->audio_num_chan = str_eq_instructions->eq_channel_count; eq_set->eq_ch_group_count = str_eq_instructions->eq_ch_group_count; - + for (i=0; ieq_channel_count; i++) { eq_set->eq_ch_group_of_channel[i] = str_eq_instructions->eq_ch_group_of_channel[i]; @@ -1301,24 +1301,24 @@ WORD32 impd_derive_eq_set(ia_eq_coeff_struct* str_eq_coeff, VOID impd_process_filt_sect(ia_filt_sect_struct filt_section[EQ_FILTER_SECTION_COUNT_MAX], WORD32 channel, FLOAT32* audio_out, - WORD32 section_count) + WORD32 section_count) { - WORD32 i; + WORD32 i; - for(i = 0; i < section_count; i++) - { - ia_filt_sect_state_struct* filt_sect_state = &filt_section[i].filt_sect_state[channel]; - FLOAT32 audio_in = *audio_out; - *audio_out = audio_in + filt_section[i].b1 * filt_sect_state->in_state_1 - + filt_section[i].b2 * filt_sect_state->in_state_2 - - filt_section[i].a1 * filt_sect_state->out_state_1 - - filt_section[i].a2 * filt_sect_state->out_state_2; + for(i = 0; i < section_count; i++) + { + ia_filt_sect_state_struct* filt_sect_state = &filt_section[i].filt_sect_state[channel]; + FLOAT32 audio_in = *audio_out; + *audio_out = audio_in + filt_section[i].b1 * filt_sect_state->in_state_1 + + filt_section[i].b2 * filt_sect_state->in_state_2 + - filt_section[i].a1 * filt_sect_state->out_state_1 + - filt_section[i].a2 * filt_sect_state->out_state_2; - filt_sect_state->in_state_2 = filt_sect_state->in_state_1; - filt_sect_state->in_state_1 = audio_in; - filt_sect_state->out_state_2 = filt_sect_state->out_state_1; - filt_sect_state->out_state_1 = *audio_out; - } + filt_sect_state->in_state_2 = filt_sect_state->in_state_1; + filt_sect_state->in_state_1 = audio_in; + filt_sect_state->out_state_2 = filt_sect_state->out_state_1; + filt_sect_state->out_state_1 = *audio_out; + } return; } @@ -1386,7 +1386,7 @@ VOID impd_pole_zero_filt_process(ia_pole_zero_filt_struct* pstr_pole_zero_filt, inp = out; } impd_audio_delay_process(&pstr_pole_zero_filt->audio_delay, channel, inp, &out); - + *ptr_audio_out = out; return ; } @@ -1400,19 +1400,19 @@ VOID impd_subband_filter_process(ia_subband_filt_struct* pstr_subband_filt, WORD32 i,j; WORD32 eq_frame_size_subband = pstr_subband_filt->eq_frame_size_subband; WORD32 coeff_count = pstr_subband_filt->coeff_count; - + FLOAT32* ptr_subband_coeff = pstr_subband_filt->subband_coeff; - for (i=0; i < eq_frame_size_subband; i++) - { - for (j=0; j < coeff_count; j++) - { - ptr_audio_real_buff[j] *= ptr_subband_coeff[j]; - ptr_audio_imag_buff[j] *= ptr_subband_coeff[j]; - } - ptr_audio_real_buff += coeff_count; - ptr_audio_imag_buff += coeff_count; - } + for (i=0; i < eq_frame_size_subband; i++) + { + for (j=0; j < coeff_count; j++) + { + ptr_audio_real_buff[j] *= ptr_subband_coeff[j]; + ptr_audio_imag_buff[j] *= ptr_subband_coeff[j]; + } + ptr_audio_real_buff += coeff_count; + ptr_audio_imag_buff += coeff_count; + } return; } @@ -1422,12 +1422,12 @@ VOID impd_phase_align_filt_process(ia_ph_alignment_filt_struct* ph_alignment_fil WORD32 channel, FLOAT32* ptr_audio_out) { - FLOAT32 audio_in = *ptr_audio_out; + FLOAT32 audio_in = *ptr_audio_out; FLOAT32 inp = audio_in; FLOAT32 out = inp; - impd_process_filt_sect(ph_alignment_filt->filt_section, channel, &out, ph_alignment_filt->section_count); - inp = out; + impd_process_filt_sect(ph_alignment_filt->filt_section, channel, &out, ph_alignment_filt->section_count); + inp = out; impd_audio_delay_process(&ph_alignment_filt->audio_delay, channel, inp, &out); @@ -1440,44 +1440,44 @@ VOID impd_eq_filt_element_process(ia_eq_filt_block_struct str_eq_filt_block[EQ_F WORD32 channel, FLOAT32 audio_in, FLOAT32* ptr_audio_out, - WORD32 block_count) + WORD32 block_count) { WORD32 i; FLOAT32 inp = audio_in; FLOAT32 out = inp; - WORD32 k,j; - WORD32 element_count; - for(j = 0; j < block_count; j++) - { - FLOAT32 sum = 0.0f; - element_count = str_eq_filt_block[j].element_count; - for (k=0; k < element_count; k++) - { - switch (str_eq_filt_block[j].eq_filt_element[k].format) - { - case FILTER_ELEMENT_FORMAT_POLE_ZERO: - impd_pole_zero_filt_process(&str_eq_filt_block[j].eq_filt_element[k].pstr_pole_zero_filt, channel, inp, &out); - break; - case FILTER_ELEMENT_FORMAT_FIR: - impd_fir_filt_process(&str_eq_filt_block[j].eq_filt_element[k].fir_filter, channel, inp, &out); - break; - default: - break; - } - out *= str_eq_filt_block[j].eq_filt_element[k].elementGainLinear; + WORD32 k,j; + WORD32 element_count; + for(j = 0; j < block_count; j++) + { + FLOAT32 sum = 0.0f; + element_count = str_eq_filt_block[j].element_count; + for (k=0; k < element_count; k++) + { + switch (str_eq_filt_block[j].eq_filt_element[k].format) + { + case FILTER_ELEMENT_FORMAT_POLE_ZERO: + impd_pole_zero_filt_process(&str_eq_filt_block[j].eq_filt_element[k].pstr_pole_zero_filt, channel, inp, &out); + break; + case FILTER_ELEMENT_FORMAT_FIR: + impd_fir_filt_process(&str_eq_filt_block[j].eq_filt_element[k].fir_filter, channel, inp, &out); + break; + default: + break; + } + out *= str_eq_filt_block[j].eq_filt_element[k].elementGainLinear; - for (i=0; i < str_eq_filt_block[j].eq_filt_element[k].num_ph_align_filt; i++) - { - inp = out; - impd_phase_align_filt_process(&str_eq_filt_block[j].eq_filt_element[k].ph_alignment_filt[i], - channel, - &out); - } - sum += out; - } - inp = sum; - } - *ptr_audio_out = inp; + for (i=0; i < str_eq_filt_block[j].eq_filt_element[k].num_ph_align_filt; i++) + { + inp = out; + impd_phase_align_filt_process(&str_eq_filt_block[j].eq_filt_element[k].ph_alignment_filt[i], + channel, + &out); + } + sum += out; + } + inp = sum; + } + *ptr_audio_out = inp; return; } @@ -1487,39 +1487,39 @@ WORD32 impd_process_eq_set_time_domain(ia_eq_set_struct* pstr_eq_set, FLOAT32 *ptr_audio_in, FLOAT32 *ptr_audio_out, WORD32 frame_size) -{ - WORD32 g=pstr_eq_set->eq_ch_group_of_channel[channel],i,j; +{ + WORD32 g=pstr_eq_set->eq_ch_group_of_channel[channel],i,j; //FLOAT32 sum = 0.0f; - //FLOAT32 temp1 = 0.0f; - + //FLOAT32 temp1 = 0.0f; + if(pstr_eq_set==NULL || g<0) return 0; - + if (pstr_eq_set->domain | EQ_FILTER_DOMAIN_TIME) - { + { for(i=0;ifilt_cascade_td[g].pstr_eq_filt_block), - channel, - ptr_audio_in[i], - &ptr_audio_out[i], - pstr_eq_set->filt_cascade_td[g].block_count); + { + impd_eq_filt_element_process((pstr_eq_set->filt_cascade_td[g].pstr_eq_filt_block), + channel, + ptr_audio_in[i], + &ptr_audio_out[i], + pstr_eq_set->filt_cascade_td[g].block_count); - for (j=0; jfilt_cascade_td[g].num_ph_align_filt; j++) - { - impd_phase_align_filt_process(&pstr_eq_set->filt_cascade_td[g].ph_alignment_filt[j], - channel, - &ptr_audio_out[i]); - } + for (j=0; jfilt_cascade_td[g].num_ph_align_filt; j++) + { + impd_phase_align_filt_process(&pstr_eq_set->filt_cascade_td[g].ph_alignment_filt[j], + channel, + &ptr_audio_out[i]); + } - ptr_audio_out[i] = ptr_audio_out[i] * pstr_eq_set->filt_cascade_td[g].cascade_gain_linear; - } - } + ptr_audio_out[i] = ptr_audio_out[i] * pstr_eq_set->filt_cascade_td[g].cascade_gain_linear; + } + } else - { + { return -1; - } - return 0; + } + return 0; } WORD32 impd_process_eq_set_subband_domain(ia_eq_set_struct* pstr_eq_set, @@ -1534,15 +1534,15 @@ WORD32 impd_process_eq_set_subband_domain(ia_eq_set_struct* pstr_eq_set, g = pstr_eq_set->eq_ch_group_of_channel[channel]; if (g >= 0) { - if (pstr_eq_set->domain == 0) - { + if (pstr_eq_set->domain == 0) + { return(-1); } else { - impd_subband_filter_process(&pstr_eq_set->subband_filt[g], - &ptr_audio_real_buff[0], - &ptr_audio_imag_buff[0]); + impd_subband_filter_process(&pstr_eq_set->subband_filt[g], + &ptr_audio_real_buff[0], + &ptr_audio_imag_buff[0]); } } } diff --git a/decoder/drc_src/impd_drc_eq.h b/decoder/drc_src/impd_drc_eq.h index 4f24106..74f40cc 100644 --- a/decoder/drc_src/impd_drc_eq.h +++ b/decoder/drc_src/impd_drc_eq.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_EQ_H #define IMPD_DRC_EQ_H @@ -49,10 +49,10 @@ typedef struct { WORD32 delay; FLOAT32 state[EQ_CHANNEL_COUNT_MAX][EQ_AUDIO_DELAY_MAX]; } ia_audio_delay_struct; - + typedef struct { FLOAT32 radius; - FLOAT32 coeff[2]; + FLOAT32 coeff[2]; } ia_2nd_order_filt_params_struct; typedef struct { @@ -101,7 +101,7 @@ typedef struct { WORD32 member_count; WORD32 member_idx[EQ_CHANNEL_GROUP_COUNT_MAX]; } ia_cascade_align_group_struct; - + typedef struct { WORD32 validity_flag; WORD32 num_matches_filter; @@ -111,7 +111,7 @@ typedef struct { ia_filt_sect_struct filt_section[EQ_FILTER_SECTION_COUNT_MAX]; ia_audio_delay_struct audio_delay; } ia_ph_alignment_filt_struct; - + typedef ia_ph_alignment_filt_struct ia_matching_ph_filt_struct; typedef struct { @@ -119,7 +119,7 @@ typedef struct { WORD32 all_pass_count; ia_matching_ph_filt_struct matching_ph_filt[MATCHING_PHASE_FILTER_COUNT_MAX]; } ia_all_pass_chain_struct; - + typedef struct { WORD32 section_count; ia_filt_sect_struct filt_section[EQ_FILTER_SECTION_COUNT_MAX]; @@ -164,17 +164,17 @@ typedef struct { WORD32 impd_derive_eq_set (ia_eq_coeff_struct* str_eq_coeff, - ia_eq_instructions_struct* str_eq_instructions, - FLOAT32 sample_rate, - WORD32 drc_frame_size, - WORD32 sub_band_domain_mode, - ia_eq_set_struct* eq_set); + ia_eq_instructions_struct* str_eq_instructions, + FLOAT32 sample_rate, + WORD32 drc_frame_size, + WORD32 sub_band_domain_mode, + ia_eq_set_struct* eq_set); VOID impd_get_eq_set_delay (ia_eq_set_struct* eq_set, - WORD32* cascade_delay); + WORD32* cascade_delay); WORD32 impd_process_eq_set_td(ia_eq_set_struct* eq_set, - WORD32 channel, + WORD32 channel, FLOAT32 audio_in, FLOAT32* audio_out); @@ -185,9 +185,9 @@ WORD32 impd_process_eq_set_time_domain(ia_eq_set_struct* eq_set, WORD32 frame_size); WORD32 impd_process_eq_set_subband_domain(ia_eq_set_struct* eq_set, - WORD32 channel, - FLOAT32* subbandSampleIn, - FLOAT32* subbandSampleOut); + WORD32 channel, + FLOAT32* subbandSampleIn, + FLOAT32* subbandSampleOut); #ifdef __cplusplus diff --git a/decoder/drc_src/impd_drc_error_codes.h b/decoder/drc_src/impd_drc_error_codes.h index 3a6940b..07e6edc 100644 --- a/decoder/drc_src/impd_drc_error_codes.h +++ b/decoder/drc_src/impd_drc_error_codes.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_ERROR_CODES_H @@ -26,31 +26,31 @@ #define IA_NO_ERROR 0x00000000 /*API Non-Fatal Errors */ -#define IA_DRC_DEC_API_NONFATAL_NO_ERROR 0x00000000 -#define IA_DRC_DEC_API_NONFATAL_CMD_NOT_SUPPORTED 0x00000001 -#define IA_DRC_DEC_API_NONFATAL_CMD_TYPE_NOT_SUPPORTED 0x00000002 +#define IA_DRC_DEC_API_NONFATAL_NO_ERROR 0x00000000 +#define IA_DRC_DEC_API_NONFATAL_CMD_NOT_SUPPORTED 0x00000001 +#define IA_DRC_DEC_API_NONFATAL_CMD_TYPE_NOT_SUPPORTED 0x00000002 /*API Fatal Errors */ -#define IA_DRC_DEC_API_FATAL_INVALID_MEMTAB_INDEX 0xFFFF8000 -#define IA_DRC_DEC_API_FATAL_INVALID_LIB_ID_STRINGS_IDX 0xFFFF8001 -#define IA_DRC_DEC_API_FATAL_MEM_ALLOC 0xFFFF8002 -#define IA_DRC_DEC_API_FATAL_INVALID_CONFIG_PARAM 0xFFFF8003 -#define IA_DRC_DEC_API_FATAL_INVALID_EXECUTE_TYPE 0xFFFF8004 -#define IA_DRC_DEC_API_FATAL_INVALID_CMD 0xFFFF8005 -#define IA_DRC_DEC_API_FATAL_MEM_ALIGN 0xFFFF8006 +#define IA_DRC_DEC_API_FATAL_INVALID_MEMTAB_INDEX 0xFFFF8000 +#define IA_DRC_DEC_API_FATAL_INVALID_LIB_ID_STRINGS_IDX 0xFFFF8001 +#define IA_DRC_DEC_API_FATAL_MEM_ALLOC 0xFFFF8002 +#define IA_DRC_DEC_API_FATAL_INVALID_CONFIG_PARAM 0xFFFF8003 +#define IA_DRC_DEC_API_FATAL_INVALID_EXECUTE_TYPE 0xFFFF8004 +#define IA_DRC_DEC_API_FATAL_INVALID_CMD 0xFFFF8005 +#define IA_DRC_DEC_API_FATAL_MEM_ALIGN 0xFFFF8006 /*****************************************************************************/ /* Class 1: Configuration Errors */ /*****************************************************************************/ /* Non Fatal Errors */ -#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_NUM_OF_CHANNELS 0x00000800 -#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_SAMP_FREQ 0x00000801 -#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PCM_SIZE 0x00000802 -#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_FRAME_SIZE 0x00000803 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_NUM_OF_CHANNELS 0x00000800 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_SAMP_FREQ 0x00000801 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PCM_SIZE 0x00000802 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_FRAME_SIZE 0x00000803 #define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DELAY_MODE 0x00000804 -#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DECODE_TYPE 0x00000805 +#define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DECODE_TYPE 0x00000805 #define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PEAK_LIM_FLAG 0x00000806 #define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_CTRL_PARAM_IDX 0x00000807 #define IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_GAIN_DELAY 0x00000808 diff --git a/decoder/drc_src/impd_drc_extr_delta_coded_info.c b/decoder/drc_src/impd_drc_extr_delta_coded_info.c index 9332a24..94f0600 100644 --- a/decoder/drc_src/impd_drc_extr_delta_coded_info.c +++ b/decoder/drc_src/impd_drc_extr_delta_coded_info.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include @@ -26,7 +26,7 @@ #include "impd_drc_struct.h" #include "impd_drc_filter_bank.h" #include "impd_drc_rom.h" - + WORD32 impd_init_tbls(const WORD32 num_gain_max_values, ia_tables_struct* str_tables) { @@ -67,8 +67,8 @@ impd_gen_delta_time_code_tbl (const WORD32 num_gain_max_values, delta_time_code_tbl_item[0].size = -1; delta_time_code_tbl_item[0].code = -1; - delta_time_code_tbl_item[0].value = -1; - + delta_time_code_tbl_item[0].value = -1; + delta_time_code_tbl_item[1].size = 2; delta_time_code_tbl_item[1].code = 0x0; delta_time_code_tbl_item[1].value = 1; @@ -107,7 +107,7 @@ impd_get_delta_tmin (const WORD32 sampling_rate) while (result <= lowerBound) result = result << 1; return result; } - + diff --git a/decoder/drc_src/impd_drc_extr_delta_coded_info.h b/decoder/drc_src/impd_drc_extr_delta_coded_info.h index 9964b5e..e2b1ad6 100644 --- a/decoder/drc_src/impd_drc_extr_delta_coded_info.h +++ b/decoder/drc_src/impd_drc_extr_delta_coded_info.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_TABLES_H #define IMPD_DRC_TABLES_H @@ -49,7 +49,7 @@ typedef struct { typedef struct { ia_delta_time_code_table_entry_struct delta_time_code_table[N_DELTA_TIME_CODE_TABLE_ENTRIES_MAX]; } ia_tables_struct; - + typedef struct { FLOAT32 in_out_ratio; FLOAT32 exp_lo; @@ -65,7 +65,7 @@ typedef struct { WORD32 coordinateCount; ia_characteristic_node_coordinate_struct characteristicNodeCoordinate[5]; } ia_cicp_node_characteristic_param; - + WORD32 impd_init_tbls(const WORD32 num_gain_max_values, ia_tables_struct* str_tables); diff --git a/decoder/drc_src/impd_drc_fiilter_bank.c b/decoder/drc_src/impd_drc_fiilter_bank.c index 5aa602f..0bd94d7 100644 --- a/decoder/drc_src/impd_drc_fiilter_bank.c +++ b/decoder/drc_src/impd_drc_fiilter_bank.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -33,10 +33,10 @@ VOID impd_compute_filt_coeff(WORD32 crossover_freq_idx, ia_iir_filter_struct* pstr_hp_filt_coeff, ia_iir_filter_struct* pstr_ap_filt_coeff, WORD32 filter_type) -{ +{ FLOAT32 gamma = normal_cross_freq[crossover_freq_idx].gamma; FLOAT32 delta = normal_cross_freq[crossover_freq_idx].delta; - + if(filter_type==0||filter_type==2){ pstr_lp_filt_coeff->a0 = 1.0f; pstr_lp_filt_coeff->a1 = 2.0f * (gamma - delta); @@ -44,7 +44,7 @@ VOID impd_compute_filt_coeff(WORD32 crossover_freq_idx, pstr_lp_filt_coeff->b0 = gamma; pstr_lp_filt_coeff->b1 = 2.0f * gamma; pstr_lp_filt_coeff->b2 = gamma; - + pstr_hp_filt_coeff->a0 = 1.0f; pstr_hp_filt_coeff->a1 = pstr_lp_filt_coeff->a1; pstr_hp_filt_coeff->a2 = pstr_lp_filt_coeff->a2; @@ -52,7 +52,7 @@ VOID impd_compute_filt_coeff(WORD32 crossover_freq_idx, pstr_hp_filt_coeff->b1 = - 2.0f * delta; pstr_hp_filt_coeff->b2 = delta; } - + if(filter_type==1||filter_type==2){ pstr_ap_filt_coeff->a0 = 1.0f; pstr_ap_filt_coeff->a1 = 2.0f * (gamma - delta);; @@ -60,8 +60,8 @@ VOID impd_compute_filt_coeff(WORD32 crossover_freq_idx, pstr_ap_filt_coeff->b0 = pstr_ap_filt_coeff->a2; pstr_ap_filt_coeff->b1 = pstr_ap_filt_coeff->a1; pstr_ap_filt_coeff->b2 = pstr_ap_filt_coeff->a0; - } - + } + return; } @@ -85,7 +85,7 @@ WORD32 impd_initialize_filt_bank(WORD32 num_sub_bands, &(str_two_band_bank->low_pass), &(str_two_band_bank->high_pass), NULL, - 0); + 0); } else if(num_sub_bands==3){ str_three_band_bank = &drc_filter_bank->str_three_band_bank; @@ -99,7 +99,7 @@ WORD32 impd_initialize_filt_bank(WORD32 num_sub_bands, &(str_three_band_bank->str_low_pass_stage_1), &(str_three_band_bank->str_high_pass_stage_1), NULL, - 0); + 0); } else if(num_sub_bands==4){ @@ -114,7 +114,7 @@ WORD32 impd_initialize_filt_bank(WORD32 num_sub_bands, &(str_four_band_bank->str_low_pass_stage_1), &(str_four_band_bank->str_high_pass_stage_1), NULL, - 0); + 0); impd_compute_filt_coeff(gain_params[3].crossover_freq_idx, &(str_four_band_bank->str_low_pass_stage_3_high), &(str_four_band_bank->str_high_pass_stage_3_high), @@ -137,11 +137,11 @@ WORD32 impd_init_all_filter_banks( ia_uni_drc_coeffs_struct* str_p_loc_drc_coeff WORD32 match_found = 0, num_filter; WORD32 cascade_cross_idx[CHANNEL_GROUP_COUNT_MAX+1][CHANNEL_GROUP_COUNT_MAX * 3]; WORD32 count[CHANNEL_GROUP_COUNT_MAX + 1]; - + num_ch_in_groups = 0; num_ph_align_ch_groups = str_drc_instruction_str->num_drc_ch_groups; - + for (g=0; gnum_drc_ch_groups; g++) { num_ch_in_groups += str_drc_instruction_str->num_chan_per_ch_group[g]; @@ -151,10 +151,10 @@ WORD32 impd_init_all_filter_banks( ia_uni_drc_coeffs_struct* str_p_loc_drc_coeff { num_ph_align_ch_groups++; } - + ia_filter_banks_struct->nfilter_banks = str_drc_instruction_str->num_drc_ch_groups; ia_filter_banks_struct->num_ph_align_ch_groups = num_ph_align_ch_groups; - + if (str_p_loc_drc_coefficients_uni_drc == NULL) { ia_filter_banks_struct->str_drc_filter_bank->num_bands = 1; @@ -166,11 +166,11 @@ WORD32 impd_init_all_filter_banks( ia_uni_drc_coeffs_struct* str_p_loc_drc_coeff err_code = impd_initialize_filt_bank(str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[g]].band_count, str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[g]].gain_params, &(ia_filter_banks_struct->str_drc_filter_bank[g])); - if (err_code!=0) + if (err_code!=0) return (err_code); } } - + for (g=0; g0){ - for(i=0;istr_drc_filter_bank[g].str_all_pass_cascade.str_all_pass_cascade_filter[i].str_all_pass_stage), - 1); + 1); } ia_filter_banks_struct->str_drc_filter_bank[g].str_all_pass_cascade.num_filter = num_filter; - } - - if (err_code!=0) + } + + if (err_code!=0) return (err_code); } @@ -262,7 +262,7 @@ WORD32 impd_init_all_filter_banks( ia_uni_drc_coeffs_struct* str_p_loc_drc_coeff VOID impd_iir_second_order_filter_all_pass(ia_iir_filter_struct* filter, - WORD32 chan_idx, + WORD32 chan_idx, WORD32 frame_len, FLOAT32* input, FLOAT32* output) @@ -274,20 +274,20 @@ VOID impd_iir_second_order_filter_all_pass(ia_iir_filter_struct* filter, FLOAT32 b0 = filter->b0; FLOAT32 b1 = filter->b1; FLOAT32 b2 = filter->b2; - + FLOAT32 st1 = filter->x_p[chan_idx*2]; FLOAT32 st2 = filter->y_p[chan_idx*2]; for (i=0; ix_p[chan_idx*2] = st1; filter->y_p[chan_idx*2] = st2; - + return; } @@ -324,36 +324,36 @@ VOID impd_apply_low_high_filter(ia_iir_filter_struct* pstr_lp_filt_coeff, FLOAT32* output_low = output[0]; FLOAT32* output_high = output[1]; - + for (i=0; ix_p[chan_idx*2+0] = st1_l; pstr_lp_filt_coeff->x_p[chan_idx*2+1] = st2_l; pstr_lp_filt_coeff->y_p[chan_idx*2+0] = st3_l; pstr_lp_filt_coeff->y_p[chan_idx*2+1] = st4_l; - + pstr_hp_filt_coeff->x_p[chan_idx*2+0] = st1_h; pstr_hp_filt_coeff->x_p[chan_idx*2+1] = st2_h; pstr_hp_filt_coeff->y_p[chan_idx*2+0] = st3_h; - pstr_hp_filt_coeff->y_p[chan_idx*2+1] = st4_h; - + pstr_hp_filt_coeff->y_p[chan_idx*2+1] = st4_h; + return; } VOID impd_two_band_filter_process(ia_two_band_filt_struct* str_two_band_bank, @@ -364,14 +364,14 @@ VOID impd_two_band_filter_process(ia_two_band_filt_struct* str_two_band_bank, { ia_iir_filter_struct* pstr_lp_filt_coeff=&str_two_band_bank->low_pass; ia_iir_filter_struct* pstr_hp_filt_coeff=&str_two_band_bank->high_pass; - + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, chan_idx, frame_len, input, output); - return; + return; } @@ -389,34 +389,34 @@ VOID impd_three_band_filter_process(ia_three_band_filt_struct* str_three_band_ba FLOAT32* output1[2]; output1[0]=output[0]; output1[1]=output[1]; - + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, c, size, input, output1); - + all_pass_filter =&str_three_band_bank->str_all_pass_stage_2; - + impd_iir_second_order_filter_all_pass(all_pass_filter, - c, + c, size, output1[1], output[2]); pstr_lp_filt_coeff=&str_three_band_bank->str_low_pass_stage_2; - pstr_hp_filt_coeff=&str_three_band_bank->str_high_pass_stage_2; - - + pstr_hp_filt_coeff=&str_three_band_bank->str_high_pass_stage_2; + + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, c, size, output1[0], output1); - + return; - + } @@ -436,7 +436,7 @@ VOID impd_four_band_filter_process(ia_four_band_filt_struct* str_four_band_bank, output1[1]=output[1]; output2[0]=output[2]; output2[1]=output[3]; - + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, cha_idx, @@ -444,51 +444,51 @@ VOID impd_four_band_filter_process(ia_four_band_filt_struct* str_four_band_bank, input, output1); - all_pass_filter =&str_four_band_bank->str_all_pass_stage_2_low; + all_pass_filter =&str_four_band_bank->str_all_pass_stage_2_low; impd_iir_second_order_filter_all_pass(all_pass_filter, - cha_idx, + cha_idx, win_size, output1[0], output1[0]); - - - all_pass_filter =&str_four_band_bank->str_all_pass_stage_2_high; + + + all_pass_filter =&str_four_band_bank->str_all_pass_stage_2_high; impd_iir_second_order_filter_all_pass(all_pass_filter, - cha_idx, + cha_idx, win_size, output1[1], - output2[0]); - + output2[0]); + pstr_lp_filt_coeff = &str_four_band_bank->str_low_pass_stage_3_low; - pstr_hp_filt_coeff = &str_four_band_bank->str_high_pass_stage_3_low; - - + pstr_hp_filt_coeff = &str_four_band_bank->str_high_pass_stage_3_low; + + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, cha_idx, win_size, output1[0], output1); - + pstr_lp_filt_coeff = &str_four_band_bank->str_low_pass_stage_3_high; - pstr_hp_filt_coeff = &str_four_band_bank->str_high_pass_stage_3_high; - + pstr_hp_filt_coeff = &str_four_band_bank->str_high_pass_stage_3_high; + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, cha_idx, win_size, output2[0], - output2); - + output2); + return; } VOID impd_all_pass_cascade_process(ia_all_pass_cascade_struct *str_all_pass_cascade, WORD32 ch_idx, WORD32 win_size, - FLOAT32* input) + FLOAT32* input) { WORD32 i; @@ -500,6 +500,6 @@ VOID impd_all_pass_cascade_process(ia_all_pass_cascade_struct *str_all_pass_casc input, input); } - + return; } \ No newline at end of file diff --git a/decoder/drc_src/impd_drc_filter_bank.c b/decoder/drc_src/impd_drc_filter_bank.c index 23cd21d..7c7886f 100644 --- a/decoder/drc_src/impd_drc_filter_bank.c +++ b/decoder/drc_src/impd_drc_filter_bank.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -33,10 +33,10 @@ VOID impd_compute_filt_coeff(WORD32 crossover_freq_idx, ia_iir_filter_struct* pstr_hp_filt_coeff, ia_iir_filter_struct* pstr_ap_filt_coeff, WORD32 filter_type) -{ +{ FLOAT32 gamma = normal_cross_freq[crossover_freq_idx].gamma; FLOAT32 delta = normal_cross_freq[crossover_freq_idx].delta; - + if(filter_type==0||filter_type==2){ pstr_lp_filt_coeff->a0 = 1.0f; pstr_lp_filt_coeff->a1 = 2.0f * (gamma - delta); @@ -44,7 +44,7 @@ VOID impd_compute_filt_coeff(WORD32 crossover_freq_idx, pstr_lp_filt_coeff->b0 = gamma; pstr_lp_filt_coeff->b1 = 2.0f * gamma; pstr_lp_filt_coeff->b2 = gamma; - + pstr_hp_filt_coeff->a0 = 1.0f; pstr_hp_filt_coeff->a1 = pstr_lp_filt_coeff->a1; pstr_hp_filt_coeff->a2 = pstr_lp_filt_coeff->a2; @@ -52,7 +52,7 @@ VOID impd_compute_filt_coeff(WORD32 crossover_freq_idx, pstr_hp_filt_coeff->b1 = - 2.0f * delta; pstr_hp_filt_coeff->b2 = delta; } - + if(filter_type==1||filter_type==2){ pstr_ap_filt_coeff->a0 = 1.0f; pstr_ap_filt_coeff->a1 = 2.0f * (gamma - delta);; @@ -60,8 +60,8 @@ VOID impd_compute_filt_coeff(WORD32 crossover_freq_idx, pstr_ap_filt_coeff->b0 = pstr_ap_filt_coeff->a2; pstr_ap_filt_coeff->b1 = pstr_ap_filt_coeff->a1; pstr_ap_filt_coeff->b2 = pstr_ap_filt_coeff->a0; - } - + } + return; } @@ -85,7 +85,7 @@ WORD32 impd_initialize_filt_bank(WORD32 num_sub_bands, &(str_two_band_bank->low_pass), &(str_two_band_bank->high_pass), NULL, - 0); + 0); } else if(num_sub_bands==3){ str_three_band_bank = &drc_filter_bank->str_three_band_bank; @@ -99,7 +99,7 @@ WORD32 impd_initialize_filt_bank(WORD32 num_sub_bands, &(str_three_band_bank->str_low_pass_stage_1), &(str_three_band_bank->str_high_pass_stage_1), NULL, - 0); + 0); } else if(num_sub_bands==4){ @@ -114,7 +114,7 @@ WORD32 impd_initialize_filt_bank(WORD32 num_sub_bands, &(str_four_band_bank->str_low_pass_stage_1), &(str_four_band_bank->str_high_pass_stage_1), NULL, - 0); + 0); impd_compute_filt_coeff(gain_params[3].crossover_freq_idx, &(str_four_band_bank->str_low_pass_stage_3_high), &(str_four_band_bank->str_high_pass_stage_3_high), @@ -137,11 +137,11 @@ WORD32 impd_init_all_filter_banks( ia_uni_drc_coeffs_struct* str_p_loc_drc_coeff WORD32 match_found = 0, num_filter; WORD32 cascade_cross_idx[CHANNEL_GROUP_COUNT_MAX+1][CHANNEL_GROUP_COUNT_MAX * 3]; WORD32 count[CHANNEL_GROUP_COUNT_MAX + 1]; - + num_ch_in_groups = 0; num_ph_align_ch_groups = str_drc_instruction_str->num_drc_ch_groups; - + for (g=0; gnum_drc_ch_groups; g++) { num_ch_in_groups += str_drc_instruction_str->num_chan_per_ch_group[g]; @@ -151,10 +151,10 @@ WORD32 impd_init_all_filter_banks( ia_uni_drc_coeffs_struct* str_p_loc_drc_coeff { num_ph_align_ch_groups++; } - + ia_filter_banks_struct->nfilter_banks = str_drc_instruction_str->num_drc_ch_groups; ia_filter_banks_struct->num_ph_align_ch_groups = num_ph_align_ch_groups; - + if (str_p_loc_drc_coefficients_uni_drc == NULL) { ia_filter_banks_struct->str_drc_filter_bank->num_bands = 1; @@ -166,11 +166,11 @@ WORD32 impd_init_all_filter_banks( ia_uni_drc_coeffs_struct* str_p_loc_drc_coeff err_code = impd_initialize_filt_bank(str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[g]].band_count, str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[g]].gain_params, &(ia_filter_banks_struct->str_drc_filter_bank[g])); - if (err_code!=0) + if (err_code!=0) return (err_code); } } - + for (g=0; g0){ - for(i=0;istr_drc_filter_bank[g].str_all_pass_cascade.str_all_pass_cascade_filter[i].str_all_pass_stage), - 1); + 1); } ia_filter_banks_struct->str_drc_filter_bank[g].str_all_pass_cascade.num_filter = num_filter; - } - - if (err_code!=0) + } + + if (err_code!=0) return (err_code); } @@ -262,7 +262,7 @@ WORD32 impd_init_all_filter_banks( ia_uni_drc_coeffs_struct* str_p_loc_drc_coeff VOID impd_iir_second_order_filter_all_pass(ia_iir_filter_struct* filter, - WORD32 chan_idx, + WORD32 chan_idx, WORD32 frame_len, FLOAT32* input, FLOAT32* output) @@ -274,20 +274,20 @@ VOID impd_iir_second_order_filter_all_pass(ia_iir_filter_struct* filter, FLOAT32 b0 = filter->b0; FLOAT32 b1 = filter->b1; FLOAT32 b2 = filter->b2; - + FLOAT32 st1 = filter->x_p[chan_idx*2]; FLOAT32 st2 = filter->y_p[chan_idx*2]; for (i=0; ix_p[chan_idx*2] = st1; filter->y_p[chan_idx*2] = st2; - + return; } @@ -324,36 +324,36 @@ VOID impd_apply_low_high_filter(ia_iir_filter_struct* pstr_lp_filt_coeff, FLOAT32* output_low = output[0]; FLOAT32* output_high = output[1]; - + for (i=0; ix_p[chan_idx*2+0] = st1_l; pstr_lp_filt_coeff->x_p[chan_idx*2+1] = st2_l; pstr_lp_filt_coeff->y_p[chan_idx*2+0] = st3_l; pstr_lp_filt_coeff->y_p[chan_idx*2+1] = st4_l; - + pstr_hp_filt_coeff->x_p[chan_idx*2+0] = st1_h; pstr_hp_filt_coeff->x_p[chan_idx*2+1] = st2_h; pstr_hp_filt_coeff->y_p[chan_idx*2+0] = st3_h; - pstr_hp_filt_coeff->y_p[chan_idx*2+1] = st4_h; - + pstr_hp_filt_coeff->y_p[chan_idx*2+1] = st4_h; + return; } VOID impd_two_band_filter_process(ia_two_band_filt_struct* str_two_band_bank, @@ -364,14 +364,14 @@ VOID impd_two_band_filter_process(ia_two_band_filt_struct* str_two_band_bank, { ia_iir_filter_struct* pstr_lp_filt_coeff=&str_two_band_bank->low_pass; ia_iir_filter_struct* pstr_hp_filt_coeff=&str_two_band_bank->high_pass; - + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, chan_idx, frame_len, input, output); - return; + return; } @@ -389,34 +389,34 @@ VOID impd_three_band_filter_process(ia_three_band_filt_struct* str_three_band_ba FLOAT32* output1[2]; output1[0]=output[0]; output1[1]=output[1]; - + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, c, size, input, output1); - + all_pass_filter =&str_three_band_bank->str_all_pass_stage_2; - + impd_iir_second_order_filter_all_pass(all_pass_filter, - c, + c, size, output1[1], output[2]); pstr_lp_filt_coeff=&str_three_band_bank->str_low_pass_stage_2; - pstr_hp_filt_coeff=&str_three_band_bank->str_high_pass_stage_2; - - + pstr_hp_filt_coeff=&str_three_band_bank->str_high_pass_stage_2; + + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, c, size, output1[0], output1); - + return; - + } @@ -436,7 +436,7 @@ VOID impd_four_band_filter_process(ia_four_band_filt_struct* str_four_band_bank, output1[1]=output[1]; output2[0]=output[2]; output2[1]=output[3]; - + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, cha_idx, @@ -444,51 +444,51 @@ VOID impd_four_band_filter_process(ia_four_band_filt_struct* str_four_band_bank, input, output1); - all_pass_filter =&str_four_band_bank->str_all_pass_stage_2_low; + all_pass_filter =&str_four_band_bank->str_all_pass_stage_2_low; impd_iir_second_order_filter_all_pass(all_pass_filter, - cha_idx, + cha_idx, win_size, output1[0], output1[0]); - - - all_pass_filter =&str_four_band_bank->str_all_pass_stage_2_high; + + + all_pass_filter =&str_four_band_bank->str_all_pass_stage_2_high; impd_iir_second_order_filter_all_pass(all_pass_filter, - cha_idx, + cha_idx, win_size, output1[1], - output2[0]); - + output2[0]); + pstr_lp_filt_coeff = &str_four_band_bank->str_low_pass_stage_3_low; - pstr_hp_filt_coeff = &str_four_band_bank->str_high_pass_stage_3_low; - - + pstr_hp_filt_coeff = &str_four_band_bank->str_high_pass_stage_3_low; + + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, cha_idx, win_size, output1[0], output1); - + pstr_lp_filt_coeff = &str_four_band_bank->str_low_pass_stage_3_high; - pstr_hp_filt_coeff = &str_four_band_bank->str_high_pass_stage_3_high; - + pstr_hp_filt_coeff = &str_four_band_bank->str_high_pass_stage_3_high; + impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, cha_idx, win_size, output2[0], - output2); - + output2); + return; } VOID impd_all_pass_cascade_process(ia_all_pass_cascade_struct *str_all_pass_cascade, WORD32 ch_idx, WORD32 win_size, - FLOAT32* input) + FLOAT32* input) { WORD32 i; @@ -500,6 +500,6 @@ VOID impd_all_pass_cascade_process(ia_all_pass_cascade_struct *str_all_pass_casc input, input); } - + return; } \ No newline at end of file diff --git a/decoder/drc_src/impd_drc_filter_bank.h b/decoder/drc_src/impd_drc_filter_bank.h index 5ab4f8a..d0bf66b 100644 --- a/decoder/drc_src/impd_drc_filter_bank.h +++ b/decoder/drc_src/impd_drc_filter_bank.h @@ -1,27 +1,27 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_FILTER_BANK_H #define IMPD_DRC_FILTER_BANK_H #define FILTER_BANK_PARAMETER_COUNT 16 -#define CASCADE_ALLPASS_COUNT_MAX 9 +#define CASCADE_ALLPASS_COUNT_MAX 9 #define QMF_NUM_FILT_BANDS 64 #define QMF_FILT_RESOLUTION 64 @@ -66,7 +66,7 @@ typedef struct { FLOAT32 b1; FLOAT32 b2; FLOAT32 x_p[MAX_CHANNEL_COUNT*2]; - FLOAT32 y_p[MAX_CHANNEL_COUNT*2]; + FLOAT32 y_p[MAX_CHANNEL_COUNT*2]; } ia_iir_filter_struct; typedef struct { ia_iir_filter_struct low_pass; @@ -83,9 +83,9 @@ typedef struct { typedef struct { ia_iir_filter_struct str_low_pass_stage_1; - ia_iir_filter_struct str_high_pass_stage_1; + ia_iir_filter_struct str_high_pass_stage_1; ia_iir_filter_struct str_all_pass_stage_2_high; - ia_iir_filter_struct str_all_pass_stage_2_low; + ia_iir_filter_struct str_all_pass_stage_2_low; ia_iir_filter_struct str_low_pass_stage_3_high; ia_iir_filter_struct str_high_pass_stage_3_high; ia_iir_filter_struct str_low_pass_stage_3_low; @@ -95,19 +95,19 @@ typedef struct { typedef struct { ia_iir_filter_struct str_all_pass_stage; } ia_all_pass_filter_sturct; - + typedef struct { ia_all_pass_filter_sturct str_all_pass_cascade_filter[CASCADE_ALLPASS_COUNT_MAX]; WORD32 num_filter; } ia_all_pass_cascade_struct; - + typedef struct { WORD32 num_bands; WORD32 complexity; ia_two_band_filt_struct str_two_band_bank; ia_three_band_filt_struct str_three_band_bank; ia_four_band_filt_struct str_four_band_bank; - ia_all_pass_cascade_struct str_all_pass_cascade; + ia_all_pass_cascade_struct str_all_pass_cascade; } ia_drc_filter_bank_struct; typedef struct { @@ -120,31 +120,31 @@ typedef struct { WORD32 impd_init_all_filter_banks( ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc, - ia_drc_instructions_struct* str_drc_instruction_str, - ia_filter_banks_struct* ia_filter_banks_struct); + ia_drc_instructions_struct* str_drc_instruction_str, + ia_filter_banks_struct* ia_filter_banks_struct); VOID impd_two_band_filter_process(ia_two_band_filt_struct* str_two_band_bank, - WORD32 c, - WORD32 size, - FLOAT32* audio_in, - FLOAT32* audio_out[]); + WORD32 c, + WORD32 size, + FLOAT32* audio_in, + FLOAT32* audio_out[]); VOID impd_three_band_filter_process(ia_three_band_filt_struct* str_three_band_bank, - WORD32 c, - WORD32 size, - FLOAT32* audio_in, - FLOAT32* audio_out[]); + WORD32 c, + WORD32 size, + FLOAT32* audio_in, + FLOAT32* audio_out[]); VOID impd_four_band_filter_process(ia_four_band_filt_struct* str_four_band_bank, - WORD32 c, - WORD32 size, - FLOAT32* audio_in, - FLOAT32* audio_out[]); + WORD32 c, + WORD32 size, + FLOAT32* audio_in, + FLOAT32* audio_out[]); VOID impd_all_pass_cascade_process(ia_all_pass_cascade_struct *str_all_pass_cascade, - WORD32 c, - WORD32 size, - FLOAT32* audio_in); + WORD32 c, + WORD32 size, + FLOAT32* audio_in); WORD32 impd_shape_filt_block_init(ia_shape_filter_block_params_struct* pstr_shape_filter_block_params, @@ -161,5 +161,5 @@ WORD32 impd_shape_filt_block_time_process(shape_filter_block* shape_filter_block const WORD32 channel, FLOAT32 *audio_in, WORD32 start, - WORD32 end); + WORD32 end); #endif diff --git a/decoder/drc_src/impd_drc_gain_dec.c b/decoder/drc_src/impd_drc_gain_dec.c index 562e056..0d03b16 100644 --- a/decoder/drc_src/impd_drc_gain_dec.c +++ b/decoder/drc_src/impd_drc_gain_dec.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -46,16 +46,16 @@ WORD32 impd_gain_db_to_lin (ia_interp_params_struct* interp_params_str, FLOAT32 loc_db_gain = in_param_db_gain; FLOAT32 gain_ratio = 1.0; - + ia_gain_modifiers_struct* pstr_gain_modifiers = interp_params_str->pstr_gain_modifiers; if (interp_params_str->gain_modification_flag) { if ((interp_params_str->characteristic_index > 0) && (loc_db_gain != 0.0f)){ - gain_ratio = 1.0f; + gain_ratio = 1.0f; } - + if (loc_db_gain < 0.0f) { gain_ratio *= interp_params_str->compress; } @@ -74,11 +74,11 @@ WORD32 impd_gain_db_to_lin (ia_interp_params_struct* interp_params_str, if ((interp_params_str->pstr_ducking_modifiers->ducking_scaling_flag == 1) && (interp_params_str->ducking_flag == 1)) { gain_ratio *= interp_params_str->pstr_ducking_modifiers->ducking_scaling; } - + { *out_param_lin_gain = (FLOAT32)pow(2.0, (FLOAT64)(gain_ratio * loc_db_gain / 6.0f)); *out_param_lin_slope = SLOPE_FACTOR_DB_TO_LINEAR * gain_ratio * *out_param_lin_gain * in_param_db_slope; - + if (pstr_gain_modifiers->gain_offset_flag[drc_band] == 1) { *out_param_lin_gain *= (FLOAT32)pow(2.0, (FLOAT64)(pstr_gain_modifiers->gain_offset[drc_band]/6.0f)); } @@ -108,12 +108,12 @@ impd_compressor_io_sigmoid(ia_split_drc_characteristic_struct* split_drc_charact FLOAT32 in_out_ratio = split_drc_characteristic->in_out_ratio; FLOAT32 gainDbLimit = split_drc_characteristic->gain; FLOAT32 exp = split_drc_characteristic->exp; - + tmp = (DRC_INPUT_LOUDNESS_TARGET - in_db_level) * in_out_ratio; if (exp < 1000.0f) { FLOAT32 x = tmp/gainDbLimit; - if (x < 0.0f) - { + if (x < 0.0f) + { return(UNEXPECTED_ERROR); } *out_db_gain = (FLOAT32)(tmp / pow(1.0f + pow(x, exp), 1.0f/exp)); @@ -135,20 +135,20 @@ impd_compressor_io_sigmoid_inv(ia_split_drc_characteristic_struct* split_drc_cha FLOAT32 gainDbLimit = split_drc_characteristic->gain; FLOAT32 exp = split_drc_characteristic->exp; FLOAT32 tmp = loc_db_gain; - + if (split_drc_characteristic->flip_sign == 1) { tmp = - loc_db_gain; } if (exp < 1000.0f) { FLOAT32 x = tmp/gainDbLimit; - if (x < 0.0f) - { + if (x < 0.0f) + { return(UNEXPECTED_ERROR); } tmp = (FLOAT32)(tmp / pow(1.0f - pow(x, exp), 1.0f / exp)); } *in_level = DRC_INPUT_LOUDNESS_TARGET - tmp / in_out_ratio; - + return(0); } @@ -161,9 +161,9 @@ impd_compressor_io_nodes_lt(ia_split_drc_characteristic_struct* split_drc_charac FLOAT32 w; FLOAT32* node_level = split_drc_characteristic->node_level; FLOAT32* node_gain = split_drc_characteristic->node_gain; - - if (in_db_level > DRC_INPUT_LOUDNESS_TARGET) - { + + if (in_db_level > DRC_INPUT_LOUDNESS_TARGET) + { return (UNEXPECTED_ERROR); } for (n=1; n<=split_drc_characteristic->characteristic_node_count; n++) { @@ -185,9 +185,9 @@ impd_compressor_io_nodes_rt(ia_split_drc_characteristic_struct* split_drc_charac FLOAT32 w; FLOAT32* node_level = split_drc_characteristic->node_level; FLOAT32* node_gain = split_drc_characteristic->node_gain; - - if (in_db_level < DRC_INPUT_LOUDNESS_TARGET) - { + + if (in_db_level < DRC_INPUT_LOUDNESS_TARGET) + { return (UNEXPECTED_ERROR); } for (n=1; n<=split_drc_characteristic->characteristic_node_count; n++) { @@ -211,7 +211,7 @@ impd_compressor_io_nodes_inverse(ia_split_drc_characteristic_struct* split_drc_c FLOAT32* node_level = split_drc_characteristic->node_level; FLOAT32* node_gain = split_drc_characteristic->node_gain; WORD32 node_count = split_drc_characteristic->characteristic_node_count; - + if (node_gain[1] < 0.0f) { if (loc_db_gain <= node_gain[node_count]) { *in_level = node_level[node_count]; @@ -261,7 +261,7 @@ impd_map_gain ( { FLOAT32 inLevel; WORD32 err = 0; - + switch (split_drc_characteristic_source->characteristic_format) { case CHARACTERISTIC_SIGMOID: err = impd_compressor_io_sigmoid_inv(split_drc_characteristic_source, gain_in_db, &inLevel); @@ -319,7 +319,7 @@ impd_conv_to_linear_domain (ia_interp_params_struct* interp_params_str, ia_split_drc_characteristic_struct* split_drc_characteristic_source; WORD32 slopeIsNegative; - + if (interp_params_str->drc_characteristic_present) { if (interp_params_str->drc_source_characteristic_cicp_format) { @@ -345,7 +345,7 @@ impd_conv_to_linear_domain (ia_interp_params_struct* interp_params_str, (interp_params_str->split_target_characteristic_right->characteristic_format == CHARACTERISTIC_PASS_THRU))) { mapped_db_gain = DRC_INPUT_LOUDNESS_TARGET; - loc_db_gain = DRC_INPUT_LOUDNESS_TARGET; + loc_db_gain = DRC_INPUT_LOUDNESS_TARGET; } } else @@ -356,7 +356,7 @@ impd_conv_to_linear_domain (ia_interp_params_struct* interp_params_str, { err = impd_map_gain(split_drc_characteristic_source, interp_params_str->split_target_characteristic_left, loc_db_gain, &mapped_db_gain); if (err) return (err); - gain_ratio = mapped_db_gain / loc_db_gain; + gain_ratio = mapped_db_gain / loc_db_gain; } } @@ -367,13 +367,13 @@ impd_conv_to_linear_domain (ia_interp_params_struct* interp_params_str, split_drc_characteristic_source = interp_params_str->split_source_characteristic_right; err = impd_map_gain(split_drc_characteristic_source, interp_params_str->split_target_characteristic_right, loc_db_gain, &mapped_db_gain); if (err) return (err); - gain_ratio = mapped_db_gain / loc_db_gain; + gain_ratio = mapped_db_gain / loc_db_gain; } } } } } - + if (loc_db_gain < 0.0f) { gain_ratio *= interp_params_str->compress; } @@ -392,17 +392,17 @@ impd_conv_to_linear_domain (ia_interp_params_struct* interp_params_str, if ((interp_params_str->pstr_ducking_modifiers->ducking_scaling_flag == 1) && (interp_params_str->ducking_flag == 1)) { gain_ratio *= interp_params_str->pstr_ducking_modifiers->ducking_scaling; } - + if (interp_params_str->interpolation_loud_eq == 1) { - *out_param_lin_gain = gain_ratio * loc_db_gain + pstr_gain_modifiers->gain_offset[drc_band]; - *out_param_lin_slope = 0.0f; + *out_param_lin_gain = gain_ratio * loc_db_gain + pstr_gain_modifiers->gain_offset[drc_band]; + *out_param_lin_slope = 0.0f; } else { *out_param_lin_gain = (FLOAT32)pow(2.0, (FLOAT64)(gain_ratio * loc_db_gain / 6.0f)); *out_param_lin_slope = SLOPE_FACTOR_DB_TO_LINEAR * gain_ratio * *out_param_lin_gain * in_param_db_slope; - + if (pstr_gain_modifiers->gain_offset_flag[drc_band] == 1) { *out_param_lin_gain *= (FLOAT32)pow(2.0, (FLOAT64)(pstr_gain_modifiers->gain_offset[drc_band]/6.0f)); } @@ -425,7 +425,7 @@ WORD32 impd_interpolate_drc_gain(ia_interp_params_struct* interp_params_str, FLOAT32 slope0, FLOAT32 slope1, FLOAT32* result) -{ +{ WORD32 err = 0; WORD32 n; FLOAT32 k1, k2, a, b, c, d; @@ -433,23 +433,23 @@ WORD32 impd_interpolate_drc_gain(ia_interp_params_struct* interp_params_str, FLOAT32 slope_t2; FLOAT32 gain_t1; FLOAT32 gain_t2; - + WORD32 cubic_interpolation = 1; WORD32 node_inser; FLOAT32 node_inser_float; - + if (gain_step_tdomain <= 0) { return (UNEXPECTED_ERROR); } - + err = impd_conv_to_linear_domain (interp_params_str, drc_band, gain0, slope0, &gain_t1, &slope_t1); if (err) return (err); err = impd_conv_to_linear_domain (interp_params_str, drc_band, gain1, slope1, &gain_t2, &slope_t2); if (err) return (err); - + if (interp_params_str->gain_interpolation_type == GAIN_INTERPOLATION_TYPE_SPLINE) { slope_t1 = slope_t1/(FLOAT32) interp_params_str->delta_tmin; slope_t2 = slope_t2/(FLOAT32) interp_params_str->delta_tmin; @@ -459,10 +459,10 @@ WORD32 impd_interpolate_drc_gain(ia_interp_params_struct* interp_params_str, node_inser = (WORD32) (0.5f + node_inser_float); if ((node_inser >= 0) && (node_inser < gain_step_tdomain)) { cubic_interpolation = 0; - + result[0] = gain_t1; result[gain_step_tdomain] = gain_t2; - + a = 0.5f*(slope_t2 - slope_t1) / node_inser_float; b = slope_t1; c = gain_t1; @@ -487,10 +487,10 @@ WORD32 impd_interpolate_drc_gain(ia_interp_params_struct* interp_params_str, node_inser = (WORD32) (0.5f + node_inser_float); if ((node_inser >= 0) && (node_inser < gain_step_tdomain)) { cubic_interpolation = 0; - + result[0] = gain_t1; result[gain_step_tdomain] = gain_t2; - + a = slope_t1; b = gain_t1; for (n=1; nprev_node.time; prev_db_gain = buf_interpolation->prev_node.loc_db_gain; slopePrev = buf_interpolation->prev_node.slope; @@ -588,16 +588,16 @@ impd_concatenate_segments(WORD32 drc_frame_size, slope, buf_interpolation->lpcm_gains + MAX_SIGNAL_DELAY + drc_frame_size + timePrev); if (err) return (err); - + timePrev = str_spline_nodes->str_node[n].time; prev_db_gain = loc_db_gain; slopePrev = slope; } - + buf_interpolation->str_node.loc_db_gain = loc_db_gain; buf_interpolation->str_node.slope = slope; buf_interpolation->str_node.time = timePrev; - + return(0); } @@ -620,7 +620,7 @@ impd_get_drc_gain (ia_drc_gain_dec_struct* p_drc_gain_dec_structs, WORD32 b, g, gainElementIndex, err = 0; WORD32 parametricDrcInstanceIndex = 0; ia_interp_params_struct interp_params_str = {0}; - + ia_drc_instructions_struct* str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[drc_instructions_index]); WORD32 drc_set_effect = str_drc_instruction_str->drc_set_effect; WORD32 num_drc_ch_groups = str_drc_instruction_str->num_drc_ch_groups; @@ -635,14 +635,14 @@ impd_get_drc_gain (ia_drc_gain_dec_struct* p_drc_gain_dec_structs, { return (UNEXPECTED_ERROR); } - + interp_params_str.loudness_normalization_gain_db = loudness_normalization_gain_db; - interp_params_str.characteristic_index = characteristic_index; + interp_params_str.characteristic_index = characteristic_index; interp_params_str.compress = compress; interp_params_str.boost = boost; interp_params_str.limiter_peak_target_present = str_drc_instruction_str->limiter_peak_target_present; interp_params_str.limiter_peak_target = str_drc_instruction_str->limiter_peak_target; - + if ( ((drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) == 0) && (drc_set_effect != EFFECT_BIT_FADE) && (drc_set_effect != EFFECT_BIT_CLIPPING)) { interp_params_str.gain_modification_flag = 1; @@ -659,7 +659,7 @@ impd_get_drc_gain (ia_drc_gain_dec_struct* p_drc_gain_dec_structs, { interp_params_str.ducking_flag = 0; } - if (drc_set_effect == EFFECT_BIT_CLIPPING) + if (drc_set_effect == EFFECT_BIT_CLIPPING) { interp_params_str.clipping_flag = 1; } @@ -667,10 +667,10 @@ impd_get_drc_gain (ia_drc_gain_dec_struct* p_drc_gain_dec_structs, { interp_params_str.clipping_flag = 0; } - + err = impd_advance_buf(ia_drc_params_struct->drc_frame_size, &(drc_gain_buffers->pstr_gain_buf[sel_drc_index])); if (err) return (err); - + gainElementIndex = 0; for(g=0; gparametricdrc_params, &p_drc_gain_dec_structs->parametricdrc_params.str_parametric_drc_instance_params[parametricDrcInstanceIndex]); if (err) return (err); - + err = impd_concatenate_segments(ia_drc_params_struct->drc_frame_size, 0, &interp_params_str, @@ -738,9 +738,9 @@ impd_get_drc_gain (ia_drc_gain_dec_struct* p_drc_gain_dec_structs, &p_drc_gain_dec_structs->parametricdrc_params.str_parametric_drc_instance_params[parametricDrcInstanceIndex].str_spline_nodes, &(drc_gain_buffers->pstr_gain_buf[sel_drc_index].buf_interpolation[gainElementIndex])); if (err) return (err); - + } else { - return (UNEXPECTED_ERROR); + return (UNEXPECTED_ERROR); } gainElementIndex++; parametricDrcInstanceIndex++; diff --git a/decoder/drc_src/impd_drc_gain_dec.h b/decoder/drc_src/impd_drc_gain_dec.h index 5fc7280..8f2254b 100644 --- a/decoder/drc_src/impd_drc_gain_dec.h +++ b/decoder/drc_src/impd_drc_gain_dec.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_GAIN_DEC_H #define IMPD_DRC_GAIN_DEC_H diff --git a/decoder/drc_src/impd_drc_gain_decoder.c b/decoder/drc_src/impd_drc_gain_decoder.c index 0b09722..3583051 100644 --- a/decoder/drc_src/impd_drc_gain_decoder.c +++ b/decoder/drc_src/impd_drc_gain_decoder.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -47,25 +47,25 @@ IA_ERRORCODE impd_init_drc_decode( WORD32 frame_size, { IA_ERRORCODE err_code = IA_NO_ERROR; - + err_code = impd_init_drc_params(frame_size, sample_rate, gain_delay_samples, delay_mode, sub_band_domain_mode, &p_drc_gain_dec_structs->ia_drc_params_struct); - - if (err_code!=IA_NO_ERROR) + + if (err_code!=IA_NO_ERROR) return (err_code); - + impd_init_parametric_drc(p_drc_gain_dec_structs->ia_drc_params_struct.drc_frame_size, sample_rate, sub_band_domain_mode, &p_drc_gain_dec_structs->parametricdrc_params); - - if (err_code!=IA_NO_ERROR) + + if (err_code!=IA_NO_ERROR) return (err_code); - + return err_code; } @@ -75,19 +75,19 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num WORD32* downmix_id_processed, WORD32 num_sets_processed, WORD32 eq_set_id_processed, - + ia_drc_gain_dec_struct* p_drc_gain_dec_structs, ia_drc_config* pstr_drc_config, ia_drc_loudness_info_set_struct* pstr_loudness_info, - pVOID *mem_ptr + pVOID *mem_ptr ) { IA_ERRORCODE err_code = 0; - WORD32 i,j,k, maxMultibandAudioSignalCount=0; + WORD32 i,j,k, maxMultibandAudioSignalCount=0; ia_drc_params_struct* p_drc_params_struct = &p_drc_gain_dec_structs->ia_drc_params_struct; ia_audio_in_out_buf* p_audio_in_out_buf = &p_drc_gain_dec_structs->audio_in_out_buf; - + for (i = 0; i < num_sets_processed; i++) { err_code = impd_init_selected_drc_set(pstr_drc_config, @@ -100,10 +100,10 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num &p_drc_gain_dec_structs->str_overlap_params ,p_drc_gain_dec_structs->shape_filter_block ); - if (err_code) + if (err_code) return (err_code); } - + p_drc_gain_dec_structs->audio_num_chan = audio_num_chan; p_drc_gain_dec_structs->ia_drc_params_struct.audio_delay_samples = p_drc_gain_dec_structs->ia_drc_params_struct.parametric_drc_delay; if (pstr_drc_config->str_drc_config_ext.parametric_drc_present) { @@ -111,15 +111,15 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num pstr_loudness_info, &p_drc_gain_dec_structs->parametricdrc_params, mem_ptr); - if (err_code) + if (err_code) return (err_code); } p_audio_in_out_buf->audio_num_chan = audio_num_chan; p_audio_in_out_buf->audio_delay_samples = p_drc_params_struct->audio_delay_samples; p_audio_in_out_buf->frame_size = p_drc_params_struct->drc_frame_size; - - + + if(p_drc_params_struct->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_QMF64){ p_audio_in_out_buf->audio_delay_sub_band_samples = p_drc_params_struct->audio_delay_samples / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; p_audio_in_out_buf->audio_sub_band_frame_size = p_drc_params_struct->drc_frame_size / AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; @@ -147,12 +147,12 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num for (k=0; ksel_drc_array[k].drc_instructions_index >= 0) - { + { ia_drc_instructions_struct* drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[p_drc_params_struct->sel_drc_array[k].drc_instructions_index]); if (drc_instruction_str->gain_element_count > 0) { p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[k].buf_interpolation = (ia_interp_buf_struct*)*mem_ptr; - *mem_ptr=(pVOID)((SIZE_T)*mem_ptr+drc_instruction_str->gain_element_count*sizeof(ia_interp_buf_struct)+32); + *mem_ptr=(pVOID)((SIZE_T)*mem_ptr+drc_instruction_str->gain_element_count*sizeof(ia_interp_buf_struct)+32); p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[k].buf_interpolation_count = drc_instruction_str->gain_element_count; for (i=0; idrc_gain_buffers.pstr_gain_buf[i].buf_interpolation_count; i++) { @@ -160,7 +160,7 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[i].buf_interpolation[i].prev_node.time = -1; p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[i].buf_interpolation[i].str_node.loc_db_gain = 0.0f; p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[i].buf_interpolation[i].str_node.slope = 0.0f; - + for (j=0; j<2 * AUDIO_CODEC_FRAME_SIZE_MAX + MAX_SIGNAL_DELAY; j++) { p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[i].buf_interpolation[i].lpcm_gains[j] = 1.f; @@ -170,9 +170,9 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num } } - - + + if (eq_set_id_processed > 0) { for(i=0; istr_drc_config_ext.eq_instructions_count; i++) @@ -180,16 +180,16 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num if (pstr_drc_config->str_drc_config_ext.str_eq_instructions[i].eq_set_id == eq_set_id_processed) break; } - if (i==pstr_drc_config->str_drc_config_ext.eq_instructions_count) + if (i==pstr_drc_config->str_drc_config_ext.eq_instructions_count) { return -1; } - + p_drc_gain_dec_structs->eq_set=(ia_eq_set_struct*)*mem_ptr ; *mem_ptr=(pVOID)((SIZE_T)*mem_ptr+sizeof(ia_eq_set_struct)+32); - - if (err_code) + + if (err_code) return (err_code); err_code = impd_derive_eq_set (&pstr_drc_config->str_drc_config_ext.str_eq_coeff, @@ -198,14 +198,14 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num p_drc_gain_dec_structs->ia_drc_params_struct.drc_frame_size, p_drc_gain_dec_structs->ia_drc_params_struct.sub_band_domain_mode, p_drc_gain_dec_structs->eq_set); - if (err_code) + if (err_code) return (err_code); - + impd_get_eq_set_delay (p_drc_gain_dec_structs->eq_set, &p_drc_gain_dec_structs->ia_drc_params_struct.eq_delay); } - + for (i=0; idrc_set_counter; i++) @@ -214,7 +214,7 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[p_drc_params_struct->sel_drc_array[i].drc_instructions_index]); maxMultibandAudioSignalCount = max(maxMultibandAudioSignalCount, drc_instruction_str->multiband_audio_sig_count); } - + @@ -222,7 +222,7 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num *mem_ptr = (pVOID) ((SIZE_T)*mem_ptr+(maxMultibandAudioSignalCount*sizeof(FLOAT32*))+32); - + for (i=0;iaudio_band_buffer.non_interleaved_audio[i] = *mem_ptr; @@ -236,9 +236,9 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num if (p_drc_params_struct->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_OFF && p_audio_in_out_buf->audio_delay_samples) { p_audio_in_out_buf->audio_io_buffer_delayed = *mem_ptr; *mem_ptr = (pVOID) ( (SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); - p_audio_in_out_buf->audio_in_out_buf = *mem_ptr; + p_audio_in_out_buf->audio_in_out_buf = *mem_ptr; *mem_ptr =(pVOID) ( (SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); - + for (i=0; iaudio_num_chan; i++) { p_audio_in_out_buf->audio_io_buffer_delayed[i]=*mem_ptr; *mem_ptr = (pVOID) ((SIZE_T)*mem_ptr+((p_audio_in_out_buf->frame_size + p_audio_in_out_buf->audio_delay_samples)*sizeof(FLOAT32*))+32); @@ -249,20 +249,20 @@ IA_ERRORCODE impd_init_drc_decode_post_config(WORD32 audio_num if (p_drc_params_struct->sub_band_domain_mode != SUBBAND_DOMAIN_MODE_OFF && p_audio_in_out_buf->audio_delay_sub_band_samples) { p_audio_in_out_buf->audio_buffer_delayed_real = *mem_ptr; - *mem_ptr = (pVOID) ((SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); + *mem_ptr = (pVOID) ((SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); p_audio_in_out_buf->audio_buffer_delayed_imag = *mem_ptr; - *mem_ptr = (pVOID) ( (SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); + *mem_ptr = (pVOID) ( (SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); p_audio_in_out_buf->audio_real_buff = *mem_ptr; - *mem_ptr = (pVOID) ((SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); + *mem_ptr = (pVOID) ((SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); p_audio_in_out_buf->audio_imag_buff = *mem_ptr; - *mem_ptr = (pVOID) ( (SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); - + *mem_ptr = (pVOID) ( (SIZE_T)*mem_ptr+(p_audio_in_out_buf->audio_num_chan*sizeof(FLOAT32*))+32); + for (i=0; iaudio_num_chan; i++) { p_audio_in_out_buf->audio_buffer_delayed_real[i] = *mem_ptr; - *mem_ptr =(pVOID) ((SIZE_T)*mem_ptr+(( p_audio_in_out_buf->audio_sub_band_frame_size + p_audio_in_out_buf->audio_delay_sub_band_samples)*sizeof(FLOAT32*))+32); + *mem_ptr =(pVOID) ((SIZE_T)*mem_ptr+(( p_audio_in_out_buf->audio_sub_band_frame_size + p_audio_in_out_buf->audio_delay_sub_band_samples)*sizeof(FLOAT32*))+32); p_audio_in_out_buf->audio_buffer_delayed_imag[i] = *mem_ptr; - *mem_ptr =(pVOID) ((SIZE_T)*mem_ptr+(( p_audio_in_out_buf->audio_sub_band_frame_size + p_audio_in_out_buf->audio_delay_sub_band_samples)*sizeof(FLOAT32*))+32); + *mem_ptr =(pVOID) ((SIZE_T)*mem_ptr+(( p_audio_in_out_buf->audio_sub_band_frame_size + p_audio_in_out_buf->audio_delay_sub_band_samples)*sizeof(FLOAT32*))+32); p_audio_in_out_buf->audio_real_buff[i] = &p_audio_in_out_buf->audio_buffer_delayed_real[i][ p_audio_in_out_buf->audio_delay_sub_band_samples * p_audio_in_out_buf->audio_sub_band_count]; p_audio_in_out_buf->audio_imag_buff[i] = &p_audio_in_out_buf->audio_buffer_delayed_imag[i][ p_audio_in_out_buf->audio_delay_sub_band_samples * p_audio_in_out_buf->audio_sub_band_count]; @@ -285,11 +285,11 @@ IA_ERRORCODE impd_drc_process_time_domain( ia_drc_gain_dec_struct* p_drc_gain_d FLOAT32 compress, WORD32 drc_characteristic_target) { - WORD32 sel_drc_index; + WORD32 sel_drc_index; IA_ERRORCODE err_code = 0; WORD32 passThru; ia_drc_instructions_struct* str_drc_instruction_str = pstr_drc_config->str_drc_instruction_str; - + if (p_drc_gain_dec_structs->eq_set) { WORD32 ch; @@ -305,13 +305,13 @@ IA_ERRORCODE impd_drc_process_time_domain( ia_drc_gain_dec_struct* p_drc_gain_d err_code = impd_store_audio_io_buffer_time(audio_in_out_buf, &p_drc_gain_dec_structs->audio_in_out_buf); - if(err_code!=IA_NO_ERROR) + if(err_code!=IA_NO_ERROR) return (err_code); - + if (pstr_drc_config->apply_drc) - { + { for (sel_drc_index=0; sel_drc_indexia_drc_params_struct.drc_set_counter; sel_drc_index++) - { + { err_code = impd_get_drc_gain (p_drc_gain_dec_structs, pstr_drc_config, pstr_drc_gain, @@ -321,10 +321,10 @@ IA_ERRORCODE impd_drc_process_time_domain( ia_drc_gain_dec_struct* p_drc_gain_d loudness_normalization_gain_db, sel_drc_index, &p_drc_gain_dec_structs->drc_gain_buffers); - if(err_code!=IA_NO_ERROR) + if(err_code!=IA_NO_ERROR) return (err_code); } - + if (p_drc_gain_dec_structs->ia_drc_params_struct.drc_set_counter == 0) { err_code = impd_retrieve_audio_io_buffer_time(audio_in_out_buf, @@ -350,9 +350,9 @@ IA_ERRORCODE impd_drc_process_time_domain( ia_drc_gain_dec_struct* p_drc_gain_d &p_drc_gain_dec_structs->audio_band_buffer, &p_drc_gain_dec_structs->ia_filter_banks_struct, passThru); - if(err_code!=IA_NO_ERROR) + if(err_code!=IA_NO_ERROR) return (err_code); - + err_code = impd_apply_gains_and_add(str_drc_instruction_str, p_drc_gain_dec_structs->ia_drc_params_struct.sel_drc_array[sel_drc_index].drc_instructions_index, &p_drc_gain_dec_structs->ia_drc_params_struct, @@ -363,11 +363,11 @@ IA_ERRORCODE impd_drc_process_time_domain( ia_drc_gain_dec_struct* p_drc_gain_d 1); if(err_code!=IA_NO_ERROR) return (err_code); - + } } } - + err_code = impd_advance_audio_io_buffer_time(&p_drc_gain_dec_structs->audio_in_out_buf); if(err_code!=IA_NO_ERROR) return (err_code); @@ -386,14 +386,14 @@ IA_ERRORCODE impd_drc_process_freq_domain( ia_drc_gain_dec_struct* p_drc_gain_ FLOAT32 compress, WORD32 drc_characteristic_target) { - WORD32 sel_drc_index; + WORD32 sel_drc_index; IA_ERRORCODE err_code = 0; ia_drc_instructions_struct* str_drc_instruction_str = pstr_drc_config->str_drc_instruction_str; if (p_drc_gain_dec_structs->eq_set) { WORD32 ch; - + for (ch=0; cheq_set->audio_num_chan; ch++) { err_code = impd_process_eq_set_subband_domain(p_drc_gain_dec_structs->eq_set, @@ -409,7 +409,7 @@ IA_ERRORCODE impd_drc_process_freq_domain( ia_drc_gain_dec_struct* p_drc_gain_ &p_drc_gain_dec_structs->audio_in_out_buf); if(err_code!=IA_NO_ERROR) return (err_code); - + if (pstr_drc_config->apply_drc) { for (sel_drc_index=0; sel_drc_indexia_drc_params_struct.drc_set_counter; sel_drc_index++) @@ -453,7 +453,7 @@ IA_ERRORCODE impd_drc_process_freq_domain( ia_drc_gain_dec_struct* p_drc_gain_ } } } - + err_code = impd_advance_audio_buff_freq(&p_drc_gain_dec_structs->audio_in_out_buf); return err_code; @@ -465,7 +465,7 @@ VOID impd_get_parametric_drc_delay(ia_drc_gain_dec_struct* p_drc_gain_dec_struc WORD32* parametric_drc_delay_max) { *parametric_drc_delay = p_drc_gain_dec_structs->ia_drc_params_struct.parametric_drc_delay; - + if (pstr_drc_config->str_drc_config_ext.parametric_drc_present && pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.parametric_drc_delay_max_present) { *parametric_drc_delay_max = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.parametric_drc_delay_max; } else if (pstr_drc_config->str_drc_config_ext.parametric_drc_present == 0) { @@ -483,7 +483,7 @@ VOID impd_get_eq_delay(ia_drc_gain_dec_struct* p_drc_gain_dec_structs, WORD32* eq_delay_max) { *eq_delay = p_drc_gain_dec_structs->ia_drc_params_struct.eq_delay; - + if (pstr_drc_config->str_drc_config_ext.eq_flag && pstr_drc_config->str_drc_config_ext.str_eq_coeff.eq_delay_max_present) { *eq_delay_max = pstr_drc_config->str_drc_config_ext.str_eq_coeff.eq_delay_max; } else if (pstr_drc_config->str_drc_config_ext.eq_flag == 0) { @@ -491,7 +491,7 @@ VOID impd_get_eq_delay(ia_drc_gain_dec_struct* p_drc_gain_dec_structs, } else { *eq_delay_max = -1; } - + return; } diff --git a/decoder/drc_src/impd_drc_gain_decoder.h b/decoder/drc_src/impd_drc_gain_decoder.h index a1d7aef..e38641d 100644 --- a/decoder/drc_src/impd_drc_gain_decoder.h +++ b/decoder/drc_src/impd_drc_gain_decoder.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_GAIN_DECODER2_H #define IMPD_DRC_GAIN_DECODER2_H @@ -56,9 +56,9 @@ WORD32 impd_init_drc_decode_post_config( WORD32 audio_num_chan, ia_drc_gain_dec_struct* p_drc_gain_dec_structs, ia_drc_config * pstr_drc_config, ia_drc_loudness_info_set_struct* pstr_loudness_info, - pVOID *mem_ptr - - ); + pVOID *mem_ptr + + ); WORD32 impd_drc_process_time_domain( ia_drc_gain_dec_struct* p_drc_gain_dec_structs, ia_drc_config* pstr_drc_config, @@ -83,7 +83,7 @@ VOID impd_get_parametric_drc_delay(ia_drc_gain_dec_struct* p_drc_gain_dec_struc ia_drc_config* pstr_drc_config, WORD32* parametric_drc_delay, WORD32* parametric_drc_delay_max); - + VOID impd_get_eq_delay(ia_drc_gain_dec_struct* p_drc_gain_dec_structs, ia_drc_config* pstr_drc_config, WORD32* eq_delay, @@ -101,7 +101,7 @@ impd_get_drc_gain (ia_drc_gain_dec_struct* p_drc_gain_dec_structs, ia_drc_gain_buffers_struct* drc_gain_buffers); - + #endif diff --git a/decoder/drc_src/impd_drc_hashdefines.h b/decoder/drc_src/impd_drc_hashdefines.h index befa808..09a8c2f 100644 --- a/decoder/drc_src/impd_drc_hashdefines.h +++ b/decoder/drc_src/impd_drc_hashdefines.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_HASHDEFINES_H #define IMPD_DRC_HASHDEFINES_H diff --git a/decoder/drc_src/impd_drc_host_params.c b/decoder/drc_src/impd_drc_host_params.c index 932a586..1997eca 100644 --- a/decoder/drc_src/impd_drc_host_params.c +++ b/decoder/drc_src/impd_drc_host_params.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include "impd_type_def.h" #include "impd_drc_extr_delta_coded_info.h" @@ -27,14 +27,14 @@ #include "impd_drc_filter_bank.h" #include "impd_drc_rom.h" - + WORD32 impd_set_default_params_selection_process(ia_drc_sel_proc_params_struct *pstr_drc_sel_proc_params) { pstr_drc_sel_proc_params->base_channel_count = -1; pstr_drc_sel_proc_params->base_layout = -1; pstr_drc_sel_proc_params->target_config_request_type = 0; pstr_drc_sel_proc_params->num_downmix_id_requests = 0; - + pstr_drc_sel_proc_params->album_mode = 0; pstr_drc_sel_proc_params->peak_limiter = 1; @@ -48,7 +48,7 @@ WORD32 impd_set_default_params_selection_process(ia_drc_sel_proc_params_struct * pstr_drc_sel_proc_params->loudness_measurement_system = USER_MEASUREMENT_SYSTEM_DEFAULT; pstr_drc_sel_proc_params->loudness_measurement_pre_proc = USER_LOUDNESS_PREPROCESSING_DEFAULT; pstr_drc_sel_proc_params->device_cut_off_frequency = 500; - pstr_drc_sel_proc_params->loudness_norm_gain_db_max = LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT; + pstr_drc_sel_proc_params->loudness_norm_gain_db_max = LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT; pstr_drc_sel_proc_params->loudness_norm_gain_modification_db = 0.0f; pstr_drc_sel_proc_params->output_peak_level_max = 0.0f; if (pstr_drc_sel_proc_params->peak_limiter == 1) { @@ -56,28 +56,28 @@ WORD32 impd_set_default_params_selection_process(ia_drc_sel_proc_params_struct * pstr_drc_sel_proc_params->output_peak_level_max = 6.0f; } - + pstr_drc_sel_proc_params->dynamic_range_control_on = 1; - pstr_drc_sel_proc_params->num_bands_supported = 4; + pstr_drc_sel_proc_params->num_bands_supported = 4; pstr_drc_sel_proc_params->num_drc_feature_requests = 0; - + pstr_drc_sel_proc_params->boost = 1.f; pstr_drc_sel_proc_params->compress = 1.f; pstr_drc_sel_proc_params->drc_characteristic_target = 0; - + return 0; } WORD32 impd_set_custom_params(const WORD32 param_set_idx, ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params) { WORD32 i, k; - + const ia_loc_sys_interface_struct* system_interface = &(loc_sys_interface[param_set_idx-1]); - + const ia_loc_loudness_norm_ctrl_interface_struct* loudness_norm_ctrl_interface = &(loc_loudness_norm_ctrl_interface[param_set_idx-1]); const ia_loc_loudness_norm_param_interface_struct* loudness_norm_param_interface = &(loc_loudness_norm_param_interface[param_set_idx-1]); - + const ia_loc_drc_interface_struct* drc_ctrl_interface = &(loc_dyn_range_ctrl_interface[param_set_idx-1]); const ia_loc_requested_drc_effect_struct* requested_drc_effect_type = &(loc_requested_drc_effect_type_str[param_set_idx-1]); const ia_loc_drc_parameter_interface_struct* drc_parameter_interface = &(loc_drc_parameter_interface[param_set_idx-1]); @@ -98,10 +98,10 @@ WORD32 impd_set_custom_params(const WORD32 param_set_idx, } break; } - + pstr_drc_sel_proc_params->loudness_normalization_on = loudness_norm_ctrl_interface->loudness_normalization_on; pstr_drc_sel_proc_params->target_loudness = loudness_norm_ctrl_interface->target_loudness; - + pstr_drc_sel_proc_params->album_mode = loudness_norm_param_interface->album_mode; pstr_drc_sel_proc_params->peak_limiter = loudness_norm_param_interface->peak_limiter; pstr_drc_sel_proc_params->loudness_deviation_max = loudness_norm_param_interface->loudness_deviation_max; @@ -142,19 +142,19 @@ WORD32 impd_set_custom_params(const WORD32 param_set_idx, return (UNEXPECTED_ERROR); } } - - pstr_drc_sel_proc_params->boost = drc_parameter_interface->boost; - pstr_drc_sel_proc_params->compress = drc_parameter_interface->compress; + + pstr_drc_sel_proc_params->boost = drc_parameter_interface->boost; + pstr_drc_sel_proc_params->compress = drc_parameter_interface->compress; pstr_drc_sel_proc_params->drc_characteristic_target = drc_parameter_interface->drc_characteristic_target; - + return (0); } WORD32 impd_eval_custom_params_selection_process(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params) { pstr_drc_sel_proc_params->loudness_norm_gain_db_max = max (0.0f, pstr_drc_sel_proc_params->loudness_norm_gain_db_max); pstr_drc_sel_proc_params->loudness_deviation_max = max (0, pstr_drc_sel_proc_params->loudness_deviation_max); - + return (0); } - + diff --git a/decoder/drc_src/impd_drc_host_params.h b/decoder/drc_src/impd_drc_host_params.h index 61b6970..111bd72 100644 --- a/decoder/drc_src/impd_drc_host_params.h +++ b/decoder/drc_src/impd_drc_host_params.h @@ -1,36 +1,36 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_HOST_PARAMS_H #define IMPD_DRC_HOST_PARAMS_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - + WORD32 impd_set_default_params_selection_process(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params); WORD32 impd_set_custom_params(const WORD32 param_set_idx, - ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params); + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params); WORD32 impd_eval_custom_params_selection_process(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params); - + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/decoder/drc_src/impd_drc_init.c b/decoder/drc_src/impd_drc_init.c index 77465ac..4542827 100644 --- a/decoder/drc_src/impd_drc_init.c +++ b/decoder/drc_src/impd_drc_init.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include "impd_type_def.h" @@ -43,31 +43,34 @@ #include "impd_drc_host_params.h" -#define PARAMETRIC_DRC_DELAY_MAX_DEFAULT 4096 -#define EQ_DELAY_MAX_DEFAULT 256 +#define PARAMETRIC_DRC_DELAY_MAX_DEFAULT 4096 +#define EQ_DELAY_MAX_DEFAULT 256 IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, - WORD32 iCmd, WORD32 iIdx, pVOID pvValue); + WORD32 iCmd, WORD32 iIdx, pVOID pvValue); IA_ERRORCODE impd_drc_fill_mem_tables(ia_drc_api_struct *p_obj_drc); WORD32 impd_drc_dec_interface_process( - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_interface_struct* pstr_drc_interface, UWORD8* it_bit_buf, WORD32 num_bit_stream_bits, WORD32* num_bits_read); +WORD32 +impd_drc_dec_interface_add_effect_type(ia_drc_interface_struct* pstr_drc_interface, + WORD32 drc_effect_type,WORD32 target_loudness, WORD32 loud_norm); #define NUM_GAIN_DEC_INSTANCES 2 #define BITSTREAM_FILE_FORMAT_SPLIT 1 -#define LIM_DEFAULT_THRESHOLD (0.89125094f) +#define LIM_DEFAULT_THRESHOLD (0.89125094f) static WORD32 impd_match_downmix(WORD32 downmix_id, WORD32 dec_downmix_id) -{ +{ WORD32 id_match = 0; switch (dec_downmix_id ) @@ -110,7 +113,10 @@ IA_ERRORCODE impd_drc_set_default_config(ia_drc_api_struct *p_obj_drc) p_obj_drc->str_config.absorb_delay_on = 1; p_obj_drc->str_config.subband_domain_io_flag = 0; p_obj_drc->str_config.constant_delay_on = 0; - p_obj_drc->str_config.audio_delay_samples = 0; + p_obj_drc->str_config.audio_delay_samples = 0; + p_obj_drc->str_config.effect_type = 0; + p_obj_drc->str_config.target_loudness = -24; + p_obj_drc->str_config.loud_norm_flag = 0; p_obj_drc->str_bit_handler.byte_index_bs = 0; p_obj_drc->str_bit_handler.num_bytes_bs = 0; p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; @@ -123,7 +129,7 @@ IA_ERRORCODE impd_drc_set_default_config(ia_drc_api_struct *p_obj_drc) p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface = 0; p_obj_drc->str_bit_handler.num_bits_read_bs_unidrc_interface = 0; p_obj_drc->str_bit_handler.cpy_over_in = 0; - p_obj_drc->str_bit_handler.gain_stream_flag = 0; + p_obj_drc->str_bit_handler.gain_stream_flag = 0; return IA_NO_ERROR; } @@ -131,118 +137,118 @@ IA_ERRORCODE impd_drc_set_default_config(ia_drc_api_struct *p_obj_drc) IA_ERRORCODE impd_drc_set_default_bitstream_config(ia_drc_config *pstr_drc_config) { - WORD32 i; + WORD32 i; - pstr_drc_config->sample_rate_present=0; - pstr_drc_config->sampling_rate=0; - pstr_drc_config->dwnmix_instructions_count=0; - pstr_drc_config->drc_coefficients_drc_count=1; - pstr_drc_config->drc_instructions_uni_drc_count=4; - pstr_drc_config->drc_instructions_count_plus=5; - pstr_drc_config->drc_description_basic_present=0; - pstr_drc_config->drc_coefficients_basic_count=0; - pstr_drc_config->drc_instructions_basic_count=0; - pstr_drc_config->drc_config_ext_present=1; - pstr_drc_config->apply_drc=0; - pstr_drc_config->str_drc_config_ext.drc_config_ext_type[0]=2; - pstr_drc_config->str_drc_config_ext.ext_bit_size[0]=345; - pstr_drc_config->str_drc_config_ext.parametric_drc_present=0; - pstr_drc_config->str_drc_config_ext.drc_extension_v1_present=1; - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].version=1; - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].drc_location=1; - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_count=4; - for(i=0;istr_p_loc_drc_coefficients_uni_drc[0].gain_set_count;i++) - { - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params[i].gain_interpolation_type=1; - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params[i].band_count=1; - } - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_sequence_count=4; - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[0]=0; - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[1]=1; - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[2]=2; - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[3]=3; - pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_count_plus=4; - pstr_drc_config->str_drc_instruction_str[0].drc_set_id=1; - pstr_drc_config->str_drc_instruction_str[0].drc_set_complexity_level=2; - pstr_drc_config->str_drc_instruction_str[0].drc_location=1; - pstr_drc_config->str_drc_instruction_str[0].dwnmix_id_count=1; - pstr_drc_config->str_drc_instruction_str[0].drc_set_effect=1; - pstr_drc_config->str_drc_instruction_str[0].gain_set_index[1]=1; - pstr_drc_config->str_drc_instruction_str[0].drc_set_target_loudness_value_lower=-63; - pstr_drc_config->str_drc_instruction_str[0].num_drc_ch_groups=2; - pstr_drc_config->str_drc_instruction_str[0].gain_set_index_for_channel_group[1]=1; - pstr_drc_config->str_drc_instruction_str[0].band_count_of_ch_group[0]=1; - pstr_drc_config->str_drc_instruction_str[0].band_count_of_ch_group[1]=1; - pstr_drc_config->str_drc_instruction_str[0].gain_interpolation_type_for_channel_group[0]=1; - pstr_drc_config->str_drc_instruction_str[0].gain_interpolation_type_for_channel_group[1]=1; - pstr_drc_config->str_drc_instruction_str[0].time_delta_min_for_channel_group[0]=32; - pstr_drc_config->str_drc_instruction_str[0].time_delta_min_for_channel_group[1]=32; - pstr_drc_config->str_drc_instruction_str[0].channel_group_of_ch[1]=1; - pstr_drc_config->str_drc_instruction_str[0].gain_element_count=2; + pstr_drc_config->sample_rate_present=0; + pstr_drc_config->sampling_rate=0; + pstr_drc_config->dwnmix_instructions_count=0; + pstr_drc_config->drc_coefficients_drc_count=1; + pstr_drc_config->drc_instructions_uni_drc_count=4; + pstr_drc_config->drc_instructions_count_plus=5; + pstr_drc_config->drc_description_basic_present=0; + pstr_drc_config->drc_coefficients_basic_count=0; + pstr_drc_config->drc_instructions_basic_count=0; + pstr_drc_config->drc_config_ext_present=1; + pstr_drc_config->apply_drc=0; + pstr_drc_config->str_drc_config_ext.drc_config_ext_type[0]=2; + pstr_drc_config->str_drc_config_ext.ext_bit_size[0]=345; + pstr_drc_config->str_drc_config_ext.parametric_drc_present=0; + pstr_drc_config->str_drc_config_ext.drc_extension_v1_present=1; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].version=1; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].drc_location=1; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_count=4; + for(i=0;istr_p_loc_drc_coefficients_uni_drc[0].gain_set_count;i++) + { + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params[i].gain_interpolation_type=1; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params[i].band_count=1; + } + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_sequence_count=4; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[0]=0; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[1]=1; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[2]=2; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_params_index_for_gain_sequence[3]=3; + pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0].gain_set_count_plus=4; + pstr_drc_config->str_drc_instruction_str[0].drc_set_id=1; + pstr_drc_config->str_drc_instruction_str[0].drc_set_complexity_level=2; + pstr_drc_config->str_drc_instruction_str[0].drc_location=1; + pstr_drc_config->str_drc_instruction_str[0].dwnmix_id_count=1; + pstr_drc_config->str_drc_instruction_str[0].drc_set_effect=1; + pstr_drc_config->str_drc_instruction_str[0].gain_set_index[1]=1; + pstr_drc_config->str_drc_instruction_str[0].drc_set_target_loudness_value_lower=-63; + pstr_drc_config->str_drc_instruction_str[0].num_drc_ch_groups=2; + pstr_drc_config->str_drc_instruction_str[0].gain_set_index_for_channel_group[1]=1; + pstr_drc_config->str_drc_instruction_str[0].band_count_of_ch_group[0]=1; + pstr_drc_config->str_drc_instruction_str[0].band_count_of_ch_group[1]=1; + pstr_drc_config->str_drc_instruction_str[0].gain_interpolation_type_for_channel_group[0]=1; + pstr_drc_config->str_drc_instruction_str[0].gain_interpolation_type_for_channel_group[1]=1; + pstr_drc_config->str_drc_instruction_str[0].time_delta_min_for_channel_group[0]=32; + pstr_drc_config->str_drc_instruction_str[0].time_delta_min_for_channel_group[1]=32; + pstr_drc_config->str_drc_instruction_str[0].channel_group_of_ch[1]=1; + pstr_drc_config->str_drc_instruction_str[0].gain_element_count=2; - pstr_drc_config->str_drc_instruction_str[1].drc_set_id=2; - pstr_drc_config->str_drc_instruction_str[1].drc_set_complexity_level=2; - pstr_drc_config->str_drc_instruction_str[1].drc_location=1; - pstr_drc_config->str_drc_instruction_str[1].dwnmix_id_count=1; - pstr_drc_config->str_drc_instruction_str[1].drc_set_effect=2; - pstr_drc_config->str_drc_instruction_str[1].gain_set_index[0]=1; - pstr_drc_config->str_drc_instruction_str[1].gain_set_index[1]=2; - pstr_drc_config->str_drc_instruction_str[1].drc_set_target_loudness_value_lower=-63; - pstr_drc_config->str_drc_instruction_str[1].num_drc_ch_groups=2; - pstr_drc_config->str_drc_instruction_str[1].gain_set_index_for_channel_group[0]=1; - pstr_drc_config->str_drc_instruction_str[1].gain_set_index_for_channel_group[1]=2; - pstr_drc_config->str_drc_instruction_str[1].band_count_of_ch_group[0]=1; - pstr_drc_config->str_drc_instruction_str[1].band_count_of_ch_group[1]=1; - pstr_drc_config->str_drc_instruction_str[1].gain_interpolation_type_for_channel_group[0]=1; - pstr_drc_config->str_drc_instruction_str[1].gain_interpolation_type_for_channel_group[1]=1; - pstr_drc_config->str_drc_instruction_str[1].time_delta_min_for_channel_group[0]=32; - pstr_drc_config->str_drc_instruction_str[1].time_delta_min_for_channel_group[1]=32; - pstr_drc_config->str_drc_instruction_str[1].channel_group_of_ch[1]=1; - pstr_drc_config->str_drc_instruction_str[1].gain_element_count=2; - - pstr_drc_config->str_drc_instruction_str[2].drc_set_id=3; - pstr_drc_config->str_drc_instruction_str[2].drc_set_complexity_level=2; - pstr_drc_config->str_drc_instruction_str[2].drc_location=1; - pstr_drc_config->str_drc_instruction_str[2].dwnmix_id_count=1; - pstr_drc_config->str_drc_instruction_str[2].drc_set_effect=4; - pstr_drc_config->str_drc_instruction_str[2].gain_set_index[0]=2; - pstr_drc_config->str_drc_instruction_str[2].gain_set_index[1]=3; - pstr_drc_config->str_drc_instruction_str[2].drc_set_target_loudness_value_lower=-63; - pstr_drc_config->str_drc_instruction_str[2].num_drc_ch_groups=2; - pstr_drc_config->str_drc_instruction_str[2].gain_set_index_for_channel_group[0]=2; - pstr_drc_config->str_drc_instruction_str[2].gain_set_index_for_channel_group[1]=3; - pstr_drc_config->str_drc_instruction_str[2].band_count_of_ch_group[0]=1; - pstr_drc_config->str_drc_instruction_str[2].band_count_of_ch_group[1]=1; - pstr_drc_config->str_drc_instruction_str[2].gain_interpolation_type_for_channel_group[0]=1; - pstr_drc_config->str_drc_instruction_str[2].gain_interpolation_type_for_channel_group[1]=1; - pstr_drc_config->str_drc_instruction_str[2].time_delta_min_for_channel_group[0]=32; - pstr_drc_config->str_drc_instruction_str[2].time_delta_min_for_channel_group[1]=32; - pstr_drc_config->str_drc_instruction_str[2].channel_group_of_ch[1]=1; - pstr_drc_config->str_drc_instruction_str[2].gain_element_count=2; - - pstr_drc_config->str_drc_instruction_str[3].drc_set_id=4; - pstr_drc_config->str_drc_instruction_str[3].drc_set_complexity_level=2; - pstr_drc_config->str_drc_instruction_str[3].drc_location=1; - pstr_drc_config->str_drc_instruction_str[3].dwnmix_id_count=1; - pstr_drc_config->str_drc_instruction_str[3].drc_set_effect=32; - pstr_drc_config->str_drc_instruction_str[3].gain_set_index[0]=3; - pstr_drc_config->str_drc_instruction_str[3].gain_set_index[1]=0; - pstr_drc_config->str_drc_instruction_str[3].drc_set_target_loudness_value_lower=-63; - pstr_drc_config->str_drc_instruction_str[3].num_drc_ch_groups=2; - pstr_drc_config->str_drc_instruction_str[3].gain_set_index_for_channel_group[0]=3; - pstr_drc_config->str_drc_instruction_str[3].gain_set_index_for_channel_group[1]=0; - pstr_drc_config->str_drc_instruction_str[3].band_count_of_ch_group[0]=1; - pstr_drc_config->str_drc_instruction_str[3].band_count_of_ch_group[1]=1; - pstr_drc_config->str_drc_instruction_str[3].gain_interpolation_type_for_channel_group[0]=1; - pstr_drc_config->str_drc_instruction_str[3].gain_interpolation_type_for_channel_group[1]=1; - pstr_drc_config->str_drc_instruction_str[3].time_delta_min_for_channel_group[0]=32; - pstr_drc_config->str_drc_instruction_str[3].time_delta_min_for_channel_group[1]=32; - pstr_drc_config->str_drc_instruction_str[3].channel_group_of_ch[1]=1; - pstr_drc_config->str_drc_instruction_str[3].gain_element_count=2; - - pstr_drc_config->str_drc_instruction_str[4].drc_set_id=-1; - pstr_drc_config->str_drc_instruction_str[4].dwnmix_id_count=1; - pstr_drc_config->channel_layout.base_channel_count=2; + pstr_drc_config->str_drc_instruction_str[1].drc_set_id=2; + pstr_drc_config->str_drc_instruction_str[1].drc_set_complexity_level=2; + pstr_drc_config->str_drc_instruction_str[1].drc_location=1; + pstr_drc_config->str_drc_instruction_str[1].dwnmix_id_count=1; + pstr_drc_config->str_drc_instruction_str[1].drc_set_effect=2; + pstr_drc_config->str_drc_instruction_str[1].gain_set_index[0]=1; + pstr_drc_config->str_drc_instruction_str[1].gain_set_index[1]=2; + pstr_drc_config->str_drc_instruction_str[1].drc_set_target_loudness_value_lower=-63; + pstr_drc_config->str_drc_instruction_str[1].num_drc_ch_groups=2; + pstr_drc_config->str_drc_instruction_str[1].gain_set_index_for_channel_group[0]=1; + pstr_drc_config->str_drc_instruction_str[1].gain_set_index_for_channel_group[1]=2; + pstr_drc_config->str_drc_instruction_str[1].band_count_of_ch_group[0]=1; + pstr_drc_config->str_drc_instruction_str[1].band_count_of_ch_group[1]=1; + pstr_drc_config->str_drc_instruction_str[1].gain_interpolation_type_for_channel_group[0]=1; + pstr_drc_config->str_drc_instruction_str[1].gain_interpolation_type_for_channel_group[1]=1; + pstr_drc_config->str_drc_instruction_str[1].time_delta_min_for_channel_group[0]=32; + pstr_drc_config->str_drc_instruction_str[1].time_delta_min_for_channel_group[1]=32; + pstr_drc_config->str_drc_instruction_str[1].channel_group_of_ch[1]=1; + pstr_drc_config->str_drc_instruction_str[1].gain_element_count=2; + + pstr_drc_config->str_drc_instruction_str[2].drc_set_id=3; + pstr_drc_config->str_drc_instruction_str[2].drc_set_complexity_level=2; + pstr_drc_config->str_drc_instruction_str[2].drc_location=1; + pstr_drc_config->str_drc_instruction_str[2].dwnmix_id_count=1; + pstr_drc_config->str_drc_instruction_str[2].drc_set_effect=4; + pstr_drc_config->str_drc_instruction_str[2].gain_set_index[0]=2; + pstr_drc_config->str_drc_instruction_str[2].gain_set_index[1]=3; + pstr_drc_config->str_drc_instruction_str[2].drc_set_target_loudness_value_lower=-63; + pstr_drc_config->str_drc_instruction_str[2].num_drc_ch_groups=2; + pstr_drc_config->str_drc_instruction_str[2].gain_set_index_for_channel_group[0]=2; + pstr_drc_config->str_drc_instruction_str[2].gain_set_index_for_channel_group[1]=3; + pstr_drc_config->str_drc_instruction_str[2].band_count_of_ch_group[0]=1; + pstr_drc_config->str_drc_instruction_str[2].band_count_of_ch_group[1]=1; + pstr_drc_config->str_drc_instruction_str[2].gain_interpolation_type_for_channel_group[0]=1; + pstr_drc_config->str_drc_instruction_str[2].gain_interpolation_type_for_channel_group[1]=1; + pstr_drc_config->str_drc_instruction_str[2].time_delta_min_for_channel_group[0]=32; + pstr_drc_config->str_drc_instruction_str[2].time_delta_min_for_channel_group[1]=32; + pstr_drc_config->str_drc_instruction_str[2].channel_group_of_ch[1]=1; + pstr_drc_config->str_drc_instruction_str[2].gain_element_count=2; + + pstr_drc_config->str_drc_instruction_str[3].drc_set_id=4; + pstr_drc_config->str_drc_instruction_str[3].drc_set_complexity_level=2; + pstr_drc_config->str_drc_instruction_str[3].drc_location=1; + pstr_drc_config->str_drc_instruction_str[3].dwnmix_id_count=1; + pstr_drc_config->str_drc_instruction_str[3].drc_set_effect=32; + pstr_drc_config->str_drc_instruction_str[3].gain_set_index[0]=3; + pstr_drc_config->str_drc_instruction_str[3].gain_set_index[1]=0; + pstr_drc_config->str_drc_instruction_str[3].drc_set_target_loudness_value_lower=-63; + pstr_drc_config->str_drc_instruction_str[3].num_drc_ch_groups=2; + pstr_drc_config->str_drc_instruction_str[3].gain_set_index_for_channel_group[0]=3; + pstr_drc_config->str_drc_instruction_str[3].gain_set_index_for_channel_group[1]=0; + pstr_drc_config->str_drc_instruction_str[3].band_count_of_ch_group[0]=1; + pstr_drc_config->str_drc_instruction_str[3].band_count_of_ch_group[1]=1; + pstr_drc_config->str_drc_instruction_str[3].gain_interpolation_type_for_channel_group[0]=1; + pstr_drc_config->str_drc_instruction_str[3].gain_interpolation_type_for_channel_group[1]=1; + pstr_drc_config->str_drc_instruction_str[3].time_delta_min_for_channel_group[0]=32; + pstr_drc_config->str_drc_instruction_str[3].time_delta_min_for_channel_group[1]=32; + pstr_drc_config->str_drc_instruction_str[3].channel_group_of_ch[1]=1; + pstr_drc_config->str_drc_instruction_str[3].gain_element_count=2; + + pstr_drc_config->str_drc_instruction_str[4].drc_set_id=-1; + pstr_drc_config->str_drc_instruction_str[4].dwnmix_id_count=1; + pstr_drc_config->channel_layout.base_channel_count=2; return IA_NO_ERROR; } @@ -251,61 +257,61 @@ IA_ERRORCODE impd_drc_set_default_bitstream_config(ia_drc_config *pstr_drc_confi IA_ERRORCODE impd_drc_set_struct_pointer(ia_drc_api_struct *p_obj_drc) { SIZE_T persistant_ptr = (SIZE_T)p_obj_drc->p_state->persistant_ptr; - + p_obj_drc->str_payload.pstr_bitstream_dec = (ia_drc_bits_dec_struct*)persistant_ptr; - persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_bits_dec_struct)+32; - + persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_bits_dec_struct)+32; + p_obj_drc->str_payload.pstr_gain_dec[0] = (ia_drc_gain_dec_struct*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_gain_dec_struct)+32; - + p_obj_drc->str_payload.pstr_gain_dec[1] = (ia_drc_gain_dec_struct*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_gain_dec_struct)+32; - + p_obj_drc->str_payload.pstr_loudness_info = (ia_drc_loudness_info_set_struct*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_loudness_info_set_struct)+32; - + p_obj_drc->str_payload.pstr_drc_gain = (ia_drc_gain_struct*)persistant_ptr;; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_gain_struct)+32; - + p_obj_drc->str_payload.pstr_drc_interface = (ia_drc_interface_struct*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_interface_struct)+32; - + p_obj_drc->str_payload.pstr_drc_config = (ia_drc_config*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_config)+32; - + p_obj_drc->str_payload.pstr_selection_proc = (ia_drc_sel_pro_struct*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_sel_pro_struct)+32; - + p_obj_drc->str_bit_handler.it_bit_buf = (UWORD8*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + 32*1024; /*varify the sizelater*/ - + p_obj_drc->str_payload.pstr_drc_sel_proc_params = (ia_drc_sel_proc_params_struct*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_sel_proc_params_struct); - + p_obj_drc->str_payload.pstr_drc_sel_proc_output = (ia_drc_sel_proc_output_struct*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_sel_proc_output_struct)+16*1024; - + p_obj_drc->str_bit_handler.bitstream_drc_config = (UWORD8*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + 8*1024; - + p_obj_drc->str_bit_handler.bitstream_loudness_info = (UWORD8*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + 8*1024; - + p_obj_drc->str_bit_handler.bitstream_unidrc_interface = (UWORD8*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + 8*1024; p_obj_drc->str_payload.pstr_peak_limiter = (ia_drc_peak_limiter_struct*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_peak_limiter_struct)+32; - - p_obj_drc->str_payload.pstr_peak_limiter->buffer = (FLOAT32*)((SIZE_T) p_obj_drc->str_payload.pstr_peak_limiter+sizeof(ia_drc_peak_limiter_struct)+32); + + p_obj_drc->str_payload.pstr_peak_limiter->buffer = (FLOAT32*)((SIZE_T) p_obj_drc->str_payload.pstr_peak_limiter+sizeof(ia_drc_peak_limiter_struct)+32); persistant_ptr = (SIZE_T)persistant_ptr + 16*1024; - - p_obj_drc->str_payload.pstr_qmf_filter = (ia_drc_qmf_filt_struct*)persistant_ptr; + + p_obj_drc->str_payload.pstr_qmf_filter = (ia_drc_qmf_filt_struct*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + sizeof(ia_drc_qmf_filt_struct)+32; - - p_obj_drc->str_payload.pstr_qmf_filter->ana_buff = (FLOAT64*)persistant_ptr; + + p_obj_drc->str_payload.pstr_qmf_filter->ana_buff = (FLOAT64*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + 16*1024; - + p_obj_drc->str_payload.pstr_qmf_filter->syn_buff = (FLOAT64*)persistant_ptr; persistant_ptr = (SIZE_T)persistant_ptr + 16*1024; @@ -320,16 +326,16 @@ VOID init_qmf_filt_bank(ia_drc_qmf_filt_struct *qmf_filt) FLOAT64 gain_ana =64.0 / QMF_FILT_RESOLUTION; FLOAT64 gain_syn =1.0 / 64.0; - for ( l=0; l<2*QMF_FILT_RESOLUTION; l++ ) + for ( l=0; l<2*QMF_FILT_RESOLUTION; l++ ) { - for ( k=0; ksyn_tab_real[l][k] = gain_syn * cos((0.0245436926) * (k+0.5) * (2*l-255.0)); qmf_filt->syn_tab_imag[l][k] = gain_syn * sin((0.0245436926) * (k+0.5) * (2*l-255.0)); qmf_filt->ana_tab_real[k][l] = gain_ana * cos((0.0245436926) * (k+0.5) * (2*l-1.0)); - qmf_filt->ana_tab_imag[k][l] = gain_ana * sin((0.0245436926) * (k+0.5) * (2*l-1.0)); + qmf_filt->ana_tab_imag[k][l] = gain_ana * sin((0.0245436926) * (k+0.5) * (2*l-1.0)); } - } + } } @@ -341,127 +347,130 @@ IA_ERRORCODE impd_drc_init(ia_drc_api_struct *p_obj_drc){ IA_ERRORCODE err_code = IA_NO_ERROR; WORD32 i,j; - pVOID persistant_ptr =p_obj_drc->p_state->persistant_ptr; + pVOID persistant_ptr =p_obj_drc->p_state->persistant_ptr; + + struct ia_bit_buf_struct *it_bit_buff; - struct ia_bit_buf_struct *it_bit_buff; - WORD32 decDownmixIdList[NUM_GAIN_DEC_INSTANCES] = { 0, 4 }; - - p_obj_drc->p_state->delay_in_output =0; + + p_obj_drc->p_state->delay_in_output =0; p_obj_drc->str_payload.pstr_selection_proc->first_frame=1; - - - p_obj_drc->pstr_bit_buf = impd_create_init_bit_buf(&p_obj_drc->str_bit_buf, p_obj_drc->str_bit_handler.it_bit_buf, p_obj_drc->str_bit_handler.num_bytes_bs/8); - it_bit_buff = p_obj_drc->pstr_bit_buf; - err_code = impd_init_drc_bitstream_dec(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->str_config.sampling_rate, - p_obj_drc->str_config.frame_size, - p_obj_drc->str_config.delay_mode, - -1, + p_obj_drc->pstr_bit_buf = impd_create_init_bit_buf(&p_obj_drc->str_bit_buf, p_obj_drc->str_bit_handler.it_bit_buf, p_obj_drc->str_bit_handler.num_bytes_bs/8); + it_bit_buff = p_obj_drc->pstr_bit_buf; + + + err_code = impd_init_drc_bitstream_dec(p_obj_drc->str_payload.pstr_bitstream_dec, + p_obj_drc->str_config.sampling_rate, + p_obj_drc->str_config.frame_size, + p_obj_drc->str_config.delay_mode, + -1, 0); - for (i=0; istr_config.frame_size, p_obj_drc->str_config.sampling_rate, p_obj_drc->str_config.gain_delay_samples, p_obj_drc->str_config.delay_mode, p_obj_drc->str_config.sub_band_domain_mode, p_obj_drc->str_payload.pstr_gain_dec[i]); - - } + + } if (p_obj_drc->str_config.interface_bitstream_present) { - err_code = impd_drc_dec_interface_process( - p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_drc_interface, - p_obj_drc->str_bit_handler.bitstream_unidrc_interface, - p_obj_drc->str_bit_handler.num_bytes_bs_unidrc_interface*8, - &p_obj_drc->str_bit_handler.num_bits_read_bs_unidrc_interface); - - if (err_code!=IA_NO_ERROR) + + err_code = impd_drc_dec_interface_add_effect_type(p_obj_drc->str_payload.pstr_drc_interface, + p_obj_drc->str_config.effect_type, + p_obj_drc->str_config.target_loudness, + p_obj_drc->str_config.loud_norm_flag); + + + + if (err_code!=IA_NO_ERROR) return err_code; - - err_code = impd_drc_uni_selction_proc_init(p_obj_drc->str_payload.pstr_selection_proc, - 0, - p_obj_drc->str_payload.pstr_drc_interface, + + err_code = impd_drc_uni_selction_proc_init(p_obj_drc->str_payload.pstr_selection_proc, + 0, + p_obj_drc->str_payload.pstr_drc_interface, p_obj_drc->str_config.sub_band_domain_mode); - if (err_code!=IA_NO_ERROR) + if (err_code!=IA_NO_ERROR) return err_code; - + if (p_obj_drc->str_payload.pstr_drc_interface->loudness_norm_parameter_interface_flag && p_obj_drc->str_payload.pstr_drc_interface->loudness_norm_param_interface.peak_limiter) { p_obj_drc->str_config.peak_limiter = 1; } } - else { + else { err_code = impd_set_default_params_selection_process(p_obj_drc->str_payload.pstr_drc_sel_proc_params); - if (err_code!=IA_NO_ERROR) + if (err_code!=IA_NO_ERROR) return err_code; err_code = impd_set_custom_params(p_obj_drc->str_config.control_parameter_index,p_obj_drc->str_payload.pstr_drc_sel_proc_params); - if (err_code!=IA_NO_ERROR) + if (err_code!=IA_NO_ERROR) return err_code; err_code = impd_eval_custom_params_selection_process(p_obj_drc->str_payload.pstr_drc_sel_proc_params); - if (err_code!=IA_NO_ERROR) + if (err_code!=IA_NO_ERROR) return err_code; err_code = impd_drc_uni_selction_proc_init(p_obj_drc->str_payload.pstr_selection_proc, p_obj_drc->str_payload.pstr_drc_sel_proc_params, 0, p_obj_drc->str_config.sub_band_domain_mode); - if (err_code!=IA_NO_ERROR) + if (err_code!=IA_NO_ERROR) return err_code; if (p_obj_drc->str_payload.pstr_drc_sel_proc_params->peak_limiter) { p_obj_drc->str_config.peak_limiter = 1; - } - } - p_obj_drc->str_payload.pstr_loudness_info->loudness_info_album_count=0; - p_obj_drc->str_payload.pstr_loudness_info->loudness_info_count=0; + } + } + p_obj_drc->str_payload.pstr_loudness_info->loudness_info_album_count=0; + p_obj_drc->str_payload.pstr_loudness_info->loudness_info_count=0; p_obj_drc->str_payload.pstr_loudness_info->loudness_info_set_ext_present=0; p_obj_drc->p_state->ui_exe_done =0; - + if(p_obj_drc->str_config.bitstream_file_format == BITSTREAM_FILE_FORMAT_SPLIT) { - + err_code = impd_process_drc_bitstream_dec_config(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->pstr_bit_buf, + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_drc_config, &p_obj_drc->str_bit_handler.bitstream_drc_config[0], p_obj_drc->str_bit_handler.num_bytes_bs_drc_config); - if(err_code==1) - { - err_code=impd_drc_set_default_bitstream_config(p_obj_drc->str_payload.pstr_drc_config); - } + if(err_code==1) + { + err_code=impd_drc_set_default_bitstream_config(p_obj_drc->str_payload.pstr_drc_config); + p_obj_drc->str_payload.pstr_drc_config->channel_layout.base_channel_count = + p_obj_drc->str_config.num_ch_in; + } - if (err_code!=IA_NO_ERROR) + if (err_code!=IA_NO_ERROR) return err_code; err_code = impd_process_drc_bitstream_dec_loudness_info_set(p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_loudness_info, + p_obj_drc->str_payload.pstr_loudness_info, &p_obj_drc->str_bit_handler.bitstream_loudness_info[0], - p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info + p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info ); - if (err_code!=IA_NO_ERROR) + if (err_code!=IA_NO_ERROR) return err_code; - + } else { err_code = impd_process_drc_bitstream_dec(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->pstr_bit_buf, + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_loudness_info, &p_obj_drc->str_bit_handler.it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], p_obj_drc->str_bit_handler.num_bytes_bs, p_obj_drc->str_bit_handler.num_bits_offset_bs, &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (err_code > PROC_COMPLETE) + + if (err_code > PROC_COMPLETE) return -1; - + p_obj_drc->str_bit_handler.num_bytes_read_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); p_obj_drc->str_bit_handler.num_bits_offset_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); p_obj_drc->str_bit_handler.byte_index_bs += p_obj_drc->str_bit_handler.num_bytes_read_bs; @@ -473,7 +482,7 @@ IA_ERRORCODE impd_drc_init(ia_drc_api_struct *p_obj_drc){ p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_loudness_info, p_obj_drc->str_payload.pstr_drc_sel_proc_output); - if (err_code!=IA_NO_ERROR) + if (err_code!=IA_NO_ERROR) return err_code; for (i=0; istr_config.num_ch_in != p_obj_drc->str_payload.pstr_drc_sel_proc_output->base_channel_count) - + return -1; audio_num_chan = p_obj_drc->str_config.num_ch_in; - } else if (i==1) + } else if (i==1) { p_obj_drc->str_config.num_ch_out = p_obj_drc->str_payload.pstr_drc_sel_proc_output->target_channel_count; audio_num_chan = p_obj_drc->str_config.num_ch_out; } - + err_code = impd_init_drc_decode_post_config(audio_num_chan, matchingDrcSetIds, matchingDownmixIds, @@ -510,9 +519,9 @@ IA_ERRORCODE impd_drc_init(ia_drc_api_struct *p_obj_drc){ , p_obj_drc->str_payload.pstr_gain_dec[i] , p_obj_drc->str_payload.pstr_drc_config , p_obj_drc->str_payload.pstr_loudness_info - , &persistant_ptr + , &persistant_ptr ); - + impd_get_parametric_drc_delay(p_obj_drc->str_payload.pstr_gain_dec[i], p_obj_drc->str_payload.pstr_drc_config, & p_obj_drc->str_config.parametric_drc_delay_gain_dec_instance, &p_obj_drc->str_config.parametric_drc_delay_max); impd_get_eq_delay(p_obj_drc->str_payload.pstr_gain_dec[i], p_obj_drc->str_payload.pstr_drc_config, & p_obj_drc->str_config.eq_delay_gain_dec_instance, & p_obj_drc->str_config.eq_delay_max); p_obj_drc->str_config.parametric_drc_delay += p_obj_drc->str_config.parametric_drc_delay_gain_dec_instance; @@ -527,42 +536,42 @@ IA_ERRORCODE impd_drc_init(ia_drc_api_struct *p_obj_drc){ if (p_obj_drc->str_config.eq_delay_max == -1) { p_obj_drc->str_config.eq_delay_max = EQ_DELAY_MAX_DEFAULT; } - + if (!p_obj_drc->str_config.constant_delay_on) { - + p_obj_drc->p_state->delay_in_output += p_obj_drc->str_config.parametric_drc_delay + p_obj_drc->str_config.eq_delay + p_obj_drc->str_config.audio_delay_samples; p_obj_drc->str_config.delay_line_samples = p_obj_drc->str_config.audio_delay_samples; - + if (!p_obj_drc->str_config.absorb_delay_on) { p_obj_drc->p_state->delay_in_output = 0; } } else { p_obj_drc->p_state->delay_in_output += p_obj_drc->str_config.parametric_drc_delay_max + p_obj_drc->str_config.eq_delay_max + p_obj_drc->str_config.audio_delay_samples; p_obj_drc->str_config.delay_line_samples = p_obj_drc->p_state->delay_in_output - p_obj_drc->str_config.parametric_drc_delay + p_obj_drc->str_config.eq_delay; - + if (!p_obj_drc->str_config.absorb_delay_on ) { p_obj_drc->p_state->delay_in_output = 0; } } - + } - if(p_obj_drc->str_config.dec_type==1) + if(p_obj_drc->str_config.dec_type==1) { - init_qmf_filt_bank(p_obj_drc->str_payload.pstr_qmf_filter); + init_qmf_filt_bank(p_obj_drc->str_payload.pstr_qmf_filter); } - + if (p_obj_drc->str_config.peak_limiter) { impd_peak_limiter_init(p_obj_drc->str_payload.pstr_peak_limiter, - DEFAULT_ATTACK_TIME_MS, + DEFAULT_ATTACK_TIME_MS, DEFAULT_RELEASE_TIME_MS, LIM_DEFAULT_THRESHOLD, p_obj_drc->str_config.num_ch_out, p_obj_drc->str_config.sampling_rate, - p_obj_drc->str_payload.pstr_peak_limiter->buffer); + p_obj_drc->str_payload.pstr_peak_limiter->buffer); } - - return IA_NO_ERROR; + + return IA_NO_ERROR; } diff --git a/decoder/drc_src/impd_drc_interface.h b/decoder/drc_src/impd_drc_interface.h index 875ddb6..9062eb3 100644 --- a/decoder/drc_src/impd_drc_interface.h +++ b/decoder/drc_src/impd_drc_interface.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_INTERFACE_H #define IMPD_DRC_INTERFACE_H @@ -76,7 +76,7 @@ typedef struct { WORD32 album_mode; WORD32 peak_limiter; WORD32 change_loudness_deviation_max; - WORD32 loudness_deviation_max; + WORD32 loudness_deviation_max; WORD32 change_loudness_measur_method; WORD32 loudness_measurement_method; WORD32 change_loudness_measur_system; diff --git a/decoder/drc_src/impd_drc_interface_decoder.c b/decoder/drc_src/impd_drc_interface_decoder.c index a880959..dd0d5e6 100644 --- a/decoder/drc_src/impd_drc_interface_decoder.c +++ b/decoder/drc_src/impd_drc_interface_decoder.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -31,27 +31,138 @@ WORD32 impd_drc_dec_interface_process( - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_interface_struct* pstr_drc_interface, UWORD8* it_bit_buf, WORD32 num_bit_stream_bits, WORD32* num_bits_read) { WORD32 err = 0; - + if (it_bit_buff != NULL && num_bit_stream_bits) { - it_bit_buff = impd_create_init_bit_buf(it_bit_buff, it_bit_buf, num_bit_stream_bits/8); + it_bit_buff = impd_create_init_bit_buf(it_bit_buff, it_bit_buf, num_bit_stream_bits/8); } else { return -1; } - + err = impd_unidrc_interface_read(it_bit_buff, pstr_drc_interface); if (err) return(err); - + *num_bits_read = (it_bit_buff->size ) - it_bit_buff->cnt_bits; - + return err; - + } + +WORD32 +impd_drc_dec_interface_add_effect_type(ia_drc_interface_struct* pstr_drc_interface, + WORD32 drc_effect_type, + WORD32 target_loudness, + WORD32 loud_norm) +{ + WORD32 err = 0; + WORD32 i = 0; + + if (pstr_drc_interface != NULL) + { + pstr_drc_interface->interface_signat_flag = 0; + for(i=0;idrc_uni_interface_signature.interface_signat_data[i] = 0; + + pstr_drc_interface->drc_uni_interface_signature.interface_signat_data_len = 0; + + pstr_drc_interface->system_interface_flag = 1; + + pstr_drc_interface->system_interface.target_config_request_type = 0; + pstr_drc_interface->system_interface.num_downmix_id_requests = 0; + for (i = 0; i < MAX_NUM_DOWNMIX_ID_REQUESTS; i++) + { + pstr_drc_interface->system_interface.requested_dwnmix_id[i] = 0; + } + pstr_drc_interface->system_interface.requested_target_layout = 0; + pstr_drc_interface->system_interface.requested_target_ch_count = 0; + + pstr_drc_interface->loudness_norm_ctrl_interface_flag= 1; + if(loud_norm==1) + { + pstr_drc_interface->loudness_norm_ctrl_interface.loudness_normalization_on = 1; + } + else + { + pstr_drc_interface->loudness_norm_ctrl_interface.loudness_normalization_on = 0; + } + pstr_drc_interface->loudness_norm_ctrl_interface.target_loudness = (FLOAT32)target_loudness; + + pstr_drc_interface->loudness_norm_parameter_interface_flag = 1; + pstr_drc_interface->loudness_norm_param_interface.album_mode = 0; + pstr_drc_interface->loudness_norm_param_interface.peak_limiter = 0; + pstr_drc_interface->loudness_norm_param_interface.change_loudness_deviation_max = 1; + pstr_drc_interface->loudness_norm_param_interface.loudness_deviation_max = 63; + pstr_drc_interface->loudness_norm_param_interface.change_loudness_measur_method = 1; + pstr_drc_interface->loudness_norm_param_interface.loudness_measurement_method = 1; + pstr_drc_interface->loudness_norm_param_interface.change_loudness_measur_system = 1; + pstr_drc_interface->loudness_norm_param_interface.loudness_measurement_system = 1; + pstr_drc_interface->loudness_norm_param_interface.change_loudness_measur_pre_proc = 0; + pstr_drc_interface->loudness_norm_param_interface.loudness_measurement_pre_proc = 0; + pstr_drc_interface->loudness_norm_param_interface.change_device_cut_off_freq = 1; + pstr_drc_interface->loudness_norm_param_interface.device_cut_off_frequency = 20; + pstr_drc_interface->loudness_norm_param_interface.change_loudness_norm_gain_db_max = 1; + pstr_drc_interface->loudness_norm_param_interface.loudness_norm_gain_db_max = 1000.0; + pstr_drc_interface->loudness_norm_param_interface.change_loudness_norm_gain_modification_db = 1; + pstr_drc_interface->loudness_norm_param_interface.loudness_norm_gain_modification_db = 0.0; + pstr_drc_interface->loudness_norm_param_interface.change_output_peak_level_max = 1; + pstr_drc_interface->loudness_norm_param_interface.output_peak_level_max = 0.0; + + pstr_drc_interface->drc_interface_flag = 1; + if(drc_effect_type==-1) + { + pstr_drc_interface->drc_ctrl_interface.dynamic_range_control_on=0; + pstr_drc_interface->drc_ctrl_interface.requested_drc_effect_type[0][0] = 0; + } + else if(drc_effect_type==0) + { + pstr_drc_interface->drc_ctrl_interface.dynamic_range_control_on=1; + pstr_drc_interface->drc_ctrl_interface.num_drc_feature_requests = 0; + } + else + { + pstr_drc_interface->drc_ctrl_interface.dynamic_range_control_on = 1; + pstr_drc_interface->drc_ctrl_interface.requested_drc_effect_type[0][0] = drc_effect_type; + pstr_drc_interface->drc_ctrl_interface.num_drc_feature_requests = 3; + pstr_drc_interface->drc_ctrl_interface.drc_feature_req_type[0] = 0; + pstr_drc_interface->drc_ctrl_interface.drc_feature_req_type[1] = 1; + pstr_drc_interface->drc_ctrl_interface.drc_feature_req_type[2] = 2; + pstr_drc_interface->drc_ctrl_interface.requested_num_drc_effects[0] = 1; + pstr_drc_interface->drc_ctrl_interface.desired_num_drc_effects_of_requested[0] = 1; + } + + pstr_drc_interface->drc_ctrl_interface.requested_dyn_rng_measurement_type[0] = 0; + pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_is_single_val_flag[0] = 0; + pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_is_single_val_flag[1] = 0; + pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_min_val[1] = 3.0f; + pstr_drc_interface->drc_ctrl_interface.requested_dyn_range_max_val[1] = 10.0f; + pstr_drc_interface->drc_ctrl_interface.requested_drc_characteristic[2] = 3; + + pstr_drc_interface->drc_parameter_interface_flag = 1; + pstr_drc_interface->drc_parameter_interface.change_compress = 1; + pstr_drc_interface->drc_parameter_interface.change_boost = 1; + pstr_drc_interface->drc_parameter_interface.compress = 1.0f; + pstr_drc_interface->drc_parameter_interface.boost = 1.0f; + pstr_drc_interface->drc_parameter_interface.change_drc_characteristic_target = 1; + pstr_drc_interface->drc_parameter_interface.drc_characteristic_target = 0; + + + pstr_drc_interface->drc_uni_interface_ext_flag = 0; + + + } + else + { + return UNEXPECTED_ERROR; + } + + + return err; +} diff --git a/decoder/drc_src/impd_drc_interface_parser.c b/decoder/drc_src/impd_drc_interface_parser.c index 27cec33..87dccdd 100644 --- a/decoder/drc_src/impd_drc_interface_parser.c +++ b/decoder/drc_src/impd_drc_interface_parser.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -32,61 +32,61 @@ WORD32 impd_unidrc_interface_signature_read(ia_bit_buf_struct* it_bit_buff, ia_drc_uni_interface_signat_struct* drc_uni_interface_signature) { //WORD32 err = 0 - WORD32 interface_signat_data_len = 0, i, tmp; + WORD32 interface_signat_data_len = 0, i, tmp; - tmp = impd_read_bits_buf(it_bit_buff, 16); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 16); + if(it_bit_buff->error) + return it_bit_buff->error; + + drc_uni_interface_signature->interface_signat_type = (tmp>>8)&0xff; + drc_uni_interface_signature->interface_signat_data_len = tmp&0xff; - drc_uni_interface_signature->interface_signat_type = (tmp>>8)&0xff; - drc_uni_interface_signature->interface_signat_data_len = tmp&0xff; - interface_signat_data_len = drc_uni_interface_signature->interface_signat_data_len + 1; for (i=0; ierror) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; drc_uni_interface_signature->interface_signat_data[i] = (UWORD32)tmp; } - + return(0); } WORD32 impd_sys_interface_read(ia_bit_buf_struct* it_bit_buff, ia_system_interface_struct* system_interface) { - //WORD32 err = 0; - WORD32 i = 0, tmp = 0; - - system_interface->target_config_request_type = impd_read_bits_buf(it_bit_buff, 2); - if(it_bit_buff->error) - return it_bit_buff->error; - + //WORD32 err = 0; + WORD32 i = 0, tmp = 0; + + system_interface->target_config_request_type = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; + switch (system_interface->target_config_request_type) { case 0: - system_interface->num_downmix_id_requests = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - + system_interface->num_downmix_id_requests = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + if (system_interface->num_downmix_id_requests == 0) { system_interface->num_downmix_id_requests = 1; system_interface->requested_dwnmix_id[0] = 0; break; } for (i=0; inum_downmix_id_requests; i++) { - system_interface->requested_dwnmix_id[i] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + system_interface->requested_dwnmix_id[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; } break; case 1: - system_interface->requested_target_layout = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + system_interface->requested_target_layout = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; break; case 2: - tmp = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; system_interface->requested_target_ch_count = tmp + 1; break; default: @@ -100,16 +100,16 @@ WORD32 impd_loudness_norm_control_interface_read(ia_bit_buf_struct* it_bit_buff, ia_loudness_norm_ctrl_interface_struct* loudness_norm_ctrl_interface) { //WORD32 err = 0; - WORD32 tmp = 0; - - loudness_norm_ctrl_interface->loudness_normalization_on = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - + WORD32 tmp = 0; + + loudness_norm_ctrl_interface->loudness_normalization_on = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (loudness_norm_ctrl_interface->loudness_normalization_on == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 12); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; loudness_norm_ctrl_interface->target_loudness = - tmp * 0.03125f; } return(0); @@ -119,93 +119,93 @@ WORD32 impd_loudness_norm_param_interface_read(ia_bit_buf_struct* it_bit_buff, ia_loudness_norm_parameter_interface_struct* loudness_norm_param_interface) { //WORD32 err = 0; - WORD32 tmp = 0; - - tmp = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; - - loudness_norm_param_interface->album_mode = (tmp>>2)&1; - loudness_norm_param_interface->peak_limiter = (tmp>>1)&1; - loudness_norm_param_interface->change_loudness_deviation_max = tmp&1; + WORD32 tmp = 0; + + tmp = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + + loudness_norm_param_interface->album_mode = (tmp>>2)&1; + loudness_norm_param_interface->peak_limiter = (tmp>>1)&1; + loudness_norm_param_interface->change_loudness_deviation_max = tmp&1; if (loudness_norm_param_interface->change_loudness_deviation_max == 1) { - loudness_norm_param_interface->loudness_deviation_max = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + loudness_norm_param_interface->loudness_deviation_max = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; } - - loudness_norm_param_interface->change_loudness_measur_method = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + loudness_norm_param_interface->change_loudness_measur_method = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (loudness_norm_param_interface->change_loudness_measur_method == 1) { - loudness_norm_param_interface->loudness_measurement_method = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; + loudness_norm_param_interface->loudness_measurement_method = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; } - - loudness_norm_param_interface->change_loudness_measur_system = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + loudness_norm_param_interface->change_loudness_measur_system = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (loudness_norm_param_interface->change_loudness_measur_system == 1) { - loudness_norm_param_interface->loudness_measurement_system = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; + loudness_norm_param_interface->loudness_measurement_system = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; } - - loudness_norm_param_interface->change_loudness_measur_pre_proc = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + loudness_norm_param_interface->change_loudness_measur_pre_proc = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (loudness_norm_param_interface->change_loudness_measur_pre_proc == 1) { - loudness_norm_param_interface->loudness_measurement_pre_proc = impd_read_bits_buf(it_bit_buff, 2); - if(it_bit_buff->error) - return it_bit_buff->error; + loudness_norm_param_interface->loudness_measurement_pre_proc = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; } - - loudness_norm_param_interface->change_device_cut_off_freq = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + loudness_norm_param_interface->change_device_cut_off_freq = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (loudness_norm_param_interface->change_device_cut_off_freq == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; loudness_norm_param_interface->device_cut_off_frequency = max(min(tmp*10,500),20); } - - loudness_norm_param_interface->change_loudness_norm_gain_db_max = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + loudness_norm_param_interface->change_loudness_norm_gain_db_max = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (loudness_norm_param_interface->change_loudness_norm_gain_db_max == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; if (tmp<63) { loudness_norm_param_interface->loudness_norm_gain_db_max = tmp*0.5f; } else { loudness_norm_param_interface->loudness_norm_gain_db_max = LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT; } } - - loudness_norm_param_interface->change_loudness_norm_gain_modification_db = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + loudness_norm_param_interface->change_loudness_norm_gain_modification_db = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (loudness_norm_param_interface->change_loudness_norm_gain_modification_db == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 10); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 10); + if(it_bit_buff->error) + return it_bit_buff->error; loudness_norm_param_interface->loudness_norm_gain_modification_db = -16+tmp*0.03125f; } - - loudness_norm_param_interface->change_output_peak_level_max = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + loudness_norm_param_interface->change_output_peak_level_max = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (loudness_norm_param_interface->change_output_peak_level_max == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; loudness_norm_param_interface->output_peak_level_max = tmp*0.5f; } - + return(0); } @@ -213,50 +213,50 @@ WORD32 impd_drc_interface_read(ia_bit_buf_struct* it_bit_buff, ia_dyn_rng_ctrl_interface_struct* drc_ctrl_interface) { //WORD32 err = 0; - WORD32 i = 0, j = 0, tmp = 0; - - drc_ctrl_interface->dynamic_range_control_on = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - + WORD32 i = 0, j = 0, tmp = 0; + + drc_ctrl_interface->dynamic_range_control_on = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (drc_ctrl_interface->dynamic_range_control_on == 1) { - drc_ctrl_interface->num_drc_feature_requests = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; + drc_ctrl_interface->num_drc_feature_requests = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; for (i=0; inum_drc_feature_requests; i++) { - drc_ctrl_interface->drc_feature_req_type[i] = impd_read_bits_buf(it_bit_buff, 2); - if(it_bit_buff->error) - return it_bit_buff->error; - + drc_ctrl_interface->drc_feature_req_type[i] = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; + switch (drc_ctrl_interface->drc_feature_req_type[i]) { case 0: - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - drc_ctrl_interface->requested_num_drc_effects[i] = (tmp>>4)&0xf; - drc_ctrl_interface->desired_num_drc_effects_of_requested[i] = tmp&0xf; + drc_ctrl_interface->requested_num_drc_effects[i] = (tmp>>4)&0xf; + drc_ctrl_interface->desired_num_drc_effects_of_requested[i] = tmp&0xf; - for (j=0; jrequested_num_drc_effects[i]; j++) - { - drc_ctrl_interface->requested_drc_effect_type[i][j] = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; + for (j=0; jrequested_num_drc_effects[i]; j++) + { + drc_ctrl_interface->requested_drc_effect_type[i][j] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; } break; case 1: - tmp = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; - drc_ctrl_interface->requested_dyn_rng_measurement_type[i] = (tmp>>1)&3; - drc_ctrl_interface->requested_dyn_range_is_single_val_flag[i] = tmp&1; + drc_ctrl_interface->requested_dyn_rng_measurement_type[i] = (tmp>>1)&3; + drc_ctrl_interface->requested_dyn_range_is_single_val_flag[i] = tmp&1; if (drc_ctrl_interface->requested_dyn_range_is_single_val_flag[i] == 0) { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; if (tmp == 0) drc_ctrl_interface->requested_dyn_range_value[i] = 0.0f; else if(tmp <= 128) @@ -266,9 +266,9 @@ WORD32 impd_drc_interface_read(ia_bit_buf_struct* it_bit_buff, else drc_ctrl_interface->requested_dyn_range_value[i] = tmp - 134.0f; } else { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; if (tmp == 0) drc_ctrl_interface->requested_dyn_range_min_val[i] = 0.0f; else if(tmp <= 128) @@ -277,9 +277,9 @@ WORD32 impd_drc_interface_read(ia_bit_buf_struct* it_bit_buff, drc_ctrl_interface->requested_dyn_range_min_val[i] = 0.5f * tmp - 32.0f; else drc_ctrl_interface->requested_dyn_range_min_val[i] = tmp - 134.0f; - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; if (tmp == 0) drc_ctrl_interface->requested_dyn_range_max_val[i] = 0.0f; else if(tmp <= 128) @@ -291,9 +291,9 @@ WORD32 impd_drc_interface_read(ia_bit_buf_struct* it_bit_buff, } break; case 2: - drc_ctrl_interface->requested_drc_characteristic[i] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + drc_ctrl_interface->requested_drc_characteristic[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; break; default: return(1); @@ -308,45 +308,45 @@ WORD32 impd_drc_param_interface_read(ia_bit_buf_struct* it_bit_buff, ia_drc_parameter_interface_struct* drc_parameter_interface) { //WORD32 err = 0; - WORD32 tmp = 0; + WORD32 tmp = 0; + + tmp = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; + + drc_parameter_interface->change_compress = (tmp>>1)&1; + drc_parameter_interface->change_boost = tmp&1; - tmp = impd_read_bits_buf(it_bit_buff, 2); - if(it_bit_buff->error) - return it_bit_buff->error; - - drc_parameter_interface->change_compress = (tmp>>1)&1; - drc_parameter_interface->change_boost = tmp&1; - if (drc_parameter_interface->change_compress == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; if (tmp<255) { drc_parameter_interface->compress = 1 - tmp * 0.00390625f; } else { drc_parameter_interface->compress = 0.f; } } - + if (drc_parameter_interface->change_boost == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; if (tmp<255) { drc_parameter_interface->boost = 1 - tmp * 0.00390625f; } else { drc_parameter_interface->boost = 0.f; } } - - drc_parameter_interface->change_drc_characteristic_target = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - + + drc_parameter_interface->change_drc_characteristic_target = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (drc_parameter_interface->change_drc_characteristic_target == 1) { - drc_parameter_interface->drc_characteristic_target = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + drc_parameter_interface->drc_characteristic_target = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; } return(0); } @@ -356,31 +356,31 @@ static WORD32 impd_parse_loud_eq_param_interface(ia_bit_buf_struct* it_bit_buff, { //WORD32 err = 0; WORD32 bsSensitivity, bsPlaybackGain; - - loudness_eq_parameter_interface->loudness_eq_request_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + loudness_eq_parameter_interface->loudness_eq_request_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (loudness_eq_parameter_interface->loudness_eq_request_flag) { - loudness_eq_parameter_interface->loudness_eq_request = impd_read_bits_buf(it_bit_buff, 2); - if(it_bit_buff->error) - return it_bit_buff->error; + loudness_eq_parameter_interface->loudness_eq_request = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; } - loudness_eq_parameter_interface->sensitivity_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + loudness_eq_parameter_interface->sensitivity_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (loudness_eq_parameter_interface->sensitivity_flag) { - bsSensitivity = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + bsSensitivity = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; loudness_eq_parameter_interface->sensitivity = bsSensitivity + 23.0f; } - loudness_eq_parameter_interface->playback_gain_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + loudness_eq_parameter_interface->playback_gain_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (loudness_eq_parameter_interface->playback_gain_flag) { - bsPlaybackGain = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + bsPlaybackGain = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; loudness_eq_parameter_interface->playback_gain = (FLOAT32) - bsPlaybackGain; } return (0); @@ -394,58 +394,58 @@ impd_unidrc_interface_extension_read(ia_bit_buf_struct* it_bit_buff, WORD32 err = 0, i = 0, tmp = 0, dummy; WORD32 uni_drc_interface_ext_type; ia_specific_interface_extension_struct* specific_interface_ext; - - uni_drc_interface_ext_type = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - + + uni_drc_interface_ext_type = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + while (uni_drc_interface_ext_type != UNIDRCINTERFACEEXT_TERM) { specific_interface_ext = &(drc_uni_interface_ext->specific_interface_ext[i]); specific_interface_ext->uni_drc_interface_ext_type = uni_drc_interface_ext_type; - tmp = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; specific_interface_ext->ext_size_bits = tmp+4; - - tmp = impd_read_bits_buf(it_bit_buff, specific_interface_ext->ext_size_bits); - if(it_bit_buff->error) - return it_bit_buff->error; + + tmp = impd_read_bits_buf(it_bit_buff, specific_interface_ext->ext_size_bits); + if(it_bit_buff->error) + return it_bit_buff->error; specific_interface_ext->ext_bit_size = tmp+1; - + switch (uni_drc_interface_ext_type) { case UNIDRCINTERFACEEXT_EQ: - impd_drc_uni_interface->drc_uni_interface_ext.loudness_eq_parameter_interface_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + impd_drc_uni_interface->drc_uni_interface_ext.loudness_eq_parameter_interface_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (impd_drc_uni_interface->drc_uni_interface_ext.loudness_eq_parameter_interface_flag) { err = impd_parse_loud_eq_param_interface(it_bit_buff, &(impd_drc_uni_interface->drc_uni_interface_ext.loudness_eq_parameter_interface)); if (err) return(err); } - impd_drc_uni_interface->drc_uni_interface_ext.eq_ctrl_interface_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + impd_drc_uni_interface->drc_uni_interface_ext.eq_ctrl_interface_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (impd_drc_uni_interface->drc_uni_interface_ext.eq_ctrl_interface_flag) { - impd_drc_uni_interface->drc_uni_interface_ext.eq_ctrl_interface.eq_set_purpose_request = impd_read_bits_buf(it_bit_buff, 16); - if(it_bit_buff->error) - return it_bit_buff->error; + impd_drc_uni_interface->drc_uni_interface_ext.eq_ctrl_interface.eq_set_purpose_request = impd_read_bits_buf(it_bit_buff, 16); + if(it_bit_buff->error) + return it_bit_buff->error; } break; default: - dummy = impd_read_bits_buf(it_bit_buff, specific_interface_ext->ext_bit_size); - if(it_bit_buff->error) - return it_bit_buff->error; + dummy = impd_read_bits_buf(it_bit_buff, specific_interface_ext->ext_bit_size); + if(it_bit_buff->error) + return it_bit_buff->error; break; } - + i++; - if (i==EXT_COUNT_MAX) - { + if (i==EXT_COUNT_MAX) + { return(1); } - uni_drc_interface_ext_type = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; + uni_drc_interface_ext_type = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; } drc_uni_interface_ext->interface_ext_count = i; return(0); @@ -454,62 +454,62 @@ WORD32 impd_unidrc_interface_read(ia_bit_buf_struct* it_bit_buff, ia_drc_interface_struct* uniDrcInterface) { WORD32 err = 0; - - uniDrcInterface->interface_signat_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + uniDrcInterface->interface_signat_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (uniDrcInterface->interface_signat_flag == 1) { err = impd_unidrc_interface_signature_read(it_bit_buff, &(uniDrcInterface->drc_uni_interface_signature)); if (err) return(err); } - - uniDrcInterface->system_interface_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + uniDrcInterface->system_interface_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (uniDrcInterface->system_interface_flag == 1) { err = impd_sys_interface_read(it_bit_buff, &(uniDrcInterface->system_interface)); if (err) return(err); } - - uniDrcInterface->loudness_norm_ctrl_interface_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + uniDrcInterface->loudness_norm_ctrl_interface_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (uniDrcInterface->loudness_norm_ctrl_interface_flag == 1) { err = impd_loudness_norm_control_interface_read(it_bit_buff, &(uniDrcInterface->loudness_norm_ctrl_interface)); if (err) return(err); } - - uniDrcInterface->loudness_norm_parameter_interface_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + uniDrcInterface->loudness_norm_parameter_interface_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (uniDrcInterface->loudness_norm_parameter_interface_flag == 1) { err = impd_loudness_norm_param_interface_read(it_bit_buff, &(uniDrcInterface->loudness_norm_param_interface)); if (err) return(err); } - - uniDrcInterface->drc_interface_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + uniDrcInterface->drc_interface_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (uniDrcInterface->drc_interface_flag == 1) { err = impd_drc_interface_read(it_bit_buff, &(uniDrcInterface->drc_ctrl_interface)); if (err) return(err); } - - uniDrcInterface->drc_parameter_interface_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + uniDrcInterface->drc_parameter_interface_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (uniDrcInterface->drc_parameter_interface_flag == 1) { err = impd_drc_param_interface_read(it_bit_buff, &(uniDrcInterface->drc_parameter_interface)); if (err) return(err); } - - uniDrcInterface->drc_uni_interface_ext_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + uniDrcInterface->drc_uni_interface_ext_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (uniDrcInterface->drc_uni_interface_ext_flag == 1) { err = impd_unidrc_interface_extension_read(it_bit_buff, uniDrcInterface, &(uniDrcInterface->drc_uni_interface_ext)); if (err) return(err); } - + return(0); } \ No newline at end of file diff --git a/decoder/drc_src/impd_drc_loud_eq.c b/decoder/drc_src/impd_drc_loud_eq.c index 8b93ec6..4f02d00 100644 --- a/decoder/drc_src/impd_drc_loud_eq.c +++ b/decoder/drc_src/impd_drc_loud_eq.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -36,25 +36,25 @@ WORD32 impd_parametric_drc_instance_reset(WORD32 instance_idx, - ia_parametric_drc_instance_params_struct* pstr_parametric_drc_instance_params) + ia_parametric_drc_instance_params_struct* pstr_parametric_drc_instance_params) { WORD32 err = 0; - - if (pstr_parametric_drc_instance_params->parametric_drc_type == PARAM_DRC_TYPE_FF) - { - + + if (pstr_parametric_drc_instance_params->parametric_drc_type == PARAM_DRC_TYPE_FF) + { + ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params = &(pstr_parametric_drc_instance_params->str_parametric_drc_type_ff_params); err = impd_parametric_ffwd_type_drc_reset(pstr_parametric_ffwd_type_drc_params); - if (err) - return (err); - - - } - else - { - return (UNEXPECTED_ERROR); + if (err) + return (err); + + } - + else + { + return (UNEXPECTED_ERROR); + } + return 0; } @@ -70,10 +70,10 @@ WORD32 impd_add_drc_band_audio(ia_drc_instructions_struct* pstr_drc_instruction_ FLOAT32** drcBandAudio; FLOAT32** channel_audio; ia_drc_instructions_struct* str_drc_instruction_str; - + drcBandAudio = audio_band_buffer->non_interleaved_audio; channel_audio = audio_io_buf; - + if (drc_instructions_index >= 0) { str_drc_instruction_str = &(pstr_drc_instruction_arr[drc_instructions_index]); } else { diff --git a/decoder/drc_src/impd_drc_loudness_control.c b/decoder/drc_src/impd_drc_loudness_control.c index 23853cd..470c5fe 100644 --- a/decoder/drc_src/impd_drc_loudness_control.c +++ b/decoder/drc_src/impd_drc_loudness_control.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include @@ -55,7 +55,7 @@ WORD32 impd_signal_peak_level_info(ia_drc_config* pstr_drc_config, eq_set_id[0] = 0; signal_peak_level[0] = 0.0f; explicit_peak_information_present[0] = 0; - + k=0; if (drc_set_id_requested < 0) { @@ -70,7 +70,7 @@ WORD32 impd_signal_peak_level_info(ia_drc_config* pstr_drc_config, signal_peak_level[k] = 0.0f; explicit_peak_information_present[k] = 0; k++; - + pre_lim_count = k; if (drc_set_id_requested < 0) @@ -92,7 +92,7 @@ WORD32 impd_signal_peak_level_info(ia_drc_config* pstr_drc_config, mode = 0; loudness_info_count = pstr_loudness_info->loudness_info_count; } - + for (n=0; ndwnmix_id_count; i++) + for (i=0; idwnmix_id_count; i++) { if (requested_dwnmix_id == str_drc_instruction_str->downmix_id[0] || ID_FOR_ANY_DOWNMIX == str_drc_instruction_str->downmix_id[0]) { @@ -200,7 +200,7 @@ WORD32 impd_signal_peak_level_info(ia_drc_config* pstr_drc_config, } } } - else + else { eq_set_id[peak_count] = 0; @@ -335,7 +335,7 @@ WORD32 impd_signal_peak_level_info(ia_drc_config* pstr_drc_config, } } } - if (match_found_flag == 0) { + if (match_found_flag == 0) { ia_drc_instructions_struct* drc_instructions_drc_tmp; for (n=0; ndrc_instructions_count_plus; n++) { drc_instructions_drc_tmp = &pstr_drc_config->str_drc_instruction_str[n]; @@ -343,7 +343,7 @@ WORD32 impd_signal_peak_level_info(ia_drc_config* pstr_drc_config, for (k=0; kdwnmix_id_count; k++) { if (ID_FOR_BASE_LAYOUT == drc_instructions_drc_tmp->downmix_id[k]) { if (drc_instructions_drc_tmp->limiter_peak_target_present) { - eq_set_id[peak_count] = -1; + eq_set_id[peak_count] = -1; signal_peak_level[peak_count] = drc_instructions_drc_tmp->limiter_peak_target + signal_peak_level_tmp; explicit_peak_information_present[peak_count] = 0; match_found_flag = 1; @@ -369,7 +369,7 @@ WORD32 impd_signal_peak_level_info(ia_drc_config* pstr_drc_config, } - + WORD32 impd_extract_loudness_peak_to_average_info(ia_loudness_info_struct* loudness_info, WORD32 dyn_range_measurement_type, @@ -409,7 +409,7 @@ impd_extract_loudness_peak_to_average_info(ia_loudness_info_struct* loudness_inf } } break; - + case MOMENTARY_LOUDNESS_TO_AVG: if (loudness_measure->method_def == METHOD_DEFINITION_MOMENTARY_LOUDNESS_MAX) { @@ -421,7 +421,7 @@ impd_extract_loudness_peak_to_average_info(ia_loudness_info_struct* loudness_inf } } break; - + case TOP_OF_LOUDNESS_RANGE_TO_AVG: if (loudness_measure->method_def == METHOD_DEFINITION_MAX_OF_LOUDNESS_RANGE) { @@ -433,10 +433,10 @@ impd_extract_loudness_peak_to_average_info(ia_loudness_info_struct* loudness_inf } } break; - + default: return (UNEXPECTED_ERROR); - + break; } } @@ -459,7 +459,7 @@ WORD32 impd_loudness_peak_to_average_info( { WORD32 n, err; WORD32 drc_set_id = max(0,str_drc_instruction_str->drc_set_id); - + *loudness_peak_2_avg_value_present = 0; if (album_mode == 1) @@ -510,7 +510,7 @@ WORD32 impd_overall_loudness_present( ia_loudness_info_struct* loudness_info, WORD32* loudness_info_present) { WORD32 m; - + *loudness_info_present = 0; for (m=0; mmeasurement_count; m++) { @@ -539,8 +539,8 @@ WORD32 impd_check_loud_info(WORD32 loudness_info_count, if (drc_set_id_requested == loudness_info[n].drc_set_id) { err = impd_overall_loudness_present(&(loudness_info[n]), &loudness_info_present); - if (err) - return (err); + if (err) + return (err); if (loudness_info_present) { loudness_info_matching[*info_count] = &(loudness_info[n]); @@ -548,9 +548,9 @@ WORD32 impd_check_loud_info(WORD32 loudness_info_count, } } } - } - - return (0); + } + + return (0); } WORD32 impd_check_loud_payload(WORD32 loudness_info_count, @@ -561,9 +561,9 @@ WORD32 impd_check_loud_payload(WORD32 loudness_info_count, ia_loudness_info_struct* loudness_info_matching[]) { WORD32 err = 0; - + err = impd_check_loud_info(loudness_info_count, loudness_info, requested_dwnmix_id, drc_set_id_requested, info_count, loudness_info_matching); - if (err || *info_count) goto matchEnd; + if (err || *info_count) goto matchEnd; err = impd_check_loud_info(loudness_info_count, loudness_info, ID_FOR_ANY_DOWNMIX, drc_set_id_requested, info_count, loudness_info_matching); if (err || *info_count) goto matchEnd; err = impd_check_loud_info(loudness_info_count, loudness_info, requested_dwnmix_id, ID_FOR_ANY_DRC, info_count, loudness_info_matching); if (err || *info_count) goto matchEnd; err = impd_check_loud_info(loudness_info_count, loudness_info, requested_dwnmix_id, ID_FOR_NO_DRC, info_count, loudness_info_matching); if (err || *info_count) goto matchEnd; @@ -587,7 +587,7 @@ WORD32 impd_find_overall_loudness_info(ia_drc_sel_proc_params_struct* pstr_drc_s { WORD32 err; WORD32 loudness_drc_set_id_requested; - + *info_count = 0; if (drc_set_id_requested < 0) { @@ -606,7 +606,7 @@ WORD32 impd_find_overall_loudness_info(ia_drc_sel_proc_params_struct* pstr_drc_s info_count, loudness_info_matching); if (err) return (err); - + } if (*info_count == 0) { @@ -630,7 +630,7 @@ impd_high_pass_loudness_adjust_info( ia_loudness_info_struct* loudness_info, FLOAT32* loudness_hp_adjust) { WORD32 m, k; - + *loudness_hp_adjust_present = 0; *loudness_hp_adjust = 0.0f; for (m=0; mmeasurement_count; m++) @@ -664,7 +664,7 @@ WORD32 impd_find_high_pass_loudness_adjust( { WORD32 n, err; WORD32 loudness_drc_set_id_requested; - + if (drc_set_id_requested < 0) { loudness_drc_set_id_requested = 0; @@ -673,9 +673,9 @@ WORD32 impd_find_high_pass_loudness_adjust( { loudness_drc_set_id_requested = drc_set_id_requested; } - + *loudness_hp_adjust_present = 0; - + if (album_mode == 1) { for (n=0; nloudness_info_album_count; n++) @@ -742,7 +742,7 @@ WORD32 impd_find_high_pass_loudness_adjust( } return(0); } - + WORD32 impd_init_loudness_control (ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, ia_drc_loudness_info_set_struct* pstr_loudness_info, @@ -759,7 +759,7 @@ WORD32 impd_init_loudness_control (ia_drc_sel_proc_params_struct* pstr_drc_sel_p WORD32 loudness_hp_adjust_present; WORD32 overall_loudness_info_present; FLOAT32 pre_proc_adjust; - + k=0; if (drc_set_id_requested < 0) { @@ -774,7 +774,7 @@ WORD32 impd_init_loudness_control (ia_drc_sel_proc_params_struct* pstr_drc_sel_p loudness[k] = UNDEFINED_LOUDNESS_VALUE; loudness_normalization_gain_db[k] = 0.0f; k++; - + pre_lim_count = k; if (pstr_drc_sel_proc_params_struct->loudness_normalization_on == 1) @@ -789,19 +789,19 @@ WORD32 impd_init_loudness_control (ia_drc_sel_proc_params_struct* pstr_drc_sel_p &info_count, loudness_info); if (err) return (err); - + if (overall_loudness_info_present == 1) { WORD32 requested_method_definition = METHOD_DEFINITION_PROGRAM_LOUDNESS; WORD32 other_method_definition = METHOD_DEFINITION_PROGRAM_LOUDNESS; WORD32 requested_measurement_system = MEASUREMENT_SYSTEM_BS_1770_4; - WORD32 requested_preprocessing = 0; - + WORD32 requested_preprocessing = 0; + WORD32* system_bonus = measurement_system_default_tbl; - + WORD32 match_measure; FLOAT32 method_val = 0; - + switch (pstr_drc_sel_proc_params_struct->loudness_measurement_method) { case USER_METHOD_DEFINITION_DEFAULT: case USER_METHOD_DEFINITION_PROGRAM_LOUDNESS: @@ -812,12 +812,12 @@ WORD32 impd_init_loudness_control (ia_drc_sel_proc_params_struct* pstr_drc_sel_p requested_method_definition = METHOD_DEFINITION_ANCHOR_LOUDNESS; other_method_definition = METHOD_DEFINITION_PROGRAM_LOUDNESS; break; - + default: return (UNEXPECTED_ERROR); break; } - + switch (pstr_drc_sel_proc_params_struct->loudness_measurement_system) { case USER_MEASUREMENT_SYSTEM_DEFAULT: case USER_MEASUREMENT_SYSTEM_BS_1770_4: @@ -852,12 +852,12 @@ WORD32 impd_init_loudness_control (ia_drc_sel_proc_params_struct* pstr_drc_sel_p requested_measurement_system = USER_MEASUREMENT_SYSTEM_RESERVED_E; system_bonus = measurement_system_rms_e_tbl; break; - + default: return (UNEXPECTED_ERROR); break; } - + switch (pstr_drc_sel_proc_params_struct->loudness_measurement_pre_proc) { case USER_LOUDNESS_PREPROCESSING_DEFAULT: case USER_LOUDNESS_PREPROCESSING_OFF: @@ -866,12 +866,12 @@ WORD32 impd_init_loudness_control (ia_drc_sel_proc_params_struct* pstr_drc_sel_p case USER_LOUDNESS_PREPROCESSING_HIGHPASS: requested_preprocessing = 1; break; - + default: return (UNEXPECTED_ERROR); break; } - + for (k=0; kmeasurement_system]; } } - if (match_measure == -1) + if (match_measure == -1) { for (n=0; nmeasurement_count; n++) { @@ -896,13 +896,13 @@ WORD32 impd_init_loudness_control (ia_drc_sel_proc_params_struct* pstr_drc_sel_p } } } - + if (requested_preprocessing == 1) { err = impd_find_high_pass_loudness_adjust(pstr_loudness_info, requested_dwnmix_id, drc_set_id_requested, pstr_drc_sel_proc_params_struct->album_mode, (FLOAT32)pstr_drc_sel_proc_params_struct->device_cut_off_frequency, &loudness_hp_adjust_present, &pre_proc_adjust); if (err) return (err); - + if (loudness_hp_adjust_present == 0) { pre_proc_adjust = -2.0f; @@ -943,7 +943,7 @@ impd_mixing_level_info(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_s WORD32 album_mode = pstr_drc_sel_proc_params_struct->album_mode; WORD32 loudness_drc_set_id_requested; ia_loudness_info_struct* loudness_info; - + *mixing_level = MIXING_LEVEL_DEFAULT; if (drc_set_id_requested < 0) { diff --git a/decoder/drc_src/impd_drc_loudness_control.h b/decoder/drc_src/impd_drc_loudness_control.h index 82ee853..0cdfcb3 100644 --- a/decoder/drc_src/impd_drc_loudness_control.h +++ b/decoder/drc_src/impd_drc_loudness_control.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_LOUDNESS_CONTROL_H #define IMPD_DRC_LOUDNESS_CONTROL_H diff --git a/decoder/drc_src/impd_drc_main_qmf_process.c b/decoder/drc_src/impd_drc_main_qmf_process.c index 99730b1..9426eb6 100644 --- a/decoder/drc_src/impd_drc_main_qmf_process.c +++ b/decoder/drc_src/impd_drc_main_qmf_process.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include "impd_type_def.h" #include "impd_memory_standards.h" @@ -47,25 +47,25 @@ static WORD32 impd_down_mix ( ia_drc_sel_proc_output_struct *uni_drc_sel_proc_ou WORD32 num_target_ch = uni_drc_sel_proc_output->target_channel_count; WORD32 i, i_ch, o_ch; FLOAT32 tmp_out[MAX_CHANNEL_COUNT]; - + if (uni_drc_sel_proc_output->downmix_matrix_present == 0) - return 0; - + return 0; + if (input_audio == 0) return 0; - + if (num_target_ch > MAX_CHANNEL_COUNT) return -1; - + if (num_target_ch > num_base_ch) return -1; - + for (i=0; idownmix_matrix[i_ch][o_ch]; } } @@ -76,8 +76,8 @@ static WORD32 impd_down_mix ( ia_drc_sel_proc_output_struct *uni_drc_sel_proc_ou input_audio[o_ch][i] = 0.0f; } } - - + + return 0; } @@ -90,30 +90,30 @@ WORD32 impd_init_process_audio_main_qmf (ia_drc_api_struct *p_obj_drc) FLOAT32 *audio_io_buf_real[10]; FLOAT32 *audio_io_buf_imag[10]; FLOAT32 *scratch_buffer; - WORD32 last_frame=0; + WORD32 last_frame=0; scratch_buffer= (FLOAT32*)p_obj_drc->pp_mem[1]; input_buffer = (FLOAT32*)p_obj_drc->pp_mem[2]; output_buffer = (FLOAT32*)p_obj_drc->pp_mem[3]; - + if(p_obj_drc->p_state->ui_in_bytes<=0) - { + { p_obj_drc->p_state->ui_out_bytes=0; - return 0; + return 0; } - if((p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in/(p_obj_drc->str_config.pcm_size>>3)) < (UWORD32)p_obj_drc->str_config.frame_size) + if((p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in/(p_obj_drc->str_config.pcm_size>>3)) < (UWORD32)p_obj_drc->str_config.frame_size) last_frame=1; for(i=0;istr_config.num_ch_in;i++){ audio_io_buf_real[i]=scratch_buffer+i*(p_obj_drc->str_config.frame_size+32); - audio_io_buf_imag[i]=scratch_buffer+p_obj_drc->str_config.num_ch_in*p_obj_drc->str_config.frame_size+p_obj_drc->str_config.num_ch_in*64+i*(p_obj_drc->str_config.frame_size+64); + audio_io_buf_imag[i]=scratch_buffer+p_obj_drc->str_config.num_ch_in*p_obj_drc->str_config.frame_size+p_obj_drc->str_config.num_ch_in*64+i*(p_obj_drc->str_config.frame_size+64); for(j=0;jstr_config.frame_size;j++){ audio_io_buf_real[i][j]=input_buffer[j*p_obj_drc->str_config.num_ch_in + i]; audio_io_buf_imag[i][j]=input_buffer[p_obj_drc->str_config.num_ch_in*p_obj_drc->str_config.frame_size+j*p_obj_drc->str_config.num_ch_in + i]; } } - + error = impd_process_drc_bitstream_dec_gain(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->pstr_bit_buf, + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_drc_gain, &p_obj_drc->str_bit_handler.it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], @@ -124,21 +124,21 @@ WORD32 impd_init_process_audio_main_qmf (ia_drc_api_struct *p_obj_drc) if (error > PROC_COMPLETE) return -1; - + p_obj_drc->str_bit_handler.num_bytes_read_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); p_obj_drc->str_bit_handler.num_bits_offset_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); p_obj_drc->str_bit_handler.byte_index_bs += p_obj_drc->str_bit_handler.num_bytes_read_bs; - if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; - } - - - - - - - + if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame + { + p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; + } + + + + + + + if (p_obj_drc->str_config.bitstream_file_format == BITSTREAM_FILE_FORMAT_SPLIT) { if (p_obj_drc->str_bit_handler.num_bits_offset_bs != 0) { @@ -146,12 +146,12 @@ WORD32 impd_init_process_audio_main_qmf (ia_drc_api_struct *p_obj_drc) p_obj_drc->str_bit_handler.num_bytes_read_bs = p_obj_drc->str_bit_handler.num_bytes_read_bs + 1; p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; p_obj_drc->str_bit_handler.byte_index_bs = p_obj_drc->str_bit_handler.byte_index_bs + 1; - if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs = p_obj_drc->str_bit_handler.num_bytes_bs - 1; - } + if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame + { + p_obj_drc->str_bit_handler.num_bytes_bs = p_obj_drc->str_bit_handler.num_bytes_bs - 1; + } } - } + } error = impd_drc_process_freq_domain(p_obj_drc->str_payload.pstr_gain_dec[0], p_obj_drc->str_payload.pstr_drc_config, @@ -163,17 +163,17 @@ WORD32 impd_init_process_audio_main_qmf (ia_drc_api_struct *p_obj_drc) p_obj_drc->str_payload.pstr_drc_sel_proc_output->compress, p_obj_drc->str_payload.pstr_drc_sel_proc_output->drc_characteristic_target); if (error) return -1; - + error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, audio_io_buf_real, p_obj_drc->str_config.frame_size); if (error) return -1; - + error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, audio_io_buf_imag, p_obj_drc->str_config.frame_size); if (error) return -1; - + error = impd_drc_process_freq_domain(p_obj_drc->str_payload.pstr_gain_dec[1], p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_drc_gain, @@ -192,7 +192,7 @@ WORD32 impd_init_process_audio_main_qmf (ia_drc_api_struct *p_obj_drc) for (j=0; j str_config. frame_size; j++) { audio_io_buf_real[i][j] *= loudness_normalization_gain; audio_io_buf_imag[i][j] *= loudness_normalization_gain; - + } } } @@ -201,37 +201,37 @@ WORD32 impd_init_process_audio_main_qmf (ia_drc_api_struct *p_obj_drc) for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) { for (j=0; j < p_obj_drc->str_config.frame_size; j++) { output_buffer[j*p_obj_drc->str_config.num_ch_out + i] = audio_io_buf_real[i][j]; - output_buffer[p_obj_drc->str_config.frame_size*p_obj_drc->str_config.num_ch_in+j*p_obj_drc->str_config.num_ch_out + i] = audio_io_buf_imag[i][j]; + output_buffer[p_obj_drc->str_config.frame_size*p_obj_drc->str_config.num_ch_in+j*p_obj_drc->str_config.num_ch_out + i] = audio_io_buf_imag[i][j]; } } - p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->str_config.frame_size)*4; - p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in); + p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->str_config.frame_size)*4; + p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in); - if(last_frame==0){ + if(last_frame==0){ if (p_obj_drc->str_config.bitstream_file_format != BITSTREAM_FILE_FORMAT_SPLIT) { error = impd_process_drc_bitstream_dec(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->pstr_bit_buf, + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_loudness_info, &p_obj_drc->str_bit_handler.it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], p_obj_drc->str_bit_handler.num_bytes_bs, p_obj_drc->str_bit_handler.num_bits_offset_bs, &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (error > PROC_COMPLETE) + + if (error > PROC_COMPLETE) return -1; - + p_obj_drc->str_bit_handler.num_bytes_read_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); p_obj_drc->str_bit_handler.num_bits_offset_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); p_obj_drc->str_bit_handler.byte_index_bs += p_obj_drc->str_bit_handler.num_bytes_read_bs; p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; - + } - } - return error; - + } + return error; + } diff --git a/decoder/drc_src/impd_drc_main_stft_process.c b/decoder/drc_src/impd_drc_main_stft_process.c index 7aefc14..c2fcc73 100644 --- a/decoder/drc_src/impd_drc_main_stft_process.c +++ b/decoder/drc_src/impd_drc_main_stft_process.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include "impd_type_def.h" #include "impd_memory_standards.h" @@ -45,19 +45,19 @@ static WORD32 impd_down_mix(ia_drc_sel_proc_output_struct *uni_drc_sel_proc_outp WORD32 num_target_ch = uni_drc_sel_proc_output->target_channel_count; WORD32 i, i_ch, o_ch; FLOAT32 tmp_out[MAX_CHANNEL_COUNT]; - + if (uni_drc_sel_proc_output->downmix_matrix_present == 0) - return 0; - + return 0; + if (input_audio == 0) return 0; - + if (num_target_ch > MAX_CHANNEL_COUNT) return -1; - + if (num_target_ch > num_base_ch) return -1; - + for (i=0; ipp_mem[1]; input_buffer = (FLOAT32*)p_obj_drc->pp_mem[2]; output_buffer = (FLOAT32*)p_obj_drc->pp_mem[3]; - - + + if(p_obj_drc->p_state->ui_in_bytes<=0){ p_obj_drc->p_state->ui_out_bytes=0; - return 0; + return 0; } - if((p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in/(p_obj_drc->str_config.pcm_size>>3)) < (UWORD32)p_obj_drc->str_config.frame_size) + if((p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in/(p_obj_drc->str_config.pcm_size>>3)) < (UWORD32)p_obj_drc->str_config.frame_size) last_frame=1; for(i=0;istr_config.num_ch_in;i++){ audio_io_buf_real[i]=scratch_buffer+i*(p_obj_drc->str_config.frame_size+32); - audio_io_buf_imag[i]=scratch_buffer+p_obj_drc->str_config.num_ch_in*p_obj_drc->str_config.frame_size+p_obj_drc->str_config.num_ch_in*64+i*(p_obj_drc->str_config.frame_size+64); + audio_io_buf_imag[i]=scratch_buffer+p_obj_drc->str_config.num_ch_in*p_obj_drc->str_config.frame_size+p_obj_drc->str_config.num_ch_in*64+i*(p_obj_drc->str_config.frame_size+64); for(j=0;jstr_config.frame_size;j++){ audio_io_buf_real[i][j]=input_buffer[j*p_obj_drc->str_config.num_ch_in + i]; audio_io_buf_imag[i][j]=input_buffer[p_obj_drc->str_config.num_ch_in*p_obj_drc->str_config.frame_size+j*p_obj_drc->str_config.num_ch_in + i]; } } - + error = impd_process_drc_bitstream_dec_gain(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->pstr_bit_buf, + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_drc_gain, &p_obj_drc->str_bit_handler.it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], @@ -123,16 +123,16 @@ WORD32 impd_init_process_audio_main_stft (ia_drc_api_struct *p_obj_drc) if (error > PROC_COMPLETE) return -1; - + p_obj_drc->str_bit_handler.num_bytes_read_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); p_obj_drc->str_bit_handler.num_bits_offset_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); p_obj_drc->str_bit_handler.byte_index_bs += p_obj_drc->str_bit_handler.num_bytes_read_bs; - if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; - } - - + if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame + { + p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; + } + + if (p_obj_drc->str_config.bitstream_file_format == BITSTREAM_FILE_FORMAT_SPLIT) { if (p_obj_drc->str_bit_handler.num_bits_offset_bs != 0) { @@ -140,12 +140,12 @@ WORD32 impd_init_process_audio_main_stft (ia_drc_api_struct *p_obj_drc) p_obj_drc->str_bit_handler.num_bytes_read_bs = p_obj_drc->str_bit_handler.num_bytes_read_bs + 1; p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; p_obj_drc->str_bit_handler.byte_index_bs = p_obj_drc->str_bit_handler.byte_index_bs + 1; - if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs = p_obj_drc->str_bit_handler.num_bytes_bs - 1; - } + if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame + { + p_obj_drc->str_bit_handler.num_bytes_bs = p_obj_drc->str_bit_handler.num_bytes_bs - 1; + } } - } + } error = impd_drc_process_freq_domain(p_obj_drc->str_payload.pstr_gain_dec[0], p_obj_drc->str_payload.pstr_drc_config, @@ -157,17 +157,17 @@ WORD32 impd_init_process_audio_main_stft (ia_drc_api_struct *p_obj_drc) p_obj_drc->str_payload.pstr_drc_sel_proc_output->compress, p_obj_drc->str_payload.pstr_drc_sel_proc_output->drc_characteristic_target); if (error) return -1; - + error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, audio_io_buf_real, p_obj_drc->str_config.frame_size); if (error) return -1; - + error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, audio_io_buf_imag, p_obj_drc->str_config.frame_size); if (error) return -1; - + error = impd_drc_process_freq_domain(p_obj_drc->str_payload.pstr_gain_dec[1], p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_drc_gain, @@ -186,47 +186,47 @@ WORD32 impd_init_process_audio_main_stft (ia_drc_api_struct *p_obj_drc) for (j=0; j str_config. frame_size; j++) { audio_io_buf_real[i][j] *= loudness_normalization_gain; audio_io_buf_imag[i][j] *= loudness_normalization_gain; - + } } } - + num_samples_per_channel = p_obj_drc->str_config.frame_size; for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) { for (j=0; j < p_obj_drc->str_config.frame_size; j++) { output_buffer[j*p_obj_drc->str_config.num_ch_out + i] = audio_io_buf_real[i][j]; - output_buffer[p_obj_drc->str_config.frame_size*p_obj_drc->str_config.num_ch_in+j*p_obj_drc->str_config.num_ch_out + i] = audio_io_buf_imag[i][j]; + output_buffer[p_obj_drc->str_config.frame_size*p_obj_drc->str_config.num_ch_in+j*p_obj_drc->str_config.num_ch_out + i] = audio_io_buf_imag[i][j]; } } - p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->str_config.frame_size)*4; - p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in); + p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->str_config.frame_size)*4; + p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in); - if(last_frame==0){ + if(last_frame==0){ if (p_obj_drc->str_config.bitstream_file_format != BITSTREAM_FILE_FORMAT_SPLIT) { error = impd_process_drc_bitstream_dec(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->pstr_bit_buf, + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_loudness_info, &p_obj_drc->str_bit_handler.it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], p_obj_drc->str_bit_handler.num_bytes_bs, p_obj_drc->str_bit_handler.num_bits_offset_bs, &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (error > PROC_COMPLETE) + + if (error > PROC_COMPLETE) return -1; - + p_obj_drc->str_bit_handler.num_bytes_read_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); p_obj_drc->str_bit_handler.num_bits_offset_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); p_obj_drc->str_bit_handler.byte_index_bs += p_obj_drc->str_bit_handler.num_bytes_read_bs; p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; - + } - } - - return error; + } + + return error; } diff --git a/decoder/drc_src/impd_drc_main_td_process.c b/decoder/drc_src/impd_drc_main_td_process.c index ea72ea2..49dcba2 100644 --- a/decoder/drc_src/impd_drc_main_td_process.c +++ b/decoder/drc_src/impd_drc_main_td_process.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include "impd_type_def.h" @@ -47,35 +47,35 @@ static IA_ERRORCODE impd_down_mix ( ia_drc_sel_proc_output_struct *uni_drc_sel_p WORD32 num_target_ch = uni_drc_sel_proc_output->target_channel_count; WORD32 i, i_ch, o_ch; FLOAT32 tmp_out[MAX_CHANNEL_COUNT]; - + if (num_target_ch > MAX_CHANNEL_COUNT) return -1; - + if (num_target_ch > num_base_ch) return -1; - - for (i=0; idownmix_matrix[i_ch][o_ch]; } } - for (o_ch=0; o_chpp_mem[1]; input_buffer = (FLOAT32*)p_obj_drc->pp_mem[2]; output_buffer = (FLOAT32*)p_obj_drc->pp_mem[3]; input_buffer16 = (WORD16*)p_obj_drc->pp_mem[2]; output_buffer16 = (WORD16*)p_obj_drc->pp_mem[3]; - + if(p_obj_drc->p_state->ui_in_bytes<=0){ p_obj_drc->p_state->ui_out_bytes=0; - return IA_NO_ERROR; + return IA_NO_ERROR; } err_code = impd_process_drc_bitstream_dec_gain(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->pstr_bit_buf, + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_drc_gain, &p_obj_drc->str_bit_handler.it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], @@ -110,63 +110,65 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) p_obj_drc->str_bit_handler.num_bits_offset_bs, &p_obj_drc->str_bit_handler.num_bits_read_bs); - if (err_code > PROC_COMPLETE) + if (err_code > PROC_COMPLETE) return -1; - + p_obj_drc->str_bit_handler.num_bytes_read_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); p_obj_drc->str_bit_handler.num_bits_offset_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); p_obj_drc->str_bit_handler.byte_index_bs += p_obj_drc->str_bit_handler.num_bytes_read_bs; - if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; - } + if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame + { + p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; + } if (p_obj_drc->str_config.bitstream_file_format == BITSTREAM_FILE_FORMAT_SPLIT) { if (p_obj_drc->str_bit_handler.num_bits_offset_bs != 0) { - p_obj_drc->str_bit_handler.num_bits_read_bs = p_obj_drc->str_bit_handler.num_bits_read_bs + 8 - - p_obj_drc->str_bit_handler.num_bits_offset_bs; + p_obj_drc->str_bit_handler.num_bits_read_bs = p_obj_drc->str_bit_handler.num_bits_read_bs + 8 + - p_obj_drc->str_bit_handler.num_bits_offset_bs; p_obj_drc->str_bit_handler.num_bytes_read_bs = p_obj_drc->str_bit_handler.num_bytes_read_bs + 1; p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; p_obj_drc->str_bit_handler.byte_index_bs = p_obj_drc->str_bit_handler.byte_index_bs + 1; - if(p_obj_drc->str_bit_handler.gain_stream_flag==0) - { - p_obj_drc->str_bit_handler.num_bytes_bs = p_obj_drc->str_bit_handler.num_bytes_bs - 1; - } + if(p_obj_drc->str_bit_handler.gain_stream_flag==0) + { + p_obj_drc->str_bit_handler.num_bytes_bs = p_obj_drc->str_bit_handler.num_bytes_bs - 1; + } } - } - - num_sample_to_process=(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in/(p_obj_drc->str_config.pcm_size>>3)); - - if(num_sample_to_processstr_config.frame_size) - last_frame=1; - - if(p_obj_drc->str_config.pcm_size==16) - { - for(i=0;istr_config.num_ch_in;i++) - { - audio_buff[i]=scratch_buffer+i*(p_obj_drc->str_config.frame_size+32); - - for(j=0;jstr_config.num_ch_in + i])/32767.0f; - } - } - } - else - { - for(i=0;istr_config.num_ch_in;i++) - { - audio_buff[i]=scratch_buffer+i*(p_obj_drc->str_config.frame_size+32); - - for(j=0;jstr_config.num_ch_in + i]; - } - } } - + + num_sample_to_process=(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in/(p_obj_drc->str_config.pcm_size>>3)); + + p_obj_drc->str_config.frame_size = num_sample_to_process; + + if(num_sample_to_processstr_config.frame_size) + last_frame=1; + + if(p_obj_drc->str_config.pcm_size==16) + { + for(i=0;istr_config.num_ch_in;i++) + { + audio_buff[i]=scratch_buffer+i*(p_obj_drc->str_config.frame_size+32); + + for(j=0;jstr_config.num_ch_in + i])/32767.0f; + } + } + } + else + { + for(i=0;istr_config.num_ch_in;i++) + { + audio_buff[i]=scratch_buffer+i*(p_obj_drc->str_config.frame_size+32); + + for(j=0;jstr_config.num_ch_in + i]; + } + } + } + err_code = impd_drc_process_time_domain(p_obj_drc->str_payload.pstr_gain_dec[0], p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_drc_gain, @@ -175,18 +177,18 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) p_obj_drc->str_payload.pstr_drc_sel_proc_output->boost, p_obj_drc->str_payload.pstr_drc_sel_proc_output->compress, p_obj_drc->str_payload.pstr_drc_sel_proc_output->drc_characteristic_target); - - if (err_code!=IA_NO_ERROR) + + if (err_code!=IA_NO_ERROR) return err_code; - + if(p_obj_drc->str_payload.pstr_drc_sel_proc_output->downmix_matrix_present!=0) err_code = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, audio_buff, p_obj_drc->str_config.frame_size); - - if (err_code!=IA_NO_ERROR) + + if (err_code!=IA_NO_ERROR) return err_code; - + err_code = impd_drc_process_time_domain(p_obj_drc->str_payload.pstr_gain_dec[1], p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_drc_gain, @@ -195,20 +197,20 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) p_obj_drc->str_payload.pstr_drc_sel_proc_output->boost, p_obj_drc->str_payload.pstr_drc_sel_proc_output->compress, p_obj_drc->str_payload.pstr_drc_sel_proc_output->drc_characteristic_target); - - if (err_code!=IA_NO_ERROR) + + if (err_code!=IA_NO_ERROR) return err_code; - + if (p_obj_drc->str_payload.pstr_drc_sel_proc_output->loudness_normalization_gain_db != 0.0f) { - FLOAT32 gain_value = (FLOAT32)pow(10.0,p_obj_drc->str_payload.pstr_drc_sel_proc_output->loudness_normalization_gain_db/20.0); + FLOAT32 gain_value = (FLOAT32)pow(10.0,p_obj_drc->str_payload.pstr_drc_sel_proc_output->loudness_normalization_gain_db/20.0); for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) { for (j=0; j < p_obj_drc->str_config.frame_size; j++) { - audio_buff[i][j] *= gain_value; + audio_buff[i][j] *= gain_value; } } } - + if (p_obj_drc->str_config.peak_limiter) { for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) { @@ -216,28 +218,28 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) output_buffer[j*p_obj_drc->str_config.num_ch_out + i] = audio_buff[i][j]; } } - - err_code=impd_limiter_process(p_obj_drc->str_payload.pstr_peak_limiter, + + err_code=impd_limiter_process(p_obj_drc->str_payload.pstr_peak_limiter, output_buffer, p_obj_drc->str_config.frame_size); - if (err_code!=IA_NO_ERROR) + if (err_code!=IA_NO_ERROR) return err_code; - + for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) { for (j=0; j < p_obj_drc->str_config.frame_size; j++) { audio_buff[i][j] = output_buffer[j*p_obj_drc->str_config.num_ch_out + i]; } } } - - if(p_obj_drc->str_config.pcm_size==16) - { - for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) - { - for (j=0; j < p_obj_drc->str_config.frame_size; j++) - { + + if(p_obj_drc->str_config.pcm_size==16) + { + for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) + { + for (j=0; j < p_obj_drc->str_config.frame_size; j++) + { if(audio_buff[i][j]<-1.0f) output_buffer16[j*p_obj_drc->str_config.num_ch_out + i] = -32767; @@ -246,67 +248,67 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) else output_buffer16[j*p_obj_drc->str_config.num_ch_out + i] = (WORD16)(audio_buff[i][j]*32767.0f); - } - } - } - else - { - for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) - { - for (j=0; j < p_obj_drc->str_config.frame_size; j++) - { + } + } + } + else + { + for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) + { + for (j=0; j < p_obj_drc->str_config.frame_size; j++) + { output_buffer[j*p_obj_drc->str_config.num_ch_out + i] = audio_buff[i][j]; } } } - - p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in); + + p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in); if(p_obj_drc->p_state->delay_in_output!=0){ p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->str_config.frame_size-p_obj_drc->p_state->delay_in_output)*(p_obj_drc->str_config.pcm_size>>3); if(p_obj_drc->str_config.pcm_size==16) - memcpy(output_buffer16,(output_buffer16+(p_obj_drc->p_state->delay_in_output*p_obj_drc->str_config.num_ch_out)),p_obj_drc->p_state->ui_out_bytes); - else + memcpy(output_buffer16,(output_buffer16+(p_obj_drc->p_state->delay_in_output*p_obj_drc->str_config.num_ch_out)),p_obj_drc->p_state->ui_out_bytes); + else memcpy(output_buffer,(output_buffer+(p_obj_drc->p_state->delay_in_output*p_obj_drc->str_config.num_ch_out)),p_obj_drc->p_state->ui_out_bytes); - p_obj_drc->p_state->delay_adjust_samples = p_obj_drc->p_state->delay_in_output; - p_obj_drc->p_state->delay_in_output=0; - - } - if(last_frame==1) - { - if((num_sample_to_process+p_obj_drc->p_state->delay_adjust_samples)<=p_obj_drc->str_config.frame_size) - p_obj_drc->p_state->ui_out_bytes = (num_sample_to_process+p_obj_drc->p_state->delay_adjust_samples)*p_obj_drc->str_config.num_ch_out*(p_obj_drc->str_config.pcm_size>>3); - else - p_obj_drc->p_state->ui_out_bytes = (p_obj_drc->str_config.frame_size)*p_obj_drc->str_config.num_ch_out*(p_obj_drc->str_config.pcm_size>>3); + p_obj_drc->p_state->delay_adjust_samples = p_obj_drc->p_state->delay_in_output; + p_obj_drc->p_state->delay_in_output=0; + + } + if(last_frame==1) + { + if((num_sample_to_process+p_obj_drc->p_state->delay_adjust_samples)<=p_obj_drc->str_config.frame_size) + p_obj_drc->p_state->ui_out_bytes = (num_sample_to_process+p_obj_drc->p_state->delay_adjust_samples)*p_obj_drc->str_config.num_ch_out*(p_obj_drc->str_config.pcm_size>>3); + else + p_obj_drc->p_state->ui_out_bytes = (p_obj_drc->str_config.frame_size)*p_obj_drc->str_config.num_ch_out*(p_obj_drc->str_config.pcm_size>>3); + + } - } - if(last_frame==0){ - + if (p_obj_drc->str_config.bitstream_file_format != BITSTREAM_FILE_FORMAT_SPLIT) { err_code = impd_process_drc_bitstream_dec(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->pstr_bit_buf, + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_loudness_info, &p_obj_drc->str_bit_handler.it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], p_obj_drc->str_bit_handler.num_bytes_bs, p_obj_drc->str_bit_handler.num_bits_offset_bs, &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (err_code > PROC_COMPLETE) + + if (err_code > PROC_COMPLETE) return -1; - + p_obj_drc->str_bit_handler.num_bytes_read_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); p_obj_drc->str_bit_handler.num_bits_offset_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); p_obj_drc->str_bit_handler.byte_index_bs += p_obj_drc->str_bit_handler.num_bytes_read_bs; p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; - + } - } - + } + return err_code; } diff --git a/decoder/drc_src/impd_drc_main_td_qmf_process.c b/decoder/drc_src/impd_drc_main_td_qmf_process.c index 15cfddb..91a3690 100644 --- a/decoder/drc_src/impd_drc_main_td_qmf_process.c +++ b/decoder/drc_src/impd_drc_main_td_qmf_process.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include "impd_type_def.h" #include "impd_memory_standards.h" @@ -41,7 +41,7 @@ VOID process_qmf_syn_filt_bank(ia_drc_qmf_filt_struct *qmf_filt, - FLOAT64 *buff, + FLOAT64 *buff, FLOAT32 *input_real, FLOAT32 *input_imag, FLOAT32 *output) @@ -51,24 +51,24 @@ VOID process_qmf_syn_filt_bank(ia_drc_qmf_filt_struct *qmf_filt, FLOAT64 W[10 * QMF_NUM_FILT_BANDS]; FLOAT64 tmp; - + for ( i=20*QMF_FILT_RESOLUTION-1; i>=2*QMF_FILT_RESOLUTION; i-- ) { buff[i] = buff[i-2*QMF_FILT_RESOLUTION]; } - + for ( i=0; i<2*QMF_FILT_RESOLUTION; i++ ) { tmp = 0.0; for ( j=0; jsyn_tab_real[i][j] + tmp = tmp + + input_real[j] * qmf_filt->syn_tab_real[i][j] - input_imag[j] * qmf_filt->syn_tab_imag[i][j]; } buff[i] = tmp; } - + for ( i=0; i<5; i++ ) { for ( j=0; j=0; i-- ) { buff[i] = input[QMF_FILT_RESOLUTION-1-i]; } - + for ( i=0; i<10*QMF_FILT_RESOLUTION; i++ ) { - Z[i] = (FLOAT32) (buff[i] * qmf_filter_coeff[i]); + Z[i] = (FLOAT32) (buff[i] * qmf_filter_coeff[i]); } @@ -144,14 +144,14 @@ static WORD32 impd_down_mix ( ia_drc_sel_proc_output_struct *uni_drc_sel_proc_o WORD32 num_target_ch = uni_drc_sel_proc_output->target_channel_count; WORD32 i, i_ch, o_ch; FLOAT32 tmp_out[MAX_CHANNEL_COUNT]; - - + + if (num_target_ch > MAX_CHANNEL_COUNT) return -1; - + if (num_target_ch > num_base_ch) return -1; - + for (i=0; ipp_mem[1]; input_buffer = (FLOAT32*)p_obj_drc->pp_mem[2]; output_buffer = (FLOAT32*)p_obj_drc->pp_mem[3]; - + input_buffer16 = (WORD16*)p_obj_drc->pp_mem[2]; output_buffer16 = (WORD16*)p_obj_drc->pp_mem[3]; - - + + if(p_obj_drc->p_state->ui_in_bytes<=0){ p_obj_drc->p_state->ui_out_bytes=0; - return 0; + return 0; } - if((p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in/(p_obj_drc->str_config.pcm_size>>3)) < (UWORD32)p_obj_drc->str_config.frame_size) + if((p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in/(p_obj_drc->str_config.pcm_size>>3)) < (UWORD32)p_obj_drc->str_config.frame_size) last_frame=1; for(i=0;istr_config.num_ch_in;i++){ audio_in_out_buf[i]=scratch_buffer; - scratch_buffer=scratch_buffer+(p_obj_drc->str_config.frame_size+32); - audio_io_buf_real[i]=scratch_buffer+(p_obj_drc->str_config.frame_size*p_obj_drc->str_config.num_ch_in+512); - audio_io_buf_imag[i]=scratch_buffer+2*(p_obj_drc->str_config.frame_size*p_obj_drc->str_config.num_ch_in+512);; + scratch_buffer=scratch_buffer+(p_obj_drc->str_config.frame_size+32); + audio_io_buf_real[i]=scratch_buffer+(p_obj_drc->str_config.frame_size*p_obj_drc->str_config.num_ch_in+512); + audio_io_buf_imag[i]=scratch_buffer+2*(p_obj_drc->str_config.frame_size*p_obj_drc->str_config.num_ch_in+512);; for(j=0;jstr_config.frame_size;j++){ if(p_obj_drc->str_config.pcm_size==16){ audio_in_out_buf[i][j]=((FLOAT32)input_buffer16[j*p_obj_drc->str_config.num_ch_in + i])/32767.0f; @@ -219,10 +219,10 @@ WORD32 impd_init_process_audio_main_td_qmf (ia_drc_api_struct *p_obj_drc) } } } - - + + error = impd_process_drc_bitstream_dec_gain(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->pstr_bit_buf, + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_drc_gain, &p_obj_drc->str_bit_handler.it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], @@ -233,14 +233,14 @@ WORD32 impd_init_process_audio_main_td_qmf (ia_drc_api_struct *p_obj_drc) if (error > PROC_COMPLETE) return -1; - + p_obj_drc->str_bit_handler.num_bytes_read_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); p_obj_drc->str_bit_handler.num_bits_offset_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); p_obj_drc->str_bit_handler.byte_index_bs += p_obj_drc->str_bit_handler.num_bytes_read_bs; - if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; - } + if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame + { + p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; + } if (p_obj_drc->str_config.bitstream_file_format == BITSTREAM_FILE_FORMAT_SPLIT) { /* shift over fill-bits for frame byte alignment */ if (p_obj_drc->str_bit_handler.num_bits_offset_bs != 0) @@ -249,22 +249,22 @@ WORD32 impd_init_process_audio_main_td_qmf (ia_drc_api_struct *p_obj_drc) p_obj_drc->str_bit_handler.num_bytes_read_bs = p_obj_drc->str_bit_handler.num_bytes_read_bs + 1; p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; p_obj_drc->str_bit_handler.byte_index_bs = p_obj_drc->str_bit_handler.byte_index_bs + 1; - if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs = p_obj_drc->str_bit_handler.num_bytes_bs - 1; - } + if(p_obj_drc->str_bit_handler.gain_stream_flag==0) //ITTIAM: Flag for applying gain frame by frame + { + p_obj_drc->str_bit_handler.num_bytes_bs = p_obj_drc->str_bit_handler.num_bytes_bs - 1; + } } - } + } for (i=0; i < p_obj_drc->str_config.num_ch_in; i++) { for (j=0; j < p_obj_drc->str_config.frame_size; j += 64) { - process_qmf_ana_filt_bank(p_obj_drc->str_payload.pstr_qmf_filter, - p_obj_drc->str_payload.pstr_qmf_filter->ana_buff+i*4*p_obj_drc->str_config.frame_size, - &(audio_in_out_buf[i][j]), + process_qmf_ana_filt_bank(p_obj_drc->str_payload.pstr_qmf_filter, + p_obj_drc->str_payload.pstr_qmf_filter->ana_buff+i*4*p_obj_drc->str_config.frame_size, + &(audio_in_out_buf[i][j]), &(audio_io_buf_real[i][j]), &(audio_io_buf_imag[i][j])); - + } } @@ -281,12 +281,12 @@ WORD32 impd_init_process_audio_main_td_qmf (ia_drc_api_struct *p_obj_drc) if (error) return error; - if(p_obj_drc->str_payload.pstr_drc_sel_proc_output->target_channel_countstr_payload.pstr_drc_sel_proc_output->base_channel_count){ + if(p_obj_drc->str_payload.pstr_drc_sel_proc_output->target_channel_countstr_payload.pstr_drc_sel_proc_output->base_channel_count){ error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, audio_io_buf_real, p_obj_drc->str_config.frame_size); if (error) return error; - + error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, audio_io_buf_imag, p_obj_drc->str_config.frame_size); @@ -306,16 +306,16 @@ WORD32 impd_init_process_audio_main_td_qmf (ia_drc_api_struct *p_obj_drc) for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) { for (j=0; j < p_obj_drc->str_config.frame_size; j += 64) { - process_qmf_syn_filt_bank(p_obj_drc->str_payload.pstr_qmf_filter, - p_obj_drc->str_payload.pstr_qmf_filter->syn_buff+i*4*p_obj_drc->str_config.frame_size, + process_qmf_syn_filt_bank(p_obj_drc->str_payload.pstr_qmf_filter, + p_obj_drc->str_payload.pstr_qmf_filter->syn_buff+i*4*p_obj_drc->str_config.frame_size, &(audio_io_buf_real[i][j]), &(audio_io_buf_imag[i][j]), &(audio_in_out_buf[i][j])); - + } } - + if (p_obj_drc->str_payload.pstr_drc_sel_proc_output->loudness_normalization_gain_db != 0.0f) { FLOAT32 loudness_normalization_gain = (FLOAT32)pow(10.0,p_obj_drc->str_payload.pstr_drc_sel_proc_output->loudness_normalization_gain_db/20.0); @@ -323,15 +323,15 @@ WORD32 impd_init_process_audio_main_td_qmf (ia_drc_api_struct *p_obj_drc) for (j=0; j str_config. frame_size; j++) { audio_io_buf_real[i][j] *= loudness_normalization_gain; audio_io_buf_imag[i][j] *= loudness_normalization_gain; - + } } } - + num_samples_per_channel = p_obj_drc->str_config.frame_size; - + for (i=0; i < p_obj_drc->str_config.num_ch_out; i++) { for (j=0; j < p_obj_drc->str_config.frame_size; j++) { if(p_obj_drc->str_config.pcm_size==16){ @@ -343,29 +343,29 @@ WORD32 impd_init_process_audio_main_td_qmf (ia_drc_api_struct *p_obj_drc) } } } - p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in); - + p_obj_drc->p_state->ui_out_bytes=p_obj_drc->str_config.num_ch_out*(p_obj_drc->p_state->ui_in_bytes/p_obj_drc->str_config.num_ch_in); + if (p_obj_drc->str_config.bitstream_file_format != BITSTREAM_FILE_FORMAT_SPLIT) { error = impd_process_drc_bitstream_dec(p_obj_drc->str_payload.pstr_bitstream_dec, - p_obj_drc->pstr_bit_buf, + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_drc_config, p_obj_drc->str_payload.pstr_loudness_info, &p_obj_drc->str_bit_handler.it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], p_obj_drc->str_bit_handler.num_bytes_bs, p_obj_drc->str_bit_handler.num_bits_offset_bs, &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (error > PROC_COMPLETE) + + if (error > PROC_COMPLETE) return -1; - + p_obj_drc->str_bit_handler.num_bytes_read_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); p_obj_drc->str_bit_handler.num_bits_offset_bs = (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); p_obj_drc->str_bit_handler.byte_index_bs += p_obj_drc->str_bit_handler.num_bytes_read_bs; p_obj_drc->str_bit_handler.num_bytes_bs -= p_obj_drc->str_bit_handler.num_bytes_read_bs; - + } - - return error; + + return error; } diff --git a/decoder/drc_src/impd_drc_multi_band.h b/decoder/drc_src/impd_drc_multi_band.h index 1a733be..0352ca9 100644 --- a/decoder/drc_src/impd_drc_multi_band.h +++ b/decoder/drc_src/impd_drc_multi_band.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_MULTI_BAND_H #define IMPD_DRC_MULTI_BAND_H diff --git a/decoder/drc_src/impd_drc_multiband.c b/decoder/drc_src/impd_drc_multiband.c index cdb51f4..9acb747 100644 --- a/decoder/drc_src/impd_drc_multiband.c +++ b/decoder/drc_src/impd_drc_multiband.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -46,10 +46,10 @@ IA_ERRORCODE impd_generate_slope (WORD32 num_sub_bands, FLOAT32* response) { WORD32 i; - FLOAT32 filter_slope =-24.0f; + FLOAT32 filter_slope =-24.0f; FLOAT32 inv_log10_2 =3.32192809f; FLOAT32 norm = 0.05f * filter_slope * inv_log10_2; - + for (i=0; istr_band_overlap_params[b].overlap_weight); - + fcross_norm_lo = fcross_norm_hi; } for (s=0; sstr_band_overlap_params[b].overlap_weight[s]; } } - + for (s=0; s #include #include @@ -41,112 +41,112 @@ WORD32 impd_init_parametric_drc( WORD32 drc_frame_size, - WORD32 sampling_rate, - WORD32 sub_band_domain_mode, - ia_parametric_drc_params_struct *p_parametricdrc_params) + WORD32 sampling_rate, + WORD32 sub_band_domain_mode, + ia_parametric_drc_params_struct *p_parametricdrc_params) { - - WORD32 sub_band_count_tbl[4]={0,64,71,256}; + + WORD32 sub_band_count_tbl[4]={0,64,71,256}; p_parametricdrc_params->drc_frame_size = drc_frame_size; p_parametricdrc_params->sampling_rate = sampling_rate; p_parametricdrc_params->sub_band_domain_mode = sub_band_domain_mode; - p_parametricdrc_params->sub_band_count=sub_band_count_tbl[sub_band_domain_mode]; + p_parametricdrc_params->sub_band_count=sub_band_count_tbl[sub_band_domain_mode]; return 0; } -WORD32 impd_init_parametric_drc_feed_fwd(ia_drc_config* pstr_drc_config, - WORD32 instance_idx, - WORD32 ch_count_from_dwnmix_id, - ia_parametric_drc_params_struct* p_parametricdrc_params) +WORD32 impd_init_parametric_drc_feed_fwd(ia_drc_config* pstr_drc_config, + WORD32 instance_idx, + WORD32 ch_count_from_dwnmix_id, + ia_parametric_drc_params_struct* p_parametricdrc_params) { WORD32 err = 0, i = 0; - + WORD32 parametric_drc_idx = p_parametricdrc_params->parametric_drc_idx[instance_idx]; WORD32 gain_set_index = p_parametricdrc_params->gain_set_index[instance_idx]; WORD32* channel_map = p_parametricdrc_params->channel_map[instance_idx]; - + ia_drc_coeff_parametric_drc_struct* hDrcCoefficientsParametricDrcBs = &(pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc); ia_parametric_drc_type_feed_forward_struct* hParametricDrcTypeFeedForwardBs = &(pstr_drc_config->str_drc_config_ext.str_parametric_drc_instructions[parametric_drc_idx].str_parametric_drc_type_feed_forward); ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params = &(p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].str_parametric_drc_type_ff_params); - + /* level estimation */ pstr_parametric_ffwd_type_drc_params->frame_size = p_parametricdrc_params->parametric_drc_frame_size; pstr_parametric_ffwd_type_drc_params->sub_band_domain_mode = p_parametricdrc_params->sub_band_domain_mode; pstr_parametric_ffwd_type_drc_params->sub_band_count = p_parametricdrc_params->sub_band_count; pstr_parametric_ffwd_type_drc_params->sub_band_compensation_type = 0; - - if (pstr_parametric_ffwd_type_drc_params->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_QMF64) - { - if (p_parametricdrc_params->sampling_rate == 48000) - { + + if (pstr_parametric_ffwd_type_drc_params->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_QMF64) + { + if (p_parametricdrc_params->sampling_rate == 48000) + { pstr_parametric_ffwd_type_drc_params->sub_band_compensation_type = 1; - } - else - { + } + else + { /* support of other sampling rates than 48000 might be missing */ return UNEXPECTED_ERROR; } } - + pstr_parametric_ffwd_type_drc_params->audio_num_chan = p_parametricdrc_params->audio_num_chan; pstr_parametric_ffwd_type_drc_params->level_estim_k_weighting_type = hParametricDrcTypeFeedForwardBs->level_estim_k_weighting_type; pstr_parametric_ffwd_type_drc_params->level_estim_integration_time = hParametricDrcTypeFeedForwardBs->level_estim_integration_time; pstr_parametric_ffwd_type_drc_params->level_estim_frame_index = 0; pstr_parametric_ffwd_type_drc_params->level_estim_frame_count = hParametricDrcTypeFeedForwardBs->level_estim_integration_time/pstr_parametric_ffwd_type_drc_params->frame_size; - - memset(pstr_parametric_ffwd_type_drc_params->level,0,PARAM_DRC_TYPE_FF_LEVEL_ESTIM_FRAME_COUNT_MAX*sizeof(FLOAT32)); - if (ch_count_from_dwnmix_id != 0) - { + memset(pstr_parametric_ffwd_type_drc_params->level,0,PARAM_DRC_TYPE_FF_LEVEL_ESTIM_FRAME_COUNT_MAX*sizeof(FLOAT32)); - memcpy(pstr_parametric_ffwd_type_drc_params->level_estim_ch_weight, - hDrcCoefficientsParametricDrcBs->str_parametric_drc_gain_set_params[gain_set_index].level_estim_ch_weight,ch_count_from_dwnmix_id*sizeof(FLOAT32)); - } - else - { + if (ch_count_from_dwnmix_id != 0) + { - for (i=0; iaudio_num_chan; i++) - { - pstr_parametric_ffwd_type_drc_params->level_estim_ch_weight[i] = (FLOAT32)channel_map[i]; - } + memcpy(pstr_parametric_ffwd_type_drc_params->level_estim_ch_weight, + hDrcCoefficientsParametricDrcBs->str_parametric_drc_gain_set_params[gain_set_index].level_estim_ch_weight,ch_count_from_dwnmix_id*sizeof(FLOAT32)); + } + else + { + + for (i=0; iaudio_num_chan; i++) + { + pstr_parametric_ffwd_type_drc_params->level_estim_ch_weight[i] = (FLOAT32)channel_map[i]; + } } - - if (pstr_parametric_ffwd_type_drc_params->sub_band_domain_mode==SUBBAND_DOMAIN_MODE_OFF) - { + + if (pstr_parametric_ffwd_type_drc_params->sub_band_domain_mode==SUBBAND_DOMAIN_MODE_OFF) + { err = impd_init_lvl_est_filt_time(pstr_parametric_ffwd_type_drc_params->level_estim_k_weighting_type, - p_parametricdrc_params->sampling_rate, - &pstr_parametric_ffwd_type_drc_params->pre_filt_coeff, - &pstr_parametric_ffwd_type_drc_params->rlb_filt_coeff); + p_parametricdrc_params->sampling_rate, + &pstr_parametric_ffwd_type_drc_params->pre_filt_coeff, + &pstr_parametric_ffwd_type_drc_params->rlb_filt_coeff); - if (err) - return (err); - } - else - { - err = impd_init_lvl_est_filt_subband(pstr_parametric_ffwd_type_drc_params->level_estim_k_weighting_type, - p_parametricdrc_params->sampling_rate, - p_parametricdrc_params->sub_band_domain_mode, - p_parametricdrc_params->sub_band_count, - pstr_parametric_ffwd_type_drc_params->sub_band_compensation_type, - pstr_parametric_ffwd_type_drc_params->weighting_filt, - &pstr_parametric_ffwd_type_drc_params->filt_coeff_subband); - - if (err) - return (err); + if (err) + return (err); } - + else + { + err = impd_init_lvl_est_filt_subband(pstr_parametric_ffwd_type_drc_params->level_estim_k_weighting_type, + p_parametricdrc_params->sampling_rate, + p_parametricdrc_params->sub_band_domain_mode, + p_parametricdrc_params->sub_band_count, + pstr_parametric_ffwd_type_drc_params->sub_band_compensation_type, + pstr_parametric_ffwd_type_drc_params->weighting_filt, + &pstr_parametric_ffwd_type_drc_params->filt_coeff_subband); + + if (err) + return (err); + } + pstr_parametric_ffwd_type_drc_params->node_count = hParametricDrcTypeFeedForwardBs->node_count; - memcpy(pstr_parametric_ffwd_type_drc_params->node_level,hParametricDrcTypeFeedForwardBs->node_level,pstr_parametric_ffwd_type_drc_params->node_count*sizeof(WORD32)); - memcpy(pstr_parametric_ffwd_type_drc_params->node_gain,hParametricDrcTypeFeedForwardBs->node_gain,pstr_parametric_ffwd_type_drc_params->node_count*sizeof(WORD32)); + memcpy(pstr_parametric_ffwd_type_drc_params->node_level,hParametricDrcTypeFeedForwardBs->node_level,pstr_parametric_ffwd_type_drc_params->node_count*sizeof(WORD32)); + memcpy(pstr_parametric_ffwd_type_drc_params->node_gain,hParametricDrcTypeFeedForwardBs->node_gain,pstr_parametric_ffwd_type_drc_params->node_count*sizeof(WORD32)); pstr_parametric_ffwd_type_drc_params->ref_level_parametric_drc = hDrcCoefficientsParametricDrcBs->str_parametric_drc_gain_set_params[gain_set_index].drc_input_loudness; - + { WORD32 gain_smooth_attack_time_fast = hParametricDrcTypeFeedForwardBs->gain_smooth_attack_time_fast; WORD32 gain_smooth_release_time_fast = hParametricDrcTypeFeedForwardBs->gain_smooth_release_time_fast; @@ -155,7 +155,7 @@ WORD32 impd_init_parametric_drc_feed_fwd(ia_drc_config* pstr_drc_config, WORD32 gain_smooth_hold_off = hParametricDrcTypeFeedForwardBs->gain_smooth_hold_off; WORD32 sampling_rate = p_parametricdrc_params->sampling_rate; WORD32 parametric_drc_frame_size = p_parametricdrc_params->parametric_drc_frame_size; - + pstr_parametric_ffwd_type_drc_params->gain_smooth_attack_alpha_fast = 1 - (FLOAT32)exp(-1.0 * parametric_drc_frame_size / (gain_smooth_attack_time_fast * sampling_rate * 0.001)); pstr_parametric_ffwd_type_drc_params->gain_smooth_rel_alpha_fast = 1 - (FLOAT32)exp(-1.0 * parametric_drc_frame_size / (gain_smooth_release_time_fast * sampling_rate * 0.001)); pstr_parametric_ffwd_type_drc_params->gain_smooth_attack_alpha_slow = 1 - (FLOAT32)exp(-1.0 * parametric_drc_frame_size / (gain_smooth_attack_time_slow * sampling_rate * 0.001)); @@ -164,62 +164,62 @@ WORD32 impd_init_parametric_drc_feed_fwd(ia_drc_config* pstr_drc_config, pstr_parametric_ffwd_type_drc_params->gain_smooth_attack_threshold = hParametricDrcTypeFeedForwardBs->gain_smooth_attack_threshold; pstr_parametric_ffwd_type_drc_params->gain_smooth_rel_threshold = hParametricDrcTypeFeedForwardBs->gain_smooth_rel_threshold; } - + err = impd_parametric_ffwd_type_drc_reset(pstr_parametric_ffwd_type_drc_params); - - if (err) - return (err); - + + if (err) + return (err); + return 0; } WORD32 impd_init_parametric_drc_lim(ia_drc_config* pstr_drc_config, - WORD32 instance_idx, - WORD32 ch_count_from_dwnmix_id, - ia_parametric_drc_params_struct* p_parametricdrc_params, + WORD32 instance_idx, + WORD32 ch_count_from_dwnmix_id, + ia_parametric_drc_params_struct* p_parametricdrc_params, pVOID *mem_ptr) { WORD32 err = 0, i = 0; - UWORD32 j; + UWORD32 j; UWORD32 attack, sec_len; - + WORD32 parametric_drc_idx = p_parametricdrc_params->parametric_drc_idx[instance_idx]; WORD32 gain_set_index = p_parametricdrc_params->gain_set_index[instance_idx]; WORD32* channel_map = p_parametricdrc_params->channel_map[instance_idx]; - + ia_drc_coeff_parametric_drc_struct* hDrcCoefficientsParametricDrcBs = &(pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc); ia_parametric_drc_lim_struct* hParametricDrcTypeLimBs = &(pstr_drc_config->str_drc_config_ext.str_parametric_drc_instructions[parametric_drc_idx].parametric_drc_lim); ia_parametric_drc_type_lim_params_struct* pstr_parametric_lim_type_drc_params = &(p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].str_parametric_drc_type_lim_params); - + pstr_parametric_lim_type_drc_params->frame_size = p_parametricdrc_params->drc_frame_size; pstr_parametric_lim_type_drc_params->audio_num_chan = p_parametricdrc_params->audio_num_chan; - - if (ch_count_from_dwnmix_id != 0) - { - memcpy(pstr_parametric_lim_type_drc_params->level_estim_ch_weight, - hDrcCoefficientsParametricDrcBs->str_parametric_drc_gain_set_params[gain_set_index].level_estim_ch_weight,ch_count_from_dwnmix_id*sizeof(FLOAT32)); - } - else - { - for (i=0; iaudio_num_chan; i++) - { - pstr_parametric_lim_type_drc_params->level_estim_ch_weight[i] = (FLOAT32)channel_map[i]; - } + + if (ch_count_from_dwnmix_id != 0) + { + memcpy(pstr_parametric_lim_type_drc_params->level_estim_ch_weight, + hDrcCoefficientsParametricDrcBs->str_parametric_drc_gain_set_params[gain_set_index].level_estim_ch_weight,ch_count_from_dwnmix_id*sizeof(FLOAT32)); + } + else + { + for (i=0; iaudio_num_chan; i++) + { + pstr_parametric_lim_type_drc_params->level_estim_ch_weight[i] = (FLOAT32)channel_map[i]; + } } - + attack = (UWORD32)(hParametricDrcTypeLimBs->parametric_lim_attack * p_parametricdrc_params->sampling_rate / 1000); - + sec_len = (UWORD32)sqrt(attack+1); - + pstr_parametric_lim_type_drc_params->sec_len = sec_len; pstr_parametric_lim_type_drc_params->num_max_buf_sec = (attack+1)/sec_len; if (pstr_parametric_lim_type_drc_params->num_max_buf_sec*sec_len < (attack+1)) - pstr_parametric_lim_type_drc_params->num_max_buf_sec++; + pstr_parametric_lim_type_drc_params->num_max_buf_sec++; pstr_parametric_lim_type_drc_params->max_buf =(FLOAT32*)(*mem_ptr); - *mem_ptr =(pVOID)((SIZE_T)(*mem_ptr)+pstr_parametric_lim_type_drc_params->num_max_buf_sec * sec_len*sizeof(FLOAT32)); - + *mem_ptr =(pVOID)((SIZE_T)(*mem_ptr)+pstr_parametric_lim_type_drc_params->num_max_buf_sec * sec_len*sizeof(FLOAT32)); + pstr_parametric_lim_type_drc_params->attack_ms = (FLOAT32)hParametricDrcTypeLimBs->parametric_lim_attack; pstr_parametric_lim_type_drc_params->release_ms = (FLOAT32)hParametricDrcTypeLimBs->parametric_lim_release; pstr_parametric_lim_type_drc_params->attack = attack; @@ -232,7 +232,7 @@ WORD32 impd_init_parametric_drc_lim(ia_drc_config* pstr_drc_config, pstr_parametric_lim_type_drc_params->smooth_state_0 = 1.0; - + for (j=0; jnum_max_buf_sec * pstr_parametric_lim_type_drc_params->sec_len; j++) { pstr_parametric_lim_type_drc_params->max_buf[j] = 0.f; } @@ -240,116 +240,116 @@ WORD32 impd_init_parametric_drc_lim(ia_drc_config* pstr_drc_config, if (err) return (err); - + return 0; } WORD32 impd_init_parametric_drcInstance(ia_drc_config* pstr_drc_config, - WORD32 instance_idx, - WORD32 ch_count_from_dwnmix_id, - ia_parametric_drc_params_struct* p_parametricdrc_params, - pVOID *mem_ptr) + WORD32 instance_idx, + WORD32 ch_count_from_dwnmix_id, + ia_parametric_drc_params_struct* p_parametricdrc_params, + pVOID *mem_ptr) { WORD32 err = 0; - + WORD32 parametric_drc_idx = p_parametricdrc_params->parametric_drc_idx[instance_idx]; ia_parametric_drc_instructions_struct *hParametricDrcInstructions = &(pstr_drc_config->str_drc_config_ext.str_parametric_drc_instructions[parametric_drc_idx]); - + p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].disable_paramteric_drc = hParametricDrcInstructions->disable_paramteric_drc; p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].parametric_drc_type = hParametricDrcInstructions->parametric_drc_type; p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].str_spline_nodes.num_nodes = p_parametricdrc_params->num_nodes; - - if (p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].disable_paramteric_drc == 0) - { - - if (p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].parametric_drc_type == PARAM_DRC_TYPE_FF) - { - + + if (p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].disable_paramteric_drc == 0) + { + + if (p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].parametric_drc_type == PARAM_DRC_TYPE_FF) + { + err = impd_init_parametric_drc_feed_fwd(pstr_drc_config, - instance_idx, - ch_count_from_dwnmix_id, - p_parametricdrc_params); + instance_idx, + ch_count_from_dwnmix_id, + p_parametricdrc_params); + + if (err) + return (err); + + } + else if (p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].parametric_drc_type == PARAM_DRC_TYPE_LIM) + { - if (err) - return (err); - - } - else if (p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].parametric_drc_type == PARAM_DRC_TYPE_LIM) - { - p_parametricdrc_params->str_parametric_drc_instance_params[instance_idx].str_spline_nodes.num_nodes = p_parametricdrc_params->drc_frame_size; - - err = impd_init_parametric_drc_lim(pstr_drc_config, - instance_idx, - ch_count_from_dwnmix_id, - p_parametricdrc_params, - mem_ptr); - if (err) - return (err); - + err = impd_init_parametric_drc_lim(pstr_drc_config, + instance_idx, + ch_count_from_dwnmix_id, + p_parametricdrc_params, + mem_ptr); + + if (err) + return (err); + } else { - - return (UNEXPECTED_ERROR); - + + return (UNEXPECTED_ERROR); + } } - + return 0; } WORD32 impd_init_parametric_drc_after_config(ia_drc_config* pstr_drc_config, - ia_drc_loudness_info_set_struct* pstr_loudness_info, - ia_parametric_drc_params_struct *p_parametricdrc_params, + ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_parametric_drc_params_struct *p_parametricdrc_params, pVOID *mem_ptr) { - + WORD32 err = 0, instance_idx = 0, gain_set_index = 0, side_chain_config_type = 0, downmix_id = 0, ch_count_from_dwnmix_id = 0, L = 0; - + p_parametricdrc_params->parametric_drc_frame_size = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.parametric_drc_frame_size; p_parametricdrc_params->reset_parametric_drc = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.reset_parametric_drc; p_parametricdrc_params->num_nodes = p_parametricdrc_params->drc_frame_size/p_parametricdrc_params->parametric_drc_frame_size; - + switch (p_parametricdrc_params->sub_band_domain_mode) { - case SUBBAND_DOMAIN_MODE_QMF64: - L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; - break; - case SUBBAND_DOMAIN_MODE_QMF71: - L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71; - break; - case SUBBAND_DOMAIN_MODE_STFT256: - L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256; - break; - case SUBBAND_DOMAIN_MODE_OFF: - default: - L = 0; - break; + case SUBBAND_DOMAIN_MODE_QMF64: + L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; + break; + case SUBBAND_DOMAIN_MODE_QMF71: + L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71; + break; + case SUBBAND_DOMAIN_MODE_STFT256: + L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256; + break; + case SUBBAND_DOMAIN_MODE_OFF: + default: + L = 0; + break; } - if (p_parametricdrc_params->sub_band_domain_mode != SUBBAND_DOMAIN_MODE_OFF && p_parametricdrc_params->parametric_drc_frame_size != L) - { + if (p_parametricdrc_params->sub_band_domain_mode != SUBBAND_DOMAIN_MODE_OFF && p_parametricdrc_params->parametric_drc_frame_size != L) + { return (EXTERNAL_ERROR); } - + for (instance_idx=0; instance_idxparametric_drc_instance_count; instance_idx++) { - + gain_set_index = p_parametricdrc_params->gain_set_index[instance_idx]; side_chain_config_type = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].side_chain_config_type; downmix_id = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].downmix_id; - + if (side_chain_config_type==1 && downmix_id == p_parametricdrc_params->dwnmix_id_from_drc_instructions[instance_idx]) { ch_count_from_dwnmix_id = pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].ch_count_from_dwnmix_id; } else { ch_count_from_dwnmix_id = 0; } - + if (pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].drc_input_loudness_present == 0) { WORD32 n = 0, m = 0, drcInputLoudnessFound = 0; FLOAT32 drc_input_loudness = 0.f; - - + + for (n=0; nloudness_info_count; n++) { ia_loudness_info_struct* loudness_info = &pstr_loudness_info->loudness_info[n]; @@ -366,8 +366,8 @@ WORD32 impd_init_parametric_drc_after_config(ia_drc_config* pstr_drc_con break; } } - if (drcInputLoudnessFound == 0) - { + if (drcInputLoudnessFound == 0) + { for (m=0; mmeasurement_count; m++) { if (loudness_info->loudness_measure[m].method_def == METHOD_DEFINITION_ANCHOR_LOUDNESS) @@ -420,160 +420,160 @@ WORD32 impd_init_parametric_drc_after_config(ia_drc_config* pstr_drc_con pstr_drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[gain_set_index].drc_input_loudness = drc_input_loudness; } } - + impd_init_parametric_drcInstance(pstr_drc_config, - instance_idx, - ch_count_from_dwnmix_id, - p_parametricdrc_params, + instance_idx, + ch_count_from_dwnmix_id, + p_parametricdrc_params, mem_ptr); if (err) return (err); } - + return 0; } WORD32 impd_init_lvl_est_filt_time( WORD32 level_estim_k_weighting_type, - WORD32 sampling_rate, - ia_2nd_order_filt_coeff_struct* pre_filt_coeff, - ia_2nd_order_filt_coeff_struct* rlb_filt_coeff) + WORD32 sampling_rate, + ia_2nd_order_filt_coeff_struct* pre_filt_coeff, + ia_2nd_order_filt_coeff_struct* rlb_filt_coeff) { - WORD32 i; - const FLOAT32* ptr_samp_tbl; + WORD32 i; + const FLOAT32* ptr_samp_tbl; - switch(sampling_rate) - { - case 96000:i=0; - break; - case 88200:i=1; - break; - case 64000:i=2; - break; - case 48000:i=3; - break; - case 44100:i=4; - break; - case 32000:i=5; - break; - case 24000:i=6; - break; - case 22050:i=7; - break; - case 16000:i=8; - break; - case 12000:i=9; - break; - case 11025:i=10; - break; - case 8000:i=11; - break; - case 7350:i=12; - break; - default:i=3; - break; - } + switch(sampling_rate) + { + case 96000:i=0; + break; + case 88200:i=1; + break; + case 64000:i=2; + break; + case 48000:i=3; + break; + case 44100:i=4; + break; + case 32000:i=5; + break; + case 24000:i=6; + break; + case 22050:i=7; + break; + case 16000:i=8; + break; + case 12000:i=9; + break; + case 11025:i=10; + break; + case 8000:i=11; + break; + case 7350:i=12; + break; + default:i=3; + break; + } - ptr_samp_tbl = samp_rate_tbl[i]; + ptr_samp_tbl = samp_rate_tbl[i]; if (level_estim_k_weighting_type==2) { - + pre_filt_coeff->b0 = ptr_samp_tbl[0]; pre_filt_coeff->b1 = ptr_samp_tbl[1]; pre_filt_coeff->b2 = ptr_samp_tbl[2]; pre_filt_coeff->a1 = ptr_samp_tbl[3]; pre_filt_coeff->a2 = ptr_samp_tbl[4]; - + } - + if (level_estim_k_weighting_type == 1 || level_estim_k_weighting_type == 2) { - + rlb_filt_coeff->b0 = ptr_samp_tbl[5]; rlb_filt_coeff->b1 = ptr_samp_tbl[6]; rlb_filt_coeff->b2 = ptr_samp_tbl[7]; rlb_filt_coeff->a1 = ptr_samp_tbl[8]; rlb_filt_coeff->a2 = ptr_samp_tbl[9]; - + } - + return 0; } WORD32 impd_init_lvl_est_filt_subband( WORD32 level_estim_k_weighting_type, - WORD32 sampling_rate, - WORD32 sub_band_domain_mode, - WORD32 sub_band_count, - WORD32 sub_band_compensation_type, - FLOAT32 *weighting_filt, - ia_2nd_order_filt_coeff_struct* filt_coeff_subband) + WORD32 sampling_rate, + WORD32 sub_band_domain_mode, + WORD32 sub_band_count, + WORD32 sub_band_compensation_type, + FLOAT32 *weighting_filt, + ia_2nd_order_filt_coeff_struct* filt_coeff_subband) { FLOAT32 w0, alpha, sinw0, cosw0; FLOAT32 b0, b1, b2, a0, a1, a2; FLOAT32 num_real,num_imag,den_real,den_imag; FLOAT32 *f_bands_nrm; WORD32 b; - WORD32 i; - const FLOAT32* ptr_samp_tbl; - - switch(sampling_rate) - { - case 96000:i=0; - break; - case 88200:i=1; - break; - case 64000:i=2; - break; - case 48000:i=3; - break; - case 44100:i=4; - break; - case 32000:i=5; - break; - case 24000:i=6; - break; - case 22050:i=7; - break; - case 16000:i=8; - break; - case 12000:i=9; - break; - case 11025:i=10; - break; - case 8000:i=11; - break; - case 7350:i=12; - break; - default:i=3; - break; - } - - ptr_samp_tbl = samp_rate_tbl[i]; + WORD32 i; + const FLOAT32* ptr_samp_tbl; - switch (sub_band_domain_mode) - { - case SUBBAND_DOMAIN_MODE_QMF64: - f_bands_nrm = f_bands_nrm_QMF64; - break; - case SUBBAND_DOMAIN_MODE_QMF71: - f_bands_nrm = f_bands_nrm_QMF71; - break; - case SUBBAND_DOMAIN_MODE_STFT256: - f_bands_nrm = f_bands_nrm_STFT256; - break; - default: - return UNEXPECTED_ERROR; - break; + switch(sampling_rate) + { + case 96000:i=0; + break; + case 88200:i=1; + break; + case 64000:i=2; + break; + case 48000:i=3; + break; + case 44100:i=4; + break; + case 32000:i=5; + break; + case 24000:i=6; + break; + case 22050:i=7; + break; + case 16000:i=8; + break; + case 12000:i=9; + break; + case 11025:i=10; + break; + case 8000:i=11; + break; + case 7350:i=12; + break; + default:i=3; + break; } - - for (b=0; bb0 = b0/a0; filt_coeff_subband->b1 = b1/a0; filt_coeff_subband->b2 = b2/a0; @@ -640,20 +640,20 @@ WORD32 impd_init_lvl_est_filt_subband( WORD32 level_estim_k_weighting_ty filt_coeff_subband->a2 = a2/a0; } } - + return 0; } -WORD32 impd_parametric_ffwd_type_drc_reset(ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params) +WORD32 impd_parametric_ffwd_type_drc_reset(ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params) { WORD32 i = 0; - + pstr_parametric_ffwd_type_drc_params->level_estim_frame_index = 0; pstr_parametric_ffwd_type_drc_params->start_up_phase = 1; for (i=0; ilevel[i] = 0.f; } - + for (i=0; ipre_filt_state[i].z1 = 0.f; pstr_parametric_ffwd_type_drc_params->pre_filt_state[i].z2 = 0.f; @@ -664,58 +664,58 @@ WORD32 impd_parametric_ffwd_type_drc_reset(ia_parametric_drc_type_ff_params_stru pstr_parametric_ffwd_type_drc_params->filt_state_subband_imag[i].z1 = 0.f; pstr_parametric_ffwd_type_drc_params->filt_state_subband_imag[i].z2 = 0.f; } - + pstr_parametric_ffwd_type_drc_params->db_level_smooth = -135.f; pstr_parametric_ffwd_type_drc_params->db_gain_smooth = 0.f; pstr_parametric_ffwd_type_drc_params->hold_counter = 0; - + return 0; } WORD32 impd_parametric_drc_instance_process (FLOAT32* audio_in_out_buf[], - FLOAT32* audio_real_buff[], - FLOAT32* audio_imag_buff[], - ia_parametric_drc_params_struct* p_parametricdrc_params, - ia_parametric_drc_instance_params_struct* pstr_parametric_drc_instance_params) + FLOAT32* audio_real_buff[], + FLOAT32* audio_imag_buff[], + ia_parametric_drc_params_struct* p_parametricdrc_params, + ia_parametric_drc_instance_params_struct* pstr_parametric_drc_instance_params) { WORD32 err = 0, i = 0; - + if (pstr_parametric_drc_instance_params->disable_paramteric_drc) { - + for (i=0; inum_nodes; i++) { - + pstr_parametric_drc_instance_params->str_spline_nodes.str_node[i].loc_db_gain = 0.f; pstr_parametric_drc_instance_params->str_spline_nodes.str_node[i].slope = 0.f; pstr_parametric_drc_instance_params->str_spline_nodes.str_node[i].time = (i+1) * p_parametricdrc_params->parametric_drc_frame_size - 1; - + } - + } else { - + if (pstr_parametric_drc_instance_params->parametric_drc_type == PARAM_DRC_TYPE_FF) { - + ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params = &(pstr_parametric_drc_instance_params->str_parametric_drc_type_ff_params); for (i=0; inum_nodes; i++) { err = impd_parametric_ffwd_type_drc_process(audio_in_out_buf, - audio_real_buff, - audio_imag_buff, - i, - pstr_parametric_ffwd_type_drc_params, - &pstr_parametric_drc_instance_params->str_spline_nodes); + audio_real_buff, + audio_imag_buff, + i, + pstr_parametric_ffwd_type_drc_params, + &pstr_parametric_drc_instance_params->str_spline_nodes); if (err) return (err); } - + } else if (pstr_parametric_drc_instance_params->parametric_drc_type == PARAM_DRC_TYPE_LIM) { - + return (UNEXPECTED_ERROR); - + } else { - return (UNEXPECTED_ERROR); - + return (UNEXPECTED_ERROR); + } - + } - + return 0; } @@ -725,157 +725,157 @@ VOID iir_second_order_filter (ia_2nd_order_filt_coeff_struct* coeff, FLOAT32* input, FLOAT32* output) { - FLOAT32 z2=state->z2; - FLOAT32 z1=state->z1; + FLOAT32 z2=state->z2; + FLOAT32 z1=state->z1; FLOAT32 z0; - WORD32 i; - + WORD32 i; + for (i=0; ia1 * z1 - coeff->a2 * z2; output[i] = coeff->b0 * z0 + coeff->b1 * z1 + coeff->b2 * z2; z2 = z1; - z1 = z0; + z1 = z0; } state->z1=z1; state->z2=z2; } WORD32 impd_parametric_ffwd_type_drc_process(FLOAT32* audio_in_out_buf[], - FLOAT32* audio_real_buff[], - FLOAT32* audio_imag_buff[], - WORD32 nodeIdx, - ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params, - ia_spline_nodes_struct* str_spline_nodes) + FLOAT32* audio_real_buff[], + FLOAT32* audio_imag_buff[], + WORD32 nodeIdx, + ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params, + ia_spline_nodes_struct* str_spline_nodes) { WORD32 c, t, b, n, i, offset; FLOAT32 x, y, channelLevel, level, levelDb, loc_db_gain, levelDelta, alpha; - + WORD32 frame_size = pstr_parametric_ffwd_type_drc_params->frame_size; WORD32 sub_band_count = pstr_parametric_ffwd_type_drc_params->sub_band_count; FLOAT32 *level_estim_ch_weight = pstr_parametric_ffwd_type_drc_params->level_estim_ch_weight; WORD32 level_estim_k_weighting_type = pstr_parametric_ffwd_type_drc_params->level_estim_k_weighting_type; - + ia_2nd_order_filt_coeff_struct preC = pstr_parametric_ffwd_type_drc_params->pre_filt_coeff; ia_2nd_order_filt_coeff_struct rlbC = pstr_parametric_ffwd_type_drc_params->rlb_filt_coeff; ia_2nd_order_filt_state_struct* preS = pstr_parametric_ffwd_type_drc_params->pre_filt_state; ia_2nd_order_filt_state_struct* rlbS = pstr_parametric_ffwd_type_drc_params->rlb_filt_state; - + ia_2nd_order_filt_coeff_struct rlbC_sb = pstr_parametric_ffwd_type_drc_params->filt_coeff_subband; ia_2nd_order_filt_state_struct* rlbS_sbReal = pstr_parametric_ffwd_type_drc_params->filt_state_subband_real; ia_2nd_order_filt_state_struct* rlbS_sbImag = pstr_parametric_ffwd_type_drc_params->filt_state_subband_imag; FLOAT32 *weighting_filt = pstr_parametric_ffwd_type_drc_params->weighting_filt; WORD32 sub_band_compensation_type = pstr_parametric_ffwd_type_drc_params->sub_band_compensation_type; - + if (audio_in_out_buf != NULL) { - + level = 0; offset = nodeIdx * pstr_parametric_ffwd_type_drc_params->frame_size; for(c=0; caudio_num_chan; c++) { channelLevel = 0.f; - + if (!level_estim_ch_weight[c]) continue; - - if (level_estim_k_weighting_type == 0) { - + + if (level_estim_k_weighting_type == 0) { + for(t=0; tsub_band_count; for(c=0; caudio_num_chan; c++) { channelLevel = 0.f; - + if (!level_estim_ch_weight[c]) continue; - - if (level_estim_k_weighting_type == 0) { - + + if (level_estim_k_weighting_type == 0) { + for(b=0; blevel[pstr_parametric_ffwd_type_drc_params->level_estim_frame_index] = level; pstr_parametric_ffwd_type_drc_params->level_estim_frame_index++; - + level = 0.f; if (pstr_parametric_ffwd_type_drc_params->start_up_phase) { for (i=0; ilevel_estim_frame_index; i++) { @@ -892,7 +892,7 @@ WORD32 impd_parametric_ffwd_type_drc_process(FLOAT32* pstr_parametric_ffwd_type_drc_params->level_estim_frame_index = 0; pstr_parametric_ffwd_type_drc_params->start_up_phase = 0; } - + if (level < 1e-10f) level = 1e-10f; if (level_estim_k_weighting_type == 2) { levelDb = -0.691f + 10 * (FLOAT32)log10(level) + 3; @@ -900,7 +900,7 @@ WORD32 impd_parametric_ffwd_type_drc_process(FLOAT32* levelDb = 10 * (FLOAT32)log10(level) + 3; } levelDb -= pstr_parametric_ffwd_type_drc_params->ref_level_parametric_drc; - + for(n=0; nnode_count; n++) { if (levelDb <= (FLOAT32)pstr_parametric_ffwd_type_drc_params->node_level[n]) { break; @@ -913,7 +913,7 @@ WORD32 impd_parametric_ffwd_type_drc_process(FLOAT32* } else { loc_db_gain = (FLOAT32)pstr_parametric_ffwd_type_drc_params->node_gain[n] + (levelDb - (FLOAT32)pstr_parametric_ffwd_type_drc_params->node_level[n]) / (FLOAT32)(pstr_parametric_ffwd_type_drc_params->node_level[n-1] - pstr_parametric_ffwd_type_drc_params->node_level[n]) * (FLOAT32)(pstr_parametric_ffwd_type_drc_params->node_gain[n-1] - pstr_parametric_ffwd_type_drc_params->node_gain[n]); } - + levelDelta = levelDb - pstr_parametric_ffwd_type_drc_params->db_level_smooth; if (loc_db_gain < pstr_parametric_ffwd_type_drc_params->db_gain_smooth) { if (levelDelta > pstr_parametric_ffwd_type_drc_params->gain_smooth_attack_threshold) { @@ -938,21 +938,21 @@ WORD32 impd_parametric_ffwd_type_drc_process(FLOAT32* if (loc_db_gain < pstr_parametric_ffwd_type_drc_params->db_gain_smooth) { pstr_parametric_ffwd_type_drc_params->hold_counter = pstr_parametric_ffwd_type_drc_params->gain_smooth_hold_off_count; } - + str_spline_nodes->str_node[nodeIdx].loc_db_gain = pstr_parametric_ffwd_type_drc_params->db_gain_smooth; str_spline_nodes->str_node[nodeIdx].slope = 0.f; str_spline_nodes->str_node[nodeIdx].time = pstr_parametric_ffwd_type_drc_params->frame_size + offset - 1; - + return 0; } WORD32 impd_parametric_lim_type_drc_process(FLOAT32* samples[], - FLOAT32 loudness_normalization_gain_db, - ia_parametric_drc_type_lim_params_struct* pstr_parametric_lim_type_drc_params, - FLOAT32* lpcm_gains) + FLOAT32 loudness_normalization_gain_db, + ia_parametric_drc_type_lim_params_struct* pstr_parametric_lim_type_drc_params, + FLOAT32* lpcm_gains) { WORD32 i, j; FLOAT32 tmp, gain; @@ -970,14 +970,14 @@ WORD32 impd_parametric_lim_type_drc_process(FLOAT32* FLOAT64 pre_smoothed_gain = pstr_parametric_lim_type_drc_params->smooth_state_0; - - + + for (i = 0; i < pstr_parametric_lim_type_drc_params->frame_size; i++) { tmp =0.0f; for (j = 0; j < num_channels; j++){ if (!level_estim_ch_weight[j]) - continue; + continue; tmp = max(tmp, (FLOAT32)fabs(loudness_normalization_gain*(level_estim_ch_weight[j])*(samples[j][i]))); } @@ -987,39 +987,39 @@ WORD32 impd_parametric_lim_type_drc_process(FLOAT32* max_buf[0] = tmp; sectionMaximum=tmp; for (j = 1; j < (attack_time_samples+1); j++) { - if (max_buf[j] > sectionMaximum) + if (max_buf[j] > sectionMaximum) sectionMaximum = max_buf[j]; } maximum=sectionMaximum; - + if (maximum > limit_threshold) { gain = limit_threshold / maximum; } else { gain = 1; } - + if (gain < pre_smoothed_gain) { gain_modified = min(gain_modified, (gain - 0.1f * (FLOAT32)pre_smoothed_gain) * 1.11111111f); } else { gain_modified = gain; } - + if (gain_modified < pre_smoothed_gain) { - pre_smoothed_gain = attack_constant * (pre_smoothed_gain - gain_modified) + gain_modified; + pre_smoothed_gain = attack_constant * (pre_smoothed_gain - gain_modified) + gain_modified; pre_smoothed_gain = max(pre_smoothed_gain, gain); } else { - pre_smoothed_gain = release_constant * (pre_smoothed_gain - gain_modified) + gain_modified; + pre_smoothed_gain = release_constant * (pre_smoothed_gain - gain_modified) + gain_modified; } - + gain = (FLOAT32)pre_smoothed_gain; lpcm_gains[i] = gain; } - + pstr_parametric_lim_type_drc_params->cor = gain_modified; pstr_parametric_lim_type_drc_params->smooth_state_0 = pre_smoothed_gain; return 0; diff --git a/decoder/drc_src/impd_drc_parser.h b/decoder/drc_src/impd_drc_parser.h index bb6c07a..57948ae 100644 --- a/decoder/drc_src/impd_drc_parser.h +++ b/decoder/drc_src/impd_drc_parser.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_PARSER_H #define IMPD_DRC_PARSER_H @@ -34,7 +34,7 @@ impd_parse_loudness_info(ia_bit_buf_struct* it_bit_buff, WORD32 impd_parse_loudness_info_set_ext(ia_bit_buf_struct* it_bit_buff, ia_drc_loudness_info_set_struct* loudness_info_set); - + WORD32 impd_sel_drc_coeff(ia_drc_config* drc_config, WORD32 location, @@ -72,14 +72,14 @@ impd_parse_dwnmix_instructions(ia_bit_buf_struct* it_bit_buff, WORD32 impd_parse_drc_ext_v1( - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_params_bs_dec_struct* ia_drc_params_struct, ia_drc_config* drc_config, ia_drc_config_ext* str_drc_config_ext); - + WORD32 impd_parse_drc_config( - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_params_bs_dec_struct* ia_drc_params_struct, ia_drc_config* drc_config ); @@ -90,7 +90,7 @@ impd_parse_loudness_info_set(ia_bit_buf_struct* it_bit_buff, WORD32 impd_parse_drc_gain_sequence( - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, ia_gain_set_params_struct* gain_set_params, ia_drc_gain_sequence_struct* drc_gain_sequence); @@ -100,7 +100,7 @@ impd_parse_uni_drc_gain_ext(ia_bit_buf_struct* it_bit_buff, ia_uni_drc_gain_ext_struct* uni_drc_gain_ext); WORD32 impd_drc_uni_gain_read( - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, ia_drc_config* drc_config, ia_drc_gain_struct* pstr_uni_drc_gain); diff --git a/decoder/drc_src/impd_drc_parser_interface.h b/decoder/drc_src/impd_drc_parser_interface.h index c690026..d1be9c2 100644 --- a/decoder/drc_src/impd_drc_parser_interface.h +++ b/decoder/drc_src/impd_drc_parser_interface.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_PARSER_INTERFACE_H #define IMPD_DRC_PARSER_INTERFACE_H diff --git a/decoder/drc_src/impd_drc_peak_limiter.c b/decoder/drc_src/impd_drc_peak_limiter.c index d02e3bb..aa813cc 100644 --- a/decoder/drc_src/impd_drc_peak_limiter.c +++ b/decoder/drc_src/impd_drc_peak_limiter.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -34,55 +34,55 @@ -WORD32 impd_peak_limiter_init( ia_drc_peak_limiter_struct *peak_limiter, - FLOAT32 attack_time, - FLOAT32 release_time, - FLOAT32 limit_threshold, - UWORD32 num_channels, - UWORD32 sample_rate, - FLOAT32 *buffer - ) +WORD32 impd_peak_limiter_init( ia_drc_peak_limiter_struct *peak_limiter, + FLOAT32 attack_time, + FLOAT32 release_time, + FLOAT32 limit_threshold, + UWORD32 num_channels, + UWORD32 sample_rate, + FLOAT32 *buffer + ) { - - UWORD32 attack; - attack = (UWORD32)(attack_time * sample_rate / 1000); - - if (attack < 1) - return 0; - - peak_limiter->max_buf=buffer; - peak_limiter->delayed_input=buffer+attack*4+32; - - peak_limiter->delayed_input_index = 0; - peak_limiter->attack_time = attack_time; - peak_limiter->release_time = release_time; - peak_limiter->attack_time_samples = attack; - peak_limiter->attack_constant = (FLOAT32)pow(0.1, 1.0 / (attack + 1)); - peak_limiter->release_constant = (FLOAT32)pow(0.1, 1.0 / (release_time * sample_rate / 1000 + 1)); - peak_limiter->limit_threshold = limit_threshold; - peak_limiter->num_channels = num_channels; - peak_limiter->sample_rate = sample_rate; - peak_limiter->min_gain = 1.0f; - peak_limiter->limiter_on=1; - peak_limiter->pre_smoothed_gain=1.0f; - peak_limiter->gain_modified=1.0f; - - return 0; + + UWORD32 attack; + attack = (UWORD32)(attack_time * sample_rate / 1000); + + if (attack < 1) + return 0; + + peak_limiter->max_buf=buffer; + peak_limiter->delayed_input=buffer+attack*4+32; + + peak_limiter->delayed_input_index = 0; + peak_limiter->attack_time = attack_time; + peak_limiter->release_time = release_time; + peak_limiter->attack_time_samples = attack; + peak_limiter->attack_constant = (FLOAT32)pow(0.1, 1.0 / (attack + 1)); + peak_limiter->release_constant = (FLOAT32)pow(0.1, 1.0 / (release_time * sample_rate / 1000 + 1)); + peak_limiter->limit_threshold = limit_threshold; + peak_limiter->num_channels = num_channels; + peak_limiter->sample_rate = sample_rate; + peak_limiter->min_gain = 1.0f; + peak_limiter->limiter_on=1; + peak_limiter->pre_smoothed_gain=1.0f; + peak_limiter->gain_modified=1.0f; + + return 0; } WORD32 impd_peak_limiter_reinit(ia_drc_peak_limiter_struct *peak_limiter) { - if (peak_limiter) - { - peak_limiter->delayed_input_index = 0; - peak_limiter->pre_smoothed_gain=1.0f; - peak_limiter->gain_modified=1.0f; - peak_limiter->min_gain = 1.0f; - memset(peak_limiter->max_buf, 0, (peak_limiter->attack_time_samples + 1) * sizeof(FLOAT32) ); - memset(peak_limiter->delayed_input, 0, peak_limiter->attack_time_samples * peak_limiter->num_channels * sizeof(FLOAT32) ); - } - - return 0; + if (peak_limiter) + { + peak_limiter->delayed_input_index = 0; + peak_limiter->pre_smoothed_gain=1.0f; + peak_limiter->gain_modified=1.0f; + peak_limiter->min_gain = 1.0f; + memset(peak_limiter->max_buf, 0, (peak_limiter->attack_time_samples + 1) * sizeof(FLOAT32) ); + memset(peak_limiter->delayed_input, 0, peak_limiter->attack_time_samples * peak_limiter->num_channels * sizeof(FLOAT32) ); + } + + return 0; } WORD32 impd_limiter_process(ia_drc_peak_limiter_struct *peak_limiter, FLOAT32 *samples, UWORD32 frame_len) @@ -103,8 +103,8 @@ WORD32 impd_limiter_process(ia_drc_peak_limiter_struct *peak_limiter, FLOAT32 *s FLOAT64 pre_smoothed_gain = peak_limiter->pre_smoothed_gain; - - + + if (peak_limiter->limiter_on || (FLOAT32)pre_smoothed_gain < 1.0f) { for (i = 0; i < frame_len; i++) { tmp =0.0f; @@ -118,33 +118,33 @@ WORD32 impd_limiter_process(ia_drc_peak_limiter_struct *peak_limiter, FLOAT32 *s max_buf[0] = tmp; sectionMaximum=tmp; for (j = 1; j < (attack_time_samples+1); j++) { - if (max_buf[j] > sectionMaximum) + if (max_buf[j] > sectionMaximum) sectionMaximum = max_buf[j]; } maximum=sectionMaximum; - + if (maximum > limit_threshold) { gain = limit_threshold / maximum; } else { gain = 1; } - + if (gain < pre_smoothed_gain) { gain_modified = min(gain_modified, (gain - 0.1f * (FLOAT32)pre_smoothed_gain) * 1.11111111f); } else { gain_modified = gain; } - + if (gain_modified < pre_smoothed_gain) { - pre_smoothed_gain = attack_constant * (pre_smoothed_gain - gain_modified) + gain_modified; - pre_smoothed_gain = max(pre_smoothed_gain, gain); + pre_smoothed_gain = attack_constant * (pre_smoothed_gain - gain_modified) + gain_modified; + pre_smoothed_gain = max(pre_smoothed_gain, gain); } else { - pre_smoothed_gain = release_constant * (pre_smoothed_gain - gain_modified) + gain_modified; + pre_smoothed_gain = release_constant * (pre_smoothed_gain - gain_modified) + gain_modified; } - + gain = (FLOAT32)pre_smoothed_gain; for (j = 0; j < num_channels; j++) { @@ -152,23 +152,23 @@ WORD32 impd_limiter_process(ia_drc_peak_limiter_struct *peak_limiter, FLOAT32 *s delayed_input[delayed_input_index * num_channels + j] = samples[i * num_channels + j]; tmp *= gain; - if (tmp > limit_threshold) + if (tmp > limit_threshold) tmp = limit_threshold; - else if (tmp < -limit_threshold) + else if (tmp < -limit_threshold) tmp = -limit_threshold; samples[i * num_channels + j] = tmp; } delayed_input_index++; - if (delayed_input_index >= attack_time_samples) + if (delayed_input_index >= attack_time_samples) delayed_input_index = 0; - if (gain < min_gain) + if (gain < min_gain) min_gain = gain; } } - else { + else { for (i = 0; i < frame_len; i++) { for (j = 0; j < num_channels; j++) { tmp = delayed_input[delayed_input_index * num_channels + j]; @@ -181,7 +181,7 @@ WORD32 impd_limiter_process(ia_drc_peak_limiter_struct *peak_limiter, FLOAT32 *s delayed_input_index = 0; } } - + peak_limiter->gain_modified = gain_modified; peak_limiter->delayed_input_index = delayed_input_index; peak_limiter->pre_smoothed_gain = pre_smoothed_gain; diff --git a/decoder/drc_src/impd_drc_peak_limiter.h b/decoder/drc_src/impd_drc_peak_limiter.h index 0257201..90f5478 100644 --- a/decoder/drc_src/impd_drc_peak_limiter.h +++ b/decoder/drc_src/impd_drc_peak_limiter.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_PEAK_LIMITER_H #define IMPD_DRC_PEAK_LIMITER_H @@ -44,13 +44,13 @@ typedef struct ia_drc_peak_limiter_struct { FLOAT32* buffer; }ia_drc_peak_limiter_struct; -WORD32 impd_peak_limiter_init(ia_drc_peak_limiter_struct *peak_limiter, - FLOAT32 attack_time, - FLOAT32 release_time, - FLOAT32 limit_threshold, - UWORD32 num_channels, - UWORD32 sample_rate, - FLOAT32 *buffer); +WORD32 impd_peak_limiter_init(ia_drc_peak_limiter_struct *peak_limiter, + FLOAT32 attack_time, + FLOAT32 release_time, + FLOAT32 limit_threshold, + UWORD32 num_channels, + UWORD32 sample_rate, + FLOAT32 *buffer); WORD32 impd_limiter_process(ia_drc_peak_limiter_struct *peak_limiter, FLOAT32 *samples, UWORD32 frame_len); diff --git a/decoder/drc_src/impd_drc_peak_limiter_struct.h b/decoder/drc_src/impd_drc_peak_limiter_struct.h index 38b31e8..d025ce5 100644 --- a/decoder/drc_src/impd_drc_peak_limiter_struct.h +++ b/decoder/drc_src/impd_drc_peak_limiter_struct.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_PEAK_LIMITER_STRUCT_H #define IMPD_DRC_PEAK_LIMITER_STRUCT_H diff --git a/decoder/drc_src/impd_drc_process.c b/decoder/drc_src/impd_drc_process.c index fb8be2c..8370907 100644 --- a/decoder/drc_src/impd_drc_process.c +++ b/decoder/drc_src/impd_drc_process.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -51,7 +51,7 @@ WORD32 impd_apply_gains_and_add(ia_drc_instructions_struct* pstr_drc_instruction FLOAT32 drc_gain_last, gainThr; WORD32 iEnd, iStart; ia_drc_instructions_struct* str_drc_instruction_str = &(pstr_drc_instruction_arr[drc_instructions_index]); - + if (drc_instructions_index >= 0) { str_drc_instruction_str = &(pstr_drc_instruction_arr[drc_instructions_index]); @@ -65,7 +65,7 @@ WORD32 impd_apply_gains_and_add(ia_drc_instructions_struct* pstr_drc_instruction gainIndexForGroup[0] = 0; for (g=0; gnum_drc_ch_groups-1; g++) { - gainIndexForGroup[g+1] = gainIndexForGroup[g] + str_drc_instruction_str->band_count_of_ch_group[g]; + gainIndexForGroup[g+1] = gainIndexForGroup[g] + str_drc_instruction_str->band_count_of_ch_group[g]; } signalIndexForChannel[0] = 0; for (c=0; caudio_num_chan-1; c++) @@ -79,7 +79,7 @@ WORD32 impd_apply_gains_and_add(ia_drc_instructions_struct* pstr_drc_instruction signalIndexForChannel[c+1] = signalIndexForChannel[c] + 1; } } - + for (g=0; gnum_drc_ch_groups; g++) { for (b=0; bband_count_of_ch_group[g]; b++) @@ -109,7 +109,7 @@ WORD32 impd_apply_gains_and_add(ia_drc_instructions_struct* pstr_drc_instruction if (g == str_drc_instruction_str->channel_group_of_ch[c]) { signalIndex = signalIndexForChannel[c] + b; - + if(impd_apply_gains == 1) { impd_shape_filt_block_time_process(&shape_filter_block[g], @@ -118,10 +118,10 @@ WORD32 impd_apply_gains_and_add(ia_drc_instructions_struct* pstr_drc_instruction &deinterleaved_audio[signalIndex][0], iStart, iEnd); - + } - else { - for (i=iStart; idrc_frame_size) && (shape_filter_block[g].shape_flter_block_flag)) { @@ -145,9 +145,9 @@ WORD32 impd_apply_gains_and_add(ia_drc_instructions_struct* pstr_drc_instruction } } } - -signalIndex=0; - + +signalIndex=0; + if (str_drc_instruction_str->drc_set_id > 0) { @@ -190,22 +190,22 @@ if (str_drc_instruction_str->drc_set_id > 0) channel_audio[c][i] = deinterleaved_audio[c][i]; } } - } - - - - - - - - - - - - - - - + } + + + + + + + + + + + + + + + return (0); } @@ -257,7 +257,7 @@ WORD32 break; } drc_frame_sizeSb = ia_drc_params_struct->drc_frame_size/L; - + if (drc_instructions_index >= 0) { str_drc_instruction_str = &(pstr_drc_instruction_arr[drc_instructions_index]); @@ -273,7 +273,7 @@ WORD32 { gainIndexForGroup[g+1] = gainIndexForGroup[g] + str_drc_instruction_str->band_count_of_ch_group[g]; /* index of first gain sequence in channel group */ } - + for (c=0; caudio_num_chan; c++) @@ -282,7 +282,7 @@ WORD32 if (g>=0) { for (m=0; mband_count_of_ch_group[g] > 1) { /* multiband DRC */ for (s=0; sdrc_set_id < 0) { - num_bands = 1; + num_bands = 1; } else { @@ -397,7 +397,7 @@ impd_filter_banks_process(ia_drc_instructions_struct* pstr_drc_instruction_arr, //{ //if (&str_drc_filter_bank->str_all_pass_cascade != NULL) //{ - impd_all_pass_cascade_process(&str_drc_filter_bank->str_all_pass_cascade, c, drc_frame_size, audio_in); + impd_all_pass_cascade_process(&str_drc_filter_bank->str_all_pass_cascade, c, drc_frame_size, audio_in); //} //} } @@ -443,7 +443,7 @@ impd_filter_banks_process(ia_drc_instructions_struct* pstr_drc_instruction_arr, break; } } - + return (0); } @@ -454,7 +454,7 @@ impd_store_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], ia_audio_in_out_buf* audio_io_buf_internal) { WORD32 i,j; - + if (audio_io_buf_internal->audio_delay_samples) { for (i=0; iaudio_num_chan; i++) { for (j=0; jframe_size; j++) { @@ -465,7 +465,7 @@ impd_store_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], audio_io_buf_internal->audio_io_buffer_delayed = audio_in_out_buf; audio_io_buf_internal->audio_in_out_buf = audio_in_out_buf; } - + return 0; } @@ -475,7 +475,7 @@ impd_store_audio_io_buffer_freq(FLOAT32* audio_real_buff[], ia_audio_in_out_buf* audio_io_buf_internal) { WORD32 i,j; - + if (audio_io_buf_internal->audio_delay_sub_band_samples) { for (i=0; iaudio_num_chan; i++) { for (j=0; jaudio_sub_band_frame_size*audio_io_buf_internal->audio_sub_band_count; j++) { @@ -489,7 +489,7 @@ impd_store_audio_io_buffer_freq(FLOAT32* audio_real_buff[], audio_io_buf_internal->audio_real_buff = audio_real_buff; audio_io_buf_internal->audio_imag_buff = audio_imag_buff; } - + return 0; } @@ -498,7 +498,7 @@ impd_retrieve_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], ia_audio_in_out_buf* audio_io_buf_internal) { WORD32 i,j; - + if (audio_io_buf_internal->audio_delay_samples) { for (i=0; iaudio_num_chan; i++) { for (j=0; jframe_size; j++) { @@ -506,7 +506,7 @@ impd_retrieve_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], } } } - + return 0; } @@ -516,7 +516,7 @@ impd_retrieve_audio_buffer_freq(FLOAT32* audio_real_buff[], ia_audio_in_out_buf* audio_io_buf_internal) { WORD32 i,j; - + if (audio_io_buf_internal->audio_delay_sub_band_samples) { for (i=0; iaudio_num_chan; i++) { for (j=0; jaudio_sub_band_frame_size*audio_io_buf_internal->audio_sub_band_count; j++) { @@ -525,7 +525,7 @@ impd_retrieve_audio_buffer_freq(FLOAT32* audio_real_buff[], } } } - + return 0; } diff --git a/decoder/drc_src/impd_drc_process_audio.h b/decoder/drc_src/impd_drc_process_audio.h index 485cc71..d7f8f5f 100644 --- a/decoder/drc_src/impd_drc_process_audio.h +++ b/decoder/drc_src/impd_drc_process_audio.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_PROCESS_AUDIO_H #define IMPD_DRC_PROCESS_AUDIO_H @@ -80,12 +80,12 @@ impd_store_audio_io_buffer_freq(FLOAT32* audio_real_buff[], WORD32 impd_retrieve_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], ia_audio_in_out_buf* audio_io_buf_internal); - + WORD32 impd_retrieve_audio_buffer_freq(FLOAT32* audio_real_buff[], FLOAT32* audio_imag_buff[], ia_audio_in_out_buf* audio_io_buf_internal); - + WORD32 impd_advance_audio_io_buffer_time(ia_audio_in_out_buf* audio_io_buf_internal); diff --git a/decoder/drc_src/impd_drc_qmf_filter.h b/decoder/drc_src/impd_drc_qmf_filter.h index 702ba35..051f44c 100644 --- a/decoder/drc_src/impd_drc_qmf_filter.h +++ b/decoder/drc_src/impd_drc_qmf_filter.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_QMF_FILTER_H #define IMPD_DRC_QMF_FILTER_H diff --git a/decoder/drc_src/impd_drc_rom.c b/decoder/drc_src/impd_drc_rom.c index c1b678a..e741dc0 100644 --- a/decoder/drc_src/impd_drc_rom.c +++ b/decoder/drc_src/impd_drc_rom.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include "impd_type_def.h" @@ -30,20 +30,20 @@ const FLOAT32 samp_rate_tbl[13][12]= { - {1.559742927551f,-2.926673889160f,1.378173947334f,-1.844531774521f,0.855774641037f,0.997517585754f,-1.995035171509f,0.997517585754f,-1.995032072067f,0.995038211346f}, - {1.557545065880f,-2.905559301376f,1.361245870590f,-1.830842256546f,0.844074070454f,0.997298538685f,-1.994597077370f,0.997298538685f,-1.994593381882f,0.994600534439f}, - {1.547380685806f,-2.808161973953f,1.285161137581f,-1.767331838608f,0.791711509228f,0.996279776096f,-1.992559552193f,0.996279776096f,-1.992552518845f,0.992566406727f}, - {1.535182833672f,-2.691803932190f,1.198426246643f,-1.690699458122f,0.732504665852f,0.995044350624f,-1.990088701248f,0.995044350624f,-1.990076303482f,0.990100920200f}, - {1.530909657478f,-2.651169300079f,1.169166922569f,-1.663750052452f,0.712657511234f,0.994607865810f,-1.989215731621f,0.994607865810f,-1.989201068878f,0.989230215549f}, - {1.511321425438f,-2.465713739395f,1.042117238045f,-1.539572954178f,0.627297878265f,0.992580235004f,-1.985160470009f,0.992580235004f,-1.985132932663f,0.985188126564f}, - {1.488207340240f,-2.248480796814f,0.906192243099f,-1.391770243645f,0.537688970566f,0.990125238895f,-1.980250477791f,0.990125238895f,-1.980201482773f,0.980299532413f}, - {1.480212569237f,-2.173723459244f,0.862487196922f,-1.340346932411f,0.509323298931f,0.989259064198f,-1.978518128395f,0.989259064198f,-1.978460073471f,0.978576123714f}, - {1.444234013557f,-1.839543223381f,0.685432314873f,-1.107139229774f,0.397262454033f,0.985242545605f,-1.970485091209f,0.985242545605f,-1.970375299454f,0.970594763756f}, - {1.403080821037f,-1.461511373520f,0.519652962685f,-0.837045848370f,0.298268288374f,0.980395674706f,-1.960791349411f,0.980395674706f,-1.960597157478f,0.960985362530f}, - {1.389132857323f,-1.334347724915f,0.471855700016f,-0.744739949703f,0.271380871534f,0.978689610958f,-1.957379221916f,0.978689610958f,-1.957149744034f,0.957608699799f}, - {1.327733159065f,-0.780098080635f,0.309720277786f,-0.334008187056f,0.191363617778f,0.970807731152f,-1.941615462303f,0.970807731152f,-1.941183090210f,0.942047894001f}, - {1.308971643448f,-0.612507879734f,0.275601744652f,-0.207099482417f,0.179165065289f,0.968287348747f,-1.936574697495f,0.968287348747f,-1.936063885689f,0.937085747719f} -}; + {1.559742927551f,-2.926673889160f,1.378173947334f,-1.844531774521f,0.855774641037f,0.997517585754f,-1.995035171509f,0.997517585754f,-1.995032072067f,0.995038211346f}, + {1.557545065880f,-2.905559301376f,1.361245870590f,-1.830842256546f,0.844074070454f,0.997298538685f,-1.994597077370f,0.997298538685f,-1.994593381882f,0.994600534439f}, + {1.547380685806f,-2.808161973953f,1.285161137581f,-1.767331838608f,0.791711509228f,0.996279776096f,-1.992559552193f,0.996279776096f,-1.992552518845f,0.992566406727f}, + {1.535182833672f,-2.691803932190f,1.198426246643f,-1.690699458122f,0.732504665852f,0.995044350624f,-1.990088701248f,0.995044350624f,-1.990076303482f,0.990100920200f}, + {1.530909657478f,-2.651169300079f,1.169166922569f,-1.663750052452f,0.712657511234f,0.994607865810f,-1.989215731621f,0.994607865810f,-1.989201068878f,0.989230215549f}, + {1.511321425438f,-2.465713739395f,1.042117238045f,-1.539572954178f,0.627297878265f,0.992580235004f,-1.985160470009f,0.992580235004f,-1.985132932663f,0.985188126564f}, + {1.488207340240f,-2.248480796814f,0.906192243099f,-1.391770243645f,0.537688970566f,0.990125238895f,-1.980250477791f,0.990125238895f,-1.980201482773f,0.980299532413f}, + {1.480212569237f,-2.173723459244f,0.862487196922f,-1.340346932411f,0.509323298931f,0.989259064198f,-1.978518128395f,0.989259064198f,-1.978460073471f,0.978576123714f}, + {1.444234013557f,-1.839543223381f,0.685432314873f,-1.107139229774f,0.397262454033f,0.985242545605f,-1.970485091209f,0.985242545605f,-1.970375299454f,0.970594763756f}, + {1.403080821037f,-1.461511373520f,0.519652962685f,-0.837045848370f,0.298268288374f,0.980395674706f,-1.960791349411f,0.980395674706f,-1.960597157478f,0.960985362530f}, + {1.389132857323f,-1.334347724915f,0.471855700016f,-0.744739949703f,0.271380871534f,0.978689610958f,-1.957379221916f,0.978689610958f,-1.957149744034f,0.957608699799f}, + {1.327733159065f,-0.780098080635f,0.309720277786f,-0.334008187056f,0.191363617778f,0.970807731152f,-1.941615462303f,0.970807731152f,-1.941183090210f,0.942047894001f}, + {1.308971643448f,-0.612507879734f,0.275601744652f,-0.207099482417f,0.179165065289f,0.968287348747f,-1.936574697495f,0.968287348747f,-1.936063885689f,0.937085747719f} +}; @@ -74,60 +74,60 @@ const ia_delta_gain_code_table_struct ia_drc_gain_tbls_prof_0_1[NUM_GAIN_TBL_PRO { 10, 0x1AD , -1.250f }, { 11, 0x0E2 , -1.750f }, { 11, 0x0E3 , -1.625f } - + }; const ia_delta_gain_code_table_struct ia_drc_gain_tbls_prof_2[NUM_GAIN_TBL_PROF_2_ENTRIES] = { - { 3, 0x007, -0.125f }, - { 4, 0x00C, -0.625f }, - { 4, 0x009, -0.500f }, - { 4, 0x005, -0.375f }, - { 4, 0x003, -0.250f }, - { 4, 0x001, 0.000f }, - { 4, 0x00B, 0.125f }, - { 5, 0x011, -0.875f }, - { 5, 0x00E, -0.750f }, - { 5, 0x005, 0.250f }, - { 5, 0x004, 0.375f }, - { 5, 0x008, 0.500f }, - { 5, 0x000, 0.625f }, - { 5, 0x00D, 0.750f }, - { 5, 0x00F, 0.875f }, - { 5, 0x010, 1.000f }, - { 5, 0x01B, 1.125f }, - { 6, 0x02B, -1.250f }, - { 6, 0x028, -1.125f }, - { 6, 0x002, -1.000f }, - { 6, 0x012, 1.250f }, - { 6, 0x018, 1.375f }, - { 6, 0x029, 1.500f }, - { 7, 0x06A, -4.000f }, - { 7, 0x054, -1.750f }, - { 7, 0x068, -1.625f }, - { 7, 0x026, -1.500f }, - { 7, 0x006, -1.375f }, - { 7, 0x032, 1.625f }, - { 8, 0x0D2, -2.250f }, - { 8, 0x0AB, -2.125f }, - { 8, 0x0AA, -2.000f }, - { 8, 0x04F, -1.875f }, - { 8, 0x04E, 1.750f }, - { 8, 0x0D7, 1.875f }, - { 8, 0x00E, 2.000f }, - { 9, 0x1AD, -3.625f }, - { 9, 0x1AC, -3.375f }, - { 9, 0x1A6, -3.250f }, - { 9, 0x0CD, -3.125f }, - { 9, 0x0CE, -2.750f }, - { 9, 0x1A7, -2.625f }, - { 9, 0x01F, -2.500f }, - { 9, 0x0CC, -2.375f }, - { 10, 0x03C, -3.500f }, - { 10, 0x19E, -3.000f }, - { 10, 0x19F, -2.875f }, - { 11, 0x07A, -3.875f }, - { 11, 0x07B, -3.750f } + { 3, 0x007, -0.125f }, + { 4, 0x00C, -0.625f }, + { 4, 0x009, -0.500f }, + { 4, 0x005, -0.375f }, + { 4, 0x003, -0.250f }, + { 4, 0x001, 0.000f }, + { 4, 0x00B, 0.125f }, + { 5, 0x011, -0.875f }, + { 5, 0x00E, -0.750f }, + { 5, 0x005, 0.250f }, + { 5, 0x004, 0.375f }, + { 5, 0x008, 0.500f }, + { 5, 0x000, 0.625f }, + { 5, 0x00D, 0.750f }, + { 5, 0x00F, 0.875f }, + { 5, 0x010, 1.000f }, + { 5, 0x01B, 1.125f }, + { 6, 0x02B, -1.250f }, + { 6, 0x028, -1.125f }, + { 6, 0x002, -1.000f }, + { 6, 0x012, 1.250f }, + { 6, 0x018, 1.375f }, + { 6, 0x029, 1.500f }, + { 7, 0x06A, -4.000f }, + { 7, 0x054, -1.750f }, + { 7, 0x068, -1.625f }, + { 7, 0x026, -1.500f }, + { 7, 0x006, -1.375f }, + { 7, 0x032, 1.625f }, + { 8, 0x0D2, -2.250f }, + { 8, 0x0AB, -2.125f }, + { 8, 0x0AA, -2.000f }, + { 8, 0x04F, -1.875f }, + { 8, 0x04E, 1.750f }, + { 8, 0x0D7, 1.875f }, + { 8, 0x00E, 2.000f }, + { 9, 0x1AD, -3.625f }, + { 9, 0x1AC, -3.375f }, + { 9, 0x1A6, -3.250f }, + { 9, 0x0CD, -3.125f }, + { 9, 0x0CE, -2.750f }, + { 9, 0x1A7, -2.625f }, + { 9, 0x01F, -2.500f }, + { 9, 0x0CC, -2.375f }, + { 10, 0x03C, -3.500f }, + { 10, 0x19E, -3.000f }, + { 10, 0x19F, -2.875f }, + { 11, 0x07A, -3.875f }, + { 11, 0x07B, -3.750f } }; const FLOAT32 channel_weight[] = @@ -149,7 +149,7 @@ const FLOAT32 channel_weight[] = -40.0f, -1000.0f }; - + const FLOAT32 dwnmix_coeff_v1[] = { 10.00f, @@ -186,65 +186,65 @@ const FLOAT32 dwnmix_coeff_v1[] = -100000.0f }; -const FLOAT32 eq_slope_tbl [] = +const FLOAT32 eq_slope_tbl [] = { - -32.0f, - -24.0f, - -18.0f, - -12.0f, - -7.0f, - -4.0f, - -2.0f, - -1.0f, - 1.0f, - 2.0f, - 4.0f, - 7.0f, - 12.0f, - 18.0f, - 24.0f, - 32.0f + -32.0f, + -24.0f, + -18.0f, + -12.0f, + -7.0f, + -4.0f, + -2.0f, + -1.0f, + 1.0f, + 2.0f, + 4.0f, + 7.0f, + 12.0f, + 18.0f, + 24.0f, + 32.0f }; -const FLOAT32 eq_gain_delta_tbl[] = +const FLOAT32 eq_gain_delta_tbl[] = { -22.0f, -16.0f, -13.0f, -11.0f, - -9.0f, - -7.0f, - -6.0f, - -5.0f, - -4.0f, - -3.0f, - -2.5f, - -2.0f, - -1.5f, - -1.0f, - -0.5f, - 0.0f, - 0.5f, - 1.0f, - 1.5f, - 2.0f, - 2.5f, - 3.0f, - 4.0f, - 5.0f, - 6.0f, - 7.0f, - 9.0f, - 11.0f, - 13.0f, - 16.0f, - 22.0f, - 32.0f, + -9.0f, + -7.0f, + -6.0f, + -5.0f, + -4.0f, + -3.0f, + -2.5f, + -2.0f, + -1.5f, + -1.0f, + -0.5f, + 0.0f, + 0.5f, + 1.0f, + 1.5f, + 2.0f, + 2.5f, + 3.0f, + 4.0f, + 5.0f, + 6.0f, + 7.0f, + 9.0f, + 11.0f, + 13.0f, + 16.0f, + 22.0f, + 32.0f, }; -const FLOAT32 zero_pole_radius_tbl[] = +const FLOAT32 zero_pole_radius_tbl[] = { 0.00000000E+00f, 7.57409621E-11f, @@ -376,7 +376,7 @@ const FLOAT32 zero_pole_radius_tbl[] = 9.77237225E-01f }; -const FLOAT32 zero_pole_angle_tbl[] = +const FLOAT32 zero_pole_angle_tbl[] = { 0.00000000E+00f, 6.90533966E-04f, @@ -508,7 +508,7 @@ const FLOAT32 zero_pole_angle_tbl[] = 1.00000000E+00f }; -const FLOAT32 shape_filt_lf_y1_bound_tbl[][3] = +const FLOAT32 shape_filt_lf_y1_bound_tbl[][3] = { {-0.994f,-0.996f, -1.0f}, {-0.99f, -0.995f, -0.999f}, @@ -516,7 +516,7 @@ const FLOAT32 shape_filt_lf_y1_bound_tbl[][3] = {-0.97f, -0.983f, -0.994f}, }; -const FLOAT32 shape_filt_hf_y1_bound_tbl[][3] = +const FLOAT32 shape_filt_hf_y1_bound_tbl[][3] = { {0.15f, 0.75f, 1.05f }, {0.43f, 0.87f, 1.07f}, @@ -660,13 +660,13 @@ WORD32 measurement_system_rms_e_tbl[] = {0, 0, 1, 0, WORD32 measurement_method_prog_loudness_tbl[] = {0, 0, 1, 0, 0, 0, 0, 2, 3, 4, 0, 0}; WORD32 measurement_method_peak_loudness_tbl[] = {0, 7, 0, 0, 0, 0, 6, 5, 4, 3, 2, 1}; -const ia_loc_sys_interface_struct loc_sys_interface[]= -{ +const ia_loc_sys_interface_struct loc_sys_interface[]= +{ {0, 1, {0,0,0}, 0, 0}, {0, 1, {2,0,0}, 0, 0}, }; -const ia_loc_loudness_norm_ctrl_interface_struct loc_loudness_norm_ctrl_interface[] = +const ia_loc_loudness_norm_ctrl_interface_struct loc_loudness_norm_ctrl_interface[] = { {0,0.0f}, {0,0.0f}, @@ -674,7 +674,7 @@ const ia_loc_loudness_norm_ctrl_interface_struct loc_loudness_norm_ctrl_interfac const ia_loc_loudness_norm_param_interface_struct loc_loudness_norm_param_interface[] = { - + {0, 0, LOUDNESS_DEVIATION_MAX_DEFAULT, USER_METHOD_DEFINITION_PROGRAM_LOUDNESS, USER_MEASUREMENT_SYSTEM_BS_1770_3, USER_LOUDNESS_PREPROCESSING_OFF, 20, LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT, 0.0f, 0.0f}, {0, 0, LOUDNESS_DEVIATION_MAX_DEFAULT, USER_METHOD_DEFINITION_PROGRAM_LOUDNESS, USER_MEASUREMENT_SYSTEM_BS_1770_3, USER_LOUDNESS_PREPROCESSING_OFF, 20, LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT, 0.0f, 0.0f}, @@ -682,11 +682,11 @@ const ia_loc_loudness_norm_param_interface_struct loc_loudness_norm_param_interf const ia_loc_drc_interface_struct loc_dyn_range_ctrl_interface[] = { - + {1, 3, {MATCH_EFFECT_TYPE, MATCH_DYNAMIC_RANGE, MATCH_DRC_CHARACTERISTIC}, SHORT_TERM_LOUDNESS_TO_AVG, 1, 5.0f, 3.0f, 10.0f, 3}, {1, 3, {MATCH_EFFECT_TYPE, MATCH_DYNAMIC_RANGE, MATCH_DRC_CHARACTERISTIC}, TOP_OF_LOUDNESS_RANGE_TO_AVG, 0, 5.0f, 3.0f, 10.0f, 3}, - + }; @@ -694,13 +694,13 @@ const ia_loc_requested_drc_effect_struct loc_requested_drc_effect_type_str[] = { {1, 1, {EFFECT_TYPE_REQUESTED_NIGHT, EFFECT_TYPE_REQUESTED_GENERAL_COMPR, EFFECT_TYPE_REQUESTED_ARTISTIC, EFFECT_TYPE_REQUESTED_LIMITED, EFFECT_TYPE_REQUESTED_DIALOG}}, {4, 1, {EFFECT_TYPE_REQUESTED_LOWLEVEL, EFFECT_TYPE_REQUESTED_NIGHT, EFFECT_TYPE_REQUESTED_LIMITED, EFFECT_TYPE_REQUESTED_ARTISTIC, EFFECT_TYPE_REQUESTED_DIALOG}}, - + }; const ia_loc_drc_parameter_interface_struct loc_drc_parameter_interface[] = { - + {1.0f,1.0f,0}, {1.0f,1.0f,0}, }; @@ -820,30 +820,30 @@ const ia_loc_drc_parameter_interface_struct loc_drc_parameter_interface[] = { 0.5859400000000000f, 0.6015600000000000f, 0.6171900000000000f, - 0.6328100000000000f, - 0.6484400000000000f, - 0.6640600000000000f, - 0.6796900000000000f, - 0.6953100000000000f, - 0.7109400000000000f, - 0.7265600000000000f, - 0.7421900000000000f, - 0.7578100000000000f, - 0.7734400000000000f, - 0.7890600000000000f, - 0.8046900000000000f, - 0.8203100000000000f, - 0.8359400000000000f, - 0.8515600000000000f, - 0.8671900000000000f, - 0.8828100000000000f, - 0.8984400000000000f, - 0.9140600000000000f, - 0.9296900000000000f, - 0.9453100000000000f, - 0.9609400000000000f, - 0.9765600000000000f, - 0.9921900000000000f + 0.6328100000000000f, + 0.6484400000000000f, + 0.6640600000000000f, + 0.6796900000000000f, + 0.6953100000000000f, + 0.7109400000000000f, + 0.7265600000000000f, + 0.7421900000000000f, + 0.7578100000000000f, + 0.7734400000000000f, + 0.7890600000000000f, + 0.8046900000000000f, + 0.8203100000000000f, + 0.8359400000000000f, + 0.8515600000000000f, + 0.8671900000000000f, + 0.8828100000000000f, + 0.8984400000000000f, + 0.9140600000000000f, + 0.9296900000000000f, + 0.9453100000000000f, + 0.9609400000000000f, + 0.9765600000000000f, + 0.9921900000000000f }; FLOAT32 f_bands_nrm_STFT256[257]={ @@ -1105,7 +1105,7 @@ const ia_loc_drc_parameter_interface_struct loc_drc_parameter_interface[] = { 0.996093750000000f, 1.000000000000000f }; - + FLOAT64 qmf_filter_coeff[640] = { 0, -0.00055252865047, -0.00056176925738, -0.00049475180896, @@ -1271,21 +1271,21 @@ FLOAT64 qmf_filter_coeff[640] = { }; const ia_filter_bank_params_struct normal_cross_freq[FILTER_BANK_PARAMETER_COUNT] = { - {2.0f/1024.0f, 0.0000373252f, 0.9913600345f}, - {3.0f/1024.0f, 0.0000836207f, 0.9870680830f}, - {4.0f/1024.0f, 0.0001480220f, 0.9827947083f}, - {5.0f/1024.0f, 0.0002302960f, 0.9785398263f}, - {6.0f/1024.0f, 0.0003302134f, 0.9743033527f}, - {2.0f/256.0f, 0.0005820761f, 0.9658852897f}, - {3.0f/256.0f, 0.0012877837f, 0.9492662926f}, - {2.0f/128.0f, 0.0022515827f, 0.9329321561f}, - {3.0f/128.0f, 0.0049030350f, 0.9010958535f}, - {2.0f/64.0f, 0.0084426929f, 0.8703307793f}, - {3.0f/64.0f, 0.0178631928f, 0.8118317459f}, - {2.0f/32.0f, 0.0299545822f, 0.7570763753f}, - {3.0f/32.0f, 0.0604985076f, 0.6574551915f}, - {2.0f/16.0f, 0.0976310729f, 0.5690355937f}, - {3.0f/16.0f, 0.1866943331f, 0.4181633458f}, - {2.0f/8.0f, 0.2928932188f, 0.2928932188f}, + {2.0f/1024.0f, 0.0000373252f, 0.9913600345f}, + {3.0f/1024.0f, 0.0000836207f, 0.9870680830f}, + {4.0f/1024.0f, 0.0001480220f, 0.9827947083f}, + {5.0f/1024.0f, 0.0002302960f, 0.9785398263f}, + {6.0f/1024.0f, 0.0003302134f, 0.9743033527f}, + {2.0f/256.0f, 0.0005820761f, 0.9658852897f}, + {3.0f/256.0f, 0.0012877837f, 0.9492662926f}, + {2.0f/128.0f, 0.0022515827f, 0.9329321561f}, + {3.0f/128.0f, 0.0049030350f, 0.9010958535f}, + {2.0f/64.0f, 0.0084426929f, 0.8703307793f}, + {3.0f/64.0f, 0.0178631928f, 0.8118317459f}, + {2.0f/32.0f, 0.0299545822f, 0.7570763753f}, + {3.0f/32.0f, 0.0604985076f, 0.6574551915f}, + {2.0f/16.0f, 0.0976310729f, 0.5690355937f}, + {3.0f/16.0f, 0.1866943331f, 0.4181633458f}, + {2.0f/8.0f, 0.2928932188f, 0.2928932188f}, }; diff --git a/decoder/drc_src/impd_drc_rom.h b/decoder/drc_src/impd_drc_rom.h index 7078f95..c0c7933 100644 --- a/decoder/drc_src/impd_drc_rom.h +++ b/decoder/drc_src/impd_drc_rom.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_ROM_H #define IMPD_DRC_ROM_H #define MAX_NUM_QMF_BANDS 128 @@ -32,7 +32,7 @@ extern const ia_delta_gain_code_table_struct ia_drc_gain_tbls_prof_0_1[NUM_GAIN_ extern const ia_delta_gain_code_table_struct ia_drc_gain_tbls_prof_2[NUM_GAIN_TBL_PROF_2_ENTRIES]; extern const FLOAT32 channel_weight[]; - + extern const FLOAT32 dwnmix_coeff_v1[]; extern const FLOAT32 eq_slope_tbl []; @@ -77,7 +77,7 @@ extern WORD32 measurement_system_rms_c_tbl[]; extern WORD32 measurement_system_rms_d_tbl[]; extern WORD32 measurement_system_rms_e_tbl[]; extern WORD32 measurement_method_prog_loudness_tbl[]; -extern WORD32 measurement_method_peak_loudness_tbl[]; +extern WORD32 measurement_method_peak_loudness_tbl[]; #define MAX_NUM_DOWNMIX_ID_REQUESTS_LOCAL 3 @@ -97,8 +97,8 @@ typedef struct { FLOAT32 target_loudness; } ia_loc_loudness_norm_ctrl_interface_struct; -extern const ia_loc_loudness_norm_ctrl_interface_struct loc_loudness_norm_ctrl_interface[]; - +extern const ia_loc_loudness_norm_ctrl_interface_struct loc_loudness_norm_ctrl_interface[]; + typedef struct { WORD32 album_mode; WORD32 peak_limiter; @@ -137,7 +137,7 @@ typedef struct { } ia_loc_requested_drc_effect_struct; extern const ia_loc_requested_drc_effect_struct loc_requested_drc_effect_type_str[]; - + typedef struct { FLOAT32 compress; FLOAT32 boost; @@ -153,4 +153,4 @@ extern FLOAT32 f_bands_nrm_STFT256[257]; FLOAT64 qmf_filter_coeff[640]; extern const ia_filter_bank_params_struct normal_cross_freq[FILTER_BANK_PARAMETER_COUNT]; -#endif +#endif diff --git a/decoder/drc_src/impd_drc_sel_proc_drc_set_sel.h b/decoder/drc_src/impd_drc_sel_proc_drc_set_sel.h index 77747ee..18c5697 100644 --- a/decoder/drc_src/impd_drc_sel_proc_drc_set_sel.h +++ b/decoder/drc_src/impd_drc_sel_proc_drc_set_sel.h @@ -1,33 +1,33 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_SEL_PROC_DRC_SET_SEL_H #define IMPD_DRC_SEL_PROC_DRC_SET_SEL_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - - + + #define SELECTION_FLAG_DRC_TARGET_LOUDNESS_MATCH (1<<0) #define SELECTION_FLAG_EXPLICIT_PEAK_INFO_PRESENT (1<<1) - + typedef struct { WORD32 drc_instructions_index; WORD32 downmix_id_request_index; @@ -42,7 +42,7 @@ typedef struct { WORD32 impd_validate_requested_drc_feature(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct); - + WORD32 impd_map_requested_effect_bit_idx(WORD32 requested_effect_type, WORD32* effect_bit_idx); @@ -87,7 +87,7 @@ impd_get_dependent_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); WORD32 impd_get_selected_loud_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, WORD32 loudEqSetIdSelected); - + WORD32 impd_select_drcs_without_compr_effects (ia_drc_config* pstr_drc_config, WORD32* match_found_flag, @@ -112,8 +112,8 @@ impd_match_effect_types(ia_drc_config* pstr_drc_config, WORD32 impd_match_dynamic_range(ia_drc_config* pstr_drc_config, ia_drc_loudness_info_set_struct* pstr_loudness_info, - ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, - WORD32 num_drc_requests, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + WORD32 num_drc_requests, WORD32* selection_candidate_count, ia_selection_candidate_info_struct* selection_candidate_info); @@ -129,7 +129,7 @@ impd_match_drc_characteristic(ia_drc_config* pstr_drc_config, WORD32 requested_drc_characteristic, WORD32* selection_candidate_count, ia_selection_candidate_info_struct* selection_candidate_info); - + VOID impd_select_drc_coeff3(ia_drc_config* drc_config, ia_uni_drc_coeffs_struct** str_p_loc_drc_coefficients_uni_drc); @@ -138,7 +138,7 @@ impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_param ia_drc_config* pstr_drc_config, ia_drc_loudness_info_set_struct* pstr_loudness_info, WORD32 restrict_to_drc_with_album_loudness, - ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, WORD32* selection_candidate_count, ia_selection_candidate_info_struct* selection_candidate_info); @@ -152,11 +152,11 @@ WORD32 impd_drc_set_final_selection(ia_drc_config* pstr_drc_config, WORD32 impd_match_eq_set_purpose(ia_drc_config* drc_config, WORD32 eq_set_purpose_requested, WORD32* eq_set_id_valid_flag, - WORD32* selection_candidate_count, - ia_selection_candidate_info_struct* selection_candidate_info, - ia_selection_candidate_info_struct* selection_candidate_info_step_2 - ); - + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info, + ia_selection_candidate_info_struct* selection_candidate_info_step_2 + ); + WORD32 impd_select_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, WORD32* drc_set_id_selected @@ -173,10 +173,10 @@ impd_drc_sel_proc_init_sel_proc_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_p WORD32 impd_drc_sel_proc_init_interface_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, - ia_drc_interface_struct* pstr_drc_interface); - - - + ia_drc_interface_struct* pstr_drc_interface); + + + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/decoder/drc_src/impd_drc_selection_process.c b/decoder/drc_src/impd_drc_selection_process.c index 606a689..b7b6e36 100644 --- a/decoder/drc_src/impd_drc_selection_process.c +++ b/decoder/drc_src/impd_drc_selection_process.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -35,16 +35,16 @@ WORD32 impd_drc_uni_selction_proc_init(ia_drc_sel_pro_struct* pstr_drc_uni_sel_p WORD32 subband_domain_mode) { WORD32 err = 0; - + if (pstr_drc_uni_sel_proc == NULL) { return 1; } - + if (pstr_drc_uni_sel_proc->first_frame == 1) { err = impd_drc_sel_proc_init_dflt(pstr_drc_uni_sel_proc); if (err) return (err); } - + err = impd_drc_sel_proc_init_sel_proc_params(pstr_drc_uni_sel_proc, pstr_drc_sel_proc_params_struct); if (err) return (err); @@ -65,7 +65,7 @@ WORD32 impd_drc_uni_selction_proc_init(ia_drc_sel_pro_struct* pstr_drc_uni_sel_p err = impd_drc_sel_proc_init_interface_params(pstr_drc_uni_sel_proc, pstr_drc_interface); if (err) return (err); - + pstr_drc_uni_sel_proc->subband_domain_mode = subband_domain_mode; return 0; @@ -81,15 +81,15 @@ impd_drc_uni_sel_proc_process(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, WORD32 i, err, drc_set_id_selected, activeDrcSetIndex; WORD32 eq_set_id_selected; WORD32 loudEqSetIdSelected; - - + + if (pstr_drc_config != NULL) { if ( memcmp ( &pstr_drc_uni_sel_proc->drc_config, pstr_drc_config, sizeof(ia_drc_config) )) { pstr_drc_uni_sel_proc->drc_config = *pstr_drc_config; pstr_drc_uni_sel_proc->drc_config_flag = 1; - + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_channel_count != pstr_drc_uni_sel_proc->drc_config.channel_layout.base_channel_count) { @@ -127,12 +127,12 @@ impd_drc_uni_sel_proc_process(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, &pstr_drc_uni_sel_proc->drc_config); if (err) return (err); } - + if (pstr_drc_uni_sel_proc->drc_config_flag || pstr_drc_uni_sel_proc->loudness_info_set_flag || pstr_drc_uni_sel_proc->sel_proc_request_flag) { WORD32 repeat_selection = 1; WORD32 loop_cnt = 0; - + err = impd_manage_drc_complexity (pstr_drc_uni_sel_proc, pstr_drc_config); if (err) return(err); err = impd_manage_eq_complexity (pstr_drc_uni_sel_proc, pstr_drc_config); @@ -145,44 +145,44 @@ impd_drc_uni_sel_proc_process(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, , &loudEqSetIdSelected ); if (err) return (err); - + err = impd_get_selected_drc_set(pstr_drc_uni_sel_proc, drc_set_id_selected); if (err) return (err); - + err = impd_get_dependent_drc_set(pstr_drc_uni_sel_proc); if (err) return (err); - + err = impd_get_fading_drc_set(pstr_drc_uni_sel_proc); if (err) return (err); - + err = impd_get_ducking_drc_set(pstr_drc_uni_sel_proc); if (err) return (err); - + pstr_drc_uni_sel_proc->eq_inst_index[0] = -1; pstr_drc_uni_sel_proc->eq_inst_index[1] = -1; - + err = impd_get_selected_eq_set(pstr_drc_uni_sel_proc, eq_set_id_selected); if (err) return (err); - + err = impd_get_dependent_eq_set(pstr_drc_uni_sel_proc); if (err) return (err); - + err = impd_get_selected_loud_eq_set(pstr_drc_uni_sel_proc, loudEqSetIdSelected); if (err) return (err); - + activeDrcSetIndex = 0; - for (i=SUB_DRC_COUNT-1; i>=0; i--) { + for (i=SUB_DRC_COUNT-1; i>=0; i--) { WORD32 drc_instructions_index = pstr_drc_uni_sel_proc->drc_instructions_index[i]; ia_drc_instructions_struct str_drc_instruction_str; - + str_drc_instruction_str = pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[drc_instructions_index]; - if (drc_instructions_index >= 0 && str_drc_instruction_str.drc_set_id > 0) + if (drc_instructions_index >= 0 && str_drc_instruction_str.drc_set_id > 0) { pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[activeDrcSetIndex] = str_drc_instruction_str.drc_set_id; - if ((i==3) && (str_drc_instruction_str.drc_set_effect & (EFFECT_BIT_DUCK_SELF | EFFECT_BIT_DUCK_OTHER))) { + if ((i==3) && (str_drc_instruction_str.drc_set_effect & (EFFECT_BIT_DUCK_SELF | EFFECT_BIT_DUCK_OTHER))) { pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_downmix_ids[activeDrcSetIndex] = 0; } else { @@ -192,25 +192,25 @@ impd_drc_uni_sel_proc_process(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_downmix_ids[activeDrcSetIndex] = 0; } } - + activeDrcSetIndex++; } } if (activeDrcSetIndex <= 3) { pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.num_sel_drc_sets = activeDrcSetIndex; - } else - { + } else + { pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.num_sel_drc_sets = -1; return(UNEXPECTED_ERROR); } - + impd_sel_downmix_matrix(pstr_drc_uni_sel_proc, &pstr_drc_uni_sel_proc->drc_config); err = impd_manage_complexity (pstr_drc_uni_sel_proc, pstr_drc_config, &repeat_selection); if (err) return(err); - + loop_cnt++; if (loop_cnt > 100) { @@ -223,11 +223,11 @@ impd_drc_uni_sel_proc_process(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.compress = pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.compress; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.drc_characteristic_target = pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.drc_characteristic_target; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.loudness_normalization_gain_db += pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_modification_db; - + } - for (i=0; i<2; i++) + for (i=0; i<2; i++) { pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_eq_set_ids[i] = pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.str_eq_instructions[pstr_drc_uni_sel_proc->eq_inst_index[i]].eq_set_id; } @@ -240,16 +240,16 @@ impd_drc_uni_sel_proc_process(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_loud_eq_id = 0; } *hia_drc_sel_proc_output_struct = pstr_drc_uni_sel_proc->uni_drc_sel_proc_output; - + return 0; } - + WORD32 impd_map_target_config_req_downmix_id(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_config* pstr_drc_config) { WORD32 i, dwnmix_instructions_count; WORD32 target_ch_count_prelim = pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_channel_count; - + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests = 0; switch (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type) { case 0: @@ -324,19 +324,19 @@ VOID impd_sel_downmix_matrix(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_config* pstr_drc_config) { WORD32 i, j, n; - + pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.base_channel_count = pstr_drc_config->channel_layout.base_channel_count; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.target_channel_count = pstr_drc_config->channel_layout.base_channel_count; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.target_layout = -1; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.downmix_matrix_present = 0; pstr_drc_uni_sel_proc->downmix_inst_index_sel = -1; - + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.active_downmix_id != 0) { for (n=0; ndwnmix_instructions_count; n++) { ia_downmix_instructions_struct* dwnmix_instructions = &(pstr_drc_config->dwnmix_instructions[n]); - + if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.active_downmix_id == dwnmix_instructions->downmix_id) { pstr_drc_uni_sel_proc->downmix_inst_index_sel = n; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.target_channel_count = dwnmix_instructions->target_channel_count; @@ -363,9 +363,9 @@ WORD32 impd_get_selected_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, WORD32 eq_set_id_selected) { WORD32 n; - + pstr_drc_uni_sel_proc->eq_inst_index_sel = -1; - + if (eq_set_id_selected > 0) { for(n=0; ndrc_config.str_drc_config_ext.eq_instructions_count; n++) @@ -396,12 +396,12 @@ WORD32 impd_get_dependent_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) if (pstr_drc_uni_sel_proc->eq_inst_index_sel >= 0) { str_eq_instructions = &(pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.str_eq_instructions[pstr_drc_uni_sel_proc->eq_inst_index_sel]); - + if (str_eq_instructions->depends_on_eq_set_present == 1) { WORD32 n; WORD32 dependsOnEqSetID = str_eq_instructions->depends_on_eq_set; - + for(n=0; ndrc_config.str_drc_config_ext.eq_instructions_count; n++) { if (pstr_drc_uni_sel_proc->drc_config.str_drc_config_ext.str_eq_instructions[n].eq_set_id == dependsOnEqSetID) break; @@ -427,9 +427,9 @@ WORD32 impd_get_selected_loud_eq_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_pro WORD32 loudEqSetIdSelected) { WORD32 n; - + pstr_drc_uni_sel_proc->loud_eq_inst_index_sel = -1; - + if (loudEqSetIdSelected > 0) { for(n=0; ndrc_config.str_drc_config_ext.loud_eq_instructions_count; n++) @@ -452,7 +452,7 @@ WORD32 impd_select_loud_eq(ia_drc_config* pstr_drc_config, WORD32* loud_eq_id_sel) { WORD32 i, c, d, e; - + *loud_eq_id_sel = 0; for (i=0; istr_drc_config_ext.loud_eq_instructions_count; i++) { @@ -478,7 +478,7 @@ WORD32 impd_select_loud_eq(ia_drc_config* pstr_drc_config, } return (0); } - + WORD32 impd_match_eq_set(ia_drc_config* drc_config, WORD32 downmix_id, WORD32 drc_set_id, @@ -493,7 +493,7 @@ WORD32 impd_match_eq_set(ia_drc_config* drc_config, for (i=0; istr_drc_config_ext.eq_instructions_count; i++) { str_eq_instructions = &drc_config->str_drc_config_ext.str_eq_instructions[i]; - + if (str_eq_instructions->depends_on_eq_set_present == 0) { if (str_eq_instructions->no_independent_eq_use == 1) continue; } @@ -516,52 +516,52 @@ WORD32 impd_match_eq_set(ia_drc_config* drc_config, WORD32 impd_match_eq_set_purpose(ia_drc_config* drc_config, WORD32 eq_set_purpose_requested, WORD32* eq_set_id_valid_flag, - WORD32* selection_candidate_count, - ia_selection_candidate_info_struct* selection_candidate_info, - ia_selection_candidate_info_struct* selection_candidate_info_step_2 - ) + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info, + ia_selection_candidate_info_struct* selection_candidate_info_step_2 + ) { WORD32 i,j,k; - WORD32 match_found_flag; - WORD32 loop_cnt = 0; + WORD32 match_found_flag; + WORD32 loop_cnt = 0; ia_eq_instructions_struct* str_eq_instructions = NULL; - match_found_flag = 0; - - k = 0; - while ((k==0) && (loop_cnt < 2)) - { - for (j=0; j < *selection_candidate_count; j++) - { - WORD32 eq_set_id_requested = selection_candidate_info[j].eq_set_id; - - for (i=0; istr_drc_config_ext.eq_instructions_count; i++) - { - str_eq_instructions = &drc_config->str_drc_config_ext.str_eq_instructions[i]; - - if (str_eq_instructions->depends_on_eq_set_present == 0) { - if (eq_set_id_valid_flag[str_eq_instructions->eq_set_id] == 0) continue; - } - if (eq_set_id_valid_flag[str_eq_instructions->eq_set_id] == 0) continue; - if ((str_eq_instructions->eq_set_id == eq_set_id_requested) && (str_eq_instructions->eq_set_purpose & eq_set_purpose_requested)) - { - match_found_flag = 1; - } - } - - if (match_found_flag > 0) - { - memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[j], sizeof(ia_selection_candidate_info_struct)); - k++; - } - } - eq_set_purpose_requested = EQ_PURPOSE_DEFAULT; - loop_cnt++; - } - - if (k>0) { - memcpy(&selection_candidate_info[0], &selection_candidate_info_step_2[0], k * sizeof(ia_selection_candidate_info_struct)); - *selection_candidate_count = k; - } + match_found_flag = 0; + + k = 0; + while ((k==0) && (loop_cnt < 2)) + { + for (j=0; j < *selection_candidate_count; j++) + { + WORD32 eq_set_id_requested = selection_candidate_info[j].eq_set_id; + + for (i=0; istr_drc_config_ext.eq_instructions_count; i++) + { + str_eq_instructions = &drc_config->str_drc_config_ext.str_eq_instructions[i]; + + if (str_eq_instructions->depends_on_eq_set_present == 0) { + if (eq_set_id_valid_flag[str_eq_instructions->eq_set_id] == 0) continue; + } + if (eq_set_id_valid_flag[str_eq_instructions->eq_set_id] == 0) continue; + if ((str_eq_instructions->eq_set_id == eq_set_id_requested) && (str_eq_instructions->eq_set_purpose & eq_set_purpose_requested)) + { + match_found_flag = 1; + } + } + + if (match_found_flag > 0) + { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[j], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + eq_set_purpose_requested = EQ_PURPOSE_DEFAULT; + loop_cnt++; + } + + if (k>0) { + memcpy(&selection_candidate_info[0], &selection_candidate_info_step_2[0], k * sizeof(ia_selection_candidate_info_struct)); + *selection_candidate_count = k; + } return(0); } @@ -623,7 +623,7 @@ VOID impd_select_drc_coeff3(ia_drc_config* drc_config, *str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[cV0]); } else { - *str_p_loc_drc_coefficients_uni_drc = NULL; + *str_p_loc_drc_coefficients_uni_drc = NULL; } return; } @@ -678,7 +678,7 @@ WORD32 impd_manage_drc_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, } } complexityDrcPrelim =(FLOAT32)( channel_count * (1 << str_drc_instruction_str->drc_set_complexity_level)); - + if (str_drc_instruction_str->depends_on_drc_set > 0) { err = impd_find_drc_instructions_uni_drc(pstr_drc_config, str_drc_instruction_str->depends_on_drc_set, &drc_inst_uni_drc_dependent); @@ -713,7 +713,7 @@ WORD32 impd_manage_drc_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, } complexityDrcPrelim *= pstr_drc_config->sampling_rate / 48000.0f; - + if ((complexityDrcPrelim <= complexitySupportedTotal) && (numBandsTooLarge == 0)) { pstr_drc_uni_sel_proc->drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id] = 1; @@ -721,7 +721,7 @@ WORD32 impd_manage_drc_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, } return (0); } - + WORD32 impd_manage_eq_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_config* pstr_drc_config) { @@ -733,14 +733,14 @@ WORD32 impd_manage_eq_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_config* drc_config = &pstr_drc_uni_sel_proc->drc_config; ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct = &pstr_drc_uni_sel_proc->uni_drc_sel_proc_params; FLOAT32 complexitySupportedTotal =(FLOAT32)( pow(2.0f, pstr_drc_uni_sel_proc->compl_level_supported_total)); - + for (n=0; nstr_drc_config_ext.eq_instructions_count; n++) { ia_eq_instructions_struct* str_eq_instructions = &pstr_drc_config->str_drc_config_ext.str_eq_instructions[n]; - + eqChannelCountPrimary = pstr_drc_sel_proc_params_struct->base_channel_count; eqChannelCountDependent = pstr_drc_sel_proc_params_struct->base_channel_count; - + eqComplexityPrimary = 1 << str_eq_instructions->eq_set_complexity_level; if (pstr_drc_uni_sel_proc->subband_domain_mode == SUBBAND_DOMAIN_MODE_OFF) { @@ -824,10 +824,10 @@ WORD32 impd_manage_eq_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, } complexityTotalEq += eqChannelCountDependent * eqComplexityDependent; } - + pstr_drc_uni_sel_proc->eq_set_id_valid_flag[str_eq_instructions->eq_set_id] = 0; complexityTotalEq *= pstr_drc_config->sampling_rate / 48000.0f; - + if (complexityTotalEq <= complexitySupportedTotal) { pstr_drc_uni_sel_proc->eq_set_id_valid_flag[str_eq_instructions->eq_set_id] = 1; @@ -836,7 +836,7 @@ WORD32 impd_manage_eq_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, return 0; } - + WORD32 impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_config* pstr_drc_config, WORD32* repeat_selection) @@ -857,7 +857,7 @@ WORD32 impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, impd_select_drc_coeff3(pstr_drc_config, &str_p_loc_drc_coefficients_uni_drc); - for (p=0; p<4; p++) + for (p=0; p<4; p++) { if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p] <= 0) continue; err = impd_find_drc_instructions_uni_drc(pstr_drc_config, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p], &str_drc_instruction_str); @@ -878,12 +878,12 @@ WORD32 impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_gain_set_params_struct* gain_set_params = &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[str_drc_instruction_str->gain_set_index_for_channel_group[j]]); if (gain_set_params->band_count > pstr_drc_sel_proc_params_struct->num_bands_supported) { - if (p<2) - { + if (p<2) + { numBandsTooLarge = 1; } - else - { + else + { pstr_drc_uni_sel_proc->drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id] = 0; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p] = 0; } @@ -899,7 +899,7 @@ WORD32 impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, } complexityDrcTotal += channel_count * (1 << str_drc_instruction_str->drc_set_complexity_level); } - + if (uni_drc_sel_proc_output->active_downmix_id > 0) { FLOAT32 complexityPerCoeff; @@ -932,7 +932,7 @@ WORD32 impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, /* add standard downmix here */ } } - + for (p=0; p<2; p++) { if(pstr_drc_uni_sel_proc->eq_inst_index[p] >= 0) @@ -946,7 +946,7 @@ WORD32 impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, { channel_count = uni_drc_sel_proc_output->target_channel_count; } - + complexityEq =(FLOAT32)(1 << str_eq_instructions->eq_set_complexity_level); if (pstr_drc_uni_sel_proc->subband_domain_mode == SUBBAND_DOMAIN_MODE_OFF) { @@ -966,17 +966,17 @@ WORD32 impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, complexityEqTotal += channel_count * complexityEq; } } - + complexityDrcTotal *= freqNorm; complexityEqTotal *= freqNorm; - + if (numBandsTooLarge == 1) { if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[0] > 0) { err = impd_find_drc_instructions_uni_drc(pstr_drc_config, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[0], &str_drc_instruction_str); if (err) return (err); - + pstr_drc_uni_sel_proc->drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id] = 0; } *repeat_selection = 1; @@ -990,7 +990,7 @@ WORD32 impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, else { drcRequiresEq = 0; - for (p=0; p<2; p++) + for (p=0; p<2; p++) { if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p] <= 0) continue; err = impd_find_drc_instructions_uni_drc(pstr_drc_config, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p], &str_drc_instruction_str); @@ -1014,13 +1014,13 @@ WORD32 impd_manage_complexity (ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, { err = impd_find_drc_instructions_uni_drc(pstr_drc_config, pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[0], &str_drc_instruction_str); if (err) return (err); - + pstr_drc_uni_sel_proc->drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id] = 0; } else { - for (p=2; p<4; p++) - { + for (p=2; p<4; p++) + { pstr_drc_uni_sel_proc->drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id] = 0; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.sel_drc_set_ids[p] = 0; } @@ -1050,8 +1050,8 @@ WORD32 impd_find_loud_eq_instructions_idx_for_id(ia_drc_config* drc_config, { if (drc_config->str_drc_config_ext.loud_eq_instructions[i].loud_eq_set_id == loud_eq_set_id_requested) break; } - if (i == drc_config->str_drc_config_ext.loud_eq_instructions_count) - { + if (i == drc_config->str_drc_config_ext.loud_eq_instructions_count) + { return (UNEXPECTED_ERROR); } *instructions_idx = i; @@ -1063,7 +1063,7 @@ WORD32 impd_find_loud_eq_instructions_idx_for_id(ia_drc_config* drc_config, return (0); } - + WORD32 impd_find_eq_instructions(ia_drc_config* drc_config, WORD32 eq_set_id_requested, ia_eq_instructions_struct** str_eq_instructions) @@ -1073,8 +1073,8 @@ WORD32 impd_find_eq_instructions(ia_drc_config* drc_config, { if (eq_set_id_requested == drc_config->str_drc_config_ext.str_eq_instructions[i].eq_set_id) break; } - if (i == drc_config->str_drc_config_ext.eq_instructions_count) - { + if (i == drc_config->str_drc_config_ext.eq_instructions_count) + { return (UNEXPECTED_ERROR); } *str_eq_instructions = &drc_config->str_drc_config_ext.str_eq_instructions[i]; @@ -1090,12 +1090,11 @@ WORD32 impd_find_downmix(ia_drc_config* drc_config, { if (requested_dwnmix_id == drc_config->dwnmix_instructions[i].downmix_id) break; } - if (i == drc_config->dwnmix_instructions_count) - { + if (i == drc_config->dwnmix_instructions_count) + { return (UNEXPECTED_ERROR); } *dwnmix_instructions = &drc_config->dwnmix_instructions[i]; return (0); } - \ No newline at end of file diff --git a/decoder/drc_src/impd_drc_selection_process.h b/decoder/drc_src/impd_drc_selection_process.h index 6e6cefb..9061cec 100644 --- a/decoder/drc_src/impd_drc_selection_process.h +++ b/decoder/drc_src/impd_drc_selection_process.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_SECLECTION_PROCESS_H #define IMPD_DRC_SECLECTION_PROCESS_H @@ -43,20 +43,20 @@ extern "C" { typedef struct ia_drc_sel_proc_params_struct { - WORD32 base_channel_count; - WORD32 base_layout; + WORD32 base_channel_count; + WORD32 base_layout; WORD32 target_config_request_type; WORD32 num_downmix_id_requests; WORD32 requested_dwnmix_id[MAX_NUM_DOWNMIX_ID_REQUESTS]; WORD32 requested_target_layout; WORD32 requested_target_ch_count; WORD32 target_ch_count_prelim; - + WORD32 loudness_normalization_on; FLOAT32 target_loudness; WORD32 album_mode; WORD32 peak_limiter; - WORD32 loudness_deviation_max; + WORD32 loudness_deviation_max; WORD32 loudness_measurement_method; WORD32 loudness_measurement_system; WORD32 loudness_measurement_pre_proc; @@ -64,7 +64,7 @@ typedef struct ia_drc_sel_proc_params_struct FLOAT32 loudness_norm_gain_db_max; FLOAT32 loudness_norm_gain_modification_db; FLOAT32 output_peak_level_max; - + WORD32 num_bands_supported; WORD32 dynamic_range_control_on; WORD32 num_drc_feature_requests; @@ -78,56 +78,56 @@ typedef struct ia_drc_sel_proc_params_struct FLOAT32 requested_dyn_range_min_val[MAX_NUM_DRC_FEATURE_REQUESTS]; FLOAT32 requested_dyn_range_max_val[MAX_NUM_DRC_FEATURE_REQUESTS]; WORD32 requested_drc_characteristic[MAX_NUM_DRC_FEATURE_REQUESTS]; - - + + WORD32 loudness_eq_request; FLOAT32 sensitivity; FLOAT32 playback_gain; WORD32 eq_set_purpose_request; - + FLOAT32 boost; FLOAT32 compress; WORD32 drc_characteristic_target; } ia_drc_sel_proc_params_struct; typedef struct ia_drc_sel_pro_struct -{ - +{ + WORD32 first_frame; WORD32 drc_config_flag; WORD32 loudness_info_set_flag; WORD32 sel_proc_request_flag; WORD32 subband_domain_mode; - WORD32 eq_inst_index[SUB_EQ_COUNT]; - WORD32 drc_instructions_index[SUB_DRC_COUNT]; + WORD32 eq_inst_index[SUB_EQ_COUNT]; + WORD32 drc_instructions_index[SUB_DRC_COUNT]; ia_drc_sel_proc_params_struct uni_drc_sel_proc_params; - + ia_drc_config drc_config; ia_drc_loudness_info_set_struct loudness_info_set; - + WORD32 drc_inst_index_sel; WORD32 drc_coef_index_sel; WORD32 downmix_inst_index_sel; - + WORD32 drc_set_id_valid_flag[DRC_INSTRUCTIONS_COUNT_MAX]; WORD32 eq_set_id_valid_flag[EQ_INSTRUCTIONS_COUNT_MAX]; - + WORD32 eq_inst_index_sel; WORD32 loud_eq_inst_index_sel; - + FLOAT32 compl_level_supported_total; ia_drc_sel_proc_output_struct uni_drc_sel_proc_output; - + } ia_drc_sel_pro_struct; WORD32 impd_map_target_config_req_downmix_id(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_config* pstr_drc_config); - + VOID impd_sel_downmix_matrix(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_config* pstr_drc_config); - + WORD32 impd_find_drc_instructions_uni_drc(ia_drc_config* drc_config, WORD32 drc_set_id_requested, @@ -142,22 +142,22 @@ impd_find_downmix(ia_drc_config* drc_config, ia_downmix_instructions_struct** dwnmix_instructions); - WORD32 + WORD32 impd_find_eq_set_no_compression(ia_drc_config* pstr_drc_config, WORD32 requested_dwnmix_id, WORD32* no_compression_eq_cnt, WORD32* no_compression_eq_id); - WORD32 + WORD32 impd_match_eq_set(ia_drc_config* drc_config, WORD32 downmix_id, WORD32 drc_set_id, WORD32* eq_set_id_valid_flag, WORD32* matching_eq_set_cnt, WORD32* matching_eq_set_idx); - - - WORD32 + + + WORD32 impd_select_loud_eq(ia_drc_config* pstr_drc_config, WORD32 requested_dwnmix_id, WORD32 drc_set_id_requested, @@ -169,7 +169,7 @@ impd_drc_uni_selction_proc_init(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_sel_proc_params_struct * pstr_drc_sel_proc_params_struct, ia_drc_interface_struct* pstr_drc_interface, WORD32 sub_band_domain_mode); - + WORD32 impd_drc_uni_sel_proc_process(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_config* pstr_drc_config, @@ -181,7 +181,7 @@ impd_find_loud_eq_instructions_idx_for_id(ia_drc_config* drc_config, WORD32 loud_eq_set_id_requested, WORD32* instructions_idx); - + #ifdef __cplusplus } diff --git a/decoder/drc_src/impd_drc_selection_process_drcset_selection.c b/decoder/drc_src/impd_drc_selection_process_drcset_selection.c index 042218e..f09e7ea 100644 --- a/decoder/drc_src/impd_drc_selection_process_drcset_selection.c +++ b/decoder/drc_src/impd_drc_selection_process_drcset_selection.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -46,29 +46,29 @@ static WORD32 effect_types_request_table[] = { WORD32 impd_validate_requested_drc_feature(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct) { WORD32 i,j; - + for (i=0; inum_drc_feature_requests; i++) { switch (pstr_drc_sel_proc_params_struct->drc_feature_req_type[i]) { - case MATCH_EFFECT_TYPE: - for (j=0; jdesired_num_drc_effects_of_requested[i]; j++) - { - if (pstr_drc_sel_proc_params_struct->requested_drc_effect_type[i][j] == EFFECT_TYPE_REQUESTED_NONE) - { - if (pstr_drc_sel_proc_params_struct->desired_num_drc_effects_of_requested[i] > 1) - { - return (UNEXPECTED_ERROR); - } - } - } - break; - case MATCH_DYNAMIC_RANGE: - break; - case MATCH_DRC_CHARACTERISTIC: - break; - default: - return (UNEXPECTED_ERROR); - break; + case MATCH_EFFECT_TYPE: + for (j=0; jdesired_num_drc_effects_of_requested[i]; j++) + { + if (pstr_drc_sel_proc_params_struct->requested_drc_effect_type[i][j] == EFFECT_TYPE_REQUESTED_NONE) + { + if (pstr_drc_sel_proc_params_struct->desired_num_drc_effects_of_requested[i] > 1) + { + return (UNEXPECTED_ERROR); + } + } + } + break; + case MATCH_DYNAMIC_RANGE: + break; + case MATCH_DRC_CHARACTERISTIC: + break; + default: + return (UNEXPECTED_ERROR); + break; } } return (0); @@ -84,7 +84,7 @@ WORD32 impd_find_drc_instructions_uni_drc(ia_drc_config* drc_config, if (drc_set_id_requested == drc_config->str_drc_instruction_str[i].drc_set_id) break; } if (i == drc_config->drc_instructions_uni_drc_count) { - return (UNEXPECTED_ERROR); + return (UNEXPECTED_ERROR); } *str_drc_instruction_str = &drc_config->str_drc_instruction_str[i]; return (0); @@ -94,45 +94,45 @@ WORD32 impd_map_requested_effect_bit_idx( WORD32 requested_effect_type, WORD32* effect_bit_idx) { switch (requested_effect_type) { - case EFFECT_TYPE_REQUESTED_NONE: - *effect_bit_idx = EFFECT_BIT_NONE; - break; - case EFFECT_TYPE_REQUESTED_NIGHT: - *effect_bit_idx = EFFECT_BIT_NIGHT; - break; - case EFFECT_TYPE_REQUESTED_NOISY: - *effect_bit_idx = EFFECT_BIT_NOISY; - break; - case EFFECT_TYPE_REQUESTED_LIMITED: - *effect_bit_idx = EFFECT_BIT_LIMITED; - break; - case EFFECT_TYPE_REQUESTED_LOWLEVEL: - *effect_bit_idx = EFFECT_BIT_LOWLEVEL; - break; - case EFFECT_TYPE_REQUESTED_DIALOG: - *effect_bit_idx = EFFECT_BIT_DIALOG; - break; - case EFFECT_TYPE_REQUESTED_GENERAL_COMPR: - *effect_bit_idx = EFFECT_BIT_GENERAL_COMPR; - break; - case EFFECT_TYPE_REQUESTED_EXPAND: - *effect_bit_idx = EFFECT_BIT_EXPAND; - break; - case EFFECT_TYPE_REQUESTED_ARTISTIC: - *effect_bit_idx = EFFECT_BIT_ARTISTIC; - break; - - default: - return (UNEXPECTED_ERROR); - - break; + case EFFECT_TYPE_REQUESTED_NONE: + *effect_bit_idx = EFFECT_BIT_NONE; + break; + case EFFECT_TYPE_REQUESTED_NIGHT: + *effect_bit_idx = EFFECT_BIT_NIGHT; + break; + case EFFECT_TYPE_REQUESTED_NOISY: + *effect_bit_idx = EFFECT_BIT_NOISY; + break; + case EFFECT_TYPE_REQUESTED_LIMITED: + *effect_bit_idx = EFFECT_BIT_LIMITED; + break; + case EFFECT_TYPE_REQUESTED_LOWLEVEL: + *effect_bit_idx = EFFECT_BIT_LOWLEVEL; + break; + case EFFECT_TYPE_REQUESTED_DIALOG: + *effect_bit_idx = EFFECT_BIT_DIALOG; + break; + case EFFECT_TYPE_REQUESTED_GENERAL_COMPR: + *effect_bit_idx = EFFECT_BIT_GENERAL_COMPR; + break; + case EFFECT_TYPE_REQUESTED_EXPAND: + *effect_bit_idx = EFFECT_BIT_EXPAND; + break; + case EFFECT_TYPE_REQUESTED_ARTISTIC: + *effect_bit_idx = EFFECT_BIT_ARTISTIC; + break; + + default: + return (UNEXPECTED_ERROR); + + break; } return (0); } WORD32 impd_get_fading_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) -{ +{ pstr_drc_uni_sel_proc->drc_instructions_index[2] = -1; if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.album_mode == 0) { @@ -141,17 +141,17 @@ WORD32 impd_get_fading_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) for (n=0; ndrc_config.drc_instructions_uni_drc_count; n++) { str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[n]); - + if (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_FADE) { if (str_drc_instruction_str->downmix_id[0] == ID_FOR_ANY_DOWNMIX) { pstr_drc_uni_sel_proc->drc_instructions_index[2] = n; - + } else { - return (UNEXPECTED_ERROR); + return (UNEXPECTED_ERROR); } } } @@ -164,35 +164,35 @@ WORD32 impd_get_ducking_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) WORD32 drc_instructions_index; WORD32 n, k; ia_drc_instructions_struct* str_drc_instruction_str; - + WORD32 requested_dwnmix_id = pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.active_downmix_id; - + pstr_drc_uni_sel_proc->drc_instructions_index[3] = -1; drc_instructions_index = -1; str_drc_instruction_str = NULL; - + for (n=0; ndrc_config.drc_instructions_uni_drc_count; n++) { str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[n]); - + if (str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) { for (k=0; kdwnmix_id_count; k++) { if (str_drc_instruction_str->downmix_id[k] == requested_dwnmix_id) { - + drc_instructions_index = n; - + } } } } - if (drc_instructions_index == -1) + if (drc_instructions_index == -1) { for (n=0; ndrc_config.drc_instructions_uni_drc_count; n++) { str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[n]); - + if (str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) { for (k=0; kdwnmix_id_count; k++) { @@ -206,8 +206,8 @@ WORD32 impd_get_ducking_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) } if (drc_instructions_index > -1) { - pstr_drc_uni_sel_proc->drc_instructions_index[2] = -1; - pstr_drc_uni_sel_proc->drc_instructions_index[3] = drc_instructions_index; + pstr_drc_uni_sel_proc->drc_instructions_index[2] = -1; + pstr_drc_uni_sel_proc->drc_instructions_index[3] = drc_instructions_index; } return (0); } @@ -216,20 +216,20 @@ WORD32 impd_get_selected_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, WORD32 drc_set_id_selected) { WORD32 n; - + ia_drc_instructions_struct* str_drc_instruction_str = NULL; - + for(n=0; ndrc_config.drc_instructions_count_plus; n++) { if (pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[n].drc_set_id == drc_set_id_selected) break; } if (n == pstr_drc_uni_sel_proc->drc_config.drc_instructions_count_plus) { - return(EXTERNAL_ERROR); + return(EXTERNAL_ERROR); } pstr_drc_uni_sel_proc->drc_inst_index_sel = n; str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[pstr_drc_uni_sel_proc->drc_inst_index_sel]); - + pstr_drc_uni_sel_proc->drc_instructions_index[0] = pstr_drc_uni_sel_proc->drc_inst_index_sel; return (0); } @@ -239,19 +239,19 @@ WORD32 impd_get_dependent_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) { ia_drc_instructions_struct* str_drc_instruction_str = NULL; str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[pstr_drc_uni_sel_proc->drc_inst_index_sel]); - + if (str_drc_instruction_str->depends_on_drc_set_present == 1) { WORD32 n; WORD32 drc_dependent_set_id = str_drc_instruction_str->depends_on_drc_set; - + for (n=0; ndrc_config.drc_instructions_count_plus; n++) { if (pstr_drc_uni_sel_proc->drc_config.str_drc_instruction_str[n].drc_set_id == drc_dependent_set_id) break; } if (n == pstr_drc_uni_sel_proc->drc_config.drc_instructions_count_plus) - { - return(UNEXPECTED_ERROR); + { + return(UNEXPECTED_ERROR); } pstr_drc_uni_sel_proc->drc_instructions_index[1] = n; } @@ -278,16 +278,16 @@ WORD32 impd_get_dependent_drc_instructions(const ia_drc_config* drc_config, } if (j == drc_config->drc_instructions_uni_drc_count) { - return (UNEXPECTED_ERROR); + return (UNEXPECTED_ERROR); } if (dependent_drc->depends_on_drc_set_present == 1) { - return (UNEXPECTED_ERROR); + return (UNEXPECTED_ERROR); } *drc_instructions_dependent = dependent_drc; return(0); } - + WORD32 impd_select_drcs_without_compr_effects (ia_drc_config* pstr_drc_config, WORD32* match_found_flag, WORD32* selection_candidate_count, @@ -299,14 +299,14 @@ WORD32 impd_select_drcs_without_compr_effects (ia_drc_config* pstr_drc_config, WORD32 effect_types_request_table_size; WORD32 match; ia_drc_instructions_struct* str_drc_instruction_str; - + effect_types_request_table_size = sizeof(effect_types_request_table) / sizeof(WORD32); - + k=0; for (i=0; i < *selection_candidate_count; i++) { str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info[i].drc_instructions_index]); - + match = 1; for (n=0; n 0) { *match_found_flag = 1; @@ -336,7 +336,7 @@ WORD32 impd_select_drcs_without_compr_effects (ia_drc_config* pstr_drc_config, { *match_found_flag = 0; } - + return (0); } @@ -353,10 +353,10 @@ WORD32 impd_match_effect_type_attempt(ia_drc_config* pstr_drc_config, ia_drc_instructions_struct* str_drc_instruction_str; ia_drc_instructions_struct* drc_instructions_dependent; WORD32 effect_bit_idx; - + err = impd_map_requested_effect_bit_idx(requested_effect_type, &effect_bit_idx); if (err) return (err); - + if (effect_bit_idx == EFFECT_BIT_NONE) { err = impd_select_drcs_without_compr_effects (pstr_drc_config, match_found_flag, selection_candidate_count, selection_candidate_info); @@ -372,7 +372,7 @@ WORD32 impd_match_effect_type_attempt(ia_drc_config* pstr_drc_config, { err = impd_get_dependent_drc_instructions(pstr_drc_config, str_drc_instruction_str, &drc_instructions_dependent); if (err) return (err); - + if (state_requested == 1) { if (((str_drc_instruction_str->drc_set_effect & effect_bit_idx) != 0x0) || @@ -413,7 +413,7 @@ WORD32 impd_match_effect_type_attempt(ia_drc_config* pstr_drc_config, } } selection_candidate_step_2_count = k; - + if (selection_candidate_step_2_count > 0) { *match_found_flag = 1; @@ -442,7 +442,7 @@ WORD32 impd_match_effect_types(ia_drc_config* pstr_drc_config, WORD32 match_found_flag = 0; WORD32 state_requested; WORD32 desired_effect_type_found, fallback_effect_type_found; - + desired_effect_type_found = 0; fallback_effect_type_found = 0; k = 0; @@ -465,14 +465,14 @@ WORD32 impd_match_effect_types(ia_drc_config* pstr_drc_config, k++; } } - + return(0); } WORD32 impd_match_dynamic_range(ia_drc_config* pstr_drc_config, ia_drc_loudness_info_set_struct* pstr_loudness_info, - ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, - WORD32 num_drc_requests, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + WORD32 num_drc_requests, WORD32* selection_candidate_count, ia_selection_candidate_info_struct* selection_candidate_info) { @@ -482,40 +482,40 @@ WORD32 impd_match_dynamic_range(ia_drc_config* pstr_drc_config, FLOAT32 lp_avg_val; FLOAT32 deviation_min = 1000.0f; WORD32 selected[DRC_INSTRUCTIONS_COUNT_MAX]; - WORD32 dynamic_range_measurement_type = pstr_drc_sel_proc_params_struct-> - requested_dyn_range_measur_type[num_drc_requests]; - - WORD32 requested_dyn_range_range_flag = pstr_drc_sel_proc_params_struct-> - requested_dyn_range_range_flag[num_drc_requests]; - - FLOAT32 dynamic_range_requested = pstr_drc_sel_proc_params_struct-> - requested_dyn_range_value[num_drc_requests]; - - FLOAT32 dynamic_range_min_requested = pstr_drc_sel_proc_params_struct-> - requested_dyn_range_min_val[num_drc_requests]; - - FLOAT32 dynamic_range_max_requested = pstr_drc_sel_proc_params_struct-> - requested_dyn_range_max_val[num_drc_requests]; - - WORD32* requested_dwnmix_id = pstr_drc_sel_proc_params_struct->requested_dwnmix_id; - - WORD32 album_mode = pstr_drc_sel_proc_params_struct->album_mode; - + WORD32 dynamic_range_measurement_type = pstr_drc_sel_proc_params_struct-> + requested_dyn_range_measur_type[num_drc_requests]; + + WORD32 requested_dyn_range_range_flag = pstr_drc_sel_proc_params_struct-> + requested_dyn_range_range_flag[num_drc_requests]; + + FLOAT32 dynamic_range_requested = pstr_drc_sel_proc_params_struct-> + requested_dyn_range_value[num_drc_requests]; + + FLOAT32 dynamic_range_min_requested = pstr_drc_sel_proc_params_struct-> + requested_dyn_range_min_val[num_drc_requests]; + + FLOAT32 dynamic_range_max_requested = pstr_drc_sel_proc_params_struct-> + requested_dyn_range_max_val[num_drc_requests]; + + WORD32* requested_dwnmix_id = pstr_drc_sel_proc_params_struct->requested_dwnmix_id; + + WORD32 album_mode = pstr_drc_sel_proc_params_struct->album_mode; + k=0; for (i=0; i < *selection_candidate_count; i++) { str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info[i].drc_instructions_index]); - + err = impd_loudness_peak_to_average_info( - pstr_loudness_info, - str_drc_instruction_str, - requested_dwnmix_id[selection_candidate_info[i].downmix_id_request_index], - dynamic_range_measurement_type, - album_mode, - &lp_avg_present_val, - &lp_avg_val); + pstr_loudness_info, + str_drc_instruction_str, + requested_dwnmix_id[selection_candidate_info[i].downmix_id_request_index], + dynamic_range_measurement_type, + album_mode, + &lp_avg_present_val, + &lp_avg_val); if (err) return (err); - + if (lp_avg_present_val == 1) { if (requested_dyn_range_range_flag == 1) @@ -550,7 +550,7 @@ WORD32 impd_match_dynamic_range(ia_drc_config* pstr_drc_config, } *selection_candidate_count = k; } - + return(0); } @@ -568,15 +568,15 @@ WORD32 impd_match_drc_characteristic_attempt(ia_drc_config* pstr_drc_config, WORD32 drc_characteristic_request_1; WORD32 drc_characteristic_request_2; WORD32 drc_characteristic_request_3; - + ia_drc_instructions_struct* str_drc_instruction_str = NULL; ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc = NULL; ia_gain_set_params_struct* gain_set_params = NULL; *match_found_flag = 0; - + if (requested_drc_characteristic < 1) { - return(UNEXPECTED_ERROR); + return(UNEXPECTED_ERROR); } if(requested_drc_characteristic < 12) { @@ -590,26 +590,26 @@ WORD32 impd_match_drc_characteristic_attempt(ia_drc_config* pstr_drc_config, drc_characteristic_request_2 = -1; drc_characteristic_request_3 = -1; } - + if (pstr_drc_config->drc_coefficients_drc_count) { for (i=0; idrc_coefficients_drc_count; i++) { str_p_loc_drc_coefficients_uni_drc = &(pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[i]); if (str_p_loc_drc_coefficients_uni_drc->drc_location == LOCATION_SELECTED) break; } - + if (i == pstr_drc_config->drc_coefficients_drc_count) { - return (UNEXPECTED_ERROR); + return (UNEXPECTED_ERROR); } } - + n = 0; for (i=0; i < *selection_candidate_count; i++) { ref_count = 0; match_count = 0; - + str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info[i].drc_instructions_index]); for (k=0; knum_drc_ch_groups; k++) { @@ -632,7 +632,7 @@ WORD32 impd_match_drc_characteristic_attempt(ia_drc_config* pstr_drc_config, } if (m == pstr_drc_config->drc_instructions_uni_drc_count) { - return (UNEXPECTED_ERROR); + return (UNEXPECTED_ERROR); } str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[m]); if ((str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_FADE | EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) == 0) @@ -664,7 +664,7 @@ WORD32 impd_match_drc_characteristic_attempt(ia_drc_config* pstr_drc_config, *selection_candidate_count = n; *match_found_flag = 1; } - + return(0); } @@ -677,53 +677,53 @@ WORD32 impd_match_drc_characteristic(ia_drc_config* pstr_drc_config, { WORD32 k, err; WORD32 match_found_flag = 0; - + WORD32* drc_characteristic_order = drc_characteristic_order_default[requested_drc_characteristic-1]; WORD32 drc_characteristic_order_count = sizeof(drc_characteristic_order_default[requested_drc_characteristic]) / sizeof(WORD32); k = 0; while ((k 0)) { err = impd_match_drc_characteristic_attempt(pstr_drc_config, - drc_characteristic_order[k], - &match_found_flag, - selection_candidate_count, - selection_candidate_info); + drc_characteristic_order[k], + &match_found_flag, + selection_candidate_count, + selection_candidate_info); if (err) return (err); k++; } return (0); } - + WORD32 impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, ia_drc_config* pstr_drc_config, ia_drc_loudness_info_set_struct* pstr_loudness_info, WORD32 restrict_to_drc_with_album_loudness, - ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, + ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, WORD32* selection_candidate_count, ia_selection_candidate_info_struct* selection_candidate_info) { WORD32 i, j, k, l, d, n, err; WORD32 downmix_id_match = 0; - - + + WORD32 selection_candidate_step_2_count; ia_selection_candidate_info_struct selection_candidate_info_step_2[SELECTION_CANDIDATE_COUNT_MAX]; - + WORD32 num_downmix_id_requests = pstr_drc_sel_proc_params_struct->num_downmix_id_requests; WORD32* requested_dwnmix_id = pstr_drc_sel_proc_params_struct->requested_dwnmix_id; FLOAT32 output_peak_level_max = pstr_drc_sel_proc_params_struct->output_peak_level_max; WORD32 loudness_deviation_max = pstr_drc_sel_proc_params_struct->loudness_deviation_max; - WORD32* drc_set_id_valid_flag = pstr_drc_uni_sel_proc->drc_set_id_valid_flag; + WORD32* drc_set_id_valid_flag = pstr_drc_uni_sel_proc->drc_set_id_valid_flag; WORD32* eq_set_id_valid_flag = pstr_drc_uni_sel_proc->eq_set_id_valid_flag; - + FLOAT32 output_peak_level_min = 1000.0f; FLOAT32 adjustment; WORD32 loudness_drc_set_id_requested; - + WORD32 num_compression_eq_count = 0; WORD32 num_compression_eq_id[16]; - + WORD32 loudness_info_count = 0; WORD32 eq_set_id_loudness[16]; FLOAT32 loudness_normalization_gain_db[16]; @@ -732,25 +732,25 @@ WORD32 impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_pro WORD32 eq_set_id_Peak[16]; FLOAT32 signal_peak_level[16]; WORD32 explicit_peak_information_present[16]; - + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc = NULL; ia_drc_instructions_struct* str_drc_instruction_str = NULL; - + impd_select_drc_coeff3(pstr_drc_config, &str_p_loc_drc_coefficients_uni_drc); - + k=0; for (d=0; ddrc_instructions_count_plus; i++) { downmix_id_match = 0; str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[i]); - + for (j=0; jdwnmix_id_count; j++) { if ((str_drc_instruction_str->downmix_id[j] == requested_dwnmix_id[d]) || @@ -760,59 +760,59 @@ WORD32 impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_pro downmix_id_match = 1; } } - if (downmix_id_match == 1) + if (downmix_id_match == 1) { if (pstr_drc_sel_proc_params_struct->dynamic_range_control_on == 1) { - if ((str_drc_instruction_str->drc_set_effect != EFFECT_BIT_FADE) && + if ((str_drc_instruction_str->drc_set_effect != EFFECT_BIT_FADE) && (str_drc_instruction_str->drc_set_effect != EFFECT_BIT_DUCK_OTHER) && (str_drc_instruction_str->drc_set_effect != EFFECT_BIT_DUCK_SELF) && - (str_drc_instruction_str->drc_set_effect != 0 || str_drc_instruction_str->drc_set_id < 0) && + (str_drc_instruction_str->drc_set_effect != 0 || str_drc_instruction_str->drc_set_id < 0) && (((str_drc_instruction_str->depends_on_drc_set_present == 0) && (str_drc_instruction_str->no_independent_use == 0)) || - (str_drc_instruction_str->depends_on_drc_set_present == 1)) ) + (str_drc_instruction_str->depends_on_drc_set_present == 1)) ) { WORD32 drc_is_permitted = 1; if (str_drc_instruction_str->drc_set_id > 0) { drc_is_permitted = drc_set_id_valid_flag[str_drc_instruction_str->drc_set_id]; } - if (drc_is_permitted == 1) + if (drc_is_permitted == 1) { - + err = impd_init_loudness_control (pstr_drc_sel_proc_params_struct, - pstr_loudness_info, - requested_dwnmix_id[d], - str_drc_instruction_str->drc_set_id, - - num_compression_eq_count, - num_compression_eq_id, - &loudness_info_count, - eq_set_id_loudness, - loudness_normalization_gain_db, - loudness); + pstr_loudness_info, + requested_dwnmix_id[d], + str_drc_instruction_str->drc_set_id, + + num_compression_eq_count, + num_compression_eq_id, + &loudness_info_count, + eq_set_id_loudness, + loudness_normalization_gain_db, + loudness); if (err) return (err); - + err = impd_signal_peak_level_info(pstr_drc_config, - pstr_loudness_info, - str_drc_instruction_str, - requested_dwnmix_id[d], - pstr_drc_sel_proc_params_struct->album_mode, - num_compression_eq_count, - num_compression_eq_id, - &peak_info_count, - eq_set_id_Peak, - signal_peak_level, - explicit_peak_information_present); + pstr_loudness_info, + str_drc_instruction_str, + requested_dwnmix_id[d], + pstr_drc_sel_proc_params_struct->album_mode, + num_compression_eq_count, + num_compression_eq_id, + &peak_info_count, + eq_set_id_Peak, + signal_peak_level, + explicit_peak_information_present); if (err) return (err); - + for (l=0; lloudness_norm_gain_db_max); - + if (loudness[l] != UNDEFINED_LOUDNESS_VALUE) { selection_candidate_info[k].output_loudness = loudness[l] + selection_candidate_info[k].loudness_norm_db_gain_adjusted; @@ -821,14 +821,14 @@ WORD32 impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_pro { selection_candidate_info[k].output_loudness = UNDEFINED_LOUDNESS_VALUE; } - + for (p=0; prequires_eq == 1) && (eq_set_id_valid_flag[eq_set_id_loudness[l]] == 0)) continue; + if ((str_drc_instruction_str->requires_eq == 1) && (eq_set_id_valid_flag[eq_set_id_loudness[l]] == 0)) continue; selection_candidate_info[k].drc_instructions_index = i; selection_candidate_info[k].downmix_id_request_index = d; selection_candidate_info[k].eq_set_id = eq_set_id_loudness[l]; @@ -856,20 +856,20 @@ WORD32 impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_pro selection_candidate_info[k].selection_flags = 0; } impd_mixing_level_info(pstr_drc_sel_proc_params_struct, - pstr_loudness_info, - requested_dwnmix_id[d], - str_drc_instruction_str->drc_set_id, - eq_set_id_loudness[l], - &selection_candidate_info[k].mixing_level); + pstr_loudness_info, + requested_dwnmix_id[d], + str_drc_instruction_str->drc_set_id, + eq_set_id_loudness[l], + &selection_candidate_info[k].mixing_level); if (str_drc_instruction_str->drc_set_target_loudness_present && ((pstr_drc_sel_proc_params_struct->loudness_normalization_on && - str_drc_instruction_str->drc_set_target_loudness_value_upper >= pstr_drc_sel_proc_params_struct->target_loudness && - str_drc_instruction_str->drc_set_target_loudness_value_lower < pstr_drc_sel_proc_params_struct->target_loudness) || - !pstr_drc_sel_proc_params_struct->loudness_normalization_on)) { + str_drc_instruction_str->drc_set_target_loudness_value_upper >= pstr_drc_sel_proc_params_struct->target_loudness && + str_drc_instruction_str->drc_set_target_loudness_value_lower < pstr_drc_sel_proc_params_struct->target_loudness) || + !pstr_drc_sel_proc_params_struct->loudness_normalization_on)) { selection_candidate_info[k].selection_flags |= SELECTION_FLAG_DRC_TARGET_LOUDNESS_MATCH; if (!explicit_peak_information_present[p]) - { - if (pstr_drc_sel_proc_params_struct->loudness_normalization_on) { + { + if (pstr_drc_sel_proc_params_struct->loudness_normalization_on) { selection_candidate_info[k].output_peak_level = pstr_drc_sel_proc_params_struct->target_loudness - str_drc_instruction_str->drc_set_target_loudness_value_upper; } else { @@ -890,32 +890,32 @@ WORD32 impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_pro { if (str_drc_instruction_str->drc_set_id < 0) { - - - + + + err = impd_init_loudness_control (pstr_drc_sel_proc_params_struct, - pstr_loudness_info, - requested_dwnmix_id[d], - str_drc_instruction_str->drc_set_id, - num_compression_eq_count, - num_compression_eq_id, - &loudness_info_count, - eq_set_id_loudness, - loudness_normalization_gain_db, - loudness); + pstr_loudness_info, + requested_dwnmix_id[d], + str_drc_instruction_str->drc_set_id, + num_compression_eq_count, + num_compression_eq_id, + &loudness_info_count, + eq_set_id_loudness, + loudness_normalization_gain_db, + loudness); if (err) return (err); - + err = impd_signal_peak_level_info(pstr_drc_config, - pstr_loudness_info, - str_drc_instruction_str, - requested_dwnmix_id[d], - pstr_drc_sel_proc_params_struct->album_mode, - num_compression_eq_count, - num_compression_eq_id, - &peak_info_count, - eq_set_id_Peak, - signal_peak_level, - explicit_peak_information_present); + pstr_loudness_info, + str_drc_instruction_str, + requested_dwnmix_id[d], + pstr_drc_sel_proc_params_struct->album_mode, + num_compression_eq_count, + num_compression_eq_id, + &peak_info_count, + eq_set_id_Peak, + signal_peak_level, + explicit_peak_information_present); if (err) return (err); for (l=0; loutput_peak_level_max); adjustment = min(adjustment, max(0.0f, loudness_deviation_max)); selection_candidate_info[k].loudness_norm_db_gain_adjusted = loudness_normalization_gain_db[l] - adjustment; - + selection_candidate_info[k].loudness_norm_db_gain_adjusted = min(selection_candidate_info[k].loudness_norm_db_gain_adjusted, pstr_drc_sel_proc_params_struct->loudness_norm_gain_db_max); - + selection_candidate_info[k].output_peak_level = signal_peak_level[p] + selection_candidate_info[k].loudness_norm_db_gain_adjusted; if (loudness[l] != UNDEFINED_LOUDNESS_VALUE) { @@ -961,11 +961,11 @@ WORD32 impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_pro selection_candidate_info[k].selection_flags = 0; } impd_mixing_level_info(pstr_drc_sel_proc_params_struct, - pstr_loudness_info, - requested_dwnmix_id[d], - str_drc_instruction_str->drc_set_id, - eq_set_id_loudness[l], - &selection_candidate_info[k].mixing_level); + pstr_loudness_info, + requested_dwnmix_id[d], + str_drc_instruction_str->drc_set_id, + eq_set_id_loudness[l], + &selection_candidate_info[k].mixing_level); k++; } } @@ -974,11 +974,11 @@ WORD32 impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_pro } } } - *selection_candidate_count = k; - - if (*selection_candidate_count > SELECTION_CANDIDATE_COUNT_MAX) + *selection_candidate_count = k; + + if (*selection_candidate_count > SELECTION_CANDIDATE_COUNT_MAX) { - return UNEXPECTED_ERROR; + return UNEXPECTED_ERROR; } else if (pstr_drc_sel_proc_params_struct->dynamic_range_control_on == 1) { @@ -986,17 +986,17 @@ WORD32 impd_drc_set_preselection(ia_drc_sel_proc_params_struct* pstr_drc_sel_pro for (k=0; k<*selection_candidate_count; k++) { str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info[k].drc_instructions_index]); - + if (pstr_drc_sel_proc_params_struct->eq_set_purpose_request != EQ_PURPOSE_EQ_OFF) { WORD32 matching_eq_set_count = 0; WORD32 matching_eq_instrucions_index[64]; err = impd_match_eq_set(pstr_drc_config, - requested_dwnmix_id[selection_candidate_info[k].downmix_id_request_index], - str_drc_instruction_str->drc_set_id, - eq_set_id_valid_flag, - &matching_eq_set_count, - matching_eq_instrucions_index); + requested_dwnmix_id[selection_candidate_info[k].downmix_id_request_index], + str_drc_instruction_str->drc_set_id, + eq_set_id_valid_flag, + &matching_eq_set_count, + matching_eq_instrucions_index); if (err) return(err); for (j=0; jeq_set_purpose_request > 0) - { - WORD32 eq_purpose_requested = pstr_drc_sel_proc_params_struct->eq_set_purpose_request; + WORD32 k, i, n, err; + WORD32 selection_candidate_step_2_count; + ia_selection_candidate_info_struct selection_candidate_info_step_2[SELECTION_CANDIDATE_COUNT_MAX]; + WORD32 drc_set_id_max; + FLOAT32 output_level_max; + FLOAT32 output_level_min; + WORD32 effect_count, effect_count_min; + WORD32 effect_types_request_table_size; + WORD32 drc_set_target_loudness_val_upper_min; + ia_drc_instructions_struct* str_drc_instruction_str; + ia_drc_instructions_struct* drc_instructions_dependent; - impd_match_eq_set_purpose(pstr_drc_config, - eq_purpose_requested, - eq_set_id_valid_flag, - selection_candidate_count, - selection_candidate_info, - selection_candidate_info_step_2); - } - output_level_min = 10000.0f; - k = 0; - for (i=0; i < *selection_candidate_count; i++) - { - if (output_level_min >= selection_candidate_info[i].output_peak_level) - { - if (output_level_min > selection_candidate_info[i].output_peak_level) - { - output_level_min = selection_candidate_info[i].output_peak_level; - k = 0; - } - memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[i], sizeof(ia_selection_candidate_info_struct)); - k++; - } - } - selection_candidate_step_2_count = k; - - if (output_level_min <= 0.0f ) - { - selection_candidate_step_2_count = *selection_candidate_count; - k = 0; - for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); - for (n=0; ndwnmix_id_count; n++) { - if (pstr_drc_sel_proc_params_struct->requested_dwnmix_id[selection_candidate_info_step_2[i].downmix_id_request_index] == str_drc_instruction_str->downmix_id[n]) - { - memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); - k++; - } - } - } - if (k > 0) - { - selection_candidate_step_2_count = k; - } - - effect_types_request_table_size = sizeof(effect_types_request_table) / sizeof(WORD32); - effect_count_min = 100; - k=0; - for (i=0; i < selection_candidate_step_2_count; i++) - { - str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); - effect_count = 0; - if (str_drc_instruction_str->depends_on_drc_set_present == 1) - { - err = impd_get_dependent_drc_instructions(pstr_drc_config, str_drc_instruction_str, &drc_instructions_dependent); - if (err) return (err); - - for (n=0; ndrc_set_effect & effect_types_request_table[n]) != 0x0) || - ((drc_instructions_dependent->drc_set_effect & effect_types_request_table[n]) != 0x0)) - { - effect_count++; - } - } - } - } - else - { - for (n=0; ndrc_set_effect & effect_types_request_table[n]) != 0x0) - { - effect_count++; - } - } - } - } - if (effect_count_min >= effect_count) - { - if (effect_count_min > effect_count) - { - effect_count_min = effect_count; - k = 0; - } - memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); - k++; - } - } - selection_candidate_step_2_count = k; - - drc_set_target_loudness_val_upper_min = 100; - k = 0; - for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); - if (str_drc_instruction_str->drc_set_target_loudness_present != 1) - { - return UNEXPECTED_ERROR; - } - if (drc_set_target_loudness_val_upper_min >= str_drc_instruction_str->drc_set_target_loudness_value_upper) - { - if (drc_set_target_loudness_val_upper_min > str_drc_instruction_str->drc_set_target_loudness_value_upper) - { - drc_set_target_loudness_val_upper_min = str_drc_instruction_str->drc_set_target_loudness_value_upper; - k = 0; - } - memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); - k++; - } - } - selection_candidate_step_2_count = k; - } - - k = 0; - for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); - if (str_drc_instruction_str->drc_set_target_loudness_present && pstr_drc_sel_proc_params_struct->loudness_normalization_on && str_drc_instruction_str->drc_set_target_loudness_value_upper >= pstr_drc_sel_proc_params_struct->target_loudness && str_drc_instruction_str->drc_set_target_loudness_value_lower < pstr_drc_sel_proc_params_struct->target_loudness) { - k++; - } - } - if (k != 0 && k != selection_candidate_step_2_count) - { - k = 0; - for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); - if (str_drc_instruction_str->drc_set_target_loudness_present && pstr_drc_sel_proc_params_struct->loudness_normalization_on && str_drc_instruction_str->drc_set_target_loudness_value_upper >= pstr_drc_sel_proc_params_struct->target_loudness && str_drc_instruction_str->drc_set_target_loudness_value_lower < pstr_drc_sel_proc_params_struct->target_loudness) { - memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); - k++; - } - } - selection_candidate_step_2_count = k; - drc_set_target_loudness_val_upper_min = 100; - k = 0; - for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); - if (str_drc_instruction_str->drc_set_target_loudness_present != 1) - { - return UNEXPECTED_ERROR; - } - if (drc_set_target_loudness_val_upper_min >= str_drc_instruction_str->drc_set_target_loudness_value_upper) - { - if (drc_set_target_loudness_val_upper_min > str_drc_instruction_str->drc_set_target_loudness_value_upper) - { - drc_set_target_loudness_val_upper_min = str_drc_instruction_str->drc_set_target_loudness_value_upper; - k = 0; - } - memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); - k++; - } - } - selection_candidate_step_2_count = k; - } - else if (k == selection_candidate_step_2_count) - { - drc_set_target_loudness_val_upper_min = 100; - k = 0; - for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); - if (str_drc_instruction_str->drc_set_target_loudness_present != 1) - { - return UNEXPECTED_ERROR; - } - if (drc_set_target_loudness_val_upper_min >= str_drc_instruction_str->drc_set_target_loudness_value_upper) - { - if (drc_set_target_loudness_val_upper_min > str_drc_instruction_str->drc_set_target_loudness_value_upper) - { - drc_set_target_loudness_val_upper_min = str_drc_instruction_str->drc_set_target_loudness_value_upper; - k = 0; - } - memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); - k++; - } - } - selection_candidate_step_2_count = k; - } - k = 0; - output_level_max = -1000.0f; - for (i=0; i < selection_candidate_step_2_count; i++) - { - if ((selection_candidate_info_step_2[i].output_peak_level <= 0.0f) && (output_level_max <= selection_candidate_info_step_2[i].output_peak_level)) - { - if (output_level_max < selection_candidate_info_step_2[i].output_peak_level) - { - output_level_max = selection_candidate_info_step_2[i].output_peak_level; - k = 0; - } - memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); - k++; - output_level_max = selection_candidate_info_step_2[i].output_peak_level; - } - } - selection_candidate_step_2_count = k; + if (pstr_drc_sel_proc_params_struct->eq_set_purpose_request > 0) + { + WORD32 eq_purpose_requested = pstr_drc_sel_proc_params_struct->eq_set_purpose_request; + + impd_match_eq_set_purpose(pstr_drc_config, + eq_purpose_requested, + eq_set_id_valid_flag, + selection_candidate_count, + selection_candidate_info, + selection_candidate_info_step_2); } - + + output_level_min = 10000.0f; + k = 0; + for (i=0; i < *selection_candidate_count; i++) + { + if (output_level_min >= selection_candidate_info[i].output_peak_level) + { + if (output_level_min > selection_candidate_info[i].output_peak_level) + { + output_level_min = selection_candidate_info[i].output_peak_level; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + + if (output_level_min <= 0.0f ) + { + selection_candidate_step_2_count = *selection_candidate_count; + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + for (n=0; ndwnmix_id_count; n++) { + if (pstr_drc_sel_proc_params_struct->requested_dwnmix_id[selection_candidate_info_step_2[i].downmix_id_request_index] == str_drc_instruction_str->downmix_id[n]) + { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + } + if (k > 0) + { + selection_candidate_step_2_count = k; + } + + effect_types_request_table_size = sizeof(effect_types_request_table) / sizeof(WORD32); + effect_count_min = 100; + k=0; + for (i=0; i < selection_candidate_step_2_count; i++) + { + str_drc_instruction_str = &(pstr_drc_config->str_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + effect_count = 0; + if (str_drc_instruction_str->depends_on_drc_set_present == 1) + { + err = impd_get_dependent_drc_instructions(pstr_drc_config, str_drc_instruction_str, &drc_instructions_dependent); + if (err) return (err); + + for (n=0; ndrc_set_effect & effect_types_request_table[n]) != 0x0) || + ((drc_instructions_dependent->drc_set_effect & effect_types_request_table[n]) != 0x0)) + { + effect_count++; + } + } + } + } + else + { + for (n=0; ndrc_set_effect & effect_types_request_table[n]) != 0x0) + { + effect_count++; + } + } + } + } + if (effect_count_min >= effect_count) + { + if (effect_count_min > effect_count) + { + effect_count_min = effect_count; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + + drc_set_target_loudness_val_upper_min = 100; + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (str_drc_instruction_str->drc_set_target_loudness_present != 1) + { + return UNEXPECTED_ERROR; + } + if (drc_set_target_loudness_val_upper_min >= str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + if (drc_set_target_loudness_val_upper_min > str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + drc_set_target_loudness_val_upper_min = str_drc_instruction_str->drc_set_target_loudness_value_upper; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + } + + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (str_drc_instruction_str->drc_set_target_loudness_present && pstr_drc_sel_proc_params_struct->loudness_normalization_on && str_drc_instruction_str->drc_set_target_loudness_value_upper >= pstr_drc_sel_proc_params_struct->target_loudness && str_drc_instruction_str->drc_set_target_loudness_value_lower < pstr_drc_sel_proc_params_struct->target_loudness) { + k++; + } + } + if (k != 0 && k != selection_candidate_step_2_count) + { + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (str_drc_instruction_str->drc_set_target_loudness_present && pstr_drc_sel_proc_params_struct->loudness_normalization_on && str_drc_instruction_str->drc_set_target_loudness_value_upper >= pstr_drc_sel_proc_params_struct->target_loudness && str_drc_instruction_str->drc_set_target_loudness_value_lower < pstr_drc_sel_proc_params_struct->target_loudness) { + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + drc_set_target_loudness_val_upper_min = 100; + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (str_drc_instruction_str->drc_set_target_loudness_present != 1) + { + return UNEXPECTED_ERROR; + } + if (drc_set_target_loudness_val_upper_min >= str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + if (drc_set_target_loudness_val_upper_min > str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + drc_set_target_loudness_val_upper_min = str_drc_instruction_str->drc_set_target_loudness_value_upper; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + } + else if (k == selection_candidate_step_2_count) + { + drc_set_target_loudness_val_upper_min = 100; + k = 0; + for (i=0; istr_drc_instruction_str[selection_candidate_info_step_2[i].drc_instructions_index]); + if (str_drc_instruction_str->drc_set_target_loudness_present != 1) + { + return UNEXPECTED_ERROR; + } + if (drc_set_target_loudness_val_upper_min >= str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + if (drc_set_target_loudness_val_upper_min > str_drc_instruction_str->drc_set_target_loudness_value_upper) + { + drc_set_target_loudness_val_upper_min = str_drc_instruction_str->drc_set_target_loudness_value_upper; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + } + } + selection_candidate_step_2_count = k; + } + k = 0; + output_level_max = -1000.0f; + for (i=0; i < selection_candidate_step_2_count; i++) + { + if ((selection_candidate_info_step_2[i].output_peak_level <= 0.0f) && (output_level_max <= selection_candidate_info_step_2[i].output_peak_level)) + { + if (output_level_max < selection_candidate_info_step_2[i].output_peak_level) + { + output_level_max = selection_candidate_info_step_2[i].output_peak_level; + k = 0; + } + memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); + k++; + output_level_max = selection_candidate_info_step_2[i].output_peak_level; + } + } + selection_candidate_step_2_count = k; + } + drc_set_id_max = -1000; for (i=0; i < selection_candidate_step_2_count; i++) { @@ -1360,8 +1360,8 @@ WORD32 impd_drc_set_final_selection(ia_drc_config* pstr_drc_config, } memcpy(&selection_candidate_info[0], &selection_candidate_info_step_2[0], sizeof(ia_selection_candidate_info_struct)); *selection_candidate_count = 1; - - return 0; + + return 0; } WORD32 impd_select_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, @@ -1371,32 +1371,32 @@ WORD32 impd_select_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ) { WORD32 i, err; - + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct = &pstr_drc_uni_sel_proc->uni_drc_sel_proc_params; ia_drc_config* pstr_drc_config = &pstr_drc_uni_sel_proc->drc_config; ia_drc_loudness_info_set_struct* pstr_loudness_info = &pstr_drc_uni_sel_proc->loudness_info_set; - + WORD32 selection_candidate_count = 0; - WORD32 restrict_to_drc_with_album_loudness = 0; + WORD32 restrict_to_drc_with_album_loudness = 0; ia_selection_candidate_info_struct selection_candidate_info[SELECTION_CANDIDATE_COUNT_MAX]; - + // WORD32 selected_eq_set_count = 0; - + if (pstr_drc_sel_proc_params_struct->album_mode == 1) { restrict_to_drc_with_album_loudness = 1; } - + while (!selection_candidate_count) { impd_drc_set_preselection(pstr_drc_sel_proc_params_struct, - pstr_drc_config, - pstr_loudness_info, - restrict_to_drc_with_album_loudness, - pstr_drc_uni_sel_proc, - &selection_candidate_count, - selection_candidate_info); - + pstr_drc_config, + pstr_loudness_info, + restrict_to_drc_with_album_loudness, + pstr_drc_uni_sel_proc, + &selection_candidate_count, + selection_candidate_info); + if (selection_candidate_count == 0) { if (restrict_to_drc_with_album_loudness == 1) @@ -1406,103 +1406,103 @@ WORD32 impd_select_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, } else { - return(UNEXPECTED_ERROR); + return(UNEXPECTED_ERROR); } } - + err = impd_validate_requested_drc_feature(pstr_drc_sel_proc_params_struct); if (err) return (err); - + if (pstr_drc_sel_proc_params_struct->dynamic_range_control_on == 1) { if (pstr_drc_sel_proc_params_struct->num_drc_feature_requests > 0) { for (i=0; inum_drc_feature_requests; i++) { - switch (pstr_drc_sel_proc_params_struct->drc_feature_req_type[i]) - { - case MATCH_EFFECT_TYPE: - err = impd_match_effect_types(pstr_drc_config, - pstr_drc_sel_proc_params_struct->requested_num_drc_effects[i], - pstr_drc_sel_proc_params_struct->desired_num_drc_effects_of_requested[i], - pstr_drc_sel_proc_params_struct->requested_drc_effect_type[i], - &selection_candidate_count, - selection_candidate_info); - if (err) return (err); - break; - case MATCH_DYNAMIC_RANGE: - err = impd_match_dynamic_range(pstr_drc_config, - pstr_loudness_info, - pstr_drc_sel_proc_params_struct, - i, - &selection_candidate_count, - selection_candidate_info); - if (err) return (err); - break; - case MATCH_DRC_CHARACTERISTIC: - err = impd_match_drc_characteristic(pstr_drc_config, - pstr_drc_sel_proc_params_struct->requested_drc_characteristic[i], - &selection_candidate_count, - selection_candidate_info); - if (err) return (err); - break; - - default: - return (UNEXPECTED_ERROR); - break; + switch (pstr_drc_sel_proc_params_struct->drc_feature_req_type[i]) + { + case MATCH_EFFECT_TYPE: + err = impd_match_effect_types(pstr_drc_config, + pstr_drc_sel_proc_params_struct->requested_num_drc_effects[i], + pstr_drc_sel_proc_params_struct->desired_num_drc_effects_of_requested[i], + pstr_drc_sel_proc_params_struct->requested_drc_effect_type[i], + &selection_candidate_count, + selection_candidate_info); + if (err) return (err); + break; + case MATCH_DYNAMIC_RANGE: + err = impd_match_dynamic_range(pstr_drc_config, + pstr_loudness_info, + pstr_drc_sel_proc_params_struct, + i, + &selection_candidate_count, + selection_candidate_info); + if (err) return (err); + break; + case MATCH_DRC_CHARACTERISTIC: + err = impd_match_drc_characteristic(pstr_drc_config, + pstr_drc_sel_proc_params_struct->requested_drc_characteristic[i], + &selection_candidate_count, + selection_candidate_info); + if (err) return (err); + break; + + default: + return (UNEXPECTED_ERROR); + break; } } } else { WORD32 match_found_flag = 0; - - err = impd_select_drcs_without_compr_effects (pstr_drc_config, - &match_found_flag, - &selection_candidate_count, - selection_candidate_info); + + err = impd_select_drcs_without_compr_effects (pstr_drc_config, + &match_found_flag, + &selection_candidate_count, + selection_candidate_info); if (err) return (err); - + if (match_found_flag == 0) { WORD32 requested_num_drc_effects = 5; WORD32 desired_num_drc_effects_of_requested = 1; WORD32 requested_drc_effect_type[5] = { - EFFECT_TYPE_REQUESTED_GENERAL_COMPR, - EFFECT_TYPE_REQUESTED_NIGHT, - EFFECT_TYPE_REQUESTED_NOISY, - EFFECT_TYPE_REQUESTED_LIMITED, - EFFECT_TYPE_REQUESTED_LOWLEVEL - }; - + EFFECT_TYPE_REQUESTED_GENERAL_COMPR, + EFFECT_TYPE_REQUESTED_NIGHT, + EFFECT_TYPE_REQUESTED_NOISY, + EFFECT_TYPE_REQUESTED_LIMITED, + EFFECT_TYPE_REQUESTED_LOWLEVEL + }; + err = impd_match_effect_types(pstr_drc_config, - requested_num_drc_effects, - desired_num_drc_effects_of_requested, - requested_drc_effect_type, - &selection_candidate_count, - selection_candidate_info); + requested_num_drc_effects, + desired_num_drc_effects_of_requested, + requested_drc_effect_type, + &selection_candidate_count, + selection_candidate_info); if (err) return (err); } } - - if (selection_candidate_count > 0) - { - err = impd_drc_set_final_selection (pstr_drc_config, - pstr_drc_sel_proc_params_struct, - &selection_candidate_count, - selection_candidate_info - , pstr_drc_uni_sel_proc->eq_set_id_valid_flag - ); - if (err) return (err); - } - else - { - selection_candidate_count = 0; - return(UNEXPECTED_ERROR); - } - + + if (selection_candidate_count > 0) + { + err = impd_drc_set_final_selection (pstr_drc_config, + pstr_drc_sel_proc_params_struct, + &selection_candidate_count, + selection_candidate_info + , pstr_drc_uni_sel_proc->eq_set_id_valid_flag + ); + if (err) return (err); + } + else + { + selection_candidate_count = 0; + return(UNEXPECTED_ERROR); + } + } - + if (selection_candidate_count == 0) { if (restrict_to_drc_with_album_loudness == 1) @@ -1511,7 +1511,7 @@ WORD32 impd_select_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, } else { - return(UNEXPECTED_ERROR); + return(UNEXPECTED_ERROR); } } } @@ -1519,10 +1519,10 @@ WORD32 impd_select_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, *eq_set_id_selected = selection_candidate_info[0].eq_set_id; impd_select_loud_eq(pstr_drc_config, - pstr_drc_sel_proc_params_struct->requested_dwnmix_id[selection_candidate_info[0].downmix_id_request_index], - *drc_set_id_selected, - *eq_set_id_selected, - loud_eq_id_sel); + pstr_drc_sel_proc_params_struct->requested_dwnmix_id[selection_candidate_info[0].downmix_id_request_index], + *drc_set_id_selected, + *eq_set_id_selected, + loud_eq_id_sel); if (selection_candidate_count > 0) { pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.loudness_normalization_gain_db = selection_candidate_info[0].loudness_norm_db_gain_adjusted; diff --git a/decoder/drc_src/impd_drc_selection_process_init.c b/decoder/drc_src/impd_drc_selection_process_init.c index 38e9bef..93ad236 100644 --- a/decoder/drc_src/impd_drc_selection_process_init.c +++ b/decoder/drc_src/impd_drc_selection_process_init.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -30,14 +30,14 @@ WORD32 impd_drc_sel_proc_init_dflt(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) { if (pstr_drc_uni_sel_proc != NULL) { - + pstr_drc_uni_sel_proc->first_frame = 0; - + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_channel_count = -1; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.base_layout = -1; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type = 0; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_downmix_id_requests = 0; - + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.album_mode = 0; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.peak_limiter = 0; @@ -51,7 +51,7 @@ WORD32 impd_drc_sel_proc_init_dflt(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_system = USER_MEASUREMENT_SYSTEM_DEFAULT; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_measurement_pre_proc = USER_LOUDNESS_PREPROCESSING_DEFAULT; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.device_cut_off_frequency = 500; - pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_db_max = LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT; + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_db_max = LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_norm_gain_modification_db = 0.0f; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.output_peak_level_max = 0.0f; if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.peak_limiter == 1) { @@ -59,26 +59,26 @@ WORD32 impd_drc_sel_proc_init_dflt(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.output_peak_level_max = 6.0f; } - + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.dynamic_range_control_on = 1; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_bands_supported = 4; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.num_drc_feature_requests = 0; - + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.boost = 1.f; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.compress = 1.f; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.drc_characteristic_target = 0; - + pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.loudness_eq_request = LOUD_EQ_REQUEST_OFF; pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.eq_set_purpose_request = EQ_PURPOSE_EQ_OFF; pstr_drc_uni_sel_proc->compl_level_supported_total = COMPLEXITY_LEVEL_SUPPORTED_TOTAL; - + pstr_drc_uni_sel_proc->drc_inst_index_sel = -1; pstr_drc_uni_sel_proc->drc_coef_index_sel = -1; pstr_drc_uni_sel_proc->downmix_inst_index_sel = -1; - pstr_drc_uni_sel_proc->drc_instructions_index[0] = -1; - pstr_drc_uni_sel_proc->drc_instructions_index[1] = -1; - pstr_drc_uni_sel_proc->drc_instructions_index[2] = -1; - pstr_drc_uni_sel_proc->drc_instructions_index[3] = -1; + pstr_drc_uni_sel_proc->drc_instructions_index[0] = -1; + pstr_drc_uni_sel_proc->drc_instructions_index[1] = -1; + pstr_drc_uni_sel_proc->drc_instructions_index[2] = -1; + pstr_drc_uni_sel_proc->drc_instructions_index[3] = -1; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.output_peak_level_db = 0; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.loudness_normalization_gain_db = 0; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.output_loudness = UNDEFINED_LOUDNESS_VALUE; @@ -87,30 +87,30 @@ WORD32 impd_drc_sel_proc_init_dflt(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc) pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.base_channel_count = 0; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.target_channel_count = 0; pstr_drc_uni_sel_proc->uni_drc_sel_proc_output.downmix_matrix_present = 0; - - pstr_drc_uni_sel_proc->eq_inst_index[0] = -1; - pstr_drc_uni_sel_proc->eq_inst_index[1] = -1; + + pstr_drc_uni_sel_proc->eq_inst_index[0] = -1; + pstr_drc_uni_sel_proc->eq_inst_index[1] = -1; pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; } else { return 1; } - + return 0; } WORD32 impd_drc_sel_proc_init_sel_proc_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct) { - + if (pstr_drc_uni_sel_proc != NULL && pstr_drc_sel_proc_params_struct != NULL) { - + if ( memcmp ( &pstr_drc_uni_sel_proc->uni_drc_sel_proc_params, pstr_drc_sel_proc_params_struct, sizeof(ia_drc_sel_proc_params_struct) )) { pstr_drc_uni_sel_proc->uni_drc_sel_proc_params = *pstr_drc_sel_proc_params_struct; pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; } } - + return 0; } WORD32 @@ -118,9 +118,9 @@ impd_drc_sel_proc_init_interface_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_ ia_drc_interface_struct* pstr_drc_interface) { WORD32 i,j; - + if (pstr_drc_uni_sel_proc != NULL && pstr_drc_interface != NULL) { - + if (pstr_drc_interface->system_interface_flag) { if (pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type != pstr_drc_interface->system_interface.target_config_request_type) { pstr_drc_uni_sel_proc->uni_drc_sel_proc_params.target_config_request_type = pstr_drc_interface->system_interface.target_config_request_type; @@ -289,7 +289,7 @@ impd_drc_sel_proc_init_interface_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_ pstr_drc_uni_sel_proc->sel_proc_request_flag = 1; } break; - } + } } } } @@ -328,9 +328,9 @@ impd_drc_sel_proc_init_interface_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_ } } } - + return 0; } - + diff --git a/decoder/drc_src/impd_drc_shape_filter.c b/decoder/drc_src/impd_drc_shape_filter.c index 4579681..4a33c7b 100644 --- a/decoder/drc_src/impd_drc_shape_filter.c +++ b/decoder/drc_src/impd_drc_shape_filter.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include #include @@ -40,8 +40,8 @@ WORD32 impd_shape_filt_block_adapt(const FLOAT32 drc_gain, shape_filter_block* shape_filter_block) { -// WORD32 err = 0; - WORD32 i; +// WORD32 err = 0; + WORD32 i; FLOAT32 warpedGain, x1, y1; shape_filter_block->drc_gain_last = drc_gain; for (i=0; i<4; i++) { @@ -50,9 +50,9 @@ WORD32 impd_shape_filt_block_adapt(const FLOAT32 drc_gain, continue; else if(shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_LF_CUT||shape_filter_block->shape_filter[i].type==SHAPE_FILTER_TYPE_HF_CUT) { - if (drc_gain < 1.0f) + if (drc_gain < 1.0f) warpedGain = -1.0f; - else + else warpedGain = (drc_gain - 1.0f) / (drc_gain - 1.0f + shape_filter_block->shape_filter[i].gain_offset); x1 = shape_filter_block->shape_filter[i].a1; } @@ -60,12 +60,12 @@ WORD32 impd_shape_filt_block_adapt(const FLOAT32 drc_gain, { if (drc_gain >= 1.0f) warpedGain = -1.0f; - else + else warpedGain = (1.0f - drc_gain) / (1.0f + drc_gain * (shape_filter_block->shape_filter[i].gain_offset - 1.0f)); x1 = shape_filter_block->shape_filter[i].b1; } - + if (warpedGain <= 0.0f) { y1 = x1; @@ -117,25 +117,25 @@ WORD32 resetshape_flter_block(shape_filter_block* shape_filter_block) return (0); } - + WORD32 impd_shape_filt_block_init(ia_shape_filter_block_params_struct* shape_flter_block_params, shape_filter_block* shape_filter_block) { //WORD32 err = 0; - FLOAT32 x1; + FLOAT32 x1; FLOAT32 x2 = 0.0f; FLOAT32 radius; if (shape_flter_block_params->lf_cut_filter_present) { - - ia_shape_filter_params_struct* params = &shape_flter_block_params->str_lf_cut_params; + + ia_shape_filter_params_struct* params = &shape_flter_block_params->str_lf_cut_params; shape_filter_block->shape_filter[0].type = SHAPE_FILTER_TYPE_LF_CUT; shape_filter_block->shape_filter[0].gain_offset = shape_filt_lf_gain_offset_tbl[params->corner_freq_index][params->filter_strength_index]; shape_filter_block->shape_filter[0].y1_bound = shape_filt_lf_y1_bound_tbl[params->corner_freq_index][params->filter_strength_index]; - x1 = - shape_filt_lf_radius_tbl[params->corner_freq_index]; + x1 = - shape_filt_lf_radius_tbl[params->corner_freq_index]; shape_filter_block->shape_filter[0].warped_gain_max = SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE / (SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE + shape_filter_block->shape_filter[0].gain_offset); shape_filter_block->shape_filter[0].factor = (shape_filter_block->shape_filter[0].y1_bound - x1) / shape_filter_block->shape_filter[0].warped_gain_max; shape_filter_block->shape_filter[0].a1 = x1; - + } else { @@ -147,11 +147,11 @@ WORD32 impd_shape_filt_block_init(ia_shape_filter_block_params_struct* shape_flt shape_filter_block->shape_filter[1].type = SHAPE_FILTER_TYPE_LF_BOOST; shape_filter_block->shape_filter[1].gain_offset = shape_filt_lf_gain_offset_tbl[params->corner_freq_index][params->filter_strength_index]; shape_filter_block->shape_filter[1].y1_bound = shape_filt_lf_y1_bound_tbl[params->corner_freq_index][params->filter_strength_index]; - x1 = - shape_filt_lf_radius_tbl[params->corner_freq_index]; + x1 = - shape_filt_lf_radius_tbl[params->corner_freq_index]; shape_filter_block->shape_filter[1].warped_gain_max = SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE / (SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE + shape_filter_block->shape_filter[1].gain_offset); shape_filter_block->shape_filter[1].factor = (shape_filter_block->shape_filter[1].y1_bound - x1) / shape_filter_block->shape_filter[1].warped_gain_max; shape_filter_block->shape_filter[1].b1 = x1; - + } else { @@ -172,30 +172,30 @@ WORD32 impd_shape_filt_block_init(ia_shape_filter_block_params_struct* shape_flt shape_filter_block->shape_filter[2].partial_coeff_sum = 1.0f + x2; shape_filter_block->shape_filter[2].a1 = x1; shape_filter_block->shape_filter[2].a2 = x2; - shape_filter_block->shape_filter[2].b2 = x2; + shape_filter_block->shape_filter[2].b2 = x2; } else { shape_filter_block->shape_filter[2].type = SHAPE_FILTER_TYPE_OFF; } if (shape_flter_block_params->hf_boost_filter_present) { - + ia_shape_filter_params_struct* params = &shape_flter_block_params->str_hf_boost_params; shape_filter_block->shape_filter[3].type = SHAPE_FILTER_TYPE_HF_BOOST; shape_filter_block->shape_filter[3].gain_offset = shape_filt_hf_gain_offset_tbl[params->corner_freq_index][params->filter_strength_index]; shape_filter_block->shape_filter[3].y1_bound = shape_filt_hf_y1_bound_tbl[params->corner_freq_index][params->filter_strength_index]; radius = shape_filt_hf_radius_tbl[params->corner_freq_index]; x1 = (FLOAT32)(- 2.0f * radius * cos(2.0f * M_PI * shape_filt_cutoff_freq_norm_hf_tbl[params->corner_freq_index])); - x2 = radius * radius; + x2 = radius * radius; shape_filter_block->shape_filter[3].warped_gain_max = SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE / (SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE + shape_filter_block->shape_filter[3].gain_offset); shape_filter_block->shape_filter[3].factor = (shape_filter_block->shape_filter[3].y1_bound - x1) / shape_filter_block->shape_filter[3].warped_gain_max; shape_filter_block->shape_filter[3].coeff_sum = 1.0f + x1 + x2; shape_filter_block->shape_filter[3].partial_coeff_sum = 1.0f + x2; shape_filter_block->shape_filter[3].b1 = x1; shape_filter_block->shape_filter[3].b2 = x2; - shape_filter_block->shape_filter[3].a2 = x2; - - + shape_filter_block->shape_filter[3].a2 = x2; + + } else { @@ -215,7 +215,7 @@ WORD32 impd_shape_filt_block_time_process(shape_filter_block* shape_filter_block WORD32 start, WORD32 end) { - WORD32 i,j, err=0; + WORD32 i,j, err=0; FLOAT32 audio_out; if(shape_filter_block->shape_flter_block_flag){ @@ -224,42 +224,42 @@ WORD32 impd_shape_filt_block_time_process(shape_filter_block* shape_filter_block FLOAT32 tmp = audio_in[i]; for (j=0; j<4; j++) { if(shape_filter_block->shape_filter[j].type==SHAPE_FILTER_TYPE_LF_CUT||shape_filter_block->shape_filter[j].type==SHAPE_FILTER_TYPE_LF_BOOST){ - - audio_out = tmp + shape_filter_block->shape_filter[j].b1 * shape_filter_block->shape_filter[j].audio_in_state_1[channel] + + audio_out = tmp + shape_filter_block->shape_filter[j].b1 * shape_filter_block->shape_filter[j].audio_in_state_1[channel] - shape_filter_block->shape_filter[j].a1 * shape_filter_block->shape_filter[j].audio_out_state_1[channel]; shape_filter_block->shape_filter[j].audio_in_state_1[channel] = tmp; shape_filter_block->shape_filter[j].audio_out_state_1[channel] = audio_out; } else if(shape_filter_block->shape_filter[j].type==SHAPE_FILTER_TYPE_HF_CUT||shape_filter_block->shape_filter[j].type==SHAPE_FILTER_TYPE_HF_BOOST){ - - audio_out = shape_filter_block->shape_filter[j].g_norm * tmp + shape_filter_block->shape_filter[j].b1 * shape_filter_block->shape_filter[j].audio_in_state_1[channel] - + shape_filter_block->shape_filter[j].b2 * shape_filter_block->shape_filter[j].audio_in_state_2[channel] - - shape_filter_block->shape_filter[j].a1 * shape_filter_block->shape_filter[j].audio_out_state_1[channel] + + audio_out = shape_filter_block->shape_filter[j].g_norm * tmp + shape_filter_block->shape_filter[j].b1 * shape_filter_block->shape_filter[j].audio_in_state_1[channel] + + shape_filter_block->shape_filter[j].b2 * shape_filter_block->shape_filter[j].audio_in_state_2[channel] + - shape_filter_block->shape_filter[j].a1 * shape_filter_block->shape_filter[j].audio_out_state_1[channel] - shape_filter_block->shape_filter[j].a2 * shape_filter_block->shape_filter[j].audio_out_state_2[channel]; shape_filter_block->shape_filter[j].audio_in_state_2[channel] = shape_filter_block->shape_filter[j].audio_in_state_1[channel]; shape_filter_block->shape_filter[j].audio_in_state_1[channel] = shape_filter_block->shape_filter[j].g_norm * tmp; shape_filter_block->shape_filter[j].audio_out_state_2[channel] = shape_filter_block->shape_filter[j].audio_out_state_1[channel]; - shape_filter_block->shape_filter[j].audio_out_state_1[channel] = audio_out; + shape_filter_block->shape_filter[j].audio_out_state_1[channel] = audio_out; } else { audio_out = tmp; } tmp = audio_out; - - } - + + } + audio_in[i] = audio_out * drc_gain[i]; } } else{ for (i=start; i #include #include @@ -79,314 +79,314 @@ static VOID impd_parametric_drc_ffwd_init_drc_curve_params(WORD32 drc_characteri default: str_parametric_drc_type_feed_forward->disable_paramteric_drc = 1; } - + return; } static VOID impd_parametric_drc_ffwd_init_drc_gain_smooth_params(WORD32 drc_characteristic, - ia_parametric_drc_type_feed_forward_struct* str_parametric_drc_type_feed_forward) + ia_parametric_drc_type_feed_forward_struct* str_parametric_drc_type_feed_forward) { - str_parametric_drc_type_feed_forward->gain_smooth_attack_time_slow = 100; - str_parametric_drc_type_feed_forward->gain_smooth_time_fast_present = 1; - str_parametric_drc_type_feed_forward->gain_smooth_attack_time_fast = 10; - str_parametric_drc_type_feed_forward->gain_smooth_threshold_present = 1; - str_parametric_drc_type_feed_forward->gain_smooth_hold_off_count_present = 1; - str_parametric_drc_type_feed_forward->gain_smooth_hold_off = 10; + str_parametric_drc_type_feed_forward->gain_smooth_attack_time_slow = 100; + str_parametric_drc_type_feed_forward->gain_smooth_time_fast_present = 1; + str_parametric_drc_type_feed_forward->gain_smooth_attack_time_fast = 10; + str_parametric_drc_type_feed_forward->gain_smooth_threshold_present = 1; + str_parametric_drc_type_feed_forward->gain_smooth_hold_off_count_present = 1; + str_parametric_drc_type_feed_forward->gain_smooth_hold_off = 10; - switch (drc_characteristic) - { - case 7: - case 8: - case 9: - str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 3000; - str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 1000; - str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 15; - str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 20; - break; - case 10: - str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 10000; - str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 1000; - str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 15; - str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 20; - break; - case 11: - str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 1000; - str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 200; - str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 10; - str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 10; - break; - default: - str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 3000; - str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 1000; - str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 15; - str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 20; - break; + switch (drc_characteristic) + { + case 7: + case 8: + case 9: + str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 3000; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 1000; + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 15; + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 20; + break; + case 10: + str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 10000; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 1000; + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 15; + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 20; + break; + case 11: + str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 1000; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 200; + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 10; + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 10; + break; + default: + str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = 3000; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = 1000; + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 15; + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 20; + break; } - + return; } static WORD32 impd_parse_parametric_drc_ffwd(ia_bit_buf_struct* it_bit_buff, - WORD32 parametric_drc_frame_size, - ia_parametric_drc_type_feed_forward_struct* str_parametric_drc_type_feed_forward) + WORD32 parametric_drc_frame_size, + ia_parametric_drc_type_feed_forward_struct* str_parametric_drc_type_feed_forward) { WORD32 i = 0, tmp = 0; - //WORD32 err = 0; - + //WORD32 err = 0; + str_parametric_drc_type_feed_forward->disable_paramteric_drc = 0; - tmp = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; - str_parametric_drc_type_feed_forward->level_estim_k_weighting_type = (tmp>>1)&3; - str_parametric_drc_type_feed_forward->level_estim_integration_time_present = tmp&1; + str_parametric_drc_type_feed_forward->level_estim_k_weighting_type = (tmp>>1)&3; + str_parametric_drc_type_feed_forward->level_estim_integration_time_present = tmp&1; - if (str_parametric_drc_type_feed_forward->level_estim_integration_time_present) - { - tmp = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - str_parametric_drc_type_feed_forward->level_estim_integration_time = (tmp+1)*parametric_drc_frame_size; - } else - { - str_parametric_drc_type_feed_forward->level_estim_integration_time = parametric_drc_frame_size; - } - - str_parametric_drc_type_feed_forward->drc_curve_definition_type = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (str_parametric_drc_type_feed_forward->drc_curve_definition_type == 0) - { - str_parametric_drc_type_feed_forward->drc_characteristic = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - impd_parametric_drc_ffwd_init_drc_curve_params(str_parametric_drc_type_feed_forward->drc_characteristic, str_parametric_drc_type_feed_forward); - } - else - { - str_parametric_drc_type_feed_forward->drc_characteristic = 0; - - tmp = impd_read_bits_buf(it_bit_buff, 15); - if(it_bit_buff->error) - return it_bit_buff->error; - - str_parametric_drc_type_feed_forward->node_count = ((tmp>>12)&3) + 2; - str_parametric_drc_type_feed_forward->node_level[0] = -11-((tmp>>6)&0x3f); - str_parametric_drc_type_feed_forward->node_gain[0] = (tmp&0x3f)-39; - - for (i=1; inode_count; i++) - { - tmp = impd_read_bits_buf(it_bit_buff, 11); - if(it_bit_buff->error) - return it_bit_buff->error; - - str_parametric_drc_type_feed_forward->node_level[i] = str_parametric_drc_type_feed_forward->node_level[i-1]+1+((tmp>>6)&0x1f); - str_parametric_drc_type_feed_forward->node_gain[i] = (tmp&0x3f)-39; - } - } - - impd_parametric_drc_ffwd_init_drc_gain_smooth_params(str_parametric_drc_type_feed_forward->drc_characteristic, str_parametric_drc_type_feed_forward); - - str_parametric_drc_type_feed_forward->drc_gain_smooth_parameters_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (str_parametric_drc_type_feed_forward->drc_gain_smooth_parameters_present) - { + if (str_parametric_drc_type_feed_forward->level_estim_integration_time_present) + { + tmp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_parametric_drc_type_feed_forward->level_estim_integration_time = (tmp+1)*parametric_drc_frame_size; + } else + { + str_parametric_drc_type_feed_forward->level_estim_integration_time = parametric_drc_frame_size; + } - tmp = impd_read_bits_buf(it_bit_buff, 17); - if(it_bit_buff->error) - return it_bit_buff->error; + str_parametric_drc_type_feed_forward->drc_curve_definition_type = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; - str_parametric_drc_type_feed_forward->gain_smooth_attack_time_slow = ((tmp>>9)&0xff)*5; - str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = ((tmp>>1)&0xff)*40; - str_parametric_drc_type_feed_forward->gain_smooth_time_fast_present = tmp&1; + if (str_parametric_drc_type_feed_forward->drc_curve_definition_type == 0) + { + str_parametric_drc_type_feed_forward->drc_characteristic = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + impd_parametric_drc_ffwd_init_drc_curve_params(str_parametric_drc_type_feed_forward->drc_characteristic, str_parametric_drc_type_feed_forward); + } + else + { + str_parametric_drc_type_feed_forward->drc_characteristic = 0; - if (str_parametric_drc_type_feed_forward->gain_smooth_time_fast_present) - { - - tmp = impd_read_bits_buf(it_bit_buff, 17); - if(it_bit_buff->error) - return it_bit_buff->error; + tmp = impd_read_bits_buf(it_bit_buff, 15); + if(it_bit_buff->error) + return it_bit_buff->error; - str_parametric_drc_type_feed_forward->gain_smooth_attack_time_fast = ((tmp>>9)&0xff)*5; - str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = ((tmp>>1)&0xff)*20; - str_parametric_drc_type_feed_forward->gain_smooth_threshold_present = tmp&1; - - if (str_parametric_drc_type_feed_forward->gain_smooth_threshold_present) - { - str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - if ( str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold == 31) - { - str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 1000; - } - - str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - if (str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold == 31) - { - str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 1000; - } - } - } - else - { - str_parametric_drc_type_feed_forward->gain_smooth_attack_time_fast = str_parametric_drc_type_feed_forward->gain_smooth_attack_time_slow; - str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow; - } - - str_parametric_drc_type_feed_forward->gain_smooth_hold_off_count_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (str_parametric_drc_type_feed_forward->gain_smooth_hold_off_count_present) - { - str_parametric_drc_type_feed_forward->gain_smooth_hold_off = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - } - } - return 0; + str_parametric_drc_type_feed_forward->node_count = ((tmp>>12)&3) + 2; + str_parametric_drc_type_feed_forward->node_level[0] = -11-((tmp>>6)&0x3f); + str_parametric_drc_type_feed_forward->node_gain[0] = (tmp&0x3f)-39; + + for (i=1; inode_count; i++) + { + tmp = impd_read_bits_buf(it_bit_buff, 11); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_type_feed_forward->node_level[i] = str_parametric_drc_type_feed_forward->node_level[i-1]+1+((tmp>>6)&0x1f); + str_parametric_drc_type_feed_forward->node_gain[i] = (tmp&0x3f)-39; + } + } + + impd_parametric_drc_ffwd_init_drc_gain_smooth_params(str_parametric_drc_type_feed_forward->drc_characteristic, str_parametric_drc_type_feed_forward); + + str_parametric_drc_type_feed_forward->drc_gain_smooth_parameters_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_parametric_drc_type_feed_forward->drc_gain_smooth_parameters_present) + { + + tmp = impd_read_bits_buf(it_bit_buff, 17); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_type_feed_forward->gain_smooth_attack_time_slow = ((tmp>>9)&0xff)*5; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow = ((tmp>>1)&0xff)*40; + str_parametric_drc_type_feed_forward->gain_smooth_time_fast_present = tmp&1; + + if (str_parametric_drc_type_feed_forward->gain_smooth_time_fast_present) + { + + tmp = impd_read_bits_buf(it_bit_buff, 17); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_type_feed_forward->gain_smooth_attack_time_fast = ((tmp>>9)&0xff)*5; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = ((tmp>>1)&0xff)*20; + str_parametric_drc_type_feed_forward->gain_smooth_threshold_present = tmp&1; + + if (str_parametric_drc_type_feed_forward->gain_smooth_threshold_present) + { + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + if ( str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold == 31) + { + str_parametric_drc_type_feed_forward->gain_smooth_attack_threshold = 1000; + } + + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold == 31) + { + str_parametric_drc_type_feed_forward->gain_smooth_rel_threshold = 1000; + } + } + } + else + { + str_parametric_drc_type_feed_forward->gain_smooth_attack_time_fast = str_parametric_drc_type_feed_forward->gain_smooth_attack_time_slow; + str_parametric_drc_type_feed_forward->gain_smooth_release_time_fast = str_parametric_drc_type_feed_forward->gain_smooth_release_time_slow; + } + + str_parametric_drc_type_feed_forward->gain_smooth_hold_off_count_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_parametric_drc_type_feed_forward->gain_smooth_hold_off_count_present) + { + str_parametric_drc_type_feed_forward->gain_smooth_hold_off = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + return 0; } static WORD32 impd_parse_parametric_drc_lim(ia_bit_buf_struct* it_bit_buff, - ia_parametric_drc_lim_struct* parametric_drc_lim) + ia_parametric_drc_lim_struct* parametric_drc_lim) { //WORD32 err = 0; - WORD32 tmp = 0; - + WORD32 tmp = 0; + parametric_drc_lim->disable_paramteric_drc = 0; - - parametric_drc_lim->parametric_lim_threshold_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (parametric_drc_lim->parametric_lim_threshold_present) - { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - parametric_drc_lim->parametric_lim_threshold = - tmp * 0.125f; - } else - { - parametric_drc_lim->parametric_lim_threshold = PARAM_DRC_TYPE_LIM_THRESHOLD_DEFAULT; - } - - parametric_drc_lim->parametric_lim_release_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (parametric_drc_lim->parametric_lim_release_present) - { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - parametric_drc_lim->parametric_lim_release = tmp*10; - } - else - { - parametric_drc_lim->parametric_lim_release = PARAM_DRC_TYPE_LIM_RELEASE_DEFAULT; - } - - parametric_drc_lim->parametric_lim_attack = PARAM_DRC_TYPE_LIM_ATTACK_DEFAULT; - parametric_drc_lim->drc_characteristic = 0; - - return 0; + + parametric_drc_lim->parametric_lim_threshold_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (parametric_drc_lim->parametric_lim_threshold_present) + { + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + parametric_drc_lim->parametric_lim_threshold = - tmp * 0.125f; + } else + { + parametric_drc_lim->parametric_lim_threshold = PARAM_DRC_TYPE_LIM_THRESHOLD_DEFAULT; + } + + parametric_drc_lim->parametric_lim_release_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (parametric_drc_lim->parametric_lim_release_present) + { + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + parametric_drc_lim->parametric_lim_release = tmp*10; + } + else + { + parametric_drc_lim->parametric_lim_release = PARAM_DRC_TYPE_LIM_RELEASE_DEFAULT; + } + + parametric_drc_lim->parametric_lim_attack = PARAM_DRC_TYPE_LIM_ATTACK_DEFAULT; + parametric_drc_lim->drc_characteristic = 0; + + return 0; } WORD32 impd_parametric_drc_parse_gain_set_params(ia_bit_buf_struct* it_bit_buff, - ia_drc_config* drc_config, - ia_parametric_drc_gain_set_params_struct* str_parametric_drc_gain_set_params) + ia_drc_config* drc_config, + ia_parametric_drc_gain_set_params_struct* str_parametric_drc_gain_set_params) { WORD32 i = 0, bsDrcInputLoudness = 0, bs_channel_weight = 0, temp; - //WORD32 err = 0; - temp = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + //WORD32 err = 0; + temp = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; - str_parametric_drc_gain_set_params->parametric_drc_id = (temp>>3)&0xf; - str_parametric_drc_gain_set_params->side_chain_config_type = temp&7; - - if (str_parametric_drc_gain_set_params->side_chain_config_type) - { - - temp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + str_parametric_drc_gain_set_params->parametric_drc_id = (temp>>3)&0xf; + str_parametric_drc_gain_set_params->side_chain_config_type = temp&7; - str_parametric_drc_gain_set_params->downmix_id = (temp>>1)&0x7f; - str_parametric_drc_gain_set_params->level_estim_channel_weight_format = temp&1; + if (str_parametric_drc_gain_set_params->side_chain_config_type) + { - if (str_parametric_drc_gain_set_params->downmix_id == ID_FOR_BASE_LAYOUT) - { - str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = drc_config->channel_layout.base_channel_count; - } - else if (str_parametric_drc_gain_set_params->downmix_id == ID_FOR_ANY_DOWNMIX) - { - str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = 1; - } else - { - for(i=0; idwnmix_instructions_count; i++) - { - if (str_parametric_drc_gain_set_params->downmix_id == drc_config->dwnmix_instructions[i].downmix_id) break; - } - if (i == drc_config->dwnmix_instructions_count) - { - /* dwnmix_instructions not found */ - return(UNEXPECTED_ERROR); - } - str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = drc_config->dwnmix_instructions[i].target_channel_count; - } - - for (i=0; ich_count_from_dwnmix_id; i++) - { - if (str_parametric_drc_gain_set_params->level_estim_channel_weight_format == 0) - { - str_parametric_drc_gain_set_params->level_estim_ch_weight[i] = (FLOAT32)impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - } else - { - bs_channel_weight = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - str_parametric_drc_gain_set_params->level_estim_ch_weight[i] = (FLOAT32)pow(10.0f, 0.05f * channel_weight[bs_channel_weight]); - } - } - } - else - { - str_parametric_drc_gain_set_params->downmix_id = 0; - str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = 0; - } - - str_parametric_drc_gain_set_params->drc_input_loudness_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (str_parametric_drc_gain_set_params->drc_input_loudness_present) - { - bsDrcInputLoudness = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - str_parametric_drc_gain_set_params->drc_input_loudness = -57.75f + bsDrcInputLoudness * 0.25f; - } - - return 0; + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_parametric_drc_gain_set_params->downmix_id = (temp>>1)&0x7f; + str_parametric_drc_gain_set_params->level_estim_channel_weight_format = temp&1; + + if (str_parametric_drc_gain_set_params->downmix_id == ID_FOR_BASE_LAYOUT) + { + str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = drc_config->channel_layout.base_channel_count; + } + else if (str_parametric_drc_gain_set_params->downmix_id == ID_FOR_ANY_DOWNMIX) + { + str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = 1; + } else + { + for(i=0; idwnmix_instructions_count; i++) + { + if (str_parametric_drc_gain_set_params->downmix_id == drc_config->dwnmix_instructions[i].downmix_id) break; + } + if (i == drc_config->dwnmix_instructions_count) + { + /* dwnmix_instructions not found */ + return(UNEXPECTED_ERROR); + } + str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = drc_config->dwnmix_instructions[i].target_channel_count; + } + + for (i=0; ich_count_from_dwnmix_id; i++) + { + if (str_parametric_drc_gain_set_params->level_estim_channel_weight_format == 0) + { + str_parametric_drc_gain_set_params->level_estim_ch_weight[i] = (FLOAT32)impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } else + { + bs_channel_weight = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + str_parametric_drc_gain_set_params->level_estim_ch_weight[i] = (FLOAT32)pow(10.0f, 0.05f * channel_weight[bs_channel_weight]); + } + } + } + else + { + str_parametric_drc_gain_set_params->downmix_id = 0; + str_parametric_drc_gain_set_params->ch_count_from_dwnmix_id = 0; + } + + str_parametric_drc_gain_set_params->drc_input_loudness_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_parametric_drc_gain_set_params->drc_input_loudness_present) + { + bsDrcInputLoudness = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + str_parametric_drc_gain_set_params->drc_input_loudness = -57.75f + bsDrcInputLoudness * 0.25f; + } + + return 0; } static WORD32 impd_parametric_drc_gen_virtual_gain_sets(ia_drc_config* drc_config) { - + WORD32 i = 0, j = 0, c1 = -1, c0 = -1, parametric_drc_id = 0, drc_characteristic = 0; ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc; ia_parametric_drc_instructions_struct* str_parametric_drc_instructions; ia_drc_coeff_parametric_drc_struct* str_drc_coeff_param_drc = &(drc_config->str_drc_config_ext.str_drc_coeff_param_drc); - + for(i=0; idrc_coefficients_drc_count; i++) { if (drc_config->str_p_loc_drc_coefficients_uni_drc[i].drc_location == str_drc_coeff_param_drc->drc_location) @@ -401,25 +401,25 @@ static WORD32 impd_parametric_drc_gen_virtual_gain_sets(ia_drc_config* drc_confi } } } - if (c1 >= 0) - { + if (c1 >= 0) + { str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[c1]); } - else if (c0 >= 0) - { + else if (c0 >= 0) + { str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[c0]); } - else - { + else + { str_p_loc_drc_coefficients_uni_drc = &drc_config->str_p_loc_drc_coefficients_uni_drc[drc_config->drc_coefficients_drc_count]; - + str_p_loc_drc_coefficients_uni_drc->version = 1; str_p_loc_drc_coefficients_uni_drc->drc_location = str_drc_coeff_param_drc->drc_location; str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present = 0; str_p_loc_drc_coefficients_uni_drc->gain_set_count = 0; str_p_loc_drc_coefficients_uni_drc->gain_set_count_plus = 0; - + str_p_loc_drc_coefficients_uni_drc->drc_characteristic_left_present = 0; str_p_loc_drc_coefficients_uni_drc->drc_characteristic_right_present = 0; str_p_loc_drc_coefficients_uni_drc->shape_filters_present = 0; @@ -430,245 +430,245 @@ static WORD32 impd_parametric_drc_gen_virtual_gain_sets(ia_drc_config* drc_confi for (i=str_p_loc_drc_coefficients_uni_drc->gain_set_count; igain_set_count_plus; i++) { str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].band_count = 1; - + parametric_drc_id = drc_config->str_drc_config_ext.str_drc_coeff_param_drc.str_parametric_drc_gain_set_params[i-str_p_loc_drc_coefficients_uni_drc->gain_set_count].parametric_drc_id; - + for(j=0; jstr_drc_config_ext.parametric_drc_instructions_count; j++) { if (parametric_drc_id == drc_config->str_drc_config_ext.str_parametric_drc_instructions[j].parametric_drc_id) break; } if (j == drc_config->str_drc_config_ext.parametric_drc_instructions_count) { - /* str_parametric_drc_instructions not found */ + /* str_parametric_drc_instructions not found */ return(UNEXPECTED_ERROR); } str_parametric_drc_instructions = &drc_config->str_drc_config_ext.str_parametric_drc_instructions[j]; - + drc_characteristic = 0; - if (str_parametric_drc_instructions->parametric_drc_preset_id_present) - { + if (str_parametric_drc_instructions->parametric_drc_preset_id_present) + { drc_characteristic = str_parametric_drc_instructions->drc_characteristic; - } - else if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_FF) - { - if (str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.drc_curve_definition_type == 0) - { + } + else if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_FF) + { + if (str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.drc_curve_definition_type == 0) + { drc_characteristic = str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.drc_characteristic; } } if (drc_characteristic != 0) - { + { str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic_present = 1; str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic_format_is_cicp = 1; str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic = drc_characteristic; - } - else - { + } + else + { str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic_present = 0; str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic_format_is_cicp = 0; str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].gain_params[0].drc_characteristic = 0; } } - + return 0; } static WORD32 impd_parametic_drc_parse_coeff(ia_bit_buf_struct* it_bit_buff, - ia_drc_config* drc_config, - ia_drc_coeff_parametric_drc_struct* str_drc_coeff_param_drc) + ia_drc_config* drc_config, + ia_drc_coeff_parametric_drc_struct* str_drc_coeff_param_drc) { WORD32 i = 0, err = 0, code = 0, mu = 0, nu = 0, temp; - temp = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; - str_drc_coeff_param_drc->drc_location = (temp>>1)&0xf; - str_drc_coeff_param_drc->parametric_drc_frame_size_format = temp&1; + str_drc_coeff_param_drc->drc_location = (temp>>1)&0xf; + str_drc_coeff_param_drc->parametric_drc_frame_size_format = temp&1; - if (str_drc_coeff_param_drc->parametric_drc_frame_size) - { - code = impd_read_bits_buf(it_bit_buff, 15); - if(it_bit_buff->error) - return it_bit_buff->error; - str_drc_coeff_param_drc->parametric_drc_frame_size = code + 1; - } - else - { - code = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - str_drc_coeff_param_drc->parametric_drc_frame_size = 1 << code; - } - - str_drc_coeff_param_drc->parametric_drc_delay_max_present = impd_read_bits_buf(it_bit_buff, 1); - if (str_drc_coeff_param_drc->parametric_drc_delay_max_present) - { - temp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + if (str_drc_coeff_param_drc->parametric_drc_frame_size) + { + code = impd_read_bits_buf(it_bit_buff, 15); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_coeff_param_drc->parametric_drc_frame_size = code + 1; + } + else + { + code = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_coeff_param_drc->parametric_drc_frame_size = 1 << code; + } - mu = (temp>>3)&0x1f; - nu = temp&3; + str_drc_coeff_param_drc->parametric_drc_delay_max_present = impd_read_bits_buf(it_bit_buff, 1); + if (str_drc_coeff_param_drc->parametric_drc_delay_max_present) + { + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - str_drc_coeff_param_drc->parametric_drc_delay_max = 16 * mu * (1<>3)&0x1f; + nu = temp&3; - temp = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - - str_drc_coeff_param_drc->reset_parametric_drc = (temp>>6)&1; - str_drc_coeff_param_drc->parametric_drc_gain_set_count = temp&0x3f; + str_drc_coeff_param_drc->parametric_drc_delay_max = 16 * mu * (1<parametric_drc_gain_set_count; i++) - { - err = impd_parametric_drc_parse_gain_set_params(it_bit_buff, drc_config, &(str_drc_coeff_param_drc->str_parametric_drc_gain_set_params[i])); - if (err) return (err); - } - - return 0; + temp = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_drc_coeff_param_drc->reset_parametric_drc = (temp>>6)&1; + str_drc_coeff_param_drc->parametric_drc_gain_set_count = temp&0x3f; + + for(i=0; iparametric_drc_gain_set_count; i++) + { + err = impd_parametric_drc_parse_gain_set_params(it_bit_buff, drc_config, &(str_drc_coeff_param_drc->str_parametric_drc_gain_set_params[i])); + if (err) return (err); + } + + return 0; } static WORD32 impd_parse_parametric_drc_instructions(ia_bit_buf_struct* it_bit_buff, - WORD32 parametric_drc_frame_size, - ia_parametric_drc_instructions_struct* str_parametric_drc_instructions) + WORD32 parametric_drc_frame_size, + ia_parametric_drc_instructions_struct* str_parametric_drc_instructions) { WORD32 i = 0, err = 0, temp; WORD32 bit_size_len, bit_size, other_bit; - + str_parametric_drc_instructions->drc_characteristic = 0; str_parametric_drc_instructions->disable_paramteric_drc = 0; - temp = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; - str_parametric_drc_instructions->parametric_drc_id = (temp>>1)&0xf; - str_parametric_drc_instructions->parametric_drc_look_ahead_flag = temp&1; - - if (str_parametric_drc_instructions->parametric_drc_look_ahead_flag) - { - str_parametric_drc_instructions->parametric_drc_look_ahead = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - } - else - { - str_parametric_drc_instructions->parametric_drc_look_ahead = 0; - } - - str_parametric_drc_instructions->parametric_drc_preset_id_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (str_parametric_drc_instructions->parametric_drc_preset_id_present) - { - str_parametric_drc_instructions->parametric_drc_preset_id = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - - switch (str_parametric_drc_instructions->parametric_drc_preset_id) - { - case 0: - case 1: - case 2: - case 3: - case 4: - str_parametric_drc_instructions->drc_characteristic = str_parametric_drc_instructions->parametric_drc_preset_id + 7; - str_parametric_drc_instructions->parametric_drc_type = PARAM_DRC_TYPE_FF; + str_parametric_drc_instructions->parametric_drc_id = (temp>>1)&0xf; + str_parametric_drc_instructions->parametric_drc_look_ahead_flag = temp&1; - str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.level_estim_k_weighting_type = 2; - str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.level_estim_integration_time = parametric_drc_frame_size; + if (str_parametric_drc_instructions->parametric_drc_look_ahead_flag) + { + str_parametric_drc_instructions->parametric_drc_look_ahead = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + str_parametric_drc_instructions->parametric_drc_look_ahead = 0; + } - impd_parametric_drc_ffwd_init_drc_curve_params(str_parametric_drc_instructions->drc_characteristic, &str_parametric_drc_instructions->str_parametric_drc_type_feed_forward); - impd_parametric_drc_ffwd_init_drc_gain_smooth_params(str_parametric_drc_instructions->drc_characteristic, &str_parametric_drc_instructions->str_parametric_drc_type_feed_forward); + str_parametric_drc_instructions->parametric_drc_preset_id_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; - break; - default: - str_parametric_drc_instructions->disable_paramteric_drc = 1; - break; - } - } - else - { - str_parametric_drc_instructions->parametric_drc_type = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_FF) - { - err = impd_parse_parametric_drc_ffwd(it_bit_buff, parametric_drc_frame_size, &(str_parametric_drc_instructions->str_parametric_drc_type_feed_forward)); - if (err) return (err); - str_parametric_drc_instructions->disable_paramteric_drc = str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.disable_paramteric_drc; - str_parametric_drc_instructions->drc_characteristic = str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.drc_characteristic; - } - else if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_LIM) - { - err = impd_parse_parametric_drc_lim(it_bit_buff, &(str_parametric_drc_instructions->parametric_drc_lim)); - if (err) return (err); - str_parametric_drc_instructions->disable_paramteric_drc = str_parametric_drc_instructions->parametric_drc_lim.disable_paramteric_drc; - str_parametric_drc_instructions->drc_characteristic = str_parametric_drc_instructions->parametric_drc_lim.drc_characteristic; - if (str_parametric_drc_instructions->parametric_drc_look_ahead_flag) - { - str_parametric_drc_instructions->parametric_drc_lim.parametric_lim_attack = str_parametric_drc_instructions->parametric_drc_look_ahead; - } - } - else - { - bit_size_len = impd_read_bits_buf(it_bit_buff, 3) + 4; - if(it_bit_buff->error) - return it_bit_buff->error; - - bit_size = impd_read_bits_buf(it_bit_buff, bit_size_len); - if(it_bit_buff->error) - return it_bit_buff->error; - str_parametric_drc_instructions->len_bit_size = bit_size + 1; - - switch(str_parametric_drc_instructions->parametric_drc_type) - { - - default: - str_parametric_drc_instructions->disable_paramteric_drc = 1; - for(i = 0; ilen_bit_size; i++) - { - other_bit = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - } - break; - } - } - } - - return 0; + if (str_parametric_drc_instructions->parametric_drc_preset_id_present) + { + str_parametric_drc_instructions->parametric_drc_preset_id = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + + switch (str_parametric_drc_instructions->parametric_drc_preset_id) + { + case 0: + case 1: + case 2: + case 3: + case 4: + str_parametric_drc_instructions->drc_characteristic = str_parametric_drc_instructions->parametric_drc_preset_id + 7; + str_parametric_drc_instructions->parametric_drc_type = PARAM_DRC_TYPE_FF; + + str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.level_estim_k_weighting_type = 2; + str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.level_estim_integration_time = parametric_drc_frame_size; + + impd_parametric_drc_ffwd_init_drc_curve_params(str_parametric_drc_instructions->drc_characteristic, &str_parametric_drc_instructions->str_parametric_drc_type_feed_forward); + impd_parametric_drc_ffwd_init_drc_gain_smooth_params(str_parametric_drc_instructions->drc_characteristic, &str_parametric_drc_instructions->str_parametric_drc_type_feed_forward); + + break; + default: + str_parametric_drc_instructions->disable_paramteric_drc = 1; + break; + } + } + else + { + str_parametric_drc_instructions->parametric_drc_type = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_FF) + { + err = impd_parse_parametric_drc_ffwd(it_bit_buff, parametric_drc_frame_size, &(str_parametric_drc_instructions->str_parametric_drc_type_feed_forward)); + if (err) return (err); + str_parametric_drc_instructions->disable_paramteric_drc = str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.disable_paramteric_drc; + str_parametric_drc_instructions->drc_characteristic = str_parametric_drc_instructions->str_parametric_drc_type_feed_forward.drc_characteristic; + } + else if (str_parametric_drc_instructions->parametric_drc_type == PARAM_DRC_TYPE_LIM) + { + err = impd_parse_parametric_drc_lim(it_bit_buff, &(str_parametric_drc_instructions->parametric_drc_lim)); + if (err) return (err); + str_parametric_drc_instructions->disable_paramteric_drc = str_parametric_drc_instructions->parametric_drc_lim.disable_paramteric_drc; + str_parametric_drc_instructions->drc_characteristic = str_parametric_drc_instructions->parametric_drc_lim.drc_characteristic; + if (str_parametric_drc_instructions->parametric_drc_look_ahead_flag) + { + str_parametric_drc_instructions->parametric_drc_lim.parametric_lim_attack = str_parametric_drc_instructions->parametric_drc_look_ahead; + } + } + else + { + bit_size_len = impd_read_bits_buf(it_bit_buff, 3) + 4; + if(it_bit_buff->error) + return it_bit_buff->error; + + bit_size = impd_read_bits_buf(it_bit_buff, bit_size_len); + if(it_bit_buff->error) + return it_bit_buff->error; + str_parametric_drc_instructions->len_bit_size = bit_size + 1; + + switch(str_parametric_drc_instructions->parametric_drc_type) + { + + default: + str_parametric_drc_instructions->disable_paramteric_drc = 1; + for(i = 0; ilen_bit_size; i++) + { + other_bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + break; + } + } + } + + return 0; } -WORD32 impd_parse_loud_info_set_ext_eq(ia_bit_buf_struct* it_bit_buff, +WORD32 impd_parse_loud_info_set_ext_eq(ia_bit_buf_struct* it_bit_buff, ia_drc_loudness_info_set_struct* loudness_info_set) { WORD32 err, i, offset, version = 1, temp; WORD32 loudness_info_v1_album_cnt, loudness_info_v1_cnt; - - temp = impd_read_bits_buf(it_bit_buff, 12); - if(it_bit_buff->error) - return it_bit_buff->error; - - loudness_info_v1_album_cnt = (temp>>6)&0x3f; - loudness_info_v1_cnt = temp&0x3f; + + temp = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; + + loudness_info_v1_album_cnt = (temp>>6)&0x3f; + loudness_info_v1_cnt = temp&0x3f; offset = loudness_info_set->loudness_info_album_count; loudness_info_set->loudness_info_album_count += loudness_info_v1_album_cnt; - for (i=0; istr_loudness_info_album[i + offset]); if (err) return(err); } offset = loudness_info_set->loudness_info_count; loudness_info_set->loudness_info_count += loudness_info_v1_cnt; - for (i=0; iloudness_info[i + offset]); if (err) return(err); } @@ -676,149 +676,149 @@ WORD32 impd_parse_loud_info_set_ext_eq(ia_bit_buf_struct* it_bit_buff, } WORD32 impd_parse_ch_layout(ia_bit_buf_struct* it_bit_buff, - ia_drc_params_bs_dec_struct* ia_drc_params_struct, - ia_channel_layout_struct* channel_layout) + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_channel_layout_struct* channel_layout) { //WORD32 err = 0; - WORD32 i; - - channel_layout->base_channel_count = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - if (ia_drc_params_struct->lfe_channel_map_count != -1 && channel_layout->base_channel_count != ia_drc_params_struct->lfe_channel_map_count) - { - return (UNEXPECTED_ERROR); - } - channel_layout->layout_signaling_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (channel_layout->layout_signaling_present) - { - channel_layout->defined_layout = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (channel_layout->defined_layout == 0) - { - for (i=0; ibase_channel_count; i++) - { - channel_layout->speaker_position[i] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - if (channel_layout->speaker_position[i] == 3 || channel_layout->speaker_position[i] == 26) { - ia_drc_params_struct->lfe_channel_map[i] = 1; - } - else - { - ia_drc_params_struct->lfe_channel_map[i] = 0; - } - } - } - } - - return(0); + WORD32 i; + + channel_layout->base_channel_count = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + if (ia_drc_params_struct->lfe_channel_map_count != -1 && channel_layout->base_channel_count != ia_drc_params_struct->lfe_channel_map_count) + { + return (UNEXPECTED_ERROR); + } + channel_layout->layout_signaling_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (channel_layout->layout_signaling_present) + { + channel_layout->defined_layout = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (channel_layout->defined_layout == 0) + { + for (i=0; ibase_channel_count; i++) + { + channel_layout->speaker_position[i] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + if (channel_layout->speaker_position[i] == 3 || channel_layout->speaker_position[i] == 26) { + ia_drc_params_struct->lfe_channel_map[i] = 1; + } + else + { + ia_drc_params_struct->lfe_channel_map[i] = 0; + } + } + } + } + + return(0); } WORD32 impd_parse_dwnmix_instructions(ia_bit_buf_struct* it_bit_buff, - WORD32 version, - ia_drc_params_bs_dec_struct* ia_drc_params_struct, - ia_channel_layout_struct* channel_layout, - ia_downmix_instructions_struct* dwnmix_instructions) + WORD32 version, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_channel_layout_struct* channel_layout, + ia_downmix_instructions_struct* dwnmix_instructions) { - //WORD32 err = 0; - WORD32 i, j, k, temp; + //WORD32 err = 0; + WORD32 i, j, k, temp; - temp = impd_read_bits_buf(it_bit_buff, 23); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 23); + if(it_bit_buff->error) + return it_bit_buff->error; - dwnmix_instructions->downmix_id = (temp>>16)&0x7f; - dwnmix_instructions->target_channel_count = (temp>>9)&0x7f; - dwnmix_instructions->target_layout = (temp>>1)&0xff; - dwnmix_instructions->downmix_coefficients_present = temp&1; - - if (dwnmix_instructions->downmix_coefficients_present) - { - if (version == 0) - { - WORD32 dmix_coeff; - k=0; - for (i=0; itarget_channel_count; i++) - { - for (j=0; jbase_channel_count; j++) - { - dmix_coeff = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (ia_drc_params_struct->lfe_channel_map[j]) - { - dwnmix_instructions->downmix_coefficient[k] = (FLOAT32)pow(10.0f, 0.05f * dwnmix_coeff_lfe[dmix_coeff]); - } - else - { - dwnmix_instructions->downmix_coefficient[k] = (FLOAT32)pow(10.0f, 0.05f * dwnmix_coeff[dmix_coeff]); - } - k++; - } - } - } - else - { - WORD32 dmix_coeff_v1, bs_dmix_offset; - FLOAT32 a, b, dmix_offset, sum; - - bs_dmix_offset = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - k=0; - for (i=0; itarget_channel_count; i++) - { - for (j=0; jbase_channel_count; j++) - { - dmix_coeff_v1 = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - dwnmix_instructions->downmix_coefficient[k] = dwnmix_coeff_v1[dmix_coeff_v1]; - k++; - } - } - switch (bs_dmix_offset) - { - case 0: - dmix_offset = 0.0f; - break; - case 1: - a = 20.0f * (FLOAT32)log10((FLOAT32) dwnmix_instructions->target_channel_count / (FLOAT32)channel_layout->base_channel_count); - dmix_offset = 0.5f *(FLOAT32) floor(0.5f + a); - break; - case 2: - a = 20.0f *(FLOAT32) log10((FLOAT32) dwnmix_instructions->target_channel_count / (FLOAT32)channel_layout->base_channel_count); - dmix_offset = 0.5f *(FLOAT32) floor(0.5f + 2.0f * a); - break; - case 3: - sum = 0.0f; - for (k=0; ktarget_channel_count * channel_layout->base_channel_count; k++) - { - sum += (FLOAT32)pow(10.0f, 0.1f * dwnmix_instructions->downmix_coefficient[k]); - } - b = 10.0f * (FLOAT32)log10(sum); - dmix_offset = 0.5f * (FLOAT32)floor(0.5f + 2.0f * b); - break; - - default: - return (BITSTREAM_ERROR); - break; - } - for (k=0; ktarget_channel_count * channel_layout->base_channel_count; k++) - { - dwnmix_instructions->downmix_coefficient[k] = (FLOAT32)pow(10.0f, 0.05f * (dwnmix_instructions->downmix_coefficient[k] + dmix_offset)); - } - } - } - return(0); + dwnmix_instructions->downmix_id = (temp>>16)&0x7f; + dwnmix_instructions->target_channel_count = (temp>>9)&0x7f; + dwnmix_instructions->target_layout = (temp>>1)&0xff; + dwnmix_instructions->downmix_coefficients_present = temp&1; + + if (dwnmix_instructions->downmix_coefficients_present) + { + if (version == 0) + { + WORD32 dmix_coeff; + k=0; + for (i=0; itarget_channel_count; i++) + { + for (j=0; jbase_channel_count; j++) + { + dmix_coeff = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (ia_drc_params_struct->lfe_channel_map[j]) + { + dwnmix_instructions->downmix_coefficient[k] = (FLOAT32)pow(10.0f, 0.05f * dwnmix_coeff_lfe[dmix_coeff]); + } + else + { + dwnmix_instructions->downmix_coefficient[k] = (FLOAT32)pow(10.0f, 0.05f * dwnmix_coeff[dmix_coeff]); + } + k++; + } + } + } + else + { + WORD32 dmix_coeff_v1, bs_dmix_offset; + FLOAT32 a, b, dmix_offset, sum; + + bs_dmix_offset = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + k=0; + for (i=0; itarget_channel_count; i++) + { + for (j=0; jbase_channel_count; j++) + { + dmix_coeff_v1 = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + dwnmix_instructions->downmix_coefficient[k] = dwnmix_coeff_v1[dmix_coeff_v1]; + k++; + } + } + switch (bs_dmix_offset) + { + case 0: + dmix_offset = 0.0f; + break; + case 1: + a = 20.0f * (FLOAT32)log10((FLOAT32) dwnmix_instructions->target_channel_count / (FLOAT32)channel_layout->base_channel_count); + dmix_offset = 0.5f *(FLOAT32) floor(0.5f + a); + break; + case 2: + a = 20.0f *(FLOAT32) log10((FLOAT32) dwnmix_instructions->target_channel_count / (FLOAT32)channel_layout->base_channel_count); + dmix_offset = 0.5f *(FLOAT32) floor(0.5f + 2.0f * a); + break; + case 3: + sum = 0.0f; + for (k=0; ktarget_channel_count * channel_layout->base_channel_count; k++) + { + sum += (FLOAT32)pow(10.0f, 0.1f * dwnmix_instructions->downmix_coefficient[k]); + } + b = 10.0f * (FLOAT32)log10(sum); + dmix_offset = 0.5f * (FLOAT32)floor(0.5f + 2.0f * b); + break; + + default: + return (BITSTREAM_ERROR); + break; + } + for (k=0; ktarget_channel_count * channel_layout->base_channel_count; k++) + { + dwnmix_instructions->downmix_coefficient[k] = (FLOAT32)pow(10.0f, 0.05f * (dwnmix_instructions->downmix_coefficient[k] + dmix_offset)); + } + } + } + return(0); } VOID impd_drc_gen_instructions_for_drc_off(ia_drc_config* drc_config) @@ -827,14 +827,14 @@ VOID impd_drc_gen_instructions_for_drc_off(ia_drc_config* drc_config) ia_drc_instructions_struct* str_drc_instruction_str; s = -1; - + k = drc_config->drc_instructions_uni_drc_count; - + str_drc_instruction_str = &(drc_config->str_drc_instruction_str[k]); memset(str_drc_instruction_str, 0, sizeof(ia_drc_instructions_struct)); - str_drc_instruction_str->drc_set_id = s; + str_drc_instruction_str->drc_set_id = s; s--; - str_drc_instruction_str->downmix_id[0] = ID_FOR_BASE_LAYOUT; + str_drc_instruction_str->downmix_id[0] = ID_FOR_BASE_LAYOUT; str_drc_instruction_str->dwnmix_id_count = 1; str_drc_instruction_str->drc_apply_to_dwnmix = 0; str_drc_instruction_str->depends_on_drc_set_present = 0; @@ -844,7 +844,7 @@ VOID impd_drc_gen_instructions_for_drc_off(ia_drc_config* drc_config) { str_drc_instruction_str = &(drc_config->str_drc_instruction_str[k+i]); memset(str_drc_instruction_str, 0, sizeof(ia_drc_instructions_struct)); - str_drc_instruction_str->drc_set_id = s; + str_drc_instruction_str->drc_set_id = s; s--; str_drc_instruction_str->drc_set_complexity_level = 0; str_drc_instruction_str->requires_eq = 0; @@ -861,150 +861,150 @@ VOID impd_drc_gen_instructions_for_drc_off(ia_drc_config* drc_config) WORD32 impd_parse_drc_config_ext(ia_bit_buf_struct* it_bit_buff, - ia_drc_params_bs_dec_struct* ia_drc_params_struct, - ia_drc_config* drc_config, - ia_drc_config_ext* str_drc_config_ext) + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_config* drc_config, + ia_drc_config_ext* str_drc_config_ext) { WORD32 err = 0, i, k; WORD32 bit_size_len, ext_size_bits, bit_size, other_bit; - + k = 0; - str_drc_config_ext->drc_config_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - while(str_drc_config_ext->drc_config_ext_type[k] != UNIDRCCONFEXT_TERM) - { - bit_size_len = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - ext_size_bits = bit_size_len + 4; - - bit_size = impd_read_bits_buf(it_bit_buff, ext_size_bits); - if(it_bit_buff->error) - return it_bit_buff->error; - str_drc_config_ext->ext_bit_size[k] = bit_size + 1; - - switch(str_drc_config_ext->drc_config_ext_type[k]) - { - case UNIDRCCONFEXT_PARAM_DRC: - str_drc_config_ext->parametric_drc_present = 1; - err = impd_parametic_drc_parse_coeff(it_bit_buff, drc_config, &(str_drc_config_ext->str_drc_coeff_param_drc)); - if (err) return(err); - str_drc_config_ext->parametric_drc_instructions_count = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - for (i=0; iparametric_drc_instructions_count; i++) - { - err = impd_parse_parametric_drc_instructions(it_bit_buff, str_drc_config_ext->str_drc_coeff_param_drc.parametric_drc_frame_size, &(str_drc_config_ext->str_parametric_drc_instructions[i])); - if (err) return (err); - } - break; - case UNIDRCCONFEXT_V1: - str_drc_config_ext->drc_extension_v1_present = 1; - err = impd_parse_drc_ext_v1( it_bit_buff, ia_drc_params_struct, drc_config, str_drc_config_ext); - if (err) return(err); - break; - default: - for(i = 0; iext_bit_size[k]; i++) - { - other_bit = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - } - break; - } - k++; - str_drc_config_ext->drc_config_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - } - - return (0); + str_drc_config_ext->drc_config_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + while(str_drc_config_ext->drc_config_ext_type[k] != UNIDRCCONFEXT_TERM) + { + bit_size_len = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + ext_size_bits = bit_size_len + 4; + + bit_size = impd_read_bits_buf(it_bit_buff, ext_size_bits); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_config_ext->ext_bit_size[k] = bit_size + 1; + + switch(str_drc_config_ext->drc_config_ext_type[k]) + { + case UNIDRCCONFEXT_PARAM_DRC: + str_drc_config_ext->parametric_drc_present = 1; + err = impd_parametic_drc_parse_coeff(it_bit_buff, drc_config, &(str_drc_config_ext->str_drc_coeff_param_drc)); + if (err) return(err); + str_drc_config_ext->parametric_drc_instructions_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=0; iparametric_drc_instructions_count; i++) + { + err = impd_parse_parametric_drc_instructions(it_bit_buff, str_drc_config_ext->str_drc_coeff_param_drc.parametric_drc_frame_size, &(str_drc_config_ext->str_parametric_drc_instructions[i])); + if (err) return (err); + } + break; + case UNIDRCCONFEXT_V1: + str_drc_config_ext->drc_extension_v1_present = 1; + err = impd_parse_drc_ext_v1( it_bit_buff, ia_drc_params_struct, drc_config, str_drc_config_ext); + if (err) return(err); + break; + default: + for(i = 0; iext_bit_size[k]; i++) + { + other_bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + break; + } + k++; + str_drc_config_ext->drc_config_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + + return (0); } static WORD32 impd_parse_split_drc_characteristic(ia_bit_buf_struct* it_bit_buff, const WORD32 side, ia_split_drc_characteristic_struct* split_drc_characteristic) { - //WORD32 err = 0; - WORD32 i, temp; - - split_drc_characteristic->characteristic_format = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (split_drc_characteristic->characteristic_format == 0) - { - WORD32 bsGain, bsIoRatio, bsExp; - bsGain = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - if (side == LEFT_SIDE) - { - split_drc_characteristic->gain = (FLOAT32)bsGain; - } - else - { - split_drc_characteristic->gain = (FLOAT32)- bsGain; - } - temp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + //WORD32 err = 0; + WORD32 i, temp; - bsIoRatio = (temp>>4)&0xf; - bsExp = temp&0xf; - split_drc_characteristic->in_out_ratio = 0.05f + 0.15f * bsIoRatio; + split_drc_characteristic->characteristic_format = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (split_drc_characteristic->characteristic_format == 0) + { + WORD32 bsGain, bsIoRatio, bsExp; + bsGain = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + if (side == LEFT_SIDE) + { + split_drc_characteristic->gain = (FLOAT32)bsGain; + } + else + { + split_drc_characteristic->gain = (FLOAT32)- bsGain; + } + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - if (bsExp<15) - { - split_drc_characteristic->exp = 1.0f + 2.0f * bsExp; - } - else - { - split_drc_characteristic->exp = 1000.0f; - } - split_drc_characteristic->flip_sign = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - } - else - { - WORD32 char_node_cnt, node_level_delta, node_gain; - char_node_cnt = impd_read_bits_buf(it_bit_buff, 2); - if(it_bit_buff->error) - return it_bit_buff->error; - split_drc_characteristic->characteristic_node_count = char_node_cnt + 1; - split_drc_characteristic->node_level[0] = DRC_INPUT_LOUDNESS_TARGET; - split_drc_characteristic->node_gain[0] = 0.0f; - for (i=1; i<=split_drc_characteristic->characteristic_node_count; i++) - { - node_level_delta = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - if (side == LEFT_SIDE) - { - split_drc_characteristic->node_level[i] = split_drc_characteristic->node_level[i-1] - (1.0f + node_level_delta); - } - else - { - split_drc_characteristic->node_level[i] = split_drc_characteristic->node_level[i-1] + (1.0f + node_level_delta); - } - node_gain = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - split_drc_characteristic->node_gain[i] = 0.5f * node_gain - 64.0f; - } - } - return(0); + bsIoRatio = (temp>>4)&0xf; + bsExp = temp&0xf; + split_drc_characteristic->in_out_ratio = 0.05f + 0.15f * bsIoRatio; + + if (bsExp<15) + { + split_drc_characteristic->exp = 1.0f + 2.0f * bsExp; + } + else + { + split_drc_characteristic->exp = 1000.0f; + } + split_drc_characteristic->flip_sign = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + WORD32 char_node_cnt, node_level_delta, node_gain; + char_node_cnt = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; + split_drc_characteristic->characteristic_node_count = char_node_cnt + 1; + split_drc_characteristic->node_level[0] = DRC_INPUT_LOUDNESS_TARGET; + split_drc_characteristic->node_gain[0] = 0.0f; + for (i=1; i<=split_drc_characteristic->characteristic_node_count; i++) + { + node_level_delta = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + if (side == LEFT_SIDE) + { + split_drc_characteristic->node_level[i] = split_drc_characteristic->node_level[i-1] - (1.0f + node_level_delta); + } + else + { + split_drc_characteristic->node_level[i] = split_drc_characteristic->node_level[i-1] + (1.0f + node_level_delta); + } + node_gain = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + split_drc_characteristic->node_gain[i] = 0.5f * node_gain - 64.0f; + } + } + return(0); } WORD32 impd_drc_gen_instructions_derived_data(ia_drc_config* drc_config, - ia_drc_params_bs_dec_struct* ia_drc_params_struct, - ia_drc_instructions_struct* str_drc_instruction_str) + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_instructions_struct* str_drc_instruction_str) { WORD32 n, g; ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc = NULL; ia_drc_coeff_parametric_drc_struct* str_drc_coeff_param_drc = NULL; WORD32 gain_element_count = 0; - + for(n=0; ndrc_coefficients_drc_count; n++) { if (drc_config->str_p_loc_drc_coefficients_uni_drc[n].drc_location == str_drc_instruction_str->drc_location) break; @@ -1016,28 +1016,28 @@ impd_drc_gen_instructions_derived_data(ia_drc_config* drc_config, return -1; } str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[n]); - + if (drc_config->drc_config_ext_present && drc_config->str_drc_config_ext.parametric_drc_present && - drc_config->str_drc_config_ext.str_drc_coeff_param_drc.drc_location == str_drc_instruction_str->drc_location) - { + drc_config->str_drc_config_ext.str_drc_coeff_param_drc.drc_location == str_drc_instruction_str->drc_location) + { str_drc_coeff_param_drc = &drc_config->str_drc_config_ext.str_drc_coeff_param_drc; } - + for (g=0; gnum_drc_ch_groups; g++) { WORD32 seq = str_drc_instruction_str->gain_set_index_for_channel_group[g]; - if (seq != -1 && (drc_config->drc_coefficients_drc_count == 0 || seq >= str_p_loc_drc_coefficients_uni_drc->gain_set_count)) - { + if (seq != -1 && (drc_config->drc_coefficients_drc_count == 0 || seq >= str_p_loc_drc_coefficients_uni_drc->gain_set_count)) + { str_drc_instruction_str->ch_group_parametric_drc_flag[g] = 1; - if (drc_config->drc_coefficients_drc_count != 0) - { + if (drc_config->drc_coefficients_drc_count != 0) + { seq = seq - str_p_loc_drc_coefficients_uni_drc->gain_set_count; } str_drc_instruction_str->gain_set_idx_of_ch_group_parametric_drc[g] = seq; - - if (str_drc_coeff_param_drc == NULL || seq>=str_drc_coeff_param_drc->parametric_drc_gain_set_count) - { - /* parametric drc gain set not available */ + + if (str_drc_coeff_param_drc == NULL || seq>=str_drc_coeff_param_drc->parametric_drc_gain_set_count) + { + /* parametric drc gain set not available */ return(EXTERNAL_ERROR); } str_drc_instruction_str->gain_interpolation_type_for_channel_group[g] = 1; @@ -1062,13 +1062,13 @@ impd_drc_gen_instructions_derived_data(ia_drc_config* drc_config, str_drc_instruction_str->time_alignment_for_channel_group[g] = str_p_loc_drc_coefficients_uni_drc->gain_set_params[seq].time_alignment; } } - + if (str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) { - str_drc_instruction_str->gain_element_count = str_drc_instruction_str->num_drc_ch_groups; - } - else - { + str_drc_instruction_str->gain_element_count = str_drc_instruction_str->num_drc_ch_groups; + } + else + { for (g=0; gnum_drc_ch_groups; g++) { if (str_drc_instruction_str->ch_group_parametric_drc_flag[g] == 1) @@ -1087,176 +1087,176 @@ impd_drc_gen_instructions_derived_data(ia_drc_config* drc_config, } str_drc_instruction_str->gain_element_count = gain_element_count; } - + return(0); } WORD32 impd_parse_drc_config(ia_bit_buf_struct* it_bit_buff, - ia_drc_params_bs_dec_struct* ia_drc_params_struct, - ia_drc_config* drc_config - ) + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_drc_config* drc_config + ) { WORD32 i, err = 0, temp; - WORD32 version = 0; - - drc_config->sample_rate_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if(drc_config->sample_rate_present == 1) - { - WORD32 bssample_rate; - bssample_rate = impd_read_bits_buf(it_bit_buff, 18); - if(it_bit_buff->error) - return it_bit_buff->error; - drc_config->sampling_rate = bssample_rate + 1000; - } + WORD32 version = 0; - temp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + drc_config->sample_rate_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; - drc_config->dwnmix_instructions_count = (temp>>1)&0x7f; - drc_config->drc_description_basic_present = temp&1; + if(drc_config->sample_rate_present == 1) + { + WORD32 bssample_rate; + bssample_rate = impd_read_bits_buf(it_bit_buff, 18); + if(it_bit_buff->error) + return it_bit_buff->error; + drc_config->sampling_rate = bssample_rate + 1000; + } - if (drc_config->drc_description_basic_present == 1) - { - temp = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - drc_config->drc_coefficients_basic_count = (temp>>4)&7; - drc_config->drc_instructions_basic_count = temp&0xf; - - } - else - { - drc_config->drc_coefficients_basic_count = 0; - drc_config->drc_instructions_basic_count = 0; - } + drc_config->dwnmix_instructions_count = (temp>>1)&0x7f; + drc_config->drc_description_basic_present = temp&1; - temp = impd_read_bits_buf(it_bit_buff, 9); - if(it_bit_buff->error) - return it_bit_buff->error; + if (drc_config->drc_description_basic_present == 1) + { + temp = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; - drc_config->drc_coefficients_drc_count = (temp>>6)&7; - drc_config->drc_instructions_uni_drc_count = temp&0x3f; + drc_config->drc_coefficients_basic_count = (temp>>4)&7; + drc_config->drc_instructions_basic_count = temp&0xf; - err = impd_parse_ch_layout(it_bit_buff, ia_drc_params_struct, &drc_config->channel_layout); - if (err) return(err); - - for(i=0; idwnmix_instructions_count; i++) - { - err = impd_parse_dwnmix_instructions(it_bit_buff, version, ia_drc_params_struct, &drc_config->channel_layout, &(drc_config->dwnmix_instructions[i])); - if (err) return(err); - } - for(i=0; idrc_coefficients_basic_count ; i++) - { - temp = impd_read_bits_buf(it_bit_buff, 11); - if(it_bit_buff->error) - return it_bit_buff->error; + } + else + { + drc_config->drc_coefficients_basic_count = 0; + drc_config->drc_instructions_basic_count = 0; + } - drc_config->str_drc_coefficients_basic[i].drc_location = (temp>>7)&0xf; - drc_config->str_drc_coefficients_basic[i].drc_characteristic = temp&0x3f; + temp = impd_read_bits_buf(it_bit_buff, 9); + if(it_bit_buff->error) + return it_bit_buff->error; - } - for(i=0; idrc_instructions_basic_count; i++) - { - err = impd_drc_parse_instructions_basic(it_bit_buff, &(drc_config->str_drc_instructions_basic[i])); - if (err) return(err); - } - for(i=0; idrc_coefficients_drc_count; i++) - { - err = impd_drc_parse_coeff(it_bit_buff, version, ia_drc_params_struct, &(drc_config->str_p_loc_drc_coefficients_uni_drc[i])); - if (err) return(err); - } - for(i=0; idrc_instructions_uni_drc_count; i++) - { - err = impd_parse_drc_instructions_uni_drc(it_bit_buff, version, drc_config, &(drc_config->str_drc_instruction_str[i])); - if (err) return(err); - } - - drc_config->drc_config_ext_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (drc_config->drc_config_ext_present == 1) - { - err = impd_parse_drc_config_ext( it_bit_buff, ia_drc_params_struct, drc_config, &(drc_config->str_drc_config_ext)); - if (err) return(err); - } - - if ( drc_config->str_drc_config_ext.parametric_drc_present ) - { - err = impd_parametric_drc_gen_virtual_gain_sets(drc_config); - if (err) return(err); - } - - for(i=0; idrc_instructions_uni_drc_count; i++) - { - err = impd_drc_gen_instructions_derived_data(drc_config, ia_drc_params_struct, &(drc_config->str_drc_instruction_str[i])); - if (err) return(err); - } - - impd_drc_gen_instructions_for_drc_off(drc_config); - return(0); + drc_config->drc_coefficients_drc_count = (temp>>6)&7; + drc_config->drc_instructions_uni_drc_count = temp&0x3f; + + err = impd_parse_ch_layout(it_bit_buff, ia_drc_params_struct, &drc_config->channel_layout); + if (err) return(err); + + for(i=0; idwnmix_instructions_count; i++) + { + err = impd_parse_dwnmix_instructions(it_bit_buff, version, ia_drc_params_struct, &drc_config->channel_layout, &(drc_config->dwnmix_instructions[i])); + if (err) return(err); + } + for(i=0; idrc_coefficients_basic_count ; i++) + { + temp = impd_read_bits_buf(it_bit_buff, 11); + if(it_bit_buff->error) + return it_bit_buff->error; + + drc_config->str_drc_coefficients_basic[i].drc_location = (temp>>7)&0xf; + drc_config->str_drc_coefficients_basic[i].drc_characteristic = temp&0x3f; + + } + for(i=0; idrc_instructions_basic_count; i++) + { + err = impd_drc_parse_instructions_basic(it_bit_buff, &(drc_config->str_drc_instructions_basic[i])); + if (err) return(err); + } + for(i=0; idrc_coefficients_drc_count; i++) + { + err = impd_drc_parse_coeff(it_bit_buff, version, ia_drc_params_struct, &(drc_config->str_p_loc_drc_coefficients_uni_drc[i])); + if (err) return(err); + } + for(i=0; idrc_instructions_uni_drc_count; i++) + { + err = impd_parse_drc_instructions_uni_drc(it_bit_buff, version, drc_config, &(drc_config->str_drc_instruction_str[i])); + if (err) return(err); + } + + drc_config->drc_config_ext_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (drc_config->drc_config_ext_present == 1) + { + err = impd_parse_drc_config_ext( it_bit_buff, ia_drc_params_struct, drc_config, &(drc_config->str_drc_config_ext)); + if (err) return(err); + } + + if ( drc_config->str_drc_config_ext.parametric_drc_present ) + { + err = impd_parametric_drc_gen_virtual_gain_sets(drc_config); + if (err) return(err); + } + + for(i=0; idrc_instructions_uni_drc_count; i++) + { + err = impd_drc_gen_instructions_derived_data(drc_config, ia_drc_params_struct, &(drc_config->str_drc_instruction_str[i])); + if (err) return(err); + } + + impd_drc_gen_instructions_for_drc_off(drc_config); + return(0); } WORD32 impd_dec_method_value(ia_bit_buf_struct* it_bit_buff, - WORD32 method_def, - FLOAT32* method_val) + WORD32 method_def, + FLOAT32* method_val) { //WORD32 err = 0; - WORD32 tmp; + WORD32 tmp; FLOAT32 val; switch (method_def) { - case METHOD_DEFINITION_UNKNOWN_OTHER: - case METHOD_DEFINITION_PROGRAM_LOUDNESS: - case METHOD_DEFINITION_ANCHOR_LOUDNESS: - case METHOD_DEFINITION_MAX_OF_LOUDNESS_RANGE: - case METHOD_DEFINITION_MOMENTARY_LOUDNESS_MAX: - case METHOD_DEFINITION_SHORT_TERM_LOUDNESS_MAX: - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - val = -57.75f + tmp * 0.25f; - break; - case METHOD_DEFINITION_LOUDNESS_RANGE: - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - if (tmp == 0) - val = 0.0f; - else if(tmp <= 128) - val = tmp * 0.25f; - else if(tmp <= 204) - val = 0.5f * tmp - 32.0f; - else - val = tmp - 134.0f; - break; - case METHOD_DEFINITION_MIXING_LEVEL: - tmp = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - val = tmp + 80.0f; - break; - case METHOD_DEFINITION_ROOM_TYPE: - tmp = impd_read_bits_buf(it_bit_buff, 2); - if(it_bit_buff->error) - return it_bit_buff->error; - val = (FLOAT32)tmp; - break; - case METHOD_DEFINITION_SHORT_TERM_LOUDNESS: - tmp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - val = -116.f + tmp * 0.5f; - break; - default: - return -1; - break; + case METHOD_DEFINITION_UNKNOWN_OTHER: + case METHOD_DEFINITION_PROGRAM_LOUDNESS: + case METHOD_DEFINITION_ANCHOR_LOUDNESS: + case METHOD_DEFINITION_MAX_OF_LOUDNESS_RANGE: + case METHOD_DEFINITION_MOMENTARY_LOUDNESS_MAX: + case METHOD_DEFINITION_SHORT_TERM_LOUDNESS_MAX: + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + val = -57.75f + tmp * 0.25f; + break; + case METHOD_DEFINITION_LOUDNESS_RANGE: + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + if (tmp == 0) + val = 0.0f; + else if(tmp <= 128) + val = tmp * 0.25f; + else if(tmp <= 204) + val = 0.5f * tmp - 32.0f; + else + val = tmp - 134.0f; + break; + case METHOD_DEFINITION_MIXING_LEVEL: + tmp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + val = tmp + 80.0f; + break; + case METHOD_DEFINITION_ROOM_TYPE: + tmp = impd_read_bits_buf(it_bit_buff, 2); + if(it_bit_buff->error) + return it_bit_buff->error; + val = (FLOAT32)tmp; + break; + case METHOD_DEFINITION_SHORT_TERM_LOUDNESS: + tmp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + val = -116.f + tmp * 0.5f; + break; + default: + return -1; + break; } *method_val = val; return 0; @@ -1265,92 +1265,92 @@ impd_dec_method_value(ia_bit_buf_struct* it_bit_buff, WORD32 impd_parse_loudness_info_set(ia_bit_buf_struct* it_bit_buff, - ia_drc_loudness_info_set_struct* loudness_info_set) + ia_drc_loudness_info_set_struct* loudness_info_set) { WORD32 err = 0, i, version = 0, offset, temp; WORD32 loudness_info_album_count, loudness_info_count; - - temp = impd_read_bits_buf(it_bit_buff, 12); - if(it_bit_buff->error) - return it_bit_buff->error; - loudness_info_album_count = (temp>>6)&0x3f; - loudness_info_count = temp&0x3f; + temp = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; - offset = loudness_info_set->loudness_info_album_count; - loudness_info_set->loudness_info_album_count += loudness_info_album_count; - for (i = 0; i< loudness_info_set->loudness_info_album_count; i++) - { - err = impd_parse_loudness_info(it_bit_buff, version, &(loudness_info_set->str_loudness_info_album[i+offset])); - if (err) return(err); - } - - offset = loudness_info_set->loudness_info_count; - loudness_info_set->loudness_info_count += loudness_info_count; - for (i = 0; iloudness_info_count; i++) - { - err = impd_parse_loudness_info(it_bit_buff, version, &(loudness_info_set->loudness_info[i+offset])); - if (err) return(err); - } - - loudness_info_set->loudness_info_set_ext_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if ( loudness_info_set->loudness_info_set_ext_present == 1) - { - err = impd_parse_loudness_info_set_ext(it_bit_buff, loudness_info_set); - if (err) return(err); - } - - return (0); + loudness_info_album_count = (temp>>6)&0x3f; + loudness_info_count = temp&0x3f; + + offset = loudness_info_set->loudness_info_album_count; + loudness_info_set->loudness_info_album_count += loudness_info_album_count; + for (i = 0; i< loudness_info_set->loudness_info_album_count; i++) + { + err = impd_parse_loudness_info(it_bit_buff, version, &(loudness_info_set->str_loudness_info_album[i+offset])); + if (err) return(err); + } + + offset = loudness_info_set->loudness_info_count; + loudness_info_set->loudness_info_count += loudness_info_count; + for (i = 0; iloudness_info_count; i++) + { + err = impd_parse_loudness_info(it_bit_buff, version, &(loudness_info_set->loudness_info[i+offset])); + if (err) return(err); + } + + loudness_info_set->loudness_info_set_ext_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if ( loudness_info_set->loudness_info_set_ext_present == 1) + { + err = impd_parse_loudness_info_set_ext(it_bit_buff, loudness_info_set); + if (err) return(err); + } + + return (0); } WORD32 impd_parse_gain_set_params_characteristics(ia_bit_buf_struct* it_bit_buff, - WORD32 version, - ia_gain_params_struct* gain_params) + WORD32 version, + ia_gain_params_struct* gain_params) { //WORD32 err = 0; - WORD32 temp; - if (version == 0) - { - gain_params->drc_characteristic = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - if (gain_params->drc_characteristic > 0) - { + WORD32 temp; + if (version == 0) + { + gain_params->drc_characteristic = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + if (gain_params->drc_characteristic > 0) + { gain_params->drc_characteristic_present = 1; gain_params->drc_characteristic_format_is_cicp = 1; } - else - { + else + { gain_params->drc_characteristic_present = 0; } } else { - gain_params->drc_characteristic_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (gain_params->drc_characteristic_present) - { - gain_params->drc_characteristic_format_is_cicp = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (gain_params->drc_characteristic_format_is_cicp) - { - gain_params->drc_characteristic = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; + gain_params->drc_characteristic_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (gain_params->drc_characteristic_present) + { + gain_params->drc_characteristic_format_is_cicp = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (gain_params->drc_characteristic_format_is_cicp) + { + gain_params->drc_characteristic = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; } - else - { - temp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + else + { + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - gain_params->drc_characteristic_left_index = (temp>>4)&0xf; - gain_params->drc_characteristic_right_index = temp&0xf; + gain_params->drc_characteristic_left_index = (temp>>4)&0xf; + gain_params->drc_characteristic_right_index = temp&0xf; } } @@ -1360,83 +1360,83 @@ impd_parse_gain_set_params_characteristics(ia_bit_buf_struct* it_bit_buff, WORD32 impd_parse_loudness_measure(ia_bit_buf_struct* it_bit_buff, - ia_loudness_measure_struct* loudness_measure) + ia_loudness_measure_struct* loudness_measure) { WORD32 err = 0, temp; - - loudness_measure->method_def = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - err = impd_dec_method_value(it_bit_buff, loudness_measure->method_def, &(loudness_measure->method_val)); - if(err) return err; + loudness_measure->method_def = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; - temp = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + err = impd_dec_method_value(it_bit_buff, loudness_measure->method_def, &(loudness_measure->method_val)); + if(err) return err; - loudness_measure->measurement_system = (temp>>2)&0xf; - loudness_measure->reliability = temp&3; + temp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; - return (0); + loudness_measure->measurement_system = (temp>>2)&0xf; + loudness_measure->reliability = temp&3; + + return (0); } WORD32 impd_dec_gain_modifiers(ia_bit_buf_struct* it_bit_buff, - WORD32 version, - WORD32 band_count, - ia_gain_modifiers_struct* pstr_gain_modifiers) + WORD32 version, + WORD32 band_count, + ia_gain_modifiers_struct* pstr_gain_modifiers) { - + //WORD32 err = 0; - WORD32 sign, temp; - - if (version > 0) - { + WORD32 sign, temp; + + if (version > 0) + { WORD32 b; - for (b=0; btarget_characteristic_left_present[b] = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (pstr_gain_modifiers->target_characteristic_left_present[b]) - { - pstr_gain_modifiers->target_characteristic_left_index[b] = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; + for (b=0; btarget_characteristic_left_present[b] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_gain_modifiers->target_characteristic_left_present[b]) + { + pstr_gain_modifiers->target_characteristic_left_index[b] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; } - pstr_gain_modifiers->target_characteristic_right_present[b] = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (pstr_gain_modifiers->target_characteristic_right_present[b]) - { - pstr_gain_modifiers->target_characteristic_right_index[b] = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; + pstr_gain_modifiers->target_characteristic_right_present[b] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_gain_modifiers->target_characteristic_right_present[b]) + { + pstr_gain_modifiers->target_characteristic_right_index[b] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; } - pstr_gain_modifiers->gain_scaling_flag[b] = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (pstr_gain_modifiers->gain_scaling_flag[b]) - { - temp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + pstr_gain_modifiers->gain_scaling_flag[b] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_gain_modifiers->gain_scaling_flag[b]) + { + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; pstr_gain_modifiers->attn_scaling[b] = ((temp>>4)&0xf) * 0.125f; pstr_gain_modifiers->ampl_scaling[b] = (temp&0xf) * 0.125f; } - pstr_gain_modifiers->gain_offset_flag[b] = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + pstr_gain_modifiers->gain_offset_flag[b] = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (pstr_gain_modifiers->gain_offset_flag[b]) { FLOAT32 gain_offset; - temp = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; sign = ((temp>>5)&1); gain_offset = (1+(temp&0x1f)) * 0.25f; @@ -1448,16 +1448,16 @@ impd_dec_gain_modifiers(ia_bit_buf_struct* it_bit_buff, pstr_gain_modifiers->gain_offset[b] = gain_offset; } } - if (band_count == 1) - { - pstr_gain_modifiers->shape_filter_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (pstr_gain_modifiers->shape_filter_flag) - { - pstr_gain_modifiers->shape_filter_idx = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; + if (band_count == 1) + { + pstr_gain_modifiers->shape_filter_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_gain_modifiers->shape_filter_flag) + { + pstr_gain_modifiers->shape_filter_idx = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; } } } @@ -1465,30 +1465,30 @@ impd_dec_gain_modifiers(ia_bit_buf_struct* it_bit_buff, { WORD32 b, gain_scaling_flag, gain_offset_flag; FLOAT32 attn_scaling = 1.0f, ampl_scaling = 1.0f, gain_offset = 0.0f; - - gain_scaling_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + gain_scaling_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if(gain_scaling_flag) { - temp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; attn_scaling = ((temp>>4)&0xf) * 0.125f; ampl_scaling = (temp&0xf) * 0.125f; - + } - - gain_offset_flag = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + + gain_offset_flag = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if(gain_offset_flag) { - temp = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; sign = ((temp>>5)&1); gain_offset = (1+(temp&0x1f)) * 0.25f; @@ -1514,98 +1514,98 @@ impd_dec_gain_modifiers(ia_bit_buf_struct* it_bit_buff, WORD32 impd_parse_gain_set_params(ia_bit_buf_struct* it_bit_buff, - WORD32 version, - WORD32* gain_seq_idx, - ia_gain_set_params_struct* gain_set_params) + WORD32 version, + WORD32* gain_seq_idx, + ia_gain_set_params_struct* gain_set_params) { WORD32 err = 0, i, temp; - temp = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; - gain_set_params->gain_coding_profile = (temp>>4)&3; - gain_set_params->gain_interpolation_type = (temp>>3)&1; - gain_set_params->full_frame = (temp>>2)&1; - gain_set_params->time_alignment = (temp>>1)&1; - gain_set_params->time_delt_min_flag = temp&1; - - if(gain_set_params->time_delt_min_flag) - { - WORD32 time_delta_min; - time_delta_min = impd_read_bits_buf(it_bit_buff, 11); - if(it_bit_buff->error) - return it_bit_buff->error; - gain_set_params->time_delt_min_val = time_delta_min + 1; - } - - if (gain_set_params->gain_coding_profile == GAIN_CODING_PROFILE_CONSTANT) - { - gain_set_params->band_count = 1; - *gain_seq_idx = (*gain_seq_idx) + 1; - } - else - { - gain_set_params->band_count = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - - if(gain_set_params->band_count>1) - { - gain_set_params->drc_band_type = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - } - for(i=0; iband_count; i++) - { - if (version == 0) { - *gain_seq_idx = (*gain_seq_idx) + 1; - } - else - { - WORD32 indexPresent; - indexPresent = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (indexPresent) - { - WORD32 bsIndex; - bsIndex = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - *gain_seq_idx = bsIndex; - } - else - { - *gain_seq_idx = (*gain_seq_idx) + 1; - } - } - gain_set_params->gain_params[i].gain_seq_idx = *gain_seq_idx; - err = impd_parse_gain_set_params_characteristics(it_bit_buff, version, &(gain_set_params->gain_params[i])); - if (err) return(err); - } - if (gain_set_params->drc_band_type) - { - for(i=1; iband_count; i++) - { - gain_set_params->gain_params[i].crossover_freq_idx = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - } - } - else - { - for(i=1; iband_count; i++) - { - gain_set_params->gain_params[i].start_subband_index = impd_read_bits_buf(it_bit_buff, 10); - if(it_bit_buff->error) - return it_bit_buff->error; - } - } + gain_set_params->gain_coding_profile = (temp>>4)&3; + gain_set_params->gain_interpolation_type = (temp>>3)&1; + gain_set_params->full_frame = (temp>>2)&1; + gain_set_params->time_alignment = (temp>>1)&1; + gain_set_params->time_delt_min_flag = temp&1; - } - - return(0); + if(gain_set_params->time_delt_min_flag) + { + WORD32 time_delta_min; + time_delta_min = impd_read_bits_buf(it_bit_buff, 11); + if(it_bit_buff->error) + return it_bit_buff->error; + gain_set_params->time_delt_min_val = time_delta_min + 1; + } + + if (gain_set_params->gain_coding_profile == GAIN_CODING_PROFILE_CONSTANT) + { + gain_set_params->band_count = 1; + *gain_seq_idx = (*gain_seq_idx) + 1; + } + else + { + gain_set_params->band_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + + if(gain_set_params->band_count>1) + { + gain_set_params->drc_band_type = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + for(i=0; iband_count; i++) + { + if (version == 0) { + *gain_seq_idx = (*gain_seq_idx) + 1; + } + else + { + WORD32 indexPresent; + indexPresent = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (indexPresent) + { + WORD32 bsIndex; + bsIndex = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + *gain_seq_idx = bsIndex; + } + else + { + *gain_seq_idx = (*gain_seq_idx) + 1; + } + } + gain_set_params->gain_params[i].gain_seq_idx = *gain_seq_idx; + err = impd_parse_gain_set_params_characteristics(it_bit_buff, version, &(gain_set_params->gain_params[i])); + if (err) return(err); + } + if (gain_set_params->drc_band_type) + { + for(i=1; iband_count; i++) + { + gain_set_params->gain_params[i].crossover_freq_idx = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + else + { + for(i=1; iband_count; i++) + { + gain_set_params->gain_params[i].start_subband_index = impd_read_bits_buf(it_bit_buff, 10); + if(it_bit_buff->error) + return it_bit_buff->error; + } + } + + } + + return(0); } WORD32 @@ -1637,7 +1637,7 @@ impd_sel_drc_coeff(ia_drc_config* drc_config, *str_p_loc_drc_coefficients_uni_drc = &(drc_config->str_p_loc_drc_coefficients_uni_drc[c0]); } else { - *str_p_loc_drc_coefficients_uni_drc = NULL; + *str_p_loc_drc_coefficients_uni_drc = NULL; } return (0); } @@ -1646,95 +1646,95 @@ impd_sel_drc_coeff(ia_drc_config* drc_config, WORD32 impd_parse_loudness_info_set_ext(ia_bit_buf_struct* it_bit_buff, - ia_drc_loudness_info_set_struct* loudness_info_set) + ia_drc_loudness_info_set_struct* loudness_info_set) { WORD32 err = 0, i, k; WORD32 bit_size_len, ext_size_bits, bit_size, other_bit; - + k = 0; - loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - while(loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k] != UNIDRCLOUDEXT_TERM) - { - bit_size_len = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - ext_size_bits = bit_size_len + 4; - - bit_size = impd_read_bits_buf(it_bit_buff, ext_size_bits); - if(it_bit_buff->error) - return it_bit_buff->error; - loudness_info_set->str_loudness_info_set_ext.ext_bit_size[k] = bit_size + 1; - - switch(loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k]) - { - case UNIDRCLOUDEXT_EQ: - err = impd_parse_loud_info_set_ext_eq(it_bit_buff, loudness_info_set); - if (err) return(err); - break; - default: - for(i = 0; istr_loudness_info_set_ext.ext_bit_size[k]; i++) - { - other_bit = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - } - break; - } - k++; - loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - } - - return (0); + loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + while(loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k] != UNIDRCLOUDEXT_TERM) + { + bit_size_len = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + ext_size_bits = bit_size_len + 4; + + bit_size = impd_read_bits_buf(it_bit_buff, ext_size_bits); + if(it_bit_buff->error) + return it_bit_buff->error; + loudness_info_set->str_loudness_info_set_ext.ext_bit_size[k] = bit_size + 1; + + switch(loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k]) + { + case UNIDRCLOUDEXT_EQ: + err = impd_parse_loud_info_set_ext_eq(it_bit_buff, loudness_info_set); + if (err) return(err); + break; + default: + for(i = 0; istr_loudness_info_set_ext.ext_bit_size[k]; i++) + { + other_bit = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + break; + } + k++; + loudness_info_set->str_loudness_info_set_ext.loudness_info_set_ext_type[k] = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + + return (0); } WORD32 impd_drc_parse_coeff(ia_bit_buf_struct* it_bit_buff, - WORD32 version, - ia_drc_params_bs_dec_struct* ia_drc_params_struct, - ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc) + WORD32 version, + ia_drc_params_bs_dec_struct* ia_drc_params_struct, + ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc) { WORD32 err = 0, i, drc_frame_size, temp; WORD32 gain_seq_idx = -1; - + str_p_loc_drc_coefficients_uni_drc->version = version; if (version == 0) { WORD32 gain_sequence_count = 0; - temp = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; - str_p_loc_drc_coefficients_uni_drc->drc_location = (temp>>1)&0xf; - str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present = temp&1; + str_p_loc_drc_coefficients_uni_drc->drc_location = (temp>>1)&0xf; + str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present = temp&1; if (str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present == 1) { - drc_frame_size = impd_read_bits_buf(it_bit_buff, 15); - if(it_bit_buff->error) - return it_bit_buff->error; + drc_frame_size = impd_read_bits_buf(it_bit_buff, 15); + if(it_bit_buff->error) + return it_bit_buff->error; str_p_loc_drc_coefficients_uni_drc->drc_frame_size = drc_frame_size + 1; } - + str_p_loc_drc_coefficients_uni_drc->drc_characteristic_left_present = 0; str_p_loc_drc_coefficients_uni_drc->drc_characteristic_right_present = 0; str_p_loc_drc_coefficients_uni_drc->shape_filters_present = 0; - str_p_loc_drc_coefficients_uni_drc->gain_set_count = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + str_p_loc_drc_coefficients_uni_drc->gain_set_count = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; str_p_loc_drc_coefficients_uni_drc->gain_set_count_plus = str_p_loc_drc_coefficients_uni_drc->gain_set_count; for(i=0; igain_set_count; i++) { err = impd_parse_gain_set_params(it_bit_buff, version, &gain_seq_idx, &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[i])); if (err) return (err); - + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_flag) { - if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_val > ia_drc_params_struct->drc_frame_size) + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_val > ia_drc_params_struct->drc_frame_size) { - /* drc time interval too big */ + /* drc time interval too big */ return(PARAM_ERROR); } str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].num_gain_max_values = ia_drc_params_struct->drc_frame_size / str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_val; @@ -1746,140 +1746,140 @@ impd_drc_parse_coeff(ia_bit_buf_struct* it_bit_buff, str_p_loc_drc_coefficients_uni_drc->gain_sequence_count = gain_sequence_count; } else { - + ia_shape_filter_block_params_struct* pstr_shape_filter_block_params; - for (i=0; igain_set_params_index_for_gain_sequence[i] = -1; } - temp = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; - str_p_loc_drc_coefficients_uni_drc->drc_location = (temp>>1)&0xf; - str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present = temp&1; + str_p_loc_drc_coefficients_uni_drc->drc_location = (temp>>1)&0xf; + str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present = temp&1; if (str_p_loc_drc_coefficients_uni_drc->drc_frame_size_present == 1) { - drc_frame_size = impd_read_bits_buf(it_bit_buff, 15); - if(it_bit_buff->error) - return it_bit_buff->error; + drc_frame_size = impd_read_bits_buf(it_bit_buff, 15); + if(it_bit_buff->error) + return it_bit_buff->error; str_p_loc_drc_coefficients_uni_drc->drc_frame_size = drc_frame_size + 1; } - str_p_loc_drc_coefficients_uni_drc->drc_characteristic_left_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + str_p_loc_drc_coefficients_uni_drc->drc_characteristic_left_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (str_p_loc_drc_coefficients_uni_drc->drc_characteristic_left_present == 1) - { - str_p_loc_drc_coefficients_uni_drc->characteristic_left_count = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; + { + str_p_loc_drc_coefficients_uni_drc->characteristic_left_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; for (i=1; i<=str_p_loc_drc_coefficients_uni_drc->characteristic_left_count; i++) - { + { err = impd_parse_split_drc_characteristic(it_bit_buff, LEFT_SIDE, &(str_p_loc_drc_coefficients_uni_drc->str_split_characteristic_left[i])); if (err) return(err); } } - str_p_loc_drc_coefficients_uni_drc->drc_characteristic_right_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + str_p_loc_drc_coefficients_uni_drc->drc_characteristic_right_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (str_p_loc_drc_coefficients_uni_drc->drc_characteristic_right_present == 1) - { - str_p_loc_drc_coefficients_uni_drc->characteristic_right_count = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - for (i=1; i<=str_p_loc_drc_coefficients_uni_drc->characteristic_right_count; i++) - { + { + str_p_loc_drc_coefficients_uni_drc->characteristic_right_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=1; i<=str_p_loc_drc_coefficients_uni_drc->characteristic_right_count; i++) + { err = impd_parse_split_drc_characteristic(it_bit_buff, RIGHT_SIDE, &(str_p_loc_drc_coefficients_uni_drc->str_split_characteristic_right[i])); if (err) return(err); } } - str_p_loc_drc_coefficients_uni_drc->shape_filters_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (str_p_loc_drc_coefficients_uni_drc->shape_filters_present == 1) - { - str_p_loc_drc_coefficients_uni_drc->shape_num_filter = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - for (i=1; i<=str_p_loc_drc_coefficients_uni_drc->shape_num_filter; i++) - { + str_p_loc_drc_coefficients_uni_drc->shape_filters_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_p_loc_drc_coefficients_uni_drc->shape_filters_present == 1) + { + str_p_loc_drc_coefficients_uni_drc->shape_num_filter = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + for (i=1; i<=str_p_loc_drc_coefficients_uni_drc->shape_num_filter; i++) + { pstr_shape_filter_block_params = &(str_p_loc_drc_coefficients_uni_drc->str_shape_filter_block_params[i]); - pstr_shape_filter_block_params->lf_cut_filter_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (pstr_shape_filter_block_params->lf_cut_filter_present == 1) - { + pstr_shape_filter_block_params->lf_cut_filter_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; - temp = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - - pstr_shape_filter_block_params->str_lf_cut_params.corner_freq_index = (temp>>2)&7; - pstr_shape_filter_block_params->str_lf_cut_params.filter_strength_index = temp&3; + if (pstr_shape_filter_block_params->lf_cut_filter_present == 1) + { + + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + pstr_shape_filter_block_params->str_lf_cut_params.corner_freq_index = (temp>>2)&7; + pstr_shape_filter_block_params->str_lf_cut_params.filter_strength_index = temp&3; } - pstr_shape_filter_block_params->lf_boost_filter_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (pstr_shape_filter_block_params->lf_boost_filter_present == 1) - { - temp = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - - pstr_shape_filter_block_params->str_lf_boost_params.corner_freq_index = (temp>>2)&7; - pstr_shape_filter_block_params->str_lf_boost_params.filter_strength_index = temp&3; + pstr_shape_filter_block_params->lf_boost_filter_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_shape_filter_block_params->lf_boost_filter_present == 1) + { + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + pstr_shape_filter_block_params->str_lf_boost_params.corner_freq_index = (temp>>2)&7; + pstr_shape_filter_block_params->str_lf_boost_params.filter_strength_index = temp&3; } - pstr_shape_filter_block_params->hf_cut_filter_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; + pstr_shape_filter_block_params->hf_cut_filter_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; if (pstr_shape_filter_block_params->hf_cut_filter_present == 1) - { - temp = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - - pstr_shape_filter_block_params->str_hfCutParams.corner_freq_index = (temp>>2)&7; - pstr_shape_filter_block_params->str_hfCutParams.filter_strength_index = temp&3; - + { + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + pstr_shape_filter_block_params->str_hfCutParams.corner_freq_index = (temp>>2)&7; + pstr_shape_filter_block_params->str_hfCutParams.filter_strength_index = temp&3; + } - pstr_shape_filter_block_params->hf_boost_filter_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (pstr_shape_filter_block_params->hf_boost_filter_present == 1) - { - temp = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - - pstr_shape_filter_block_params->str_hf_boost_params.corner_freq_index = (temp>>2)&7; - pstr_shape_filter_block_params->str_hf_boost_params.filter_strength_index = temp&3; - + pstr_shape_filter_block_params->hf_boost_filter_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (pstr_shape_filter_block_params->hf_boost_filter_present == 1) + { + temp = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + pstr_shape_filter_block_params->str_hf_boost_params.corner_freq_index = (temp>>2)&7; + pstr_shape_filter_block_params->str_hf_boost_params.filter_strength_index = temp&3; + } } } - temp = impd_read_bits_buf(it_bit_buff, 12); - if(it_bit_buff->error) - return it_bit_buff->error; - - str_p_loc_drc_coefficients_uni_drc->gain_sequence_count = (temp>>6)&0x3f; - str_p_loc_drc_coefficients_uni_drc->gain_set_count = temp&0x3f; + temp = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_p_loc_drc_coefficients_uni_drc->gain_sequence_count = (temp>>6)&0x3f; + str_p_loc_drc_coefficients_uni_drc->gain_set_count = temp&0x3f; str_p_loc_drc_coefficients_uni_drc->gain_set_count_plus = str_p_loc_drc_coefficients_uni_drc->gain_set_count; for(i=0; igain_set_count; i++) { err = impd_parse_gain_set_params(it_bit_buff, version, &gain_seq_idx, &(str_p_loc_drc_coefficients_uni_drc->gain_set_params[i])); if (err) return (err); - + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_flag) { - if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_val > ia_drc_params_struct->drc_frame_size) + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_val > ia_drc_params_struct->drc_frame_size) { - /* drc time interval too big */ + /* drc time interval too big */ return(PARAM_ERROR); } str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].num_gain_max_values = ia_drc_params_struct->drc_frame_size / str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].time_delt_min_val; @@ -1887,7 +1887,7 @@ impd_drc_parse_coeff(ia_bit_buf_struct* it_bit_buff, if (err) return (err); } } - + for(i=0; igain_set_count; i++) { WORD32 b; @@ -1902,131 +1902,131 @@ impd_drc_parse_coeff(ia_bit_buf_struct* it_bit_buff, WORD32 impd_drc_parse_instructions_basic(ia_bit_buf_struct* it_bit_buff, - ia_drc_instructions_basic_struct* str_drc_instructions_basic) + ia_drc_instructions_basic_struct* str_drc_instructions_basic) { //WORD32 err = 0; - WORD32 i, limiter_peak_target, temp; + WORD32 i, limiter_peak_target, temp; WORD32 additional_dmix_id_present, additional_dmix_id_cnt; - temp = impd_read_bits_buf(it_bit_buff, 18); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 18); + if(it_bit_buff->error) + return it_bit_buff->error; - str_drc_instructions_basic->drc_set_id = (temp>>12)&0x3f; - str_drc_instructions_basic->drc_location = (temp>>8)&0xf; - str_drc_instructions_basic->downmix_id[0] = (temp>>1)&0x7f; - additional_dmix_id_present = temp&1; - str_drc_instructions_basic->dwnmix_id_count = 1; + str_drc_instructions_basic->drc_set_id = (temp>>12)&0x3f; + str_drc_instructions_basic->drc_location = (temp>>8)&0xf; + str_drc_instructions_basic->downmix_id[0] = (temp>>1)&0x7f; + additional_dmix_id_present = temp&1; + str_drc_instructions_basic->dwnmix_id_count = 1; - if (additional_dmix_id_present) - { - additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; - for(i=0; idownmix_id[i+1] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - } - str_drc_instructions_basic->dwnmix_id_count = 1 + additional_dmix_id_cnt; - } - - - str_drc_instructions_basic->drc_set_effect = impd_read_bits_buf(it_bit_buff, 16); - if(it_bit_buff->error) - return it_bit_buff->error; - - if ((str_drc_instructions_basic->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) == 0) - { - str_drc_instructions_basic->limiter_peak_target_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (str_drc_instructions_basic->limiter_peak_target_present) - { - - limiter_peak_target = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - str_drc_instructions_basic->limiter_peak_target = - limiter_peak_target * 0.125f; - } - } - - str_drc_instructions_basic->drc_set_target_loudness_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - str_drc_instructions_basic->drc_set_target_loudness_value_upper = 0; - str_drc_instructions_basic->drc_set_target_loudness_value_lower = -63; - - if (str_drc_instructions_basic->drc_set_target_loudness_present == 1) - { - WORD32 bsDrcSetTargetLoudnessValueUpper, bsDrcSetTargetLoudnessValueLower; - bsDrcSetTargetLoudnessValueUpper = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - str_drc_instructions_basic->drc_set_target_loudness_value_upper = bsDrcSetTargetLoudnessValueUpper - 63; - - str_drc_instructions_basic->drc_set_target_loudness_value_lower_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (str_drc_instructions_basic->drc_set_target_loudness_value_lower_present == 1) - { - bsDrcSetTargetLoudnessValueLower = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - str_drc_instructions_basic->drc_set_target_loudness_value_lower = bsDrcSetTargetLoudnessValueLower - 63; - } - } - - return(0); + if (additional_dmix_id_present) + { + additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + for(i=0; idownmix_id[i+1] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + str_drc_instructions_basic->dwnmix_id_count = 1 + additional_dmix_id_cnt; + } + + + str_drc_instructions_basic->drc_set_effect = impd_read_bits_buf(it_bit_buff, 16); + if(it_bit_buff->error) + return it_bit_buff->error; + + if ((str_drc_instructions_basic->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) == 0) + { + str_drc_instructions_basic->limiter_peak_target_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_drc_instructions_basic->limiter_peak_target_present) + { + + limiter_peak_target = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instructions_basic->limiter_peak_target = - limiter_peak_target * 0.125f; + } + } + + str_drc_instructions_basic->drc_set_target_loudness_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_drc_instructions_basic->drc_set_target_loudness_value_upper = 0; + str_drc_instructions_basic->drc_set_target_loudness_value_lower = -63; + + if (str_drc_instructions_basic->drc_set_target_loudness_present == 1) + { + WORD32 bsDrcSetTargetLoudnessValueUpper, bsDrcSetTargetLoudnessValueLower; + bsDrcSetTargetLoudnessValueUpper = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instructions_basic->drc_set_target_loudness_value_upper = bsDrcSetTargetLoudnessValueUpper - 63; + + str_drc_instructions_basic->drc_set_target_loudness_value_lower_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (str_drc_instructions_basic->drc_set_target_loudness_value_lower_present == 1) + { + bsDrcSetTargetLoudnessValueLower = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instructions_basic->drc_set_target_loudness_value_lower = bsDrcSetTargetLoudnessValueLower - 63; + } + } + + return(0); } WORD32 impd_dec_ducking_scaling(ia_bit_buf_struct* it_bit_buff, - WORD32* ducking_scaling_flag, - FLOAT32* p_ducking_scaling) + WORD32* ducking_scaling_flag, + FLOAT32* p_ducking_scaling) { WORD32 ducking_scaling_present, ducking_scaling, sigma, mu; - - ducking_scaling_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (ducking_scaling_present == 0) - { - *ducking_scaling_flag = 0; - *p_ducking_scaling = 1.0f; - } - else - { - *ducking_scaling_flag = 1; - ducking_scaling = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - - - sigma = ducking_scaling >> 3; - mu = ducking_scaling & 0x7; - - if (sigma == 0) - { - *p_ducking_scaling = 1.0f + 0.125f * (1.0f + mu); - } - else - { - *p_ducking_scaling = 1.0f - 0.125f * (1.0f + mu); - } - } - return (0); + + ducking_scaling_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (ducking_scaling_present == 0) + { + *ducking_scaling_flag = 0; + *p_ducking_scaling = 1.0f; + } + else + { + *ducking_scaling_flag = 1; + ducking_scaling = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + + + sigma = ducking_scaling >> 3; + mu = ducking_scaling & 0x7; + + if (sigma == 0) + { + *p_ducking_scaling = 1.0f + 0.125f * (1.0f + mu); + } + else + { + *p_ducking_scaling = 1.0f - 0.125f * (1.0f + mu); + } + } + return (0); } WORD32 impd_parse_drc_instructions_uni_drc(ia_bit_buf_struct* it_bit_buff, - WORD32 version, - ia_drc_config* drc_config, - ia_drc_instructions_struct* str_drc_instruction_str) + WORD32 version, + ia_drc_config* drc_config, + ia_drc_instructions_struct* str_drc_instruction_str) { WORD32 err = 0, i, n, k, g, c, limiter_peak_target, idx; WORD32 additional_dmix_id_present, additional_dmix_id_cnt; @@ -2039,308 +2039,308 @@ impd_parse_drc_instructions_uni_drc(ia_bit_buf_struct* it_bit_buff, WORD32 repeat_parameters, repeat_parameters_cnt; WORD32 ducking_sequence; FLOAT32 factor; - - str_drc_instruction_str->drc_set_id = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - if (version == 0) - { - str_drc_instruction_str->drc_set_complexity_level = DRC_COMPLEXITY_LEVEL_MAX; - } - else - { - str_drc_instruction_str->drc_set_complexity_level = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - } - str_drc_instruction_str->drc_location = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - dmix_id_present = 1; - if (version >= 1) - { - dmix_id_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - } - if (dmix_id_present == 1) - { - str_drc_instruction_str->downmix_id[0] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - if (version >= 1) - { - str_drc_instruction_str->drc_apply_to_dwnmix = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - } - if (version == 0) - { - if (str_drc_instruction_str->downmix_id[0] == 0) - { - str_drc_instruction_str->drc_apply_to_dwnmix = 0; - } - else - { - str_drc_instruction_str->drc_apply_to_dwnmix = 1; - } - } - additional_dmix_id_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (additional_dmix_id_present) - { - additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 3); - if(it_bit_buff->error) - return it_bit_buff->error; - for(i=0; idownmix_id[i+1] = impd_read_bits_buf(it_bit_buff, 7); - if(it_bit_buff->error) - return it_bit_buff->error; - } - str_drc_instruction_str->dwnmix_id_count = 1 + additional_dmix_id_cnt; - } else - { - str_drc_instruction_str->dwnmix_id_count = 1; - } - } - else - { - str_drc_instruction_str->downmix_id[0] = 0; - str_drc_instruction_str->dwnmix_id_count = 1; - } - - str_drc_instruction_str->drc_set_effect = impd_read_bits_buf(it_bit_buff, 16); - if(it_bit_buff->error) - return it_bit_buff->error; - - if ((str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) == 0) - { - str_drc_instruction_str->limiter_peak_target_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (str_drc_instruction_str->limiter_peak_target_present) - { - limiter_peak_target = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; - str_drc_instruction_str->limiter_peak_target = - limiter_peak_target * 0.125f; - } - } - - str_drc_instruction_str->drc_set_target_loudness_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - str_drc_instruction_str->drc_set_target_loudness_value_upper = 0; - str_drc_instruction_str->drc_set_target_loudness_value_lower = -63; - - if (str_drc_instruction_str->drc_set_target_loudness_present == 1) - { - WORD32 bsDrcSetTargetLoudnessValueUpper, bsDrcSetTargetLoudnessValueLower; - bsDrcSetTargetLoudnessValueUpper = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - str_drc_instruction_str->drc_set_target_loudness_value_upper = bsDrcSetTargetLoudnessValueUpper - 63; - str_drc_instruction_str->drc_set_target_loudness_value_lower_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - if (str_drc_instruction_str->drc_set_target_loudness_value_lower_present == 1) - { - bsDrcSetTargetLoudnessValueLower = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - str_drc_instruction_str->drc_set_target_loudness_value_lower = bsDrcSetTargetLoudnessValueLower - 63; - } - } - - - str_drc_instruction_str->depends_on_drc_set_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - - str_drc_instruction_str->no_independent_use = 0; - if (str_drc_instruction_str->depends_on_drc_set_present) - { - - str_drc_instruction_str->depends_on_drc_set = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - } - else - { - - str_drc_instruction_str->no_independent_use = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - } - if (version == 0) - { - str_drc_instruction_str->requires_eq = 0; - } - else - { - - str_drc_instruction_str->requires_eq = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - } - - err = impd_sel_drc_coeff(drc_config, str_drc_instruction_str->drc_location, &str_p_loc_drc_coefficients_uni_drc); - if (err) return (err); - - ch_cnt = drc_config->channel_layout.base_channel_count; - - for (c=0; cdrc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) - { - c=0; - while (cerror) - return it_bit_buff->error; - str_drc_instruction_str->gain_set_index[c] = bs_gain_set_idx - 1; - impd_dec_ducking_scaling(it_bit_buff, - &(str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling_flag), - &(str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling)); - - c++; - - repeat_parameters = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - - if (repeat_parameters == 1) - { - - repeat_parameters_cnt = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - - repeat_parameters_cnt += 1; - for (k=0; kgain_set_index[c] = str_drc_instruction_str->gain_set_index[c-1]; - str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling_flag = str_drc_instruction_str->str_ducking_modifiers_for_channel[c-1].ducking_scaling_flag; - str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling = str_drc_instruction_str->str_ducking_modifiers_for_channel[c-1].ducking_scaling; - c++; - } - } - } - if (c>ch_cnt) - { - return(UNEXPECTED_ERROR); - } - ducking_sequence = -1; - g = 0; - if (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_DUCK_OTHER) - { - for (c=0; cgain_set_index[c]; - factor = str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling; - if (idx < 0) { - for (n=0; nchannel_group_of_ch[c] = n; - break; - } - } - if (match == 0) - { - unique_idx[g] = idx; - unique_scaling[g] = factor; - str_drc_instruction_str->channel_group_of_ch[c] = g; - g++; - } - } - else - { - if ((ducking_sequence > 0) && (ducking_sequence != idx)) - { - /* drc for ducking can have only one ducking sequence */ - return(UNEXPECTED_ERROR); - } - ducking_sequence = idx; - str_drc_instruction_str->channel_group_of_ch[c] = -1; - } - } - str_drc_instruction_str->num_drc_ch_groups = g; - if (ducking_sequence == -1) - { - /* ducking sequence not found */ - return(UNEXPECTED_ERROR); - } - } else if (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_DUCK_SELF) - { - for (c=0; cgain_set_index[c]; - factor = str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling; - if (idx >= 0) { - for (n=0; nchannel_group_of_ch[c] = n; - break; - } - } - if (match == 0) - { - unique_idx[g] = idx; - unique_scaling[g] = factor; - str_drc_instruction_str->channel_group_of_ch[c] = g; - g++; - } - } - else - { - str_drc_instruction_str->channel_group_of_ch[c] = -1; - } - } - str_drc_instruction_str->num_drc_ch_groups = g; - } - - for (g=0; gnum_drc_ch_groups; g++) - { - WORD32 set = (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_DUCK_OTHER) ? ducking_sequence : unique_idx[g]; - str_drc_instruction_str->gain_set_index_for_channel_group[g] = set; - str_drc_instruction_str->str_ducking_modifiers_for_channel_group[g].ducking_scaling = unique_scaling[g]; - if (unique_scaling[g] != 1.0f) - { - str_drc_instruction_str->str_ducking_modifiers_for_channel_group[g].ducking_scaling_flag = 1; - } - else - { - str_drc_instruction_str->str_ducking_modifiers_for_channel_group[g].ducking_scaling_flag = 0; - } - str_drc_instruction_str->band_count_of_ch_group[g] = 1; - } + str_drc_instruction_str->drc_set_id = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + if (version == 0) + { + str_drc_instruction_str->drc_set_complexity_level = DRC_COMPLEXITY_LEVEL_MAX; + } + else + { + str_drc_instruction_str->drc_set_complexity_level = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + } + str_drc_instruction_str->drc_location = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + dmix_id_present = 1; + if (version >= 1) + { + dmix_id_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + if (dmix_id_present == 1) + { + str_drc_instruction_str->downmix_id[0] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + if (version >= 1) + { + str_drc_instruction_str->drc_apply_to_dwnmix = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + } + if (version == 0) + { + if (str_drc_instruction_str->downmix_id[0] == 0) + { + str_drc_instruction_str->drc_apply_to_dwnmix = 0; + } + else + { + str_drc_instruction_str->drc_apply_to_dwnmix = 1; + } + } + additional_dmix_id_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (additional_dmix_id_present) + { + additional_dmix_id_cnt = impd_read_bits_buf(it_bit_buff, 3); + if(it_bit_buff->error) + return it_bit_buff->error; + for(i=0; idownmix_id[i+1] = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; + } + str_drc_instruction_str->dwnmix_id_count = 1 + additional_dmix_id_cnt; + } else + { + str_drc_instruction_str->dwnmix_id_count = 1; + } + } + else + { + str_drc_instruction_str->downmix_id[0] = 0; + str_drc_instruction_str->dwnmix_id_count = 1; + } + + str_drc_instruction_str->drc_set_effect = impd_read_bits_buf(it_bit_buff, 16); + if(it_bit_buff->error) + return it_bit_buff->error; + + if ((str_drc_instruction_str->drc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) == 0) + { + str_drc_instruction_str->limiter_peak_target_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_drc_instruction_str->limiter_peak_target_present) + { + limiter_peak_target = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instruction_str->limiter_peak_target = - limiter_peak_target * 0.125f; + } + } + + str_drc_instruction_str->drc_set_target_loudness_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + str_drc_instruction_str->drc_set_target_loudness_value_upper = 0; + str_drc_instruction_str->drc_set_target_loudness_value_lower = -63; + + if (str_drc_instruction_str->drc_set_target_loudness_present == 1) + { + WORD32 bsDrcSetTargetLoudnessValueUpper, bsDrcSetTargetLoudnessValueLower; + bsDrcSetTargetLoudnessValueUpper = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instruction_str->drc_set_target_loudness_value_upper = bsDrcSetTargetLoudnessValueUpper - 63; + str_drc_instruction_str->drc_set_target_loudness_value_lower_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + if (str_drc_instruction_str->drc_set_target_loudness_value_lower_present == 1) + { + bsDrcSetTargetLoudnessValueLower = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + str_drc_instruction_str->drc_set_target_loudness_value_lower = bsDrcSetTargetLoudnessValueLower - 63; + } + } + + + str_drc_instruction_str->depends_on_drc_set_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + + str_drc_instruction_str->no_independent_use = 0; + if (str_drc_instruction_str->depends_on_drc_set_present) + { + + str_drc_instruction_str->depends_on_drc_set = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + + str_drc_instruction_str->no_independent_use = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + } + if (version == 0) + { + str_drc_instruction_str->requires_eq = 0; + } + else + { + + str_drc_instruction_str->requires_eq = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + } + + err = impd_sel_drc_coeff(drc_config, str_drc_instruction_str->drc_location, &str_p_loc_drc_coefficients_uni_drc); + if (err) return (err); + + ch_cnt = drc_config->channel_layout.base_channel_count; + + for (c=0; cdrc_set_effect & (EFFECT_BIT_DUCK_OTHER | EFFECT_BIT_DUCK_SELF)) + { + c=0; + while (cerror) + return it_bit_buff->error; + str_drc_instruction_str->gain_set_index[c] = bs_gain_set_idx - 1; + impd_dec_ducking_scaling(it_bit_buff, + &(str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling_flag), + &(str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling)); + + c++; + + repeat_parameters = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + + if (repeat_parameters == 1) + { + + repeat_parameters_cnt = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + + repeat_parameters_cnt += 1; + for (k=0; kgain_set_index[c] = str_drc_instruction_str->gain_set_index[c-1]; + str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling_flag = str_drc_instruction_str->str_ducking_modifiers_for_channel[c-1].ducking_scaling_flag; + str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling = str_drc_instruction_str->str_ducking_modifiers_for_channel[c-1].ducking_scaling; + c++; + } + } + } + if (c>ch_cnt) + { + return(UNEXPECTED_ERROR); + } + ducking_sequence = -1; + g = 0; + if (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_DUCK_OTHER) + { + for (c=0; cgain_set_index[c]; + factor = str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling; + if (idx < 0) { + for (n=0; nchannel_group_of_ch[c] = n; + break; + } + } + if (match == 0) + { + unique_idx[g] = idx; + unique_scaling[g] = factor; + str_drc_instruction_str->channel_group_of_ch[c] = g; + g++; + } + } + else + { + if ((ducking_sequence > 0) && (ducking_sequence != idx)) + { + /* drc for ducking can have only one ducking sequence */ + return(UNEXPECTED_ERROR); + } + ducking_sequence = idx; + str_drc_instruction_str->channel_group_of_ch[c] = -1; + } + } + str_drc_instruction_str->num_drc_ch_groups = g; + if (ducking_sequence == -1) + { + /* ducking sequence not found */ + return(UNEXPECTED_ERROR); + } + } else if (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_DUCK_SELF) + { + for (c=0; cgain_set_index[c]; + factor = str_drc_instruction_str->str_ducking_modifiers_for_channel[c].ducking_scaling; + if (idx >= 0) { + for (n=0; nchannel_group_of_ch[c] = n; + break; + } + } + if (match == 0) + { + unique_idx[g] = idx; + unique_scaling[g] = factor; + str_drc_instruction_str->channel_group_of_ch[c] = g; + g++; + } + } + else + { + str_drc_instruction_str->channel_group_of_ch[c] = -1; + } + } + str_drc_instruction_str->num_drc_ch_groups = g; + } + + for (g=0; gnum_drc_ch_groups; g++) + { + WORD32 set = (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_DUCK_OTHER) ? ducking_sequence : unique_idx[g]; + str_drc_instruction_str->gain_set_index_for_channel_group[g] = set; + str_drc_instruction_str->str_ducking_modifiers_for_channel_group[g].ducking_scaling = unique_scaling[g]; + if (unique_scaling[g] != 1.0f) + { + str_drc_instruction_str->str_ducking_modifiers_for_channel_group[g].ducking_scaling_flag = 1; + } + else + { + str_drc_instruction_str->str_ducking_modifiers_for_channel_group[g].ducking_scaling_flag = 0; + } + str_drc_instruction_str->band_count_of_ch_group[g] = 1; + } } else { if ( - ((version==0) || (str_drc_instruction_str->drc_apply_to_dwnmix != 0)) && - (str_drc_instruction_str->downmix_id[0] != 0) && (str_drc_instruction_str->downmix_id[0] != ID_FOR_ANY_DOWNMIX) && (str_drc_instruction_str->dwnmix_id_count==1)) + ((version==0) || (str_drc_instruction_str->drc_apply_to_dwnmix != 0)) && + (str_drc_instruction_str->downmix_id[0] != 0) && (str_drc_instruction_str->downmix_id[0] != ID_FOR_ANY_DOWNMIX) && (str_drc_instruction_str->dwnmix_id_count==1)) { for(i=0; idwnmix_instructions_count; i++) { @@ -2348,41 +2348,41 @@ impd_parse_drc_instructions_uni_drc(ia_bit_buf_struct* it_bit_buff, } if (i == drc_config->dwnmix_instructions_count) { - /* dwnmix_instructions not found */ + /* dwnmix_instructions not found */ return(UNEXPECTED_ERROR); } - ch_cnt = drc_config->dwnmix_instructions[i].target_channel_count; + ch_cnt = drc_config->dwnmix_instructions[i].target_channel_count; } else if ( - ((version==0) || (str_drc_instruction_str->drc_apply_to_dwnmix != 0)) && - ((str_drc_instruction_str->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (str_drc_instruction_str->dwnmix_id_count > 1))) + ((version==0) || (str_drc_instruction_str->drc_apply_to_dwnmix != 0)) && + ((str_drc_instruction_str->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (str_drc_instruction_str->dwnmix_id_count > 1))) { ch_cnt = 1; } - + c=0; while (cerror) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 7); + if(it_bit_buff->error) + return it_bit_buff->error; - bs_gain_set_idx = (temp>>1)&0x7f; - repeat_gain_set_idx = temp&1; + bs_gain_set_idx = (temp>>1)&0x7f; + repeat_gain_set_idx = temp&1; str_drc_instruction_str->gain_set_index[c] = bs_gain_set_idx - 1; c++; - + if (repeat_gain_set_idx == 1) { - - repeat_gain_set_idx_cnt = impd_read_bits_buf(it_bit_buff, 5); - if(it_bit_buff->error) - return it_bit_buff->error; - + + repeat_gain_set_idx_cnt = impd_read_bits_buf(it_bit_buff, 5); + if(it_bit_buff->error) + return it_bit_buff->error; + repeat_gain_set_idx_cnt += 1; for (k=0; kdownmix_id[0] == ID_FOR_ANY_DOWNMIX) || (str_drc_instruction_str->dwnmix_id_count > 1)) - { + if ((str_drc_instruction_str->downmix_id[0] == ID_FOR_ANY_DOWNMIX) || (str_drc_instruction_str->dwnmix_id_count > 1)) + { WORD32 idx = str_drc_instruction_str->gain_set_index[0]; if (idx >= 0) - { + { unique_idx[0] = idx; g = 1; } } else { - for (c=0; cgain_set_index[c]; match = 0; - if (idx>=0) - { - for (n=0; n=0) + { + for (n=0; nchannel_group_of_ch[c] = n; break; @@ -2429,122 +2429,122 @@ impd_parse_drc_instructions_uni_drc(ia_bit_buf_struct* it_bit_buff, g++; } } - else - { + else + { str_drc_instruction_str->channel_group_of_ch[c] = -1; } } } - + str_drc_instruction_str->num_drc_ch_groups = g; for (g=0; gnum_drc_ch_groups; g++) { WORD32 set, band_count; - + set = unique_idx[g]; str_drc_instruction_str->gain_set_index_for_channel_group[g] = set; - - if (str_p_loc_drc_coefficients_uni_drc != NULL && set < str_p_loc_drc_coefficients_uni_drc->gain_set_count) - { + + if (str_p_loc_drc_coefficients_uni_drc != NULL && set < str_p_loc_drc_coefficients_uni_drc->gain_set_count) + { band_count = str_p_loc_drc_coefficients_uni_drc->gain_set_params[set].band_count; - } else - { - band_count = 1; + } else + { + band_count = 1; } - + err = impd_dec_gain_modifiers(it_bit_buff, version, band_count, &(str_drc_instruction_str->str_gain_modifiers_of_ch_group[g])); if (err) return (err); } } - + return(0); } WORD32 impd_parse_loudness_info(ia_bit_buf_struct* it_bit_buff, - WORD32 version, - ia_loudness_info_struct* loudness_info) + WORD32 version, + ia_loudness_info_struct* loudness_info) { WORD32 err = 0, sample_peak_level, true_peak_level, i, temp; - - loudness_info->drc_set_id = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (version >= 1) - { - loudness_info->eq_set_id = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; - } - else - { - loudness_info->eq_set_id = 0; - } - temp = impd_read_bits_buf(it_bit_buff, 8); - if(it_bit_buff->error) - return it_bit_buff->error; + loudness_info->drc_set_id = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; - loudness_info->downmix_id = (temp>>1)&0x7f; - loudness_info->sample_peak_level_present = temp&1; + if (version >= 1) + { + loudness_info->eq_set_id = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + } + else + { + loudness_info->eq_set_id = 0; + } - if(loudness_info->sample_peak_level_present) - { - - sample_peak_level = impd_read_bits_buf(it_bit_buff, 12); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (sample_peak_level == 0) - { - loudness_info->sample_peak_level_present = 0; - loudness_info->sample_peak_level = 0.0f; - } - else - { - loudness_info->sample_peak_level = 20.0f - sample_peak_level * 0.03125f; - } - } - - loudness_info->true_peak_level_present = impd_read_bits_buf(it_bit_buff, 1); - if(it_bit_buff->error) - return it_bit_buff->error; - - if(loudness_info->true_peak_level_present) - { - - true_peak_level = impd_read_bits_buf(it_bit_buff, 12); - if(it_bit_buff->error) - return it_bit_buff->error; - - if (true_peak_level == 0) - { - loudness_info->true_peak_level_present = 0; - loudness_info->true_peak_level = 0.0f; - } - else - { - loudness_info->true_peak_level = 20.0f - true_peak_level * 0.03125f; - } - - temp = impd_read_bits_buf(it_bit_buff, 6); - if(it_bit_buff->error) - return it_bit_buff->error; + temp = impd_read_bits_buf(it_bit_buff, 8); + if(it_bit_buff->error) + return it_bit_buff->error; - loudness_info->true_peak_level_measurement_system = (temp>>2)&0xf; - loudness_info->true_peak_level_reliability = temp&3; - } - - loudness_info->measurement_count = impd_read_bits_buf(it_bit_buff, 4); - if(it_bit_buff->error) - return it_bit_buff->error; - - - for (i=0; imeasurement_count; i++) - { - err = impd_parse_loudness_measure(it_bit_buff, &(loudness_info->loudness_measure[i])); - if (err) return(err); - } - - return(0); + loudness_info->downmix_id = (temp>>1)&0x7f; + loudness_info->sample_peak_level_present = temp&1; + + if(loudness_info->sample_peak_level_present) + { + + sample_peak_level = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (sample_peak_level == 0) + { + loudness_info->sample_peak_level_present = 0; + loudness_info->sample_peak_level = 0.0f; + } + else + { + loudness_info->sample_peak_level = 20.0f - sample_peak_level * 0.03125f; + } + } + + loudness_info->true_peak_level_present = impd_read_bits_buf(it_bit_buff, 1); + if(it_bit_buff->error) + return it_bit_buff->error; + + if(loudness_info->true_peak_level_present) + { + + true_peak_level = impd_read_bits_buf(it_bit_buff, 12); + if(it_bit_buff->error) + return it_bit_buff->error; + + if (true_peak_level == 0) + { + loudness_info->true_peak_level_present = 0; + loudness_info->true_peak_level = 0.0f; + } + else + { + loudness_info->true_peak_level = 20.0f - true_peak_level * 0.03125f; + } + + temp = impd_read_bits_buf(it_bit_buff, 6); + if(it_bit_buff->error) + return it_bit_buff->error; + + loudness_info->true_peak_level_measurement_system = (temp>>2)&0xf; + loudness_info->true_peak_level_reliability = temp&3; + } + + loudness_info->measurement_count = impd_read_bits_buf(it_bit_buff, 4); + if(it_bit_buff->error) + return it_bit_buff->error; + + + for (i=0; imeasurement_count; i++) + { + err = impd_parse_loudness_measure(it_bit_buff, &(loudness_info->loudness_measure[i])); + if (err) return(err); + } + + return(0); } \ No newline at end of file diff --git a/decoder/drc_src/impd_drc_struct.h b/decoder/drc_src/impd_drc_struct.h index 83348a1..f3fe501 100644 --- a/decoder/drc_src/impd_drc_struct.h +++ b/decoder/drc_src/impd_drc_struct.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_STURCT_H #define IMPD_DRC_STURCT_H @@ -59,7 +59,7 @@ extern "C" #define EFFECT_BIT_COUNT 12 -#define EFFECT_BIT_NONE (-1) +#define EFFECT_BIT_NONE (-1) #define EFFECT_BIT_NIGHT 0x0001 #define EFFECT_BIT_NOISY 0x0002 #define EFFECT_BIT_LIMITED 0x0004 @@ -100,9 +100,9 @@ extern "C" #define USER_LOUDNESS_PREPROCESSING_DEFAULT 0 #define USER_LOUDNESS_PREPROCESSING_OFF 1 #define USER_LOUDNESS_PREPROCESSING_HIGHPASS 2 - + #define LOUDNESS_DEVIATION_MAX_DEFAULT 63 -#define LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT 1000 +#define LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT 1000 #define SHORT_TERM_LOUDNESS_TO_AVG 0 #define MOMENTARY_LOUDNESS_TO_AVG 1 @@ -110,7 +110,7 @@ extern "C" #define DRC_COMPLEXITY_LEVEL_MAX 0xF #define EQ_COMPLEXITY_LEVEL_MAX 0xF -#define COMPLEXITY_LEVEL_SUPPORTED_TOTAL 20.0f +#define COMPLEXITY_LEVEL_SUPPORTED_TOTAL 20.0f #define COMPLEXITY_W_SUBBAND_EQ 2.5f #define COMPLEXITY_W_FIR 0.4f @@ -125,14 +125,14 @@ extern "C" #define COMPLEXITY_W_PARAM_DRC_SUBBAND 5.0f #define COMPLEXITY_W_PARAM_LIM_FILT 4.5f #define COMPLEXITY_W_PARAM_DRC_ATTACK 136.0f - + #define LEFT_SIDE 0 #define RIGHT_SIDE 1 - + #define CHARACTERISTIC_SIGMOID 0 #define CHARACTERISTIC_NODES 1 #define CHARACTERISTIC_PASS_THRU 2 - + #define GAINFORMAT_QMF32 0x1 #define GAINFORMAT_QMFHYBRID39 0x2 #define GAINFORMAT_QMF64 0x3 @@ -140,17 +140,17 @@ extern "C" #define GAINFORMAT_QMF128 0x5 #define GAINFORMAT_QMFHYBRID135 0x6 #define GAINFORMAT_UNIFORM 0x7 - -#define DRC_INPUT_LOUDNESS_TARGET (-31.0f) - + +#define DRC_INPUT_LOUDNESS_TARGET (-31.0f) + #define SHAPE_FILTER_TYPE_OFF 0 #define SHAPE_FILTER_TYPE_LF_CUT 1 #define SHAPE_FILTER_TYPE_LF_BOOST 2 #define SHAPE_FILTER_TYPE_HF_CUT 3 #define SHAPE_FILTER_TYPE_HF_BOOST 4 - -#define SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE 1583.8931924611f - + +#define SHAPE_FILTER_DRC_GAIN_MAX_MINUS_ONE 1583.8931924611f + typedef struct { WORD32 type; FLOAT32 gain_offset; @@ -196,10 +196,10 @@ typedef struct { WORD32 gain_smooth_rel_threshold; WORD32 gain_smooth_hold_off_count_present; WORD32 gain_smooth_hold_off; - + WORD32 disable_paramteric_drc; } ia_parametric_drc_type_feed_forward_struct; - + typedef struct { WORD32 parametric_lim_threshold_present; FLOAT32 parametric_lim_threshold; @@ -207,7 +207,7 @@ typedef struct { WORD32 parametric_lim_release_present; WORD32 parametric_lim_release; WORD32 drc_characteristic; - + WORD32 disable_paramteric_drc; } ia_parametric_drc_lim_struct; @@ -221,7 +221,7 @@ typedef struct { WORD32 len_bit_size; ia_parametric_drc_type_feed_forward_struct str_parametric_drc_type_feed_forward; ia_parametric_drc_lim_struct parametric_drc_lim; - + WORD32 drc_characteristic; WORD32 disable_paramteric_drc; } ia_parametric_drc_instructions_struct; @@ -234,7 +234,7 @@ typedef struct { FLOAT32 level_estim_ch_weight[MAX_CHANNEL_COUNT]; WORD32 drc_input_loudness_present; FLOAT32 drc_input_loudness; - + WORD32 ch_count_from_dwnmix_id; } ia_parametric_drc_gain_set_params_struct; @@ -248,7 +248,7 @@ typedef struct { WORD32 parametric_drc_gain_set_count; ia_parametric_drc_gain_set_params_struct str_parametric_drc_gain_set_params[SEQUENCE_COUNT_MAX]; } ia_drc_coeff_parametric_drc_struct; - + typedef struct { WORD32 base_channel_count; WORD32 layout_signaling_present; @@ -305,12 +305,12 @@ typedef struct { WORD32 band_count; WORD32 drc_band_type; ia_gain_params_struct gain_params[BAND_COUNT_MAX]; - + WORD32 num_gain_max_values; ia_tables_struct str_tables; } ia_gain_set_params_struct; -#define SPLIT_CHARACTERISTIC_NODE_COUNT_MAX 4 +#define SPLIT_CHARACTERISTIC_NODE_COUNT_MAX 4 typedef struct { WORD32 characteristic_format; FLOAT32 in_out_ratio; @@ -337,7 +337,7 @@ typedef struct { WORD32 hf_boost_filter_present; ia_shape_filter_params_struct str_hf_boost_params; } ia_shape_filter_block_params_struct; - + typedef struct { WORD32 drc_location; WORD32 drc_characteristic; @@ -362,7 +362,7 @@ typedef struct { WORD32 gain_sequence_count; WORD32 gain_set_params_index_for_gain_sequence[SEQUENCE_COUNT_MAX]; WORD32 gain_set_count_plus; - + } ia_uni_drc_coeffs_struct; typedef struct { @@ -400,8 +400,8 @@ typedef struct { WORD32 drc_set_target_loudness_value_upper; WORD32 drc_set_target_loudness_value_lower_present; WORD32 drc_set_target_loudness_value_lower; - - WORD32 audio_num_chan; + + WORD32 audio_num_chan; WORD32 num_drc_ch_groups; WORD32 gain_set_index_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; WORD32 band_count_of_ch_group[CHANNEL_GROUP_COUNT_MAX]; @@ -411,8 +411,8 @@ typedef struct { ia_ducking_modifiers_struct str_ducking_modifiers_for_channel_group[CHANNEL_GROUP_COUNT_MAX]; WORD32 channel_group_of_ch[MAX_CHANNEL_COUNT]; WORD32 num_chan_per_ch_group[CHANNEL_GROUP_COUNT_MAX]; - WORD32 gain_element_count; - WORD32 multiband_audio_sig_count; + WORD32 gain_element_count; + WORD32 multiband_audio_sig_count; WORD32 ch_group_parametric_drc_flag[CHANNEL_GROUP_COUNT_MAX]; WORD32 gain_set_idx_of_ch_group_parametric_drc[CHANNEL_GROUP_COUNT_MAX]; WORD32 parametric_drc_look_ahead_samples[CHANNEL_GROUP_COUNT_MAX]; @@ -439,7 +439,7 @@ typedef struct { WORD32 measurement_count; ia_loudness_measure_struct loudness_measure[MEASUREMENT_COUNT_MAX]; } ia_loudness_info_struct; - + typedef struct { WORD32 loud_eq_set_id; WORD32 drc_location; @@ -558,7 +558,7 @@ typedef struct { typedef struct { WORD32 drc_config_ext_type[EXT_COUNT_MAX]; WORD32 ext_bit_size[EXT_COUNT_MAX-1]; - + WORD32 parametric_drc_present; ia_drc_coeff_parametric_drc_struct str_drc_coeff_param_drc; WORD32 parametric_drc_instructions_count; @@ -579,7 +579,7 @@ typedef struct ia_drc_config{ WORD32 dwnmix_instructions_count; WORD32 drc_coefficients_drc_count; WORD32 drc_instructions_uni_drc_count; - WORD32 drc_instructions_count_plus; + WORD32 drc_instructions_count_plus; WORD32 drc_description_basic_present; WORD32 drc_coefficients_basic_count; WORD32 drc_instructions_basic_count; @@ -641,16 +641,16 @@ typedef struct { WORD32 drc_frame_size; WORD32 num_gain_values_max_default; WORD32 delay_mode; - WORD32 lfe_channel_map_count; + WORD32 lfe_channel_map_count; WORD32 lfe_channel_map[MAX_CHANNEL_COUNT]; } ia_drc_params_bs_dec_struct; typedef struct ia_drc_bits_dec_struct { - + ia_tables_struct tables_default; ia_drc_params_bs_dec_struct ia_drc_params_struct; - + }ia_drc_bits_dec_struct; diff --git a/decoder/drc_src/impd_drc_tables.c b/decoder/drc_src/impd_drc_tables.c index 8a9481a..849c300 100644 --- a/decoder/drc_src/impd_drc_tables.c +++ b/decoder/drc_src/impd_drc_tables.c @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #include #include @@ -26,7 +26,7 @@ #include "impd_drc_struct.h" #include "impd_drc_filter_bank.h" #include "impd_drc_rom.h" - + WORD32 impd_init_tbls(const WORD32 num_gain_max_values, ia_tables_struct* str_tables) { @@ -74,8 +74,8 @@ impd_gen_delta_time_code_tbl (const WORD32 num_gain_max_values, delta_time_code_tbl_item[0].size = -1; delta_time_code_tbl_item[0].code = -1; - delta_time_code_tbl_item[0].value = -1; - + delta_time_code_tbl_item[0].value = -1; + delta_time_code_tbl_item[1].size = 2; delta_time_code_tbl_item[1].code = 0x0; delta_time_code_tbl_item[1].value = 1; @@ -114,7 +114,7 @@ impd_get_delta_tmin (const WORD32 sampling_rate) while (result <= lowerBound) result = result << 1; return result; } - + diff --git a/decoder/drc_src/impd_drc_tables.h b/decoder/drc_src/impd_drc_tables.h index c207b56..c9a7b4a 100644 --- a/decoder/drc_src/impd_drc_tables.h +++ b/decoder/drc_src/impd_drc_tables.h @@ -1,42 +1,42 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_TABLES_H #define IMPD_DRC_TABLES_H const ia_filter_bank_params_struct normal_cross_freq[FILTER_BANK_PARAMETER_COUNT] = { - {2.0f/1024.0f, 0.0000373252f, 0.9913600345f}, - {3.0f/1024.0f, 0.0000836207f, 0.9870680830f}, - {4.0f/1024.0f, 0.0001480220f, 0.9827947083f}, - {5.0f/1024.0f, 0.0002302960f, 0.9785398263f}, - {6.0f/1024.0f, 0.0003302134f, 0.9743033527f}, - {2.0f/256.0f, 0.0005820761f, 0.9658852897f}, - {3.0f/256.0f, 0.0012877837f, 0.9492662926f}, - {2.0f/128.0f, 0.0022515827f, 0.9329321561f}, - {3.0f/128.0f, 0.0049030350f, 0.9010958535f}, - {2.0f/64.0f, 0.0084426929f, 0.8703307793f}, - {3.0f/64.0f, 0.0178631928f, 0.8118317459f}, - {2.0f/32.0f, 0.0299545822f, 0.7570763753f}, - {3.0f/32.0f, 0.0604985076f, 0.6574551915f}, - {2.0f/16.0f, 0.0976310729f, 0.5690355937f}, - {3.0f/16.0f, 0.1866943331f, 0.4181633458f}, - {2.0f/8.0f, 0.2928932188f, 0.2928932188f}, + {2.0f/1024.0f, 0.0000373252f, 0.9913600345f}, + {3.0f/1024.0f, 0.0000836207f, 0.9870680830f}, + {4.0f/1024.0f, 0.0001480220f, 0.9827947083f}, + {5.0f/1024.0f, 0.0002302960f, 0.9785398263f}, + {6.0f/1024.0f, 0.0003302134f, 0.9743033527f}, + {2.0f/256.0f, 0.0005820761f, 0.9658852897f}, + {3.0f/256.0f, 0.0012877837f, 0.9492662926f}, + {2.0f/128.0f, 0.0022515827f, 0.9329321561f}, + {3.0f/128.0f, 0.0049030350f, 0.9010958535f}, + {2.0f/64.0f, 0.0084426929f, 0.8703307793f}, + {3.0f/64.0f, 0.0178631928f, 0.8118317459f}, + {2.0f/32.0f, 0.0299545822f, 0.7570763753f}, + {3.0f/32.0f, 0.0604985076f, 0.6574551915f}, + {2.0f/16.0f, 0.0976310729f, 0.5690355937f}, + {3.0f/16.0f, 0.1866943331f, 0.4181633458f}, + {2.0f/8.0f, 0.2928932188f, 0.2928932188f}, }; #endif diff --git a/decoder/drc_src/impd_drc_uni_bitstream_dec_api.h b/decoder/drc_src/impd_drc_uni_bitstream_dec_api.h index b602072..1c0bfe3 100644 --- a/decoder/drc_src/impd_drc_uni_bitstream_dec_api.h +++ b/decoder/drc_src/impd_drc_uni_bitstream_dec_api.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_BITSTREAM_DEC_API_H #define IMPD_DRC_UNI_BITSTREAM_DEC_API_H @@ -25,38 +25,38 @@ WORD32 impd_init_drc_bitstream_dec(ia_drc_bits_dec_struct* p_uni_drc_bs_dec_stru WORD32 sample_rate, WORD32 frame_size, WORD32 delay_mode, - WORD32 lfe_channel_map_count, + WORD32 lfe_channel_map_count, WORD32* lfe_channel_map); - + WORD32 impd_process_drc_bitstream_dec(ia_drc_bits_dec_struct* p_uni_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_config* pstr_drc_config, ia_drc_loudness_info_set_struct* pstr_loudness_info, UWORD8* bitstream_config, WORD32 num_bytes, WORD32 num_bits_offset, WORD32* num_bits_read); - + WORD32 impd_process_drc_bitstream_dec_config(ia_drc_bits_dec_struct* p_uni_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_config* pstr_drc_config, UWORD8* bitstream_config, WORD32 num_bytes); WORD32 impd_process_drc_bitstream_dec_gain(ia_drc_bits_dec_struct* p_uni_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_config* pstr_drc_config, ia_drc_gain_struct* pstr_drc_gain, UWORD8* bitstream_gain, WORD32 num_bytes, WORD32 num_bits_offset, WORD32* num_bits_read); - + WORD32 impd_process_drc_bitstream_dec_loudness_info_set(ia_drc_bits_dec_struct* p_uni_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, - ia_drc_loudness_info_set_struct* pstr_loudness_info, + ia_bit_buf_struct* it_bit_buff, + ia_drc_loudness_info_set_struct* pstr_loudness_info, UWORD8* bitstream_loudness, - WORD32 num_bytes_loudness + WORD32 num_bytes_loudness ); #endif diff --git a/decoder/drc_src/impd_drc_uni_common.h b/decoder/drc_src/impd_drc_uni_common.h index ae64e09..e59af5d 100644 --- a/decoder/drc_src/impd_drc_uni_common.h +++ b/decoder/drc_src/impd_drc_uni_common.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_COMMON_H #define IMPD_DRC_UNI_COMMON_H @@ -28,40 +28,40 @@ extern "C" #define AMD1_SYNTAX 0 #define MPEG_D_DRC_EXTENSION_V1 0 #define AMD1_PARAMETRIC_LIMITER 0 - + #define MPEG_H_SYNTAX 0 - -#define EQ_IS_SUPPORTED 1 - + +#define EQ_IS_SUPPORTED 1 + #define MEASURE_AVERAGE_BITRATE 0 #define DEBUG_NODES 0 -#define DRC_GAIN_DEBUG_FILE 0 -#define DEBUG_BITSTREAM 0 -#define DEBUG_DRC_SELECTION 0 -#define DEBUG_WARNINGS 0 +#define DRC_GAIN_DEBUG_FILE 0 +#define DEBUG_BITSTREAM 0 +#define DEBUG_DRC_SELECTION 0 +#define DEBUG_WARNINGS 0 #define ENABLE_ADDITIONAL_TESTS 1 #define SPEAKER_POS_COUNT_MAX 128 -#define DOWNMIX_COEFF_COUNT_MAX 32*32 +#define DOWNMIX_COEFF_COUNT_MAX 32*32 #define MAX_CHANNEL_COUNT 128 -#define BAND_COUNT_MAX 8 -#define SEQUENCE_COUNT_MAX 24 +#define BAND_COUNT_MAX 8 +#define SEQUENCE_COUNT_MAX 24 #define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX #define MEASUREMENT_COUNT_MAX 16 #define DOWNMIX_INSTRUCTION_COUNT_MAX 16 #define DRC_COEFF_COUNT_MAX 8 -#define DRC_INSTRUCTIONS_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) -#define LOUDNESS_INFO_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) -#define AUDIO_CODEC_FRAME_SIZE_MAX 4096 -#define DRC_CODEC_FRAME_SIZE_MAX (AUDIO_CODEC_FRAME_SIZE_MAX/8) +#define DRC_INSTRUCTIONS_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) +#define LOUDNESS_INFO_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) +#define AUDIO_CODEC_FRAME_SIZE_MAX 4096 +#define DRC_CODEC_FRAME_SIZE_MAX (AUDIO_CODEC_FRAME_SIZE_MAX/8) #define NODE_COUNT_MAX DRC_CODEC_FRAME_SIZE_MAX #define CHANNEL_GROUP_COUNT_MAX SEQUENCE_COUNT_MAX #define SUB_DRC_COUNT 4 #define SEL_DRC_COUNT 3 #define DOWNMIX_ID_COUNT_MAX 8 -#define MAX_SIGNAL_DELAY 4500 - +#define MAX_SIGNAL_DELAY 4500 + #define DELAY_MODE_REGULAR_DELAY 0 #define DELAY_MODE_LOW_DELAY 1 @@ -69,7 +69,7 @@ extern "C" #define FEATURE_REQUEST_COUNT_MAX 10 #define EFFECT_TYPE_REQUEST_COUNT_MAX 10 - + #define SELECTION_CANDIDATE_COUNT_MAX 32 #define PROC_COMPLETE 1 @@ -85,11 +85,11 @@ extern "C" #define ID_FOR_NO_DRC 0x0 #define ID_FOR_ANY_DRC 0x3F #define ID_FOR_ANY_EQ 0x3F - + #define LOCATION_MP4_INSTREAM_UNIDRC 0x1 #define LOCATION_MP4_DYN_RANGE_INFO 0x2 #define LOCATION_MP4_COMPRESSION_VALUE 0x3 -#define LOCATION_SELECTED LOCATION_MP4_INSTREAM_UNIDRC +#define LOCATION_SELECTED LOCATION_MP4_INSTREAM_UNIDRC #define AUDIO_CODEC_SUBBAND_COUNT_MAX 256 @@ -97,19 +97,19 @@ extern "C" #define SUBBAND_DOMAIN_MODE_QMF64 1 #define SUBBAND_DOMAIN_MODE_QMF71 2 #define SUBBAND_DOMAIN_MODE_STFT256 3 - + #define AUDIO_CODEC_SUBBAND_COUNT_QMF64 64 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64 64 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF64 320 - + #define AUDIO_CODEC_SUBBAND_COUNT_QMF71 71 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71 64 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF71 320+384 - + #define AUDIO_CODEC_SUBBAND_COUNT_STFT256 256 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256 256 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_STFT256 256 - + #define MAX_NUM_DOWNMIX_ID_REQUESTS 15 #define MAX_NUM_DRC_FEATURE_REQUESTS 7 #define MAX_NUM_DRC_EFFECT_TYPE_REQUESTS 15 @@ -121,12 +121,12 @@ extern "C" #define UNIDRCCONFEXT_TERM 0x0 #define UNIDRCINTERFACEEXT_TERM 0x0 - - - + + + #define MAXPACKETLOSSTIME 2.5f -#define SLOPE_FACTOR_DB_TO_LINEAR 0.1151f +#define SLOPE_FACTOR_DB_TO_LINEAR 0.1151f #ifndef min #define min(a, b) ((a) < (b) ? (a) : (b)) @@ -138,17 +138,17 @@ extern "C" #ifndef bool #define bool WORD32 #endif - + typedef struct ia_drc_sel_proc_output_struct -{ +{ FLOAT32 output_peak_level_db; FLOAT32 loudness_normalization_gain_db; FLOAT32 output_loudness; - + WORD32 sel_drc_set_ids[SUB_DRC_COUNT]; WORD32 sel_downmix_ids[SUB_DRC_COUNT]; WORD32 num_sel_drc_sets; - + WORD32 active_downmix_id; WORD32 base_channel_count; WORD32 target_channel_count; @@ -159,7 +159,7 @@ typedef struct ia_drc_sel_proc_output_struct FLOAT32 boost; FLOAT32 compress; WORD32 drc_characteristic_target; - + } ia_drc_sel_proc_output_struct; diff --git a/decoder/drc_src/impd_drc_uni_dec.h b/decoder/drc_src/impd_drc_uni_dec.h index 878a3bc..3370068 100644 --- a/decoder/drc_src/impd_drc_uni_dec.h +++ b/decoder/drc_src/impd_drc_uni_dec.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_DEC_H #define IMPD_DRC_UNI_DEC_H @@ -28,7 +28,7 @@ extern "C" WORD32 impd_select_drc_coefficients(ia_drc_config* drc_config, ia_uni_drc_coeffs_struct** drc_coefficients_drc, WORD32* drc_coefficients_selected); - + WORD32 impd_init_selected_drc_set(ia_drc_config* drc_config, ia_drc_params_struct* ia_drc_params_struct, WORD32 audio_num_chan, diff --git a/decoder/drc_src/impd_drc_uni_eq.h b/decoder/drc_src/impd_drc_uni_eq.h index 963897a..d83521f 100644 --- a/decoder/drc_src/impd_drc_uni_eq.h +++ b/decoder/drc_src/impd_drc_uni_eq.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_EQ_H #define IMPD_DRC_UNI_EQ_H diff --git a/decoder/drc_src/impd_drc_uni_gain_dec.h b/decoder/drc_src/impd_drc_uni_gain_dec.h index c01cd6e..1137db4 100644 --- a/decoder/drc_src/impd_drc_uni_gain_dec.h +++ b/decoder/drc_src/impd_drc_uni_gain_dec.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_GAIN_DEC_H #define IMPD_DRC_UNI_GAIN_DEC_H diff --git a/decoder/drc_src/impd_drc_uni_interface.h b/decoder/drc_src/impd_drc_uni_interface.h index 54ba750..222a3e3 100644 --- a/decoder/drc_src/impd_drc_uni_interface.h +++ b/decoder/drc_src/impd_drc_uni_interface.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_INTERFACE_H #define IMPD_DRC_UNI_INTERFACE_H @@ -60,7 +60,7 @@ typedef struct { WORD32 album_mode; WORD32 peak_limiter; WORD32 change_loudness_deviation_max; - WORD32 loudness_deviation_max; + WORD32 loudness_deviation_max; WORD32 change_loudness_measur_method; WORD32 loudness_measurement_method; WORD32 change_loudness_measur_system; diff --git a/decoder/drc_src/impd_drc_uni_loud_eq.h b/decoder/drc_src/impd_drc_uni_loud_eq.h index 2c3d3f0..4f85f81 100644 --- a/decoder/drc_src/impd_drc_uni_loud_eq.h +++ b/decoder/drc_src/impd_drc_uni_loud_eq.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_LOUD_EQ_H #define IMPD_DRC_UNI_LOUD_EQ_H @@ -25,7 +25,7 @@ extern "C" { #endif - + #ifdef __cplusplus } #endif diff --git a/decoder/drc_src/impd_drc_uni_multi_band.h b/decoder/drc_src/impd_drc_uni_multi_band.h index 7eb677e..0b60ee6 100644 --- a/decoder/drc_src/impd_drc_uni_multi_band.h +++ b/decoder/drc_src/impd_drc_uni_multi_band.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_MULTI_BAND_H #define IMPD_DRC_UNI_MULTI_BAND_H diff --git a/decoder/drc_src/impd_drc_uni_parser.h b/decoder/drc_src/impd_drc_uni_parser.h index f7c7f19..7713304 100644 --- a/decoder/drc_src/impd_drc_uni_parser.h +++ b/decoder/drc_src/impd_drc_uni_parser.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_PARSER_H #define IMPD_DRC_UNI_PARSER_H @@ -34,7 +34,7 @@ impd_parse_loudness_info(ia_bit_buf_struct* it_bit_buff, WORD32 impd_parse_loudness_info_set_ext(ia_bit_buf_struct* it_bit_buff, ia_drc_loudness_info_set_struct* loudness_info_set); - + WORD32 impd_sel_drc_coeff(ia_drc_config* drc_config, WORD32 location, @@ -73,10 +73,10 @@ impd_parse_dwnmix_instructions(ia_bit_buf_struct* it_bit_buff, ia_channel_layout_struct* channel_layout, ia_downmix_instructions_struct* dwnmix_instructions); - + WORD32 impd_parse_drc_config( - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_params_bs_dec_struct* ia_drc_params_struct, ia_drc_config* drc_config ); @@ -88,7 +88,7 @@ impd_parse_loudness_info_set(ia_bit_buf_struct* it_bit_buff, WORD32 impd_parse_drc_gain_sequence( - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, ia_gain_set_params_struct* gain_set_params, ia_drc_gain_sequence_struct* drc_gain_sequence); @@ -98,7 +98,7 @@ impd_parse_uni_drc_gain_ext(ia_bit_buf_struct* it_bit_buff, ia_uni_drc_gain_ext_struct* uni_drc_gain_ext); WORD32 impd_drc_uni_gain_read( - ia_bit_buf_struct* it_bit_buff, + ia_bit_buf_struct* it_bit_buff, ia_drc_bits_dec_struct *pstr_drc_uni_bs_dec, ia_drc_config* drc_config, ia_drc_gain_struct* pstr_uni_drc_gain); diff --git a/decoder/drc_src/impd_drc_uni_process_audio.h b/decoder/drc_src/impd_drc_uni_process_audio.h index 07b2749..da57588 100644 --- a/decoder/drc_src/impd_drc_uni_process_audio.h +++ b/decoder/drc_src/impd_drc_uni_process_audio.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_PROCESS_AUDIO_H #define IMPD_DRC_UNI_PROCESS_AUDIO_H diff --git a/decoder/drc_src/impd_drc_uni_sel_proc_drc_set_sel.h b/decoder/drc_src/impd_drc_uni_sel_proc_drc_set_sel.h index 92a158f..7b31d5a 100644 --- a/decoder/drc_src/impd_drc_uni_sel_proc_drc_set_sel.h +++ b/decoder/drc_src/impd_drc_uni_sel_proc_drc_set_sel.h @@ -1,33 +1,33 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_SEL_PROC_DRC_SET_SEL_H #define IMPD_DRC_UNI_SEL_PROC_DRC_SET_SEL_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - - + + #define SELECTION_FLAG_DRC_TARGET_LOUDNESS_MATCH (1<<0) #define SELECTION_FLAG_EXPLICIT_PEAK_INFO_PRESENT (1<<1) - + typedef struct { WORD32 drc_instructions_index; WORD32 downmix_id_request_index; @@ -42,7 +42,7 @@ typedef struct { WORD32 impd_validate_requested_drc_feature(ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct); - + WORD32 impd_map_requested_effect_bit_idx(WORD32 requested_effect_type, WORD32* effect_bit_idx); @@ -65,7 +65,7 @@ impd_get_dependent_drc_instructions(const ia_drc_config* drc_config, const ia_drc_instructions_struct* str_drc_instruction_str, ia_drc_instructions_struct** ppstr_drc_instructions_dependent); - + WORD32 impd_select_drcs_without_compr_effects (ia_drc_config* pstr_drc_config, WORD32* match_found_flag, @@ -90,8 +90,8 @@ impd_match_effect_types(ia_drc_config* pstr_drc_config, WORD32 impd_match_dynamic_range(ia_drc_config* pstr_drc_config, ia_drc_loudness_info_set_struct* pstr_loudness_info, - ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, - WORD32 num_drc_requests, + ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params_struct, + WORD32 num_drc_requests, WORD32* selection_candidate_count, ia_selection_candidate_info_struct* selection_candidate_info); @@ -107,7 +107,7 @@ impd_match_drc_characteristic(ia_drc_config* pstr_drc_config, WORD32 requested_drc_characteristic, WORD32* selection_candidate_count, ia_selection_candidate_info_struct* selection_candidate_info); - + VOID impd_select_drc_coeff3(ia_drc_config* drc_config, ia_uni_drc_coeffs_struct** str_p_loc_drc_coefficients_uni_drc); @@ -128,11 +128,11 @@ WORD32 impd_drc_set_final_selection(ia_drc_config* pstr_drc_config, WORD32 impd_match_eq_set_purpose(ia_drc_config* drc_config, WORD32 eq_set_purpose_requested, WORD32* eq_set_id_valid_flag, - WORD32* selection_candidate_count, - ia_selection_candidate_info_struct* selection_candidate_info, - ia_selection_candidate_info_struct* selection_candidate_info_step_2 - ); - + WORD32* selection_candidate_count, + ia_selection_candidate_info_struct* selection_candidate_info, + ia_selection_candidate_info_struct* selection_candidate_info_step_2 + ); + WORD32 impd_select_drc_set(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, WORD32* drc_set_id_selected diff --git a/decoder/drc_src/impd_drc_uni_sel_proc_init.h b/decoder/drc_src/impd_drc_uni_sel_proc_init.h index 82565b1..5603008 100644 --- a/decoder/drc_src/impd_drc_uni_sel_proc_init.h +++ b/decoder/drc_src/impd_drc_uni_sel_proc_init.h @@ -1,29 +1,29 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_SEL_PROC_INIT_H #define IMPD_DRC_UNI_SEL_PROC_INIT_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - + WORD32 impd_drc_sel_proc_init_dflt(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc); @@ -34,7 +34,7 @@ impd_drc_sel_proc_init_sel_proc_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_p WORD32 impd_drc_sel_proc_init_interface_params(ia_drc_sel_pro_struct* pstr_drc_uni_sel_proc, ia_drc_interface_struct* pstr_drc_interface); - + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/decoder/drc_src/impd_drc_uni_sel_proc_loudness_control.h b/decoder/drc_src/impd_drc_uni_sel_proc_loudness_control.h index 95b8e8a..057d338 100644 --- a/decoder/drc_src/impd_drc_uni_sel_proc_loudness_control.h +++ b/decoder/drc_src/impd_drc_uni_sel_proc_loudness_control.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_SEL_PROC_LOUDNESS_CONTROL_H #define IMPD_DRC_UNI_SEL_PROC_LOUDNESS_CONTROL_H diff --git a/decoder/drc_src/impd_drc_uni_shape_filter.h b/decoder/drc_src/impd_drc_uni_shape_filter.h index ac38099..17cb04a 100644 --- a/decoder/drc_src/impd_drc_uni_shape_filter.h +++ b/decoder/drc_src/impd_drc_uni_shape_filter.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_SHAPE_FILTER_H #define IMPD_DRC_UNI_SHAPE_FILTER_H diff --git a/decoder/drc_src/impd_drc_uni_tables.h b/decoder/drc_src/impd_drc_uni_tables.h index 3f3fc35..89b864b 100644 --- a/decoder/drc_src/impd_drc_uni_tables.h +++ b/decoder/drc_src/impd_drc_uni_tables.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2015 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2015 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_DRC_UNI_TABLES_H #define IMPD_DRC_UNI_TABLES_H @@ -49,7 +49,7 @@ typedef struct { typedef struct { ia_delta_time_code_table_entry_struct delta_time_code_table[N_DELTA_TIME_CODE_TABLE_ENTRIES_MAX]; } ia_tables_struct; - + typedef struct { FLOAT32 in_out_ratio; FLOAT32 exp_lo; @@ -65,7 +65,7 @@ typedef struct { WORD32 coordinateCount; ia_characteristic_node_coordinate_struct characteristicNodeCoordinate[5]; } ia_cicp_node_characteristic_param; - + WORD32 impd_init_tbls(const WORD32 num_gain_max_values, ia_tables_struct* str_tables); diff --git a/decoder/drc_src/impd_error_handler.h b/decoder/drc_src/impd_error_handler.h index 2ac84c3..6de2968 100644 --- a/decoder/drc_src/impd_error_handler.h +++ b/decoder/drc_src/impd_error_handler.h @@ -1,21 +1,21 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #ifndef IMPD_ERROR_HANDLER_H @@ -34,25 +34,25 @@ /*****************************************************************************/ /* Constant hash defines */ /*****************************************************************************/ -#define IA_ERROR_NON_FATAL_IDX 0x0 -#define IA_ERROR_FATAL_IDX 0x1 +#define IA_ERROR_NON_FATAL_IDX 0x0 +#define IA_ERROR_FATAL_IDX 0x1 -#define IA_ERROR_CLASS_0 0x0 -#define IA_ERROR_CLASS_1 0x1 -#define IA_ERROR_CLASS_2 0x2 -#define IA_ERROR_CLASS_3 0x3 -#define IA_ERROR_CLASS_4 0x4 -#define IA_ERROR_CLASS_5 0x5 -#define IA_ERROR_CLASS_6 0x6 -#define IA_ERROR_CLASS_7 0x7 -#define IA_ERROR_CLASS_8 0x8 -#define IA_ERROR_CLASS_9 0x9 -#define IA_ERROR_CLASS_A 0xA -#define IA_ERROR_CLASS_B 0xB -#define IA_ERROR_CLASS_C 0xC -#define IA_ERROR_CLASS_D 0xD -#define IA_ERROR_CLASS_E 0xE -#define IA_ERROR_CLASS_F 0xF +#define IA_ERROR_CLASS_0 0x0 +#define IA_ERROR_CLASS_1 0x1 +#define IA_ERROR_CLASS_2 0x2 +#define IA_ERROR_CLASS_3 0x3 +#define IA_ERROR_CLASS_4 0x4 +#define IA_ERROR_CLASS_5 0x5 +#define IA_ERROR_CLASS_6 0x6 +#define IA_ERROR_CLASS_7 0x7 +#define IA_ERROR_CLASS_8 0x8 +#define IA_ERROR_CLASS_9 0x9 +#define IA_ERROR_CLASS_A 0xA +#define IA_ERROR_CLASS_B 0xB +#define IA_ERROR_CLASS_C 0xC +#define IA_ERROR_CLASS_D 0xD +#define IA_ERROR_CLASS_E 0xE +#define IA_ERROR_CLASS_F 0xF /* each module, hence, needs to copy the following structure */ /* the first index is for FATAL/NONFATAL */ @@ -65,9 +65,9 @@ /*****************************************************************************/ typedef struct { - pWORD8 pb_module_name; - pWORD8 ppb_class_names[16]; - WORD8 **ppppb_error_msg_pointers[2][16]; + pWORD8 pb_module_name; + pWORD8 ppb_class_names[16]; + WORD8 **ppppb_error_msg_pointers[2][16]; } ia_error_info_struct; /*****************************************************************************/ @@ -75,8 +75,8 @@ typedef struct /*****************************************************************************/ /* this error handler maps the code generated by a module to a error string */ /* pb_context is a string to specify where the module broke */ -IA_ERRORCODE ia_error_handler(ia_error_info_struct *p_mod_err_info, - WORD8 *pb_context, IA_ERRORCODE code); +IA_ERRORCODE ia_error_handler(ia_error_info_struct *p_mod_err_info, + WORD8 *pb_context, IA_ERRORCODE code); /*****************************************************************************/ /* Macro functions */ @@ -84,11 +84,11 @@ IA_ERRORCODE ia_error_handler(ia_error_info_struct *p_mod_err_info, /* the following macro does a line job of returning back to the parent */ /* in case a fatal error occurs after calling the errorhandler */ #define _IA_HANDLE_ERROR(p_mod_err_info, context, e) \ - if((e) != IA_NO_ERROR) \ - { \ - ia_error_handler((p_mod_err_info), (context), (e)); \ - if((e) & IA_FATAL_ERROR) \ - return (e); \ - } - + if((e) != IA_NO_ERROR) \ + { \ + ia_error_handler((p_mod_err_info), (context), (e)); \ + if((e) & IA_FATAL_ERROR) \ + return (e); \ + } + #endif diff --git a/decoder/drc_src/impd_error_standards.h b/decoder/drc_src/impd_error_standards.h index 2edc0a6..8bce654 100644 --- a/decoder/drc_src/impd_error_standards.h +++ b/decoder/drc_src/impd_error_standards.h @@ -1,21 +1,21 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #ifndef IMPD_ERROR_STANDARDS_H @@ -33,8 +33,8 @@ typedef WORD32 IA_ERRORCODE; /*****************************************************************************/ /* Constant hash defines */ /*****************************************************************************/ -#define IA_NO_ERROR 0x00000000 +#define IA_NO_ERROR 0x00000000 /* error handling 'AND' definition */ -#define IA_FATAL_ERROR 0x80000000 +#define IA_FATAL_ERROR 0x80000000 #endif /* __IMPD_ERROR_STANDARDS_H__ */ diff --git a/decoder/drc_src/impd_memory_standards.h b/decoder/drc_src/impd_memory_standards.h index 14b8a52..a7ef91c 100644 --- a/decoder/drc_src/impd_memory_standards.h +++ b/decoder/drc_src/impd_memory_standards.h @@ -1,21 +1,21 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #ifndef IMPD_MEMORY_STANDARDS_H @@ -25,85 +25,85 @@ /* Type definitions */ /*****************************************************************************/ /* standard memory table descriptor for libraries */ -typedef struct +typedef struct { - UWORD32 ui_size; /* size of the memory in bytes */ - UWORD32 ui_alignment; /* alignment in bytes */ - UWORD32 ui_type; /* type of memory */ - UWORD32 ui_placement[2]; /* 64 bit placement info */ - UWORD32 ui_priority; /* the importance for placement */ - UWORD32 ui_placed[2]; /* the o_red location for placement */ + UWORD32 ui_size; /* size of the memory in bytes */ + UWORD32 ui_alignment; /* alignment in bytes */ + UWORD32 ui_type; /* type of memory */ + UWORD32 ui_placement[2]; /* 64 bit placement info */ + UWORD32 ui_priority; /* the importance for placement */ + UWORD32 ui_placed[2]; /* the o_red location for placement */ }ia_mem_info_struct; /*****************************************************************************/ /* Constant hash defines */ /*****************************************************************************/ /* when you don't need alignment, pass this to memory library */ -#define IA_MEM_NO_ALIGN 0x01 +#define IA_MEM_NO_ALIGN 0x01 /* ittiam standard memory types */ /* to be used inter frames */ -#define IA_MEMTYPE_PERSIST 0x00 +#define IA_MEMTYPE_PERSIST 0x00 /* read write, to be used intra frames */ -#define IA_MEMTYPE_SCRATCH 0x01 +#define IA_MEMTYPE_SCRATCH 0x01 /* read only memory, intra frame */ -#define IA_MEMTYPE_INPUT 0x02 +#define IA_MEMTYPE_INPUT 0x02 /* read-write memory, for usable output, intra frame */ -#define IA_MEMTYPE_OUTPUT 0x03 +#define IA_MEMTYPE_OUTPUT 0x03 /* readonly memory, inter frame */ -#define IA_MEMTYPE_TABLE 0x04 +#define IA_MEMTYPE_TABLE 0x04 /* input buffer before mem tabs allocation */ -#define IA_MEMTYPE_PRE_FRAME_INPUT 0x05 +#define IA_MEMTYPE_PRE_FRAME_INPUT 0x05 /* input buffer before mem tabs allocation */ -#define IA_MEMTYPE_PRE_FRAME_SCRATCH 0x06 +#define IA_MEMTYPE_PRE_FRAME_SCRATCH 0x06 /* for local variables */ -#define IA_MEMTYPE_AUTO_VAR 0x80 +#define IA_MEMTYPE_AUTO_VAR 0x80 /* ittiam standard memory priorities */ -#define IA_MEMPRIORITY_ANYWHERE 0x00 -#define IA_MEMPRIORITY_LOWEST 0x01 -#define IA_MEMPRIORITY_LOW 0x02 -#define IA_MEMPRIORITY_NORM 0x03 -#define IA_MEMPRIORITY_ABOVE_NORM 0x04 -#define IA_MEMPRIORITY_HIGH 0x05 -#define IA_MEMPRIORITY_HIGHER 0x06 -#define IA_MEMPRIORITY_CRITICAL 0x07 +#define IA_MEMPRIORITY_ANYWHERE 0x00 +#define IA_MEMPRIORITY_LOWEST 0x01 +#define IA_MEMPRIORITY_LOW 0x02 +#define IA_MEMPRIORITY_NORM 0x03 +#define IA_MEMPRIORITY_ABOVE_NORM 0x04 +#define IA_MEMPRIORITY_HIGH 0x05 +#define IA_MEMPRIORITY_HIGHER 0x06 +#define IA_MEMPRIORITY_CRITICAL 0x07 /* ittiam standard memory placements */ /* placement is defined by 64 bits */ -#define IA_MEMPLACE_FAST_RAM_0 0x000001 -#define IA_MEMPLACE_FAST_RAM_1 0x000002 -#define IA_MEMPLACE_FAST_RAM_2 0x000004 -#define IA_MEMPLACE_FAST_RAM_3 0x000008 -#define IA_MEMPLACE_FAST_RAM_4 0x000010 -#define IA_MEMPLACE_FAST_RAM_5 0x000020 -#define IA_MEMPLACE_FAST_RAM_6 0x000040 -#define IA_MEMPLACE_FAST_RAM_7 0x000080 +#define IA_MEMPLACE_FAST_RAM_0 0x000001 +#define IA_MEMPLACE_FAST_RAM_1 0x000002 +#define IA_MEMPLACE_FAST_RAM_2 0x000004 +#define IA_MEMPLACE_FAST_RAM_3 0x000008 +#define IA_MEMPLACE_FAST_RAM_4 0x000010 +#define IA_MEMPLACE_FAST_RAM_5 0x000020 +#define IA_MEMPLACE_FAST_RAM_6 0x000040 +#define IA_MEMPLACE_FAST_RAM_7 0x000080 -#define IA_MEMPLACE_INT_RAM_0 0x000100 -#define IA_MEMPLACE_INT_RAM_1 0x000200 -#define IA_MEMPLACE_INT_RAM_2 0x000400 -#define IA_MEMPLACE_INT_RAM_3 0x000800 -#define IA_MEMPLACE_INT_RAM_4 0x001000 -#define IA_MEMPLACE_INT_RAM_5 0x002000 -#define IA_MEMPLACE_INT_RAM_6 0x004000 -#define IA_MEMPLACE_INT_RAM_7 0x008000 +#define IA_MEMPLACE_INT_RAM_0 0x000100 +#define IA_MEMPLACE_INT_RAM_1 0x000200 +#define IA_MEMPLACE_INT_RAM_2 0x000400 +#define IA_MEMPLACE_INT_RAM_3 0x000800 +#define IA_MEMPLACE_INT_RAM_4 0x001000 +#define IA_MEMPLACE_INT_RAM_5 0x002000 +#define IA_MEMPLACE_INT_RAM_6 0x004000 +#define IA_MEMPLACE_INT_RAM_7 0x008000 -#define IA_MEMPLACE_EXT_RAM_0 0x010000 -#define IA_MEMPLACE_EXT_RAM_1 0x020000 -#define IA_MEMPLACE_EXT_RAM_2 0x040000 -#define IA_MEMPLACE_EXT_RAM_3 0x080000 -#define IA_MEMPLACE_EXT_RAM_4 0x100000 -#define IA_MEMPLACE_EXT_RAM_5 0x200000 -#define IA_MEMPLACE_EXT_RAM_6 0x400000 -#define IA_MEMPLACE_EXT_RAM_7 0x800000 +#define IA_MEMPLACE_EXT_RAM_0 0x010000 +#define IA_MEMPLACE_EXT_RAM_1 0x020000 +#define IA_MEMPLACE_EXT_RAM_2 0x040000 +#define IA_MEMPLACE_EXT_RAM_3 0x080000 +#define IA_MEMPLACE_EXT_RAM_4 0x100000 +#define IA_MEMPLACE_EXT_RAM_5 0x200000 +#define IA_MEMPLACE_EXT_RAM_6 0x400000 +#define IA_MEMPLACE_EXT_RAM_7 0x800000 -#define IA_MEMPLACE_DONTCARE_H 0xFFFFFFFF -#define IA_MEMPLACE_DONTCARE_L 0xFFFFFFFF +#define IA_MEMPLACE_DONTCARE_H 0xFFFFFFFF +#define IA_MEMPLACE_DONTCARE_L 0xFFFFFFFF /* the simple common PC RAM */ -#define IA_PC_RAM_H 0x00000000 -#define IA_PC_RAM_L IA_MEMPLACE_EXT_RAM_0 +#define IA_PC_RAM_H 0x00000000 +#define IA_PC_RAM_L IA_MEMPLACE_EXT_RAM_0 #endif diff --git a/decoder/drc_src/impd_parametric_drc_dec.h b/decoder/drc_src/impd_parametric_drc_dec.h index abf0c72..d0ab76b 100644 --- a/decoder/drc_src/impd_parametric_drc_dec.h +++ b/decoder/drc_src/impd_parametric_drc_dec.h @@ -1,22 +1,22 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore -*/ + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore +*/ #ifndef IMPD_PARAMETRIC_DRC_DEC_H #define IMPD_PARAMETRIC_DRC_DEC_H @@ -26,18 +26,18 @@ extern "C" { #endif - -typedef struct ia_2nd_order_filt_coeff_struct_t { + +typedef struct ia_2nd_order_filt_coeff_struct_t { FLOAT32 b0, b1, b2; FLOAT32 a1, a2; } ia_2nd_order_filt_coeff_struct; -typedef struct ia_2nd_order_filt_state_struct_t { +typedef struct ia_2nd_order_filt_state_struct_t { FLOAT32 z1, z2; } ia_2nd_order_filt_state_struct; - + typedef struct ia_parametric_drc_type_ff_params_struct_t { - + WORD32 audio_num_chan; WORD32 frame_size; WORD32 sub_band_domain_mode; @@ -59,11 +59,11 @@ typedef struct ia_parametric_drc_type_ff_params_struct_t { ia_2nd_order_filt_state_struct filt_state_subband_real[MAX_CHANNEL_COUNT]; ia_2nd_order_filt_state_struct filt_state_subband_imag[MAX_CHANNEL_COUNT]; FLOAT32 ref_level_parametric_drc; - + WORD32 node_count; WORD32 node_level[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX]; WORD32 node_gain[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX]; - + FLOAT32 gain_smooth_attack_alpha_slow; FLOAT32 gain_smooth_rel_alpha_slow; FLOAT32 gain_smooth_attack_alpha_fast; @@ -74,15 +74,15 @@ typedef struct ia_parametric_drc_type_ff_params_struct_t { FLOAT32 db_level_smooth; FLOAT32 db_gain_smooth; WORD32 hold_counter; - + } ia_parametric_drc_type_ff_params_struct; - + typedef struct ia_parametric_drc_type_lim_params_struct_t { - + WORD32 audio_num_chan; WORD32 frame_size; FLOAT32 level_estim_ch_weight[MAX_CHANNEL_COUNT]; - + UWORD32 attack; FLOAT32 attack_constant; FLOAT32 release_constant; @@ -101,9 +101,9 @@ typedef struct ia_parametric_drc_type_lim_params_struct_t { UWORD32 max_buf_sec_idx; UWORD32 max_buf_sec_ctr; FLOAT64 smooth_state_0; - + } ia_parametric_drc_type_lim_params_struct; - + typedef struct ia_parametric_drc_instance_params_struct_t { WORD32 disable_paramteric_drc; WORD32 parametric_drc_type; @@ -111,8 +111,8 @@ typedef struct ia_parametric_drc_instance_params_struct_t { ia_parametric_drc_type_ff_params_struct str_parametric_drc_type_ff_params; ia_parametric_drc_type_lim_params_struct str_parametric_drc_type_lim_params; } ia_parametric_drc_instance_params_struct; - -typedef struct ia_parametric_drc_params_struct_t { + +typedef struct ia_parametric_drc_params_struct_t { WORD32 sampling_rate; WORD32 audio_num_chan; WORD32 sub_band_domain_mode; @@ -123,34 +123,34 @@ typedef struct ia_parametric_drc_params_struct_t { WORD32 parametric_drc_frame_size; WORD32 parametric_drc_look_ahead_samples_max; WORD32 reset_parametric_drc; - + WORD32 parametric_drc_instance_count; - WORD32 parametric_drc_idx[PARAM_DRC_INSTANCE_COUNT_MAX]; + WORD32 parametric_drc_idx[PARAM_DRC_INSTANCE_COUNT_MAX]; WORD32 gain_set_index[PARAM_DRC_INSTANCE_COUNT_MAX]; WORD32 dwnmix_id_from_drc_instructions[PARAM_DRC_INSTANCE_COUNT_MAX]; WORD32 channel_map[PARAM_DRC_INSTANCE_COUNT_MAX][MAX_CHANNEL_COUNT]; ia_parametric_drc_instance_params_struct str_parametric_drc_instance_params[PARAM_DRC_INSTANCE_COUNT_MAX]; - + } ia_parametric_drc_params_struct; - + WORD32 impd_init_parametric_drc( WORD32 drc_frame_size, WORD32 sampling_rate, WORD32 sub_band_domain_mode, ia_parametric_drc_params_struct* pstr_parametric_drc_params); - + WORD32 impd_init_parametric_drc_after_config(ia_drc_config* pstr_drc_config, ia_drc_loudness_info_set_struct* pstr_loudness_info, ia_parametric_drc_params_struct *pstr_parametric_drc_params, - pVOID *mem_ptr); - - + pVOID *mem_ptr); + + WORD32 impd_init_lvl_est_filt_time( WORD32 level_estim_k_weighting_type, WORD32 sampling_rate, ia_2nd_order_filt_coeff_struct* pre_filt_coeff, ia_2nd_order_filt_coeff_struct* rlb_filt_coeff); - + WORD32 impd_init_lvl_est_filt_subband( WORD32 level_estim_k_weighting_type, WORD32 sampling_rate, @@ -160,14 +160,14 @@ impd_init_lvl_est_filt_subband( WORD32 level_estim_k_weighting_type, FLOAT32 *weighting_filt, ia_2nd_order_filt_coeff_struct* filt_coeff_subband); - + WORD32 impd_parametric_ffwd_type_drc_reset(ia_parametric_drc_type_ff_params_struct* pstr_parametric_ffwd_type_drc_params); - + WORD32 impd_parametric_lim_type_drc_reset( WORD32 instance_idx, ia_parametric_drc_type_lim_params_struct* pstr_parametric_lim_type_drc_params); - + WORD32 impd_parametric_drc_instance_process (FLOAT32* audio_in_out_buf[], FLOAT32* audio_real_buff[], @@ -175,7 +175,7 @@ impd_parametric_drc_instance_process (FLOAT32* ia_parametric_drc_params_struct* pstr_parametric_drc_params, ia_parametric_drc_instance_params_struct* pstr_parametric_drc_instance_params); - + WORD32 impd_parametric_ffwd_type_drc_process(FLOAT32* audio_in_out_buf[], FLOAT32* audio_real_buff[], diff --git a/decoder/drc_src/impd_type_def.h b/decoder/drc_src/impd_type_def.h index 9916940..f77a1cb 100644 --- a/decoder/drc_src/impd_type_def.h +++ b/decoder/drc_src/impd_type_def.h @@ -1,28 +1,28 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #ifndef IMPD_TYPE_DEF_H #define IMPD_TYPE_DEF_H /****************************************************************************/ -/* types type define prefix examples bytes */ +/* types type define prefix examples bytes */ /************************ *********** ****** **************** ***** */ typedef char CHAR8 ;/* c CHAR8 c_name 1 */ typedef char * pCHAR8 ;/* pc pCHAR8 pc_nmae 1 */ @@ -30,78 +30,78 @@ typedef char * pCHAR8 ;/* pc pCHAR8 pc_nmae 1 */ typedef signed char WORD8 ;/* b WORD8 b_name 1 */ typedef signed char * pWORD8 ;/* pb pWORD8 pb_nmae 1 */ -typedef unsigned char UWORD8 ;/* ub UWORD8 ub_count 1 */ -typedef unsigned char * pUWORD8 ;/* pub pUWORD8 pub_count 1 */ +typedef unsigned char UWORD8 ;/* ub UWORD8 ub_count 1 */ +typedef unsigned char * pUWORD8 ;/* pub pUWORD8 pub_count 1 */ typedef signed short WORD16 ;/* s WORD16 s_count 2 */ typedef signed short * pWORD16 ;/* ps pWORD16 ps_count 2 */ -typedef unsigned short UWORD16 ;/* us UWORD16 us_count 2 */ -typedef unsigned short * pUWORD16;/* pus pUWORD16 pus_count 2 */ +typedef unsigned short UWORD16 ;/* us UWORD16 us_count 2 */ +typedef unsigned short * pUWORD16;/* pus pUWORD16 pus_count 2 */ typedef signed int WORD24 ;/* k WORD24 k_count 3 */ typedef signed int * pWORD24 ;/* pk pWORD24 pk_count 3 */ -typedef unsigned int UWORD24 ;/* uk UWORD24 uk_count 3 */ -typedef unsigned int * pUWORD24;/* puk pUWORD24 puk_count 3 */ +typedef unsigned int UWORD24 ;/* uk UWORD24 uk_count 3 */ +typedef unsigned int * pUWORD24;/* puk pUWORD24 puk_count 3 */ typedef signed int WORD32 ;/* i WORD32 i_count 4 */ typedef signed int * pWORD32 ;/* pi pWORD32 pi_count 4 */ -typedef unsigned int UWORD32 ;/* ui UWORD32 ui_count 4 */ -typedef unsigned int * pUWORD32;/* pui pUWORD32 pui_count 4 */ +typedef unsigned int UWORD32 ;/* ui UWORD32 ui_count 4 */ +typedef unsigned int * pUWORD32;/* pui pUWORD32 pui_count 4 */ #ifdef WIN32 #ifndef ECLIPSE -typedef signed __int64 WORD40 ;/* m WORD40 m_count 5 */ -typedef signed __int64 * pWORD40 ;/* pm pWORD40 pm_count 5 */ -typedef unsigned __int64 UWORD40 ;/* um UWORD40 um_count 5 */ -typedef unsigned __int64 * pUWORD40;/* pum pUWORD40 pum_count 5 */ +typedef signed __int64 WORD40 ;/* m WORD40 m_count 5 */ +typedef signed __int64 * pWORD40 ;/* pm pWORD40 pm_count 5 */ +typedef unsigned __int64 UWORD40 ;/* um UWORD40 um_count 5 */ +typedef unsigned __int64 * pUWORD40;/* pum pUWORD40 pum_count 5 */ -typedef signed __int64 WORD64 ;/* h WORD64 h_count 8 */ -typedef signed __int64 * pWORD64 ;/* ph pWORD64 ph_count 8 */ -typedef unsigned __int64 UWORD64 ;/* uh UWORD64 uh_count 8 */ -typedef unsigned __int64 * pUWORD64;/* puh pUWORD64 puh_count 8 */ +typedef signed __int64 WORD64 ;/* h WORD64 h_count 8 */ +typedef signed __int64 * pWORD64 ;/* ph pWORD64 ph_count 8 */ +typedef unsigned __int64 UWORD64 ;/* uh UWORD64 uh_count 8 */ +typedef unsigned __int64 * pUWORD64;/* puh pUWORD64 puh_count 8 */ #else -typedef signed long long WORD40 ;/* m WORD40 m_count 5 */ -typedef signed long long * pWORD40 ;/* pm pWORD40 pm_count 5 */ -typedef unsigned long long UWORD40 ;/* um UWORD40 um_count 5 */ -typedef unsigned long long * pUWORD40;/* pum pUWORD40 pum_count 5 */ +typedef signed long long WORD40 ;/* m WORD40 m_count 5 */ +typedef signed long long * pWORD40 ;/* pm pWORD40 pm_count 5 */ +typedef unsigned long long UWORD40 ;/* um UWORD40 um_count 5 */ +typedef unsigned long long * pUWORD40;/* pum pUWORD40 pum_count 5 */ -typedef signed long long WORD64 ;/* h WORD64 h_count 8 */ -typedef signed long long * pWORD64 ;/* ph pWORD64 ph_count 8 */ -typedef unsigned long long UWORD64 ;/* uh UWORD64 uh_count 8 */ -typedef unsigned long long * pUWORD64;/* puh pUWORD64 puh_count 8 */ +typedef signed long long WORD64 ;/* h WORD64 h_count 8 */ +typedef signed long long * pWORD64 ;/* ph pWORD64 ph_count 8 */ +typedef unsigned long long UWORD64 ;/* uh UWORD64 uh_count 8 */ +typedef unsigned long long * pUWORD64;/* puh pUWORD64 puh_count 8 */ #endif #else -typedef signed long long WORD40 ;/* m WORD40 m_count 5 */ -typedef signed long long * pWORD40 ;/* pm pWORD40 pm_count 5 */ -typedef unsigned long long UWORD40 ;/* um UWORD40 um_count 5 */ -typedef unsigned long long * pUWORD40;/* pum pUWORD40 pum_count 5 */ +typedef signed long long WORD40 ;/* m WORD40 m_count 5 */ +typedef signed long long * pWORD40 ;/* pm pWORD40 pm_count 5 */ +typedef unsigned long long UWORD40 ;/* um UWORD40 um_count 5 */ +typedef unsigned long long * pUWORD40;/* pum pUWORD40 pum_count 5 */ -typedef signed long long WORD64 ;/* h WORD64 h_count 8 */ -typedef signed long long * pWORD64 ;/* ph pWORD64 ph_count 8 */ -typedef unsigned long long UWORD64 ;/* uh UWORD64 uh_count 8 */ -typedef unsigned long long * pUWORD64;/* puh pUWORD64 puh_count 8 */ +typedef signed long long WORD64 ;/* h WORD64 h_count 8 */ +typedef signed long long * pWORD64 ;/* ph pWORD64 ph_count 8 */ +typedef unsigned long long UWORD64 ;/* uh UWORD64 uh_count 8 */ +typedef unsigned long long * pUWORD64;/* puh pUWORD64 puh_count 8 */ #endif -typedef float FLOAT32 ;/* f FLOAT32 f_count 4 */ +typedef float FLOAT32 ;/* f FLOAT32 f_count 4 */ typedef float * pFLOAT32;/* pf pFLOAT32 pf_count 4 */ -typedef double FLOAT64 ;/* d UFLOAT64 d_count 8 */ +typedef double FLOAT64 ;/* d UFLOAT64 d_count 8 */ typedef double * pFlOAT64;/* pd pFLOAT64 pd_count 8 */ -typedef void VOID ;/* v VOID v_flag 4 */ -typedef void * pVOID ;/* pv pVOID pv_flag 4 */ +typedef void VOID ;/* v VOID v_flag 4 */ +typedef void * pVOID ;/* pv pVOID pv_flag 4 */ /* variable size types: platform optimized implementation */ typedef signed int BOOL ;/* bool BOOL bool_true */ -typedef unsigned int UBOOL ;/* ubool BOOL ubool_true */ +typedef unsigned int UBOOL ;/* ubool BOOL ubool_true */ typedef signed int FLAG ;/* flag FLAG flag_false */ -typedef unsigned int UFLAG ;/* uflag FLAG uflag_false */ +typedef unsigned int UFLAG ;/* uflag FLAG uflag_false */ typedef signed int LOOPIDX ;/* lp LOOPIDX lp_index */ -typedef unsigned int ULOOPIDX;/* ulp SLOOPIDX ulp_index */ +typedef unsigned int ULOOPIDX;/* ulp SLOOPIDX ulp_index */ typedef signed int WORD ;/* lp LOOPIDX lp_index */ -typedef unsigned int UWORD ;/* ulp SLOOPIDX ulp_index */ +typedef unsigned int UWORD ;/* ulp SLOOPIDX ulp_index */ typedef LOOPIDX LOOPINDEX; /* lp LOOPIDX lp_index */ typedef ULOOPIDX ULOOPINDEX;/* ulp SLOOPIDX ulp_index */ diff --git a/decoder/ixheaacd_aac_config.h b/decoder/ixheaacd_aac_config.h index a126d1e..c55bb6b 100644 --- a/decoder/ixheaacd_aac_config.h +++ b/decoder/ixheaacd_aac_config.h @@ -26,35 +26,39 @@ #define IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MASK 0x0003 #define IA_ENHAACPLUS_DEC_CONFIG_PARAM_CHANNEL_MODE 0x0004 #define IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE 0x0005 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_EFFECT_TYPE 0x0006 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LOUDNESS 0x0007 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_LOUD_NORM 0x0008 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX 0x0006 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_OUT08KHZ 0x0007 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_OUT16KHZ 0x0008 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_TOSTEREO 0x0009 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DSAMPLE 0x000A -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMEOK 0x000B -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISMP4 0x000C -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_MAX_CHANNEL 0x000D -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_COUP_CHANNEL 0x000E -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX_STEREO 0x000F -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DISABLE_SYNC 0x0010 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_AUTO_SBR_UPSAMPLE 0x0011 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISLOAS 0x0012 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_ENABLE 0x0013 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT 0x0014 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST 0x0015 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL 0x0016 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP 0x0017 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMESIZE 0x0018 -#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_ELD_SBR_PRESENT 0x0019 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX 0x0009 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_OUT08KHZ 0x000A +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_OUT16KHZ 0x000B +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_TOSTEREO 0x000C +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DSAMPLE 0x000D +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMEOK 0x000E +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISMP4 0x000F +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_MAX_CHANNEL 0x0010 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_COUP_CHANNEL 0x0011 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DOWNMIX_STEREO 0x0012 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DISABLE_SYNC 0x0013 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_AUTO_SBR_UPSAMPLE 0x0014 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISLOAS 0x0015 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_ENABLE 0x0016 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_CUT 0x0017 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_BOOST 0x0018 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL 0x0019 +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_HEAVY_COMP 0x001A +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMESIZE 0x001B +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_ELD_SBR_PRESENT 0x001C +#define IA_ENHAACPLUS_DEC_CONFIG_PARAM_LD_TESTING 0x001D -#ifdef ENABLE_DRC -#define IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR 0x001A -#define IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_BUF_SIZES 0x001B -#define IA_ENHAACPLUS_DEC_CONFIG_NUM_ELE 0x001C -#define IA_ENHAACPLUS_DEC_CONFIG_NUM_CONFIG_EXT 0x001D -#define IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_LEN 0x001E -#define IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF 0x001F -#endif +#define IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR 0x001E +#define IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_BUF_SIZES 0x001F +#define IA_ENHAACPLUS_DEC_CONFIG_NUM_ELE 0x0020 +#define IA_ENHAACPLUS_DEC_CONFIG_NUM_CONFIG_EXT 0x0021 +#define IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_LEN 0x0022 +#define IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF 0x0023 +#define IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE 0x0024 +#define IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS 0x0025 #endif /* IXHEAACD_AAC_CONFIG_H */ diff --git a/decoder/ixheaacd_aac_imdct.c b/decoder/ixheaacd_aac_imdct.c index db0df51..ab8d0dd 100644 --- a/decoder/ixheaacd_aac_imdct.c +++ b/decoder/ixheaacd_aac_imdct.c @@ -78,7 +78,7 @@ static PLATFORM_INLINE WORD32 ixheaacd_shr32_drc(WORD32 a, WORD32 b) { else out_val = 0; } else { - a += (1 << (b - 1)); + a = ixheaacd_add32_sat(a,(1 << (b - 1))); out_val = (WORD32)a >> b; } @@ -786,327 +786,6 @@ VOID ixheaacd_post_twid_overlap_add_dec( } } -VOID ixheaacd_post_twid_overlap_add_armv8( - WORD16 pcm_out[], WORD32 spec_data[], - ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD npoints, - WORD32 *ptr_overlap_buf, WORD16 q_shift, const WORD16 *window, - WORD16 ch_fac) { - WORD i; - WORD16 cos, cos1, sin, sin1; - WORD32 size = npoints / 2; - WORD16 *pcmout1 = pcm_out + (ch_fac * size); - const WORD16 *cos_sin_ptr = ptr_imdct_tables->cosine_array_2048_256p; - - pcm_out = pcmout1 - ch_fac; - spec_data += size; - - if (q_shift > 0) { - WORD32 tempr, tempi, outr, outi, win1, accu, temp1, temp2; - WORD16 adjust, adjust1; - WORD32 overlap_data; - - tempr = *(spec_data - size); - tempi = *(spec_data - size + 1); - adjust = 50; - adjust1 = -50; - cos = *cos_sin_ptr++; - sin = *cos_sin_ptr++; - outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos), - ixheaacd_mult32x16in32(tempr, sin)); - outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), - ixheaacd_mult32x16in32(tempi, sin)); - - overlap_data = *ptr_overlap_buf; - - temp1 = ixheaacd_mult32x16in32(outi, adjust1); - temp2 = ixheaacd_mult32x16in32(outr, adjust); - - outr = outr + temp1; - outi = outi + temp2; - - *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 - q_shift); - - win1 = *((WORD32 *)window + size - 1); - accu = ixheaacd_sub32_sat( - ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outi, win1), q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); - - *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - - pcm_out -= ch_fac; - accu = ixheaacd_sub32_sat( - ixheaacd_shl32_sat( - ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), - q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); - - *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - - pcmout1 += ch_fac; - - for (i = size - 2; i != 0;) { - sin = *cos_sin_ptr++; - cos = *cos_sin_ptr++; - - tempr = *(spec_data + i); - tempi = *(spec_data + i + 1); - - outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), - ixheaacd_mult32x16in32(tempi, sin)); - outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos), - ixheaacd_mult32x16in32(tempr, sin)); - - temp1 = ixheaacd_mult32x16in32(outi, adjust); - temp1 = -1 * temp1; - temp2 = ixheaacd_mult32x16in32(outr, adjust); - - outr = outr + temp1; - outi = outi + temp2; - - overlap_data = *ptr_overlap_buf; - - *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 - q_shift); - - win1 = *((WORD32 *)window + i); - accu = ixheaacd_sub32_sat( - ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outr, win1), q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); - *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcm_out -= ch_fac; - accu = ixheaacd_sub32_sat( - ixheaacd_shl32_sat( - ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), - q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); - *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcmout1 += ch_fac; - - tempr = *(spec_data - i); - tempi = *(spec_data - i + 1); - - i -= 2; - - outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, sin), - ixheaacd_mult32x16in32(tempr, cos)); - outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, sin), - ixheaacd_mult32x16in32(tempi, cos)); - overlap_data = *ptr_overlap_buf; - - temp1 = ixheaacd_mult32x16in32(outi, adjust); - temp1 = temp1 * -1; - temp2 = ixheaacd_mult32x16in32(outr, adjust); - - outr = outr + temp1; - outi = outi + temp2; - - *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 - q_shift); - - win1 = *((WORD32 *)window + i + 1); - accu = ixheaacd_sub32_sat( - ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outi, win1), q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); - *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcm_out -= ch_fac; - accu = ixheaacd_sub32_sat( - ixheaacd_shl32_sat( - ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), - q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); - *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcmout1 += ch_fac; - } - cos1 = *cos_sin_ptr++; - sin1 = *cos_sin_ptr; - - tempr = *(spec_data + i); - tempi = *(spec_data + i + 1); - - outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos1), - ixheaacd_mult32x16in32(tempi, sin1)); - outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos1), - ixheaacd_mult32x16in32(tempr, sin1)); - - temp1 = ixheaacd_mult32x16in32(outi, adjust); - temp1 = -1 * temp1; - temp2 = ixheaacd_mult32x16in32(outr, adjust); - - outr = outr + temp1; - outi = outi + temp2; - - overlap_data = *ptr_overlap_buf; - - *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 - q_shift); - - win1 = *((WORD32 *)window + i); - accu = ixheaacd_sub32_sat( - ixheaacd_shl32_sat(ixheaacd_mult32x16lin32(outr, win1), q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); - *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcm_out -= ch_fac; - accu = ixheaacd_sub32_sat( - ixheaacd_shl32_sat( - ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), - q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); - *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcmout1 += ch_fac; - } else { - q_shift = -q_shift; - { - WORD32 tempr, tempi, temp1, temp2, outr, outi, win1, accu; - WORD16 adjust, adjust1; - WORD16 overlap_data; - tempr = *(spec_data - size); - tempi = *(spec_data - size + 1); - - adjust = 50; - adjust1 = -50; - cos = *cos_sin_ptr++; - sin = *cos_sin_ptr++; - - outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos), - ixheaacd_mult32x16in32(tempr, sin)); - outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), - ixheaacd_mult32x16in32(tempi, sin)); - - overlap_data = *ptr_overlap_buf; - - temp1 = ixheaacd_mult32x16in32(outi, adjust1); - temp2 = ixheaacd_mult32x16in32(outr, adjust); - - outr = outr + temp1; - outi = outi + temp2; - - *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 + q_shift); - - win1 = *((WORD32 *)window + size - 1); - accu = ixheaacd_sub32_sat( - ixheaacd_shr32(ixheaacd_mult32x16lin32(outi, win1), q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); - - *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - - pcm_out -= ch_fac; - accu = ixheaacd_sub32_sat( - ixheaacd_shr32( - ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), - q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); - - *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcmout1 += ch_fac; - - for (i = size - 2; i != 0;) { - sin = *cos_sin_ptr++; - cos = *cos_sin_ptr++; - - tempr = *(spec_data + i); - tempi = *(spec_data + i + 1); - - outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos), - ixheaacd_mult32x16in32(tempi, sin)); - outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos), - ixheaacd_mult32x16in32(tempr, sin)); - overlap_data = *ptr_overlap_buf; - - temp1 = ixheaacd_mult32x16in32(outi, adjust); - temp1 = -1 * temp1; - temp2 = ixheaacd_mult32x16in32(outr, adjust); - outr = outr + temp1; - outi = outi + temp2; - *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 + q_shift); - - win1 = *((WORD32 *)window + i); - accu = ixheaacd_sub32_sat( - ixheaacd_shr32(ixheaacd_mult32x16lin32(outr, win1), q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); - - *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcm_out -= ch_fac; - accu = ixheaacd_sub32_sat( - ixheaacd_shr32( - ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), - q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); - *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcmout1 += ch_fac; - - tempr = *(spec_data - i); - tempi = *(spec_data - i + 1); - i -= 2; - - outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, sin), - ixheaacd_mult32x16in32(tempr, cos)); - outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, sin), - ixheaacd_mult32x16in32(tempi, cos)); - - overlap_data = *ptr_overlap_buf; - - temp1 = ixheaacd_mult32x16in32(outi, adjust); - temp1 = -1 * temp1; - temp2 = ixheaacd_mult32x16in32(outr, adjust); - - outr = outr + temp1; - outi = outi + temp2; - - *ptr_overlap_buf++ = ixheaacd_shr32_drc(outr, 16 + q_shift); - - win1 = *((WORD32 *)window + i + 1); - accu = ixheaacd_sub32_sat( - ixheaacd_shr32(ixheaacd_mult32x16lin32(outi, win1), q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); - - *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcm_out -= ch_fac; - accu = ixheaacd_sub32_sat( - ixheaacd_shr32( - ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outi), win1), - q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1))); - - *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcmout1 += ch_fac; - } - cos1 = *cos_sin_ptr++; - sin1 = *cos_sin_ptr++; - - tempr = *(spec_data + i); - tempi = *(spec_data + i + 1); - - outr = -1 * ixheaacd_add32(ixheaacd_mult32x16in32(tempr, cos1), - ixheaacd_mult32x16in32(tempi, sin1)); - outi = ixheaacd_sub32(ixheaacd_mult32x16in32(tempi, cos1), - ixheaacd_mult32x16in32(tempr, sin1)); - - overlap_data = *ptr_overlap_buf; - - temp1 = ixheaacd_mult32x16in32(outi, adjust); - temp1 = -1 * temp1; - temp2 = ixheaacd_mult32x16in32(outr, adjust); - - outr = outr + temp1; - outi = outi + temp2; - - *ptr_overlap_buf++ = ixheaacd_shr32_drc(outi, 16 + q_shift); - - win1 = *((WORD32 *)window + i); - accu = ixheaacd_sub32_sat( - ixheaacd_shr32(ixheaacd_mult32x16lin32(outr, win1), q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)(win1 >> 16))); - - *pcm_out = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcm_out -= ch_fac; - accu = ixheaacd_sub32_sat( - ixheaacd_shr32( - ixheaacd_mult32x16hin32_drc(ixheaacd_negate32(outr), win1), - q_shift), - ixheaacd_mult32x16lin32_drc(overlap_data, (WORD16)win1)); - *pcmout1 = ixheaacd_round16(ixheaacd_shl32_sat(accu, 2)); - pcmout1 += ch_fac; - } - } -} - VOID ixheaacd_imdct_using_fft_dec( ia_aac_dec_imdct_tables_struct *ptr_imdct_tables, WORD32 npoints, WORD32 *ptr_x, WORD32 *ptr_y) @@ -2025,13 +1704,17 @@ VOID ixheaacd_fft_480_ld(WORD32 *inp, WORD32 *op, } } -static PLATFORM_INLINE VOID ixheaacd_pre_twiddle_compute_ld( - WORD32 *in_ptr1, WORD32 *in_ptr2, WORD32 *xptr, WORD32 *cos_sin_ptr, - WORD npoints_4, WORD32 neg_expo) { - WORD32 i; +VOID ixheaacd_pre_twiddle(WORD32 *xptr, WORD32 *data, WORD32 n, + WORD32 *cos_sin_ptr, WORD32 neg_expo) { + WORD npoints_4, i; WORD32 tempr, tempi, temp; - WORD32 c, c1, s, s1; + WORD32 *in_ptr1, *in_ptr2; + + npoints_4 = n >> 2; + + in_ptr1 = data; + in_ptr2 = data + n - 1; if (neg_expo >= 0) { for (i = npoints_4 - 1; i >= 0; i--) { @@ -2108,20 +1791,6 @@ static PLATFORM_INLINE VOID ixheaacd_pre_twiddle_compute_ld( } } -VOID ixheaacd_pre_twiddle(WORD32 *xptr, WORD32 *data, WORD32 n, - WORD32 *cos_array_ptr, WORD32 neg_expo) { - WORD npoints_4; - WORD32 *in_ptr1, *in_ptr2; - - npoints_4 = n >> 2; - - in_ptr1 = data; - in_ptr2 = data + n - 1; - - ixheaacd_pre_twiddle_compute_ld(in_ptr1, in_ptr2, xptr, cos_array_ptr, - npoints_4, neg_expo); -} - VOID ixheaacd_post_twiddle_ld(WORD32 out[], WORD32 x[], const WORD32 *cos_sin_ptr, WORD m) { WORD i; diff --git a/decoder/ixheaacd_aac_tns.c b/decoder/ixheaacd_aac_tns.c index a439628..c00a523 100644 --- a/decoder/ixheaacd_aac_tns.c +++ b/decoder/ixheaacd_aac_tns.c @@ -255,7 +255,7 @@ VOID ixheaacd_tns_ar_filter_fixed_dec(WORD32 *spectrum, WORD32 size, WORD32 inc, } } -VOID ixheaacd_tns_ar_filter_fixed_armv7(WORD32 *spectrum, WORD32 size, +VOID ixheaacd_tns_ar_filter_fixed_non_neon_armv7(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD32 *lpc, WORD32 order, WORD32 shift_value, WORD scale_spec) { WORD32 i, j; diff --git a/decoder/ixheaacd_aacdecoder.c b/decoder/ixheaacd_aacdecoder.c index faffd27..69d060c 100644 --- a/decoder/ixheaacd_aacdecoder.c +++ b/decoder/ixheaacd_aacdecoder.c @@ -647,10 +647,10 @@ WORD32 ixheaacd_aacdec_decodeframe( it_bit_buff, ptr_ics_info, object_type, aac_dec_handle->samples_per_frame, LEFT); - if(temp!=0) - { - return temp; - } + if(temp!=0) + { + return temp; + } } } } @@ -706,7 +706,8 @@ WORD32 ixheaacd_aacdec_decodeframe( ixheaacd_extension_payload(it_bit_buff, cnt_bits); } - if ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD)) { + if (((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD)) + && (p_obj_exhaacplus_dec->aac_config.ld_decoder != 1)) { if (it_bit_buff->cnt_bits) { WORD32 alignment = it_bit_buff->bit_pos & 0x07; it_bit_buff->cnt_bits = (it_bit_buff->cnt_bits + alignment) & 7; diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c index c050b23..88eaaac 100644 --- a/decoder/ixheaacd_api.c +++ b/decoder/ixheaacd_api.c @@ -154,7 +154,7 @@ IA_ERRORCODE ixheaacd_dec_mem_api( p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config = p_temp + sizeof(ia_dec_data_struct); p_obj_exhaacplus_dec->p_state_aac->header_ptr = p_temp + sizeof(ia_dec_data_struct) - + sizeof(ia_audio_specific_config_struct); + + sizeof(ia_audio_specific_config_struct); } } else { @@ -315,10 +315,9 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) { ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec = p_ia_enhaacplus_dec_obj; pUWORD32 pui_value = pv_value; + pWORD32 pui_value_signed = pv_value; pWORD8 pb_value = pv_value; -#ifdef ENABLE_DRC pVOID *pp_value = (pVOID *)pv_value; -#endif if ((i_cmd != IA_API_CMD_GET_API_SIZE) && (i_cmd != IA_API_CMD_GET_LIB_ID_STRINGS)) { @@ -393,9 +392,12 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, p_obj_exhaacplus_dec->aac_config.ui_samp_freq = 0; p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 3; p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 0; + p_obj_exhaacplus_dec->aac_config.ui_effect_type = 0; + p_obj_exhaacplus_dec->aac_config.ui_target_loudness = -24; + p_obj_exhaacplus_dec->aac_config.ui_loud_norm_flag = 0; p_obj_exhaacplus_dec->aac_config.ui_pce_found_in_hdr = 0; p_obj_exhaacplus_dec->aac_config.loas_present = 0; - + p_obj_exhaacplus_dec->aac_config.ld_decoder = 0; p_obj_exhaacplus_dec->aac_config.ui_drc_enable = 1; p_obj_exhaacplus_dec->aac_config.ui_drc_boost = 0; p_obj_exhaacplus_dec->aac_config.ui_drc_cut = 0; @@ -623,6 +625,17 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, break; } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_LD_TESTING: { + if (*pui_value == 1) { + p_obj_exhaacplus_dec->aac_config.ld_decoder = 1; + } else if (*pui_value == 0) { + p_obj_exhaacplus_dec->aac_config.ld_decoder = 0; + } else { + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_LD_CONFIG); + } + break; + } + case IA_ENHAACPLUS_DEC_CONFIG_PARAM_ELD_SBR_PRESENT: { if (*pui_value == 1) { p_obj_exhaacplus_dec->aac_config.eld_sbr_present = 1; @@ -651,22 +664,40 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, break; } + case IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE: { + if (((*pui_value_signed) > 8) || ((*pui_value_signed) < -1) ) { + p_obj_exhaacplus_dec->aac_config.ui_effect_type = -1; + return (IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_EFFECT_TYPE); + } + p_obj_exhaacplus_dec->aac_config.ui_effect_type = *pui_value_signed; + break; + } + case IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS: { + if(*pui_value_signed>=0) + { + p_obj_exhaacplus_dec->aac_config.ui_loud_norm_flag=1; + } + *pui_value_signed = -(*pui_value_signed >> 2); + if (((*pui_value_signed) > 0) ||((*pui_value_signed) < -63)) { + p_obj_exhaacplus_dec->aac_config.ui_target_loudness = 0; + return (IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_TARGET_LOUDNESS); + } + p_obj_exhaacplus_dec->aac_config.ui_target_loudness = *pui_value_signed; + break; + } default: { return IA_ENHAACPLUS_DEC_API_FATAL_INVALID_CONFIG_PARAM; } } break; } case IA_API_CMD_GET_CONFIG_PARAM: { -#ifdef ENABLE_DRC UWORD32 i; -#endif WORD32 *pvalue = (WORD32 *)(&p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz); - if (i_idx >= 0 && i_idx <= 5) { + if (i_idx >= 0 && i_idx <= 8) { *pui_value = pvalue[i_idx]; } -#ifdef ENABLE_DRC else if (IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR == i_idx) { ia_audio_specific_config_struct *ptr_audio_specific_config = ((ia_audio_specific_config_struct *) @@ -737,7 +768,6 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, *pp_value = ptr_audio_specific_config->str_usac_config .str_usac_dec_config.usac_ext_gain_payload_buf; } -#endif else { return IA_ENHAACPLUS_DEC_API_FATAL_INVALID_CONFIG_PARAM; } @@ -890,7 +920,7 @@ IA_ERRORCODE ixheaacd_decoder_flush_api( p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config = p_temp + sizeof(ia_dec_data_struct); p_obj_exhaacplus_dec->p_state_aac->header_ptr = p_temp + sizeof(ia_dec_data_struct) - + sizeof(ia_audio_specific_config_struct); + + sizeof(ia_audio_specific_config_struct); } memset(&(p_obj_exhaacplus_dec->aac_config), 0, sizeof(ia_aac_dec_config_struct)); @@ -1065,7 +1095,7 @@ IA_ERRORCODE ixheaacd_fill_aac_mem_tables( p_mem_info_aac->ui_size += sizeof(ia_dec_data_struct); p_mem_info_aac->ui_size += sizeof(ia_audio_specific_config_struct); - p_mem_info_aac->ui_size += 8300; + p_mem_info_aac->ui_size += 8300; p_mem_info_aac->ui_alignment = 8; p_mem_info_aac->ui_type = IA_MEMTYPE_PERSIST; @@ -1466,12 +1496,14 @@ IA_ERRORCODE ixheaacd_dec_init( p_state_enhaacplus_dec->ptr_bit_stream = p_state_enhaacplus_dec->pstr_bit_buf; + if (p_state_enhaacplus_dec->s_adts_hdr_present) { //rajat + if (p_obj_exhaacplus_dec->aac_config.ld_decoder == 1) + p_state_enhaacplus_dec->audio_object_type = 23; + } + if ((p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) || (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD)) if (p_state_enhaacplus_dec->s_adts_hdr_present) { - if (p_obj_exhaacplus_dec->aac_config.ld_decoder == 1) - p_state_enhaacplus_dec->audio_object_type = 23; - if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) { p_state_enhaacplus_dec->eld_specific_config.ld_sbr_samp_rate = 1; p_state_enhaacplus_dec->eld_specific_config.ld_sbr_crc_flag = 0; @@ -1790,6 +1822,7 @@ IA_ERRORCODE ixheaacd_dec_init( p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present, p_state_enhaacplus_dec->audio_object_type) != SBRDEC_OK) { p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; + return -1; } else { if (!p_obj_exhaacplus_dec->aac_config.down_sample_flag) { sample_rate_1 *= 2; @@ -2306,6 +2339,11 @@ IA_ERRORCODE ixheaacd_dec_execute( { it_bit_buff->initial_cnt_bits = it_bit_buff->cnt_bits; } + if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD) { + if(p_state_enhaacplus_dec->s_adts_hdr_present) + p_state_enhaacplus_dec->frame_size = adts.aac_frame_length; + } + if (p_state_enhaacplus_dec->pstr_drc_dec) { p_state_enhaacplus_dec->pstr_drc_dec->num_drc_elements = 0; @@ -2502,6 +2540,7 @@ IA_ERRORCODE ixheaacd_dec_execute( p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present, p_state_enhaacplus_dec->audio_object_type) != SBRDEC_OK) { p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; + return -1; } else { if (!p_obj_exhaacplus_dec->aac_config.down_sample_flag) { frame_size = (WORD16)(frame_size * 2); diff --git a/decoder/ixheaacd_api_defs.h b/decoder/ixheaacd_api_defs.h index bd43c51..a02de10 100644 --- a/decoder/ixheaacd_api_defs.h +++ b/decoder/ixheaacd_api_defs.h @@ -36,4 +36,4 @@ IA_MAKE_VERSION_STR(IA_LASTCOMP_APIVERSION_MAJOR, \ IA_LASTCOMP_APIVERSION_MINOR) -#endif \ No newline at end of file +#endif diff --git a/decoder/ixheaacd_arith_dec.c b/decoder/ixheaacd_arith_dec.c index b0fdbf2..ed9ff75 100644 --- a/decoder/ixheaacd_arith_dec.c +++ b/decoder/ixheaacd_arith_dec.c @@ -1815,6 +1815,10 @@ WORD32 ixheaacd_arth_decoding_level2(ia_bit_buf_struct *it_bit_buff, pki = ixheaacd_arith_get_pk(s1 + ixheaacd_esc_nb_offset[esc_nb]); bit_count = ixheaacd_arith_decode(&it_bit_buff_temp, bit_count, &m, &as, ixheaacd_ari_cf_m[pki], 17); + if(bit_count == -1) + { + return -1; + } if (m < ARITH_ESCAPE) { break; @@ -1826,6 +1830,9 @@ WORD32 ixheaacd_arth_decoding_level2(ia_bit_buf_struct *it_bit_buff, if (esc_nb > 7) { esc_nb = 7; } + if (esc_nb < 0) { + esc_nb = 0; + } } if (m == 0) { @@ -1842,10 +1849,17 @@ WORD32 ixheaacd_arth_decoding_level2(ia_bit_buf_struct *it_bit_buff, WORD32 lsbidx = (a == 0) ? 1 : ((b == 0) ? 0 : 2); bit_count = ixheaacd_arith_decode(&it_bit_buff_temp, bit_count, &m, &as, ixheaacd_ari_cf_r[lsbidx], 4); - + if(bit_count == -1) + { + return -1; + } a = (a << 1) | (m & 1); b = (b << 1) | ((m >> 1) & 1); } + if((a > (8183)) || (b > (8183))) + return -1; + if((a < (-8183)) || (b < (-8183))) + return -1; quant[2 * i + 0] = a; quant[2 * i + 1] = b; temp = a + b + 1; @@ -1882,6 +1896,10 @@ WORD32 ixheaacd_arth_decoding_level2(ia_bit_buf_struct *it_bit_buff, m = (m << 1) * temp1; temp1 = m - (temp1); } + if((temp0 > (8183)) || (temp1 > (8183))) + return -1; + if((temp0 < (-8183)) || (temp1 < (-8183))) + return -1; *quant++ = temp0; *quant++ = temp1; } diff --git a/decoder/ixheaacd_basic_ops32.h b/decoder/ixheaacd_basic_ops32.h index 6784ae4..d49112e 100644 --- a/decoder/ixheaacd_basic_ops32.h +++ b/decoder/ixheaacd_basic_ops32.h @@ -319,11 +319,15 @@ static PLATFORM_INLINE WORD32 ixheaacd_negate32(WORD32 a) { static PLATFORM_INLINE WORD32 ixheaacd_negate32_sat(WORD32 a) { WORD32 neg_val; - neg_val = -a; - if (a == MIN_32) { + + if (a == MIN_32) + { neg_val = MAX_32; } - + else + { + neg_val = -a; + } return neg_val; } diff --git a/decoder/ixheaacd_basic_ops40.h b/decoder/ixheaacd_basic_ops40.h index 028b96b..1a35901 100644 --- a/decoder/ixheaacd_basic_ops40.h +++ b/decoder/ixheaacd_basic_ops40.h @@ -324,6 +324,16 @@ static PLATFORM_INLINE WORD64 ixheaacd_mult64(WORD32 a, WORD32 b) { return (result); } +static PLATFORM_INLINE WORD64 ixheaacd_add64_sat(WORD64 a, WORD64 b) { + WORD64 result , comp; + result = (a < 0) ? MIN_64 : MAX_64; + comp = result - a; + if ((a < 0) == (b > comp)) + result = a + b; + + return (result); +} + static PLATFORM_INLINE WORD64 ixheaacd_add64(WORD64 a, WORD64 b) { WORD64 result; result = a + b; diff --git a/decoder/ixheaacd_channel.c b/decoder/ixheaacd_channel.c index 9cf7e8d..4ba0836 100644 --- a/decoder/ixheaacd_channel.c +++ b/decoder/ixheaacd_channel.c @@ -213,8 +213,8 @@ static WORD16 ixheaacd_read_block_data( if (error_code) { return error_code; } - if (aac_sf_data_resil_flag && ((object_type == AOT_ER_AAC_ELD) - || (object_type == AOT_ER_AAC_LD))) + if (aac_sf_data_resil_flag && ((object_type == AOT_ER_AAC_ELD) + || (object_type == AOT_ER_AAC_LD))) ixheaacd_rvlc_read(it_bit_buff, ptr_aac_dec_channel_info); else ixheaacd_read_scale_factor_data(it_bit_buff, ptr_aac_dec_channel_info, @@ -297,7 +297,7 @@ static WORD16 ixheaacd_read_block_data( WORD16 ixheaacd_ltp_decode(ia_bit_buf_struct *it_bit_buff, ia_ics_info_struct *ptr_ics_info, - WORD32 object_type, + WORD32 object_type, WORD32 frame_size, WORD32 ch) { WORD32 retval = AAC_DEC_OK; @@ -514,10 +514,10 @@ WORD16 ixheaacd_individual_ch_stream( it_bit_buff, ptr_ics_info, object_type, aac_dec_handle->samples_per_frame, 1); - if(temp!=0) - { - return temp; - } + if(temp!=0) + { + return temp; + } aac_dec_handle->pstr_aac_dec_ch_info[ch + 1]->str_ics_info.ltp.lag = ptr_ics_info->ltp2.lag; } diff --git a/decoder/ixheaacd_channelinfo.h b/decoder/ixheaacd_channelinfo.h index 1d8c3de..199079d 100644 --- a/decoder/ixheaacd_channelinfo.h +++ b/decoder/ixheaacd_channelinfo.h @@ -335,7 +335,7 @@ WORD16 ixheaacd_ics_read(ia_bit_buf_struct *it_bit_buff, WORD16 ixheaacd_ltp_decode(ia_bit_buf_struct *it_bit_buff, ia_ics_info_struct *ptr_ics_info, - WORD32 object_type, + WORD32 object_type, WORD32 frame_size, WORD32 ch); #endif /* #ifndef IXHEAACD_CHANNELINFO_H */ diff --git a/decoder/ixheaacd_common_rom.c b/decoder/ixheaacd_common_rom.c index 5622e12..e442f8f 100644 --- a/decoder/ixheaacd_common_rom.c +++ b/decoder/ixheaacd_common_rom.c @@ -197,22 +197,22 @@ const ixheaacd_misc_tables ixheaacd_str_fft_n_transcendent_tables = { /*WORD32 down_mix_martix[4][2][8] = */ { - {/* Q30 */ /* 5.0 Channel to Stereo */ + {/* Q30 */ /* 5.0 Channel to Stereo */ {405185594, 0, 315041546, 315041546, 0, 0, 0, 0}, {0, 405185594, 315041546, 0, 315041546, 0, 0, 0}}, {/* Q30 */ /* 5.1 Channel to Stereo */ {405185594, 0, 286509481, 95503160, 286509481, 0, 0, 0}, {0, 405185594, 286509481, 95503160, 0, 286509481, 0, 0}}, - {/* Q30 */ /* 7.0 Channel to Stereo */ + {/* Q30 */ /* 7.0 Channel to Stereo */ {405185594, 0, 244131873, 244131873, 0, 244131873, 0, 0}, {0, 405185594, 244131873, 0, 244131873, 0, 244131873, 0}}, - {/* Q30 */ /* 7.1 Channel to Stereo */ + {/* Q30 */ /* 7.1 Channel to Stereo */ {405185594, 0, 226641828, 75547276, 226641828, 0, 226641828, 0}, {0, 405185594, 75547276, 226641828, 0, 226641828, 0, 226641828}}, } - /* Q29 */ + /* Q29 */ /*const WORD32 cc_gain_scale[4] = */, {585461881, 638450708, 759250125, 1073741824}, diff --git a/decoder/ixheaacd_config.h b/decoder/ixheaacd_config.h index 2d80563..6964d9d 100644 --- a/decoder/ixheaacd_config.h +++ b/decoder/ixheaacd_config.h @@ -43,15 +43,11 @@ #define ID_EXT_ELE_FILL 0 #define ID_EXT_ELE_MPEGS 1 #define ID_EXT_ELE_SAOC 2 -#ifdef ENABLE_DRC #define ID_EXT_ELE_AUDIOPREROLL 3 #define ID_EXT_ELE_UNI_DRC 4 -#endif #define ID_CONFIG_EXT_FILL 0 -#ifdef ENABLE_DRC #define ID_CONFIG_EXT_LOUDNESS_INFO (2) -#endif typedef UWORD8 UINT8; typedef UWORD32 UINT32; @@ -125,7 +121,6 @@ typedef struct { #define BS_MAX_NUM_OUT_CHANNELS (255) -#ifdef ENABLE_DRC #define EXT_COUNT_MAX (2) #define MAX_CHANNEL_COUNT (128) #define SEQUENCE_COUNT_MAX (24) @@ -164,7 +159,6 @@ typedef struct { #define DRC_BAND_COUNT_MAX BAND_COUNT_MAX #define SPEAKER_POS_COUNT_MAX (128) #define DOWNMIX_COEFF_COUNT_MAX (32 * 32) -#endif typedef struct { UINT32 tw_mdct; @@ -181,13 +175,10 @@ typedef struct { typedef struct { UWORD32 num_elements; -#ifdef ENABLE_DRC UWORD32 num_config_extensions; -#endif UWORD32 usac_element_type[USAC_MAX_ELEMENTS]; ia_usac_dec_element_config_struct str_usac_element_config[USAC_MAX_ELEMENTS]; -#ifdef ENABLE_DRC WORD32 usac_cfg_ext_info_present[USAC_MAX_CONFIG_EXTENSIONS]; WORD32 usac_ext_ele_payload_present[USAC_MAX_ELEMENTS]; WORD32 usac_cfg_ext_info_len[USAC_MAX_CONFIG_EXTENSIONS]; @@ -196,7 +187,8 @@ typedef struct { UWORD8 usac_cfg_ext_info_buf[USAC_MAX_CONFIG_EXTENSIONS][768]; UWORD8 usac_ext_ele_payload_buf[USAC_MAX_ELEMENTS][768]; UWORD8 usac_ext_gain_payload_buf[768]; -#endif + + WORD32 preroll_flag; } ia_usac_decoder_config_struct; @@ -212,8 +204,6 @@ typedef struct { } ia_usac_config_struct; -#ifdef ENABLE_DRC -#ifdef AMMENDMENT1 typedef struct { WORD32 parametric_lim_threshold_present; FLOAT32 parametric_lim_threshold; @@ -257,9 +247,7 @@ typedef struct { WORD32 len_bit_size; ia_parametric_drc_type_feed_forward_struct str_parametric_drc_type_feed_forward; -#ifdef AMMENDMENT1 ia_parametric_drc_lim_struct parametric_drc_lim; -#endif WORD32 drc_characteristic; WORD32 disable_paramteric_drc; @@ -311,7 +299,6 @@ typedef struct { FLOAT32 loud_eq_offset[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX]; } ia_loud_eq_instructions_struct; -#endif typedef struct { WORD32 filt_ele_idx; WORD32 filt_ele_gain_flag; @@ -407,14 +394,11 @@ typedef struct { WORD32 drc_config_ext_type[EXT_COUNT_MAX]; WORD32 ext_bit_size[EXT_COUNT_MAX - 1]; -#ifdef AMMENDMENT1 WORD32 parametric_drc_present; ia_drc_coeff_parametric_drc_struct str_drc_coeff_param_drc; WORD32 parametric_drc_instructions_count; ia_parametric_drc_instructions_struct str_parametric_drc_instructions[PARAM_DRC_INSTRUCTIONS_COUNT_MAX]; -#endif -#ifdef AMMENDMENT1 WORD32 drc_extension_v1_present; WORD32 loud_eq_instructions_flag; WORD32 loud_eq_instructions_count; @@ -424,7 +408,6 @@ typedef struct { ia_eq_coeff_struct str_eq_coeff; WORD32 eq_instructions_count; ia_eq_instructions_struct str_eq_instructions[EQ_INSTRUCTIONS_COUNT_MAX]; -#endif } ia_drc_config_ext; typedef struct { @@ -449,12 +432,10 @@ typedef struct { typedef struct { WORD32 gain_seq_idx; WORD32 drc_characteristic; -#ifdef AMMENDMENT1 WORD32 drc_characteristic_present; WORD32 drc_characteristic_format_is_cicp; WORD32 drc_characteristic_left_index; WORD32 drc_characteristic_right_index; -#endif WORD32 crossover_freq_idx; WORD32 start_subband_index; } ia_gain_params_struct; @@ -517,7 +498,6 @@ typedef struct { WORD32 drc_frame_size; WORD32 gain_set_count; ia_gain_set_params_struct gain_set_params[GAIN_SET_COUNT_MAX]; -#ifdef AMMENDMENT1 WORD32 drc_characteristic_left_present; WORD32 characteristic_left_count; ia_split_drc_characteristic_struct @@ -532,22 +512,17 @@ typedef struct { str_shape_filter_block_params[SHAPE_FILTER_COUNT_MAX + 1]; WORD32 gain_sequence_count; WORD32 gain_set_params_index_for_gain_sequence[SEQUENCE_COUNT_MAX]; -#endif -#ifdef AMMENDMENT1 WORD32 gain_set_count_plus; -#endif } ia_uni_drc_coeffs_struct; typedef struct { -#ifdef AMMENDMENT1 WORD32 target_characteristic_left_present[DRC_BAND_COUNT_MAX]; WORD32 target_characteristic_left_index[DRC_BAND_COUNT_MAX]; WORD32 target_characteristic_right_present[DRC_BAND_COUNT_MAX]; WORD32 target_characteristic_right_index[DRC_BAND_COUNT_MAX]; WORD32 shape_filter_flag; WORD32 shape_filter_idx; -#endif WORD32 gain_scaling_flag[BAND_COUNT_MAX]; FLOAT32 attn_scaling[BAND_COUNT_MAX]; FLOAT32 ampl_scaling[BAND_COUNT_MAX]; @@ -563,10 +538,8 @@ typedef struct { typedef struct { WORD32 drc_set_id; -#ifdef AMMENDMENT1 WORD32 drc_set_complexity_level; WORD32 requires_eq; -#endif WORD32 drc_apply_to_dwnmix; WORD32 drc_location; WORD32 dwnmix_id_count; @@ -600,12 +573,10 @@ typedef struct { WORD32 num_chan_per_ch_group[CHANNEL_GROUP_COUNT_MAX]; WORD32 gain_element_count; WORD32 multiband_audio_sig_count; -#ifdef AMMENDMENT1 WORD32 ch_group_parametric_drc_flag[CHANNEL_GROUP_COUNT_MAX]; WORD32 gain_set_idx_of_ch_group_parametric_drc[CHANNEL_GROUP_COUNT_MAX]; WORD32 parametric_drc_look_ahead_samples[CHANNEL_GROUP_COUNT_MAX]; WORD32 parametric_drc_look_ahead_samples_max; -#endif } ia_drc_instructions_struct; typedef struct { @@ -646,7 +617,6 @@ typedef struct ia_drc_config { ia_downmix_instructions_struct dwnmix_instructions[DOWNMIX_INSTRUCTION_COUNT_MAX]; } ia_drc_config; -#endif VOID ixheaacd_conf_default(ia_usac_config_struct *pstr_usac_conf); @@ -654,7 +624,7 @@ UWORD32 ixheaacd_sbr_ratio(UWORD32 core_sbr_frame_len_idx); UWORD32 ixheaacd_sbr_params(UWORD32 core_sbr_frame_len_idx, WORD32 *output_frame_length, WORD32 *block_size, - WORD32 *output_samples); + WORD32 *output_samples,WORD32 *sampling_freq, UWORD32* sample_freq_indx); WORD32 ixheaacd_config(ia_bit_buf_struct *bit_buff, ia_usac_config_struct *pstr_usac_conf); diff --git a/decoder/ixheaacd_create.c b/decoder/ixheaacd_create.c index c8a75b8..15232b1 100644 --- a/decoder/ixheaacd_create.c +++ b/decoder/ixheaacd_create.c @@ -232,7 +232,8 @@ WORD32 ixheaacd_decode_init( &aac_dec_handle->pstr_aac_tables->pstr_block_tables ->tns_max_bands_tbl_usac; - for (i = 0; i < (1 << LEN_SAMP_IDX); i++) { + + for (i = 0; i < 11 ; i++) { if (ixheaacd_sampling_boundaries[i] <= sample_rate) break; } @@ -319,14 +320,8 @@ WORD32 ixheaacd_decode_init( .str_usac_element_config[ele_id] .str_usac_mps212_config); - if (aac_dec_handle->mps_dec_handle[ele_id]) { - aac_dec_handle->mps_dec_handle[ele_id] = NULL; - } - - aac_dec_handle->mps_dec_handle[ele_id] = ixheaacd_mps_create( + ixheaacd_mps_create(&aac_dec_handle->mps_dec_handle, bs_frame_length, bs_residual_coding, ptr_usac_mps212_config); - - if (aac_dec_handle->mps_dec_handle[ele_id] == 0) return -1; } break; } @@ -369,7 +364,12 @@ WORD32 ixheaacd_dec_data_init(VOID *handle, sbr_ratio_idx = ixheaacd_sbr_params( ptr_usac_config->core_sbr_framelength_index, &out_frame_len, - &usac_data->ccfl, &usac_data->output_samples); + &usac_data->ccfl, &usac_data->output_samples, + &pstr_frame_data->str_layer.sample_rate_layer, + &layer_config->samp_frequency_index); + + pstr_stream_config->sampling_frequency = pstr_frame_data->str_layer.sample_rate_layer; + pstr_stream_config->samp_frequency_index = layer_config->samp_frequency_index; num_elements = ptr_usac_config->str_usac_dec_config.num_elements; @@ -397,14 +397,9 @@ WORD32 ixheaacd_dec_data_init(VOID *handle, num_out_chan = ptr_usac_config->num_out_channels; - if (layer_config->samp_frequency_index != 0xf) - pstr_frame_data->str_layer.sample_rate_layer = - ixheaacd_sampl_freq_idx_table[layer_config->samp_frequency_index]; - else - pstr_frame_data->str_layer.sample_rate_layer = - layer_config->sampling_frequency; - if (out_frame_len == 768) + + if (usac_data->ccfl == 768) pstr_frame_data->str_layer.sample_rate_layer = 4 * pstr_frame_data->str_layer.sample_rate_layer / 3; @@ -483,11 +478,10 @@ WORD32 ixheaacd_frm_data_init(ia_audio_specific_config_struct *pstr_audio_conf, WORD32 max_layer = -1; memset(pstr_dec_data, 0, sizeof(ia_dec_data_struct)); - pstr_dec_data->pstr_frame_data = &pstr_dec_data->str_frame_data; - memset(pstr_dec_data->pstr_frame_data, 1, + memset(&(pstr_dec_data->str_frame_data), 0, sizeof(pstr_dec_data->str_frame_data)); - pstr_frame_data = pstr_dec_data->pstr_frame_data; + pstr_frame_data = &(pstr_dec_data->str_frame_data); if (max_layer < 0) max_layer = stream_count - 1; @@ -528,7 +522,7 @@ WORD32 ixheaacd_decode_create(ia_exhaacplus_dec_api_struct *handle, ia_frame_data_struct *pstr_frame_data; WORD32 stream_count; ia_aac_dec_state_struct *aac_dec_handle = handle->p_state_aac; - pstr_frame_data = pstr_dec_data->pstr_frame_data; + pstr_frame_data = &(pstr_dec_data->str_frame_data); stream_count = pstr_frame_data->stream_count; pstr_frame_data->stream_count = tracks_for_decoder; @@ -537,12 +531,11 @@ WORD32 ixheaacd_decode_create(ia_exhaacplus_dec_api_struct *handle, switch (aot) { case AOT_USAC: - if (pstr_dec_data->pstr_usac_data == NULL) { - pstr_dec_data->pstr_usac_data = &pstr_dec_data->str_usac_data; - err = ixheaacd_dec_data_init(handle, pstr_frame_data, - pstr_dec_data->pstr_usac_data); - switch (pstr_dec_data->pstr_usac_data->sbr_ratio_idx) { + err = ixheaacd_dec_data_init(handle, pstr_frame_data, + &(pstr_dec_data->str_usac_data)); + + switch (pstr_dec_data->str_usac_data.sbr_ratio_idx) { case 0: handle->aac_config.ui_sbr_mode = 0; break; @@ -561,7 +554,7 @@ WORD32 ixheaacd_decode_create(ia_exhaacplus_dec_api_struct *handle, } if (err == -1) return -1; - } + break; default: @@ -577,7 +570,8 @@ WORD32 ixheaacd_decode_create(ia_exhaacplus_dec_api_struct *handle, pstr_frame_data->scal_out_sampling_frequency = pstr_frame_data->str_audio_specific_config.sampling_frequency; - if (pstr_dec_data->pstr_usac_data != NULL) { + if (&(pstr_dec_data->str_usac_data) != NULL) { + ia_sbr_header_data_struct usac_def_header; ia_audio_specific_config_struct *pstr_aud_spec_config = &pstr_frame_data->str_audio_specific_config; ia_usac_config_struct *ptr_usac_config = @@ -586,13 +580,24 @@ WORD32 ixheaacd_decode_create(ia_exhaacplus_dec_api_struct *handle, WORD32 inter_tes[MAX_NUM_ELEMENTS] = {0}; WORD32 bs_pvc[MAX_NUM_ELEMENTS] = {0}; WORD32 harmonic_sbr[MAX_NUM_ELEMENTS] = {0}; + WORD32 inter_test_flag = 0; + WORD32 bs_pvc_flag = 0; + WORD32 harmonic_Sbr_flag = 0; ia_usac_decoder_config_struct *ptr_usac_dec_config = &ptr_usac_config->str_usac_dec_config; WORD32 const num_ele = ptr_usac_dec_config->num_elements; WORD32 elem_idx = 0; + memset(&usac_def_header, 0, sizeof(ia_sbr_header_data_struct)); + for (elem_idx = 0; elem_idx < num_ele; elem_idx++) { + + UWORD32 usac_ele_type = + ptr_usac_config->str_usac_dec_config.usac_element_type[elem_idx]; + ia_usac_dec_element_config_struct *ptr_usac_ele_config = + &ptr_usac_config->str_usac_dec_config.str_usac_element_config[elem_idx]; + ia_usac_dec_sbr_config_struct *ptr_usac_sbr_config = &(ptr_usac_dec_config->str_usac_element_config[elem_idx] .str_usac_sbr_config); @@ -602,39 +607,21 @@ WORD32 ixheaacd_decode_create(ia_exhaacplus_dec_api_struct *handle, (ptr_usac_sbr_config != NULL) ? ptr_usac_sbr_config->bs_pvc : 0; harmonic_sbr[elem_idx] = (ptr_usac_sbr_config != NULL) ? ptr_usac_sbr_config->harmonic_sbr : 0; - } - pstr_dec_data->pstr_usac_data->down_samp_sbr = 0; + if (ptr_usac_sbr_config->bs_inter_tes) + inter_test_flag = 1; + if (ptr_usac_sbr_config->bs_pvc) + bs_pvc_flag = 1; + if (ptr_usac_sbr_config->harmonic_sbr) + harmonic_Sbr_flag = 1; + - if (pstr_dec_data->pstr_usac_data->sbr_ratio_idx > 0) { - if (pstr_aud_spec_config->ext_sampling_frequency == - pstr_aud_spec_config->sampling_frequency) { - pstr_dec_data->pstr_usac_data->down_samp_sbr = 1; - } - if (pstr_dec_data->pstr_usac_data->down_samp_sbr == 0) { - if (pstr_dec_data->pstr_usac_data->sbr_ratio_idx == 3) { - pstr_frame_data->scal_out_sampling_frequency = - 4 * pstr_frame_data->scal_out_sampling_frequency; - } else { - pstr_frame_data->scal_out_sampling_frequency = - 2 * pstr_frame_data->scal_out_sampling_frequency; - } - } - { - UWORD32 usac_ele_type = - ptr_usac_config->str_usac_dec_config.usac_element_type[0]; - ia_usac_dec_element_config_struct *ptr_usac_ele_config = - &ptr_usac_config->str_usac_dec_config.str_usac_element_config[0]; - ia_sbr_header_data_struct usac_def_header; - void *sbr_persistent_mem_v = aac_dec_handle->sbr_persistent_mem_u; if ((usac_ele_type != ID_USAC_LFE) && (usac_ele_type != ID_USAC_EXT)) { ia_usac_dec_sbr_config_struct *ptr_usac_sbr_config = &(ptr_usac_ele_config->str_usac_sbr_config); - memset(&usac_def_header, 0, sizeof(ia_sbr_header_data_struct)); - usac_def_header.start_freq = ptr_usac_sbr_config->dflt_start_freq; usac_def_header.stop_freq = ptr_usac_sbr_config->dflt_stop_freq; usac_def_header.header_extra_1 = @@ -653,23 +640,47 @@ WORD32 ixheaacd_decode_create(ia_exhaacplus_dec_api_struct *handle, usac_def_header.smoothing_mode = ptr_usac_sbr_config->dflt_smoothing_mode; } - pstr_dec_data->pstr_usac_data->pstr_esbr_dec = ixheaacd_init_sbr( - pstr_frame_data->str_layer.sample_rate_layer, - pstr_dec_data->pstr_usac_data->ccfl, - &pstr_dec_data->pstr_usac_data->down_samp_sbr, sbr_persistent_mem_v, - NULL, pstr_frame_data->scal_out_num_channels, 0, - pstr_dec_data->pstr_usac_data->sbr_ratio_idx, - pstr_dec_data->pstr_usac_data->output_samples, harmonic_sbr, - (void *)&usac_def_header, aac_dec_handle->str_sbr_config, - pstr_dec_data->pstr_usac_data->audio_object_type); - pstr_dec_data->pstr_usac_data->sbr_scratch_mem_base = - aac_dec_handle->sbr_scratch_mem_u; - if (num_ele) - ixheaacd_setesbr_flags(sbr_persistent_mem_v, bs_pvc[0], - harmonic_sbr[0], inter_tes[0]); + + } + + pstr_dec_data->str_usac_data.down_samp_sbr = 0; + + if (pstr_dec_data->str_usac_data.sbr_ratio_idx > 0) { + if (pstr_aud_spec_config->ext_sampling_frequency == + pstr_aud_spec_config->sampling_frequency) { + pstr_dec_data->str_usac_data.down_samp_sbr = 1; + } + if (pstr_dec_data->str_usac_data.down_samp_sbr == 0) { + if (pstr_dec_data->str_usac_data.sbr_ratio_idx == 3) { + pstr_frame_data->scal_out_sampling_frequency = + 4 * pstr_frame_data->scal_out_sampling_frequency; + } else { + pstr_frame_data->scal_out_sampling_frequency = + 2 * pstr_frame_data->scal_out_sampling_frequency; + } } - if (pstr_dec_data->pstr_usac_data->pstr_esbr_dec == NULL) { + { + + void *sbr_persistent_mem_v = aac_dec_handle->sbr_persistent_mem_u; + + pstr_dec_data->str_usac_data.pstr_esbr_dec = ixheaacd_init_sbr( + pstr_frame_data->str_layer.sample_rate_layer, + pstr_dec_data->str_usac_data.ccfl, + &pstr_dec_data->str_usac_data.down_samp_sbr, sbr_persistent_mem_v, + NULL, pstr_frame_data->scal_out_num_channels, 0, + pstr_dec_data->str_usac_data.sbr_ratio_idx, + pstr_dec_data->str_usac_data.output_samples, &harmonic_Sbr_flag, + (void *)&usac_def_header, aac_dec_handle->str_sbr_config, + pstr_dec_data->str_usac_data.audio_object_type); + pstr_dec_data->str_usac_data.sbr_scratch_mem_base = + aac_dec_handle->sbr_scratch_mem_u; + if (num_ele) + ixheaacd_setesbr_flags(sbr_persistent_mem_v, bs_pvc_flag, + harmonic_Sbr_flag, inter_test_flag); + } + + if (pstr_dec_data->str_usac_data.pstr_esbr_dec == NULL) { return -1; } } @@ -677,21 +688,3 @@ WORD32 ixheaacd_decode_create(ia_exhaacplus_dec_api_struct *handle, return (num_delay_samp); } - -WORD32 ixheaacd_decode_free(VOID *codec_handle) { - UWORD32 i; - ia_exhaacplus_dec_api_struct *handle = - (ia_exhaacplus_dec_api_struct *)codec_handle; - ia_aac_dec_state_struct *p_state_aac_dec = handle->p_state_aac; - ia_dec_data_struct *pstr_dec_data = - (ia_dec_data_struct *)(p_state_aac_dec->pstr_dec_data); - if (pstr_dec_data->pstr_usac_data) { - for (i = 0; i < MAX_NUM_ELEMENTS; i++) { - if (p_state_aac_dec->mps_dec_handle[i]) { - p_state_aac_dec->mps_dec_handle[i] = NULL; - } - } - } - - return (0); -} diff --git a/decoder/ixheaacd_create.h b/decoder/ixheaacd_create.h index 9b8402a..05f125e 100644 --- a/decoder/ixheaacd_create.h +++ b/decoder/ixheaacd_create.h @@ -21,8 +21,6 @@ #define IXHEAACD_CREATE_H typedef struct { - ia_frame_data_struct *pstr_frame_data; - ia_usac_data_struct *pstr_usac_data; struct ia_bit_buf_struct dec_bit_buf; ia_frame_data_struct str_frame_data; ia_usac_data_struct str_usac_data; diff --git a/decoder/ixheaacd_decode_main.c b/decoder/ixheaacd_decode_main.c index 7ae8676..efd867c 100644 --- a/decoder/ixheaacd_decode_main.c +++ b/decoder/ixheaacd_decode_main.c @@ -124,6 +124,99 @@ VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out, } } +/* audio pre roll frame parsing*/ +static WORD32 ixheaacd_audio_preroll_parsing(ia_dec_data_struct *pstr_dec_data, UWORD8 *conf_buf,WORD32 *preroll_units, WORD32 *preroll_frame_offset) +{ + ia_bit_buf_struct *temp_buff = (ia_bit_buf_struct *)&(pstr_dec_data->dec_bit_buf); + WORD32 independency_flag = 0; + WORD32 ext_ele_present = 0; + WORD32 ext_ele_use_dflt_len = 0; + WORD32 ext_ele_payload_len = 0; + + WORD32 apply_crossfade = 0; + WORD32 un_used_val = 0; + WORD32 num_pre_roll_frames = 0; + + WORD32 frame_idx = 0; + WORD32 frame_len[18] = { 0 }; // max of escapedValue(2, 4, 0) i.e. 2^2 -1 + 2^4 -1; + WORD32 temp = 0; + + WORD32 config_len = 0; + WORD32 loop; + + if (pstr_dec_data->str_frame_data.str_audio_specific_config.str_usac_config.str_usac_dec_config.usac_element_type[0] == ID_USAC_EXT) + { + temp = ixheaacd_show_bits_buf(temp_buff, 3); + independency_flag = (temp >> 2) & 0x1; + ext_ele_present = (temp >> 1) & 0x1; + + if (ext_ele_present) + { + ext_ele_use_dflt_len = temp & 0x1; // ixheaacd_read_bit(&temp_buff, 1); + if (ext_ele_use_dflt_len != 0) + return 0; + + un_used_val = ixheaacd_read_bits_buf(temp_buff, 3); + + ext_ele_payload_len = ixheaacd_read_bits_buf(temp_buff, 8); + + if (ext_ele_payload_len == 255) { + WORD32 val_add = 0; + val_add = ixheaacd_read_bits_buf(temp_buff, 16); + ext_ele_payload_len = (UWORD32)((WORD32)ext_ele_payload_len + val_add - 2); + } + + //escapedValue(4, 4, 8); + config_len = ixheaacd_read_bits_buf(temp_buff, 4); + if (config_len == 15) + { + WORD32 val_add = 0; + val_add = ixheaacd_read_bits_buf(temp_buff, 4); + config_len += val_add; + if (val_add == 15) + { + WORD32 val_add1 = 0; + val_add1 = ixheaacd_read_bits_buf(temp_buff, 8); + config_len += val_add1; + } + } + + for(loop=0; loop < config_len; loop++) + conf_buf[loop] = ixheaacd_read_bits_buf(temp_buff, 8); + + + apply_crossfade = ixheaacd_read_bits_buf(temp_buff, 1); + un_used_val = ixheaacd_read_bits_buf(temp_buff, 1); // reserverd + + //escapedValue(2, 4, 0); + num_pre_roll_frames = ixheaacd_read_bits_buf(temp_buff, 2); + if (num_pre_roll_frames == 3) + { + WORD32 val_add = 0; + val_add = ixheaacd_read_bits_buf(temp_buff, 4); + num_pre_roll_frames += val_add; + } + + for (frame_idx = 0; frame_idx < num_pre_roll_frames; frame_idx++) + { + WORD32 au_len = 0; //escapedValued(16,16,0) + au_len = ixheaacd_read_bits_buf(temp_buff, 16); + if (au_len == 65535) + { + WORD32 val_add = ixheaacd_read_bits_buf(temp_buff, 16); + au_len += val_add; + } + preroll_frame_offset[frame_idx]=temp_buff->size-temp_buff->cnt_bits; + frame_len[frame_idx] = (8 * au_len) + (temp_buff->size - temp_buff->cnt_bits); + temp_buff->ptr_read_next += au_len; + temp_buff->cnt_bits -= au_len * 8; + } + } + } + *preroll_units=num_pre_roll_frames; + return config_len; +} + WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer, WORD32 *out_bytes, WORD32 frames_done, WORD32 pcmsize, WORD32 *num_channel_out) { @@ -139,6 +232,13 @@ WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer, WORD32 suitable_tracks = 1; WORD32 num_samples_out; ia_dec_data_struct *pstr_dec_data; + UWORD8 config[285]; //max of escapedValue(4, 4, 8) i.e. 2^4 -1 + 2^4 -1 + 2^8 -1; + WORD32 config_len; + WORD32 delay; + WORD preroll_frame_offset[4]={0}; + WORD preroll_units=-1; + WORD32 access_units=0; + if (frames_done == 0) { if ((pstr_audio_specific_config->channel_configuration > 2) || @@ -167,9 +267,9 @@ WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer, WORD32 delay; delay = ixheaacd_decode_create( handle, pstr_dec_data, - pstr_dec_data->pstr_frame_data->scal_out_select + 1); + pstr_dec_data->str_frame_data.scal_out_select + 1); if (delay == -1) return -1; - *num_channel_out = pstr_dec_data->pstr_frame_data->scal_out_num_channels; + *num_channel_out = pstr_dec_data->str_frame_data.scal_out_num_channels; return 0; } @@ -181,30 +281,121 @@ WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer, pstr_dec_data->dec_bit_buf.bit_pos = 7; pstr_dec_data->dec_bit_buf.cnt_bits = pstr_dec_data->dec_bit_buf.size; - pstr_dec_data->pstr_usac_data->usac_flag = aac_dec_handle->usac_flag; + pstr_dec_data->str_usac_data.usac_flag = aac_dec_handle->usac_flag; + + /* audio pre roll frame parsing*/ + + do{ + + config_len=0; + if(access_units==0&&pstr_audio_specific_config->str_usac_config.str_usac_dec_config.preroll_flag) + { + config_len = ixheaacd_audio_preroll_parsing(pstr_dec_data,&config[0],&preroll_units,&preroll_frame_offset[0]); + } + + if (config_len != 0) + { + + + /* updating the config parameters*/ + ia_bit_buf_struct *config_bit_buf = (ia_bit_buf_struct *)malloc(sizeof(ia_bit_buf_struct)); + + config_bit_buf->ptr_bit_buf_base = config; + config_bit_buf->size = config_len << 3; + config_bit_buf->ptr_read_next = config_bit_buf->ptr_bit_buf_base; + config_bit_buf->ptr_bit_buf_end =(UWORD8 *)config + config_len; + config_bit_buf->bit_pos = 7; + config_bit_buf->cnt_bits = config_bit_buf->size; + + + + + + + suitable_tracks = + ixheaacd_frm_data_init(pstr_audio_specific_config, pstr_dec_data); + + if (suitable_tracks <= 0) + return -1; + + /* call codec re-configure*/ + err = ixheaacd_config(config_bit_buf, &(pstr_dec_data->str_frame_data.str_audio_specific_config.str_usac_config)/*&pstr_audio_specific_config->str_usac_config*/); + free(config_bit_buf); + if (err != 0) return -1; + + + delay = ixheaacd_decode_create( + handle, pstr_dec_data, + pstr_dec_data->str_frame_data.scal_out_select + 1); + if (delay == -1) return -1; + *num_channel_out = pstr_dec_data->str_frame_data.scal_out_num_channels; + + } + + pstr_dec_data->dec_bit_buf.ptr_bit_buf_base = (UWORD8 *)inbuffer; + pstr_dec_data->dec_bit_buf.size = aac_dec_handle->ui_in_bytes << 3; + pstr_dec_data->dec_bit_buf.ptr_bit_buf_end = + (UWORD8 *)inbuffer + aac_dec_handle->ui_in_bytes; + pstr_dec_data->dec_bit_buf.ptr_read_next = (UWORD8 *)inbuffer; + pstr_dec_data->dec_bit_buf.bit_pos = 7; + pstr_dec_data->dec_bit_buf.cnt_bits = pstr_dec_data->dec_bit_buf.size; + + pstr_dec_data->str_usac_data.usac_flag = aac_dec_handle->usac_flag; + + + if(preroll_frame_offset[access_units]) + { + pstr_dec_data->dec_bit_buf.cnt_bits=pstr_dec_data->dec_bit_buf.size - preroll_frame_offset[access_units]; + pstr_dec_data->dec_bit_buf.bit_pos=7-preroll_frame_offset[access_units]%8; + pstr_dec_data->dec_bit_buf.ptr_read_next=pstr_dec_data->dec_bit_buf.ptr_read_next+(preroll_frame_offset[access_units]/8); + } + + + //temp_read=ixheaacd_show_bits_buf(pstr_dec_data->dec_bit_buf,preroll_frame_offset[access_unit]); err = ixheaacd_usac_process(pstr_dec_data, num_channel_out, aac_dec_handle); + + switch (pstr_dec_data->str_usac_data.sbr_ratio_idx) { + case 0: + handle->aac_config.ui_sbr_mode = 0; + break; + case 1: + handle->aac_config.ui_sbr_mode = 1; + break; + case 2: + handle->aac_config.ui_sbr_mode = 1; + break; + case 3: + handle->aac_config.ui_sbr_mode = 3; + break; + + default: + handle->aac_config.ui_sbr_mode = 0; + } + if (err == -1) return err; - num_samples_out = pstr_dec_data->pstr_usac_data->output_samples; + num_samples_out = pstr_dec_data->str_usac_data.output_samples; ixheaacd_samples_sat(outbuffer, num_samples_out, pcmsize, - pstr_dec_data->pstr_usac_data->time_sample_vector, + pstr_dec_data->str_usac_data.time_sample_vector, out_bytes, *num_channel_out); -#ifdef ENABLE_DRC pstr_audio_specific_config->str_usac_config.str_usac_dec_config .usac_ext_gain_payload_len = - pstr_dec_data->pstr_frame_data->str_audio_specific_config + pstr_dec_data->str_frame_data.str_audio_specific_config .str_usac_config.str_usac_dec_config.usac_ext_gain_payload_len; memcpy( pstr_audio_specific_config->str_usac_config.str_usac_dec_config .usac_ext_gain_payload_buf, - pstr_dec_data->pstr_frame_data->str_audio_specific_config + pstr_dec_data->str_frame_data.str_audio_specific_config .str_usac_config.str_usac_dec_config.usac_ext_gain_payload_buf, - pstr_dec_data->pstr_frame_data->str_audio_specific_config + pstr_dec_data->str_frame_data.str_audio_specific_config .str_usac_config.str_usac_dec_config.usac_ext_gain_payload_len * sizeof(WORD8)); -#endif + + access_units++; + preroll_units--; + }while(preroll_units>=0); } return err; diff --git a/decoder/ixheaacd_drc_freq_dec.c b/decoder/ixheaacd_drc_freq_dec.c index 7b13dac..ce88aba 100644 --- a/decoder/ixheaacd_drc_freq_dec.c +++ b/decoder/ixheaacd_drc_freq_dec.c @@ -1008,21 +1008,21 @@ VOID ixheaacd_drc_apply(ia_drc_dec_struct *pstr_drc_dec, (num_qmf_sub_sample - alpha_val) * (WORD64)prev_frame_drc_sbr_factors[i]; - if (frame_size == 512) - { - drc_sbr_factors[num_qmf_sub_sample + j][i] = - (WORD32)(temp_drc >> 4); - } - else if (frame_size == 480) - { - drc_sbr_factors[num_qmf_sub_sample + j][i] = - ixheaacd_div_by_15(temp_drc); - } - else - { - drc_sbr_factors[num_qmf_sub_sample + j][i] = - (WORD32)(temp_drc >> 5); - } + if (frame_size == 512) + { + drc_sbr_factors[num_qmf_sub_sample + j][i] = + (WORD32)(temp_drc >> 4); + } + else if (frame_size == 480) + { + drc_sbr_factors[num_qmf_sub_sample + j][i] = + ixheaacd_div_by_15(temp_drc); + } + else + { + drc_sbr_factors[num_qmf_sub_sample + j][i] = + (WORD32)(temp_drc >> 5); + } if (960 == frame_size) { drc_sbr_factors[num_qmf_sub_sample + j][i] = diff --git a/decoder/ixheaacd_env_extr.c b/decoder/ixheaacd_env_extr.c index cca3ed3..4d908af 100644 --- a/decoder/ixheaacd_env_extr.c +++ b/decoder/ixheaacd_env_extr.c @@ -923,7 +923,7 @@ WORD8 ixheaacd_sbr_read_cpe(ia_sbr_header_data_struct *ptr_header_data, ixheaacd_sbr_env_dtdf_data(ptr_frame_data[1], it_bit_buff, ptr_header_data->usac_flag); - for (i = 0; i < ptr_header_data->noise_bands; i++) { + for (i = 0; i < ptr_header_data->pstr_freq_band_data->num_if_bands; i++) { ptr_frame_data[0]->sbr_invf_mode_prev[i] = ptr_frame_data[0]->sbr_invf_mode[i]; ptr_frame_data[1]->sbr_invf_mode_prev[i] = diff --git a/decoder/ixheaacd_error_codes.h b/decoder/ixheaacd_error_codes.h index 3476657..4820704 100644 --- a/decoder/ixheaacd_error_codes.h +++ b/decoder/ixheaacd_error_codes.h @@ -61,12 +61,15 @@ #define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_DRC_TARGET 0x00000811 #define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_FRAMSZ 0x00000812 #define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_ELDSBR 0x00000813 -#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_DELAY_MODE 0x00000804 -#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_DECODE_TYPE 0x00000805 -#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_PEAK_LIM_FLAG 0x00000806 -#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_CTRL_PARAM_IDX 0x00000807 -#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_GAIN_DELAY 0x00000808 -#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_CONST_DELAY_MODE 0x00000809 +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_LD_CONFIG 0x00000814 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_DELAY_MODE 0x00000815 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_DECODE_TYPE 0x00000816 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_PEAK_LIM_FLAG 0x00000817 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_CTRL_PARAM_IDX 0x00000818 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_GAIN_DELAY 0x00000819 +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_CONST_DELAY_MODE 0x0000081A +#define IA_ENHAACPLUS_DEC_CONFIG_NON_FATAL_INVALID_EFFECT_TYPE 0x0000081B +#define IA_ENHAACPLUS_DEC_CONFIG_NONFATAL_INVALID_TARGET_LOUDNESS 0x0000081C // Fatal Errors #define IA_ENHAACPLUS_DEC_CONFIG_FATAL_INVALID_SAMPLE_RATE 0xFFFF8800 diff --git a/decoder/ixheaacd_esbr_rom.h b/decoder/ixheaacd_esbr_rom.h index de93bab..57edc24 100644 --- a/decoder/ixheaacd_esbr_rom.h +++ b/decoder/ixheaacd_esbr_rom.h @@ -58,4 +58,4 @@ extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_24[24 * 24 * 2]; extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_32[32 * 32 * 2]; extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_40[40 * 80 * 2]; extern const FLOAT32 ixheaacd_sel_case[4][8]; -#endif \ No newline at end of file +#endif diff --git a/decoder/ixheaacd_ext_ch_ele.c b/decoder/ixheaacd_ext_ch_ele.c index b403456..bfa8d92 100644 --- a/decoder/ixheaacd_ext_ch_ele.c +++ b/decoder/ixheaacd_ext_ch_ele.c @@ -323,8 +323,8 @@ VOID ixheaacd_ms_stereo(ia_usac_data_struct *usac_data, WORD32 *r_spec, for (k = 0; k < ptr_sfb_info->sfb_width[sfb]; k++) { temp_r = *r_spec; temp_l = *l_spec; - *l_spec = temp_r + temp_l; - *r_spec = temp_l - temp_r; + *l_spec = ixheaacd_add32_sat(temp_r , temp_l); + *r_spec = ixheaacd_sub32_sat(temp_l , temp_r); r_spec++; l_spec++; } @@ -491,7 +491,7 @@ static WORD32 ixheaacd_cplx_pred_upmixing( else { for (k = 0; k < pstr_sfb_info->sfb_width[sfb]; k++, i++) { - dmx_re[i] = (l_spec[i] + (factor * r_spec[i])) >> 1; + dmx_re[i] = (WORD32)(((WORD64)l_spec[i] + ((WORD64)factor * (WORD64)r_spec[i])) >> 1); } } } @@ -541,12 +541,12 @@ static WORD32 ixheaacd_cplx_pred_upmixing( if (cplx_pred_used[grp][sfb]) { for (k = 0; k < pstr_sfb_info->sfb_width[sfb]; k++, i++) { WORD32 mid_side = - r_spec[i] - (WORD32)((WORD64)ixheaacd_mult32x32in64( + ixheaacd_sub32_sat(r_spec[i] , (WORD32)((WORD64)ixheaacd_mult32x32in64( alpha_q_re_temp, l_spec[i]) >> - 24); + 24)); - r_spec[i] = (factor) * (l_spec[i] - mid_side); - l_spec[i] = l_spec[i] + mid_side; + r_spec[i] = (factor) * (ixheaacd_sub32_sat(l_spec[i] , mid_side)); + l_spec[i] = ixheaacd_add32_sat(l_spec[i] , mid_side); } } else { diff --git a/decoder/ixheaacd_fft.c b/decoder/ixheaacd_fft.c index 677bcb0..ec7dab0 100644 --- a/decoder/ixheaacd_fft.c +++ b/decoder/ixheaacd_fft.c @@ -1154,14 +1154,14 @@ VOID ixheaacd_complex_fft_p2_dec(WORD32 *xr, WORD32 *xi, WORD32 nlength, x3r = x1r - (x3r << 1); x3i = x1i - (x3i << 1); - x0r = x0r + x1r; - x0i = x0i + x1i; - x1r = x0r - (x1r << 1); - x1i = x0i - (x1i << 1); - x2r = x2r - x3i; - x2i = x2i + x3r; - x3i = x2r + (x3i << 1); - x3r = x2i - (x3r << 1); + x0r = ixheaacd_add32_sat(x0r , x1r); + x0i = ixheaacd_add32_sat(x0i , x1i); + x1r = ixheaacd_sub32_sat(x0r , (x1r << 1)); + x1i = ixheaacd_sub32_sat(x0i , (x1i << 1)); + x2r = ixheaacd_sub32_sat(x2r , x3i); + x2i = ixheaacd_add32_sat(x2i , x3r); + x3i = ixheaacd_add32_sat(x2r , (x3i << 1)); + x3r = ixheaacd_sub32_sat(x2i , (x3r << 1)); *data = x0r; *(data + 1) = x0i; diff --git a/decoder/ixheaacd_freq_sca.c b/decoder/ixheaacd_freq_sca.c index 15db6fc..a29dd8f 100644 --- a/decoder/ixheaacd_freq_sca.c +++ b/decoder/ixheaacd_freq_sca.c @@ -17,6 +17,10 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ + +#include +#include +#include #include "ixheaacd_sbr_common.h" #include @@ -52,101 +56,301 @@ WORD32 ixheaacd_samp_rate_table[12] = {92017, 75132, 55426, 46009, WORD32 ixheaacd_v_offset_40[16] = {3 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 1 + 1, 0}; -static WORD32 ixheaacd_get_sr_idx_2(WORD32 samplerate) { - WORD32 i; - for (i = 0; i < 12; i++) { - if (ixheaacd_samp_rate_table[i] <= samplerate) break; + +static WORD32 ixheaacd_int_div(WORD32 num, WORD32 den) { + if (den != 0) { + WORD32 result = 0; + WORD32 temp = 0; + while (den <= num) { + temp = 0; + while (num >= (den << (temp + 1))) { + temp++; + } + result = result + (1 << temp); + num = num - (den * (1 << temp)); + } + return result; + } else { + return 0; } - return i; } -static WORD32 ixheaacd_get_sr_idx_4(WORD32 fs) { - if (92017 <= fs) return 0; - if (75132 <= fs) return 1; - if (55426 <= fs) return 2; - if (46009 <= fs) return 3; - if (42000 <= fs) return 4; - if (35777 <= fs) return 5; - if (27713 <= fs) return 6; - if (23004 <= fs) return 7; - if (18783 <= fs) return 8; - if (00000 <= fs) return 9; - return 0; + +VOID ixheaacd_aac_shellsort(WORD16 *in, WORD32 n) { + WORD32 i, j; + WORD32 inc; + WORD32 v, w; + + inc = 1; + + do { + inc = (((inc << 1) + inc) + 1); + } while (inc <= n); + + do { + inc = (ixheaacd_int_div(inc, 3)); + for (i = inc; i < n; i++) { + v = in[i]; + j = i; + + while ((w = in[(j - inc)]) > v) { + in[j] = w; + j = (j - inc); + + if (j < inc) break; + } + in[j] = v; + } + + } while (inc > 1); } -static PLATFORM_INLINE WORD16 ixheaacd_get_k0( - WORD32 sr_idx, WORD16 start_freq, ia_sbr_tables_struct *ptr_sbr_tables) { - WORD32 start_min = ptr_sbr_tables->env_extr_tables_ptr->start_min[sr_idx]; - WORD32 ixheaacd_drc_offset = - ptr_sbr_tables->env_extr_tables_ptr->offset_idx[sr_idx]; - return start_min + - ptr_sbr_tables->env_extr_tables_ptr - ->ixheaacd_drc_offset[ixheaacd_drc_offset][start_freq]; + + + +WORD32 +ixheaacd_calc_start_band(WORD32 fs, const WORD32 start_freq, FLOAT32 upsamp_fac) +{ + WORD32 k0_min; + WORD32 fs_mapped = 0; + + if (upsamp_fac == 4) { + fs = fs / 2; + } + + if (fs >= 0 && fs < 18783) { + fs_mapped = 16000; + } + else if (fs >= 18783 && fs < 23004) { + fs_mapped = 22050; + } + else if (fs >= 23004 && fs < 27713) { + fs_mapped = 24000; + } + else if (fs >= 27713 && fs < 35777) { + fs_mapped = 32000; + } + else if (fs >= 35777 && fs < 42000) { + fs_mapped = 40000; + } + else if (fs >= 42000 && fs < 46009) { + fs_mapped = 44100; + } + else if (fs >= 46009 && fs < 55426) { + fs_mapped = 48000; + } + else if (fs >= 55426 && fs < 75132) { + fs_mapped = 64000; + } + else if (fs >= 75132 && fs < 92017) { + fs_mapped = 88200; + } + else if (fs >= 92017) { + fs_mapped = 96000; + } + else { + return -1; + } + + if (upsamp_fac == 4) { + if (fs_mapped < 32000) { + k0_min = (WORD32)(((FLOAT32)(3000 * 2 * 32) / fs_mapped) + 0.5); + } + else { + if (fs_mapped < 64000) { + k0_min = (WORD32)(((FLOAT32)(4000 * 2 * 32) / fs_mapped) + 0.5); + } + else { + k0_min = (WORD32)(((FLOAT32)(5000 * 2 * 32) / fs_mapped) + 0.5); + } + } + } + else { + if (fs_mapped < 32000) { + k0_min = (WORD32)(((FLOAT32)(3000 * 2 * 64) / fs_mapped) + 0.5); + } + else { + if (fs_mapped < 64000) { + k0_min = (WORD32)(((FLOAT32)(4000 * 2 * 64) / fs_mapped) + 0.5); + } + else { + k0_min = (WORD32)(((FLOAT32)(5000 * 2 * 64) / fs_mapped) + 0.5); + } + } + } + + switch (fs_mapped) { + case 16000: + { + WORD32 v_offset[] = { -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7 }; + return (k0_min + v_offset[start_freq]); + } + break; + case 22050: + { + WORD32 v_offset[] = { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13 }; + return (k0_min + v_offset[start_freq]); + } + break; + case 24000: + { + WORD32 v_offset[] = { -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 }; + return (k0_min + v_offset[start_freq]); + } + break; + case 32000: + { + WORD32 v_offset[] = { -6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 }; + return (k0_min + v_offset[start_freq]); + } + break; + case 40000: + { + WORD32 v_offset[] = { -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 17, 19 }; + return (k0_min + v_offset[start_freq]); + } + break; + case 44100: + case 48000: + case 64000: + { + WORD32 v_offset[] = { -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20 }; + return (k0_min + v_offset[start_freq]); + } + break; + case 88200: + case 96000: + { + WORD32 v_offset[] = { -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24 }; + return (k0_min + v_offset[start_freq]); + } + break; + + default: + { + WORD32 v_offset[] = { 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24, 28, 33 }; + return (k0_min + v_offset[start_freq]); + } + } +} + +WORD32 +ixheaacd_calc_stop_band(WORD32 fs, const WORD32 stop_freq, FLOAT32 upsamp_fac) +{ + WORD32 result, i; + WORD16 arr_stop_freq[14]; + WORD32 k1_min; + WORD16 arr_diff_stop_freq[13]; + + if (upsamp_fac == 4) { + fs = fs / 2; + if (fs < 32000) { + k1_min = (WORD32)(((FLOAT32)(6000 * 2 * 32) / fs) + 0.5); + } + else { + if (fs < 64000) { + k1_min = (WORD32)(((FLOAT32)(8000 * 2 * 32) / fs) + 0.5); + } + else { + k1_min = (WORD32)(((FLOAT32)(10000 * 2 * 32) / fs) + 0.5); + } + } + } + else { + if (fs < 32000) { + k1_min = (WORD32)(((FLOAT32)(6000 * 2 * 64) / fs) + 0.5); + } + else { + if (fs < 64000) { + k1_min = (WORD32)(((FLOAT32)(8000 * 2 * 64) / fs) + 0.5); + } + else { + k1_min = (WORD32)(((FLOAT32)(10000 * 2 * 64) / fs) + 0.5); + } + } + } + + /*Calculate stop frequency vector*/ + for (i = 0; i <= 13; i++) { + arr_stop_freq[i] = (WORD32)(k1_min * pow(64.0 / k1_min, i / 13.0) + 0.5); + } + + + /*Ensure increasing bandwidth */ + for (i = 0; i <= 12; i++) { + arr_diff_stop_freq[i] = arr_stop_freq[i + 1] - arr_stop_freq[i]; + } + + ixheaacd_aac_shellsort(&arr_diff_stop_freq[0], 13); /*Sort bandwidth changes */ + + result = k1_min; + for (i = 0; i 64) { + *ptr_k2 = 64; + } } WORD16 ixheaacd_calc_master_frq_bnd_tbl( ia_freq_band_data_struct *pstr_freq_band_data, ia_sbr_header_data_struct *ptr_header_data, - ia_sbr_tables_struct *ptr_sbr_tables, ixheaacd_misc_tables *pstr_common_tables) { WORD32 k; WORD32 fs = ptr_header_data->out_sampling_freq; WORD16 bands; - WORD16 k0, k2, k1; + WORD16 k0 = 0, k2 = 0, k1; WORD32 k2_achived; WORD32 k2_diff; WORD32 incr; - WORD32 dk, sr_idx; + WORD32 dk; WORD16 vec_dk[MAX_OCTAVE + MAX_SECOND_REGION]; WORD16 *vec_dk0 = &vec_dk[0]; WORD16 *vec_dk1 = &vec_dk[MAX_OCTAVE]; WORD16 upsamp_fac = ptr_header_data->upsamp_fac; WORD16 *f_master_tbl = pstr_freq_band_data->f_master_tbl; WORD16 num_mf_bands; - WORD32 usac_flag = ptr_header_data->usac_flag; + k1 = 0; incr = 0; dk = 0; - if (upsamp_fac == 4) { - fs = fs / 2; - sr_idx = ixheaacd_get_sr_idx_4(fs); - k0 = pstr_common_tables->start_band[sr_idx][ptr_header_data->start_freq]; - } else { - sr_idx = ixheaacd_get_sr_idx_2(fs); - k0 = ixheaacd_get_k0(sr_idx, ptr_header_data->start_freq, ptr_sbr_tables); - if (usac_flag && fs == 40000) { - k0 = k0 + ixheaacd_v_offset_40[ptr_header_data->start_freq]; - } - } - if (ptr_header_data->stop_freq < 14) { - if (upsamp_fac == 4) { - k2 = pstr_common_tables->stop_band[sr_idx][ptr_header_data->stop_freq]; - k2 = (WORD16)ixheaacd_min32(64, k2); - if (fs == 20000) { - k2 = pstr_common_tables - ->stop_freq_table_fs40k_4[ptr_header_data->stop_freq]; - } - } else { - WORD32 stop_minv = ptr_sbr_tables->env_extr_tables_ptr->stop_min[sr_idx]; - k2 = (WORD16)ixheaacd_min32( - 64, stop_minv + - ptr_sbr_tables->env_extr_tables_ptr - ->stop_off[sr_idx][ptr_header_data->stop_freq]); - if (usac_flag && fs == 40000) { - k2 = pstr_common_tables - ->stop_freq_table_fs40k_2[ptr_header_data->stop_freq]; - } - } + ixheaacd_calc_k0_k2_bands(fs, + ptr_header_data->start_freq, + ptr_header_data->stop_freq, + upsamp_fac, + &k0, &k2); + - } else { - if (ptr_header_data->stop_freq == 14) - k2 = ixheaacd_shl16(k0, 1); - else - k2 = add_d(ixheaacd_shl16(k0, 1), k0); - } if (k2 > NO_SYNTHESIS_CHANNELS) { k2 = NO_SYNTHESIS_CHANNELS; } @@ -440,53 +644,6 @@ static VOID ixheaacd_derive_hi_lo_freq_bnd_tbls( pstr_freq_band_data->num_sf_bands[HIGH] = num_hf_bands; } -static WORD32 ixheaacd_int_div(WORD32 num, WORD32 den) { - if (den != 0) { - WORD32 result = 0; - WORD32 temp = 0; - while (den <= num) { - temp = 0; - while (num >= (den << (temp + 1))) { - temp++; - } - result = result + (1 << temp); - num = num - (den * (1 << temp)); - } - return result; - } else { - return 0; - } -} - -VOID ixheaacd_aac_shellsort(WORD16 *in, WORD32 n) { - WORD32 i, j; - WORD32 inc; - WORD32 v, w; - - inc = 1; - - do { - inc = (((inc << 1) + inc) + 1); - } while (inc <= n); - - do { - inc = (ixheaacd_int_div(inc, 3)); - for (i = inc; i < n; i++) { - v = in[i]; - j = i; - - while ((w = in[(j - inc)]) > v) { - in[j] = w; - j = (j - inc); - - if (j < inc) break; - } - in[j] = v; - } - - } while (inc > 1); -} - WORD32 ixheaacd_derive_noise_freq_bnd_tbl( ia_sbr_header_data_struct *ptr_header_data, ixheaacd_misc_tables *pstr_common_tables, @@ -544,15 +701,14 @@ WORD32 ixheaacd_derive_noise_freq_bnd_tbl( } WORD32 ixheaacd_calc_frq_bnd_tbls(ia_sbr_header_data_struct *ptr_header_data, - ia_sbr_tables_struct *ptr_sbr_tables, - ixheaacd_misc_tables *pstr_common_tables) { + ixheaacd_misc_tables *pstr_common_tables) { WORD32 err; WORD16 num_lf_bands, num_hf_bands, lsb, usb; ia_freq_band_data_struct *pstr_freq_band_data = ptr_header_data->pstr_freq_band_data; err = ixheaacd_calc_master_frq_bnd_tbl(pstr_freq_band_data, ptr_header_data, - ptr_sbr_tables, pstr_common_tables); + pstr_common_tables); if (err || (ptr_header_data->xover_band > pstr_freq_band_data->num_mf_bands)) { diff --git a/decoder/ixheaacd_freq_sca.h b/decoder/ixheaacd_freq_sca.h index a396555..f8f03fb 100644 --- a/decoder/ixheaacd_freq_sca.h +++ b/decoder/ixheaacd_freq_sca.h @@ -23,7 +23,7 @@ VOID ixheaacd_aac_shellsort(WORD16 *in, WORD32 n); WORD32 ixheaacd_calc_frq_bnd_tbls(ia_sbr_header_data_struct *ptr_header_data, - ia_sbr_tables_struct *ptr_sbr_tables, + ixheaacd_misc_tables *pstr_common_tables); VOID ixheaacd_calc_bands(WORD16 *diff, WORD16 start, WORD16 stop, diff --git a/decoder/ixheaacd_fwd_alias_cnx.c b/decoder/ixheaacd_fwd_alias_cnx.c index 749770d..27259ef 100644 --- a/decoder/ixheaacd_fwd_alias_cnx.c +++ b/decoder/ixheaacd_fwd_alias_cnx.c @@ -76,10 +76,10 @@ static VOID ixheaacd_synthesis_tool(WORD32 a[], WORD32 x[], WORD32 l, for (i = 0; i < l; i++) { s = x[i]; for (j = 1; j <= ORDER; j += 4) { - s -= ixheaacd_mul32_sh(a[j], x[i - j], (WORD8)(qshift)); - s -= ixheaacd_mul32_sh(a[j + 1], x[i - (j + 1)], (WORD8)(qshift)); - s -= ixheaacd_mul32_sh(a[j + 2], x[i - (j + 2)], (WORD8)(qshift)); - s -= ixheaacd_mul32_sh(a[j + 3], x[i - (j + 3)], (WORD8)(qshift)); + s = ixheaacd_sub32_sat(s,ixheaacd_mul32_sh(a[j], x[i - j], (WORD8)(qshift))); + s = ixheaacd_sub32_sat(s,ixheaacd_mul32_sh(a[j + 1], x[i - (j + 1)], (WORD8)(qshift))); + s = ixheaacd_sub32_sat(s,ixheaacd_mul32_sh(a[j + 2], x[i - (j + 2)], (WORD8)(qshift))); + s = ixheaacd_sub32_sat(s,ixheaacd_mul32_sh(a[j + 3], x[i - (j + 3)], (WORD8)(qshift))); } x[i] = s; } @@ -125,8 +125,8 @@ WORD32 ixheaacd_fwd_alias_cancel_tool( fac_signal[i] = (WORD32)(ptr_fac_signal_flt[i] * (1 << (16 - qshift))); for (i = 0; i < fac_length; i++) - ptr_overlap_buf[i] += - (WORD32)ixheaacd_mul32_sh(fac_signal[i], gain, (WORD8)(16 - qshift)); + ptr_overlap_buf[i] = + ixheaacd_add32_sat(ptr_overlap_buf[i],(WORD32)ixheaacd_mul32_sh(fac_signal[i], gain, (WORD8)(16 - qshift))); return err; } @@ -155,6 +155,19 @@ WORD32 ixheaacd_fr_alias_cnx_fix(WORD32 *x_in, WORD32 len, WORD32 fac_length, return -1; } + if( FAC_LENGTH < fac_length ) + { + return -1; + } + if((1 + (len /2)) < (fac_length + 1)) + { + return -1; + } + if( (len/2 + 1) > (2 * LEN_FRAME - fac_length - 1)) + { + return -1; + } + if (lp_filt_coeff != NULL && fac_data_out != NULL) { memset(fac_data_out - 16, 0, ORDER * sizeof(WORD32)); err = ixheaacd_acelp_mdct(x_in, fac_data_out, preshift, fac_length, diff --git a/decoder/ixheaacd_hcr.h b/decoder/ixheaacd_hcr.h index 827867b..e872764 100644 --- a/decoder/ixheaacd_hcr.h +++ b/decoder/ixheaacd_hcr.h @@ -41,4 +41,4 @@ WORD32 ixheaacd_ltp_data(WORD32 object_type, ia_ics_info_struct* ics, ltp_info* ltp, ia_handle_bit_buf_struct bs, WORD32 frame_len); -#endif \ No newline at end of file +#endif diff --git a/decoder/ixheaacd_headerdecode.c b/decoder/ixheaacd_headerdecode.c index bdcb3d5..3f504c2 100644 --- a/decoder/ixheaacd_headerdecode.c +++ b/decoder/ixheaacd_headerdecode.c @@ -19,6 +19,10 @@ */ #include #include +#include "ixheaacd_constants.h" +#include +#include +#include #include "ixheaacd_sbr_common.h" #include "ixheaacd_bitbuffer.h" @@ -610,17 +614,7 @@ WORD32 ixheaacd_ga_hdr_dec(ia_aac_dec_state_struct *aac_state_struct, pstr_audio_specific_config->sampling_frequency; pstr_audio_specific_config->ext_samp_frequency_index = pstr_audio_specific_config->samp_frequency_index; - if (pstr_audio_specific_config->str_usac_config - .core_sbr_framelength_index == 4) { - pstr_audio_specific_config->sampling_frequency = - pstr_audio_specific_config->ext_sampling_frequency / 4; - } else if ((pstr_audio_specific_config->str_usac_config - .core_sbr_framelength_index == 2) || - (pstr_audio_specific_config->str_usac_config - .core_sbr_framelength_index == 3)) { - pstr_audio_specific_config->sampling_frequency = - pstr_audio_specific_config->ext_sampling_frequency / 2; - } + for (i = 0; i < sizeof(ixheaacd_sampl_freq_idx_table) / sizeof(ixheaacd_sampl_freq_idx_table[0]); i++) { @@ -804,10 +798,10 @@ WORD32 ixheaacd_check_if_adts(ia_adts_header_struct *adts, result = ixheaacd_adtsframe(adts, it_bit_buff); - max_frm_len_per_ch = 768 * (adts->no_raw_data_blocks + 1); + max_frm_len_per_ch = ixheaacd_mult32(768 , (adts->no_raw_data_blocks + 1)); if (adts->channel_configuration != 0) - max_frm_len_per_ch = max_frm_len_per_ch * adts->channel_configuration; + max_frm_len_per_ch = ixheaacd_mult32(max_frm_len_per_ch, adts->channel_configuration); else max_frm_len_per_ch = max_frm_len_per_ch * usr_max_ch; diff --git a/decoder/ixheaacd_huff_code_reorder.c b/decoder/ixheaacd_huff_code_reorder.c index bc74d6a..f02127a 100644 --- a/decoder/ixheaacd_huff_code_reorder.c +++ b/decoder/ixheaacd_huff_code_reorder.c @@ -1362,7 +1362,7 @@ static PLATFORM_INLINE UWORD16 ixheaacd_huff_dec_word_hcr_non_pcw( sp1 = out1; sp2 = out2; - + if (out1) { if (flush_cw & 0x80000000) { diff --git a/decoder/ixheaacd_imdct.c b/decoder/ixheaacd_imdct.c index 9bf4117..302c981 100644 --- a/decoder/ixheaacd_imdct.c +++ b/decoder/ixheaacd_imdct.c @@ -72,7 +72,8 @@ extern const FLOAT64 ixheaacd_power_10_table[28]; static WORD32 ixheaacd_calc_max_spectralline(WORD32 *p_in_ibuffer, WORD32 n) { WORD32 k, shiftp, itemp = 0; for (k = 0; k < n; k++) { - if (ABS(p_in_ibuffer[k]) > itemp) itemp = ABS(p_in_ibuffer[k]); + + if (ixheaacd_abs32_sat(p_in_ibuffer[k]) > itemp) itemp = ixheaacd_abs32_sat(p_in_ibuffer[k]); } shiftp = ixheaacd_norm32(itemp); @@ -106,7 +107,7 @@ void ixheaacd_calc_pre_twid_dec(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, ptr_y = &ptr_x[2 * nlength - 1]; for (i = 0; i < nlength; i++) { - *r_ptr++ = ((ixheaacd_mult32(-(*ptr_x), (*cos_ptr)) - + *r_ptr++ = ((ixheaacd_mult32(ixheaacd_negate32_sat(*ptr_x), (*cos_ptr)) - ixheaacd_mult32((*ptr_y), (*sin_ptr)))); *i_ptr++ = ((ixheaacd_mult32((*ptr_y), (*cos_ptr++)) - ixheaacd_mult32((*ptr_x), (*sin_ptr++)))); @@ -398,7 +399,9 @@ static WORD32 ixheaacd_fd_imdct_short(ia_usac_data_struct *usac_data, for (k = 0; k < ixheaacd_drc_offset->n_long; k++) { p_out_buffer[k] = ((FLOAT32)p_out_ibuffer[k]) * qfac; } - ixheaacd_lpd_bpf_fix(usac_data, 1, p_out_buffer, st); + err_code = ixheaacd_lpd_bpf_fix(usac_data, 1, p_out_buffer, st); + if(err_code != 0) + return err_code; for (k = 0; k < ixheaacd_drc_offset->n_long; k++) { p_out_ibuffer[k] = (WORD32)(p_out_buffer[k] * (1 << 15)); @@ -494,7 +497,9 @@ static WORD32 ixheaacd_fd_imdct_long(ia_usac_data_struct *usac_data, for (k = 0; k < ixheaacd_drc_offset->n_long; k++) { p_out_buffer[k] = ((FLOAT32)p_out_ibuffer[k]) * qfac; } - ixheaacd_lpd_bpf_fix(usac_data, 0, p_out_buffer, st); + err_code = ixheaacd_lpd_bpf_fix(usac_data, 0, p_out_buffer, st); + if(err_code != 0) + return err_code; for (k = 0; k < ixheaacd_drc_offset->n_long; k++) { p_out_ibuffer[k] = (WORD32)(p_out_buffer[k] * (1 << 15)); diff --git a/decoder/ixheaacd_init_config.c b/decoder/ixheaacd_init_config.c index e776a65..5555736 100644 --- a/decoder/ixheaacd_init_config.c +++ b/decoder/ixheaacd_init_config.c @@ -85,9 +85,30 @@ UWORD32 ixheaacd_sbr_ratio(UWORD32 core_sbr_framelength_idx) { return sbr_ratio_index; } +WORD32 ixheaacd_get_sample_freq_indx(WORD32 sampling_freq) +{ + WORD32 sampling_rate_tbl[] = { + 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, + 8000, 7350, 0, 0, 0}; + + WORD32 index; + WORD32 tbl_size = sizeof(sampling_rate_tbl)/sizeof(WORD32) - 1; + + for (index = 0; index < tbl_size; index++) { + if (sampling_rate_tbl[index] == sampling_freq) break; + } + + if (index > tbl_size) { + return tbl_size - 1; + } + + return index; +} UWORD32 ixheaacd_sbr_params(UWORD32 core_sbr_framelength_idx, WORD32 *output_framelength, WORD32 *block_size, - WORD32 *output_samples) { + WORD32 *output_samples, + WORD32 * sample_rate_layer, + UWORD32 * sample_freq_indx) { UWORD32 sbr_ratio_index = 0x0FF; *output_framelength = -1; @@ -110,21 +131,27 @@ UWORD32 ixheaacd_sbr_params(UWORD32 core_sbr_framelength_idx, *output_framelength = USAC_OUT_FRAMELENGTH_2048; *block_size = 768; *output_samples = (*block_size * 8) / 3; + *sample_rate_layer = (*sample_rate_layer * 3) >> 3; break; case 3: sbr_ratio_index = USAC_SBR_RATIO_INDEX_2_1; *output_framelength = USAC_OUT_FRAMELENGTH_2048; *block_size = 1024; *output_samples = *block_size * 2; + *sample_rate_layer = *sample_rate_layer >> 1; break; case 4: sbr_ratio_index = USAC_SBR_RATIO_INDEX_4_1; *output_framelength = USAC_OUT_FRAMELENGTH_4096; *block_size = 1024; *output_samples = *block_size * 4; + *sample_rate_layer = *sample_rate_layer >> 2; break; } + *sample_freq_indx = ixheaacd_get_sample_freq_indx(*sample_rate_layer); + + return sbr_ratio_index; } @@ -210,16 +237,13 @@ VOID ixheaacd_sbr_config(ia_bit_buf_struct *it_bit_buff, WORD32 ixheaacd_ext_element_config( ia_bit_buf_struct *it_bit_buff, ia_usac_dec_element_config_struct *pstr_usac_element_config -#ifdef ENABLE_DRC , UWORD8 *ptr_usac_ext_ele_payload, WORD32 *ptr_usac_ext_ele_payload_len -#endif + ,WORD32 *preroll_flag ) { UWORD32 usac_ext_element_type, usac_ext_element_config_length, flag; -#ifdef ENABLE_DRC UWORD32 i; -#endif ixheaacd_read_escape_value(it_bit_buff, &(usac_ext_element_type), 4, 8, 16); @@ -228,9 +252,7 @@ WORD32 ixheaacd_ext_element_config( flag = ixheaacd_read_bits_buf(it_bit_buff, 1); -#ifdef ENABLE_DRC *ptr_usac_ext_ele_payload_len = 0; -#endif if (flag) { ixheaacd_read_escape_value( @@ -249,8 +271,8 @@ WORD32 ixheaacd_ext_element_config( switch (usac_ext_element_type) { case ID_EXT_ELE_FILL: break; -#ifdef ENABLE_DRC case ID_EXT_ELE_AUDIOPREROLL: + *preroll_flag=1; break; case ID_EXT_ELE_UNI_DRC: for (i = 0; i < usac_ext_element_config_length; i++) { @@ -258,7 +280,6 @@ WORD32 ixheaacd_ext_element_config( } *ptr_usac_ext_ele_payload_len = usac_ext_element_config_length; break; -#endif default: if ((it_bit_buff->cnt_bits >> 3) < (WORD32)usac_ext_element_config_length) @@ -352,6 +373,7 @@ WORD32 ixheaacd_decoder_config( ixheaacd_read_escape_value( it_bit_buff, &(pstr_usac_decoder_config->num_elements), 4, 8, 16); pstr_usac_decoder_config->num_elements += 1; + pstr_usac_decoder_config->preroll_flag=0; if (pstr_usac_decoder_config->num_elements > USAC_MAX_ELEMENTS) { return -1; @@ -393,20 +415,17 @@ WORD32 ixheaacd_decoder_config( case ID_USAC_EXT: err = ixheaacd_ext_element_config( it_bit_buff, pstr_usac_element_config -#ifdef ENABLE_DRC , &pstr_usac_decoder_config->usac_ext_ele_payload_buf[elem_idx][0], &pstr_usac_decoder_config->usac_ext_ele_payload_len[elem_idx] -#endif + ,&(pstr_usac_decoder_config->preroll_flag) ); -#ifdef ENABLE_DRC if (pstr_usac_decoder_config->usac_ext_ele_payload_len[elem_idx] > 0) { pstr_usac_decoder_config->usac_ext_ele_payload_present[elem_idx] = 1; } else { pstr_usac_decoder_config->usac_ext_ele_payload_present[elem_idx] = 0; } -#endif if (err != 0) return -1; break; default: @@ -418,11 +437,8 @@ WORD32 ixheaacd_decoder_config( } WORD32 ixheaacd_config_extension( - ia_bit_buf_struct *it_bit_buff -#ifdef ENABLE_DRC - , + ia_bit_buf_struct *it_bit_buff, ia_usac_decoder_config_struct *pstr_usac_decoder_config -#endif ) { UWORD32 i, j; UWORD32 num_config_extensions; @@ -434,13 +450,11 @@ WORD32 ixheaacd_config_extension( return -1; } -#ifdef ENABLE_DRC pstr_usac_decoder_config->num_config_extensions = num_config_extensions; memset(pstr_usac_decoder_config->usac_cfg_ext_info_len, 0, USAC_MAX_CONFIG_EXTENSIONS * sizeof(WORD32)); memset(pstr_usac_decoder_config->usac_cfg_ext_info_present, 0, USAC_MAX_CONFIG_EXTENSIONS * sizeof(WORD32)); -#endif for (j = 0; j < num_config_extensions; j++) { UWORD32 tmp; @@ -460,7 +474,6 @@ WORD32 ixheaacd_config_extension( if ((WORD32)usac_config_ext_len > (it_bit_buff->cnt_bits >> 3)) { return -1; } -#ifdef ENABLE_DRC if (ID_CONFIG_EXT_LOUDNESS_INFO == usac_config_ext_type) { for (i = 0; i < usac_config_ext_len; i++) { UWORD8 byte_val = ixheaacd_read_bits_buf(it_bit_buff, 8); @@ -470,12 +483,9 @@ WORD32 ixheaacd_config_extension( usac_config_ext_len; pstr_usac_decoder_config->usac_cfg_ext_info_present[j] = 1; } else { -#endif for (i = 0; i < usac_config_ext_len; i++) tmp = ixheaacd_read_bits_buf(it_bit_buff, 8); -#ifdef ENABLE_DRC } -#endif break; } } @@ -530,11 +540,8 @@ WORD32 ixheaacd_config(ia_bit_buf_struct *it_bit_buff, tmp = ixheaacd_read_bits_buf(it_bit_buff, 1); if (tmp) { - err = ixheaacd_config_extension(it_bit_buff -#ifdef ENABLE_DRC - , + err = ixheaacd_config_extension(it_bit_buff, &pstr_usac_conf->str_usac_dec_config -#endif ); if (err != 0) return -1; } @@ -556,4 +563,4 @@ VOID ixheaacd_conf_default(ia_usac_config_struct *pstr_usac_conf) { pstr_usac_conf->str_usac_dec_config.usac_element_type[i] = ID_USAC_INVALID; return; -} \ No newline at end of file +} diff --git a/decoder/ixheaacd_lpc.c b/decoder/ixheaacd_lpc.c index 82b1a74..0d753a6 100644 --- a/decoder/ixheaacd_lpc.c +++ b/decoder/ixheaacd_lpc.c @@ -202,7 +202,7 @@ static VOID ixheaacd_lsf_2_lsp_conversion_float(FLOAT32 lsf[], FLOAT32 lsp[], return; } -static VOID ixheaacd_bass_post_filter(FLOAT32 *synth_sig, WORD32 *pitch, +static WORD32 ixheaacd_bass_post_filter(FLOAT32 *synth_sig, WORD32 *pitch, FLOAT32 *pitch_gain, FLOAT32 *synth_out, WORD32 len_fr, WORD32 len2, FLOAT32 bpf_prev[]) { @@ -223,7 +223,8 @@ static VOID ixheaacd_bass_post_filter(FLOAT32 *synth_sig, WORD32 *pitch, for (num_subfr = 0; num_subfr < len_fr; num_subfr += LEN_SUBFR, sf++) { pitch_lag = pitch[sf]; gain = pitch_gain[sf]; - + if(((pitch_lag >> 1) + 96 - num_subfr) > MAX_PITCH) + return -1; if (gain > 1.0f) gain = 1.0f; if (gain < 0.0f) gain = 0.0f; @@ -290,7 +291,7 @@ static VOID ixheaacd_bass_post_filter(FLOAT32 *synth_sig, WORD32 *pitch, } } - return; + return 0; } void ixheaacd_reorder_lsf(float *lsf, float min_dist, int n) { @@ -600,10 +601,10 @@ WORD32 ixheaacd_lpd_dec(ia_usac_data_struct *usac_data, } if (mod[3] == 0) { - ixheaacd_bass_post_filter(synth, pitch, pitch_gain, fsynth, len_fr, + err = ixheaacd_bass_post_filter(synth, pitch, pitch_gain, fsynth, len_fr, synth_delay, st->bpf_prev); } else { - ixheaacd_bass_post_filter(synth, pitch, pitch_gain, fsynth, len_fr, + err = ixheaacd_bass_post_filter(synth, pitch, pitch_gain, fsynth, len_fr, synth_delay - (len_subfrm / 2), st->bpf_prev); } return err; @@ -653,7 +654,7 @@ WORD32 ixheaacd_lpd_dec_update(ia_usac_lpd_decoder_handle tddec, return err; } -void ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, WORD32 is_short_flag, +WORD32 ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, WORD32 is_short_flag, FLOAT32 out_buffer[], ia_usac_lpd_decoder_handle st) { WORD32 i, tp, k; float synth_buf[MAX_PITCH + SYNTH_DELAY_LMAX + LEN_SUPERFRAME]; @@ -662,6 +663,7 @@ void ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, WORD32 is_short_flag, WORD32 pitch[NUM_SUBFR_SUPERFRAME_BY2 + 3]; float pitch_gain[NUM_SUBFR_SUPERFRAME_BY2 + 3]; WORD32 len_fr, lpd_sbf_len, lpd_delay, num_subfr_by2, synth_delay, fac_length; + WORD32 err = 0; len_fr = usac_data->ccfl; lpd_sbf_len = (NUM_FRAMES * usac_data->num_subfrm) / 2; @@ -709,12 +711,14 @@ void ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, WORD32 is_short_flag, } } - ixheaacd_bass_post_filter(synth, pitch, pitch_gain, signal_out, + err = ixheaacd_bass_post_filter(synth, pitch, pitch_gain, signal_out, (lpd_sbf_len + 2) * LEN_SUBFR + LEN_SUBFR, len_fr - (lpd_sbf_len + 2) * LEN_SUBFR, st->bpf_prev); + if(err != 0) + return err; ixheaacd_mem_cpy(signal_out, out_buffer, (lpd_sbf_len + 2) * LEN_SUBFR + LEN_SUBFR); - return; + return err; } diff --git a/decoder/ixheaacd_lpfuncs.c b/decoder/ixheaacd_lpfuncs.c index 5f30eb9..747dd7c 100644 --- a/decoder/ixheaacd_lpfuncs.c +++ b/decoder/ixheaacd_lpfuncs.c @@ -139,7 +139,7 @@ VOID ixheaacd_process_win_seq(WORD32 *coef, WORD32 *prev, WORD16 *out, ixheaacd_mult32x16in32(coef[SIZE08 + i], window_long[2 * i]), (q_shift + 1)); - accu = temp1 + ((WORD32)prev[i] << 16); + accu = ixheaacd_add32_sat(temp1 , ((WORD32)prev[i] << 16)); out[ch_fac * i] = ixheaacd_round16(accu << 1); accu = ixheaacd_shl32_dir_sat_limit( @@ -192,9 +192,9 @@ VOID ixheaacd_process_win_seq(WORD32 *coef, WORD32 *prev, WORD16 *out, *out1 = ixheaacd_round16(accu << 2); out1 += ch_fac; - accu = (ixheaacd_shl32_dir_sat_limit( + accu = ixheaacd_sub32_sat(ixheaacd_shl32_dir_sat_limit( ixheaacd_mult32x16in32(ixheaacd_negate32_sat(temp_coef), win2), - q_shift) - + q_shift), ixheaacd_mult32x16in32_drc(prev1, win4)); *out2 = ixheaacd_round16(accu << 2); out2 -= ch_fac; @@ -414,10 +414,12 @@ VOID ixheaacd_imdct_process(ia_aac_dec_overlap_info *ptr_aac_dec_overlap_info, case LONG_STOP_SEQUENCE: if (1024 == ptr_ics_info->frame_length) { + ia_ics_info_struct *tmp_ptr_ics_info = ptr_ics_info; (*ixheaacd_post_twid_overlap_add)( out_samples, ptr_spec_coeff, ptr_aac_tables->pstr_imdct_tables, 1024, ptr_overlap_buf, q_shift, ptr_long_window, ch_fac); + ptr_ics_info = tmp_ptr_ics_info; } if ((512 == ptr_ics_info->frame_length) || (480 == ptr_ics_info->frame_length)) { @@ -826,4 +828,4 @@ void ixheaacd_eld_dec_windowing(WORD32 *ptr_spect_coeff, const WORD16 *p_win, *p_out2++ = ixheaacd_shr32(win_op, q_shift); } } -} \ No newline at end of file +} diff --git a/decoder/ixheaacd_lpp_tran.c b/decoder/ixheaacd_lpp_tran.c index e1631c2..95d60e5 100644 --- a/decoder/ixheaacd_lpp_tran.c +++ b/decoder/ixheaacd_lpp_tran.c @@ -985,7 +985,7 @@ VOID ixheaacd_hf_generator(ia_sbr_hf_generator_struct *hf_generator, ixheaacd_mult32(cov_matrix.phi_02, cov_matrix.phi_11))) >> (LPC_SCALE_FACTOR - 1); tmp_i = (ixheaacd_sub32_sat( - ixheaacd_add32( + ixheaacd_add32_sat( ixheaacd_mult32(cov_matrix.phi_01_im, cov_matrix.phi_12), ixheaacd_mult32(cov_matrix.phi_01, cov_matrix.phi_12_im)), ixheaacd_mult32(cov_matrix.phi_02_im, cov_matrix.phi_11))) >> diff --git a/decoder/ixheaacd_lt_predict.h b/decoder/ixheaacd_lt_predict.h index 1600421..4aa69e0 100644 --- a/decoder/ixheaacd_lt_predict.h +++ b/decoder/ixheaacd_lt_predict.h @@ -51,4 +51,4 @@ VOID ixheaacd_filter_bank_ltp(ia_aac_dec_tables_struct *aac_tables_ptr, WORD32 *out_mdct, UWORD32 object_type, UWORD32 frame_len); -#endif \ No newline at end of file +#endif diff --git a/decoder/ixheaacd_main.h b/decoder/ixheaacd_main.h index 76a3b31..bf80bda 100644 --- a/decoder/ixheaacd_main.h +++ b/decoder/ixheaacd_main.h @@ -220,7 +220,7 @@ WORD32 ixheaacd_fwd_alias_cancel_tool( ia_usac_data_struct *usac_data, ia_td_frame_data_struct *pstr_td_frame_data, WORD32 fac_length, FLOAT32 *iaq, WORD32 gain); -VOID ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, WORD32 is_short, +WORD32 ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, WORD32 is_short, FLOAT32 out_buffer[], ia_usac_lpd_decoder_handle st); VOID ixheaacd_reset_acelp_data_fix(ia_usac_data_struct *usac_data, diff --git a/decoder/ixheaacd_memory_standards.h b/decoder/ixheaacd_memory_standards.h index b733e9d..2494751 100644 --- a/decoder/ixheaacd_memory_standards.h +++ b/decoder/ixheaacd_memory_standards.h @@ -25,12 +25,12 @@ /*****************************************************************************/ /* standard memory table descriptor for libraries */ typedef struct { - UWORD32 ui_size; /* size of the memory in bytes */ - UWORD32 ui_alignment; /* alignment in bytes */ - UWORD32 ui_type; /* type of memory */ - UWORD32 ui_placement[2]; /* 64 bit placement info */ - UWORD32 ui_priority; /* the importance for placement */ - UWORD32 ui_placed[2]; /* the o_red location for placement */ + UWORD32 ui_size; /* size of the memory in bytes */ + UWORD32 ui_alignment; /* alignment in bytes */ + UWORD32 ui_type; /* type of memory */ + UWORD32 ui_placement[2]; /* 64 bit placement info */ + UWORD32 ui_priority; /* the importance for placement */ + UWORD32 ui_placed[2]; /* the o_red location for placement */ } ia_mem_info_struct; /*****************************************************************************/ diff --git a/decoder/ixheaacd_mps_dec.c b/decoder/ixheaacd_mps_dec.c index 8ef7458..fd3b632 100644 --- a/decoder/ixheaacd_mps_dec.c +++ b/decoder/ixheaacd_mps_dec.c @@ -79,21 +79,19 @@ extern ia_huff_cld_nodes_struct ixheaacd_huff_cld_nodes; extern ia_huff_icc_nodes_struct ixheaacd_huff_icc_nodes; extern ia_huff_res_nodes_struct ixheaacd_huff_reshape_nodes; -ia_mps_dec_state_struct* ixheaacd_mps_create( +VOID ixheaacd_mps_create(ia_mps_dec_state_struct* self, WORD32 bs_frame_len, WORD32 residual_coding, ia_usac_dec_mps_config_struct* mps212_config) { WORD32 num_ch; WORD32 err_code = 0; - ia_mps_dec_state_struct* self = NULL; ia_mps_bs_frame bs_frame; - self = (ia_mps_dec_state_struct*)calloc(1, sizeof(ia_mps_dec_state_struct)); - if (self == NULL) return 0; - self->num_parameter_sets = 1; self->qmf_band_count = 64; + self->res_ch_count = 0; + if (mps212_config) { self->config = mps212_config; self->frame_length = bs_frame_len; @@ -111,11 +109,6 @@ ia_mps_dec_state_struct* ixheaacd_mps_create( err_code = ixheaacd_mps_header_decode(self); - if (err_code == -1) { - free(self); - return 0; - } - if ((self->residual_coding) && (self->res_bands > 0)) self->res_ch_count++; ixheaacd_mps_env_init(self); @@ -154,7 +147,7 @@ ia_mps_dec_state_struct* ixheaacd_mps_create( memset(self->opd_smooth.smooth_r_phase, 0, MAX_PARAMETER_BANDS * sizeof(WORD32)); - return self; + return; } static FLOAT32 ixheaacd_tsd_mul_re[] = { @@ -278,12 +271,13 @@ VOID ixheaacd_mps_create_w(ia_mps_dec_state_struct* self) { ixheaacd_mps_decor(self); ixheaacd_mps_mix_res_decor(self); } -VOID ixheaacd_mps_apply(ia_mps_dec_state_struct* self, +WORD32 ixheaacd_mps_apply(ia_mps_dec_state_struct* self, FLOAT32** input_buffer[4], FLOAT32 (*output_buffer)[4096]) { WORD32 ch, ts, qs; WORD32 time_slots = self->time_slots; WORD32 in_ch_count = self->in_ch_count + self->res_ch_count; + WORD32 err = 0; self->output_buffer = output_buffer; @@ -302,7 +296,7 @@ VOID ixheaacd_mps_apply(ia_mps_dec_state_struct* self, self->present_time_slot += time_slots; - if (self->present_time_slot < self->time_slots) return; + if (self->present_time_slot < self->time_slots) return 0; self->present_time_slot = 0; @@ -324,9 +318,12 @@ VOID ixheaacd_mps_apply(ia_mps_dec_state_struct* self, ixheaacd_mps_time_env_shaping(self); } - ixheaacd_mps_temp_process(self); + err = ixheaacd_mps_temp_process(self); + if(err) + return err; self->parse_nxt_frame = 1; + return 0; } #define min(a, b) (((a) < (b)) ? (a) : (b)) diff --git a/decoder/ixheaacd_mps_dec.h b/decoder/ixheaacd_mps_dec.h index 060f6bf..3a13d65 100644 --- a/decoder/ixheaacd_mps_dec.h +++ b/decoder/ixheaacd_mps_dec.h @@ -356,7 +356,7 @@ VOID ixheaacd_mps_time_env_shaping(ia_mps_dec_state_struct *self); VOID ixheaacd_mps_pre_matrix_mix_matrix_smoothing( ia_mps_dec_state_struct *self); VOID ixheaacd_mps_smoothing_opd(ia_mps_dec_state_struct *self); -VOID ixheaacd_mps_temp_process(ia_mps_dec_state_struct *self); +WORD32 ixheaacd_mps_temp_process(ia_mps_dec_state_struct *self); VOID ixheaacd_mps_par2umx_ps(ia_mps_dec_state_struct *self, ia_mps_bs_frame *curr_bit_stream, WORD32 *h_real, diff --git a/decoder/ixheaacd_mps_interface.h b/decoder/ixheaacd_mps_interface.h index 4ed0d4a..7a6412d 100644 --- a/decoder/ixheaacd_mps_interface.h +++ b/decoder/ixheaacd_mps_interface.h @@ -20,7 +20,7 @@ #ifndef IXHEAACD_MPS_INTERFACE_H #define IXHEAACD_MPS_INTERFACE_H -ia_mps_dec_state_struct* ixheaacd_mps_create( +VOID ixheaacd_mps_create(ia_mps_dec_state_struct* self, WORD32 bs_frame_len, WORD32 residual_coding, ia_usac_dec_mps_config_struct* usac_mps_config); @@ -28,7 +28,7 @@ VOID ixheaacd_mps_frame_parsing(ia_mps_dec_state_struct* self, WORD32 independency_flag, ia_handle_bit_buf_struct it_bit_buff); -VOID ixheaacd_mps_apply(ia_mps_dec_state_struct* self, FLOAT32** pointers[4], +WORD32 ixheaacd_mps_apply(ia_mps_dec_state_struct* self, FLOAT32** pointers[4], FLOAT32 (*out_samples)[4096]); #endif diff --git a/decoder/ixheaacd_mps_parse.c b/decoder/ixheaacd_mps_parse.c index 5c8fd4b..9326edf 100644 --- a/decoder/ixheaacd_mps_parse.c +++ b/decoder/ixheaacd_mps_parse.c @@ -576,7 +576,7 @@ VOID ixheaacd_mps_frame_parsing(ia_mps_dec_state_struct *self, for (h = 2; h <= p; h++) { b = k - p + h; - c_64 *= b; + c_64 = c_64 * (b / h); ixheaacd_longmult1(c, b, c, 5); b = h; ixheaacd_longdiv(c, b, c, r, 5); @@ -1056,4 +1056,4 @@ WORD32 ixheaacd_mps_header_decode(ia_mps_dec_state_struct *self) { self->bs_high_rate_mode = self->config->bs_high_rate_mode; return 0; -} \ No newline at end of file +} diff --git a/decoder/ixheaacd_mps_temp_process.c b/decoder/ixheaacd_mps_temp_process.c index 32f47c8..b7ca817 100644 --- a/decoder/ixheaacd_mps_temp_process.c +++ b/decoder/ixheaacd_mps_temp_process.c @@ -213,8 +213,9 @@ static VOID ixheaacd_mps_subbandtp(ia_mps_dec_state_struct* self, WORD32 ts) { } } -VOID ixheaacd_mps_temp_process(ia_mps_dec_state_struct* self) { +WORD32 ixheaacd_mps_temp_process(ia_mps_dec_state_struct* self) { WORD32 ch, ts, hyb; + WORD32 err = 0; for (ch = 0; ch < self->out_ch_count; ch++) { for (ts = 0; ts < self->time_slots; ts++) { @@ -232,10 +233,13 @@ VOID ixheaacd_mps_temp_process(ia_mps_dec_state_struct* self) { ixheaacd_mps_qmf_hyb_synthesis(self); for (ch = 0; ch < self->out_ch_count; ch++) { - ixheaacd_sbr_dec_from_mps(&self->qmf_out_dir[ch][0][0].re, + err = ixheaacd_sbr_dec_from_mps(&self->qmf_out_dir[ch][0][0].re, self->p_sbr_dec[ch], self->p_sbr_frame[ch], self->p_sbr_header[ch]); + if(err) + return err; } ixheaacd_mps_synt_calc(self); + return err; } diff --git a/decoder/ixheaacd_process.c b/decoder/ixheaacd_process.c index 1896f24..67037a3 100644 --- a/decoder/ixheaacd_process.c +++ b/decoder/ixheaacd_process.c @@ -145,7 +145,7 @@ static VOID ixheaacd_sbr_ext_data_read( cnt_bits_in = it_bit_buff->cnt_bits; count = (it_bit_buff->cnt_bits) >> 3; if (count > 0) { - if ((count < MAXSBRBYTES) && + if ( (esbr_bit_str->no_elements < MAXNRSBRELEMENTS)) { esbr_bit_str->str_sbr_ele[esbr_bit_str->no_elements].extension_type = EXT_SBR_DATA; @@ -167,17 +167,13 @@ static VOID ixheaacd_sbr_ext_data_read( static VOID ixheaacd_read_ext_element( UWORD32 usac_ext_element_default_length, UWORD32 usac_ext_element_payload_frag, ia_bit_buf_struct *it_bit_buff -#ifdef ENABLE_DRC , ia_usac_decoder_config_struct *pstr_usac_dec_config, WORD32 elem_idx -#endif ) { UWORD32 usac_ext_element_present; UWORD32 usac_ext_element_use_dft_length; UWORD32 pay_load_length, tmp; -#ifdef ENABLE_DRC UWORD32 i; -#endif usac_ext_element_present = ixheaacd_read_bits_buf(it_bit_buff, 1); if (usac_ext_element_present) { @@ -199,7 +195,6 @@ static VOID ixheaacd_read_ext_element( if (usac_ext_element_payload_frag) tmp = ixheaacd_read_bits_buf(it_bit_buff, 2); -#ifdef ENABLE_DRC if (pstr_usac_dec_config->usac_ext_ele_payload_present[elem_idx]) { for (i = 0; i < pay_load_length; i++) { pstr_usac_dec_config->usac_ext_gain_payload_buf @@ -208,16 +203,13 @@ static VOID ixheaacd_read_ext_element( } pstr_usac_dec_config->usac_ext_gain_payload_len += pay_load_length; } else { -#endif it_bit_buff->ptr_read_next = it_bit_buff->ptr_read_next + pay_load_length; it_bit_buff->cnt_bits = it_bit_buff->cnt_bits - (WORD32)(pay_load_length * 8); -#ifdef ENABLE_DRC } -#endif } } } @@ -280,10 +272,10 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data, ia_aac_dec_state_struct *p_state_aac_dec = (ia_aac_dec_state_struct *)codec_handle; - ia_usac_data_struct *pstr_usac_data = pstr_dec_data->pstr_usac_data; + ia_usac_data_struct *pstr_usac_data = &(pstr_dec_data->str_usac_data); ia_bit_buf_struct *it_bit_buff = &pstr_dec_data->dec_bit_buf; - ia_frame_data_struct *fd = pstr_dec_data->pstr_frame_data; + ia_frame_data_struct *fd = &(pstr_dec_data->str_frame_data); ia_usac_config_struct *pstr_usac_config = &(fd->str_audio_specific_config.str_usac_config); @@ -297,9 +289,7 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data, WORD32 elem_idx = 0; WORD32 num_elements = pstr_usac_dec_config->num_elements; -#ifdef ENABLE_DRC pstr_usac_dec_config->usac_ext_gain_payload_len = 0; -#endif pstr_usac_data->usac_independency_flg = ixheaacd_read_bits_buf(it_bit_buff, 1); @@ -346,7 +336,7 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data, ixheaacd_esbr_process( pstr_usac_data, it_bit_buff, stereo_config_index, nr_core_coder_channels, - pstr_dec_data->pstr_usac_data->audio_object_type); + pstr_dec_data->str_usac_data.audio_object_type); } if (stereo_config_index > 0) { @@ -354,9 +344,9 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data, WORD32 ch; *num_out_channels = - p_state_aac_dec->mps_dec_handle[elem_idx]->out_ch_count; + p_state_aac_dec->mps_dec_handle.out_ch_count; - ixheaacd_mps_frame_parsing(p_state_aac_dec->mps_dec_handle[elem_idx], + ixheaacd_mps_frame_parsing(&p_state_aac_dec->mps_dec_handle, pstr_usac_data->usac_independency_flg, it_bit_buff); @@ -367,26 +357,28 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data, ptr_inp[2 * ch + 1] = pstr_usac_data->pstr_esbr_dec->pstr_sbr_channel[ch] ->str_sbr_dec.pp_qmf_buf_imag; - p_state_aac_dec->mps_dec_handle[0]->p_sbr_dec[ch] = + p_state_aac_dec->mps_dec_handle.p_sbr_dec[ch] = (VOID *)(&pstr_usac_data->pstr_esbr_dec->pstr_sbr_channel[ch] ->str_sbr_dec); - p_state_aac_dec->mps_dec_handle[0]->p_sbr_header[ch] = + p_state_aac_dec->mps_dec_handle.p_sbr_header[ch] = (VOID *)(pstr_usac_data->pstr_esbr_dec->pstr_sbr_header[ch]); - p_state_aac_dec->mps_dec_handle[0]->p_sbr_frame[ch] = + p_state_aac_dec->mps_dec_handle.p_sbr_frame[ch] = (VOID *)(pstr_usac_data->pstr_esbr_dec->frame_buffer[ch]); } if (nr_core_coder_channels == 1) { - p_state_aac_dec->mps_dec_handle[0]->p_sbr_dec[1] = + p_state_aac_dec->mps_dec_handle.p_sbr_dec[1] = (VOID *)(&pstr_usac_data->pstr_esbr_dec->pstr_sbr_channel[1] ->str_sbr_dec); - p_state_aac_dec->mps_dec_handle[0]->p_sbr_header[1] = + p_state_aac_dec->mps_dec_handle.p_sbr_header[1] = (VOID *)(pstr_usac_data->pstr_esbr_dec->pstr_sbr_header[1]); - p_state_aac_dec->mps_dec_handle[0]->p_sbr_frame[1] = + p_state_aac_dec->mps_dec_handle.p_sbr_frame[1] = (VOID *)(pstr_usac_data->pstr_esbr_dec->frame_buffer[1]); } - ixheaacd_mps_apply(p_state_aac_dec->mps_dec_handle[0], ptr_inp, + err = ixheaacd_mps_apply(&p_state_aac_dec->mps_dec_handle, ptr_inp, pstr_usac_data->time_sample_vector); + if(err) + return err; } ch_offset += nr_core_coder_channels; @@ -397,11 +389,8 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data, &pstr_usac_dec_config->str_usac_element_config[elem_idx]; ixheaacd_read_ext_element(pusac_element_config->usac_ext_eleme_def_len, pusac_element_config->usac_ext_elem_pld_frag, - it_bit_buff -#ifdef ENABLE_DRC - , + it_bit_buff, pstr_usac_dec_config, elem_idx -#endif ); break; diff --git a/decoder/ixheaacd_pvc_rom.h b/decoder/ixheaacd_pvc_rom.h index a952c66..6b16212 100644 --- a/decoder/ixheaacd_pvc_rom.h +++ b/decoder/ixheaacd_pvc_rom.h @@ -50,4 +50,4 @@ extern const WORD8 ixheaacd_pred_coeff_table_1_mode_2[PVC_ID_NUM_GROUPS] extern const WORD8 ixheaacd_pred_coeff_table_2_mode_2[PVC_NB_HIGH] [PVC_NB_HIGH_MODE2]; -#endif \ No newline at end of file +#endif diff --git a/decoder/ixheaacd_rvlc.h b/decoder/ixheaacd_rvlc.h index f574a84..a7a12e4 100644 --- a/decoder/ixheaacd_rvlc.h +++ b/decoder/ixheaacd_rvlc.h @@ -17,4 +17,4 @@ VOID ixheaacd_huff_sfb_table(WORD32 it_bit_buff, WORD16 *huff_index, WORD16 *len, const UWORD16 *code_book_tbl, const UWORD32 *idx_table); -#endif \ No newline at end of file +#endif diff --git a/decoder/ixheaacd_sbr_dec.c b/decoder/ixheaacd_sbr_dec.c index 1372f4b..571d955 100644 --- a/decoder/ixheaacd_sbr_dec.c +++ b/decoder/ixheaacd_sbr_dec.c @@ -554,7 +554,7 @@ VOID ixheaacd_esbr_synthesis_filt_block( } } -VOID ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, +WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, ia_sbr_header_data_struct *ptr_header_data, ia_sbr_frame_info_data_struct *ptr_frame_data, ia_sbr_prev_frame_data_struct *ptr_frame_data_prev, @@ -728,13 +728,16 @@ VOID ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, ixheaacd_qmf_enrg_calc(ptr_sbr_dec, upsample_ratio_idx, low_pow_flag); if (!mps_sbr_flag && apply_processing) { - ixheaacd_generate_hf(ptr_sbr_dec->qmf_buf_real + (SBR_HF_ADJ_OFFSET), + WORD32 err_code = 0; + err_code = ixheaacd_generate_hf(ptr_sbr_dec->qmf_buf_real + (SBR_HF_ADJ_OFFSET), ptr_sbr_dec->qmf_buf_imag + (SBR_HF_ADJ_OFFSET), ptr_sbr_dec->ph_vocod_qmf_real + (SBR_HF_ADJ_OFFSET), ptr_sbr_dec->ph_vocod_qmf_imag + (SBR_HF_ADJ_OFFSET), ptr_sbr_dec->sbr_qmf_out_real + (SBR_HF_ADJ_OFFSET), ptr_sbr_dec->sbr_qmf_out_imag + (SBR_HF_ADJ_OFFSET), ptr_frame_data, ptr_header_data); + if(err_code) + return err_code; ptr_pvc_data->pvc_rate = ptr_header_data->upsamp_fac; @@ -754,7 +757,15 @@ VOID ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, ptr_pvc_data->prev_pvc_rate = ptr_pvc_data->pvc_rate; ptr_frame_data->pstr_sbr_header = ptr_header_data; - + if(ptr_header_data->hbe_flag == 0) + ixheaacd_sbr_env_calc(ptr_frame_data, + ptr_sbr_dec->sbr_qmf_out_real + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->sbr_qmf_out_imag + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->qmf_buf_real + (SBR_HF_ADJ_OFFSET), + ptr_sbr_dec->qmf_buf_imag + (SBR_HF_ADJ_OFFSET), + NULL, + ptr_sbr_dec->scratch_buff, pvc_dec_out_buf); + else ixheaacd_sbr_env_calc(ptr_frame_data, ptr_sbr_dec->sbr_qmf_out_real + (SBR_HF_ADJ_OFFSET), ptr_sbr_dec->sbr_qmf_out_imag + (SBR_HF_ADJ_OFFSET), @@ -777,7 +788,7 @@ VOID ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, ptr_frame_data->prev_sbr_mode = sbr_mode; - return; + return 0; } ixheaacd_cplx_anal_qmffilt( @@ -998,6 +1009,7 @@ VOID ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, } ptr_sbr_dec->str_sbr_scale_fact.ov_lb_scale = save_lb_scale; + return 0; } void ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, @@ -1122,7 +1134,7 @@ void ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, return; } -void ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec, +WORD32 ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec, VOID *p_sbr_frame, VOID *p_sbr_header) { WORD32 i, k; ia_sbr_frame_info_data_struct *ptr_frame_data = @@ -1136,6 +1148,7 @@ void ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec, WORD32 op_delay = 6 + SBR_HF_ADJ_OFFSET; WORD32 num_anal_bands = 40; WORD32 mps_sbr_flag = ptr_frame_data->mps_sbr_flag; + WORD32 err = 0; if (ptr_header_data->is_usf_4) { op_delay += 6; @@ -1144,7 +1157,7 @@ void ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec, num_anal_bands = num_anal_bands - (upsample_ratio_idx << 3); if (!mps_sbr_flag) { - return; + return 0; } no_bins = ptr_header_data->output_framesize / 64; @@ -1187,18 +1200,27 @@ void ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec, ptr_header_data->pstr_freq_band_data->qmf_sb_prev = ptr_header_data->pstr_freq_band_data->sub_band_start; - ixheaacd_generate_hf(ptr_sbr_dec->mps_qmf_buf_real + SBR_HF_ADJ_OFFSET, + err = ixheaacd_generate_hf(ptr_sbr_dec->mps_qmf_buf_real + SBR_HF_ADJ_OFFSET, ptr_sbr_dec->mps_qmf_buf_imag + SBR_HF_ADJ_OFFSET, NULL, NULL, ptr_sbr_dec->mps_sbr_qmf_buf_real + SBR_HF_ADJ_OFFSET, ptr_sbr_dec->mps_sbr_qmf_buf_imag + SBR_HF_ADJ_OFFSET, ptr_frame_data, ptr_header_data); + if(err) + return err; ptr_frame_data->pstr_sbr_header = ptr_header_data; ptr_frame_data->sbr_mode = ORIG_SBR; ptr_frame_data->prev_sbr_mode = ORIG_SBR; - - ixheaacd_sbr_env_calc( + if(ptr_header_data->hbe_flag == 0) + ixheaacd_sbr_env_calc( + ptr_frame_data, ptr_sbr_dec->mps_sbr_qmf_buf_real + SBR_HF_ADJ_OFFSET, + ptr_sbr_dec->mps_sbr_qmf_buf_imag + SBR_HF_ADJ_OFFSET, + ptr_sbr_dec->mps_qmf_buf_real + SBR_HF_ADJ_OFFSET, + ptr_sbr_dec->mps_qmf_buf_imag + SBR_HF_ADJ_OFFSET, + NULL, ptr_sbr_dec->scratch_buff, NULL); + else + ixheaacd_sbr_env_calc( ptr_frame_data, ptr_sbr_dec->mps_sbr_qmf_buf_real + SBR_HF_ADJ_OFFSET, ptr_sbr_dec->mps_sbr_qmf_buf_imag + SBR_HF_ADJ_OFFSET, ptr_sbr_dec->mps_qmf_buf_real + SBR_HF_ADJ_OFFSET, @@ -1240,4 +1262,5 @@ void ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec, } ptr_frame_data->reset_flag = 0; + return err; } diff --git a/decoder/ixheaacd_sbr_dec.h b/decoder/ixheaacd_sbr_dec.h index 8fef0e0..2853237 100644 --- a/decoder/ixheaacd_sbr_dec.h +++ b/decoder/ixheaacd_sbr_dec.h @@ -147,7 +147,7 @@ typedef struct ia_sbr_pers_struct { } ia_sbr_pers_struct; -VOID ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, +WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, ia_sbr_header_data_struct *ptr_header_data, ia_sbr_frame_info_data_struct *ptr_frame_data, ia_sbr_prev_frame_data_struct *ptr_frame_data_prev, @@ -161,7 +161,7 @@ VOID ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, ia_pvc_data_struct *ptr_pvc_data_str, FLAG drc_on, WORD32 drc_sbr_factors[][64], WORD32 audio_object_type); -WORD16 ixheaacd_create_sbrdec(ia_sbr_tables_struct *pstr_sbr_tables, +WORD16 ixheaacd_create_sbrdec( ixheaacd_misc_tables *pstr_common_table, ia_sbr_channel_struct *ptr_sbr_channel, ia_sbr_header_data_struct *ptr_header_data, @@ -171,7 +171,7 @@ WORD16 ixheaacd_create_sbrdec(ia_sbr_tables_struct *pstr_sbr_tables, #define MAX_NUM_QMF_BANDS_ESBR 128 -VOID ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec, +WORD32 ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec, VOID *p_sbr_frame, VOID *p_sbr_header); VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *h_hbe_txposer, @@ -187,7 +187,7 @@ VOID ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, WORD32 x_over_qmf[MAX_NUM_PATCHES], FLOAT32 *scratch_buff, FLOAT32 *env_out); -VOID ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64], +WORD32 ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64], FLOAT32 ptr_src_buf_imag[][64], FLOAT32 ptr_ph_vocod_buf_real[][64], FLOAT32 ptr_ph_vocod_buf_imag[][64], diff --git a/decoder/ixheaacd_sbrdec_initfuncs.c b/decoder/ixheaacd_sbrdec_initfuncs.c index a41e868..b61d8c8 100644 --- a/decoder/ixheaacd_sbrdec_initfuncs.c +++ b/decoder/ixheaacd_sbrdec_initfuncs.c @@ -536,7 +536,7 @@ ia_handle_sbr_dec_inst_struct ixheaacd_init_sbr( audio_object_type); err = ixheaacd_create_sbrdec( - sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables, + sbr_persistent_mem->str_sbr_dec_inst.pstr_common_tables, sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_channel[i], ptr_header_data[i], i, *down_sample_flag, sbr_persistent_mem, ps_enable, @@ -602,9 +602,6 @@ ia_handle_sbr_dec_inst_struct ixheaacd_init_sbr( sbr_ratio_idx == SBR_UPSAMPLE_IDX_4_1 ? 1 : 0, output_frame_size, hbe_txposer_buffers); - } else { - ptr_sbr_dec[0]->p_hbe_txposer = NULL; - ptr_sbr_dec[1]->p_hbe_txposer = NULL; } p_str_sbr_dec_inst->ptr_pvc_data_str->prev_first_bnd_idx = -1; @@ -752,7 +749,7 @@ ia_handle_sbr_dec_inst_struct ixheaacd_init_sbr( } static PLATFORM_INLINE WORD16 ixheaacd_create_sbr_env_calc( - ia_sbr_tables_struct *pstr_sbr_tables, + ixheaacd_misc_tables *pstr_common_table, ia_sbr_calc_env_struct *hs, WORD16 chan, VOID *sbr_persistent_mem_v, ia_sbr_header_data_struct *ptr_header_data, WORD audio_object_type) { @@ -772,7 +769,7 @@ static PLATFORM_INLINE WORD16 ixheaacd_create_sbr_env_calc( ixheaacd_reset_sbrenvelope_calc(hs); if ((chan == 0) && (audio_object_type == AOT_ER_AAC_ELD)) { - err = ixheaacd_calc_frq_bnd_tbls(ptr_header_data, pstr_sbr_tables, + err = ixheaacd_calc_frq_bnd_tbls(ptr_header_data, pstr_common_table); } @@ -1083,8 +1080,7 @@ static PLATFORM_INLINE WORD32 ixheaacd_create_cplx_synt_qmfbank( return 0; } -WORD16 ixheaacd_create_sbrdec(ia_sbr_tables_struct *pstr_sbr_tables, - ixheaacd_misc_tables *pstr_common_table, +WORD16 ixheaacd_create_sbrdec(ixheaacd_misc_tables *pstr_common_table, ia_sbr_channel_struct *ptr_sbr_channel, ia_sbr_header_data_struct *ptr_header_data, WORD16 chan, FLAG down_sample_flag, @@ -1112,7 +1108,7 @@ WORD16 ixheaacd_create_sbrdec(ia_sbr_tables_struct *pstr_sbr_tables, sbr_persistent_mem->pstr_prev_frame_data[chan]; err = ixheaacd_create_sbr_env_calc( - pstr_sbr_tables, pstr_common_table, &hs->str_sbr_calc_env, chan, + pstr_common_table, &hs->str_sbr_calc_env, chan, sbr_persistent_mem, ptr_header_data, audio_object_type); if (err) { diff --git a/decoder/ixheaacd_sbrdec_lpfuncs.c b/decoder/ixheaacd_sbrdec_lpfuncs.c index e317b57..03d2a8a 100644 --- a/decoder/ixheaacd_sbrdec_lpfuncs.c +++ b/decoder/ixheaacd_sbrdec_lpfuncs.c @@ -935,7 +935,7 @@ VOID ixheaacd_pre_processing(FLOAT32 ptr_src_buf_real[][64], } } -VOID ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64], +WORD32 ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64], FLOAT32 ptr_src_buf_imag[][64], FLOAT32 ptr_ph_vocod_buf_real[][64], FLOAT32 ptr_ph_vocod_buf_imag[][64], @@ -1109,6 +1109,10 @@ VOID ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64], } if (num_bands_in_patch <= 0) { + if(num_bands_in_patch == 0) + { + return -1; + } continue; } @@ -1245,4 +1249,5 @@ VOID ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64], for (i = 0; i < num_if_bands; i++) { bw_array_prev[i] = bw_array[i]; } + return 0; } diff --git a/decoder/ixheaacd_sbrdecoder.c b/decoder/ixheaacd_sbrdecoder.c index 8c79888..10164e2 100644 --- a/decoder/ixheaacd_sbrdecoder.c +++ b/decoder/ixheaacd_sbrdecoder.c @@ -367,7 +367,7 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self, stereo = 1; ptr_header_data[1] = ptr_header_data[0]; - self->pstr_sbr_header[1] = self->pstr_sbr_header[0]; + memcpy(self->pstr_sbr_header[1], self->pstr_sbr_header[0], sizeof(ia_sbr_header_data_struct)); break; default: frame_status = 0; @@ -424,7 +424,7 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self, } if (header_flag == SBR_RESET) { err = ixheaacd_calc_frq_bnd_tbls(ptr_header_data[k], - self->pstr_sbr_tables, + self->pstr_common_tables); if (!err) { WORD32 lr; @@ -464,7 +464,7 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self, if (header_flag == SBR_RESET) { err = ixheaacd_calc_frq_bnd_tbls(ptr_header_data[k], - self->pstr_sbr_tables, + self->pstr_common_tables); } } @@ -645,7 +645,8 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self, } pstr_sbr_channel[0]->str_sbr_dec.time_sample_buf = self->time_sample_buf[0]; if (pstr_drc_dec == NULL) { - ixheaacd_sbr_dec( + WORD32 err_code = 0; + err_code = ixheaacd_sbr_dec( &pstr_sbr_channel[0]->str_sbr_dec, core_sample_buf + slot_element, ptr_header_data[0], ptr_frame_data[0], pstr_sbr_channel[0]->pstr_prev_frame_data, self->pstr_ps_stereo_dec, @@ -655,8 +656,11 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self, sbr_scratch_struct->ptr_work_buf_core, self->pstr_sbr_tables, self->pstr_common_tables, ch_fac, self->ptr_pvc_data_str, 0, NULL, audio_object_type); + if(err_code) + return err_code; } else { - ixheaacd_sbr_dec( + WORD32 err_code = 0; + err_code = ixheaacd_sbr_dec( &pstr_sbr_channel[0]->str_sbr_dec, core_sample_buf + slot_element, ptr_header_data[0], ptr_frame_data[0], pstr_sbr_channel[0]->pstr_prev_frame_data, self->pstr_ps_stereo_dec, @@ -668,6 +672,8 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self, pstr_drc_dec->drc_on, pstr_drc_dec->str_drc_channel_data[0].drc_factors_sbr, audio_object_type); + if(err_code) + return err_code; } if (!down_mix_flag && (stereo || dual_mono) && (num_channels == 2)) { @@ -680,7 +686,7 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self, low_pow_flag, self->pstr_sbr_tables, ch_fac); } else { if (pstr_drc_dec == NULL) { - ixheaacd_sbr_dec( + WORD32 err_code = ixheaacd_sbr_dec( &pstr_sbr_channel[1]->str_sbr_dec, core_sample_buf + slot_element + 1, ptr_header_data[1], ptr_frame_data[1], pstr_sbr_channel[1]->pstr_prev_frame_data, NULL, @@ -688,9 +694,10 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self, low_pow_flag, sbr_scratch_struct->ptr_work_buf_core, self->pstr_sbr_tables, self->pstr_common_tables, ch_fac, self->ptr_pvc_data_str, 0, NULL, audio_object_type); - + if(err_code) + return err_code; } else { - ixheaacd_sbr_dec(&pstr_sbr_channel[1]->str_sbr_dec, + WORD32 err_code = ixheaacd_sbr_dec(&pstr_sbr_channel[1]->str_sbr_dec, core_sample_buf + slot_element + 1, ptr_header_data[1], ptr_frame_data[1], pstr_sbr_channel[1]->pstr_prev_frame_data, NULL, NULL, @@ -700,6 +707,8 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self, ch_fac, self->ptr_pvc_data_str, pstr_drc_dec->drc_on, pstr_drc_dec->str_drc_channel_data[1].drc_factors_sbr, audio_object_type); + if(err_code) + return err_code; } } diff --git a/decoder/ixheaacd_spectrum_dec.c b/decoder/ixheaacd_spectrum_dec.c index 72f5421..b29911e 100644 --- a/decoder/ixheaacd_spectrum_dec.c +++ b/decoder/ixheaacd_spectrum_dec.c @@ -428,6 +428,9 @@ WORD32 ixheaacd_fd_channel_stream( usac_data, max_spec_coefficients, noise_level, noise_offset, arth_size, it_bit_buff, *max_sfb, arith_reset_flag, noise_filling, chn); + if(err_code != 0) + return err_code; + usac_data->fac_data_present[chn] = ixheaacd_read_bits_buf(it_bit_buff, 1); if (usac_data->fac_data_present[chn]) { diff --git a/decoder/ixheaacd_struct_def.h b/decoder/ixheaacd_struct_def.h index 0737448..95ad94b 100644 --- a/decoder/ixheaacd_struct_def.h +++ b/decoder/ixheaacd_struct_def.h @@ -85,6 +85,9 @@ typedef struct { WORD32 i_channel_mask; UWORD32 ui_channel_mode; UWORD32 ui_sbr_mode; + WORD32 ui_effect_type; + WORD32 ui_target_loudness; + WORD32 ui_loud_norm_flag; UWORD32 flag_downmix; UWORD32 flag_08khz_out; @@ -130,9 +133,7 @@ typedef struct { WORD32 ui_flush_cmd; -#ifdef ENABLE_DRC ia_drc_config drc_config_struct; -#endif } ia_aac_dec_config_struct; @@ -216,7 +217,7 @@ typedef struct ia_aac_dec_state_struct { WORD32 num_of_output_ch; VOID *ia_audio_specific_config; - ia_mps_dec_state_struct *mps_dec_handle[MAX_NUM_ELEMENTS]; + ia_mps_dec_state_struct mps_dec_handle; UWORD16 *huffman_code_book_scl; UWORD32 *huffman_code_book_scl_index; diff --git a/decoder/ixheaacd_tns.c b/decoder/ixheaacd_tns.c index 491cecf..ab3792b 100644 --- a/decoder/ixheaacd_tns.c +++ b/decoder/ixheaacd_tns.c @@ -151,12 +151,12 @@ static VOID ixheaacd_tns_ar_filter_usac(WORD32 *spectrum, WORD32 size, acc = 0; for (j = i; j > 0; j--) { - acc = ixheaacd_add64( + acc = ixheaacd_add64_sat( acc, ixheaacd_mult64(ptr_filter_state[j - 1], lpc_coeff[j])); ptr_filter_state[j] = ptr_filter_state[j - 1]; } - y = ixheaacd_sub32(y, (WORD32)(acc >> 31)); + y = ixheaacd_sub32_sat(y, (WORD32)(acc >> 31)); ptr_filter_state[0] = ixheaacd_shl32(y, shift_value); *spectrum = y; spectrum += inc; @@ -166,12 +166,12 @@ static VOID ixheaacd_tns_ar_filter_usac(WORD32 *spectrum, WORD32 size, y = *spectrum; acc = 0; for (j = order; j > 0; j--) { - acc = ixheaacd_add64( + acc = ixheaacd_add64_sat( acc, ixheaacd_mult64(ptr_filter_state[j - 1], lpc_coeff[j])); ; ptr_filter_state[j] = ptr_filter_state[j - 1]; } - y = ixheaacd_sub32(y, (WORD32)(acc >> 31)); + y = ixheaacd_sub32_sat(y, (WORD32)(acc >> 31)); ptr_filter_state[0] = ixheaacd_shl32(y, shift_value); *spectrum = y; spectrum += inc; diff --git a/decoder/ixheaacd_tns.h b/decoder/ixheaacd_tns.h index bbeecba..9d3cad5 100644 --- a/decoder/ixheaacd_tns.h +++ b/decoder/ixheaacd_tns.h @@ -74,6 +74,10 @@ VOID ixheaacd_tns_ar_filter_fixed_armv7(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD32 *lpc, WORD32 order, WORD32 shift_value, WORD scale_spec); +VOID ixheaacd_tns_ar_filter_fixed_non_neon_armv7(WORD32 *spectrum, WORD32 size, + WORD32 inc, WORD32 *lpc, WORD32 order, + WORD32 shift_value, WORD scale_spec); + VOID ixheaacd_tns_ar_filter_fixed_armv8(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD32 *lpc, WORD32 order, WORD32 shift_value, WORD scale_spec); diff --git a/decoder/ixheaacd_type_def.h b/decoder/ixheaacd_type_def.h index 1eabe93..9ecded3 100644 --- a/decoder/ixheaacd_type_def.h +++ b/decoder/ixheaacd_type_def.h @@ -21,7 +21,7 @@ #define IXHEAACD_TYPE_DEF_H /****************************************************************************/ -/* types type define prefix examples +/* types type define prefix examples * bytes */ /************************ *********** ****** **************** ***** */ @@ -34,70 +34,70 @@ typedef signed char WORD8; /* b WORD8 b_name 1 */ typedef signed char* pWORD8; /* pb pWORD8 pb_nmae 1 */ typedef unsigned char - UWORD8; /* ub UWORD8 ub_count 1 */ + UWORD8; /* ub UWORD8 ub_count 1 */ typedef unsigned char* - pUWORD8; /* pub pUWORD8 pub_count 1 */ + pUWORD8; /* pub pUWORD8 pub_count 1 */ typedef signed short WORD16; /* s WORD16 s_count 2 */ typedef signed short* pWORD16; /* ps pWORD16 ps_count 2 */ typedef unsigned short - UWORD16; /* us UWORD16 us_count 2 */ + UWORD16; /* us UWORD16 us_count 2 */ typedef unsigned short* - pUWORD16; /* pus pUWORD16 pus_count 2 */ + pUWORD16; /* pus pUWORD16 pus_count 2 */ typedef signed int WORD24; /* k WORD24 k_count 3 */ typedef signed int* pWORD24; /* pk pWORD24 pk_count 3 */ typedef unsigned int - UWORD24; /* uk UWORD24 uk_count 3 */ + UWORD24; /* uk UWORD24 uk_count 3 */ typedef unsigned int* - pUWORD24; /* puk pUWORD24 puk_count 3 */ + pUWORD24; /* puk pUWORD24 puk_count 3 */ typedef signed int WORD32; /* i WORD32 i_count 4 */ typedef signed int* pWORD32; /* pi pWORD32 pi_count 4 */ typedef unsigned int - UWORD32; /* ui UWORD32 ui_count 4 */ + UWORD32; /* ui UWORD32 ui_count 4 */ typedef unsigned int* - pUWORD32; /* pui pUWORD32 pui_count 4 */ + pUWORD32; /* pui pUWORD32 pui_count 4 */ typedef signed long long - WORD40; /* m WORD40 m_count 5 */ + WORD40; /* m WORD40 m_count 5 */ typedef signed long long* - pWORD40; /* pm pWORD40 pm_count 5 */ + pWORD40; /* pm pWORD40 pm_count 5 */ typedef unsigned long long - UWORD40; /* um UWORD40 um_count 5 */ + UWORD40; /* um UWORD40 um_count 5 */ typedef unsigned long long* - pUWORD40; /* pum pUWORD40 pum_count 5 */ + pUWORD40; /* pum pUWORD40 pum_count 5 */ typedef signed long long - WORD64; /* h WORD64 h_count 8 */ + WORD64; /* h WORD64 h_count 8 */ typedef signed long long* - pWORD64; /* ph pWORD64 ph_count 8 */ + pWORD64; /* ph pWORD64 ph_count 8 */ typedef unsigned long long - UWORD64; /* uh UWORD64 uh_count 8 */ + UWORD64; /* uh UWORD64 uh_count 8 */ typedef unsigned long long* - pUWORD64; /* puh pUWORD64 puh_count 8 */ + pUWORD64; /* puh pUWORD64 puh_count 8 */ -typedef float FLOAT32; /* f FLOAT32 f_count 4 +typedef float FLOAT32; /* f FLOAT32 f_count 4 */ typedef float* pFLOAT32; /* pf pFLOAT32 pf_count 4 */ -typedef double FLOAT64; /* d UFLOAT64 d_count 8 +typedef double FLOAT64; /* d UFLOAT64 d_count 8 */ typedef double* pFlOAT64; /* pd pFLOAT64 pd_count 8 */ -typedef void VOID; /* v VOID v_flag 4 */ -typedef void* pVOID; /* pv pVOID pv_flag 4 */ +typedef void VOID; /* v VOID v_flag 4 */ +typedef void* pVOID; /* pv pVOID pv_flag 4 */ /* variable size types: platform optimized implementation */ typedef signed int BOOL; /* bool BOOL bool_true */ -typedef unsigned int UBOOL; /* ubool BOOL ubool_true */ +typedef unsigned int UBOOL; /* ubool BOOL ubool_true */ typedef signed int FLAG; /* flag FLAG flag_false */ -typedef unsigned int UFLAG; /* uflag FLAG uflag_false */ +typedef unsigned int UFLAG; /* uflag FLAG uflag_false */ typedef signed int LOOPIDX; /* lp LOOPIDX lp_index */ typedef unsigned int - ULOOPIDX; /* ulp SLOOPIDX ulp_index */ + ULOOPIDX; /* ulp SLOOPIDX ulp_index */ typedef signed int WORD; /* lp LOOPIDX lp_index */ typedef unsigned int - UWORD; /* ulp SLOOPIDX ulp_index */ + UWORD; /* ulp SLOOPIDX ulp_index */ typedef LOOPIDX LOOPINDEX; /* lp LOOPIDX lp_index */ typedef ULOOPIDX ULOOPINDEX; /* ulp SLOOPIDX ulp_index */ diff --git a/decoder/ixheaacd_ver_number.h b/decoder/ixheaacd_ver_number.h index b7d5435..9aa7338 100644 --- a/decoder/ixheaacd_ver_number.h +++ b/decoder/ixheaacd_ver_number.h @@ -18,9 +18,9 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #ifdef _ARM_ -#define xHE_AAC_DEC_ITTIAM_VER "_ARM $Rev: 1.36 $" +#define xHE_AAC_DEC_ITTIAM_VER "_ARM $Rev: 1.38 $" #elif _X86_ -#define xHE_AAC_DEC_ITTIAM_VER "_X86 $Rev: 1.36 $" +#define xHE_AAC_DEC_ITTIAM_VER "_X86 $Rev: 1.38 $" #else -#define xHE_AAC_DEC_ITTIAM_VER "_MSVC $Rev: 1.36 $" +#define xHE_AAC_DEC_ITTIAM_VER "_MSVC $Rev: 1.38 $" #endif diff --git a/decoder/ixheaacd_windows.h b/decoder/ixheaacd_windows.h index c93c0d0..05fc0f5 100644 --- a/decoder/ixheaacd_windows.h +++ b/decoder/ixheaacd_windows.h @@ -59,4 +59,4 @@ typedef struct { } offset_lengths; -#endif \ No newline at end of file +#endif diff --git a/test/Android.bp b/test/Android.bp index 18f17ce..7990708 100644 --- a/test/Android.bp +++ b/test/Android.bp @@ -10,7 +10,8 @@ cc_test { "-UARM_PROFILE_BOARD", "-DECLIPSE", "-DDRC_ENABLE", - "-DMULTICHANNEL_ENABLE" + "-DMULTICHANNEL_ENABLE", + "-DENABLE_DRC" ], include_dirs: [ diff --git a/test/impd_drc_config_params.h b/test/impd_drc_config_params.h index c0bd642..8d15f2f 100644 --- a/test/impd_drc_config_params.h +++ b/test/impd_drc_config_params.h @@ -1,50 +1,53 @@ /****************************************************************************** - * - * Copyright (C) 2018 The Android Open Source Project - * - * 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. - * + * + * Copyright (C) 2018 The Android Open Source Project + * + * 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. + * ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore + * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #ifndef IMPD_DRC_CONFIG_PARAMS_H #define IMPD_DRC_CONFIG_PARAMS_H -#define IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ 0x0000 -#define IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ 0x0001 -#define IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS 0x0002 -#define IA_DRC_DEC_CONFIG_PARAM_DEC_TYPE 0x0003 -#define IA_DRC_DEC_CONFIG_PARAM_PEAK_LIMITER 0x0004 -#define IA_DRC_DEC_CONFIG_PARAM_CTRL_PARAM 0x0005 -#define IA_DRC_DEC_CONFIG_PARAM_VER_MODE 0x0006 -#define IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT 0x0007 +#define IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ 0x0000 +#define IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ 0x0001 +#define IA_DRC_DEC_CONFIG_PARAM_NUM_CHANNELS 0x0002 +#define IA_DRC_DEC_CONFIG_PARAM_DEC_TYPE 0x0003 +#define IA_DRC_DEC_CONFIG_PARAM_PEAK_LIMITER 0x0004 +#define IA_DRC_DEC_CONFIG_PARAM_CTRL_PARAM 0x0005 +#define IA_DRC_DEC_CONFIG_PARAM_VER_MODE 0x0006 +#define IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT 0x0007 #define IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT 0x0008 -#define IA_DRC_DEC_CONFIG_PARAM_DELAY_MODE 0x0009 +#define IA_DRC_DEC_CONFIG_PARAM_DELAY_MODE 0x0009 #define IA_DRC_DEC_CONFIG_PARAM_GAIN_DELAY 0x000A #define IA_DRC_DEC_CONFIG_PARAM_AUDIO_DELAY 0x000B #define IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE 0x000C #define IA_DRC_DEC_CONFIG_PARAM_ABSO_DELAY_OFF 0x000D #define IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE 0x000E -#define IA_DRC_DEC_CONFIG_PROC_OUT_PTR 0x000F -#define IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG 0x0010 - +#define IA_DRC_DEC_CONFIG_PROC_OUT_PTR 0x000F +#define IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG 0x0010 +#define IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE 0x0011 +#define IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS 0x0012 +#define IA_DRC_DEC_CONFIG_DRC_LOUD_NORM 0x0013 -#define IA_API_CMD_SET_INPUT_BYTES_BS 0x0026 -#define IA_API_CMD_SET_INPUT_BYTES_IC_BS 0x0027 -#define IA_API_CMD_SET_INPUT_BYTES_IL_BS 0x0029 -#define IA_API_CMD_SET_INPUT_BYTES_IN_BS 0x002A + +#define IA_API_CMD_SET_INPUT_BYTES_BS 0x0026 +#define IA_API_CMD_SET_INPUT_BYTES_IC_BS 0x0027 +#define IA_API_CMD_SET_INPUT_BYTES_IL_BS 0x0029 +#define IA_API_CMD_SET_INPUT_BYTES_IN_BS 0x002A #define IA_CMD_TYPE_INIT_CPY_BSF_BUFF 0x0201 diff --git a/test/ixheaacd_error.c b/test/ixheaacd_error.c index 8256af1..aa88755 100644 --- a/test/ixheaacd_error.c +++ b/test/ixheaacd_error.c @@ -75,7 +75,8 @@ pWORD8 ixheaacd_ppb_config_non_fatal[] = { (pWORD8) "Invalid peak limiter flag", (pWORD8) "Invalid control param index", (pWORD8) "Inalid gain delay", - (pWORD8) "invalid constant delay mode"}; + (pWORD8) "Invalid constant delay mode", + (pWORD8) "Invalid effect type"}; /* Fatal Errors */ pWORD8 ixheaacd_ppb_config_fatal[] = { (pWORD8) "Invalid Sample rate specified for RAW decoding"}; @@ -85,9 +86,9 @@ pWORD8 ixheaacd_ppb_config_fatal[] = { /*****************************************************************************/ /* Non Fatal Errors */ pWORD8 ixheaacd_ppb_init_non_fatal[] = { - (pWORD8)"Both 16 kHz and 8 kHz output config set. Giving 16 kHz output", - (pWORD8)"Output sampling frequency is 8 kHz, 16 kHz output disabled ", - (pWORD8)"Header not found at the beginning of input data continuing syncing" + (pWORD8)"Both 16 kHz and 8 kHz output config set. Giving 16 kHz output", + (pWORD8)"Output sampling frequency is 8 kHz, 16 kHz output disabled ", + (pWORD8)"Header not found at the beginning of input data continuing syncing" }; /* Fatal Errors */ pWORD8 ixheaacd_ppb_init_fatal[] = { @@ -101,22 +102,22 @@ pWORD8 ixheaacd_ppb_init_fatal[] = { /*****************************************************************************/ /* Non Fatal Errors */ pWORD8 ixheaacd_ppb_exe_non_fatal[] = { - (pWORD8)"ADTS syncronization is lost. Re-syncing", - (pWORD8)"Though SBR was present in previous frame, not present in current frame (SBR turned off)", - (pWORD8)"SBR was not present in previous frame, but it is present in current frame (SBR turned on)", - (pWORD8)"ADTS Header CRC failed.Re-syncing", - (pWORD8)"Input bytes insufficient for decoding", - (pWORD8)"Element instance tag mismatch, because of new channel mode", - (pWORD8)"max huffman decoded value exceeded", - (pWORD8)"Error in AAC decoding", - (pWORD8)"Scale factor exceeds the transmitted boundary", - (pWORD8)"Gain control not supported", - (pWORD8)"Filter Order of TNS data is greater than maximum order", - (pWORD8)"LTP data found, not supported", - (pWORD8)"The base sampling frequency has changed in ADTS header", - (pWORD8)"Pulse Data exceeds the permitted boundary", - (pWORD8)"Invalid code ixheaacd_book number in ia_huffman_data_type decoding", -// (pWORD8)"The base sampling frequency has changed in ADTS header" + (pWORD8)"ADTS syncronization is lost. Re-syncing", + (pWORD8)"Though SBR was present in previous frame, not present in current frame (SBR turned off)", + (pWORD8)"SBR was not present in previous frame, but it is present in current frame (SBR turned on)", + (pWORD8)"ADTS Header CRC failed.Re-syncing", + (pWORD8)"Input bytes insufficient for decoding", + (pWORD8)"Element instance tag mismatch, because of new channel mode", + (pWORD8)"max huffman decoded value exceeded", + (pWORD8)"Error in AAC decoding", + (pWORD8)"Scale factor exceeds the transmitted boundary", + (pWORD8)"Gain control not supported", + (pWORD8)"Filter Order of TNS data is greater than maximum order", + (pWORD8)"LTP data found, not supported", + (pWORD8)"The base sampling frequency has changed in ADTS header", + (pWORD8)"Pulse Data exceeds the permitted boundary", + (pWORD8)"Invalid code ixheaacd_book number in ia_huffman_data_type decoding", +// (pWORD8)"The base sampling frequency has changed in ADTS header" }; /* Fatal Errors */ pWORD8 ixheaacd_ppb_exe_fatal[] = { @@ -129,14 +130,14 @@ pWORD8 ixheaacd_ppb_exe_fatal[] = { /*****************************************************************************/ /* The Module's Error Info Structure */ ia_error_info_struct ixheaacd_error_info = { - /* The Module Name */ + /* The Module Name */ (pWORD8) "Ittiam xheaac_dec", - {/* The Class Names */ + {/* The Class Names */ (pWORD8) "API", (pWORD8) "Configuration", (pWORD8) "Initialization", (pWORD8) "Execution", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "xHeaac"}, - {/* The Message Pointers */ + {/* The Message Pointers */ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -176,7 +177,7 @@ ia_error_info_struct ixheaacd_error_info = { /*****************************************************************************/ VOID ixheaacd_error_handler_init() { - /* The Message Pointers */ + /* The Message Pointers */ ixheaacd_error_info.ppppb_error_msg_pointers[0][0] = ixheaacd_ppb_api_non_fatal; ixheaacd_error_info.ppppb_error_msg_pointers[1][0] = ixheaacd_ppb_api_fatal; @@ -209,14 +210,14 @@ pWORD8 ixheaacd_ppb_ia_testbench_mem_file_man_fatal[] = { /*****************************************************************************/ /* The Module's Error Info Structure */ ia_error_info_struct ixheaacd_ia_testbench_error_info = { - /* The Module Name */ + /* The Module Name */ (pWORD8) "ia_testbench", - {/* The Class Names */ + {/* The Class Names */ (pWORD8) "Memory & File Manager", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) "", (pWORD8) ""}, - {/* The Message Pointers */ + {/* The Message Pointers */ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -249,7 +250,7 @@ ia_error_info_struct ixheaacd_ia_testbench_error_info = { /*****************************************************************************/ VOID ia_testbench_error_handler_init() { - /* The Message Pointers */ + /* The Message Pointers */ ixheaacd_ia_testbench_error_info.ppppb_error_msg_pointers[1][0] = ixheaacd_ppb_ia_testbench_mem_file_man_fatal; } diff --git a/test/ixheaacd_main.c b/test/ixheaacd_main.c index ed53e53..4d77b58 100644 --- a/test/ixheaacd_main.c +++ b/test/ixheaacd_main.c @@ -36,10 +36,8 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_module_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value); -#ifdef ENABLE_DRC IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_module_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value); -#endif VOID ixheaacd_error_handler_init(); VOID ia_testbench_error_handler_init(); @@ -100,10 +98,8 @@ WORD g_w_malloc_count; FILE *g_pf_out; FileWrapperPtr g_pf_inp; /* file pointer to bitstream file (mp4) */ -#ifdef ENABLE_DRC FILE *g_pf_interface; WORD32 interface_file_present = 0; -#endif metadata_info meta_info; // metadata pointer; WORD32 ixheaacd_i_bytes_to_read; @@ -589,6 +585,33 @@ IA_ERRORCODE ixheaacd_set_config_param(WORD32 argc, pWORD8 argv[], IA_ENHAACPLUS_DEC_CONFIG_PARAM_FRAMESIZE, &ui_fs480); _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); } + + /*For MPEG-D DRC effect type*/ + if (!strncmp((pCHAR8)argv[i], "-effect:", 8)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 8); + WORD32 ui_effect = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE, &ui_effect); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + /*For MPEG-D DRC target loudness*/ + if (!strncmp((pCHAR8)argv[i], "-target_loudness:", 17)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 17); + WORD32 ui_target_loudness = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS, &ui_target_loudness); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + if (!strncmp((pCHAR8)argv[i], "-ld_testing:", 12)) { + pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 12); + UWORD32 ld_testing = atoi(pb_arg_val); + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_LD_TESTING, &ld_testing); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } } return IA_NO_ERROR; @@ -749,10 +772,8 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { /* API obj */ pVOID pv_ia_process_api_obj; -#ifdef ENABLE_DRC pVOID pv_ia_drc_process_api_obj; UWORD32 pui_api_size; -#endif /* First part */ /* Error Handler Init */ @@ -762,10 +783,8 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { /* Initialize memory tables */ /* Get memory information and allocate memory */ -#ifdef ENABLE_DRC - UWORD8 drc_ip_buf[8192 * 2]; - UWORD8 drc_op_buf[8192 * 2]; -#endif + UWORD8 drc_ip_buf[8192 * 4]; + UWORD8 drc_op_buf[8192 * 4]; /* Memory variables */ UWORD32 n_mems, ui_rem; @@ -802,11 +821,13 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { WORD32 i_out_bytes, i_total_bytes = 0; WORD32 i_samp_freq, i_num_chan, i_pcm_wd_sz, i_channel_mask; -#ifdef ENABLE_DRC + UWORD32 i_sbr_mode; + WORD32 i_effect_type = 0; + WORD32 i_target_loudness = 0; + WORD32 i_loud_norm = 0; WORD32 drc_flag = 0; WORD32 mpegd_drc_present = 0; WORD32 uo_num_chan; -#endif /* The process API function */ IA_ERRORCODE(*p_ia_process_api) @@ -893,7 +914,6 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); -#ifdef ENABLE_DRC /*ITTIAM: Get API size for DRC*/ /* Get the API size */ @@ -922,7 +942,6 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); -#endif /* ******************************************************************/ /* Set config parameters got from the user present in argc argv */ @@ -1012,7 +1031,7 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { /* API object requires 4 bytes (WORD32) alignment */ ui_rem = ((WORD32)g_pv_arr_alloc_memory[g_w_malloc_count] & 3); - /* Set pointer for process memory tables */ + /* Set pointer for process memory tables */ err_code = (*p_ia_process_api)( pv_ia_process_api_obj, IA_API_CMD_SET_MEMTABS_PTR, 0, (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + 4 - ui_rem)); @@ -1021,7 +1040,7 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { g_w_malloc_count++; - /* initialize the API, post config, fill memory tables */ + /* initialize the API, post config, fill memory tables */ err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL); @@ -1228,7 +1247,6 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { } while (!ui_init_done); -#ifdef ENABLE_DRC if (interface_file_present == 1) { err_code = (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, &i_num_chan, @@ -1258,6 +1276,55 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); } + /*Set Effect Type*/ + + { + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_EFFECT_TYPE, &i_effect_type); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = + ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_DRC_EFFECT_TYPE, &i_effect_type); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + } + + /*Set target loudness */ + + { + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_TARGET_LOUDNESS, &i_target_loudness); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = + ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_DRC_TARGET_LOUDNESS, &i_target_loudness); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + } + + /*Set loud_norm_flag*/ + { + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_DRC_LOUD_NORM, &i_loud_norm); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + err_code = + ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_DRC_LOUD_NORM, &i_loud_norm); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + } + + + + + + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_INIT, IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL); @@ -1418,23 +1485,16 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { } /*Read interface buffer config file bitstream*/ - { + + if(mpegd_drc_present==1){ WORD32 interface_is_present = 1; - i_bytes_read = fread(drc_ip_buf, sizeof(WORD8), 16384, g_pf_interface); err_code = ia_drc_dec_api( pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT, &interface_is_present); _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); - /* Set number of bytes to be processed */ - err_code = - ia_drc_dec_api(pv_ia_drc_process_api_obj, - IA_API_CMD_SET_INPUT_BYTES_IN_BS, 0, &i_bytes_read); - - _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); - /* Execute process */ err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_INIT, IA_CMD_TYPE_INIT_CPY_IN_BSF_BUFF, NULL); @@ -1453,7 +1513,6 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { } } } -#endif /* ******************************************************************/ /* Get config params from API */ @@ -1484,7 +1543,7 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { prev_sampling_rate = i_samp_freq; do { - if ((ui_inp_size - (i_buff_size - i_bytes_consumed)) > 0) { + if (((WORD32)ui_inp_size - (WORD32)(i_buff_size - i_bytes_consumed)) > 0) { for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; } @@ -1493,7 +1552,7 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { #endif FileWrapper_Read(g_pf_inp, (unsigned char *)(pb_inp_buf + i_buff_size - i_bytes_consumed), - (ui_inp_size - (i_buff_size - i_bytes_consumed)), + ((WORD32)ui_inp_size - (WORD32)(i_buff_size - i_bytes_consumed)), (pUWORD32)&i_bytes_read); #ifdef ENABLE_LD_DEC } else @@ -1554,7 +1613,6 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); -#ifdef ENABLE_DRC if (interface_file_present == 1) { if (ui_exec_done != 1) { VOID *p_array; // ITTIAM:buffer to handle gain payload @@ -1600,13 +1658,12 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { } } } -#endif /* How much buffer is used in input buffers */ err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_GET_CURIDX_INPUT_BUF, 0, &i_bytes_consumed); - // printf("bytes_consumed: %d \n", i_bytes_consumed); + // printf("bytes_consumed: %d \n", i_bytes_consumed); _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); /* Get the output bytes */ @@ -1619,9 +1676,39 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { i_total_bytes += i_out_bytes; -#ifdef ENABLE_DRC if (mpegd_drc_present == 1) { memcpy(drc_ip_buf, pb_out_buf, i_out_bytes); + + + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_GET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_SBR_MODE, &i_sbr_mode); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + + if (i_sbr_mode != 0) + { + WORD32 frame_length; + if (i_sbr_mode == 1) + { + frame_length = 2048; + } + else if(i_sbr_mode == 3) + { + frame_length = 4096; + } + else + { + frame_length = 1024; + } + + err_code = + ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE, &frame_length); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + + err_code = ia_drc_dec_api(pv_ia_drc_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &i_out_bytes); @@ -1635,7 +1722,6 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { memcpy(pb_out_buf, drc_op_buf, i_out_bytes); } -#endif if (total_samples != 0) // Usac stream { @@ -1976,7 +2062,6 @@ int main(WORD32 argc, char *argv[]) { (const char *)pb_input_file_path); strcat((char *)pb_metadata_file_name, (const char *)pb_arg_val); - g_pf_meta = NULL; g_pf_meta = fopen((const char *)pb_metadata_file_name, "r"); if (g_pf_meta == NULL) { @@ -2014,7 +2099,6 @@ int main(WORD32 argc, char *argv[]) { } file_count++; } -#ifdef ENABLE_DRC if (!strncmp((const char *)fargv[i], "-infile:", 8)) { pWORD8 pb_arg_val = fargv[i] + 8; WORD8 pb_interface_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; @@ -2035,17 +2119,12 @@ int main(WORD32 argc, char *argv[]) { interface_file_present = 1; file_count++; } -#endif } g_w_malloc_count = 0; printf("\n"); -#ifdef ENABLE_DRC if (file_count != 4 && file_count != 3 && file_count != 2) -#else - if (file_count != 3 && file_count != 2) -#endif { err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, @@ -2080,15 +2159,14 @@ int main(WORD32 argc, char *argv[]) { raw_testing = 0; fclose(g_pf_meta); memset_metadata(meta_info); + g_pf_meta=NULL; } FileWrapper_Close(g_pf_inp); -#ifdef ENABLE_DRC if (g_pf_interface) { fclose(g_pf_interface); interface_file_present = 0; } -#endif } } } else { @@ -2168,7 +2246,6 @@ int main(WORD32 argc, char *argv[]) { file_count++; } -#ifdef ENABLE_DRC if (!strncmp((const char *)fargv[i], "-infile:", 8)) { pWORD8 pb_arg_val = fargv[i] + 8; WORD8 pb_interface_file_name[IA_MAX_CMD_LINE_LENGTH] = ""; @@ -2189,17 +2266,12 @@ int main(WORD32 argc, char *argv[]) { interface_file_present = 1; file_count++; } -#endif } g_w_malloc_count = 0; printf("\n"); -#ifdef ENABLE_DRC if (file_count != 4 && file_count != 3 && file_count != 2) -#else - if (file_count != 2 && file_count != 3) -#endif { err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, @@ -2235,12 +2307,10 @@ int main(WORD32 argc, char *argv[]) { memset_metadata(meta_info); } FileWrapper_Close(g_pf_inp); -#ifdef ENABLE_DRC if (g_pf_interface) { fclose(g_pf_interface); interface_file_present = 0; } -#endif } return IA_NO_ERROR; diff --git a/test/ixheaacd_main_flush_csd.c b/test/ixheaacd_main_flush_csd.c index a67b1a3..d469437 100644 --- a/test/ixheaacd_main_flush_csd.c +++ b/test/ixheaacd_main_flush_csd.c @@ -345,15 +345,15 @@ WORD32 write_wav_header(FILE *fp, WORD32 pcmbytes, WORD32 freq, WORD32 channels, ixheaacd_write16_bits_lh(fp, 0x3800); ixheaacd_write16_bits_lh(fp, 0x719b); /* - ixheaacd_write16_bits_lh(fp, 0x6166); - ixheaacd_write16_bits_lh(fp, 0x7463); + ixheaacd_write16_bits_lh(fp, 0x6166); + ixheaacd_write16_bits_lh(fp, 0x7463); - ixheaacd_write16_bits_lh(fp, 0x0004); - ixheaacd_write16_bits_lh(fp, 0x0000); + ixheaacd_write16_bits_lh(fp, 0x0004); + ixheaacd_write16_bits_lh(fp, 0x0000); - ixheaacd_write16_bits_lh(fp, 0x5800); - ixheaacd_write16_bits_lh(fp, 0x0028); - */ } + ixheaacd_write16_bits_lh(fp, 0x5800); + ixheaacd_write16_bits_lh(fp, 0x0028); + */ } fwrite("data", 1, 4, fp); ixheaacd_write32_bits_lh(fp, pcmbytes); @@ -1092,7 +1092,7 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) /* API object requires 4 bytes (WORD32) alignment */ ui_rem = ((WORD32)g_pv_arr_alloc_memory[g_w_malloc_count] & 3); - /* Set pointer for process memory tables */ + /* Set pointer for process memory tables */ err_code = (*p_ia_process_api)( pv_ia_process_api_obj, IA_API_CMD_SET_MEMTABS_PTR, 0, (pVOID)((WORD8 *)g_pv_arr_alloc_memory[g_w_malloc_count] + 4 - ui_rem)); @@ -1101,7 +1101,7 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) g_w_malloc_count++; - /* initialize the API, post config, fill memory tables */ + /* initialize the API, post config, fill memory tables */ err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INIT, IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL); @@ -1158,7 +1158,7 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) // ui_size += 20*1024*sizeof(WORD8); if (ui_type == IA_MEMTYPE_OUTPUT) { - // ui_size = 8192; + // ui_size = 8192; if (i_pcm_wd_sz == 16) ui_size = 16384 * sizeof(WORD16); // refer SAMPLE_BUF_SIZE value in // audio.c file //Ramesh @@ -1387,7 +1387,7 @@ INIT_AGAIN: err_code = 0x00000000; i_count_init_errors++; } - // _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8)"", err_code); + // _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8)"", err_code); if (err_code_reinit == 0x00001804 /*IA_ENHAACPLUS_DEC_EXE_FATAL_INSUFFICIENT_INPUT_BYTES*/) { _IA_PRINT_ERROR(p_proc_err_info, (pWORD8) "", err_code); @@ -1431,9 +1431,9 @@ INIT_AGAIN: return 1; } -// frame_counter++; +// frame_counter++; #ifndef ARM_PROFILE_BOARD -// fprintf(stderr,"\r[%5d]",frame_counter); +// fprintf(stderr,"\r[%5d]",frame_counter); #endif goto HANDLE_ERROR_AT_INIT; } @@ -1743,7 +1743,7 @@ INIT_AGAIN: _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); -// fprintf(stderr,"i_bytes_consumed :: [%5d]\n",i_bytes_consumed); +// fprintf(stderr,"i_bytes_consumed :: [%5d]\n",i_bytes_consumed); #ifdef TEST_INSUFFICIENT_INPUT // shift out consumed data @@ -1773,7 +1773,7 @@ INIT_AGAIN: i_total_bytes - skip_samples * i_num_chan * (i_pcm_wd_sz >> 3); if (bytes_to_write < i_out_bytes) { ixheaacd_drc_offset = i_out_bytes - bytes_to_write; - // i_total_bytes = i_total_bytes - i_out_bytes + bytes_to_write; + // i_total_bytes = i_total_bytes - i_out_bytes + bytes_to_write; i_out_bytes = bytes_to_write; current_samples = bytes_to_write / (i_num_chan * (i_pcm_wd_sz >> 3)); @@ -1795,7 +1795,7 @@ INIT_AGAIN: } } - // printf("i_out_bytes = %d\n",i_out_bytes); + // printf("i_out_bytes = %d\n",i_out_bytes); if (write_flag) { #ifndef WIN32 @@ -1906,7 +1906,7 @@ INIT_AGAIN: err_code = (*p_set_config_param)(argc, argv, pv_ia_process_api_obj); _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); - // removed /* Open new file only if the + // removed /* Open new file only if the // error // occured // during process */ @@ -1973,7 +1973,7 @@ INIT_AGAIN: fprintf(stderr, "TOTAL FRAMES : [%5d] \n", frame_counter); - // i_num_chan = num_of_output_ch; + // i_num_chan = num_of_output_ch; err_code = (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, &i_num_chan, &i_pcm_wd_sz, &i_channel_mask); _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); diff --git a/test/ixheaacd_metadata_read.c b/test/ixheaacd_metadata_read.c index c65a456..c997350 100644 --- a/test/ixheaacd_metadata_read.c +++ b/test/ixheaacd_metadata_read.c @@ -41,13 +41,13 @@ int ixheaacd_read_metadata_info(FILE *g_pf_metadata, metadata_info *meta_info) { WORD32 i, j, k, l; i = j = k = l = 0; while (fgets((char *)cmd, IA_MAX_CMDLINE_LENGTH, g_pf_metadata)) { - if (file_count < 5) { if (!strncmp((pCHAR8)cmd, "-dec_info_init:", 15)) { pCHAR8 pb_arg_val = (pCHAR8)(cmd + 15); UWORD32 dec_info_init = atoi(pb_arg_val); meta_info->dec_info_init = dec_info_init; file_count++; - } else if (!strncmp((pCHAR8)cmd, "-g_track_count:", 15)) { + } + else if (!strncmp((pCHAR8)cmd, "-g_track_count:", 15)) { pCHAR8 pb_arg_val = (pCHAR8)(cmd + 15); UWORD32 g_track_count = atoi(pb_arg_val); meta_info->g_track_count = g_track_count; @@ -76,12 +76,14 @@ int ixheaacd_read_metadata_info(FILE *g_pf_metadata, metadata_info *meta_info) { meta_info->ia_mp4_stsz_size = (UWORD32 *)malloc(sizeof(int) * ia_mp4_stsz_entries); file_count++; - } else { - printf("Wrong file order,Check file order"); - return -1; } - } else { - if (!strncmp((pCHAR8)cmd, "-playTimeInSamples:", 19)) { + /* + else if { + //printf("Wrong file order,Check file order"); + //return -1; + } + */ + else if (!strncmp((pCHAR8)cmd, "-playTimeInSamples:", 19)) { pCHAR8 pb_arg_val = (pCHAR8)(cmd + 19); UWORD32 playTimeInSamples = atoi(pb_arg_val); meta_info->playTimeInSamples[i] = playTimeInSamples; @@ -113,7 +115,6 @@ int ixheaacd_read_metadata_info(FILE *g_pf_metadata, metadata_info *meta_info) { printf("Command not found"); return -1; } - } } for (; i < MAX_TRACKS_PER_LAYER; i++) { @@ -128,16 +129,6 @@ int ixheaacd_read_metadata_info(FILE *g_pf_metadata, metadata_info *meta_info) { meta_info->useEditlist[k] = 0; } -#if 0 - fill_once=meta_info->fill_once=0; - - for(i=0;iuseEditlist[i]; - startOffsetInSamples[i]=meta_info->startOffsetInSamples[i]; - playTimeInSamples[i]=meta_info->playTimeInSamples[i]; - } -#endif return 0; }