Go to the documentation of this file.
63 #define MONO 0x1000001
64 #define STEREO 0x1000002
65 #define JOINT_STEREO 0x1000003
66 #define MC_COOK 0x2000000
68 #define SUBBAND_SIZE 20
69 #define MAX_SUBPACKETS 5
71 #define QUANT_VLC_BITS 9
72 #define COUPLING_VLC_BITS 6
114 int *subband_coef_index,
int *subband_coef_sign,
121 float *decode_buffer,
122 float *mlt_buffer1,
float *mlt_buffer2);
125 cook_gains *gains_ptr,
float *previous_buffer);
128 int gain_index,
int gain_index_next);
177 static const float exp2_tab[2] = {1,
M_SQRT2};
178 float exp2_val =
powf(2, -63);
179 float root_val =
powf(2, -32);
180 for (
i = -63;
i < 64;
i++) {
193 q->gain_size_factor = q->samples_per_channel / 8;
194 for (
i = 0;
i < 31;
i++)
196 (1.0 / (
double) q->gain_size_factor));
200 const void *syms,
int symbol_size,
int offset,
206 for (
int i = 0;
i < 16;
i++)
207 for (
unsigned count = num + counts[
i]; num < count; num++)
211 syms, symbol_size, symbol_size,
220 for (
i = 0;
i < 13;
i++) {
226 for (
i = 0;
i < 7;
i++) {
227 int sym_size = 1 + (
i == 3);
233 for (
i = 0;
i < q->num_subpackets;
i++) {
234 if (q->subpacket[
i].joint_stereo == 1) {
250 int mlt_size = q->samples_per_channel;
252 if (!(q->mlt_window =
av_malloc_array(mlt_size,
sizeof(*q->mlt_window))))
257 for (j = 0; j < mlt_size; j++)
258 q->mlt_window[j] *= sqrt(2.0 / q->samples_per_channel);
273 for (
i = 0;
i < 5;
i++)
279 #define DECODE_BYTES_PAD1(bytes) (3 - ((bytes) + 3) % 4)
280 #define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes)))
304 static const uint32_t
tab[4] = {
311 uint32_t *obuf = (uint32_t *)
out;
318 off = (intptr_t) inbuffer & 3;
319 buf = (
const uint32_t *) (inbuffer - off);
322 for (
i = 0;
i < bytes / 4;
i++)
323 obuf[
i] =
c ^ buf[
i];
342 for (
i = 0;
i < 13;
i++)
344 for (
i = 0;
i < 7;
i++)
346 for (
i = 0;
i < q->num_subpackets;
i++)
372 gaininfo[
i++] = gain;
385 int *quant_index_table)
389 quant_index_table[0] =
get_bits(&q->gb, 6) - 6;
403 j =
get_vlc2(&q->gb, q->envelope_quant_index[vlc_index - 1].table,
405 quant_index_table[
i] = quant_index_table[
i - 1] + j;
406 if (quant_index_table[
i] > 63 || quant_index_table[
i] < -63) {
408 "Invalid quantizer %d at position %d, outside [-63, 63] range\n",
409 quant_index_table[
i],
i);
428 int exp_idx, bias, tmpbias1, tmpbias2, bits_left, num_bits,
index, v,
i, j;
429 int exp_index2[102] = { 0 };
430 int exp_index1[102] = { 0 };
432 int tmp_categorize_array[128 * 2] = { 0 };
438 if (bits_left > q->samples_per_channel)
439 bits_left = q->samples_per_channel +
440 ((bits_left - q->samples_per_channel) * 5) / 8;
445 for (
i = 32;
i > 0;
i =
i / 2) {
453 if (num_bits >= bits_left - 32)
462 exp_index1[
i] = exp_idx;
463 exp_index2[
i] = exp_idx;
465 tmpbias1 = tmpbias2 = num_bits;
468 if (tmpbias1 + tmpbias2 > 2 * bits_left) {
472 if (exp_index1[
i] < 7) {
473 v = (-2 * exp_index1[
i]) - quant_index_table[
i] + bias;
482 tmp_categorize_array[tmp_categorize_array1_idx++] =
index;
490 if (exp_index2[
i] > 0) {
491 v = (-2 * exp_index2[
i]) - quant_index_table[
i] + bias;
500 tmp_categorize_array[--tmp_categorize_array2_idx] =
index;
511 category_index[
i] = tmp_categorize_array[tmp_categorize_array2_idx++];
526 for (
i = 0;
i < q->num_vectors;
i++)
528 int idx = category_index[
i];
545 int *subband_coef_index,
int *subband_coef_sign,
552 if (subband_coef_index[
i]) {
554 if (subband_coef_sign[
i])
559 if (
av_lfg_get(&q->random_state) < 0x80000000)
574 int *subband_coef_index,
int *subband_coef_sign)
587 for (j = vd - 1; j >= 0; j--) {
592 for (j = 0; j < vd; j++) {
593 if (subband_coef_index[
i * vd + j]) {
595 subband_coef_sign[
i * vd + j] =
get_bits1(&q->gb);
598 subband_coef_sign[
i * vd + j] = 0;
601 subband_coef_sign[
i * vd + j] = 0;
618 int *quant_index_table,
float *mlt_buffer)
639 memset(subband_coef_index, 0,
sizeof(subband_coef_index));
640 memset(subband_coef_sign, 0,
sizeof(subband_coef_sign));
642 q->scalar_dequant(q,
index, quant_index_table[band],
643 subband_coef_index, subband_coef_sign,
655 int category_index[128] = { 0 };
657 int quant_index_table[102];
684 int gain_index,
int gain_index_next)
688 fc1 =
pow2tab[gain_index + 63];
690 if (gain_index == gain_index_next) {
691 for (
i = 0;
i < q->gain_size_factor;
i++)
694 fc2 = q->gain_table[15 + (gain_index_next - gain_index)];
695 for (
i = 0;
i < q->gain_size_factor;
i++) {
711 cook_gains *gains_ptr,
float *previous_buffer)
722 for (
i = 0;
i < q->samples_per_channel;
i++)
723 inbuffer[
i] = inbuffer[
i] *
fc * q->mlt_window[
i] -
724 previous_buffer[
i] * q->mlt_window[q->samples_per_channel - 1 -
i];
739 cook_gains *gains_ptr,
float *previous_buffer)
741 float *buffer0 = q->mono_mdct_output;
742 float *buffer1 = q->mono_mdct_output + q->samples_per_channel;
746 q->mdct_ctx.imdct_calc(&q->mdct_ctx, q->mono_mdct_output, inbuffer);
748 q->imlt_window(q, buffer1, gains_ptr, previous_buffer);
751 for (
i = 0;
i < 8;
i++)
752 if (gains_ptr->
now[
i] || gains_ptr->
now[
i + 1])
753 q->interpolate(q, &buffer1[q->gain_size_factor *
i],
754 gains_ptr->
now[
i], gains_ptr->
now[
i + 1]);
757 memcpy(previous_buffer, buffer0,
758 q->samples_per_channel *
sizeof(*previous_buffer));
774 int length = end - start + 1;
780 for (
i = 0;
i < length;
i++)
781 decouple_tab[start +
i] =
get_vlc2(&q->gb,
785 for (
i = 0;
i < length;
i++) {
791 decouple_tab[start +
i] = v;
811 float *decode_buffer,
812 float *mlt_buffer1,
float *mlt_buffer2)
817 mlt_buffer1[
SUBBAND_SIZE * subband + j] = f1 * decode_buffer[tmp_idx];
818 mlt_buffer2[
SUBBAND_SIZE * subband + j] = f2 * decode_buffer[tmp_idx];
830 float *mlt_buffer_left,
float *mlt_buffer_right)
834 float *decode_buffer = q->decode_buffer_0;
837 const float *cplscale;
839 memset(decode_buffer, 0,
sizeof(q->decode_buffer_0));
842 memset(mlt_buffer_left, 0, 1024 *
sizeof(*mlt_buffer_left));
843 memset(mlt_buffer_right, 0, 1024 *
sizeof(*mlt_buffer_right));
851 mlt_buffer_left[
i * 20 + j] = decode_buffer[
i * 40 + j];
852 mlt_buffer_right[
i * 20 + j] = decode_buffer[
i * 40 + 20 + j];
861 idx -= decouple_tab[cpl_tmp];
863 f1 = cplscale[decouple_tab[cpl_tmp] + 1];
865 q->decouple(q, p,
i, f1, f2, decode_buffer,
866 mlt_buffer_left, mlt_buffer_right);
882 const uint8_t *inbuffer,
905 q->adsp.vector_clipf(
out, q->mono_mdct_output + q->samples_per_channel,
906 FFALIGN(q->samples_per_channel, 8), -1.0f, 1.0f);
922 cook_gains *gains_ptr,
float *previous_buffer,
925 imlt_gain(q, decode_buffer, gains_ptr, previous_buffer);
927 q->saturate_output(q,
out);
940 const uint8_t *inbuffer,
float **outbuffer)
942 int sub_packet_size = p->
size;
945 memset(q->decode_buffer_1, 0,
sizeof(q->decode_buffer_1));
949 if ((res =
joint_decode(q, p, q->decode_buffer_1, q->decode_buffer_2)) < 0)
952 if ((res =
mono_decode(q, p, q->decode_buffer_1)) < 0)
957 if ((res =
mono_decode(q, p, q->decode_buffer_2)) < 0)
982 int *got_frame_ptr,
AVPacket *avpkt)
984 const uint8_t *buf = avpkt->
data;
985 int buf_size = avpkt->
size;
992 if (buf_size < avctx->block_align)
996 if (q->discarded_packets >= 2) {
997 frame->nb_samples = q->samples_per_channel;
1006 for (
i = 1;
i < q->num_subpackets;
i++) {
1008 q->subpacket[0].size -= q->subpacket[
i].size + 1;
1009 if (q->subpacket[0].size < 0) {
1011 "frame subpacket size total > avctx->block_align!\n");
1017 for (
i = 0;
i < q->num_subpackets;
i++) {
1018 q->subpacket[
i].bits_per_subpacket = (q->subpacket[
i].size * 8) >>
1019 q->subpacket[
i].bits_per_subpdiv;
1020 q->subpacket[
i].ch_idx = chidx;
1022 "subpacket[%i] size %i js %i %i block_align %i\n",
1023 i, q->subpacket[
i].size, q->subpacket[
i].joint_stereo,
offset,
1028 offset += q->subpacket[
i].size;
1029 chidx += q->subpacket[
i].num_channels;
1035 if (q->discarded_packets < 2) {
1036 q->discarded_packets++;
1049 #define PRINT(a, b) ff_dlog(q->avctx, " %s = %d\n", a, b);
1050 ff_dlog(q->avctx,
"COOKextradata\n");
1051 ff_dlog(q->avctx,
"cookversion=%x\n", q->subpacket[0].cookversion);
1052 if (q->subpacket[0].cookversion >
STEREO) {
1053 PRINT(
"js_subband_start", q->subpacket[0].js_subband_start);
1054 PRINT(
"js_vlc_bits", q->subpacket[0].js_vlc_bits);
1056 ff_dlog(q->avctx,
"COOKContext\n");
1057 PRINT(
"nb_channels", q->avctx->ch_layout.nb_channels);
1058 PRINT(
"bit_rate", (
int)q->avctx->bit_rate);
1059 PRINT(
"sample_rate", q->avctx->sample_rate);
1060 PRINT(
"samples_per_channel", q->subpacket[0].samples_per_channel);
1061 PRINT(
"subbands", q->subpacket[0].subbands);
1062 PRINT(
"js_subband_start", q->subpacket[0].js_subband_start);
1063 PRINT(
"log2_numvector_size", q->subpacket[0].log2_numvector_size);
1064 PRINT(
"numvector_size", q->subpacket[0].numvector_size);
1065 PRINT(
"total_subbands", q->subpacket[0].total_subbands);
1079 unsigned int channel_mask = 0;
1080 int samples_per_frame = 0;
1116 q->subpacket[
s].cookversion = bytestream2_get_be32(&
gb);
1117 samples_per_frame = bytestream2_get_be16(&
gb);
1118 q->subpacket[
s].subbands = bytestream2_get_be16(&
gb);
1119 bytestream2_get_be32(&
gb);
1120 q->subpacket[
s].js_subband_start = bytestream2_get_be16(&
gb);
1121 if (q->subpacket[
s].js_subband_start >= 51) {
1125 q->subpacket[
s].js_vlc_bits = bytestream2_get_be16(&
gb);
1128 q->subpacket[
s].samples_per_channel = samples_per_frame /
channels;
1132 q->subpacket[
s].log2_numvector_size = 5;
1133 q->subpacket[
s].total_subbands = q->subpacket[
s].subbands;
1134 q->subpacket[
s].num_channels = 1;
1139 q->subpacket[
s].cookversion);
1140 q->subpacket[
s].joint_stereo = 0;
1141 switch (q->subpacket[
s].cookversion) {
1151 q->subpacket[
s].bits_per_subpdiv = 1;
1152 q->subpacket[
s].num_channels = 2;
1163 q->subpacket[
s].total_subbands = q->subpacket[
s].subbands +
1164 q->subpacket[
s].js_subband_start;
1165 q->subpacket[
s].joint_stereo = 1;
1166 q->subpacket[
s].num_channels = 2;
1168 if (q->subpacket[
s].samples_per_channel > 256) {
1169 q->subpacket[
s].log2_numvector_size = 6;
1171 if (q->subpacket[
s].samples_per_channel > 512) {
1172 q->subpacket[
s].log2_numvector_size = 7;
1177 channel_mask |= q->subpacket[
s].channel_mask = bytestream2_get_be32(&
gb);
1180 q->subpacket[
s].total_subbands = q->subpacket[
s].subbands +
1181 q->subpacket[
s].js_subband_start;
1182 q->subpacket[
s].joint_stereo = 1;
1183 q->subpacket[
s].num_channels = 2;
1184 q->subpacket[
s].samples_per_channel = samples_per_frame >> 1;
1186 if (q->subpacket[
s].samples_per_channel > 256) {
1187 q->subpacket[
s].log2_numvector_size = 6;
1189 if (q->subpacket[
s].samples_per_channel > 512) {
1190 q->subpacket[
s].log2_numvector_size = 7;
1193 q->subpacket[
s].samples_per_channel = samples_per_frame;
1198 q->subpacket[
s].cookversion);
1202 if (
s > 1 && q->subpacket[
s].samples_per_channel != q->samples_per_channel) {
1206 q->samples_per_channel = q->subpacket[0].samples_per_channel;
1210 q->subpacket[
s].numvector_size = (1 << q->subpacket[
s].log2_numvector_size);
1213 if (q->subpacket[
s].total_subbands > 53) {
1218 if ((q->subpacket[
s].js_vlc_bits > 6) ||
1219 (q->subpacket[
s].js_vlc_bits < 2 * q->subpacket[
s].joint_stereo)) {
1221 q->subpacket[
s].js_vlc_bits, 2 * q->subpacket[
s].joint_stereo);
1225 if (q->subpacket[
s].subbands > 50) {
1229 if (q->subpacket[
s].subbands == 0) {
1233 q->subpacket[
s].gains1.now = q->subpacket[
s].gain_1;
1234 q->subpacket[
s].gains1.previous = q->subpacket[
s].gain_2;
1235 q->subpacket[
s].gains2.now = q->subpacket[
s].gain_3;
1236 q->subpacket[
s].gains2.previous = q->subpacket[
s].gain_4;
1238 if (q->num_subpackets + q->subpacket[
s].num_channels >
channels) {
1243 q->num_subpackets++;
1248 if (q->samples_per_channel != 256 && q->samples_per_channel != 512 &&
1249 q->samples_per_channel != 1024) {
1251 q->samples_per_channel);
1266 q->decoded_bytes_buffer =
1270 if (!q->decoded_bytes_buffer)
1304 .priv_data_size =
sizeof(COOKContext),
static void decode_vectors(COOKContext *q, COOKSubpacket *p, int *category, int *quant_index_table, float *mlt_buffer)
Fill the mlt_buffer with mlt coefficients.
static int mono_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer)
@ AV_SAMPLE_FMT_FLTP
float, planar
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static av_cold int cook_decode_init(AVCodecContext *avctx)
Cook initialization.
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
static av_cold void init_pow2table(void)
static void decode_gain_info(GetBitContext *gb, int *gaininfo)
Fill the gain array for the timedomain quantization.
void(* interpolate)(struct cook *q, float *buffer, int gain_index, int gain_index_next)
static int get_bits_count(const GetBitContext *s)
static int unpack_SQVH(COOKContext *q, COOKSubpacket *p, int category, int *subband_coef_index, int *subband_coef_sign)
Unpack the subband_coef_index and subband_coef_sign vectors.
This structure describes decoded (raw) audio or video data.
static void scalar_dequant_float(COOKContext *q, int index, int quant_index, int *subband_coef_index, int *subband_coef_sign, float *mlt_p)
The real requantization of the mltcoefs.
av_cold void ff_audiodsp_init(AudioDSPContext *c)
#define fc(width, name, range_min, range_max)
void(* scalar_dequant)(struct cook *q, int index, int quant_index, int *subband_coef_index, int *subband_coef_sign, float *mlt_p)
#define COUPLING_VLC_BITS
int nb_channels
Number of channels in this layout.
static av_cold int cook_decode_close(AVCodecContext *avctx)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define DECODE_BYTES_PAD1(bytes)
static av_cold int init_cook_mlt(COOKContext *q)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static const int expbits_tab[8]
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
static const struct twinvq_data tab
static int decode_bytes(const uint8_t *inbuffer, uint8_t *out, int bytes)
Cook indata decoding, every 32 bits are XORed with 0x37c511f2.
static int decode_subpacket(COOKContext *q, COOKSubpacket *p, const uint8_t *inbuffer, float **outbuffer)
Cook subpacket decoding.
static const float dither_tab[9]
static av_cold void init_cplscales_table(COOKContext *q)
static void saturate_output_float(COOKContext *q, float *out)
Saturate the output signal and interleave.
static int ff_thread_once(char *control, void(*routine)(void))
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static const float quant_centroid_tab[7][14]
#define FF_CODEC_DECODE_CB(func)
const float * cplscales[5]
static av_cold int init_cook_vlc_tables(COOKContext *q)
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
static const int vhvlcsize_tab[7]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void(* decouple)(struct cook *q, COOKSubpacket *p, int subband, float f1, float f2, float *decode_buffer, float *mlt_buffer1, float *mlt_buffer2)
float decode_buffer_1[1024]
const FFCodec ff_cook_decoder
static const int vd_tab[7]
and forward the result(frame or status change) to the corresponding input. If nothing is possible
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static void imlt_window_float(COOKContext *q, float *inbuffer, cook_gains *gains_ptr, float *previous_buffer)
Apply transform window, overlap buffers.
static void decouple_float(COOKContext *q, COOKSubpacket *p, int subband, float f1, float f2, float *decode_buffer, float *mlt_buffer1, float *mlt_buffer2)
function decouples a pair of signals from a single signal via multiplication.
static unsigned int get_bits1(GetBitContext *s)
int ff_init_vlc_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()
static void dump_cook_context(COOKContext *q)
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
static void mlt_compensate_output(COOKContext *q, float *decode_buffer, cook_gains *gains_ptr, float *previous_buffer, float *out)
Final part of subpacket decoding: Apply modulated lapped transform, gain compensation,...
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static const int vpr_tab[7]
static av_cold int build_vlc(VLC *vlc, int nb_bits, const uint8_t counts[16], const void *syms, int symbol_size, int offset, void *logctx)
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
COOKSubpacket subpacket[MAX_SUBPACKETS]
static const float *const cplscales[5]
static const uint8_t cvh_huffcounts[7][16]
Context structure for the Lagged Fibonacci PRNG.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
enum AVSampleFormat sample_fmt
audio sample format
static void imlt_gain(COOKContext *q, float *inbuffer, cook_gains *gains_ptr, float *previous_buffer)
The modulated lapped transform, this takes transform coefficients and transforms them into timedomain...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
unsigned int channel_mask
void ff_sine_window_init(float *window, int n)
Generate a sine window.
#define MAX_COOK_VLC_ENTRIES
static const int kmax_tab[7]
#define DECLARE_ALIGNED(n, t, v)
#define i(width, name, range_min, range_max)
float mono_previous_buffer1[1024]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define av_malloc_array(a, b)
AVSampleFormat
Audio sample formats.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
static int decode_envelope(COOKContext *q, COOKSubpacket *p, int *quant_index_table)
Create the quant index table needed for the envelope.
void ff_free_vlc(VLC *vlc)
FF_ENABLE_DEPRECATION_WARNINGS int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
static int decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab)
function for getting the jointstereo coupling information
static float pow2tab[127]
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
#define FFSWAP(type, a, b)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static void interpolate_float(COOKContext *q, float *buffer, int gain_index, int gain_index_next)
the actual requantization of the timedomain samples
#define AV_INPUT_BUFFER_PADDING_SIZE
main external API structure.
static float rootpow2tab[127]
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
static const uint8_t *const ccpl_huffsyms[5]
float mono_previous_buffer2[1024]
uint8_t * decoded_bytes_buffer
static int cook_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static av_cold void init_gain_table(COOKContext *q)
Filter the word “frame” indicates either a video frame or a group of audio samples
static int joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer_left, float *mlt_buffer_right)
function for decoding joint stereo data
static const uint8_t envelope_quant_index_huffcounts[13][16]
VLC envelope_quant_index[13]
void(* imlt_window)(struct cook *q, float *buffer1, cook_gains *gains_ptr, float *previous_buffer)
#define avpriv_request_sample(...)
This structure stores compressed data.
static const uint8_t ccpl_huffcounts[5][16]
void(* saturate_output)(struct cook *q, float *out)
static const void *const cvh_huffsyms[7]
float decode_buffer_0[1060]
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static void categorize(COOKContext *q, COOKSubpacket *p, const int *quant_index_table, int *category, int *category_index)
Calculate the category and category_index vector.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const int cplband[51]
float mono_mdct_output[2048]
static const uint8_t envelope_quant_index_huffsyms[13][24]
float decode_buffer_2[1024]
static void expand_category(COOKContext *q, int *category, int *category_index)
Expand the category vector.
static const int invradix_tab[7]
static void decode_bytes_and_gain(COOKContext *q, COOKSubpacket *p, const uint8_t *inbuffer, cook_gains *gains_ptr)
First part of subpacket decoding: decode raw stream bytes and read gain info.