X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fcook.c;h=f487db6a975b41ceb08f91f2dc55b16dcef791a8;hb=1f1ad8ace040a08edc2646ff638ca42a8828779f;hp=90d78eb3f562d33188a5afeb3d91c584cc0bea5d;hpb=6d97484d72e33f7dde9493a9ead1a72e2f029605;p=ffmpeg diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 90d78eb3f56..f487db6a975 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -44,9 +44,10 @@ #include "libavutil/channel_layout.h" #include "libavutil/lfg.h" + +#include "audiodsp.h" #include "avcodec.h" #include "get_bits.h" -#include "dsputil.h" #include "bytestream.h" #include "fft.h" #include "internal.h" @@ -63,12 +64,12 @@ #define SUBBAND_SIZE 20 #define MAX_SUBPACKETS 5 -typedef struct { +typedef struct cook_gains { int *now; int *previous; } cook_gains; -typedef struct { +typedef struct COOKSubpacket { int ch_idx; int size; int num_channels; @@ -122,7 +123,7 @@ typedef struct cook { void (*saturate_output)(struct cook *q, float *out); AVCodecContext* avctx; - DSPContext dsp; + AudioDSPContext adsp; GetBitContext gb; /* stream data */ int num_vectors; @@ -139,7 +140,7 @@ typedef struct cook { VLC envelope_quant_index[13]; VLC sqvh[7]; // scalar quantization - /* generatable tables and related variables */ + /* generate tables and related variables */ int gain_size_factor; float gain_table[23]; @@ -865,8 +866,8 @@ static inline void decode_bytes_and_gain(COOKContext *q, COOKSubpacket *p, */ static void saturate_output_float(COOKContext *q, float *out) { - q->dsp.vector_clipf(out, q->mono_mdct_output + q->samples_per_channel, - -1.0f, 1.0f, FFALIGN(q->samples_per_channel, 8)); + q->adsp.vector_clipf(out, q->mono_mdct_output + q->samples_per_channel, + -1.0f, 1.0f, FFALIGN(q->samples_per_channel, 8)); } @@ -1012,14 +1013,14 @@ static int cook_decode_frame(AVCodecContext *avctx, void *data, static void dump_cook_context(COOKContext *q) { //int i=0; -#define PRINT(a, b) av_dlog(q->avctx, " %s = %d\n", a, b); - av_dlog(q->avctx, "COOKextradata\n"); - av_dlog(q->avctx, "cookversion=%x\n", q->subpacket[0].cookversion); +#define PRINT(a, b) ff_dlog(q->avctx, " %s = %d\n", a, b); + ff_dlog(q->avctx, "COOKextradata\n"); + ff_dlog(q->avctx, "cookversion=%x\n", q->subpacket[0].cookversion); if (q->subpacket[0].cookversion > STEREO) { PRINT("js_subband_start", q->subpacket[0].js_subband_start); PRINT("js_vlc_bits", q->subpacket[0].js_vlc_bits); } - av_dlog(q->avctx, "COOKContext\n"); + ff_dlog(q->avctx, "COOKContext\n"); PRINT("nb_channels", q->avctx->channels); PRINT("bit_rate", q->avctx->bit_rate); PRINT("sample_rate", q->avctx->sample_rate); @@ -1050,7 +1051,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) q->avctx = avctx; /* Take care of the codec specific extradata. */ - if (extradata_size <= 0) { + if (extradata_size < 8) { av_log(avctx, AV_LOG_ERROR, "Necessary extradata missing!\n"); return AVERROR_INVALIDDATA; } @@ -1065,7 +1066,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) /* Initialize RNG. */ av_lfg_init(&q->random_state, 0); - ff_dsputil_init(&q->dsp, avctx); + ff_audiodsp_init(&q->adsp); while (edata_ptr < edata_ptr_end) { /* 8 for mono, 16 for stereo, ? for multichannel @@ -1169,7 +1170,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) /* Initialize variable relations */ q->subpacket[s].numvector_size = (1 << q->subpacket[s].log2_numvector_size); - /* Try to catch some obviously faulty streams, othervise it might be exploitable */ + /* Try to catch some obviously faulty streams, otherwise it might be exploitable */ if (q->subpacket[s].total_subbands > 53) { avpriv_request_sample(avctx, "total_subbands > 53"); return AVERROR_PATCHWELCOME; @@ -1212,12 +1213,12 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) /* Pad the databuffer with: DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(), - FF_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */ + AV_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */ q->decoded_bytes_buffer = av_mallocz(avctx->block_align + DECODE_BYTES_PAD1(avctx->block_align) - + FF_INPUT_BUFFER_PADDING_SIZE); - if (q->decoded_bytes_buffer == NULL) + + AV_INPUT_BUFFER_PADDING_SIZE); + if (!q->decoded_bytes_buffer) return AVERROR(ENOMEM); /* Initialize transform. */ @@ -1233,7 +1234,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) q->saturate_output = saturate_output_float; } - /* Try to catch some obviously faulty streams, othervise it might be exploitable */ + /* Try to catch some obviously faulty streams, otherwise it might be exploitable */ if (q->samples_per_channel != 256 && q->samples_per_channel != 512 && q->samples_per_channel != 1024) { avpriv_request_sample(avctx, "samples_per_channel = %d", @@ -1255,14 +1256,14 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) AVCodec ff_cook_decoder = { .name = "cook", + .long_name = NULL_IF_CONFIG_SMALL("Cook / Cooker / Gecko (RealAudio G2)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_COOK, .priv_data_size = sizeof(COOKContext), .init = cook_decode_init, .close = cook_decode_close, .decode = cook_decode_frame, - .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("Cook / Cooker / Gecko (RealAudio G2)"), + .capabilities = AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, };