#include "libavutil/avassert.h"
#include "avcodec.h"
+#include "libavutil/common.h"
/** decoder context */
typedef struct EightSvxContext {
#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.
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 */
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);
}
*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 ?
}
switch (avctx->codec->id) {
- case CODEC_ID_8SVX_FIB: esc->table = fibonacci; break;
- case CODEC_ID_8SVX_EXP: esc->table = exponential; break;
- case CODEC_ID_PCM_S8_PLANAR:
- case CODEC_ID_8SVX_RAW: esc->table = NULL; break;
+ case AV_CODEC_ID_8SVX_FIB: esc->table = fibonacci; break;
+ case AV_CODEC_ID_8SVX_EXP: esc->table = exponential; break;
+ case AV_CODEC_ID_PCM_S8_PLANAR:
+ case AV_CODEC_ID_8SVX_RAW: esc->table = NULL; break;
default:
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;
AVCodec ff_eightsvx_fib_decoder = {
.name = "8svx_fib",
.type = AVMEDIA_TYPE_AUDIO,
- .id = CODEC_ID_8SVX_FIB,
+ .id = AV_CODEC_ID_8SVX_FIB,
.priv_data_size = sizeof (EightSvxContext),
.init = eightsvx_decode_init,
.decode = eightsvx_decode_frame,
.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
AVCodec ff_eightsvx_exp_decoder = {
.name = "8svx_exp",
.type = AVMEDIA_TYPE_AUDIO,
- .id = CODEC_ID_8SVX_EXP,
+ .id = AV_CODEC_ID_8SVX_EXP,
.priv_data_size = sizeof (EightSvxContext),
.init = eightsvx_decode_init,
.decode = eightsvx_decode_frame,
.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
AVCodec ff_pcm_s8_planar_decoder = {
.name = "pcm_s8_planar",
.type = AVMEDIA_TYPE_AUDIO,
- .id = CODEC_ID_PCM_S8_PLANAR,
+ .id = AV_CODEC_ID_PCM_S8_PLANAR,
.priv_data_size = sizeof(EightSvxContext),
.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"),
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
+ AV_SAMPLE_FMT_NONE },
};
#endif