[FFmpeg-devel] [PATCH] avcodec/als: use planar sample formats

Paul B Mahol onemda at gmail.com
Sat Jul 1 22:28:35 EEST 2017


This is native layout of this codec.

Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/alsdec.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 4a8f13d..31e95e2 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1790,25 +1790,28 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
         return ret;
 
     // transform decoded frame into output format
-    #define INTERLEAVE_OUTPUT(bps)                                                   \
+    #define SHIFT_OUTPUT(bps)                                                        \
     {                                                                                \
-        int##bps##_t *dest = (int##bps##_t*)frame->data[0];                          \
         shift = bps - ctx->avctx->bits_per_raw_sample;                               \
         if (!ctx->cs_switch) {                                                       \
-            for (sample = 0; sample < ctx->cur_frame_length; sample++)               \
-                for (c = 0; c < avctx->channels; c++)                                \
+            for (c = 0; c < avctx->channels; c++) {                                  \
+                int##bps##_t *dest = (int##bps##_t*)frame->extended_data[c];         \
+                for (sample = 0; sample < ctx->cur_frame_length; sample++)           \
                     *dest++ = ctx->raw_samples[c][sample] << shift;                  \
+            }                                                                        \
         } else {                                                                     \
-            for (sample = 0; sample < ctx->cur_frame_length; sample++)               \
-                for (c = 0; c < avctx->channels; c++)                                \
+            for (c = 0; c < avctx->channels; c++) {                                  \
+                int##bps##_t *dest = (int##bps##_t*)frame->extended_data[c];         \
+                for (sample = 0; sample < ctx->cur_frame_length; sample++)           \
                     *dest++ = ctx->raw_samples[sconf->chan_pos[c]][sample] << shift; \
+            }                                                                        \
         }                                                                            \
     }
 
     if (ctx->avctx->bits_per_raw_sample <= 16) {
-        INTERLEAVE_OUTPUT(16)
+        SHIFT_OUTPUT(16)
     } else {
-        INTERLEAVE_OUTPUT(32)
+        SHIFT_OUTPUT(32)
     }
 
     // update CRC
@@ -1960,11 +1963,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
             goto fail;
     }
     if (sconf->floating) {
-        avctx->sample_fmt          = AV_SAMPLE_FMT_FLT;
+        avctx->sample_fmt          = AV_SAMPLE_FMT_FLTP;
         avctx->bits_per_raw_sample = 32;
     } else {
         avctx->sample_fmt          = sconf->resolution > 1
-                                     ? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S16;
+                                     ? AV_SAMPLE_FMT_S32P : AV_SAMPLE_FMT_S16P;
         avctx->bits_per_raw_sample = (sconf->resolution + 1) * 8;
         if (avctx->bits_per_raw_sample > 32) {
             av_log(avctx, AV_LOG_ERROR, "Bits per raw sample %d larger than 32.\n",
-- 
2.9.3



More information about the ffmpeg-devel mailing list