8svx: convert to new channel layout API

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
release/5.1
Anton Khirnov 12 years ago committed by James Almer
parent 548aeb9383
commit 2350a50bed
  1. 19
      libavcodec/8svx.c

@ -88,38 +88,39 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
{ {
EightSvxContext *esc = avctx->priv_data; EightSvxContext *esc = avctx->priv_data;
AVFrame *frame = data; AVFrame *frame = data;
int channels = avctx->ch_layout.nb_channels;
int buf_size; int buf_size;
int ch, ret; int ch, ret;
int hdr_size = 2; int hdr_size = 2;
/* decode and interleave the first packet */ /* decode and interleave the first packet */
if (!esc->data[0] && avpkt) { if (!esc->data[0] && avpkt) {
int chan_size = avpkt->size / avctx->channels - hdr_size; int chan_size = avpkt->size / channels - hdr_size;
if (avpkt->size % avctx->channels) { if (avpkt->size % channels) {
av_log(avctx, AV_LOG_WARNING, "Packet with odd size, ignoring last byte\n"); av_log(avctx, AV_LOG_WARNING, "Packet with odd size, ignoring last byte\n");
} }
if (avpkt->size < (hdr_size + 1) * avctx->channels) { if (avpkt->size < (hdr_size + 1) * channels) {
av_log(avctx, AV_LOG_ERROR, "packet size is too small\n"); av_log(avctx, AV_LOG_ERROR, "packet size is too small\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
esc->fib_acc[0] = avpkt->data[1] + 128; esc->fib_acc[0] = avpkt->data[1] + 128;
if (avctx->channels == 2) if (channels == 2)
esc->fib_acc[1] = avpkt->data[2+chan_size+1] + 128; esc->fib_acc[1] = avpkt->data[2+chan_size+1] + 128;
esc->data_idx = 0; esc->data_idx = 0;
esc->data_size = chan_size; esc->data_size = chan_size;
if (!(esc->data[0] = av_malloc(chan_size))) if (!(esc->data[0] = av_malloc(chan_size)))
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if (avctx->channels == 2) { if (channels == 2) {
if (!(esc->data[1] = av_malloc(chan_size))) { if (!(esc->data[1] = av_malloc(chan_size))) {
av_freep(&esc->data[0]); av_freep(&esc->data[0]);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
} }
memcpy(esc->data[0], &avpkt->data[hdr_size], chan_size); memcpy(esc->data[0], &avpkt->data[hdr_size], chan_size);
if (avctx->channels == 2) if (channels == 2)
memcpy(esc->data[1], &avpkt->data[2*hdr_size+chan_size], chan_size); memcpy(esc->data[1], &avpkt->data[2*hdr_size+chan_size], chan_size);
} }
if (!esc->data[0]) { if (!esc->data[0]) {
@ -139,7 +140,7 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret; return ret;
for (ch = 0; ch < avctx->channels; ch++) { for (ch = 0; ch < channels; ch++) {
delta_decode(frame->data[ch], &esc->data[ch][esc->data_idx], delta_decode(frame->data[ch], &esc->data[ch][esc->data_idx],
buf_size, &esc->fib_acc[ch], esc->table); buf_size, &esc->fib_acc[ch], esc->table);
} }
@ -148,14 +149,14 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
*got_frame_ptr = 1; *got_frame_ptr = 1;
return ((avctx->frame_number == 0)*hdr_size + buf_size)*avctx->channels; return ((avctx->frame_number == 0) * hdr_size + buf_size) * channels;
} }
static av_cold int eightsvx_decode_init(AVCodecContext *avctx) static av_cold int eightsvx_decode_init(AVCodecContext *avctx)
{ {
EightSvxContext *esc = avctx->priv_data; EightSvxContext *esc = avctx->priv_data;
if (avctx->channels < 1 || avctx->channels > 2) { if (avctx->ch_layout.nb_channels < 1 || avctx->ch_layout.nb_channels > 2) {
av_log(avctx, AV_LOG_ERROR, "8SVX does not support more than 2 channels\n"); av_log(avctx, AV_LOG_ERROR, "8SVX does not support more than 2 channels\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }

Loading…
Cancel
Save