|
|
@ -49,19 +49,28 @@ function [S, sfc, G] = AACquantizer(frameF, frameType, SMR) |
|
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
|
.^ (3 / 4) + 0.4054); |
|
|
|
|
|
|
|
% Calculates dequantized frame samples |
|
|
|
frameFDequant = sign(S(frameWlow:frameWhigh, 1)) .* ... |
|
|
|
abs(S(frameWlow:frameWhigh, 1)) .^ ... |
|
|
|
(4 / 3) .* 2 ^ (quantCoeff(band) / 4); |
|
|
|
|
|
|
|
% Calculates current quantization error |
|
|
|
quantErr = sumsqr(subFrameF - S(frameWlow:frameWhigh)); |
|
|
|
quantErr = sumsqr(subFrameF - frameFDequant); |
|
|
|
|
|
|
|
% Gradually increases the quantization coefficient |
|
|
|
while quantErr < T(band) && (band > 1 || ... |
|
|
|
(quantErr(band) - quantErr(band - 1) + 1) <= 60) |
|
|
|
while quantErr < T(band) && (band < 2 || ... |
|
|
|
(quantCoeff(band) - quantCoeff(band - 1) + 1) <= 60) |
|
|
|
quantCoeff(band) = quantCoeff(band) + 1; |
|
|
|
|
|
|
|
S(frameWlow:frameWhigh) = sign(subFrameF) .* round(( ... |
|
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
|
.^ (3 / 4) + 0.4054); |
|
|
|
|
|
|
|
quantErr = sumsqr(subFrameF - S(frameWlow:frameWhigh)); |
|
|
|
frameFDequant = sign(S(frameWlow:frameWhigh, 1)) .* ... |
|
|
|
abs(S(frameWlow:frameWhigh, 1)) .^ ... |
|
|
|
(4 / 3) .* 2 ^ (quantCoeff(band) / 4); |
|
|
|
|
|
|
|
quantErr = sumsqr(subFrameF - frameFDequant); |
|
|
|
end |
|
|
|
|
|
|
|
if band == 1 |
|
|
@ -94,18 +103,29 @@ function [S, sfc, G] = AACquantizer(frameF, frameType, SMR) |
|
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
|
.^ (3 / 4) + 0.4054); |
|
|
|
|
|
|
|
% Calculates dequantized frame samples |
|
|
|
frameFDequant = sign(S(currFrameStart + frameWlow: ... |
|
|
|
currFrameStart + frameWhigh, 1)) .* abs(S( ... |
|
|
|
currFrameStart + frameWlow:currFrameStart + frameWhigh, 1) ... |
|
|
|
) .^ (4 / 3) .* 2 ^ (quantCoeff(band) / 4); |
|
|
|
|
|
|
|
% Calculates current quantization error |
|
|
|
quantErr = sumsqr(subFrameF - S(currFrameStart + frameWlow:currFrameStart + frameWhigh)); |
|
|
|
quantErr = sumsqr(subFrameF - frameFDequant); |
|
|
|
|
|
|
|
% Gradually increases the quantization coefficient |
|
|
|
while quantErr < T(band) && (band > 1 || ... |
|
|
|
(quantErr(band) - quantErr(band - 1) + 1) <= 60) |
|
|
|
while quantErr < T(band) && (band < 2 || ... |
|
|
|
(quantCoeff(band) - quantCoeff(band - 1) + 1) <= 60) |
|
|
|
quantCoeff(band) = quantCoeff(band) + 1; |
|
|
|
S(currFrameStart + frameWlow:currFrameStart + frameWhigh) = sign(subFrameF) .* round(( ... |
|
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
|
.^ (3 / 4) + 0.4054); |
|
|
|
|
|
|
|
quantErr = sumsqr(subFrameF - S(currFrameStart + frameWlow:currFrameStart + frameWhigh)); |
|
|
|
frameFDequant = sign(S(currFrameStart + frameWlow: ... |
|
|
|
currFrameStart + frameWhigh, 1)) .* abs(S( ... |
|
|
|
currFrameStart + frameWlow:currFrameStart + frameWhigh, 1) ... |
|
|
|
) .^ (4 / 3) .* 2 ^ (quantCoeff(band) / 4); |
|
|
|
|
|
|
|
quantErr = sumsqr(subFrameF - frameFDequant); |
|
|
|
end |
|
|
|
|
|
|
|
if band == 1 |
|
|
|