/** decoder context */
typedef struct EightSvxContext {
+ AVFrame frame;
const int8_t *table;
/* buffer used to store the whole audio decoded/interleaved chunk,
return dst-dst0;
}
-static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
- AVPacket *avpkt)
+/** decode a frame */
+static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
{
EightSvxContext *esc = avctx->priv_data;
- int out_data_size, n;
+ int n, out_data_size, ret;
+ uint8_t *out_date;
uint8_t *src, *dst;
/* decode and interleave the first packet */
memcpy(esc->samples, deinterleaved_samples, esc->samples_size);
}
- /* return single packed with fixed size */
- out_data_size = FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx);
- if (*data_size < out_data_size) {
- av_log(avctx, AV_LOG_ERROR, "Provided buffer with size %d is too small.\n", *data_size);
- return AVERROR(EINVAL);
+ /* get output buffer */
+ esc->frame.nb_samples = (FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx) +avctx->channels-1) / avctx->channels;
+ if ((ret = avctx->get_buffer(avctx, &esc->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
}
- *data_size = out_data_size;
- dst = 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;
- esc->samples_idx += *data_size;
+ esc->samples_idx += out_data_size;
return avctx->codec->id == CODEC_ID_8SVX_FIB || avctx->codec->id == CODEC_ID_8SVX_EXP ?
(avctx->frame_number == 0)*2 + out_data_size / 2 :
}
avctx->sample_fmt = AV_SAMPLE_FMT_U8;
+ avcodec_get_frame_defaults(&esc->frame);
+ avctx->coded_frame = &esc->frame;
+
return 0;
}
.init = eightsvx_decode_init,
.decode = eightsvx_decode_frame,
.close = eightsvx_decode_close,
+ .capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"),
};
.init = eightsvx_decode_init,
.decode = eightsvx_decode_frame,
.close = eightsvx_decode_close,
+ .capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"),
};
.init = eightsvx_decode_init,
.close = eightsvx_decode_close,
.decode = eightsvx_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"),
};