From a62f25d1ac2a1974073c1ef5d824f609345c306d Mon Sep 17 00:00:00 2001 From: Stefan Pöschel Date: Mon, 7 Aug 2017 23:22:02 +0200 Subject: Calc calculated_padlen only once --- src/odr-audioenc.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/odr-audioenc.cpp b/src/odr-audioenc.cpp index 14666a5..89e8dd1 100644 --- a/src/odr-audioenc.cpp +++ b/src/odr-audioenc.cpp @@ -992,6 +992,17 @@ int main(int argc, char *argv[]) break; } + int calculated_padlen = 0; + if (pad_ret == padlen + 1) { + calculated_padlen = pad_buf[padlen]; + if (calculated_padlen < 2) { + stringstream ss; + ss << "Invalid X-PAD length " << calculated_padlen; + throw runtime_error(ss.str()); + } + } + + // -------------- Read Data memset(&outbuf[0], 0x00, outbuf_size); memset(&input_buf[0], 0x00, input_buf.size()); @@ -1158,7 +1169,6 @@ int main(int argc, char *argv[]) // int in_identifier[] = {IN_AUDIO_DATA, IN_ANCILLRY_DATA}; int out_identifier = OUT_BITSTREAM_DATA; - const int calculated_padlen = pad_ret > 0 ? pad_buf[padlen] : 0; const int subchannel_index = bitrate / 8; void *in_ptr[2], *out_ptr; @@ -1204,16 +1214,6 @@ int main(int argc, char *argv[]) numOutBytes = out_args.numOutBytes; } else if (selected_encoder == encoder_selection_t::toolame_dab) { - int calculated_padlen = 0; - if (pad_ret == padlen + 1) { - calculated_padlen = pad_buf[padlen]; - if (calculated_padlen < 2) { - stringstream ss; - ss << "Invalid X-PAD length " << calculated_padlen; - throw runtime_error(ss.str()); - } - } - /*! \note toolame expects the audio to be in another shape as * we have in input_buf, and we need to convert first */ -- cgit v1.2.3