aboutsummaryrefslogtreecommitdiffstats
path: root/libAACenc/src/qc_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libAACenc/src/qc_main.cpp')
-rw-r--r--libAACenc/src/qc_main.cpp49
1 files changed, 19 insertions, 30 deletions
diff --git a/libAACenc/src/qc_main.cpp b/libAACenc/src/qc_main.cpp
index bcfaa23..9a42550 100644
--- a/libAACenc/src/qc_main.cpp
+++ b/libAACenc/src/qc_main.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -373,13 +373,8 @@ AAC_ENCODER_ERROR FDKaacEnc_QCInit(QC_STATE* hQC, struct QC_INIT* init,
hQC->invQuant = init->invQuant;
hQC->maxIterations = init->maxIterations;
- if (isConstantBitrateMode(hQC->bitrateMode)) {
- /* 0: full bitreservoir, 1: reduced bitreservoir, 2: disabled bitreservoir
- */
- hQC->bitResMode = init->bitResMode;
- } else {
- hQC->bitResMode = AACENC_BR_MODE_FULL; /* full bitreservoir */
- }
+ /* 0: full bitreservoir, 1: reduced bitreservoir, 2: disabled bitreservoir */
+ hQC->bitResMode = init->bitResMode;
hQC->padding.paddingRest = init->padding.paddingRest;
@@ -800,10 +795,15 @@ AAC_ENCODER_ERROR FDKaacEnc_QCMain(QC_STATE* RESTRICT hQC, PSY_OUT** psyOut,
INT avgTotalDynBits = 0; /* maximal allowed dynamic bits for all frames */
INT totalAvailableBits = 0;
INT nSubFrames = 1;
+ const INT isCBRAdjustment = (isConstantBitrateMode(hQC->bitrateMode) ||
+ (hQC->bitResMode != AACENC_BR_MODE_FULL))
+ ? 1
+ : 0;
/*-------------------------------------------- */
/* redistribute total bitreservoir to elements */
- ErrorStatus = FDKaacEnc_BitResRedistribution(hQC, cm, avgTotalBits);
+ ErrorStatus = FDKaacEnc_BitResRedistribution(
+ hQC, cm, (isCBRAdjustment == 0) ? hQC->maxBitsPerFrame : avgTotalBits);
if (ErrorStatus != AAC_ENC_OK) {
return ErrorStatus;
}
@@ -831,33 +831,22 @@ AAC_ENCODER_ERROR FDKaacEnc_QCMain(QC_STATE* RESTRICT hQC, PSY_OUT** psyOut,
/*-------------------------------------------- */
/*-------------------------------------------- */
- if (isConstantBitrateMode(hQC->bitrateMode)) {
- /* calc granted dynamic bits for sub frame and
- distribute it to each element */
- ErrorStatus = FDKaacEnc_prepareBitDistribution(
- hQC, psyOut, qcOut, cm, qcElement, avgTotalBits, &totalAvailableBits,
- &avgTotalDynBits);
-
- if (ErrorStatus != AAC_ENC_OK) {
- return ErrorStatus;
- }
- } else {
- qcOut[0]->grantedDynBits =
- ((hQC->maxBitsPerFrame - (hQC->globHdrBits)) & ~7) -
- (qcOut[0]->globalExtBits + qcOut[0]->staticBits +
- qcOut[0]->elementExtBits);
- qcOut[0]->maxDynBits = qcOut[0]->grantedDynBits;
-
- totalAvailableBits = hQC->maxBitsPerFrame;
- avgTotalDynBits = 0;
+ /* calc granted dynamic bits for sub frame and
+ distribute it to each element */
+ ErrorStatus = FDKaacEnc_prepareBitDistribution(
+ hQC, psyOut, qcOut, cm, qcElement,
+ (isCBRAdjustment == 0) ? hQC->maxBitsPerFrame : avgTotalBits,
+ &totalAvailableBits, &avgTotalDynBits);
+
+ if (ErrorStatus != AAC_ENC_OK) {
+ return ErrorStatus;
}
/* for ( all sub frames ) ... */
for (c = 0; c < nSubFrames; c++) {
/* for CBR and VBR mode */
FDKaacEnc_AdjustThresholds(hQC->hAdjThr, qcElement[c], qcOut[c],
- psyOut[c]->psyOutElement,
- isConstantBitrateMode(hQC->bitrateMode), cm);
+ psyOut[c]->psyOutElement, isCBRAdjustment, cm);
} /* -end- sub frame counter */