diff --git a/ext/at3_standalone/atrac3plus.cpp b/ext/at3_standalone/atrac3plus.cpp index 01a5fbe801..0844deed59 100644 --- a/ext/at3_standalone/atrac3plus.cpp +++ b/ext/at3_standalone/atrac3plus.cpp @@ -815,16 +815,6 @@ static int decode_code_table_indexes(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, return 0; } -/** - * Clear high bits from an unsigned integer starting with specific bit position - * @param a value to clip - * @param p bit position to clip at - * @return clipped value - */ -inline unsigned av_mod_uintp2(unsigned a, unsigned p) { - return a & ((1 << p) - 1); -} - /** * Decode huffman-coded spectral lines for a given quant unit. * @@ -846,21 +836,21 @@ static void decode_qu_spectra(GetBitContext *gb, const Atrac3pSpecCodeTab *tab, int bits = tab->bits; int is_signed = tab->is_signed; unsigned val; + const unsigned bitmask = ((1 << bits) - 1); // mask to clear higher bits. for (pos = 0; pos < num_specs;) { if (group_size == 1 || get_bits1(gb)) { for (j = 0; j < group_size; j++) { val = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1); - for (i = 0; i < num_coeffs; i++) { - cf = av_mod_uintp2(val, bits); + cf = val & bitmask; if (is_signed) cf = sign_extend(cf, bits); else if (cf && get_bits1(gb)) cf = -cf; out[pos++] = cf; - val >>= bits; + val >>= bits; } } } else /* group skipped */ diff --git a/ext/at3_standalone/compat.h b/ext/at3_standalone/compat.h index 57b0244de4..f282f0c9c5 100644 --- a/ext/at3_standalone/compat.h +++ b/ext/at3_standalone/compat.h @@ -37,10 +37,6 @@ #define av_printf_format(a,b) #define avpriv_report_missing_feature(...) -#define AV_NOPTS_VALUE ((int64_t)UINT64_C(0x8000000000000000)) -#define AV_TIME_BASE 1000000 -#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} - #define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions. #define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value. @@ -49,8 +45,6 @@ #define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input #define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome -#define FF_SANE_NB_CHANNELS 64U - #define AV_LOG_ERROR 16 #define AV_LOG_WARNING 24 #define AV_LOG_INFO 32 @@ -60,13 +54,6 @@ void av_log(int level, const char *fmt, ...) av_printf_format(3, 4); -/** - * Maximum size in bytes of extradata. - * This value was chosen such that every bit of the buffer is - * addressable by a 32-bit signed integer as used by get_bits. - */ -#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) - /** * Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they * are not representable as absolute values of their type. This is the same diff --git a/ext/at3_standalone/get_bits.cpp b/ext/at3_standalone/get_bits.cpp index 4c7725f89b..50d3969219 100644 --- a/ext/at3_standalone/get_bits.cpp +++ b/ext/at3_standalone/get_bits.cpp @@ -87,7 +87,7 @@ static int alloc_table(VLC *vlc, int size, int use_static) vlc->table_size = 0; return AVERROR(ENOMEM); } - memset(vlc->table + vlc->table_allocated - (1 << vlc->bits), 0, sizeof(VLC_TYPE) * 2 << vlc->bits); + memset(vlc->table + vlc->table_allocated - (unsigned int)(1UL << vlc->bits), 0, sizeof(VLC_TYPE) * 2 << vlc->bits); } return index; }