92 const uint8_t codes_counts[16],
93 const uint8_t **syms,
int offset)
99 vlc->
table = &vlc_buf[*buf_offset];
102 for (
int i = 16;
i > 0;
i--)
103 for (
unsigned tmp = num + codes_counts[
i - 1]; num <
tmp; num++)
124 for (
int i = 0;
i < 2;
i++){
133 &q_syms, -48 - 16 *
i);
134 for (
int j = 0; j < 4; j++)
136 &q_syms, -((8 << j) - 1));
152 memset(
c->oldDSCF, 0,
sizeof(
c->oldDSCF));
158 uint8_t sample_rate_idx =
get_bits(&gb, 3);
159 static const int sample_rates[] = { 44100, 48000, 37800, 32000 };
166 if (
c->maxbands >=
BANDS) {
188 int *got_frame_ptr,
AVPacket *avpkt)
190 const uint8_t *buf = avpkt->
data;
191 int buf_size = avpkt->
size;
194 int i, j, k, ch, cnt, res, t;
197 int maxband, keyframe;
200 keyframe =
c->cur_frame == 0;
203 memset(
c->Q, 0,
sizeof(
c->Q));
204 c->last_bits_used = 0;
215 if(maxband > 32) maxband -= 33;
223 if(maxband >
c->maxbands + 1) {
227 c->last_max_band = maxband;
231 last[0] = last[1] = 0;
232 for(
i = maxband - 1;
i >= 0;
i--){
233 for(ch = 0; ch < 2; ch++){
235 if(last[ch] > 15) last[ch] -= 17;
236 bands[
i].res[ch] = last[ch];
243 for(
i = 0;
i < maxband;
i++)
248 for(
i = maxband - 1;
i >= 0;
i--)
255 for(
i = maxband;
i <
c->maxbands;
i++)
259 for(
i = 0;
i < 32;
i++)
260 c->oldDSCF[0][
i] =
c->oldDSCF[1][
i] = 1;
263 for(
i = 0;
i < maxband;
i++){
274 for(
i = 0;
i < maxband;
i++){
275 for(ch = 0; ch < 2; ch++){
276 if(!
bands[
i].res[ch])
continue;
278 if(
c->oldDSCF[ch][
i]){
280 c->oldDSCF[ch][
i] = 0;
285 bands[
i].scf_idx[ch][0] = ((
bands[
i].scf_idx[ch][2] + t - 25) & 0x7F) - 6;
287 for(j = 0; j < 2; j++){
288 if((
bands[
i].scfi[ch] << j) & 2)
294 bands[
i].scf_idx[ch][j + 1] = ((
bands[
i].scf_idx[ch][j] + t - 25) & 0x7F) - 6;
301 for(ch = 0; ch < 2; ch++){
306 c->Q[ch][off + j] = (
av_lfg_get(&
c->rnd) & 0x3FC) - 510;
333 c->Q[ch][off + j + 1] = t >> 4;
345 cnt = (cnt >> 1) +
FFABS(
c->Q[ch][off + j]);
352 c->Q[ch][off + j] <<= res - 9;
353 c->Q[ch][off + j] |=
get_bits(gb, res - 9);
355 c->Q[ch][off + j] -= (1 << (res - 2)) - 1;
366 (int16_t **)
frame->extended_data,
372 if(
c->cur_frame >=
c->frames)
376 c->last_bits_used = buf_size << 3;
378 c->last_bits_used = buf_size << 3;
383 return c->cur_frame ?
c->last_bits_used >> 3 : buf_size;
static const float bands[]
const FFCodec ff_mpc8_decoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const int sample_rates[]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
static const uint8_t bits[8]
bitstream reader API header.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
static av_cold void mpc8_init_static(void)
static av_cold int mpc8_decode_init(AVCodecContext *avctx)
static int mpc8_dec_enum(GetBitContext *gb, int k, int n)
static int mpc8_get_mask(GetBitContext *gb, int size, int t)
static av_cold void mpc8_decode_flush(AVCodecContext *avctx)
static int mpc8_get_mod_golomb(GetBitContext *gb, int m)
static av_cold void build_vlc(VLC *vlc, unsigned *buf_offset, const uint8_t codes_counts[16], const uint8_t **syms, int offset)
static int mpc8_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static int mpc8_dec_base(GetBitContext *gb, int k, int n)
void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, int16_t **out, int channels)
static int ff_thread_once(char *control, void(*routine)(void))
static const uint16_t mask[17]
static av_const int sign_extend(int val, unsigned bits)
static VLCElem scfi_vlc[1<< MPC7_SCFI_BITS]
static const VLCElem * quant_vlc[MPC7_QUANT_VLC_TABLES][2]
static VLCElem dscf_vlc[1<< MPC7_DSCF_BITS]
static const uint32_t mpc8_cnk_lost[16][33]
static const uint32_t mpc8_cnk[16][32]
static const int8_t mpc8_idx51[125]
static const int8_t mpc8_huffq2[5 *5 *5]
static const unsigned int mpc8_thres[]
static const uint8_t mpc8_cnk_len[16][33]
static const int8_t mpc8_idx50[125]
static const int8_t mpc8_idx52[125]
static const uint8_t mpc8_q5_8_len_counts[2][4][16]
static const uint8_t mpc8_dscf_syms[]
static const uint8_t mpc8_res_syms[]
static const uint8_t mpc8_res_len_counts[2][16]
static const uint8_t mpc8_scfi_syms[]
static const uint8_t mpc8_bands_syms[MPC8_BANDS_SIZE]
static const uint8_t mpc8_q2_len_counts[2][16]
static const uint8_t mpc8_q1_len_counts[16]
static const uint8_t mpc8_q_syms[]
#define MPC8_MAX_VLC_SIZE
static const uint8_t mpc8_q34_len_counts[2][16]
static const uint8_t mpc8_dscf_len_counts[2][16]
static const uint8_t mpc8_bands_len_counts[16]
static const uint8_t mpc8_q9up_len_counts[16]
static const uint8_t mpc8_scfi_len_counts[2][16]
Musepack decoder MPEG Audio Layer 1/2 -like codec with frames of 1152 samples divided into 32 subband...
av_cold void ff_mpadsp_init(MPADSPContext *s)
void ff_mpa_synth_init_fixed(void)
static const uint16_t table[]
#define FF_ARRAY_ELEMS(a)
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int sample_rate
samples per second
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
Subband structure - hold all variables for each subband.
#define avpriv_request_sample(...)
int ff_vlc_init_from_lengths(VLC *vlc, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
#define VLC_INIT_STATIC_OVERLONG