summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-05-07 07:20:32 +0200
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:43 -0300
commitc5ccc0bd9421e6aed3e341f49a57284132b80a86 (patch)
tree6a5b2017a76840a3613d38c6f4d4334166b5b90d /libavcodec
parente5d4941c40fe7ef8ff279a2f9f7fa14b126558cf (diff)
mace: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mace.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libavcodec/mace.c b/libavcodec/mace.c
index 506a0ddece..9ed4747ba9 100644
--- a/libavcodec/mace.c
+++ b/libavcodec/mace.c
@@ -226,7 +226,7 @@ static void chomp6(ChannelData *chd, int16_t *output, uint8_t val, int tab_idx)
static av_cold int mace_decode_init(AVCodecContext * avctx)
{
- if (avctx->channels > 2 || avctx->channels < 1)
+ if (avctx->ch_layout.nb_channels > 2 || avctx->ch_layout.nb_channels < 1)
return AVERROR(EINVAL);
avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
@@ -239,31 +239,32 @@ static int mace_decode_frame(AVCodecContext *avctx, void *data,
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
+ int channels = avctx->ch_layout.nb_channels;
int16_t **samples;
MACEContext *ctx = avctx->priv_data;
int i, j, k, l, ret;
int is_mace3 = (avctx->codec_id == AV_CODEC_ID_MACE3);
- if (buf_size % (avctx->channels << is_mace3)) {
+ if (buf_size % (channels << is_mace3)) {
av_log(avctx, AV_LOG_ERROR, "buffer size %d is odd\n", buf_size);
- buf_size -= buf_size % (avctx->channels << is_mace3);
+ buf_size -= buf_size % (channels << is_mace3);
if (!buf_size)
return AVERROR_INVALIDDATA;
}
/* get output buffer */
- frame->nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels;
+ frame->nb_samples = 3 * (buf_size << (1 - is_mace3)) / channels;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
samples = (int16_t **)frame->extended_data;
- for(i = 0; i < avctx->channels; i++) {
+ for(i = 0; i < channels; i++) {
int16_t *output = samples[i];
- for (j=0; j < buf_size / (avctx->channels << is_mace3); j++)
+ for (j=0; j < buf_size / (channels << is_mace3); j++)
for (k=0; k < (1 << is_mace3); k++) {
uint8_t pkt = buf[(i << is_mace3) +
- (j*avctx->channels << is_mace3) + k];
+ (j * channels << is_mace3) + k];
uint8_t val[2][3] = {{pkt >> 5, (pkt >> 3) & 3, pkt & 7 },
{pkt & 7 , (pkt >> 3) & 3, pkt >> 5}};