diff options
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/8svx.c | 48 | ||||
-rw-r--r-- | libavcodec/adpcm.c | 60 | ||||
-rw-r--r-- | libavcodec/apedec.c | 39 | ||||
-rw-r--r-- | libavcodec/atrac3.c | 44 | ||||
-rw-r--r-- | libavcodec/cook.c | 40 | ||||
-rw-r--r-- | libavcodec/dcadec.c | 128 | ||||
-rw-r--r-- | libavcodec/imc.c | 26 | ||||
-rw-r--r-- | libavcodec/mpc.c | 14 | ||||
-rw-r--r-- | libavcodec/mpc.h | 2 | ||||
-rw-r--r-- | libavcodec/mpc7.c | 6 | ||||
-rw-r--r-- | libavcodec/mpc8.c | 7 | ||||
-rw-r--r-- | libavcodec/ralf.c | 35 | ||||
-rw-r--r-- | libavcodec/twinvq.c | 31 |
13 files changed, 210 insertions, 270 deletions
diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c index f41b19fd58..0da48986f0 100644 --- a/libavcodec/8svx.c +++ b/libavcodec/8svx.c @@ -59,25 +59,6 @@ static const int8_t exponential[16] = { -128, -64, -32, -16, -8, -4, -2, -1, 0, #define MAX_FRAME_SIZE 2048 /** - * Interleave samples in buffer containing all left channel samples - * at the beginning, and right channel samples at the end. - * Each sample is assumed to be in signed 8-bit format. - * - * @param size the size in bytes of the dst and src buffer - */ -static void interleave_stereo(uint8_t *dst, const uint8_t *src, int size) -{ - uint8_t *dst_end = dst + size; - size = size>>1; - - while (dst < dst_end) { - *dst++ = *src; - *dst++ = *(src+size); - src++; - } -} - -/** * Delta decode the compressed values in src, and put the resulting * decoded n samples in dst. * @@ -107,7 +88,8 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { EightSvxContext *esc = avctx->priv_data; - int n, out_data_size, ret; + int n, out_data_size; + int ch, ret; uint8_t *src, *dst; /* decode and interleave the first packet */ @@ -152,10 +134,7 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, deinterleaved_samples = avpkt->data; } - if (avctx->channels == 2) - interleave_stereo(esc->samples, deinterleaved_samples, esc->samples_size); - else - memcpy(esc->samples, deinterleaved_samples, esc->samples_size); + memcpy(esc->samples, deinterleaved_samples, esc->samples_size); av_freep(&p); } @@ -170,11 +149,14 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, *got_frame_ptr = 1; *(AVFrame *)data = esc->frame; - dst = esc->frame.data[0]; - src = esc->samples + esc->samples_idx; - out_data_size = esc->frame.nb_samples * avctx->channels; - for (n = out_data_size; n > 0; n--) - *dst++ = *src++ + 128; + out_data_size = esc->frame.nb_samples; + for (ch = 0; ch<avctx->channels; ch++) { + dst = esc->frame.data[ch]; + src = esc->samples + esc->samples_idx / avctx->channels + ch * esc->samples_size / avctx->channels; + for (n = out_data_size; n > 0; n--) + *dst++ = *src++ + 128; + } + out_data_size *= avctx->channels; esc->samples_idx += out_data_size; return esc->table ? @@ -200,7 +182,7 @@ static av_cold int eightsvx_decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "Invalid codec id %d.\n", avctx->codec->id); return AVERROR_INVALIDDATA; } - avctx->sample_fmt = AV_SAMPLE_FMT_U8; + avctx->sample_fmt = AV_SAMPLE_FMT_U8P; avcodec_get_frame_defaults(&esc->frame); avctx->coded_frame = &esc->frame; @@ -230,6 +212,8 @@ AVCodec ff_eightsvx_fib_decoder = { .close = eightsvx_decode_close, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, + AV_SAMPLE_FMT_NONE }, }; #endif #if CONFIG_EIGHTSVX_EXP_DECODER @@ -243,6 +227,8 @@ AVCodec ff_eightsvx_exp_decoder = { .close = eightsvx_decode_close, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, + AV_SAMPLE_FMT_NONE }, }; #endif #if CONFIG_PCM_S8_PLANAR_DECODER @@ -256,5 +242,7 @@ AVCodec ff_pcm_s8_planar_decoder = { .decode = eightsvx_decode_frame, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, + AV_SAMPLE_FMT_NONE }, }; #endif diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 852549638b..054fa0a73d 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -1268,7 +1268,10 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } -#define ADPCM_DECODER(id_, name_, long_name_) \ +static const enum AVSampleFormat sample_fmts_s16[] = { AV_SAMPLE_FMT_S16, + AV_SAMPLE_FMT_NONE }; + +#define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_) \ AVCodec ff_ ## name_ ## _decoder = { \ .name = #name_, \ .type = AVMEDIA_TYPE_AUDIO, \ @@ -1278,33 +1281,34 @@ AVCodec ff_ ## name_ ## _decoder = { \ .decode = adpcm_decode_frame, \ .capabilities = CODEC_CAP_DR1, \ .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ + .sample_fmts = sample_fmts_, \ } /* Note: Do not forget to add new entries to the Makefile as well. */ -ADPCM_DECODER(AV_CODEC_ID_ADPCM_4XM, adpcm_4xm, "ADPCM 4X Movie"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_CT, adpcm_ct, "ADPCM Creative Technology"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA, adpcm_ea, "ADPCM Electronic Arts"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_MAXIS_XA, adpcm_ea_maxis_xa, "ADPCM Electronic Arts Maxis CDROM XA"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R1, adpcm_ea_r1, "ADPCM Electronic Arts R1"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R2, adpcm_ea_r2, "ADPCM Electronic Arts R2"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3, adpcm_ea_r3, "ADPCM Electronic Arts R3"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS, adpcm_ea_xas, "ADPCM Electronic Arts XAS"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, adpcm_ima_amv, "ADPCM IMA AMV"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, adpcm_ima_apc, "ADPCM IMA CRYO APC"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3, "ADPCM IMA Duck DK3"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4, "ADPCM IMA Duck DK4"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ISS, adpcm_ima_iss, "ADPCM IMA Funcom ISS"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt, "ADPCM IMA QuickTime"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav, "ADPCM IMA WAV"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws, "ADPCM IMA Westwood"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, adpcm_ms, "ADPCM Microsoft"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4, "ADPCM Sound Blaster Pro 4-bit"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_SWF, adpcm_swf, "ADPCM Shockwave Flash"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_THP, adpcm_thp, "ADPCM Nintendo Gamecube THP"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_XA, adpcm_xa, "ADPCM CDROM XA"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha, "ADPCM Yamaha"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_4XM, sample_fmts_s16, adpcm_4xm, "ADPCM 4X Movie"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_CT, sample_fmts_s16, adpcm_ct, "ADPCM Creative Technology"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA, sample_fmts_s16, adpcm_ea, "ADPCM Electronic Arts"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_MAXIS_XA, sample_fmts_s16, adpcm_ea_maxis_xa, "ADPCM Electronic Arts Maxis CDROM XA"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R1, sample_fmts_s16, adpcm_ea_r1, "ADPCM Electronic Arts R1"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R2, sample_fmts_s16, adpcm_ea_r2, "ADPCM Electronic Arts R2"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3, sample_fmts_s16, adpcm_ea_r3, "ADPCM Electronic Arts R3"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS, sample_fmts_s16, adpcm_ea_xas, "ADPCM Electronic Arts XAS"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16, adpcm_ima_amv, "ADPCM IMA AMV"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16, adpcm_ima_apc, "ADPCM IMA CRYO APC"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK3, sample_fmts_s16, adpcm_ima_dk3, "ADPCM IMA Duck DK3"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK4, sample_fmts_s16, adpcm_ima_dk4, "ADPCM IMA Duck DK4"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_EACS, sample_fmts_s16, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_SEAD, sample_fmts_s16, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ISS, sample_fmts_s16, adpcm_ima_iss, "ADPCM IMA Funcom ISS"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT, sample_fmts_s16, adpcm_ima_qt, "ADPCM IMA QuickTime"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG, sample_fmts_s16, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WAV, sample_fmts_s16, adpcm_ima_wav, "ADPCM IMA WAV"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WS, sample_fmts_s16, adpcm_ima_ws, "ADPCM IMA Westwood"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, sample_fmts_s16, adpcm_ms, "ADPCM Microsoft"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_2, sample_fmts_s16, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_3, sample_fmts_s16, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_4, sample_fmts_s16, adpcm_sbpro_4, "ADPCM Sound Blaster Pro 4-bit"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_SWF, sample_fmts_s16, adpcm_swf, "ADPCM Shockwave Flash"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_THP, sample_fmts_s16, adpcm_thp, "ADPCM Nintendo Gamecube THP"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_XA, sample_fmts_s16, adpcm_xa, "ADPCM CDROM XA"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_YAMAHA, sample_fmts_s16, adpcm_yamaha, "ADPCM Yamaha"); diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 21080902ee..cba3dc0354 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -196,13 +196,13 @@ static av_cold int ape_decode_init(AVCodecContext *avctx) s->bps = avctx->bits_per_coded_sample; switch (s->bps) { case 8: - avctx->sample_fmt = AV_SAMPLE_FMT_U8; + avctx->sample_fmt = AV_SAMPLE_FMT_U8P; break; case 16: - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break; case 24: - avctx->sample_fmt = AV_SAMPLE_FMT_S32; + avctx->sample_fmt = AV_SAMPLE_FMT_S32P; break; default: av_log_ask_for_sample(avctx, "Unsupported bits per coded sample %d\n", @@ -830,7 +830,7 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data, uint8_t *sample8; int16_t *sample16; int32_t *sample24; - int i, ret; + int i, ch, ret; int blockstodecode; int bytes_used = 0; @@ -930,27 +930,24 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data, switch (s->bps) { case 8: - sample8 = (uint8_t *)s->frame.data[0]; - for (i = 0; i < blockstodecode; i++) { - *sample8++ = (s->decoded[0][i] + 0x80) & 0xff; - if (s->channels == 2) - *sample8++ = (s->decoded[1][i] + 0x80) & 0xff; + for (ch = 0; ch < s->channels; ch++) { + sample8 = (uint8_t *)s->frame.data[ch]; + for (i = 0; i < blockstodecode; i++) + *sample8++ = (s->decoded[ch][i] + 0x80) & 0xff; } break; case 16: - sample16 = (int16_t *)s->frame.data[0]; - for (i = 0; i < blockstodecode; i++) { - *sample16++ = s->decoded[0][i]; - if (s->channels == 2) - *sample16++ = s->decoded[1][i]; + for (ch = 0; ch < s->channels; ch++) { + sample16 = (int16_t *)s->frame.data[ch]; + for (i = 0; i < blockstodecode; i++) + *sample16++ = s->decoded[ch][i]; } break; case 24: - sample24 = (int32_t *)s->frame.data[0]; - for (i = 0; i < blockstodecode; i++) { - *sample24++ = s->decoded[0][i] << 8; - if (s->channels == 2) - *sample24++ = s->decoded[1][i] << 8; + for (ch = 0; ch < s->channels; ch++) { + sample24 = (int32_t *)s->frame.data[ch]; + for (i = 0; i < blockstodecode; i++) + *sample24++ = s->decoded[ch][i] << 8; } break; } @@ -995,5 +992,9 @@ AVCodec ff_ape_decoder = { .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1, .flush = ape_flush, .long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, + AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_S32P, + AV_SAMPLE_FMT_NONE }, .priv_class = &ape_decoder_class, }; diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 7d076bed99..b900882a7a 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -112,7 +112,6 @@ typedef struct { //@} //@{ /** data buffers */ - float *outSamples[2]; uint8_t* decoded_bytes_buffer; float tempBuf[1070]; //@} @@ -198,7 +197,7 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ } -static av_cold int init_atrac3_transforms(ATRAC3Context *q, int is_float) { +static av_cold int init_atrac3_transforms(ATRAC3Context *q) { float enc_window[256]; int i; @@ -214,7 +213,7 @@ static av_cold int init_atrac3_transforms(ATRAC3Context *q, int is_float) { } /* Initialize the MDCT transform. */ - return ff_mdct_init(&q->mdct_ctx, 9, 1, is_float ? 1.0 / 32768 : 1.0); + return ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768); } /** @@ -227,7 +226,6 @@ static av_cold int atrac3_decode_close(AVCodecContext *avctx) av_free(q->pUnits); av_free(q->decoded_bytes_buffer); - av_freep(&q->outSamples[0]); ff_mdct_end(&q->mdct_ctx); @@ -838,8 +836,6 @@ static int atrac3_decode_frame(AVCodecContext *avctx, void *data, ATRAC3Context *q = avctx->priv_data; int result; const uint8_t* databuf; - float *samples_flt; - int16_t *samples_s16; if (buf_size < avctx->block_align) { av_log(avctx, AV_LOG_ERROR, @@ -853,8 +849,6 @@ static int atrac3_decode_frame(AVCodecContext *avctx, void *data, av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return result; } - samples_flt = (float *)q->frame.data[0]; - samples_s16 = (int16_t *)q->frame.data[0]; /* Check if we need to descramble and what buffer to pass on. */ if (q->scrambled_stream) { @@ -864,27 +858,13 @@ static int atrac3_decode_frame(AVCodecContext *avctx, void *data, databuf = buf; } - if (q->channels == 1 && avctx->sample_fmt == AV_SAMPLE_FMT_FLT) - result = decodeFrame(q, databuf, &samples_flt); - else - result = decodeFrame(q, databuf, q->outSamples); + result = decodeFrame(q, databuf, (float **)q->frame.extended_data); if (result != 0) { av_log(NULL,AV_LOG_ERROR,"Frame decoding error!\n"); return result; } - /* interleave */ - if (q->channels == 2 && avctx->sample_fmt == AV_SAMPLE_FMT_FLT) { - q->fmt_conv.float_interleave(samples_flt, - (const float **)q->outSamples, - SAMPLES_PER_FRAME, 2); - } else if (avctx->sample_fmt == AV_SAMPLE_FMT_S16) { - q->fmt_conv.float_to_int16_interleave(samples_s16, - (const float **)q->outSamples, - SAMPLES_PER_FRAME, q->channels); - } - *got_frame_ptr = 1; *(AVFrame *)data = q->frame; @@ -1006,12 +986,9 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) vlcs_initialized = 1; } - if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) - avctx->sample_fmt = AV_SAMPLE_FMT_FLT; - else - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; - if ((ret = init_atrac3_transforms(q, avctx->sample_fmt == AV_SAMPLE_FMT_FLT))) { + if ((ret = init_atrac3_transforms(q))) { av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n"); av_freep(&q->decoded_bytes_buffer); return ret; @@ -1049,15 +1026,6 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); } - if (avctx->channels > 1 || avctx->sample_fmt == AV_SAMPLE_FMT_S16) { - q->outSamples[0] = av_mallocz(SAMPLES_PER_FRAME * avctx->channels * sizeof(*q->outSamples[0])); - q->outSamples[1] = q->outSamples[0] + SAMPLES_PER_FRAME; - if (!q->outSamples[0]) { - atrac3_decode_close(avctx); - return AVERROR(ENOMEM); - } - } - avcodec_get_frame_defaults(&q->frame); avctx->coded_frame = &q->frame; @@ -1076,4 +1044,6 @@ AVCodec ff_atrac3_decoder = .decode = atrac3_decode_frame, .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_NONE }, }; diff --git a/libavcodec/cook.c b/libavcodec/cook.c index cca97e3046..b4d1a37ca1 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -119,9 +119,10 @@ typedef struct cook { void (*interpolate)(struct cook *q, float *buffer, int gain_index, int gain_index_next); - void (*saturate_output)(struct cook *q, int chan, float *out); + void (*saturate_output)(struct cook *q, float *out); AVCodecContext* avctx; + DSPContext dsp; AVFrame frame; GetBitContext gb; /* stream data */ @@ -887,18 +888,15 @@ static inline void decode_bytes_and_gain(COOKContext *q, COOKSubpacket *p, * Saturate the output signal and interleave. * * @param q pointer to the COOKContext - * @param chan channel to saturate * @param out pointer to the output vector */ -static void saturate_output_float(COOKContext *q, int chan, float *out) +static void saturate_output_float(COOKContext *q, float *out) { - int j; - float *output = q->mono_mdct_output + q->samples_per_channel; - for (j = 0; j < q->samples_per_channel; j++) { - out[chan + q->nb_channels * j] = av_clipf(output[j], -1.0, 1.0); - } + q->dsp.vector_clipf(out, q->mono_mdct_output + q->samples_per_channel, + -1.0f, 1.0f, FFALIGN(q->samples_per_channel, 8)); } + /** * Final part of subpacket decoding: * Apply modulated lapped transform, gain compensation, @@ -909,15 +907,14 @@ static void saturate_output_float(COOKContext *q, int chan, float *out) * @param gains_ptr array of current/prev gain pointers * @param previous_buffer pointer to the previous buffer to be used for overlapping * @param out pointer to the output buffer - * @param chan 0: left or single channel, 1: right channel */ static inline void mlt_compensate_output(COOKContext *q, float *decode_buffer, cook_gains *gains_ptr, float *previous_buffer, - float *out, int chan) + float *out) { imlt_gain(q, decode_buffer, gains_ptr, previous_buffer); if (out) - q->saturate_output(q, chan, out); + q->saturate_output(q, out); } @@ -930,7 +927,7 @@ static inline void mlt_compensate_output(COOKContext *q, float *decode_buffer, * @param outbuffer pointer to the outbuffer */ static int decode_subpacket(COOKContext *q, COOKSubpacket *p, - const uint8_t *inbuffer, float *outbuffer) + const uint8_t *inbuffer, float **outbuffer) { int sub_packet_size = p->size; int res; @@ -953,15 +950,18 @@ static int decode_subpacket(COOKContext *q, COOKSubpacket *p, } mlt_compensate_output(q, q->decode_buffer_1, &p->gains1, - p->mono_previous_buffer1, outbuffer, p->ch_idx); + p->mono_previous_buffer1, + outbuffer ? outbuffer[p->ch_idx] : NULL); if (p->num_channels == 2) if (p->joint_stereo) mlt_compensate_output(q, q->decode_buffer_2, &p->gains1, - p->mono_previous_buffer2, outbuffer, p->ch_idx + 1); + p->mono_previous_buffer2, + outbuffer ? outbuffer[p->ch_idx + 1] : NULL); else mlt_compensate_output(q, q->decode_buffer_2, &p->gains2, - p->mono_previous_buffer2, outbuffer, p->ch_idx + 1); + p->mono_previous_buffer2, + outbuffer ? outbuffer[p->ch_idx + 1] : NULL); return 0; } @@ -978,7 +978,7 @@ static int cook_decode_frame(AVCodecContext *avctx, void *data, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; COOKContext *q = avctx->priv_data; - float *samples = NULL; + float **samples = NULL; int i, ret; int offset = 0; int chidx = 0; @@ -993,7 +993,7 @@ static int cook_decode_frame(AVCodecContext *avctx, void *data, av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - samples = (float *) q->frame.data[0]; + samples = (float **)q->frame.extended_data; } /* estimate subpacket sizes */ @@ -1110,6 +1110,8 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) /* Initialize RNG. */ av_lfg_init(&q->random_state, 0); + ff_dsputil_init(&q->dsp, avctx); + while (edata_ptr < edata_ptr_end) { /* 8 for mono, 16 for stereo, ? for multichannel Swap to right endianness so we don't need to care later on. */ @@ -1290,7 +1292,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) return AVERROR_PATCHWELCOME; } - avctx->sample_fmt = AV_SAMPLE_FMT_FLT; + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; if (channel_mask) avctx->channel_layout = channel_mask; else @@ -1315,4 +1317,6 @@ AVCodec ff_cook_decoder = { .decode = cook_decode_frame, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Cook / Cooker / Gecko (RealAudio G2)"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_NONE }, }; diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index 4e9f957660..4d5e1152f2 100644 --- a/libavcodec/dcadec.c +++ b/libavcodec/dcadec.c @@ -417,11 +417,9 @@ typedef struct { DECLARE_ALIGNED(32, float, raXin)[32]; int output; ///< type of output - float scale_bias; ///< output scale DECLARE_ALIGNED(32, float, subband_samples)[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8]; - DECLARE_ALIGNED(32, float, samples)[(DCA_PRIM_CHANNELS_MAX + 1) * 256]; - const float *samples_chanptr[DCA_PRIM_CHANNELS_MAX + 1]; + float *samples_chanptr[DCA_PRIM_CHANNELS_MAX + 1]; uint8_t dca_buffer[DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE + DCA_BUFFER_PADDING_SIZE]; int dca_buffer_size; ///< how much data is in the dca_buffer @@ -1169,20 +1167,20 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select, } /* downmixing routines */ -#define MIX_REAR1(samples, si1, rs, coef) \ - samples[i] += samples[si1] * coef[rs][0]; \ - samples[i+256] += samples[si1] * coef[rs][1]; +#define MIX_REAR1(samples, s1, rs, coef) \ + samples[0][i] += samples[s1][i] * coef[rs][0]; \ + samples[1][i] += samples[s1][i] * coef[rs][1]; -#define MIX_REAR2(samples, si1, si2, rs, coef) \ - samples[i] += samples[si1] * coef[rs][0] + samples[si2] * coef[rs + 1][0]; \ - samples[i+256] += samples[si1] * coef[rs][1] + samples[si2] * coef[rs + 1][1]; +#define MIX_REAR2(samples, s1, s2, rs, coef) \ + samples[0][i] += samples[s1][i] * coef[rs][0] + samples[s2][i] * coef[rs + 1][0]; \ + samples[1][i] += samples[s1][i] * coef[rs][1] + samples[s2][i] * coef[rs + 1][1]; #define MIX_FRONT3(samples, coef) \ - t = samples[i + c]; \ - u = samples[i + l]; \ - v = samples[i + r]; \ - samples[i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \ - samples[i+256] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1]; + t = samples[c][i]; \ + u = samples[l][i]; \ + v = samples[r][i]; \ + samples[0][i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \ + samples[1][i] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1]; #define DOWNMIX_TO_STEREO(op1, op2) \ for (i = 0; i < 256; i++) { \ @@ -1190,7 +1188,7 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select, op2 \ } -static void dca_downmix(float *samples, int srcfmt, +static void dca_downmix(float **samples, int srcfmt, int downmix_coef[DCA_PRIM_CHANNELS_MAX][2], const int8_t *channel_mapping) { @@ -1215,36 +1213,36 @@ static void dca_downmix(float *samples, int srcfmt, case DCA_STEREO: break; case DCA_3F: - c = channel_mapping[0] * 256; - l = channel_mapping[1] * 256; - r = channel_mapping[2] * 256; + c = channel_mapping[0]; + l = channel_mapping[1]; + r = channel_mapping[2]; DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), ); break; case DCA_2F1R: - s = channel_mapping[2] * 256; - DOWNMIX_TO_STEREO(MIX_REAR1(samples, i + s, 2, coef), ); + s = channel_mapping[2]; + DOWNMIX_TO_STEREO(MIX_REAR1(samples, s, 2, coef), ); break; case DCA_3F1R: - c = channel_mapping[0] * 256; - l = channel_mapping[1] * 256; - r = channel_mapping[2] * 256; - s = channel_mapping[3] * 256; + c = channel_mapping[0]; + l = channel_mapping[1]; + r = channel_mapping[2]; + s = channel_mapping[3]; DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), - MIX_REAR1(samples, i + s, 3, coef)); + MIX_REAR1(samples, s, 3, coef)); break; case DCA_2F2R: - sl = channel_mapping[2] * 256; - sr = channel_mapping[3] * 256; - DOWNMIX_TO_STEREO(MIX_REAR2(samples, i + sl, i + sr, 2, coef), ); + sl = channel_mapping[2]; + sr = channel_mapping[3]; + DOWNMIX_TO_STEREO(MIX_REAR2(samples, sl, sr, 2, coef), ); break; case DCA_3F2R: - c = channel_mapping[0] * 256; - l = channel_mapping[1] * 256; - r = channel_mapping[2] * 256; - sl = channel_mapping[3] * 256; - sr = channel_mapping[4] * 256; + c = channel_mapping[0]; + l = channel_mapping[1]; + r = channel_mapping[2]; + sl = channel_mapping[3]; + sr = channel_mapping[4]; DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), - MIX_REAR2(samples, i + sl, i + sr, 3, coef)); + MIX_REAR2(samples, sl, sr, 3, coef)); break; } } @@ -1441,21 +1439,21 @@ static int dca_filter_channels(DCAContext *s, int block_index) /* static float pcm_to_double[8] = { 32768.0, 32768.0, 524288.0, 524288.0, 0, 8388608.0, 8388608.0 };*/ qmf_32_subbands(s, k, subband_samples[k], - &s->samples[256 * s->channel_order_tab[k]], - M_SQRT1_2 * s->scale_bias /* pcm_to_double[s->source_pcm_res] */); + s->samples_chanptr[s->channel_order_tab[k]], + M_SQRT1_2 / 32768.0 /* pcm_to_double[s->source_pcm_res] */); } /* Down mixing */ if (s->avctx->request_channels == 2 && s->prim_channels > 2) { - dca_downmix(s->samples, s->amode, s->downmix_coef, s->channel_order_tab); + dca_downmix(s->samples_chanptr, s->amode, s->downmix_coef, s->channel_order_tab); } /* Generate LFE samples for this subsubframe FIXME!!! */ if (s->output & DCA_LFE) { lfe_interpolation_fir(s, s->lfe, 2 * s->lfe, s->lfe_data + 2 * s->lfe * (block_index + 4), - &s->samples[256 * s->lfe_index], - (1.0 / 256.0) * s->scale_bias); + s->samples_chanptr[s->lfe_index], + 1.0 / (256.0 * 32768.0)); /* Outputs 20bits pcm samples */ } @@ -2067,10 +2065,9 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, int lfe_samples; int num_core_channels = 0; int i, ret; - float *samples_flt; + float **samples_flt; float *src_chan; float *dst_chan; - int16_t *samples_s16; DCAContext *s = avctx->priv_data; int core_ss_end; int channels; @@ -2081,7 +2078,6 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, int lavc; int posn; int j, k; - int ch; int endch; s->xch_present = 0; @@ -2342,19 +2338,23 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - samples_flt = (float *) s->frame.data[0]; - samples_s16 = (int16_t *) s->frame.data[0]; + samples_flt = (float **) s->frame.extended_data; /* filter to get final output */ for (i = 0; i < (s->sample_blocks / 8); i++) { + int ch; + + for (ch = 0; ch < channels; ch++) + s->samples_chanptr[ch] = samples_flt[ch] + i * 256; + dca_filter_channels(s, i); /* If this was marked as a DTS-ES stream we need to subtract back- */ /* channel from SL & SR to remove matrixed back-channel signal */ if ((s->source_pcm_res & 1) && s->xch_present) { - float *back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256; - float *lt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256; - float *rt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256; + float *back_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel]]; + float *lt_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel - 2]]; + float *rt_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel - 1]]; s->fdsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256); s->fdsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256); } @@ -2370,12 +2370,12 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, /* undo downmix */ for (j = ch; j < endch; j++) { if (mask & (1 << j)) { /* this channel has been mixed-out */ - src_chan = s->samples + s->channel_order_tab[j] * 256; + src_chan = s->samples_chanptr[s->channel_order_tab[j]]; for (k = 0; k < endch; k++) { achan = s->channel_order_tab[k]; scale = s->xxch_dmix_coeff[j][k]; if (scale != 0.0) { - dst_chan = s->samples + achan * 256; + dst_chan = s->samples_chanptr[achan]; s->fdsp.vector_fmac_scalar(dst_chan, src_chan, -scale, 256); } @@ -2388,14 +2388,14 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, scale = s->xxch_dmix_sf[chset]; for (j = 0; j < ch; j++) { - src_chan = s->samples + s->channel_order_tab[j] * 256; + src_chan = s->samples_chanptr[s->channel_order_tab[j]]; for (k = 0; k < 256; k++) src_chan[k] *= scale; } /* LFE channel is always part of core, scale if it exists */ if (s->lfe) { - src_chan = s->samples + s->lfe_index * 256; + src_chan = s->samples_chanptr[s->lfe_index]; for (k = 0; k < 256; k++) src_chan[k] *= scale; } @@ -2405,17 +2405,6 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, } } - - if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) { - s->fmt_conv.float_interleave(samples_flt, s->samples_chanptr, 256, - channels); - samples_flt += 256 * channels; - } else { - s->fmt_conv.float_to_int16_interleave(samples_s16, - s->samples_chanptr, 256, - channels); - samples_s16 += 256 * channels; - } } /* update lfe history */ @@ -2440,7 +2429,6 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, static av_cold int dca_decode_init(AVCodecContext *avctx) { DCAContext *s = avctx->priv_data; - int i; s->avctx = avctx; dca_init_vlcs(); @@ -2451,16 +2439,7 @@ static av_cold int dca_decode_init(AVCodecContext *avctx) ff_dcadsp_init(&s->dcadsp); ff_fmt_convert_init(&s->fmt_conv, avctx); - for (i = 0; i < DCA_PRIM_CHANNELS_MAX + 1; i++) - s->samples_chanptr[i] = s->samples + i * 256; - - if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) { - avctx->sample_fmt = AV_SAMPLE_FMT_FLT; - s->scale_bias = 1.0 / 32768.0; - } else { - avctx->sample_fmt = AV_SAMPLE_FMT_S16; - s->scale_bias = 1.0; - } + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; /* allow downmixing to stereo */ if (avctx->channels > 0 && avctx->request_channels < avctx->channels && @@ -2500,8 +2479,7 @@ AVCodec ff_dca_decoder = { .close = dca_decode_end, .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"), .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1, - .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, - AV_SAMPLE_FMT_S16, + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .profiles = NULL_IF_CONFIG_SMALL(profiles), }; diff --git a/libavcodec/imc.c b/libavcodec/imc.c index d12c7551e9..9da769ba38 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -242,7 +242,7 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) return ret; } ff_dsputil_init(&q->dsp, avctx); - avctx->sample_fmt = AV_SAMPLE_FMT_FLT; + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; @@ -662,7 +662,7 @@ static void imc_imdct256(IMCContext *q, IMCChannel *chctx, int channels) int i; float re, im; float *dst1 = q->out_samples; - float *dst2 = q->out_samples + (COEFFS - 1) * channels; + float *dst2 = q->out_samples + (COEFFS - 1); /* prerotation */ for (i = 0; i < COEFFS / 2; i++) { @@ -684,8 +684,8 @@ static void imc_imdct256(IMCContext *q, IMCChannel *chctx, int channels) + (q->mdct_sine_window[i * 2] * re); *dst2 = (q->mdct_sine_window[i * 2] * chctx->last_fft_im[i]) - (q->mdct_sine_window[COEFFS - 1 - i * 2] * re); - dst1 += channels * 2; - dst2 -= channels * 2; + dst1 += 2; + dst2 -= 2; chctx->last_fft_im[i] = im; } } @@ -786,7 +786,6 @@ static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch) chctx->decoder_reset = 1; if (chctx->decoder_reset) { - memset(q->out_samples, 0, COEFFS * sizeof(*q->out_samples)); for (i = 0; i < BANDS; i++) chctx->old_floor[i] = 1.0; for (i = 0; i < COEFFS; i++) @@ -945,7 +944,7 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, } for (i = 0; i < avctx->channels; i++) { - q->out_samples = (float*)q->frame.data[0] + i; + q->out_samples = (float *)q->frame.extended_data[i]; q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2); @@ -958,15 +957,8 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, } if (avctx->channels == 2) { - float *src = (float*)q->frame.data[0], t1, t2; - - for (i = 0; i < COEFFS; i++) { - t1 = src[0]; - t2 = src[1]; - src[0] = t1 + t2; - src[1] = t1 - t2; - src += 2; - } + q->dsp.butterflies_float((float *)q->frame.extended_data[0], + (float *)q->frame.extended_data[1], COEFFS); } *got_frame_ptr = 1; @@ -996,6 +988,8 @@ AVCodec ff_imc_decoder = { .decode = imc_decode_frame, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_NONE }, }; #endif #if CONFIG_IAC_DECODER @@ -1009,5 +1003,7 @@ AVCodec ff_iac_decoder = { .decode = imc_decode_frame, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("IAC (Indeo Audio Coder)"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_NONE }, }; #endif diff --git a/libavcodec/mpc.c b/libavcodec/mpc.c index 7ef437c4dc..d064924b91 100644 --- a/libavcodec/mpc.c +++ b/libavcodec/mpc.c @@ -43,28 +43,24 @@ void ff_mpc_init(void) /** * Process decoded Musepack data and produce PCM */ -static void mpc_synth(MPCContext *c, int16_t *out, int channels) +static void mpc_synth(MPCContext *c, int16_t **out, int channels) { int dither_state = 0; int i, ch; - OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE], *samples_ptr; for(ch = 0; ch < channels; ch++){ - samples_ptr = samples + ch; for(i = 0; i < SAMPLES_PER_BAND; i++) { ff_mpa_synth_filter_fixed(&c->mpadsp, c->synth_buf[ch], &(c->synth_buf_offset[ch]), ff_mpa_synth_window_fixed, &dither_state, - samples_ptr, channels, + out[ch] + 32 * i, 1, c->sb_samples[ch][i]); - samples_ptr += 32 * channels; } } - for(i = 0; i < MPC_FRAME_SIZE*channels; i++) - *out++=samples[i]; } -void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int channels) +void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, int16_t **out, + int channels) { int i, j, ch; Band *bands = c->bands; @@ -100,5 +96,5 @@ void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int ch } } - mpc_synth(c, data, channels); + mpc_synth(c, out, channels); } diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h index 8b4deef689..34ef263b40 100644 --- a/libavcodec/mpc.h +++ b/libavcodec/mpc.h @@ -73,6 +73,6 @@ typedef struct { } MPCContext; void ff_mpc_init(void); -void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, void *dst, int channels); +void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, int16_t **out, int channels); #endif /* AVCODEC_MPC_H */ diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index cab4eee03d..9f3cf6c828 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -90,7 +90,7 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) c->IS, c->MSS, c->gapless, c->lastframelen, c->maxbands); c->frames_to_skip = 0; - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + avctx->sample_fmt = AV_SAMPLE_FMT_S16P; avctx->channel_layout = AV_CH_LAYOUT_STEREO; avcodec_get_frame_defaults(&c->frame); @@ -293,7 +293,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data, for(ch = 0; ch < 2; ch++) idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off); - ff_mpc_dequantize_and_synth(c, mb, c->frame.data[0], 2); + ff_mpc_dequantize_and_synth(c, mb, (int16_t **)c->frame.extended_data, 2); if(last_frame) c->frame.nb_samples = c->lastframelen; @@ -342,4 +342,6 @@ AVCodec ff_mpc7_decoder = { .flush = mpc7_decode_flush, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_NONE }, }; diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index cb30b2c28b..64d19193b0 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -139,7 +139,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) c->MSS = get_bits1(&gb); c->frames = 1 << (get_bits(&gb, 3) * 2); - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + avctx->sample_fmt = AV_SAMPLE_FMT_S16P; avctx->channel_layout = (channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; avctx->channels = channels; @@ -413,7 +413,8 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data, } } - ff_mpc_dequantize_and_synth(c, maxband - 1, c->frame.data[0], + ff_mpc_dequantize_and_synth(c, maxband - 1, + (int16_t **)c->frame.extended_data, avctx->channels); c->cur_frame++; @@ -446,4 +447,6 @@ AVCodec ff_mpc8_decoder = { .flush = mpc8_decode_flush, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_NONE }, }; diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c index 6866f79609..3244424f74 100644 --- a/libavcodec/ralf.c +++ b/libavcodec/ralf.c @@ -149,7 +149,7 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->sample_rate, avctx->channels); return AVERROR_INVALIDDATA; } - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + avctx->sample_fmt = AV_SAMPLE_FMT_S16P; avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; @@ -338,7 +338,8 @@ static void apply_lpc(RALFContext *ctx, int ch, int length, int bits) } } -static int decode_block(AVCodecContext *avctx, GetBitContext *gb, int16_t *dst) +static int decode_block(AVCodecContext *avctx, GetBitContext *gb, + int16_t *dst0, int16_t *dst1) { RALFContext *ctx = avctx->priv_data; int len, ch, ret; @@ -382,35 +383,35 @@ static int decode_block(AVCodecContext *avctx, GetBitContext *gb, int16_t *dst) switch (dmode) { case 0: for (i = 0; i < len; i++) - *dst++ = ch0[i] + ctx->bias[0]; + dst0[i] = ch0[i] + ctx->bias[0]; break; case 1: for (i = 0; i < len; i++) { - *dst++ = ch0[i] + ctx->bias[0]; - *dst++ = ch1[i] + ctx->bias[1]; + dst0[i] = ch0[i] + ctx->bias[0]; + dst1[i] = ch1[i] + ctx->bias[1]; } break; case 2: for (i = 0; i < len; i++) { ch0[i] += ctx->bias[0]; - *dst++ = ch0[i]; - *dst++ = ch0[i] - (ch1[i] + ctx->bias[1]); + dst0[i] = ch0[i]; + dst1[i] = ch0[i] - (ch1[i] + ctx->bias[1]); } break; case 3: for (i = 0; i < len; i++) { t = ch0[i] + ctx->bias[0]; t2 = ch1[i] + ctx->bias[1]; - *dst++ = t + t2; - *dst++ = t; + dst0[i] = t + t2; + dst1[i] = t; } break; case 4: for (i = 0; i < len; i++) { t = ch1[i] + ctx->bias[1]; t2 = ((ch0[i] + ctx->bias[0]) << 1) | (t & 1); - *dst++ = (t2 + t) / 2; - *dst++ = (t2 - t) / 2; + dst0[i] = (t2 + t) / 2; + dst1[i] = (t2 - t) / 2; } break; } @@ -424,7 +425,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { RALFContext *ctx = avctx->priv_data; - int16_t *samples; + int16_t *samples0; + int16_t *samples1; int ret; GetBitContext gb; int table_size, table_bytes, i; @@ -465,7 +467,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, av_log(avctx, AV_LOG_ERROR, "Me fail get_buffer()? That's unpossible!\n"); return ret; } - samples = (int16_t*)ctx->frame.data[0]; + samples0 = (int16_t *)ctx->frame.data[0]; + samples1 = (int16_t *)ctx->frame.data[1]; if (src_size < 5) { av_log(avctx, AV_LOG_ERROR, "too short packets are too short!\n"); @@ -498,8 +501,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, break; } init_get_bits(&gb, block_pointer, ctx->block_size[i] * 8); - if (decode_block(avctx, &gb, samples + ctx->sample_offset - * avctx->channels) < 0) { + if (decode_block(avctx, &gb, samples0 + ctx->sample_offset, + samples1 + ctx->sample_offset) < 0) { av_log(avctx, AV_LOG_ERROR, "Sir, I got carsick in your office. Not decoding the rest of packet.\n"); break; } @@ -533,4 +536,6 @@ AVCodec ff_ralf_decoder = { .flush = decode_flush, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("RealAudio Lossless"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_NONE }, }; diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index 070f498cae..f47f4c30f1 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -666,7 +666,7 @@ static void imdct_and_window(TwinContext *tctx, enum FrameType ftype, int wtype, } static void imdct_output(TwinContext *tctx, enum FrameType ftype, int wtype, - float *out) + float **out) { const ModeTab *mtab = tctx->mtab; int size1, size2; @@ -685,24 +685,15 @@ static void imdct_output(TwinContext *tctx, enum FrameType ftype, int wtype, size2 = tctx->last_block_pos[0]; size1 = mtab->size - size2; - if (tctx->avctx->channels == 2) { - tctx->dsp.butterflies_float_interleave(out, prev_buf, - &prev_buf[2*mtab->size], - size1); - - out += 2 * size1; - - tctx->dsp.butterflies_float_interleave(out, tctx->curr_frame, - &tctx->curr_frame[2*mtab->size], - size2); - } else { - memcpy(out, prev_buf, size1 * sizeof(*out)); - out += size1; + memcpy(&out[0][0 ], prev_buf, size1 * sizeof(out[0][0])); + memcpy(&out[0][size1], tctx->curr_frame, size2 * sizeof(out[0][0])); - memcpy(out, tctx->curr_frame, size2 * sizeof(*out)); + if (tctx->avctx->channels == 2) { + memcpy(&out[1][0], &prev_buf[2*mtab->size], size1 * sizeof(out[1][0])); + memcpy(&out[1][size1], &tctx->curr_frame[2*mtab->size], size2 * sizeof(out[1][0])); + tctx->dsp.butterflies_float(out[0], out[1], mtab->size); } - } static void dec_bark_env(TwinContext *tctx, const uint8_t *in, int use_hist, @@ -825,7 +816,7 @@ static int twin_decode_frame(AVCodecContext * avctx, void *data, TwinContext *tctx = avctx->priv_data; GetBitContext gb; const ModeTab *mtab = tctx->mtab; - float *out = NULL; + float **out = NULL; enum FrameType ftype; int window_type, ret; static const enum FrameType wtype_to_ftype_table[] = { @@ -846,7 +837,7 @@ static int twin_decode_frame(AVCodecContext * avctx, void *data, av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - out = (float *)tctx->frame.data[0]; + out = (float **)tctx->frame.extended_data; } init_get_bits(&gb, buf, buf_size * 8); @@ -1119,7 +1110,7 @@ static av_cold int twin_decode_init(AVCodecContext *avctx) int isampf, ibps; tctx->avctx = avctx; - avctx->sample_fmt = AV_SAMPLE_FMT_FLT; + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; if (!avctx->extradata || avctx->extradata_size < 12) { av_log(avctx, AV_LOG_ERROR, "Missing or incomplete extradata\n"); @@ -1184,4 +1175,6 @@ AVCodec ff_twinvq_decoder = { .decode = twin_decode_frame, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_NONE }, }; |