mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-01 12:07:31 +01:00
The ffmpeg submodule held prebuilt libraries for every platform next to the sources (about 1.5 GB checked out), and nothing uses those any more. Only the needed sources are copied in, from the submodule's commit, along with every header and template they include. The path is new, so checking out commits on either side of this works. It's also cut down to what PPSSPP uses: the H.264, AAC, MP3, ATRAC3 and ATRAC3+ decoders, the H.264 parser, the demuxers as before, and the FFV1 encoder, AVI muxer and file protocol for AVI dumping. config.h takes its CONFIG_ values from FFmpeg 3.0.2's own configure run with just those enabled. The raw H.264 demuxer stays even though nothing opens raw H.264: probing PSMF data uses it to identify the video stream's codec, which otherwise comes out as none. On top of that: - The files nothing links (configure would build them, but they're never pulled out of the static library, going by the GCC link map) are left out: mostly libavutil's crypto and hashing and the alternative DCT/IDCT/FFT versions. - libswresample isn't built, now that nothing uses it. - The H.264 decoder only does 8-bit video, which is all the PSP has. The SPS parser rejects any other bit depth, and the DSP files no longer build their 9- to 16-bit variants, which the linker kept because the init functions pick one by bit depth at run time. That's 160 files to compile instead of 277, and 391 of FFmpeg's vendored, about 5.8 MB. The README in ext/ffmpeg has what was done, the PPSSPP patches in the copy, how to add a component, and the tradeoffs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
218 lines
7.5 KiB
C
218 lines
7.5 KiB
C
/*
|
|
* Spectral Band Replication definitions and structures
|
|
* Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
|
|
* Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
|
|
*
|
|
* This file is part of FFmpeg.
|
|
*
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* Spectral Band Replication definitions and structures
|
|
* @author Robert Swain ( rob opendot cl )
|
|
*/
|
|
|
|
#ifndef AVCODEC_SBR_H
|
|
#define AVCODEC_SBR_H
|
|
|
|
#include <stdint.h>
|
|
#include "fft.h"
|
|
#include "aacps.h"
|
|
#include "sbrdsp.h"
|
|
|
|
typedef struct AACContext AACContext;
|
|
|
|
/**
|
|
* Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header.
|
|
*/
|
|
typedef struct SpectrumParameters {
|
|
uint8_t bs_start_freq;
|
|
uint8_t bs_stop_freq;
|
|
uint8_t bs_xover_band;
|
|
|
|
/**
|
|
* @name Variables associated with bs_header_extra_1
|
|
* @{
|
|
*/
|
|
uint8_t bs_freq_scale;
|
|
uint8_t bs_alter_scale;
|
|
uint8_t bs_noise_bands;
|
|
/** @} */
|
|
} SpectrumParameters;
|
|
|
|
#define SBR_SYNTHESIS_BUF_SIZE ((1280-128)*2)
|
|
|
|
/**
|
|
* Spectral Band Replication per channel data
|
|
*/
|
|
typedef struct SBRData {
|
|
/**
|
|
* @name Main bitstream data variables
|
|
* @{
|
|
*/
|
|
unsigned bs_frame_class;
|
|
unsigned bs_add_harmonic_flag;
|
|
AAC_SIGNE bs_num_env;
|
|
uint8_t bs_freq_res[7];
|
|
AAC_SIGNE bs_num_noise;
|
|
uint8_t bs_df_env[5];
|
|
uint8_t bs_df_noise[2];
|
|
uint8_t bs_invf_mode[2][5];
|
|
uint8_t bs_add_harmonic[48];
|
|
unsigned bs_amp_res;
|
|
/** @} */
|
|
|
|
/**
|
|
* @name State variables
|
|
* @{
|
|
*/
|
|
DECLARE_ALIGNED(32, INTFLOAT, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE];
|
|
DECLARE_ALIGNED(32, INTFLOAT, analysis_filterbank_samples) [1312];
|
|
int synthesis_filterbank_samples_offset;
|
|
///l_APrev and l_A
|
|
int e_a[2];
|
|
///Chirp factors
|
|
INTFLOAT bw_array[5];
|
|
///QMF values of the original signal
|
|
INTFLOAT W[2][32][32][2];
|
|
///QMF output of the HF adjustor
|
|
int Ypos;
|
|
DECLARE_ALIGNED(16, INTFLOAT, Y)[2][38][64][2];
|
|
DECLARE_ALIGNED(16, AAC_FLOAT, g_temp)[42][48];
|
|
AAC_FLOAT q_temp[42][48];
|
|
uint8_t s_indexmapped[8][48];
|
|
///Envelope scalefactors
|
|
uint8_t env_facs_q[6][48];
|
|
AAC_FLOAT env_facs[6][48];
|
|
///Noise scalefactors
|
|
uint8_t noise_facs_q[3][5];
|
|
AAC_FLOAT noise_facs[3][5];
|
|
///Envelope time borders
|
|
uint8_t t_env[8];
|
|
///Envelope time border of the last envelope of the previous frame
|
|
uint8_t t_env_num_env_old;
|
|
///Noise time borders
|
|
uint8_t t_q[3];
|
|
unsigned f_indexnoise;
|
|
unsigned f_indexsine;
|
|
/** @} */
|
|
} SBRData;
|
|
|
|
typedef struct SpectralBandReplication SpectralBandReplication;
|
|
|
|
/**
|
|
* aacsbr functions pointers
|
|
*/
|
|
typedef struct AACSBRContext {
|
|
int (*sbr_lf_gen)(AACContext *ac, SpectralBandReplication *sbr,
|
|
INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2],
|
|
int buf_idx);
|
|
void (*sbr_hf_assemble)(INTFLOAT Y1[38][64][2],
|
|
const INTFLOAT X_high[64][40][2],
|
|
SpectralBandReplication *sbr, SBRData *ch_data,
|
|
const int e_a[2]);
|
|
int (*sbr_x_gen)(SpectralBandReplication *sbr, INTFLOAT X[2][38][64],
|
|
const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2],
|
|
const INTFLOAT X_low[32][40][2], int ch);
|
|
void (*sbr_hf_inverse_filter)(SBRDSPContext *dsp,
|
|
INTFLOAT (*alpha0)[2], INTFLOAT (*alpha1)[2],
|
|
const INTFLOAT X_low[32][40][2], int k0);
|
|
} AACSBRContext;
|
|
|
|
/**
|
|
* Spectral Band Replication
|
|
*/
|
|
struct SpectralBandReplication {
|
|
int sample_rate;
|
|
int start;
|
|
int ready_for_dequant;
|
|
int id_aac;
|
|
int reset;
|
|
SpectrumParameters spectrum_params;
|
|
int bs_amp_res_header;
|
|
/**
|
|
* @name Variables associated with bs_header_extra_2
|
|
* @{
|
|
*/
|
|
unsigned bs_limiter_bands;
|
|
unsigned bs_limiter_gains;
|
|
unsigned bs_interpol_freq;
|
|
unsigned bs_smoothing_mode;
|
|
/** @} */
|
|
unsigned bs_coupling;
|
|
AAC_SIGNE k[5]; ///< k0, k1, k2
|
|
///kx', and kx respectively, kx is the first QMF subband where SBR is used.
|
|
///kx' is its value from the previous frame
|
|
AAC_SIGNE kx[2];
|
|
///M' and M respectively, M is the number of QMF subbands that use SBR.
|
|
AAC_SIGNE m[2];
|
|
unsigned kx_and_m_pushed;
|
|
///The number of frequency bands in f_master
|
|
AAC_SIGNE n_master;
|
|
SBRData data[2];
|
|
PSContext ps;
|
|
///N_Low and N_High respectively, the number of frequency bands for low and high resolution
|
|
AAC_SIGNE n[2];
|
|
///Number of noise floor bands
|
|
AAC_SIGNE n_q;
|
|
///Number of limiter bands
|
|
AAC_SIGNE n_lim;
|
|
///The master QMF frequency grouping
|
|
uint16_t f_master[49];
|
|
///Frequency borders for low resolution SBR
|
|
uint16_t f_tablelow[25];
|
|
///Frequency borders for high resolution SBR
|
|
uint16_t f_tablehigh[49];
|
|
///Frequency borders for noise floors
|
|
uint16_t f_tablenoise[6];
|
|
///Frequency borders for the limiter
|
|
uint16_t f_tablelim[30];
|
|
AAC_SIGNE num_patches;
|
|
uint8_t patch_num_subbands[6];
|
|
uint8_t patch_start_subband[6];
|
|
///QMF low frequency input to the HF generator
|
|
DECLARE_ALIGNED(16, INTFLOAT, X_low)[32][40][2];
|
|
///QMF output of the HF generator
|
|
DECLARE_ALIGNED(16, INTFLOAT, X_high)[64][40][2];
|
|
///QMF values of the reconstructed signal
|
|
DECLARE_ALIGNED(16, INTFLOAT, X)[2][2][38][64];
|
|
///Zeroth coefficient used to filter the subband signals
|
|
DECLARE_ALIGNED(16, INTFLOAT, alpha0)[64][2];
|
|
///First coefficient used to filter the subband signals
|
|
DECLARE_ALIGNED(16, INTFLOAT, alpha1)[64][2];
|
|
///Dequantized envelope scalefactors, remapped
|
|
AAC_FLOAT e_origmapped[7][48];
|
|
///Dequantized noise scalefactors, remapped
|
|
AAC_FLOAT q_mapped[7][48];
|
|
///Sinusoidal presence, remapped
|
|
uint8_t s_mapped[7][48];
|
|
///Estimated envelope
|
|
AAC_FLOAT e_curr[7][48];
|
|
///Amplitude adjusted noise scalefactors
|
|
AAC_FLOAT q_m[7][48];
|
|
///Sinusoidal levels
|
|
AAC_FLOAT s_m[7][48];
|
|
AAC_FLOAT gain[7][48];
|
|
DECLARE_ALIGNED(32, INTFLOAT, qmf_filter_scratch)[5][64];
|
|
FFTContext mdct_ana;
|
|
FFTContext mdct;
|
|
SBRDSPContext dsp;
|
|
AACSBRContext c;
|
|
};
|
|
|
|
#endif /* AVCODEC_SBR_H */
|