annotate aacps.h @ 12408:ae72506d4c2a libavcodec

acenc: LAME-inspired window decision This performs quite a bit better than the current 3GPP-inspired window decision on all the samples I have tested. On the castanets.wav sample it performs very similar to iTunes window selection, and seems to perform better than Nero. On fatboy.wav, it seems to perform at least as good as iTunes, if not better. Nero performs horribly on this sample. Patch by: Nathan Caldwell <saintdev@gmail.com>
author alexc
date Mon, 23 Aug 2010 20:00:03 +0000
parents 2db24012361b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11922
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
1 /*
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
2 * MPEG-4 Parametric Stereo definitions and declarations
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
3 * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
4 *
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
5 * This file is part of FFmpeg.
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
6 *
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
11 *
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
15 * Lesser General Public License for more details.
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
16 *
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
20 */
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
21
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
22 #ifndef AVCODEC_PS_H
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
23 #define AVCODEC_PS_H
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
24
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
25 #include <stdint.h>
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
26
11929
2db24012361b Add required #includes to pass 'make checkheaders'.
diego
parents: 11922
diff changeset
27 #include "avcodec.h"
2db24012361b Add required #includes to pass 'make checkheaders'.
diego
parents: 11922
diff changeset
28 #include "get_bits.h"
2db24012361b Add required #includes to pass 'make checkheaders'.
diego
parents: 11922
diff changeset
29
11922
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
30 #define PS_MAX_NUM_ENV 5
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
31 #define PS_MAX_NR_IIDICC 34
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
32 #define PS_MAX_NR_IPDOPD 17
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
33 #define PS_MAX_SSB 91
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
34 #define PS_MAX_AP_BANDS 50
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
35 #define PS_QMF_TIME_SLOTS 32
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
36 #define PS_MAX_DELAY 14
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
37 #define PS_AP_LINKS 3
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
38 #define PS_MAX_AP_DELAY 5
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
39
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
40 typedef struct {
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
41 int start;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
42 int enable_iid;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
43 int iid_quant;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
44 int nr_iid_par;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
45 int nr_ipdopd_par;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
46 int enable_icc;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
47 int icc_mode;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
48 int nr_icc_par;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
49 int enable_ext;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
50 int frame_class;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
51 int num_env_old;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
52 int num_env;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
53 int enable_ipdopd;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
54 int border_position[PS_MAX_NUM_ENV+1];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
55 int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; //<Inter-channel Intensity Difference Parameters
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
56 int8_t icc_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; //<Inter-Channel Coherence Parameters
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
57 /* ipd/opd is iid/icc sized so that the same functions can handle both */
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
58 int8_t ipd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; //<Inter-channel Phase Difference Parameters
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
59 int8_t opd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; //<Overall Phase Difference Parameters
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
60 int is34bands;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
61 int is34bands_old;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
62
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
63 float in_buf[5][44][2];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
64 float delay[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
65 float ap_delay[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
66 float peak_decay_nrg[34];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
67 float power_smooth[34];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
68 float peak_decay_diff_smooth[34];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
69 float H11[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
70 float H12[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
71 float H21[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
72 float H22[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
73 int8_t opd_hist[PS_MAX_NR_IIDICC];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
74 int8_t ipd_hist[PS_MAX_NR_IIDICC];
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
75 } PSContext;
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
76
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
77 void ff_ps_init(void);
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
78 void ff_ps_ctx_init(PSContext *ps);
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
79 int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left);
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
80 int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top);
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
81
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents:
diff changeset
82 #endif /* AVCODEC_PS_H */