[FFmpeg-devel] [PATCH] avcodec/pcm: Increase a/mu-law encoding table sizes

Michael Niedermayer michaelni at gmx.at
Sun Nov 30 12:11:36 CET 2014


This very slightly improves quality at the expense of 96kb more memory for tables

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavcodec/pcm.c           |    4 ++--
 libavcodec/pcm_tablegen.h  |   12 ++++++------
 tests/ref/acodec/pcm-alaw  |    6 +++---
 tests/ref/acodec/pcm-mulaw |    6 +++---
 tests/ref/lavf/alaw        |    4 ++--
 tests/ref/lavf/mov         |   16 ++++++++--------
 tests/ref/lavf/mulaw       |    4 ++--
 7 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 0a4ad0b..ec702c5 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -202,13 +202,13 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     case AV_CODEC_ID_PCM_ALAW:
         for (; n > 0; n--) {
             v      = *samples++;
-            *dst++ = linear_to_alaw[(v + 32768) >> 2];
+            *dst++ = linear_to_alaw[v + 32768];
         }
         break;
     case AV_CODEC_ID_PCM_MULAW:
         for (; n > 0; n--) {
             v      = *samples++;
-            *dst++ = linear_to_ulaw[(v + 32768) >> 2];
+            *dst++ = linear_to_ulaw[v + 32768];
         }
         break;
     default:
diff --git a/libavcodec/pcm_tablegen.h b/libavcodec/pcm_tablegen.h
index 1387210..9a9a60b 100644
--- a/libavcodec/pcm_tablegen.h
+++ b/libavcodec/pcm_tablegen.h
@@ -78,8 +78,8 @@ static av_cold int ulaw2linear(unsigned char u_val)
 #include "libavcodec/pcm_tables.h"
 #else
 /* 16384 entries per table */
