Bastardization of the G.722.1 standard. This decoder handles RealNetworks, RealAudio G2 data. Cook is identified by the codec name cook in RM files.
To use this decoder, a calling application must supply the extradata bytes provided from the RM container; 8+ bytes for mono streams and 16+ for stereo streams (maybe more).
Codec technicalities (all this assume a buffer length of 1024): Cook works with several different techniques to achieve its compression. In the timedomain the buffer is divided into 8 pieces and quantized. If two neighboring pieces have different quantization index a smooth quantization curve is used to get a smooth overlap between the different pieces. To get to the transformdomain Cook uses a modulated lapped transform. The transform domain has 50 subbands with 20 elements each. This means only a maximum of 50*20=1000 coefficients are used out of the 1024 available.
Definition in file cook.c.
Go to the source code of this file.
Classes | |
| struct | cook_gains |
| struct | cook |
Typedefs | |
| typedef struct cook | COOKContext |
Functions | |
| static void | dump_float_table (float *table, int size, int delimiter) |
| static void | dump_int_table (int *table, int size, int delimiter) |
| static void | dump_short_table (short *table, int size, int delimiter) |
| static void | init_pow2table (COOKContext *q) |
| static void | init_rootpow2table (COOKContext *q) |
| static void | init_gain_table (COOKContext *q) |
| static int | init_cook_vlc_tables (COOKContext *q) |
| static int | init_cook_mlt (COOKContext *q) |
| static float * | maybe_reformat_buffer32 (COOKContext *q, float *ptr, int n) |
| static void | init_cplscales_table (COOKContext *q) |
| static int | decode_bytes (uint8_t *inbuffer, uint8_t *out, int bytes) |
| static int | cook_decode_close (AVCodecContext *avctx) |
| Cook uninit. | |
| static void | decode_gain_info (GetBitContext *gb, int *gaininfo) |
| Fill the gain array for the timedomain quantization. | |
| static void | decode_envelope (COOKContext *q, int *quant_index_table) |
| Create the quant index table needed for the envelope. | |
| static void | categorize (COOKContext *q, int *quant_index_table, int *category, int *category_index) |
| Calculate the category and category_index vector. | |
| static void | expand_category (COOKContext *q, int *category, int *category_index) |
| Expand the category vector. | |
| 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. | |
| static int | unpack_SQVH (COOKContext *q, int category, int *subband_coef_index, int *subband_coef_sign) |
| Unpack the subband_coef_index and subband_coef_sign vectors. | |
| static void | decode_vectors (COOKContext *q, int *category, int *quant_index_table, float *mlt_buffer) |
| Fill the mlt_buffer with mlt coefficients. | |
| static void | mono_decode (COOKContext *q, float *mlt_buffer) |
| function for decoding mono data | |
| static void | interpolate_float (COOKContext *q, float *buffer, int gain_index, int gain_index_next) |
| the actual requantization of the timedomain samples | |
| static void | imlt_window_float (COOKContext *q, float *buffer1, cook_gains *gains_ptr, float *previous_buffer) |
| Apply transform window, overlap buffers. | |
| 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 samples. | |
| static void | decouple_info (COOKContext *q, int *decouple_tab) |
| function for getting the jointstereo coupling information | |
| static void | decouple_float (COOKContext *q, int subband, float f1, float f2, float *decode_buffer, float *mlt_buffer1, float *mlt_buffer2) |
| static void | joint_decode (COOKContext *q, float *mlt_buffer1, float *mlt_buffer2) |
| function for decoding joint stereo data | |
| static void | decode_bytes_and_gain (COOKContext *q, uint8_t *inbuffer, cook_gains *gains_ptr) |
| First part of subpacket decoding: decode raw stream bytes and read gain info. | |
| static void | saturate_output_float (COOKContext *q, int chan, int16_t *out) |
| Saturate the output signal to signed 16bit integers. | |
| static void | mlt_compensate_output (COOKContext *q, float *decode_buffer, cook_gains *gains, float *previous_buffer, int16_t *out, int chan) |
| Final part of subpacket decoding: Apply modulated lapped transform, gain compensation, clip and convert to integer. | |
| static int | decode_subpacket (COOKContext *q, uint8_t *inbuffer, int sub_packet_size, int16_t *outbuffer) |
| Cook subpacket decoding. | |
| static int | cook_decode_frame (AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) |
| Cook frame decoding. | |
| static void | dump_cook_context (COOKContext *q) |
| static int | cook_decode_init (AVCodecContext *avctx) |
| Cook initialization. | |
Variables | |
| AVCodec | cook_decoder |
| typedef struct cook COOKContext |
| static void dump_float_table | ( | float * | table, | |
| int | size, | |||
| int | delimiter | |||
| ) | [static] |
| static void dump_int_table | ( | int * | table, | |
| int | size, | |||
| int | delimiter | |||
| ) | [static] |
| static void dump_short_table | ( | short * | table, | |
| int | size, | |||
| int | delimiter | |||
| ) | [static] |
| static void init_pow2table | ( | COOKContext * | q | ) | [static] |
| static void init_rootpow2table | ( | COOKContext * | q | ) | [static] |
| static void init_gain_table | ( | COOKContext * | q | ) | [static] |
| static int init_cook_vlc_tables | ( | COOKContext * | q | ) | [static] |
| static int init_cook_mlt | ( | COOKContext * | q | ) | [static] |
| static float* maybe_reformat_buffer32 | ( | COOKContext * | q, | |
| float * | ptr, | |||
| int | n | |||
| ) | [static] |
| static void init_cplscales_table | ( | COOKContext * | q | ) | [static] |
| static int decode_bytes | ( | uint8_t * | inbuffer, | |
| uint8_t * | out, | |||
| int | bytes | |||
| ) | [inline, static] |
| static int cook_decode_close | ( | AVCodecContext * | avctx | ) | [static] |
| static void decode_gain_info | ( | GetBitContext * | gb, | |
| int * | gaininfo | |||
| ) | [static] |
Fill the gain array for the timedomain quantization.
| q | pointer to the COOKContext | |
| gaininfo[9] | array of gain indices |
Definition at line 365 of file cook.c.
Referenced by decode_bytes_and_gain().
| static void decode_envelope | ( | COOKContext * | q, | |
| int * | quant_index_table | |||
| ) | [static] |
Create the quant index table needed for the envelope.
| q | pointer to the COOKContext | |
| quant_index_table | pointer to the array |
Definition at line 389 of file cook.c.
Referenced by mono_decode().
| static void categorize | ( | COOKContext * | q, | |
| int * | quant_index_table, | |||
| int * | category, | |||
| int * | category_index | |||
| ) | [static] |
Calculate the category and category_index vector.
| q | pointer to the COOKContext | |
| quant_index_table | pointer to the array | |
| category | pointer to the category array | |
| category_index | pointer to the category_index array |
Definition at line 419 of file cook.c.
Referenced by mono_decode().
| static void expand_category | ( | COOKContext * | q, | |
| int * | category, | |||
| int * | category_index | |||
| ) | [inline, static] |
Expand the category vector.
| q | pointer to the COOKContext | |
| category | pointer to the category array | |
| category_index | pointer to the category_index array |
Definition at line 522 of file cook.c.
Referenced by mono_decode().
| static void scalar_dequant_float | ( | COOKContext * | q, | |
| int | index, | |||
| int | quant_index, | |||
| int * | subband_coef_index, | |||
| int * | subband_coef_sign, | |||
| float * | mlt_p | |||
| ) | [static] |
The real requantization of the mltcoefs.
| q | pointer to the COOKContext | |
| index | index | |
| quant_index | quantisation index | |
| subband_coef_index | array of indexes to quant_centroid_tab | |
| subband_coef_sign | signs of coefficients | |
| mlt_p | pointer into the mlt buffer |
Definition at line 541 of file cook.c.
Referenced by cook_decode_init().
| static int unpack_SQVH | ( | COOKContext * | q, | |
| int | category, | |||
| int * | subband_coef_index, | |||
| int * | subband_coef_sign | |||
| ) | [static] |
Unpack the subband_coef_index and subband_coef_sign vectors.
| q | pointer to the COOKContext | |
| category | pointer to the category array | |
| subband_coef_index | array of indexes to quant_centroid_tab | |
| subband_coef_sign | signs of coefficients |
Definition at line 568 of file cook.c.
Referenced by decode_vectors().
| static void decode_vectors | ( | COOKContext * | q, | |
| int * | category, | |||
| int * | quant_index_table, | |||
| float * | mlt_buffer | |||
| ) | [static] |
Fill the mlt_buffer with mlt coefficients.
| q | pointer to the COOKContext | |
| category | pointer to the category array | |
| quant_index_table | pointer to the array | |
| mlt_buffer | pointer to mlt coefficients |
Definition at line 613 of file cook.c.
Referenced by mono_decode().
| static void mono_decode | ( | COOKContext * | q, | |
| float * | mlt_buffer | |||
| ) | [static] |
function for decoding mono data
| q | pointer to the COOKContext | |
| mlt_buffer | pointer to mlt coefficients |
Definition at line 654 of file cook.c.
Referenced by decode_subpacket(), and joint_decode().
| static void interpolate_float | ( | COOKContext * | q, | |
| float * | buffer, | |||
| int | gain_index, | |||
| int | gain_index_next | |||
| ) | [static] |
the actual requantization of the timedomain samples
| q | pointer to the COOKContext | |
| buffer | pointer to the timedomain buffer | |
| gain_index | index for the block multiplier | |
| gain_index_next | index for the next block multiplier |
Definition at line 680 of file cook.c.
Referenced by cook_decode_init().
| static void imlt_window_float | ( | COOKContext * | q, | |
| float * | buffer1, | |||
| cook_gains * | gains_ptr, | |||
| float * | previous_buffer | |||
| ) | [static] |
Apply transform window, overlap buffers.
| q | pointer to the COOKContext | |
| inbuffer | pointer to the mltcoefficients | |
| gains_ptr | current and previous gains | |
| previous_buffer | pointer to the previous buffer to be used for overlapping |
Definition at line 710 of file cook.c.
Referenced by cook_decode_init().
| static void imlt_gain | ( | COOKContext * | q, | |
| float * | inbuffer, | |||
| cook_gains * | gains_ptr, | |||
| float * | previous_buffer | |||
| ) | [static] |
The modulated lapped transform, this takes transform coefficients and transforms them into timedomain samples.
Apply transform window, overlap buffers, apply gain profile and buffer management.
| q | pointer to the COOKContext | |
| inbuffer | pointer to the mltcoefficients | |
| gains_ptr | current and previous gains | |
| previous_buffer | pointer to the previous buffer to be used for overlapping |
Definition at line 740 of file cook.c.
Referenced by mlt_compensate_output().
| static void decouple_info | ( | COOKContext * | q, | |
| int * | decouple_tab | |||
| ) | [static] |
function for getting the jointstereo coupling information
| q | pointer to the COOKContext | |
| decouple_tab | decoupling array |
Definition at line 773 of file cook.c.
Referenced by joint_decode().
| static void decouple_float | ( | COOKContext * | q, | |
| int | subband, | |||
| float | f1, | |||
| float | f2, | |||
| float * | decode_buffer, | |||
| float * | mlt_buffer1, | |||
| float * | mlt_buffer2 | |||
| ) | [static] |
| static void joint_decode | ( | COOKContext * | q, | |
| float * | mlt_buffer1, | |||
| float * | mlt_buffer2 | |||
| ) | [static] |
function for decoding joint stereo data
| q | pointer to the COOKContext | |
| mlt_buffer1 | pointer to left channel mlt coefficients | |
| mlt_buffer2 | pointer to right channel mlt coefficients |
Definition at line 828 of file cook.c.
Referenced by decode_subpacket().
| static void decode_bytes_and_gain | ( | COOKContext * | q, | |
| uint8_t * | inbuffer, | |||
| cook_gains * | gains_ptr | |||
| ) | [inline, static] |
First part of subpacket decoding: decode raw stream bytes and read gain info.
| q | pointer to the COOKContext | |
| inbuffer | pointer to raw stream data | |
| gain_ptr | array of current/prev gain pointers |
Definition at line 878 of file cook.c.
Referenced by decode_subpacket().
| static void saturate_output_float | ( | COOKContext * | q, | |
| int | chan, | |||
| int16_t * | out | |||
| ) | [static] |
Saturate the output signal to signed 16bit integers.
| q | pointer to the COOKContext | |
| chan | channel to saturate | |
| out | pointer to the output vector |
Definition at line 901 of file cook.c.
Referenced by cook_decode_init().
| static void mlt_compensate_output | ( | COOKContext * | q, | |
| float * | decode_buffer, | |||
| cook_gains * | gains, | |||
| float * | previous_buffer, | |||
| int16_t * | out, | |||
| int | chan | |||
| ) | [inline, static] |
Final part of subpacket decoding: Apply modulated lapped transform, gain compensation, clip and convert to integer.
| q | pointer to the COOKContext | |
| decode_buffer | pointer to the mlt coefficients | |
| gain_ptr | array of current/prev gain pointers | |
| previous_buffer | pointer to the previous buffer to be used for overlapping | |
| out | pointer to the output buffer | |
| chan | 0: left or single channel, 1: right channel |
Definition at line 927 of file cook.c.
Referenced by decode_subpacket().
| static int decode_subpacket | ( | COOKContext * | q, | |
| uint8_t * | inbuffer, | |||
| int | sub_packet_size, | |||
| int16_t * | outbuffer | |||
| ) | [static] |
Cook subpacket decoding.
This function returns one decoded subpacket, usually 1024 samples per channel.
| q | pointer to the COOKContext | |
| inbuffer | pointer to the inbuffer | |
| sub_packet_size | subpacket size | |
| outbuffer | pointer to the outbuffer |
Definition at line 947 of file cook.c.
Referenced by cook_decode_frame().
| static int cook_decode_frame | ( | AVCodecContext * | avctx, | |
| void * | data, | |||
| int * | data_size, | |||
| uint8_t * | buf, | |||
| int | buf_size | |||
| ) | [static] |
| static void dump_cook_context | ( | COOKContext * | q | ) | [static] |
| static int cook_decode_init | ( | AVCodecContext * | avctx | ) | [static] |
Initial value:
{
.name = "cook",
.type = CODEC_TYPE_AUDIO,
.id = CODEC_ID_COOK,
.priv_data_size = sizeof(COOKContext),
.init = cook_decode_init,
.close = cook_decode_close,
.decode = cook_decode_frame,
}
1.5.5