From b181b8fb96f9fdc2b166fcbd048110cec653cdf9 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 15 Mar 2011 13:30:24 -0400 Subject: mathops: convert MULL/MULH/MUL64 to inline functions rather than macros. This fixes unexpected name collisions that were occurring with variables declared within the macros. It also fixes the fate-acodec-ac3_fixed regression test on x86-32. --- libavcodec/x86/mathops.h | 53 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 16 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h index 5949dfe3d4..4e54886227 100644 --- a/libavcodec/x86/mathops.h +++ b/libavcodec/x86/mathops.h @@ -26,24 +26,45 @@ #include "libavutil/common.h" #if ARCH_X86_32 -#define MULL(ra, rb, shift) \ - ({ int rt, dummy; __asm__ (\ - "imull %3 \n\t"\ - "shrdl %4, %%edx, %%eax \n\t"\ - : "=a"(rt), "=d"(dummy)\ - : "a" ((int)(ra)), "rm" ((int)(rb)), "i"(shift));\ - rt; }) -#define MULH(ra, rb) \ - ({ int rt, dummy;\ - __asm__ ("imull %3\n\t" : "=d"(rt), "=a"(dummy): "a" ((int)(ra)), "rm" ((int)(rb)));\ - rt; }) +#define MULL MULL +static av_always_inline av_const int MULL(int a, int b, unsigned shift) +{ + int rt, dummy; + __asm__ ( + "imull %3 \n\t" + "shrdl %4, %%edx, %%eax \n\t" + :"=a"(rt), "=d"(dummy) + :"a"(a), "rm"(b), "i"(shift) + ); + return rt; +} -#define MUL64(ra, rb) \ - ({ int64_t rt;\ - __asm__ ("imull %2\n\t" : "=A"(rt) : "a" ((int)(ra)), "g" ((int)(rb)));\ - rt; }) -#endif +#define MULH MULH +static av_always_inline av_const int MULH(int a, int b) +{ + int rt, dummy; + __asm__ ( + "imull %3" + :"=d"(rt), "=a"(dummy) + :"a"(a), "rm"(b) + ); + return rt; +} + +#define MUL64 MUL64 +static av_always_inline av_const int64_t MUL64(int a, int b) +{ + int64_t rt; + __asm__ ( + "imull %2" + :"=A"(rt) + :"a"(a), "g"(b) + ); + return rt; +} + +#endif /* ARCH_X86_32 */ #if HAVE_CMOV /* median of 3 */ -- cgit v1.2.3 From aaff3b312ed0a67750aa0a3a3300a3b69bb87150 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 15 Mar 2011 13:35:05 -0400 Subject: mathops: change "g" constraint to "rm" in x86-32 version of MUL64(). The 1-arg imul instruction cannot take an immediate argument, only a register or memory argument. --- libavcodec/x86/mathops.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavcodec') diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h index 4e54886227..b18302744c 100644 --- a/libavcodec/x86/mathops.h +++ b/libavcodec/x86/mathops.h @@ -59,7 +59,7 @@ static av_always_inline av_const int64_t MUL64(int a, int b) __asm__ ( "imull %2" :"=A"(rt) - :"a"(a), "g"(b) + :"a"(a), "rm"(b) ); return rt; } -- cgit v1.2.3 From 79414257e23a0dee82a9978b5444ae8953376221 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 15 Mar 2011 20:38:23 -0400 Subject: mathops: fix MULL() when the compiler does not inline the function. If the function is not inlined, an immmediate cannot be used for the shift parameter, so the %cl register must be used instead in that case. This fixes compilation for x86-32 using gcc with --disable-optimizations. --- libavcodec/x86/mathops.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavcodec') diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h index b18302744c..33d9a6c8ff 100644 --- a/libavcodec/x86/mathops.h +++ b/libavcodec/x86/mathops.h @@ -35,7 +35,7 @@ static av_always_inline av_const int MULL(int a, int b, unsigned shift) "imull %3 \n\t" "shrdl %4, %%edx, %%eax \n\t" :"=a"(rt), "=d"(dummy) - :"a"(a), "rm"(b), "i"(shift) + :"a"(a), "rm"(b), "ci"((uint8_t)shift) ); return rt; } -- cgit v1.2.3 From 29ba091136a5e04574f7bfc1b17536c923958f6f Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Mon, 14 Mar 2011 22:23:10 +0100 Subject: replace FFMPEG with LIBAV in FFMPEG_CONFIGURATION also update the multiple inclusion guards in config.h|mak --- Makefile | 2 +- cmdutils.c | 4 ++-- configure | 22 +++++++++++----------- libavcodec/utils.c | 2 +- libavdevice/avdevice.c | 2 +- libavfilter/avfilter.c | 2 +- libavformat/utils.c | 2 +- libavutil/utils.c | 2 +- libpostproc/postprocess.c | 2 +- libswscale/utils.c | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) (limited to 'libavcodec') diff --git a/Makefile b/Makefile index ad1f737ebb..1ec443699e 100644 --- a/Makefile +++ b/Makefile @@ -177,7 +177,7 @@ distclean:: $(RM) version.h config.* libavutil/avconfig.h config: - $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION) + $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION) # regression tests diff --git a/cmdutils.c b/cmdutils.c index 514ebadb6e..7012d04cc5 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -397,7 +397,7 @@ static int warned_cfg = 0; } \ if (flags & SHOW_CONFIG) { \ const char *cfg = libname##_configuration(); \ - if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \ + if (strcmp(LIBAV_CONFIGURATION, cfg)) { \ if (!warned_cfg) { \ fprintf(outstream, \ "%sWARNING: library configuration mismatch\n", \ @@ -427,7 +427,7 @@ void show_banner(void) program_name, program_birth_year, this_year); fprintf(stderr, " built on %s %s with %s %s\n", __DATE__, __TIME__, CC_TYPE, CC_VERSION); - fprintf(stderr, " configuration: " FFMPEG_CONFIGURATION "\n"); + fprintf(stderr, " configuration: " LIBAV_CONFIGURATION "\n"); print_all_libs_info(stderr, INDENT|SHOW_CONFIG); print_all_libs_info(stderr, INDENT|SHOW_VERSION); } diff --git a/configure b/configure index 36b9e8ab5f..3dba45229c 100755 --- a/configure +++ b/configure @@ -1688,7 +1688,7 @@ for v in "$@"; do r=${v#*=} l=${v%"$r"} r=$(sh_quote "$r") - FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}" + LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}" done find_things(){ @@ -1800,7 +1800,7 @@ done disabled logging && logfile=/dev/null -echo "# $0 $FFMPEG_CONFIGURATION" > $logfile +echo "# $0 $LIBAV_CONFIGURATION" > $logfile set >> $logfile test -n "$cross_prefix" && enable cross_compile @@ -2495,7 +2495,7 @@ case $target_os in ;; esac -echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$FFMPEG_CONFIGURATION" >config.fate +echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$LIBAV_CONFIGURATION" >config.fate check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic @@ -3204,9 +3204,9 @@ config_files="$TMPH config.mak" cat > config.mak < $TMPH <> $TMPH -echo "endif # FFMPEG_CONFIG_MAK" >> config.mak +echo "#endif /* LIBAV_CONFIG_H */" >> $TMPH +echo "endif # LIBAV_CONFIG_MAK" >> config.mak # Do not overwrite an unchanged config.h to avoid superfluous rebuilds. cp_if_changed $TMPH config.h diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 18631ff164..be9c912560 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1035,7 +1035,7 @@ unsigned avcodec_version( void ) const char *avcodec_configuration(void) { - return FFMPEG_CONFIGURATION; + return LIBAV_CONFIGURATION; } const char *avcodec_license(void) diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index 3d67b4b8be..01db8776ac 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -25,7 +25,7 @@ unsigned avdevice_version(void) const char * avdevice_configuration(void) { - return FFMPEG_CONFIGURATION; + return LIBAV_CONFIGURATION; } const char * avdevice_license(void) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 039e04bf64..c0ead5c4be 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -34,7 +34,7 @@ unsigned avfilter_version(void) { const char *avfilter_configuration(void) { - return FFMPEG_CONFIGURATION; + return LIBAV_CONFIGURATION; } const char *avfilter_license(void) diff --git a/libavformat/utils.c b/libavformat/utils.c index 1dfaa3caf3..2f1db44572 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -51,7 +51,7 @@ unsigned avformat_version(void) const char *avformat_configuration(void) { - return FFMPEG_CONFIGURATION; + return LIBAV_CONFIGURATION; } const char *avformat_license(void) diff --git a/libavutil/utils.c b/libavutil/utils.c index 8a1d32e167..488bac4cc3 100644 --- a/libavutil/utils.c +++ b/libavutil/utils.c @@ -31,7 +31,7 @@ unsigned avutil_version(void) const char *avutil_configuration(void) { - return FFMPEG_CONFIGURATION; + return LIBAV_CONFIGURATION; } const char *avutil_license(void) diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index 92c822b772..7466b18be3 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -94,7 +94,7 @@ unsigned postproc_version(void) const char *postproc_configuration(void) { - return FFMPEG_CONFIGURATION; + return LIBAV_CONFIGURATION; } const char *postproc_license(void) diff --git a/libswscale/utils.c b/libswscale/utils.c index 166e983477..34988a0c66 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -53,7 +53,7 @@ unsigned swscale_version(void) const char *swscale_configuration(void) { - return FFMPEG_CONFIGURATION; + return LIBAV_CONFIGURATION; } const char *swscale_license(void) -- cgit v1.2.3 From a03be6e1ba4cbf9984b0bbdb674704bbb2da6713 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Mon, 14 Mar 2011 22:27:40 +0100 Subject: use LIBAV_LICENSE and LIBAV_VERSION instead of FFMPEG_* --- cmdutils.c | 4 ++-- configure | 2 +- libavcodec/utils.c | 2 +- libavdevice/avdevice.c | 2 +- libavfilter/avfilter.c | 2 +- libavformat/utils.c | 2 +- libavutil/utils.c | 2 +- libpostproc/postprocess.c | 2 +- libswscale/utils.c | 2 +- version.sh | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) (limited to 'libavcodec') diff --git a/cmdutils.c b/cmdutils.c index 7012d04cc5..1e7aacf00d 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -423,7 +423,7 @@ static void print_all_libs_info(FILE* outstream, int flags) void show_banner(void) { - fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmpeg developers\n", + fprintf(stderr, "%s version " LIBAV_VERSION ", Copyright (c) %d-%d the Libav developers\n", program_name, program_birth_year, this_year); fprintf(stderr, " built on %s %s with %s %s\n", __DATE__, __TIME__, CC_TYPE, CC_VERSION); @@ -433,7 +433,7 @@ void show_banner(void) } void show_version(void) { - printf("%s " FFMPEG_VERSION "\n", program_name); + printf("%s " LIBAV_VERSION "\n", program_name); print_all_libs_info(stdout, SHOW_VERSION); } diff --git a/configure b/configure index 3dba45229c..27d09f66cf 100755 --- a/configure +++ b/configure @@ -3298,7 +3298,7 @@ cat > $TMPH < /dev/null) # Update version.h only on revision changes to avoid spurious rebuilds -- cgit v1.2.3 From 381d37fda91494e312ab2938080a379c5e11998b Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 21 Apr 2010 00:09:00 +0100 Subject: dsputil: add bswap16_buf() There are several places where a buffer is byte-swapped in 16-bit units. This allows them to share code which can be optimised for various architectures. Signed-off-by: Mans Rullgard --- libavcodec/dsputil.c | 7 +++++++ libavcodec/dsputil.h | 1 + 2 files changed, 8 insertions(+) (limited to 'libavcodec') diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 1f7bd4cbc0..b293642b1d 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -222,6 +222,12 @@ static void bswap_buf(uint32_t *dst, const uint32_t *src, int w){ } } +static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len) +{ + while (len--) + *dst++ = av_bswap16(*src++); +} + static int sse4_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) { int s, i; @@ -4324,6 +4330,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->add_hfyu_left_prediction = add_hfyu_left_prediction_c; c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c; c->bswap_buf= bswap_buf; + c->bswap16_buf = bswap16_buf; #if CONFIG_PNG_DECODER c->add_png_paeth_prediction= ff_add_png_paeth_prediction; #endif diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index b4798b3de8..a37475f24b 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -369,6 +369,7 @@ typedef struct DSPContext { /* this might write to dst[w] */ void (*add_png_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp); void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w); + void (*bswap16_buf)(uint16_t *dst, const uint16_t *src, int len); void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale); void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale); -- cgit v1.2.3 From cbf5d22d24945e52b3c1e4c1a00d4d8179be930a Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Wed, 16 Mar 2011 15:28:43 -0300 Subject: Remove occurrences of my old email address Signed-off-by: Mans Rullgard --- libavcodec/mimic.c | 2 +- libavformat/msnwc_tcp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index bcf125a262..450dd65784 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2005 Ole André Vadla Ravnås - * Copyright (C) 2008 Ramiro Polla + * Copyright (C) 2008 Ramiro Polla * * This file is part of FFmpeg. * diff --git a/libavformat/msnwc_tcp.c b/libavformat/msnwc_tcp.c index 5af1c4e0ad..692dc1fdb9 100644 --- a/libavformat/msnwc_tcp.c +++ b/libavformat/msnwc_tcp.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Ramiro Polla + * Copyright (C) 2008 Ramiro Polla * * This file is part of FFmpeg. * -- cgit v1.2.3 From f578854efce12842ed4e4e25b36cf2f798054468 Mon Sep 17 00:00:00 2001 From: Young Han Lee Date: Fri, 11 Mar 2011 11:39:24 +0900 Subject: aaccoder: Change FFMAX for allzero flag to OR bit operation Signed-off-by: Ronald S. Bultje --- libavcodec/aaccoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavcodec') diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 8063fb6cd4..d2c928205f 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -723,7 +723,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, sce->zeroes[w*16+g] = !nz; if (nz) minthr = FFMIN(minthr, uplim); - allz = FFMAX(allz, nz); + allz |= nz; } } for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { -- cgit v1.2.3 From b7c96769c52a312c6f6abe43f5d8c83701118a0b Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Wed, 16 Mar 2011 23:34:12 -0400 Subject: aacenc: Refactor the parts of the AAC psymodel. 3GPP: Remove ffac from and move min_snr out of AacPsyBand. Rearrange AacPsyCoeffs to make it easier to implement energy spreading. Rename the band[] array to bands[] Copy energies and thresholds at the end of analysis. LAME: Use a loop instead of an if chain in LAME windowing. --- libavcodec/aacpsy.c | 77 +++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 40 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index a987be0abb..de3b0f329e 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -61,9 +61,7 @@ */ typedef struct AacPsyBand{ float energy; ///< band energy - float ffac; ///< form factor float thr; ///< energy threshold - float min_snr; ///< minimal SNR float thr_quiet; ///< threshold in quiet }AacPsyBand; @@ -88,17 +86,18 @@ typedef struct AacPsyChannel{ * psychoacoustic model frame type-dependent coefficients */ typedef struct AacPsyCoeffs{ - float ath [64]; ///< absolute threshold of hearing per bands - float barks [64]; ///< Bark value for each spectral band in long frame - float spread_low[64]; ///< spreading factor for low-to-high threshold spreading in long frame - float spread_hi [64]; ///< spreading factor for high-to-low threshold spreading in long frame + float ath; ///< absolute threshold of hearing per bands + float barks; ///< Bark value for each spectral band in long frame + float spread_low[2]; ///< spreading factor for low-to-high threshold spreading in long frame + float spread_hi [2]; ///< spreading factor for high-to-low threshold spreading in long frame + float min_snr; ///< minimal SNR }AacPsyCoeffs; /** * 3GPP TS26.403-inspired psychoacoustic model specific data */ typedef struct AacPsyContext{ - AacPsyCoeffs psy_coef[2]; + AacPsyCoeffs psy_coef[2][64]; AacPsyChannel *ch; }AacPsyContext; @@ -243,27 +242,30 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) { minath = ath(3410, ATH_ADD); for (j = 0; j < 2; j++) { - AacPsyCoeffs *coeffs = &pctx->psy_coef[j]; + AacPsyCoeffs *coeffs = pctx->psy_coef[j]; + const uint8_t *band_sizes = ctx->bands[j]; float line_to_frequency = ctx->avctx->sample_rate / (j ? 256.f : 2048.0f); i = 0; prev = 0.0; for (g = 0; g < ctx->num_bands[j]; g++) { - i += ctx->bands[j][g]; + i += band_sizes[g]; bark = calc_bark((i-1) * line_to_frequency); - coeffs->barks[g] = (bark + prev) / 2.0; + coeffs[g].barks = (bark + prev) / 2.0; prev = bark; } for (g = 0; g < ctx->num_bands[j] - 1; g++) { - coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW); - coeffs->spread_hi [g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_HI); + AacPsyCoeffs *coeff = &coeffs[g]; + float bark_width = coeffs[g+1].barks - coeffs->barks; + coeff->spread_low[0] = pow(10.0, -bark_width * PSY_3GPP_SPREAD_LOW); + coeff->spread_hi [0] = pow(10.0, -bark_width * PSY_3GPP_SPREAD_HI); } start = 0; for (g = 0; g < ctx->num_bands[j]; g++) { minscale = ath(start * line_to_frequency, ATH_ADD); - for (i = 1; i < ctx->bands[j][g]; i++) + for (i = 1; i < band_sizes[g]; i++) minscale = FFMIN(minscale, ath((start + i) * line_to_frequency, ATH_ADD)); - coeffs->ath[g] = minscale - minath; - start += ctx->bands[j][g]; + coeffs[g].ath = minscale - minath; + start += band_sizes[g]; } } @@ -406,24 +408,32 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, band->energy += coefs[start+i] * coefs[start+i]; band->thr = band->energy * 0.001258925f; start += band_sizes[g]; - - ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].energy = band->energy; } } //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation" for (w = 0; w < wi->num_windows*16; w += 16) { - AacPsyBand *band = &pch->band[w]; + + AacPsyBand *bands = &pch->band[w]; for (g = 1; g < num_bands; g++) - band[g].thr = FFMAX(band[g].thr, band[g-1].thr * coeffs->spread_hi [g]); + bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]); for (g = num_bands - 2; g >= 0; g--) - band[g].thr = FFMAX(band[g].thr, band[g+1].thr * coeffs->spread_low[g]); + bands[g].thr = FFMAX(bands[g].thr, bands[g+1].thr * coeffs[g].spread_low[0]); for (g = 0; g < num_bands; g++) { - band[g].thr_quiet = band[g].thr = FFMAX(band[g].thr, coeffs->ath[g]); + AacPsyBand *band = &bands[g]; + band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath); if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w))) - band[g].thr = FFMAX(PSY_3GPP_RPEMIN*band[g].thr, FFMIN(band[g].thr, - PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet)); + band->thr = FFMAX(PSY_3GPP_RPEMIN*band->thr, FFMIN(band->thr, + PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet)); + } + } - ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].threshold = band[g].thr; + for (w = 0; w < wi->num_windows*16; w += 16) { + for (g = 0; g < num_bands; g++) { + AacPsyBand *band = &pch->band[w+g]; + FFPsyBand *psy_band = &ctx->psy_bands[channel*PSY_MAX_BANDS+w+g]; + + psy_band->threshold = band->thr; + psy_band->energy = band->energy; } } memcpy(pch->prev_band, pch->band, sizeof(pch->band)); @@ -553,22 +563,9 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, if (pch->prev_attack == 3 || att_sum) { uselongblock = 0; - if (attacks[1] && attacks[0]) - attacks[1] = 0; - if (attacks[2] && attacks[1]) - attacks[2] = 0; - if (attacks[3] && attacks[2]) - attacks[3] = 0; - if (attacks[4] && attacks[3]) - attacks[4] = 0; - if (attacks[5] && attacks[4]) - attacks[5] = 0; - if (attacks[6] && attacks[5]) - attacks[6] = 0; - if (attacks[7] && attacks[6]) - attacks[7] = 0; - if (attacks[8] && attacks[7]) - attacks[8] = 0; + for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++) + if (attacks[i] && attacks[i-1]) + attacks[i] = 0; } } else { /* We have no lookahead info, so just use same type as the previous sequence. */ -- cgit v1.2.3 From 4afedfd8e5c5f102d3a67c224c33b51bbed47eee Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Wed, 16 Mar 2011 23:35:39 -0400 Subject: aacenc: cosmetics, indentation, and comment clarification Correct bad indentation in aaccoder Clarify and correct comments in 3GPP psymodel, other cosmetics. --- libavcodec/aaccoder.c | 50 +++++++++++++++++++++++++------------------------- libavcodec/aacpsy.c | 21 ++++++++++++--------- 2 files changed, 37 insertions(+), 34 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index d2c928205f..79723c61ef 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -146,34 +146,34 @@ static av_always_inline float quantize_and_encode_band_cost_template( curidx *= range; curidx += quants[j] + off; } - curbits = ff_aac_spectral_bits[cb-1][curidx]; - vec = &ff_aac_codebook_vectors[cb-1][curidx*dim]; - if (BT_UNSIGNED) { - for (k = 0; k < dim; k++) { - float t = fabsf(in[i+k]); - float di; - if (BT_ESC && vec[k] == 64.0f) { //FIXME: slow - if (t >= CLIPPED_ESCAPE) { - di = t - CLIPPED_ESCAPE; - curbits += 21; - } else { - int c = av_clip(quant(t, Q), 0, 8191); - di = t - c*cbrtf(c)*IQ; - curbits += av_log2(c)*2 - 4 + 1; - } + curbits = ff_aac_spectral_bits[cb-1][curidx]; + vec = &ff_aac_codebook_vectors[cb-1][curidx*dim]; + if (BT_UNSIGNED) { + for (k = 0; k < dim; k++) { + float t = fabsf(in[i+k]); + float di; + if (BT_ESC && vec[k] == 64.0f) { //FIXME: slow + if (t >= CLIPPED_ESCAPE) { + di = t - CLIPPED_ESCAPE; + curbits += 21; } else { - di = t - vec[k]*IQ; + int c = av_clip(quant(t, Q), 0, 8191); + di = t - c*cbrtf(c)*IQ; + curbits += av_log2(c)*2 - 4 + 1; } - if (vec[k] != 0.0f) - curbits++; - rd += di*di; - } - } else { - for (k = 0; k < dim; k++) { - float di = in[i+k] - vec[k]*IQ; - rd += di*di; + } else { + di = t - vec[k]*IQ; } + if (vec[k] != 0.0f) + curbits++; + rd += di*di; } + } else { + for (k = 0; k < dim; k++) { + float di = in[i+k] - vec[k]*IQ; + rd += di*di; + } + } cost += rd * lambda + curbits; resbits += curbits; if (cost >= uplim) @@ -575,7 +575,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, int qnrg = av_clip_uint8(log2f(sqrtf(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512); q1 = qnrg + 30; q0 = qnrg - 30; - //av_log(NULL, AV_LOG_ERROR, "q0 %d, q1 %d\n", q0, q1); + //av_log(NULL, AV_LOG_ERROR, "q0 %d, q1 %d\n", q0, q1); if (q0 < q0low) { q1 += q0low - q0; q0 = q0low; diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index de3b0f329e..d9896ed74f 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -39,8 +39,8 @@ * constants for 3GPP AAC psychoacoustic model * @{ */ -#define PSY_3GPP_SPREAD_HI 1.5f // spreading factor for ascending threshold spreading (15 dB/Bark) -#define PSY_3GPP_SPREAD_LOW 3.0f // spreading factor for descending threshold spreading (30 dB/Bark) +#define PSY_3GPP_THR_SPREAD_HI 1.5f // spreading factor for low-to-hi threshold spreading (15 dB/Bark) +#define PSY_3GPP_THR_SPREAD_LOW 3.0f // spreading factor for hi-to-low threshold spreading (30 dB/Bark) #define PSY_3GPP_RPEMIN 0.01f #define PSY_3GPP_RPELEV 2.0f @@ -256,8 +256,8 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) { for (g = 0; g < ctx->num_bands[j] - 1; g++) { AacPsyCoeffs *coeff = &coeffs[g]; float bark_width = coeffs[g+1].barks - coeffs->barks; - coeff->spread_low[0] = pow(10.0, -bark_width * PSY_3GPP_SPREAD_LOW); - coeff->spread_hi [0] = pow(10.0, -bark_width * PSY_3GPP_SPREAD_HI); + coeff->spread_low[0] = pow(10.0, -bark_width * PSY_3GPP_THR_SPREAD_LOW); + coeff->spread_hi [0] = pow(10.0, -bark_width * PSY_3GPP_THR_SPREAD_HI); } start = 0; for (g = 0; g < ctx->num_bands[j]; g++) { @@ -395,9 +395,9 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, AacPsyChannel *pch = &pctx->ch[channel]; int start = 0; int i, w, g; - const int num_bands = ctx->num_bands[wi->num_windows == 8]; - const uint8_t* band_sizes = ctx->bands[wi->num_windows == 8]; - AacPsyCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8]; + const int num_bands = ctx->num_bands[wi->num_windows == 8]; + const uint8_t *band_sizes = ctx->bands[wi->num_windows == 8]; + AacPsyCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8]; //calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation" for (w = 0; w < wi->num_windows*16; w += 16) { @@ -410,17 +410,19 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, start += band_sizes[g]; } } - //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation" + //modify thresholds and energies - spread, threshold in quiet, pre-echo control for (w = 0; w < wi->num_windows*16; w += 16) { - AacPsyBand *bands = &pch->band[w]; + //5.4.2.3 "Spreading" & 5.4.3 "Spreaded Energy Calculation" for (g = 1; g < num_bands; g++) bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]); for (g = num_bands - 2; g >= 0; g--) bands[g].thr = FFMAX(bands[g].thr, bands[g+1].thr * coeffs[g].spread_low[0]); + //5.4.2.4 "Threshold in quiet" for (g = 0; g < num_bands; g++) { AacPsyBand *band = &bands[g]; band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath); + //5.4.2.5 "Pre-echo control" if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w))) band->thr = FFMAX(PSY_3GPP_RPEMIN*band->thr, FFMIN(band->thr, PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet)); @@ -436,6 +438,7 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, psy_band->energy = band->energy; } } + memcpy(pch->prev_band, pch->band, sizeof(pch->band)); } -- cgit v1.2.3