|
@ -35,6 +35,7 @@ function [S, sfc, G] = AACquantizer(frameF, frameType, SMR) |
|
|
T(LONG_WINDOW_NUMBER_OF_BANDS, 1) = 0; |
|
|
T(LONG_WINDOW_NUMBER_OF_BANDS, 1) = 0; |
|
|
quantCoeff(LONG_WINDOW_NUMBER_OF_BANDS, 1) = 0; |
|
|
quantCoeff(LONG_WINDOW_NUMBER_OF_BANDS, 1) = 0; |
|
|
sfc(LONG_WINDOW_NUMBER_OF_BANDS, 1) = 0; |
|
|
sfc(LONG_WINDOW_NUMBER_OF_BANDS, 1) = 0; |
|
|
|
|
|
initialQuantCoeff = 16 * log2(max(frameF) ^ (3 / 4) / 8191) / 3; |
|
|
for band = 1:LONG_WINDOW_NUMBER_OF_BANDS |
|
|
for band = 1:LONG_WINDOW_NUMBER_OF_BANDS |
|
|
frameWlow = TNSTables.B219a(band, 2) + 1; |
|
|
frameWlow = TNSTables.B219a(band, 2) + 1; |
|
|
frameWhigh = TNSTables.B219a(band, 3) + 1; |
|
|
frameWhigh = TNSTables.B219a(band, 3) + 1; |
|
@ -44,7 +45,7 @@ function [S, sfc, G] = AACquantizer(frameF, frameType, SMR) |
|
|
|
|
|
|
|
|
% Calculates an initial quantization coefficient and attempts |
|
|
% Calculates an initial quantization coefficient and attempts |
|
|
% quantization |
|
|
% quantization |
|
|
quantCoeff(band) = 16 * log2(max(frameF) ^ (3 / 4) / 8191) / 3; |
|
|
quantCoeff(band) = initialQuantCoeff; |
|
|
S(frameWlow:frameWhigh, 1) = sign(subFrameF) .* floor(( ... |
|
|
S(frameWlow:frameWhigh, 1) = sign(subFrameF) .* floor(( ... |
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
.^ (3 / 4) + 0.4054); |
|
|
.^ (3 / 4) + 0.4054); |
|
@ -61,7 +62,6 @@ function [S, sfc, G] = AACquantizer(frameF, frameType, SMR) |
|
|
while quantErr < T(band) && (band < 2 || ... |
|
|
while quantErr < T(band) && (band < 2 || ... |
|
|
(quantCoeff(band) - quantCoeff(band - 1) + 1) <= 60) |
|
|
(quantCoeff(band) - quantCoeff(band - 1) + 1) <= 60) |
|
|
quantCoeff(band) = quantCoeff(band) + 1; |
|
|
quantCoeff(band) = quantCoeff(band) + 1; |
|
|
|
|
|
|
|
|
S(frameWlow:frameWhigh) = sign(subFrameF) .* round(( ... |
|
|
S(frameWlow:frameWhigh) = sign(subFrameF) .* round(( ... |
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
.^ (3 / 4) + 0.4054); |
|
|
.^ (3 / 4) + 0.4054); |
|
@ -73,6 +73,13 @@ function [S, sfc, G] = AACquantizer(frameF, frameType, SMR) |
|
|
quantErr = sumsqr(subFrameF - frameFDequant); |
|
|
quantErr = sumsqr(subFrameF - frameFDequant); |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if quantCoeff(band) ~= initialQuantCoeff |
|
|
|
|
|
quantCoeff(band) = quantCoeff(band) - 1; |
|
|
|
|
|
S(frameWlow:frameWhigh) = sign(subFrameF) .* round(( ... |
|
|
|
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
|
|
|
.^ (3 / 4) + 0.4054); |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
if band == 1 |
|
|
if band == 1 |
|
|
sfc(band) = quantCoeff(band); |
|
|
sfc(band) = quantCoeff(band); |
|
|
else |
|
|
else |
|
@ -89,6 +96,7 @@ function [S, sfc, G] = AACquantizer(frameF, frameType, SMR) |
|
|
currFrameStart = (subFrameIndex - 1) * 128 + 1; |
|
|
currFrameStart = (subFrameIndex - 1) * 128 + 1; |
|
|
currFrameStop = currFrameStart + 127; |
|
|
currFrameStop = currFrameStart + 127; |
|
|
subFrame = frameF(currFrameStart:currFrameStop); |
|
|
subFrame = frameF(currFrameStart:currFrameStop); |
|
|
|
|
|
initialQuantCoeff = 16 * log2(max(subFrame) ^ (3 / 4) / 8191) / 3; |
|
|
for band = 1:SHORT_WINDOW_NUMBER_OF_BANDS |
|
|
for band = 1:SHORT_WINDOW_NUMBER_OF_BANDS |
|
|
frameWlow = TNSTables.B219b(band, 2); |
|
|
frameWlow = TNSTables.B219b(band, 2); |
|
|
frameWhigh = TNSTables.B219b(band, 3); |
|
|
frameWhigh = TNSTables.B219b(band, 3); |
|
@ -98,7 +106,7 @@ function [S, sfc, G] = AACquantizer(frameF, frameType, SMR) |
|
|
|
|
|
|
|
|
% Calculates an initial quantization coefficient and attempts |
|
|
% Calculates an initial quantization coefficient and attempts |
|
|
% quantization |
|
|
% quantization |
|
|
quantCoeff(band) = 16 * log2(max(subFrame) ^ (3 / 4) / 8191) / 3; |
|
|
quantCoeff(band) = initialQuantCoeff; |
|
|
S(currFrameStart + frameWlow:currFrameStart + frameWhigh, 1) = sign(subFrameF) .* floor(( ... |
|
|
S(currFrameStart + frameWlow:currFrameStart + frameWhigh, 1) = sign(subFrameF) .* floor(( ... |
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
.^ (3 / 4) + 0.4054); |
|
|
.^ (3 / 4) + 0.4054); |
|
@ -128,6 +136,13 @@ function [S, sfc, G] = AACquantizer(frameF, frameType, SMR) |
|
|
quantErr = sumsqr(subFrameF - frameFDequant); |
|
|
quantErr = sumsqr(subFrameF - frameFDequant); |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if quantCoeff(band) ~= initialQuantCoeff |
|
|
|
|
|
quantCoeff(band) = quantCoeff(band) - 1; |
|
|
|
|
|
S(currFrameStart + frameWlow:currFrameStart + frameWhigh) = sign(subFrameF) .* round(( ... |
|
|
|
|
|
abs(subFrameF) .* 2 ^ (-quantCoeff(band) / 4)) ... |
|
|
|
|
|
.^ (3 / 4) + 0.4054); |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
if band == 1 |
|
|
if band == 1 |
|
|
sfc(band, subFrameIndex) = quantCoeff(band); |
|
|
sfc(band, subFrameIndex) = quantCoeff(band); |
|
|
else |
|
|
else |
|
|