Browse Source

Add bitrate and compression calculation, Fixes

master
Apostolos Fanakis 6 years ago
parent
commit
cc350b8f39
  1. 3
      Level_3/AACoder3.m
  2. BIN
      Level_3/decoded3.wav
  3. 17
      Level_3/demoAAC3.m
  4. BIN
      Level_3/encoded.mat
  5. 13
      Level_3/iAACoder3.m

3
Level_3/AACoder3.m

@ -130,7 +130,6 @@ function AACSeq3 = AACoder3(fNameIn, fnameAACoded)
TL(band) = sumsqr(subFrameF) ./ SMRL(band);
TR(band) = sumsqr(subFrameF) ./ SMRR(band);
end
plot(TL);
else
TL(SHORT_WINDOW_NUMBER_OF_BANDS, 1) = 0;
TR(SHORT_WINDOW_NUMBER_OF_BANDS, 1) = 0;
@ -176,6 +175,8 @@ function AACSeq3 = AACoder3(fNameIn, fnameAACoded)
AACSeq3(i + 1).chr.stream = streamR;
AACSeq3(i + 1).chl.codebook = huffcodebookL;
AACSeq3(i + 1).chr.codebook = huffcodebookR;
clearvars TL TR
end
save(fnameAACoded, 'AACSeq3');

BIN
Level_3/decoded3.wav

Binary file not shown.

17
Level_3/demoAAC3.m

@ -16,11 +16,26 @@ function [SNR, bitrate, compression] = demoAAC3(fNameIn, fNameOut, frameAACoded)
% the bitrate after it
AACSeq3 = AACoder3(fNameIn, frameAACoded);
totalSize = 0;
for frameIndex = 1:length(AACSeq3)
totalSize = totalSize + 2; % frameType
totalSize = totalSize + 2 * 4; % TNS coefficients
totalSize = totalSize + length(AACSeq3(frameIndex).chl.G) * 4;
totalSize = totalSize + length(AACSeq3(frameIndex).chr.G) * 4;
totalSize = totalSize + length(AACSeq3(frameIndex).chl.sfc);
totalSize = totalSize + length(AACSeq3(frameIndex).chr.sfc);
totalSize = totalSize + length(AACSeq3(frameIndex).chl.stream);
totalSize = totalSize + length(AACSeq3(frameIndex).chr.stream);
end
decodedAudio = iAACoder3(AACSeq3, fNameOut);
bitrate = totalSize / (length(decodedAudio) / 48000);
[audioData, ~] = audioread(fNameIn);
compression = (length(audioData) * 64) / totalSize;
snr(audioData(1025:length(decodedAudio)-1024, 1), audioData(1025:length(decodedAudio)-1024, 1) - decodedAudio(1025:end-1024, 1))
snr(audioData(1025:length(decodedAudio)-1024, 2), audioData(1025:length(decodedAudio)-1024, 2) - decodedAudio(1025:end-1024, 2))
SNR = snr(audioData(1025:length(decodedAudio)-1024, :), audioData(1025:length(decodedAudio)-1024, 2) - decodedAudio(1025:end-1024, :));
SNR = snr(audioData(1025:length(decodedAudio)-1024, :), audioData(1025:length(decodedAudio)-1024, :) - decodedAudio(1025:end-1024, :));
end

BIN
Level_3/encoded.mat

Binary file not shown.

13
Level_3/iAACoder3.m

@ -48,17 +48,6 @@ function x = iAACoder3(AACSeq3, fNameOut)
currFrameStart = i * 1024 + 1;
currFrameStop = currFrameStart + 2047;
if i < 2
continue;
frameF(:, 1) = iTNS(AACSeq3(i + 1).chl.stream, ...
AACSeq3(i+1).frameType, ...
AACSeq3(i + 1).chl.TNScoeffs);
frameF(:, 2) = iTNS(AACSeq3(i + 1).chr.stream, ...
AACSeq3(i+1).frameType, ...
AACSeq3(i + 1).chr.TNScoeffs);
frameT = iFilterbank(frameF, AACSeq3(i+1).frameType, AACSeq3(i+1).winType);
else
SL = decodeHuff(AACSeq3(i + 1).chl.stream, ...
AACSeq3(i + 1).chl.codebook, huffLUT);
SR = decodeHuff(AACSeq3(i + 1).chr.stream, ...
@ -91,7 +80,7 @@ function x = iAACoder3(AACSeq3, fNameOut)
AACSeq3(i + 1).chr.TNScoeffs);
frameT = iFilterbank(frameF, AACSeq3(i+1).frameType, AACSeq3(i+1).winType);
end
decodedAudio(currFrameStart:currFrameStop, :) = decodedAudio(currFrameStart:currFrameStop, :) + frameT;

Loading…
Cancel
Save