1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

takdec: s/bits_per_coded_sample/bits_per_raw_sample

bits_per_coded_sample should be set from demuxer and
not from decoder.

Prior to this change value set from demuxer would get
overwritten in decoder.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2012-10-12 08:51:47 +00:00
parent 62722ae2d4
commit 56519d7d14

View File

@ -146,9 +146,9 @@ static const struct CParam {
{ 0x1A, 0x1800000, 0x1800000, 0x6800000, 0xC000000 },
};
static void tak_set_bps(AVCodecContext *avctx)
static void tak_set_bps(AVCodecContext *avctx, int bps)
{
switch (avctx->bits_per_coded_sample) {
switch (bps) {
case 8:
avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
break;
@ -196,7 +196,7 @@ static av_cold int tak_decode_init(AVCodecContext *avctx)
s->uval = get_scale(avctx->sample_rate, get_shift(avctx->sample_rate));
s->subframe_scale = get_scale(avctx->sample_rate, 1);
tak_set_bps(avctx);
tak_set_bps(avctx, avctx->bits_per_coded_sample);
return 0;
}
@ -564,10 +564,10 @@ static int decode_channel(TAKDecContext *s, int chan)
int left = s->nb_samples - 1;
s->sample_shift[chan] = get_b(gb);
if (s->sample_shift[chan] >= avctx->bits_per_coded_sample)
if (s->sample_shift[chan] >= avctx->bits_per_raw_sample)
return AVERROR_INVALIDDATA;
*dst++ = get_code(gb, avctx->bits_per_coded_sample - s->sample_shift[chan]);
*dst++ = get_code(gb, avctx->bits_per_raw_sample - s->sample_shift[chan]);
s->lpc_mode[chan] = get_bits(gb, 2);
s->nb_subframes = get_bits(gb, 3) + 1;
@ -773,9 +773,9 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA;
}
if (s->ti.bps != avctx->bits_per_coded_sample) {
avctx->bits_per_coded_sample = s->ti.bps;
tak_set_bps(avctx);
if (s->ti.bps != avctx->bits_per_raw_sample) {
avctx->bits_per_raw_sample = s->ti.bps;
tak_set_bps(avctx, avctx->bits_per_raw_sample);
}
if (s->ti.sample_rate != avctx->sample_rate) {
avctx->sample_rate = s->ti.sample_rate;
@ -793,7 +793,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0)
return ret;
if (avctx->bits_per_coded_sample <= 16) {
if (avctx->bits_per_raw_sample <= 16) {
av_fast_malloc(&s->decode_buffer, &s->decode_buffer_size,
sizeof(*s->decode_buffer) * FFALIGN(s->nb_samples, 8) *
avctx->channels + FF_INPUT_BUFFER_PADDING_SIZE);
@ -811,7 +811,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
for (chan = 0; chan < avctx->channels; chan++) {
p = s->decoded[chan];
for (i = 0; i < s->nb_samples; i++)
*p++ = get_code(gb, avctx->bits_per_coded_sample);
*p++ = get_code(gb, avctx->bits_per_raw_sample);
}
} else {
if (s->ti.codec == 2) {
@ -918,7 +918,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
}
// convert to output buffer
switch (avctx->bits_per_coded_sample) {
switch (avctx->bits_per_raw_sample) {
case 8:
for (chan = 0; chan < avctx->channels; chan++) {
uint8_t *samples = (uint8_t *)s->frame.data[chan];