-static uint8_t linear_to_alaw[16384];
-static uint8_t linear_to_ulaw[16384];
+static uint8_t linear_to_alaw[65536];
+static uint8_t linear_to_ulaw[65536];
 
 static av_cold void build_xlaw_table(uint8_t *linear_to_xlaw,
                              int (*xlaw2linear)(unsigned char),
@@ -92,14 +92,14 @@ static av_cold void build_xlaw_table(uint8_t *linear_to_xlaw,
         if (i != 127) {
             v1 = xlaw2linear(i ^ mask);
             v2 = xlaw2linear((i + 1) ^ mask);
-            v = (v1 + v2 + 4) >> 3;
+            v = (v1 + v2 + 1) >> 1;
         } else {
-            v = 8192;
+            v = 32768;
         }
         for(;j<v;j++) {
-            linear_to_xlaw[8192 + j] = (i ^ mask);
+            linear_to_xlaw[32768 + j] = (i ^ mask);
             if (j > 0)
-                linear_to_xlaw[8192 - j] = (i ^ (mask ^ 0x80));
+                linear_to_xlaw[32768 - j] = (i ^ (mask ^ 0x80));
         }
     }
     linear_to_xlaw[0] = linear_to_xlaw[1];
diff --git a/tests/ref/acodec/pcm-alaw b/tests/ref/acodec/pcm-alaw
index 00555e3..436ff39 100644
--- a/tests/ref/acodec/pcm-alaw
+++ b/tests/ref/acodec/pcm-alaw
@@ -1,4 +1,4 @@
-a2dd6a934ec6d5ec901a211652e85227 *tests/data/fate/acodec-pcm-alaw.wav
+bb9733254958ebf283f4f745e277747b *tests/data/fate/acodec-pcm-alaw.wav
 529258 tests/data/fate/acodec-pcm-alaw.wav
-0568b0b9a72e31559e150e7e09d301cd *tests/data/fate/acodec-pcm-alaw.out.wav
-stddev:  101.67 PSNR: 56.19 MAXDIFF:  515 bytes:  1058400/  1058400
+7041abdd337c41a67c7cacba106cae5a *tests/data/fate/acodec-pcm-alaw.out.wav
+stddev:  101.64 PSNR: 56.19 MAXDIFF:  512 bytes:  1058400/  1058400
diff --git a/tests/ref/acodec/pcm-mulaw b/tests/ref/acodec/pcm-mulaw
index f5c117d..28761ee 100644
--- a/tests/ref/acodec/pcm-mulaw
+++ b/tests/ref/acodec/pcm-mulaw
@@ -1,4 +1,4 @@
-fd10ee54bd298fc29fd6fc70baa71414 *tests/data/fate/acodec-pcm-mulaw.wav
+0f54b6a2f77a9c2dd88239e8243793e4 *tests/data/fate/acodec-pcm-mulaw.wav
 529258 tests/data/fate/acodec-pcm-mulaw.wav
-1c3eeaa8814ebd4916780dff80ed6dc5 *tests/data/fate/acodec-pcm-mulaw.out.wav
-stddev:  103.38 PSNR: 56.04 MAXDIFF:  644 bytes:  1058400/  1058400
+c6bd3d01c4e1b3478f17127590eb27cd *tests/data/fate/acodec-pcm-mulaw.out.wav
+stddev:  103.36 PSNR: 56.04 MAXDIFF:  644 bytes:  1058400/  1058400
diff --git a/tests/ref/lavf/alaw b/tests/ref/lavf/alaw
index d93d6fc..a707029 100644
--- a/tests/ref/lavf/alaw
+++ b/tests/ref/lavf/alaw
@@ -1,3 +1,3 @@
-652d96e474869ddb01403743deb35117 *./tests/data/lavf/lavf.al
+f9172fd6e928b75363408e76908ffb09 *./tests/data/lavf/lavf.al
 44100 ./tests/data/lavf/lavf.al
-./tests/data/lavf/lavf.al CRC=0xf9643112
+./tests/data/lavf/lavf.al CRC=0xec463904
diff --git a/tests/ref/lavf/mov b/tests/ref/lavf/mov
index 72d962a..5133c5b 100644
--- a/tests/ref/lavf/mov
+++ b/tests/ref/lavf/mov
@@ -1,12 +1,12 @@
-a10d50f2679df92264e1fc21cb8be630 *./tests/data/lavf/lavf.mov
+15b1adacea02a8f89b812fc02cbbb6d5 *./tests/data/lavf/lavf.mov
 366449 ./tests/data/lavf/lavf.mov
-./tests/data/lavf/lavf.mov CRC=0xbb2b949b
-6258f70f974e3c802e01d02ac33c7bbd *./tests/data/lavf/lavf.mov
+./tests/data/lavf/lavf.mov CRC=0xfb639c8d
+101fe6ceb7873d9c08524887aed872c6 *./tests/data/lavf/lavf.mov
 357539 ./tests/data/lavf/lavf.mov
-./tests/data/lavf/lavf.mov CRC=0xbb2b949b
-ba3b8b49e420510a0d417400dbedfc2d *./tests/data/lavf/lavf.mov
+./tests/data/lavf/lavf.mov CRC=0xfb639c8d
+787445fd0875b13cc710e57f822ae237 *./tests/data/lavf/lavf.mov
 366621 ./tests/data/lavf/lavf.mov
-./tests/data/lavf/lavf.mov CRC=0xa9793231
-fd0e4de8e7f6d0c8c0681d7020f00f50 *./tests/data/lavf/lavf.mov
+./tests/data/lavf/lavf.mov CRC=0xe4263a23
+53c8673e030550d3a5f5e2bdc3932f88 *./tests/data/lavf/lavf.mov
 356921 ./tests/data/lavf/lavf.mov
-./tests/data/lavf/lavf.mov CRC=0xbb2b949b
+./tests/data/lavf/lavf.mov CRC=0xfb639c8d
diff --git a/tests/ref/lavf/mulaw b/tests/ref/lavf/mulaw
index bd54084..c2d4d5b 100644
--- a/tests/ref/lavf/mulaw
+++ b/tests/ref/lavf/mulaw
@@ -1,3 +1,3 @@
-ad492935e361f830f2f8302aa102701d *./tests/data/lavf/lavf.ul
+835290b9fa5bca50bd429e8809068a4f *./tests/data/lavf/lavf.ul
 44100 ./tests/data/lavf/lavf.ul
-./tests/data/lavf/lavf.ul CRC=0x4515fa26
+./tests/data/lavf/lavf.ul CRC=0xf098f5ee
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list