1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * MPEG-4 Parametric Stereo definitions and declarations
3cabdff1aSopenharmony_ci * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
4cabdff1aSopenharmony_ci *
5cabdff1aSopenharmony_ci * This file is part of FFmpeg.
6cabdff1aSopenharmony_ci *
7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
11cabdff1aSopenharmony_ci *
12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15cabdff1aSopenharmony_ci * Lesser General Public License for more details.
16cabdff1aSopenharmony_ci *
17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20cabdff1aSopenharmony_ci */
21cabdff1aSopenharmony_ci
22cabdff1aSopenharmony_ci#ifndef AVCODEC_AACPS_H
23cabdff1aSopenharmony_ci#define AVCODEC_AACPS_H
24cabdff1aSopenharmony_ci
25cabdff1aSopenharmony_ci#include <stdint.h>
26cabdff1aSopenharmony_ci
27cabdff1aSopenharmony_ci#include "libavutil/mem_internal.h"
28cabdff1aSopenharmony_ci
29cabdff1aSopenharmony_ci#include "aacpsdsp.h"
30cabdff1aSopenharmony_ci#include "avcodec.h"
31cabdff1aSopenharmony_ci#include "get_bits.h"
32cabdff1aSopenharmony_ci
33cabdff1aSopenharmony_ci#define PS_MAX_NUM_ENV 5
34cabdff1aSopenharmony_ci#define PS_MAX_NR_IIDICC 34
35cabdff1aSopenharmony_ci#define PS_MAX_NR_IPDOPD 17
36cabdff1aSopenharmony_ci#define PS_MAX_SSB 91
37cabdff1aSopenharmony_ci#define PS_MAX_AP_BANDS 50
38cabdff1aSopenharmony_ci#define PS_QMF_TIME_SLOTS 32
39cabdff1aSopenharmony_ci#define PS_MAX_DELAY 14
40cabdff1aSopenharmony_ci#define PS_AP_LINKS 3
41cabdff1aSopenharmony_ci#define PS_MAX_AP_DELAY 5
42cabdff1aSopenharmony_ci#define PS_BASELINE 0  ///< Operate in Baseline PS mode
43cabdff1aSopenharmony_ci                       ///< Baseline implies 10 or 20 stereo bands,
44cabdff1aSopenharmony_ci                       ///< mixing mode A, and no ipd/opd
45cabdff1aSopenharmony_ci
46cabdff1aSopenharmony_ci#define numQMFSlots 32 //numTimeSlots * RATE
47cabdff1aSopenharmony_ci
48cabdff1aSopenharmony_citypedef struct PSCommonContext {
49cabdff1aSopenharmony_ci    int    start;
50cabdff1aSopenharmony_ci    int    enable_iid;
51cabdff1aSopenharmony_ci    int    iid_quant;
52cabdff1aSopenharmony_ci    int    nr_iid_par;
53cabdff1aSopenharmony_ci    int    nr_ipdopd_par;
54cabdff1aSopenharmony_ci    int    enable_icc;
55cabdff1aSopenharmony_ci    int    icc_mode;
56cabdff1aSopenharmony_ci    int    nr_icc_par;
57cabdff1aSopenharmony_ci    int    enable_ext;
58cabdff1aSopenharmony_ci    int    frame_class;
59cabdff1aSopenharmony_ci    int    num_env_old;
60cabdff1aSopenharmony_ci    int    num_env;
61cabdff1aSopenharmony_ci    int    enable_ipdopd;
62cabdff1aSopenharmony_ci    int    border_position[PS_MAX_NUM_ENV+1];
63cabdff1aSopenharmony_ci    int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Inter-channel Intensity Difference Parameters
64cabdff1aSopenharmony_ci    int8_t icc_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Inter-Channel Coherence Parameters
65cabdff1aSopenharmony_ci    /* ipd/opd is iid/icc sized so that the same functions can handle both */
66cabdff1aSopenharmony_ci    int8_t ipd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Inter-channel Phase Difference Parameters
67cabdff1aSopenharmony_ci    int8_t opd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Overall Phase Difference Parameters
68cabdff1aSopenharmony_ci    int    is34bands;
69cabdff1aSopenharmony_ci    int    is34bands_old;
70cabdff1aSopenharmony_ci} PSCommonContext;
71cabdff1aSopenharmony_ci
72cabdff1aSopenharmony_citypedef struct PSContext {
73cabdff1aSopenharmony_ci    PSCommonContext common;
74cabdff1aSopenharmony_ci
75cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, in_buf)[5][44][2];
76cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2];
77cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2];
78cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, peak_decay_nrg)[34];
79cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, power_smooth)[34];
80cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, peak_decay_diff_smooth)[34];
81cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
82cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
83cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
84cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
85cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, Lbuf)[91][32][2];
86cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, INTFLOAT, Rbuf)[91][32][2];
87cabdff1aSopenharmony_ci    int8_t opd_hist[PS_MAX_NR_IIDICC];
88cabdff1aSopenharmony_ci    int8_t ipd_hist[PS_MAX_NR_IIDICC];
89cabdff1aSopenharmony_ci    PSDSPContext dsp;
90cabdff1aSopenharmony_ci} PSContext;
91cabdff1aSopenharmony_ci
92cabdff1aSopenharmony_ciextern const int8_t ff_k_to_i_20[];
93cabdff1aSopenharmony_ciextern const int8_t ff_k_to_i_34[];
94cabdff1aSopenharmony_ci
95cabdff1aSopenharmony_civoid ff_ps_init_common(void);
96cabdff1aSopenharmony_civoid AAC_RENAME(ff_ps_init)(void);
97cabdff1aSopenharmony_civoid AAC_RENAME(ff_ps_ctx_init)(PSContext *ps);
98cabdff1aSopenharmony_ciint ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb,
99cabdff1aSopenharmony_ci                     PSCommonContext *ps, int bits_left);
100cabdff1aSopenharmony_ciint AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top);
101cabdff1aSopenharmony_ci
102cabdff1aSopenharmony_ci#endif /* AVCODEC_AACPS_H */
103