[FFmpeg-devel] [PATCH]8 and 24 bit True Audio
Carl Eugen Hoyos
cehoyos at ag.or.at
Sun May 1 06:20:19 CEST 2011
Hi!
The patches fix decoding for some u8- and s24-encoded tta files, samples
attached to ticket 118.
(Longer samples fail because the output buffer size is too small.)
Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index ece5c1c..af883aa 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -251,7 +251,7 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
return -1;
}
else switch(s->bps) {
-// case 1: avctx->sample_fmt = AV_SAMPLE_FMT_U8; break;
+ case 1: avctx->sample_fmt = AV_SAMPLE_FMT_U8; break;
case 2: avctx->sample_fmt = AV_SAMPLE_FMT_S16; break;
// case 3: avctx->sample_fmt = AV_SAMPLE_FMT_S24; break;
case 4: avctx->sample_fmt = AV_SAMPLE_FMT_S32; break;
@@ -311,7 +311,7 @@ static int tta_decode_frame(AVCodecContext *avctx,
int cur_chan = 0, framelen = s->frame_length;
int32_t *p;
- if (*data_size < (framelen * s->channels * 2)) {
+ if (*data_size < (framelen * s->channels * av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8)) {
av_log(avctx, AV_LOG_ERROR, "Output buffer size is too small.\n");
return -1;
}
@@ -428,6 +428,13 @@ static int tta_decode_frame(AVCodecContext *avctx,
// convert to output buffer
switch(s->bps) {
+ case 1: {
+ uint8_t *samples = data;
+ for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)
+ *samples++ = *p + 0x80;
+ *data_size = (uint8_t *)samples - (uint8_t *)data;
+ break;
+ }
case 2: {
uint16_t *samples = data;
for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) {
-------------- next part --------------
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index 21a6d59..c94c48f 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -265,7 +265,7 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
else switch(s->bps) {
case 1: avctx->sample_fmt = AV_SAMPLE_FMT_U8; break;
case 2: avctx->sample_fmt = AV_SAMPLE_FMT_S16; break;
-// case 3: avctx->sample_fmt = AV_SAMPLE_FMT_S24; break;
+ case 3: avctx->bits_per_coded_sample = 24;
case 4: avctx->sample_fmt = AV_SAMPLE_FMT_S32; break;
default:
av_log_ask_for_sample(s->avctx,
@@ -459,6 +459,13 @@ static int tta_decode_frame(AVCodecContext *avctx,
*data_size = (uint8_t *)samples - (uint8_t *)data;
break;
}
+ case 3: {
+ int32_t *samples = data;
+ for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++)
+ *samples++ = AV_RN32(p) << 8;
+ *data_size = (uint8_t *)samples - (uint8_t *)data;
+ break;
+ }
default:
av_log(s->avctx, AV_LOG_ERROR, "Error, only 16bit samples supported!\n");
}
More information about the ffmpeg-devel
mailing list