History

avcodec: add derf dpcm decoder

Paul B Mahol committed 6 years ago

Commit c6bbdba1 parent 30a73367 files · +44 −0Browse files

Unified · Split

7 files
  1. Changelog +1 −0
  2. libavcodec/Makefile +1 −0
  3. libavcodec/allcodecs.c +1 −0
  4. libavcodec/avcodec.h +1 −0
  5. libavcodec/codec_desc.c +7 −0
  6. libavcodec/dpcm.c +32 −0
  7. libavcodec/utils.c +1 −0
Changelog+1−0
@@ -50,6 +50,7 @@ version <next>: · 49 unmodified lines
5050 - avgblur_vulkan, overlay_vulkan, scale_vulkan and chromaber_vulkan filters
5151 - ADPCM IMA MTF decoder
5252 - FWSE demuxer
53+- DERF DPCM decoder
5354
5455
5556 version 4.2:
libavcodec/Makefile+1−0
@@ -265,6 +265,7 @@ OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \ · 264 unmodified lines
265265 OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o dcahuff.o \
266266 dcaadpcm.o
267267 OBJS-$(CONFIG_DDS_DECODER) += dds.o
268+OBJS-$(CONFIG_DERF_DPCM_DECODER) += dpcm.o
268269 OBJS-$(CONFIG_DIRAC_DECODER) += diracdec.o dirac.o diracdsp.o diractab.o \
269270 dirac_arith.o dirac_dwt.o dirac_vlc.o
270271 OBJS-$(CONFIG_DFA_DECODER) += dfa.o
libavcodec/allcodecs.c+1−0
@@ -569,6 +569,7 @@ extern AVCodec ff_pcm_vidc_encoder; · 568 unmodified lines
569569 extern AVCodec ff_pcm_vidc_decoder;
570570
571571 /* DPCM codecs */
572+extern AVCodec ff_derf_dpcm_decoder;
572573 extern AVCodec ff_gremlin_dpcm_decoder;
573574 extern AVCodec ff_interplay_dpcm_decoder;
574575 extern AVCodec ff_roq_dpcm_encoder;
libavcodec/avcodec.h+1−0
@@ -571,6 +571,7 @@ enum AVCodecID { · 570 unmodified lines
571571
572572 AV_CODEC_ID_SDX2_DPCM = 0x14800,
573573 AV_CODEC_ID_GREMLIN_DPCM,
574+ AV_CODEC_ID_DERF_DPCM,
574575
575576 /* audio codecs */
576577 AV_CODEC_ID_MP2 = 0x15000,
libavcodec/codec_desc.c+7−0
@@ -2415,6 +2415,13 @@ static const AVCodecDescriptor codec_descriptors[] = { · 2414 unmodified lines
24152415 .long_name = NULL_IF_CONFIG_SMALL("DPCM Gremlin"),
24162416 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
24172417 },
2418+ {
2419+ .id = AV_CODEC_ID_DERF_DPCM,
2420+ .type = AVMEDIA_TYPE_AUDIO,
2421+ .name = "derf_dpcm",
2422+ .long_name = NULL_IF_CONFIG_SMALL("DPCM Xilam DERF"),
2423+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
2424+ },
24182425
24192426 /* audio codecs */
24202427 {
libavcodec/dpcm.c+32−0
@@ -49,6 +49,21 @@ typedef struct DPCMContext { · 48 unmodified lines
4949 const int8_t *sol_table; ///< delta table for SOL_DPCM
5050 } DPCMContext;
5151
52+static const int32_t derf_steps[96] = {
53+ 0, 1, 2, 3, 4, 5, 6, 7,
54+ 8, 9, 10, 11, 12, 13, 14, 16,
55+ 17, 19, 21, 23, 25, 28, 31, 34,
56+ 37, 41, 45, 50, 55, 60, 66, 73,
57+ 80, 88, 97, 107, 118, 130, 143, 157,
58+ 173, 190, 209, 230, 253, 279, 307, 337,
59+ 371, 408, 449, 494, 544, 598, 658, 724,
60+ 796, 876, 963, 1060, 1166, 1282, 1411, 1552,
61+ 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
62+ 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132,
63+ 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289,
64+ 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767,
65+};
66+
5267 static const int16_t interplay_delta_table[] = {
5368 0, 1, 2, 3, 4, 5, 6, 7,
5469 8, 9, 10, 11, 12, 13, 14, 15,
@@ -225,6 +240,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, · 170 unmodified lines
225240 else
226241 out = buf_size;
227242 break;
243+ case AV_CODEC_ID_DERF_DPCM:
228244 case AV_CODEC_ID_GREMLIN_DPCM:
229245 case AV_CODEC_ID_SDX2_DPCM:
230246 out = buf_size;
@@ -372,6 +388,21 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, · 141 unmodified lines
372388 }
373389 }
374390 break;
391+
392+ case AV_CODEC_ID_DERF_DPCM: {
393+ int idx = 0;
394+
395+ while (output_samples < samples_end) {
396+ uint8_t n = bytestream2_get_byteu(&gb);
397+ int index = FFMIN(n & 0x7f, 95);
398+
399+ s->sample[idx] += (n & 0x80 ? -1: 1) * derf_steps[index];
400+ s->sample[idx] = av_clip_int16(s->sample[idx]);
401+ *output_samples++ = s->sample[idx];
402+ idx ^= stereo;
403+ }
404+ }
405+ break;
375406 }
376407
377408 *got_frame_ptr = 1;
@@ -391,6 +422,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ · 13 unmodified lines
391422 .capabilities = AV_CODEC_CAP_DR1, \
392423 }
393424
425+DPCM_DECODER(AV_CODEC_ID_DERF_DPCM, derf_dpcm, "DPCM Xilam DERF");
394426 DPCM_DECODER(AV_CODEC_ID_GREMLIN_DPCM, gremlin_dpcm, "DPCM Gremlin");
395427 DPCM_DECODER(AV_CODEC_ID_INTERPLAY_DPCM, interplay_dpcm, "DPCM Interplay");
396428 DPCM_DECODER(AV_CODEC_ID_ROQ_DPCM, roq_dpcm, "DPCM id RoQ");
libavcodec/utils.c+1−0
@@ -1478,6 +1478,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id) · 1477 unmodified lines
14781478 case AV_CODEC_ID_PCM_S8_PLANAR:
14791479 case AV_CODEC_ID_PCM_U8:
14801480 case AV_CODEC_ID_SDX2_DPCM:
1481+ case AV_CODEC_ID_DERF_DPCM:
14811482 return 8;
14821483 case AV_CODEC_ID_PCM_S16BE:
14831484 case AV_CODEC_ID_PCM_S16BE_PLANAR:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t