* RealAudio 2.0 (28.8K)
* Copyright (c) 2003 the ffmpeg project
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define RA288_BLOCKS_PER_FRAME 32
typedef struct {
+ AVFrame frame;
DSPContext dsp;
DECLARE_ALIGNED(16, float, sp_lpc)[FFALIGN(36, 8)]; ///< LPC coefficients for speech data (spec: A)
DECLARE_ALIGNED(16, float, gain_lpc)[FFALIGN(10, 8)]; ///< LPC coefficients for gain (spec: GB)
RA288Context *ractx = avctx->priv_data;
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
dsputil_init(&ractx->dsp, avctx);
+
+ avcodec_get_frame_defaults(&ractx->frame);
+ avctx->coded_frame = &ractx->frame;
+
return 0;
}
for (i=0; i < 5; i++)
buffer[i] = codetable[cb_coef][i] * sumsum;
- sum = ff_dot_productf(buffer, buffer, 5) * ((1<<24)/5.);
+ sum = ff_dot_productf(buffer, buffer, 5);
- sum = FFMAX(sum, 1);
+ sum = FFMAX(sum, 5. / (1<<24));
/* shift and store */
memmove(gain_block, gain_block + 1, 9 * sizeof(*gain_block));
- gain_block[9] = 10 * log10(sum) - 32;
+ gain_block[9] = 10 * log10(sum) + (10*log10(((1<<24)/5.)) - 32);
ff_celp_lp_synthesis_filterf(block, ractx->sp_lpc, buffer, 5, 36);
}
int i;
float buffer1[MAX_BACKWARD_FILTER_ORDER + 1];
float buffer2[MAX_BACKWARD_FILTER_ORDER + 1];
- LOCAL_ALIGNED_16(float, work)[FFALIGN(MAX_BACKWARD_FILTER_ORDER +
- MAX_BACKWARD_FILTER_LEN +
- MAX_BACKWARD_FILTER_NONREC, 8)];
+ LOCAL_ALIGNED_16(float, work, [FFALIGN(MAX_BACKWARD_FILTER_ORDER +
+ MAX_BACKWARD_FILTER_LEN +
+ MAX_BACKWARD_FILTER_NONREC, 8)]);
ractx->dsp.vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 8));
}
static int ra288_decode_frame(AVCodecContext * avctx, void *data,
- int *data_size, AVPacket *avpkt)
+ int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
- float *out = data;
- int i, out_size;
+ float *out;
+ int i, ret;
RA288Context *ractx = avctx->priv_data;
GetBitContext gb;
return AVERROR_INVALIDDATA;
}
- out_size = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME *
- av_get_bytes_per_sample(avctx->sample_fmt);
- if (*data_size < out_size) {
- av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
- return AVERROR(EINVAL);
+ /* get output buffer */
+ ractx->frame.nb_samples = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME;
+ if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
}
+ out = (float *)ractx->frame.data[0];
init_get_bits(&gb, buf, avctx->block_align * 8);
}
}
- *data_size = out_size;
+ *got_frame_ptr = 1;
+ *(AVFrame *)data = ractx->frame;
+
return avctx->block_align;
}
.priv_data_size = sizeof(RA288Context),
.init = ra288_decode_init,
.decode = ra288_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"),
};