mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-29 10:52:20 +00:00
tta: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
0045c6dd5c
commit
1191ffd50a
@ -113,7 +113,7 @@ static int allocate_buffers(AVCodecContext *avctx)
|
||||
return AVERROR(ENOMEM);
|
||||
} else
|
||||
s->decode_buffer = NULL;
|
||||
s->ch_ctx = av_malloc_array(avctx->channels, sizeof(*s->ch_ctx));
|
||||
s->ch_ctx = av_malloc_array(avctx->ch_layout.nb_channels, sizeof(*s->ch_ctx));
|
||||
if (!s->ch_ctx)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@ -154,9 +154,17 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
|
||||
}
|
||||
AV_WL64(s->crc_pass, tta_check_crc64(s->pass));
|
||||
}
|
||||
avctx->channels = s->channels = get_bits(&gb, 16);
|
||||
if (s->channels > 1 && s->channels < 9)
|
||||
avctx->channel_layout = tta_channel_layouts[s->channels-2];
|
||||
|
||||
s->channels = get_bits(&gb, 16);
|
||||
|
||||
av_channel_layout_uninit(&avctx->ch_layout);
|
||||
if (s->channels > 1 && s->channels < 9) {
|
||||
av_channel_layout_from_mask(&avctx->ch_layout, tta_channel_layouts[s->channels-2]);
|
||||
} else {
|
||||
avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
|
||||
avctx->ch_layout.nb_channels = s->channels;
|
||||
}
|
||||
|
||||
avctx->bits_per_raw_sample = get_bits(&gb, 16);
|
||||
s->bps = (avctx->bits_per_raw_sample + 7) / 8;
|
||||
avctx->sample_rate = get_bits_long(&gb, 32);
|
||||
@ -197,7 +205,7 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
|
||||
(s->last_frame_length ? 1 : 0);
|
||||
|
||||
av_log(avctx, AV_LOG_DEBUG, "format: %d chans: %d bps: %d rate: %d block: %d\n",
|
||||
s->format, avctx->channels, avctx->bits_per_coded_sample, avctx->sample_rate,
|
||||
s->format, avctx->ch_layout.nb_channels, avctx->bits_per_coded_sample, avctx->sample_rate,
|
||||
avctx->block_align);
|
||||
av_log(avctx, AV_LOG_DEBUG, "data_length: %d frame_length: %d last: %d total: %d\n",
|
||||
s->data_length, s->frame_length, s->last_frame_length, total_frames);
|
||||
|
@ -56,7 +56,7 @@ static av_cold int tta_encode_init(AVCodecContext *avctx)
|
||||
s->bps = avctx->bits_per_raw_sample >> 3;
|
||||
avctx->frame_size = 256 * avctx->sample_rate / 245;
|
||||
|
||||
s->ch_ctx = av_malloc_array(avctx->channels, sizeof(*s->ch_ctx));
|
||||
s->ch_ctx = av_malloc_array(avctx->ch_layout.nb_channels, sizeof(*s->ch_ctx));
|
||||
if (!s->ch_ctx)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@ -89,7 +89,7 @@ static int tta_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
TTAEncContext *s = avctx->priv_data;
|
||||
PutBitContext pb;
|
||||
int ret, i, out_bytes, cur_chan, res, samples;
|
||||
int64_t pkt_size = frame->nb_samples * 2LL * avctx->channels * s->bps;
|
||||
int64_t pkt_size = frame->nb_samples * 2LL * avctx->ch_layout.nb_channels * s->bps;
|
||||
|
||||
pkt_alloc:
|
||||
cur_chan = 0, res = 0, samples = 0;
|
||||
@ -98,13 +98,13 @@ pkt_alloc:
|
||||
init_put_bits(&pb, avpkt->data, avpkt->size);
|
||||
|
||||
// init per channel states
|
||||
for (i = 0; i < avctx->channels; i++) {
|
||||
for (i = 0; i < avctx->ch_layout.nb_channels; i++) {
|
||||
s->ch_ctx[i].predictor = 0;
|
||||
ff_tta_filter_init(&s->ch_ctx[i].filter, ff_tta_filter_configs[s->bps - 1]);
|
||||
ff_tta_rice_init(&s->ch_ctx[i].rice, 10, 10);
|
||||
}
|
||||
|
||||
for (i = 0; i < frame->nb_samples * avctx->channels; i++) {
|
||||
for (i = 0; i < frame->nb_samples * avctx->ch_layout.nb_channels; i++) {
|
||||
TTAChannel *c = &s->ch_ctx[cur_chan];
|
||||
TTAFilter *filter = &c->filter;
|
||||
TTARice *rice = &c->rice;
|
||||
@ -113,8 +113,8 @@ pkt_alloc:
|
||||
|
||||
value = get_sample(frame, samples++, avctx->sample_fmt);
|
||||
|
||||
if (avctx->channels > 1) {
|
||||
if (cur_chan < avctx->channels - 1)
|
||||
if (avctx->ch_layout.nb_channels > 1) {
|
||||
if (cur_chan < avctx->ch_layout.nb_channels - 1)
|
||||
value = res = get_sample(frame, samples, avctx->sample_fmt) - value;
|
||||
else
|
||||
value -= res / 2;
|
||||
@ -176,7 +176,7 @@ pkt_alloc:
|
||||
if (k)
|
||||
put_bits(&pb, k, outval & (ff_tta_shift_1[k] - 1));
|
||||
|
||||
if (cur_chan < avctx->channels - 1)
|
||||
if (cur_chan < avctx->ch_layout.nb_channels - 1)
|
||||
cur_chan++;
|
||||
else
|
||||
cur_chan = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user