FFmpeg
Loading...
Searching...
No Matches
aacencdsp.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include <float.h>
20#include <math.h>
21
22#include "config.h"
23
24#include "libavutil/macros.h"
25#include "aacencdsp.h"
26
27static void abs_pow34_v(float *out, const float *in, const int size)
28{
29 for (int i = 0; i < size; i++) {
30 float a = fabsf(in[i]);
31 out[i] = sqrtf(a * sqrtf(a));
32 }
33}
34
35static void quantize_bands(int *out, const float *in, const float *scaled,
36 int size, int is_signed, int maxval, const float Q34,
37 const float rounding)
38{
39 for (int i = 0; i < size; i++) {
40 float qc = scaled[i] * Q34;
41 int tmp = (int)FFMIN((float)(qc + rounding), (float)maxval);
42 if (is_signed && in[i] < 0.0f) {
43 tmp = -tmp;
44 }
45 out[i] = tmp;
46 }
47}
48
49/* One NMR scalefactor-trellis Viterbi step, for each current-band candidate, find the
50 * previous-band candidate minimising dpp[op] + lamsf[d] then set
51 * dp[o] = node[o] + that cost and record the back-pointer bp[o] */
52static void nmr_trellis_step_c(float *dp, uint8_t *bp, const float *dpp,
53 const float *node, const float *lamsf,
54 int n_cur, int n_prev, int base, int step, int mdiff)
55{
56 for (int o = 0; o < n_cur; o++) {
57 int best = -1;
58 float bestc = FLT_MAX;
59 for (int op = 0; op < n_prev; op++) {
60 int d = base + (o - op) * step;
61 float c;
62 if (d < -mdiff || d > mdiff)
63 continue;
64 c = dpp[op] + lamsf[d + mdiff];
65 if (c < bestc) {
66 bestc = c;
67 best = op;
68 }
69 }
70 bp[o] = best < 0 ? 0 : best;
71 dp[o] = best < 0 ? FLT_MAX : node[o] + bestc;
72 }
73}
74
76{
77 s->abs_pow34 = abs_pow34_v;
78 s->quant_bands = quantize_bands;
79 s->nmr_trellis_step = nmr_trellis_step_c;
80
81#if ARCH_RISCV
83#elif ARCH_X86 && HAVE_X86ASM
85#elif ARCH_AARCH64
87#endif
88}
void ff_aacenc_dsp_init_aarch64(AACEncDSPContext *s)
void ff_aacenc_dsp_init_riscv(AACEncDSPContext *s)
void ff_aacenc_dsp_init_x86(AACEncDSPContext *s)
static FILE * out
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
static __device__ float sqrtf(float a)
static __device__ float fabsf(float a)
int a
static void nmr_trellis_step_c(float *dp, uint8_t *bp, const float *dpp, const float *node, const float *lamsf, int n_cur, int n_prev, int base, int step, int mdiff)
Definition aacencdsp.c:52
static void quantize_bands(int *out, const float *in, const float *scaled, int size, int is_signed, int maxval, const float Q34, const float rounding)
Definition aacencdsp.c:35
void ff_aacenc_dsp_init(AACEncDSPContext *s)
Definition aacencdsp.c:75
static void abs_pow34_v(float *out, const float *in, const int size)
Definition aacencdsp.c:27
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
Definition anm.c:76
Utility Preprocessor macros.
#define FFMIN(a, b)
Definition macros.h:49
static uint8_t tmp[40]
Definition aes_ctr.c:52
int size
uint8_t base
Definition vp3data.h:128
static double c[64]