From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 4/4] avcodec/internal: Move ff_exp2fi() to aacsbr.c Date: Sat, 17 Feb 2024 21:05:03 +0100 Message-ID: <GV1SPRMB00639BEAABCD57EFA59A147F8F532@GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <GV1SPRMB006386A16563C97BA4D00D8E8F532@GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM> Only used there. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/aacsbr.c | 39 +++++++++++++++++++++++++++++---------- libavcodec/internal.h | 22 ---------------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 683c079b91..da9e160a57 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -31,10 +31,10 @@ #include "sbr.h" #include "aacsbr.h" #include "aacsbrdata.h" -#include "internal.h" #include "aacps.h" #include "sbrdsp.h" #include "libavutil/internal.h" +#include "libavutil/intfloat.h" #include "libavutil/libm.h" #include "libavutil/avassert.h" #include "libavutil/mem_internal.h" @@ -47,6 +47,25 @@ #include "mips/aacsbr_mips.h" #endif /* ARCH_MIPS */ +/** + * 2^(x) for integer x + * @return correctly rounded float + */ +static av_always_inline float exp2fi(int x) { + /* Normal range */ + if (-126 <= x && x <= 128) + return av_int2float((x+127) << 23); + /* Too large */ + else if (x > 128) + return INFINITY; + /* Subnormal numbers */ + else if (x > -150) + return av_int2float(1 << (x+149)); + /* Negligibly small */ + else + return 0; +} + static void aacsbr_func_ptr_init(AACSBRContext *c); static void make_bands(int16_t* bands, int start, int stop, int num_bands) @@ -79,13 +98,13 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) { float temp1, temp2, fac; if (sbr->data[0].bs_amp_res) { - temp1 = ff_exp2fi(sbr->data[0].env_facs_q[e][k] + 7); - temp2 = ff_exp2fi(pan_offset - sbr->data[1].env_facs_q[e][k]); + temp1 = exp2fi(sbr->data[0].env_facs_q[e][k] + 7); + temp2 = exp2fi(pan_offset - sbr->data[1].env_facs_q[e][k]); } else { - temp1 = ff_exp2fi((sbr->data[0].env_facs_q[e][k]>>1) + 7) * + temp1 = exp2fi((sbr->data[0].env_facs_q[e][k]>>1) + 7) * exp2_tab[sbr->data[0].env_facs_q[e][k] & 1]; - temp2 = ff_exp2fi((pan_offset - sbr->data[1].env_facs_q[e][k])>>1) * + temp2 = exp2fi((pan_offset - sbr->data[1].env_facs_q[e][k])>>1) * exp2_tab[(pan_offset - sbr->data[1].env_facs_q[e][k]) & 1]; } if (temp1 > 1E20) { @@ -99,8 +118,8 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) } for (e = 1; e <= sbr->data[0].bs_num_noise; e++) { for (k = 0; k < sbr->n_q; k++) { - float temp1 = ff_exp2fi(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs_q[e][k] + 1); - float temp2 = ff_exp2fi(12 - sbr->data[1].noise_facs_q[e][k]); + float temp1 = exp2fi(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs_q[e][k] + 1); + float temp2 = exp2fi(12 - sbr->data[1].noise_facs_q[e][k]); float fac; av_assert0(temp1 <= 1E20); fac = temp1 / (1.0f + temp2); @@ -113,9 +132,9 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (e = 1; e <= sbr->data[ch].bs_num_env; e++) for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++){ if (sbr->data[ch].bs_amp_res) - sbr->data[ch].env_facs[e][k] = ff_exp2fi(sbr->data[ch].env_facs_q[e][k] + 6); + sbr->data[ch].env_facs[e][k] = exp2fi(sbr->data[ch].env_facs_q[e][k] + 6); else - sbr->data[ch].env_facs[e][k] = ff_exp2fi((sbr->data[ch].env_facs_q[e][k]>>1) + 6) + sbr->data[ch].env_facs[e][k] = exp2fi((sbr->data[ch].env_facs_q[e][k]>>1) + 6) * exp2_tab[sbr->data[ch].env_facs_q[e][k] & 1]; if (sbr->data[ch].env_facs[e][k] > 1E20) { av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n"); @@ -126,7 +145,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (e = 1; e <= sbr->data[ch].bs_num_noise; e++) for (k = 0; k < sbr->n_q; k++) sbr->data[ch].noise_facs[e][k] = - ff_exp2fi(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs_q[e][k]); + exp2fi(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs_q[e][k]); } } } diff --git a/libavcodec/internal.h b/libavcodec/internal.h index eb9e0d707c..04f7cebdcb 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -26,10 +26,7 @@ #include <stdint.h> -#include "libavutil/buffer.h" #include "libavutil/channel_layout.h" -#include "libavutil/mathematics.h" -#include "libavutil/pixfmt.h" #include "avcodec.h" #include "config.h" @@ -157,25 +154,6 @@ int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b); unsigned int ff_toupper4(unsigned int x); -/** - * 2^(x) for integer x - * @return correctly rounded float - */ -static av_always_inline float ff_exp2fi(int x) { - /* Normal range */ - if (-126 <= x && x <= 128) - return av_int2float((x+127) << 23); - /* Too large */ - else if (x > 128) - return INFINITY; - /* Subnormal numbers */ - else if (x > -150) - return av_int2float(1 << (x+149)); - /* Negligibly small */ - else - return 0; -} - int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx); int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec); -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-02-17 20:03 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-17 19:54 [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt 2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 2/4] avcodec/jpeg2000dec: Avoid using GetByteContext.buffer directly Andreas Rheinhardt 2024-02-19 14:00 ` Tomas Härdin 2024-02-17 20:05 ` [FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000: Simplify exp2fi for numbers used here Andreas Rheinhardt 2024-02-19 14:09 ` Tomas Härdin 2024-02-19 14:14 ` Andreas Rheinhardt 2024-02-19 14:51 ` Tomas Härdin 2024-02-17 20:05 ` Andreas Rheinhardt [this message] 2024-02-19 11:30 ` [FFmpeg-devel] [PATCH 1/4] avcodec/jpeg2000dec, j2kenc: Constify where appropriate Andreas Rheinhardt 2024-02-19 13:58 ` Tomas Härdin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=GV1SPRMB00639BEAABCD57EFA59A147F8F532@GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git