* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavutil/audioconvert.h"
+#include "libavutil/channel_layout.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "dsputil.h"
#include "get_bits.h"
+#include "internal.h"
#include "truespeech_data.h"
/**
* TrueSpeech decoder context
*/
typedef struct {
- AVFrame frame;
DSPContext dsp;
/* input data */
DECLARE_ALIGNED(16, uint8_t, buffer)[32];
if (avctx->channels != 1) {
av_log_ask_for_sample(avctx, "Unsupported channel count: %d\n", avctx->channels);
- return AVERROR(EINVAL);
+ return AVERROR_PATCHWELCOME;
}
avctx->channel_layout = AV_CH_LAYOUT_MONO;
ff_dsputil_init(&c->dsp, avctx);
- avcodec_get_frame_defaults(&c->frame);
- avctx->coded_frame = &c->frame;
-
return 0;
}
static int truespeech_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
+ AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
TSContext *c = avctx->priv_data;
}
/* get output buffer */
- c->frame.nb_samples = iterations * 240;
- if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
+ frame->nb_samples = iterations * 240;
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
- samples = (int16_t *)c->frame.data[0];
+ samples = (int16_t *)frame->data[0];
memset(samples, 0, iterations * 240 * sizeof(*samples));
truespeech_save_prevvec(c);
}
- *got_frame_ptr = 1;
- *(AVFrame *)data = c->frame;
+ *got_frame_ptr = 1;
return buf_size;
}