mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avcodec: add WADY DPCM decoder
This commit is contained in:
parent
9d5e66942c
commit
c5a545cff8
@ -29,6 +29,7 @@ version <next>:
|
||||
- corr video filter
|
||||
- adrc audio filter
|
||||
- afdelaysrc audio filter
|
||||
- WADY DPCM decoder
|
||||
|
||||
|
||||
version 5.1:
|
||||
|
@ -774,6 +774,7 @@ OBJS-$(CONFIG_VPLAYER_DECODER) += textdec.o ass.o
|
||||
OBJS-$(CONFIG_VP9_V4L2M2M_DECODER) += v4l2_m2m_dec.o
|
||||
OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
|
||||
OBJS-$(CONFIG_VQC_DECODER) += vqcdec.o
|
||||
OBJS-$(CONFIG_WADY_DPCM_DECODER) += dpcm.o
|
||||
OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o wavpackdata.o dsd.o
|
||||
OBJS-$(CONFIG_WAVPACK_ENCODER) += wavpackdata.o wavpackenc.o
|
||||
OBJS-$(CONFIG_WBMP_DECODER) += wbmpdec.o
|
||||
|
@ -628,6 +628,7 @@ extern const FFCodec ff_roq_dpcm_decoder;
|
||||
extern const FFCodec ff_sdx2_dpcm_decoder;
|
||||
extern const FFCodec ff_sol_dpcm_decoder;
|
||||
extern const FFCodec ff_xan_dpcm_decoder;
|
||||
extern const FFCodec ff_wady_dpcm_decoder;
|
||||
|
||||
/* ADPCM codecs */
|
||||
extern const FFCodec ff_adpcm_4xm_decoder;
|
||||
|
@ -2619,6 +2619,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
|
||||
.long_name = NULL_IF_CONFIG_SMALL("DPCM Xilam DERF"),
|
||||
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
|
||||
},
|
||||
{
|
||||
.id = AV_CODEC_ID_WADY_DPCM,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.name = "wady_dpcm",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("DPCM Marble WADY"),
|
||||
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
|
||||
},
|
||||
|
||||
/* audio codecs */
|
||||
{
|
||||
|
@ -430,6 +430,7 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_SDX2_DPCM,
|
||||
AV_CODEC_ID_GREMLIN_DPCM,
|
||||
AV_CODEC_ID_DERF_DPCM,
|
||||
AV_CODEC_ID_WADY_DPCM,
|
||||
|
||||
/* audio codecs */
|
||||
AV_CODEC_ID_MP2 = 0x15000,
|
||||
|
@ -45,7 +45,8 @@
|
||||
|
||||
typedef struct DPCMContext {
|
||||
int16_t array[256];
|
||||
int sample[2]; ///< previous sample (for SOL_DPCM)
|
||||
int sample[2]; ///< previous sample (for SOL_DPCM and WADY_DPCM)
|
||||
int scale; ///< scale for WADY_DPCM
|
||||
const int8_t *sol_table; ///< delta table for SOL_DPCM
|
||||
} DPCMContext;
|
||||
|
||||
@ -126,6 +127,24 @@ static const int16_t sol_table_16[128] = {
|
||||
0xF00, 0x1000, 0x1400, 0x1800, 0x1C00, 0x2000, 0x3000, 0x4000
|
||||
};
|
||||
|
||||
static const int16_t wady_table[128] = {
|
||||
0, 2, 4, 6, 8, 10, 12, 15,
|
||||
18, 21, 24, 28, 32, 36, 40, 44,
|
||||
49, 54, 59, 64, 70, 76, 82, 88,
|
||||
95, 102, 109, 116, 124, 132, 140, 148,
|
||||
160, 170, 180, 190, 200, 210, 220, 230,
|
||||
240, 255, 270, 285, 300, 320, 340, 360,
|
||||
380, 400, 425, 450, 475, 500, 525, 550,
|
||||
580, 610, 650, 700, 750, 800, 900, 1000,
|
||||
-0, -2, -4, -6, -8, -10, -12, -15,
|
||||
-18, -21, -24, -28, -32, -36, -40, -44,
|
||||
-49, -54, -59, -64, -70, -76, -82, -88,
|
||||
-95, -102,-109,-116,-124,-132,-140,-148,
|
||||
-160,-170,-180,-190,-200,-210,-220,-230,
|
||||
-240,-255,-270,-285,-300,-320,-340,-360,
|
||||
-380,-400,-425,-450,-475,-500,-525,-550,
|
||||
-580,-610,-650,-700,-750,-800,-900,-1000,
|
||||
};
|
||||
|
||||
static av_cold int dpcm_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
@ -139,7 +158,7 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx)
|
||||
|
||||
s->sample[0] = s->sample[1] = 0;
|
||||
|
||||
switch(avctx->codec->id) {
|
||||
switch (avctx->codec->id) {
|
||||
|
||||
case AV_CODEC_ID_ROQ_DPCM:
|
||||
/* initialize square table */
|
||||
@ -193,6 +212,10 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx)
|
||||
}
|
||||
break;
|
||||
|
||||
case AV_CODEC_ID_WADY_DPCM:
|
||||
s->scale = (avctx->extradata && avctx->extradata_size > 0) ? avctx->extradata[0] : 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -239,6 +262,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
else
|
||||
out = buf_size;
|
||||
break;
|
||||
case AV_CODEC_ID_WADY_DPCM:
|
||||
case AV_CODEC_ID_DERF_DPCM:
|
||||
case AV_CODEC_ID_GREMLIN_DPCM:
|
||||
case AV_CODEC_ID_SDX2_DPCM:
|
||||
@ -401,6 +425,22 @@ static int dpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame,
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AV_CODEC_ID_WADY_DPCM: {
|
||||
int idx = 0;
|
||||
|
||||
while (output_samples < samples_end) {
|
||||
const uint8_t n = bytestream2_get_byteu(&gb);
|
||||
|
||||
if (n & 0x80)
|
||||
s->sample[idx] = sign_extend((n & 0x7f) << 9, 16);
|
||||
else
|
||||
s->sample[idx] += s->scale * wady_table[n & 0x7f];
|
||||
*output_samples++ = av_clip_int16(s->sample[idx]);
|
||||
idx ^= stereo;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
*got_frame_ptr = 1;
|
||||
@ -427,3 +467,4 @@ 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");
|
||||
DPCM_DECODER(AV_CODEC_ID_WADY_DPCM, wady_dpcm, "DPCM Marble WADY");
|
||||
|
@ -515,6 +515,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
|
||||
case AV_CODEC_ID_PCM_U8:
|
||||
case AV_CODEC_ID_SDX2_DPCM:
|
||||
case AV_CODEC_ID_DERF_DPCM:
|
||||
case AV_CODEC_ID_WADY_DPCM:
|
||||
return 8;
|
||||
case AV_CODEC_ID_PCM_S16BE:
|
||||
case AV_CODEC_ID_PCM_S16BE_PLANAR:
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "version_major.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MINOR 56
|
||||
#define LIBAVCODEC_VERSION_MINOR 57
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
|
Loading…
Reference in New Issue
Block a user