aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2015-10-24 20:41:32 +0200
committerPaul B Mahol <onemda@gmail.com>2015-10-26 10:08:01 +0100
commit035ae3c0096f6c0a3f199d331ed4094ff5beafd1 (patch)
tree5eb7e43f1e39621980e9cb2ceef6c098c95aa40c /libavcodec
parent2ccc1b304e08a5f5e045c056e897ed377bf670f7 (diff)
downloadffmpeg-035ae3c0096f6c0a3f199d331ed4094ff5beafd1.tar.gz
avcodec: add SDX2 DPCM decoder
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/Makefile1
-rw-r--r--libavcodec/allcodecs.c1
-rw-r--r--libavcodec/avcodec.h2
-rw-r--r--libavcodec/codec_desc.c7
-rw-r--r--libavcodec/dpcm.c32
-rw-r--r--libavcodec/utils.c1
-rw-r--r--libavcodec/version.h2
7 files changed, 41 insertions, 5 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f85fc18a8d..4afb473e0f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -458,6 +458,7 @@ OBJS-$(CONFIG_S302M_DECODER) += s302m.o
OBJS-$(CONFIG_S302M_ENCODER) += s302menc.o
OBJS-$(CONFIG_SANM_DECODER) += sanm.o
OBJS-$(CONFIG_SCREENPRESSO_DECODER) += screenpresso.o
+OBJS-$(CONFIG_SDX2_DPCM_DECODER) += dpcm.o
OBJS-$(CONFIG_SGI_DECODER) += sgidec.o
OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o
OBJS-$(CONFIG_SGIRLE_DECODER) += sgirledec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 7279620fb6..52606a323c 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -287,6 +287,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (S302M, s302m);
REGISTER_DECODER(SANM, sanm);
REGISTER_DECODER(SCREENPRESSO, screenpresso);
+ REGISTER_DECODER(SDX2_DPCM, sdx2_dpcm);
REGISTER_ENCDEC (SGI, sgi);
REGISTER_DECODER(SGIRLE, sgirle);
REGISTER_DECODER(SMACKER, smacker);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7d47698531..490bcd24ed 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -410,6 +410,8 @@ enum AVCodecID {
AV_CODEC_ID_XAN_DPCM,
AV_CODEC_ID_SOL_DPCM,
+ AV_CODEC_ID_SDX2_DPCM = 0x14800,
+
/* audio codecs */
AV_CODEC_ID_MP2 = 0x15000,
AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 2f5cefd16c..32f1f8aa44 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2054,6 +2054,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("DPCM Sol"),
.props = AV_CODEC_PROP_LOSSY,
},
+ {
+ .id = AV_CODEC_ID_SDX2_DPCM,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "sdx2_dpcm",
+ .long_name = NULL_IF_CONFIG_SMALL("DPCM Squareroot-Delta-Exact"),
+ .props = AV_CODEC_PROP_LOSSY,
+ },
/* audio codecs */
{
diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c
index c13945edb6..52a2c616db 100644
--- a/libavcodec/dpcm.c
+++ b/libavcodec/dpcm.c
@@ -44,7 +44,7 @@
#include "mathops.h"
typedef struct DPCMContext {
- int16_t roq_square_array[256];
+ int16_t square_array[256];
int sample[2]; ///< previous sample (for SOL_DPCM)
const int8_t *sol_table; ///< delta table for SOL_DPCM
} DPCMContext;
@@ -130,8 +130,8 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx)
/* initialize square table */
for (i = 0; i < 128; i++) {
int16_t square = i * i;
- s->roq_square_array[i ] = square;
- s->roq_square_array[i + 128] = -square;
+ s->square_array[i ] = square;
+ s->square_array[i + 128] = -square;
}
break;
@@ -153,6 +153,13 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx)
}
break;
+ case AV_CODEC_ID_SDX2_DPCM:
+ for (i = -128; i < 128; i++) {
+ int16_t square = i * i * 2;
+ s->square_array[i+128] = i < 0 ? -square: square;
+ }
+ break;
+
default:
break;
}
@@ -200,6 +207,9 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
else
out = buf_size;
break;
+ case AV_CODEC_ID_SDX2_DPCM:
+ out = buf_size;
+ break;
}
if (out <= 0) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
@@ -230,7 +240,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
/* decode the samples */
while (output_samples < samples_end) {
- predictor[ch] += s->roq_square_array[bytestream2_get_byteu(&gb)];
+ predictor[ch] += s->square_array[bytestream2_get_byteu(&gb)];
predictor[ch] = av_clip_int16(predictor[ch]);
*output_samples++ = predictor[ch];
@@ -318,6 +328,19 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
}
}
break;
+
+ case AV_CODEC_ID_SDX2_DPCM:
+ while (output_samples < samples_end) {
+ int8_t n = bytestream2_get_byteu(&gb);
+
+ if (!(n & 1))
+ s->sample[ch] = 0;
+ s->sample[ch] += s->square_array[n + 128];
+ s->sample[ch] = av_clip_int16(s->sample[ch]);
+ *output_samples++ = s->sample[ch];
+ ch ^= stereo;
+ }
+ break;
}
*got_frame_ptr = 1;
@@ -339,5 +362,6 @@ AVCodec ff_ ## name_ ## _decoder = { \
DPCM_DECODER(AV_CODEC_ID_INTERPLAY_DPCM, interplay_dpcm, "DPCM Interplay");
DPCM_DECODER(AV_CODEC_ID_ROQ_DPCM, roq_dpcm, "DPCM id RoQ");
+DPCM_DECODER(AV_CODEC_ID_SDX2_DPCM, sdx2_dpcm, "DPCM Squareroot-Delta-Exact");
DPCM_DECODER(AV_CODEC_ID_SOL_DPCM, sol_dpcm, "DPCM Sol");
DPCM_DECODER(AV_CODEC_ID_XAN_DPCM, xan_dpcm, "DPCM Xan");
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 83a20781ec..f85cbad7c2 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2906,6 +2906,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
case AV_CODEC_ID_PCM_S8_PLANAR:
case AV_CODEC_ID_PCM_U8:
case AV_CODEC_ID_PCM_ZORK:
+ case AV_CODEC_ID_SDX2_DPCM:
return 8;
case AV_CODEC_ID_PCM_S16BE:
case AV_CODEC_ID_PCM_S16BE_PLANAR:
diff --git a/libavcodec/version.h b/libavcodec/version.h
index ea0f0bd4af..ea9e89a31c 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 57
-#define LIBAVCODEC_VERSION_MINOR 9
+#define LIBAVCODEC_VERSION_MINOR 10
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \