Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
230703a9
Commit
230703a9
authored
Mar 14, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec: add ADPCM IMA MTF decoder
parent
c149f16d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
0 deletions
+44
-0
Changelog
Changelog
+1
-0
Makefile
libavcodec/Makefile
+1
-0
adpcm.c
libavcodec/adpcm.c
+33
-0
allcodecs.c
libavcodec/allcodecs.c
+1
-0
avcodec.h
libavcodec/avcodec.h
+1
-0
codec_desc.c
libavcodec/codec_desc.c
+7
-0
No files found.
Changelog
View file @
230703a9
...
...
@@ -48,6 +48,7 @@ version <next>:
- AMQP 0-9-1 protocol (RabbitMQ)
- Vulkan support
- avgblur_vulkan, overlay_vulkan, scale_vulkan and chromaber_vulkan filters
- ADPCM IMA MTF decoder
version 4.2:
...
...
libavcodec/Makefile
View file @
230703a9
...
...
@@ -843,6 +843,7 @@ OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_EA_EACS_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_EA_SEAD_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_ISS_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_MTF_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_OKI_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_QT_ENCODER)
+=
adpcmenc.o
adpcm_data.o
...
...
libavcodec/adpcm.c
View file @
230703a9
...
...
@@ -89,6 +89,11 @@ static const int8_t zork_index_table[8] = {
-
1
,
-
1
,
-
1
,
1
,
4
,
7
,
10
,
12
,
};
static
const
int8_t
mtf_index_table
[
16
]
=
{
8
,
6
,
4
,
2
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
2
,
4
,
6
,
8
,
};
/* end of tables */
typedef
struct
ADPCMDecodeContext
{
...
...
@@ -304,6 +309,22 @@ static inline int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, int8_t
return
(
int16_t
)
c
->
predictor
;
}
static
inline
int16_t
adpcm_ima_mtf_expand_nibble
(
ADPCMChannelStatus
*
c
,
int
nibble
)
{
int
step_index
,
step
,
delta
,
predictor
;
step
=
ff_adpcm_step_table
[
c
->
step_index
];
delta
=
step
*
(
2
*
nibble
-
15
);
predictor
=
c
->
predictor
+
delta
;
step_index
=
c
->
step_index
+
mtf_index_table
[(
unsigned
)
nibble
];
c
->
predictor
=
av_clip_int16
(
predictor
>>
4
);
c
->
step_index
=
av_clip
(
step_index
,
0
,
88
);
return
(
int16_t
)
c
->
predictor
;
}
static
inline
int16_t
adpcm_ima_wav_expand_nibble
(
ADPCMChannelStatus
*
c
,
GetBitContext
*
gb
,
int
bps
)
{
int
nibble
,
step_index
,
predictor
,
sign
,
delta
,
diff
,
step
,
shift
;
...
...
@@ -700,6 +721,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
case
AV_CODEC_ID_ADPCM_IMA_SSI
:
case
AV_CODEC_ID_ADPCM_IMA_APM
:
case
AV_CODEC_ID_ADPCM_IMA_ALP
:
case
AV_CODEC_ID_ADPCM_IMA_MTF
:
nb_samples
=
buf_size
*
2
/
ch
;
break
;
}
...
...
@@ -1956,6 +1978,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
*
samples
++
=
adpcm_zork_expand_nibble
(
&
c
->
status
[
n
%
avctx
->
channels
],
v
);
}
break
;
case
AV_CODEC_ID_ADPCM_IMA_MTF
:
for
(
n
=
nb_samples
/
2
;
n
>
0
;
n
--
)
{
for
(
channel
=
0
;
channel
<
avctx
->
channels
;
channel
++
)
{
int
v
=
bytestream2_get_byteu
(
&
gb
);
*
samples
++
=
adpcm_ima_mtf_expand_nibble
(
&
c
->
status
[
channel
],
v
>>
4
);
samples
[
st
]
=
adpcm_ima_mtf_expand_nibble
(
&
c
->
status
[
channel
],
v
&
0x0F
);
}
samples
+=
avctx
->
channels
;
}
break
;
default:
av_assert0
(
0
);
// unsupported codec_id should not happen
}
...
...
@@ -2027,6 +2059,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK4, sample_fmts_s16, adpcm_ima_dk4,
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_IMA_EA_EACS
,
sample_fmts_s16
,
adpcm_ima_ea_eacs
,
"ADPCM IMA Electronic Arts EACS"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_IMA_EA_SEAD
,
sample_fmts_s16
,
adpcm_ima_ea_sead
,
"ADPCM IMA Electronic Arts SEAD"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_IMA_ISS
,
sample_fmts_s16
,
adpcm_ima_iss
,
"ADPCM IMA Funcom ISS"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_IMA_MTF
,
sample_fmts_s16
,
adpcm_ima_mtf
,
"ADPCM IMA Capcom's MT Framework"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_IMA_OKI
,
sample_fmts_s16
,
adpcm_ima_oki
,
"ADPCM IMA Dialogic OKI"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_IMA_QT
,
sample_fmts_s16p
,
adpcm_ima_qt
,
"ADPCM IMA QuickTime"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_IMA_RAD
,
sample_fmts_s16
,
adpcm_ima_rad
,
"ADPCM IMA Radical"
);
...
...
libavcodec/allcodecs.c
View file @
230703a9
...
...
@@ -608,6 +608,7 @@ extern AVCodec ff_adpcm_ima_dk4_decoder;
extern
AVCodec
ff_adpcm_ima_ea_eacs_decoder
;
extern
AVCodec
ff_adpcm_ima_ea_sead_decoder
;
extern
AVCodec
ff_adpcm_ima_iss_decoder
;
extern
AVCodec
ff_adpcm_ima_mtf_decoder
;
extern
AVCodec
ff_adpcm_ima_oki_decoder
;
extern
AVCodec
ff_adpcm_ima_qt_encoder
;
extern
AVCodec
ff_adpcm_ima_qt_decoder
;
...
...
libavcodec/avcodec.h
View file @
230703a9
...
...
@@ -553,6 +553,7 @@ enum AVCodecID {
AV_CODEC_ID_ADPCM_ZORK
,
AV_CODEC_ID_ADPCM_IMA_APM
,
AV_CODEC_ID_ADPCM_IMA_ALP
,
AV_CODEC_ID_ADPCM_IMA_MTF
,
/* AMR */
AV_CODEC_ID_AMR_NB
=
0x12000
,
...
...
libavcodec/codec_desc.c
View file @
230703a9
...
...
@@ -2332,6 +2332,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"ADPCM IMA High Voltage Software ALP"
),
.
props
=
AV_CODEC_PROP_INTRA_ONLY
|
AV_CODEC_PROP_LOSSY
,
},
{
.
id
=
AV_CODEC_ID_ADPCM_IMA_MTF
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
name
=
"adpcm_ima_mtf"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"ADPCM IMA Capcom's MT Framework"
),
.
props
=
AV_CODEC_PROP_INTRA_ONLY
|
AV_CODEC_PROP_LOSSY
,
},
/* AMR */
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment