aboutsummaryrefslogtreecommitdiffstats
path: root/src/atrac3denc.cpp
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2020-01-20 00:24:21 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2020-01-20 00:24:21 +0300
commite16e9c60a18e4b914f5cb16463ed781f09808a25 (patch)
tree23a22c26ff5b20697f9c62b6286258bac04fe6f7 /src/atrac3denc.cpp
parent83d5e5d3652608478b5f18212bd3fec2338ae954 (diff)
downloadatracdenc-e16e9c60a18e4b914f5cb16463ed781f09808a25.tar.gz
[atrac3] 0.83/0.16 M/S bitrate separation for joint stereo coding
support of encoding mono source for joint stereo mode
Diffstat (limited to 'src/atrac3denc.cpp')
-rw-r--r--src/atrac3denc.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/atrac3denc.cpp b/src/atrac3denc.cpp
index f6d8758..071a0fb 100644
--- a/src/atrac3denc.cpp
+++ b/src/atrac3denc.cpp
@@ -300,8 +300,7 @@ TPCMEngine<TFloat>::TProcessLambda TAtrac3Processor::GetEncodeLambda()
return [this, bitStreamWriter](TFloat* data, const TPCMEngine<TFloat>::ProcessMeta& meta) {
using TSce = TAtrac3BitStreamWriter::TSingleChannelElement;
- assert(SingleChannelElements.size() == meta.Channels);
- for (uint32_t channel = 0; channel < SingleChannelElements.size(); channel++) {
+ for (uint32_t channel = 0; channel < meta.Channels; channel++) {
TFloat src[NumSamples];
for (size_t i = 0; i < NumSamples; ++i) {
@@ -314,11 +313,11 @@ TPCMEngine<TFloat>::TProcessLambda TAtrac3Processor::GetEncodeLambda()
}
}
- if (Params.ConteinerParams->Js) {
+ if (Params.ConteinerParams->Js && meta.Channels == 2) {
Matrixing();
}
- for (uint32_t channel = 0; channel < SingleChannelElements.size(); channel++) {
+ for (uint32_t channel = 0; channel < meta.Channels; channel++) {
vector<TFloat> specs(1024);
TSce* sce = &SingleChannelElements[channel];
@@ -340,6 +339,14 @@ TPCMEngine<TFloat>::TProcessLambda TAtrac3Processor::GetEncodeLambda()
}
+ if (Params.ConteinerParams->Js && meta.Channels == 1) {
+ // In case of JointStereo and one input channel (mono input) we need to construct one empty SCE to produce
+ // correct bitstream
+ SingleChannelElements.resize(2);
+ // Set 1 subband
+ SingleChannelElements[1].SubbandInfo.Info.resize(1);
+ }
+
bitStreamWriter->WriteSoundUnit(SingleChannelElements);
};
}