|
|
@ -1,5 +1,5 @@ |
|
|
|
function frameType = SSC(~, nextFrameT, prevFrameType) |
|
|
|
%Implementation of the SSC step |
|
|
|
%Implementation of the Sequence Segmentation Control step |
|
|
|
% Usage frameType = SSC(frameT, nextFrameT, prevFrameType), where: |
|
|
|
% Inputs |
|
|
|
% - frameT is a frame in the time domain, containing both channels of |
|
|
@ -29,29 +29,29 @@ function frameType = SSC(~, nextFrameT, prevFrameType) |
|
|
|
|
|
|
|
% Determines the type of the next frame |
|
|
|
% Filters frame |
|
|
|
nextFrameT = filter([0.7548, -0.7548], [1, -0.5095], nextFrameT, [], 2); |
|
|
|
nextFrameT = filter([0.7548, -0.7548], [1, -0.5095], nextFrameT, [], 1); |
|
|
|
|
|
|
|
channelFrameType = {'OLS', 'OLS'}; |
|
|
|
channelFrameType = {'nan', 'nan'}; |
|
|
|
|
|
|
|
for channel = 1:2 |
|
|
|
% Calculates sub-frame energy estimation |
|
|
|
[subFrames, ~] = buffer(nextFrameT(449:end-448, channel), 256, 128, 'nodelay'); |
|
|
|
energyEstimations = sum(subFrames.^2, 1); |
|
|
|
[subFrames, ~] = buffer(nextFrameT(449:end - 448, channel), 256, 128, 'nodelay'); |
|
|
|
energyEstimations = sum(subFrames .^ 2, 1); |
|
|
|
|
|
|
|
% Calculates the ratio of the sub-frame energy to the average energy of |
|
|
|
% the previous sub-frames |
|
|
|
nextIsESH = 0; |
|
|
|
for subFrameIndex = 1:8 |
|
|
|
nextIsESH = false; |
|
|
|
for subFrameIndex = 2:8 |
|
|
|
energyRatio = energyEstimations(subFrameIndex) / ... |
|
|
|
mean(energyEstimations(1:subFrameIndex-1)); |
|
|
|
mean(energyEstimations(1:subFrameIndex - 1)); |
|
|
|
|
|
|
|
if (energyEstimations(subFrameIndex) > 10^(-3)) && (energyRatio > 10) |
|
|
|
nextIsESH = 1; |
|
|
|
nextIsESH = true; |
|
|
|
break; |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
if nextIsESH == 1 |
|
|
|
if nextIsESH == true |
|
|
|
if strcmp(prevFrameType, 'ESH') |
|
|
|
% This frame of this channel is an EIGHT_SHORT_SEQUENCE type |
|
|
|
% frame. This means the frames of both channels will be encoded |
|
|
@ -70,6 +70,9 @@ function frameType = SSC(~, nextFrameT, prevFrameType) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
if strcmp(channelFrameType{1}, 'nan') || strcmp(channelFrameType{2}, 'nan') |
|
|
|
error('SSC, l[73]: Internal error occured!') |
|
|
|
end |
|
|
|
if strcmp(channelFrameType{1}, 'OLS') |
|
|
|
frameType = channelFrameType{2}; |
|
|
|
elseif strcmp(channelFrameType{2}, 'OLS') |
|
|
|