[FFmpeg-cvslog] avcodec/tta: simplify final samples conversion

Paul B Mahol git at videolan.org
Sat Sep 17 11:34:39 EEST 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Sep 17 09:55:47 2022 +0200| [695bf82bfb233fa0e77af4029c88620d943c3cba] | committer: Paul B Mahol

avcodec/tta: simplify final samples conversion

Remove dubious overflow message and counter.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=695bf82bfb233fa0e77af4029c88620d943c3cba
---

 libavcodec/tta.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index d66e25af05..e63d08bb44 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -364,28 +364,24 @@ static int tta_decode_frame(AVCodecContext *avctx, AVFrame *frame,
     switch (s->bps) {
     case 1: {
         uint8_t *samples = (uint8_t *)frame->data[0];
-        for (p = s->decode_buffer; (int32_t*)p < s->decode_buffer + (framelen * s->channels); p++)
-            *samples++ = *p + 0x80;
+        p = s->decode_buffer;
+        for (i = 0; i < framelen * s->channels; i++)
+            samples[i] = p[i] + 0x80;
         break;
         }
     case 2: {
         int16_t *samples = (int16_t *)frame->data[0];
-        for (p = s->decode_buffer; (int32_t*)p < s->decode_buffer + (framelen * s->channels); p++)
-            *samples++ = *p;
+        p = s->decode_buffer;
+        for (i = 0; i < framelen * s->channels; i++)
+            samples[i] = p[i];
         break;
         }
     case 3: {
         // shift samples for 24-bit sample format
         int32_t *samples = (int32_t *)frame->data[0];
-        int overflow = 0;
 
-        for (i = 0; i < framelen * s->channels; i++) {
-            int scaled = *samples * 256U;
-            overflow += (scaled >> 8 != *samples);
-            *samples++ = scaled;
-        }
-        if (overflow)
-            av_log(avctx, AV_LOG_WARNING, "%d overflows occurred on 24bit upscale\n", overflow);
+        for (i = 0; i < framelen * s->channels; i++)
+            samples[i] = samples[i] * 256U;
         // reset decode buffer
         s->decode_buffer = NULL;
         break;



More information about the ffmpeg-cvslog mailing list