summaryrefslogtreecommitdiff
path: root/libavcodec/pcm_tablegen.h
diff options
context:
space:
mode:
authorCameron Cawley <ccawley2011@gmail.com>2018-10-13 00:06:39 +0100
committerPaul B Mahol <onemda@gmail.com>2018-10-26 13:39:25 +0200
commit22238d0b9440cf55aafda42c60f4413514d4aeb8 (patch)
treea406f18615ac7d99c232d797e229c5f3a9e7417b /libavcodec/pcm_tablegen.h
parentfb7925ba2fa10e1ecf63eb4bada268e25627a88d (diff)
downloadffmpeg-22238d0b9440cf55aafda42c60f4413514d4aeb8.tar.gz
avcodec: Implement Archimedes VIDC encoder/decoder
Signed-off-by: Cameron Cawley <ccawley2011@gmail.com>
Diffstat (limited to 'libavcodec/pcm_tablegen.h')
-rw-r--r--libavcodec/pcm_tablegen.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/libavcodec/pcm_tablegen.h b/libavcodec/pcm_tablegen.h
index 7ce147f768..d8763abc40 100644
--- a/libavcodec/pcm_tablegen.h
+++ b/libavcodec/pcm_tablegen.h
@@ -36,6 +36,12 @@
#define BIAS (0x84) /* Bias for linear code. */
+#define VIDC_SIGN_BIT (1)
+#define VIDC_QUANT_MASK (0x1E)
+#define VIDC_QUANT_SHIFT (1)
+#define VIDC_SEG_SHIFT (5)
+#define VIDC_SEG_MASK (0xE0)
+
/* alaw2linear() - Convert an A-law value to 16-bit linear PCM */
static av_cold int alaw2linear(unsigned char a_val)
{
@@ -69,14 +75,30 @@ static av_cold int ulaw2linear(unsigned char u_val)
return (u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS);
}
+static av_cold int vidc2linear(unsigned char u_val)
+{
+ int t;
+
+ /*
+ * Extract and bias the quantization bits. Then
+ * shift up by the segment number and subtract out the bias.
+ */
+ t = (((u_val & VIDC_QUANT_MASK) >> VIDC_QUANT_SHIFT) << 3) + BIAS;
+ t <<= ((unsigned)u_val & VIDC_SEG_MASK) >> VIDC_SEG_SHIFT;
+
+ return (u_val & VIDC_SIGN_BIT) ? (BIAS - t) : (t - BIAS);
+}
+
#if CONFIG_HARDCODED_TABLES
#define pcm_alaw_tableinit()
#define pcm_ulaw_tableinit()
+#define pcm_vidc_tableinit()
#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_vidc[16384];
static av_cold void build_xlaw_table(uint8_t *linear_to_xlaw,
int (*xlaw2linear)(unsigned char),
@@ -111,6 +133,11 @@ static void pcm_ulaw_tableinit(void)
{
build_xlaw_table(linear_to_ulaw, ulaw2linear, 0xff);
}
+
+static void pcm_vidc_tableinit(void)
+{
+ build_xlaw_table(linear_to_vidc, vidc2linear, 0xff);
+}
#endif /* CONFIG_HARDCODED_TABLES */
#endif /* AVCODEC_PCM_TABLEGEN_H */