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
e7814ed8
Commit
e7814ed8
authored
May 03, 2013
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ADPCM DTK decoder
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
b2cf655d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
71 additions
and
3 deletions
+71
-3
Changelog
Changelog
+1
-0
general.texi
doc/general.texi
+1
-0
Makefile
libavcodec/Makefile
+1
-0
adpcm.c
libavcodec/adpcm.c
+54
-0
adpcm.h
libavcodec/adpcm.h
+2
-2
allcodecs.c
libavcodec/allcodecs.c
+1
-0
avcodec.h
libavcodec/avcodec.h
+1
-0
codec_desc.c
libavcodec/codec_desc.c
+7
-0
utils.c
libavcodec/utils.c
+2
-0
version.h
libavcodec/version.h
+1
-1
No files found.
Changelog
View file @
e7814ed8
...
...
@@ -40,6 +40,7 @@ version <next>:
- Matroska muxer can now put the index at the beginning of the file.
- extractplanes filter
- avectorscope filter
- ADPCM DTK decoder
version 1.2:
...
...
doc/general.texi
View file @
e7814ed8
...
...
@@ -771,6 +771,7 @@ following image formats are supported:
@item ADPCM Microsoft @tab X @tab X
@item ADPCM MS IMA @tab X @tab X
@item ADPCM Nintendo Gamecube AFC @tab @tab X
@item ADPCM Nintendo Gamecube DTK @tab @tab X
@item ADPCM Nintendo Gamecube THP @tab @tab X
@item ADPCM QT IMA @tab X @tab X
@item ADPCM SEGA CRI ADX @tab X @tab X
...
...
libavcodec/Makefile
View file @
e7814ed8
...
...
@@ -569,6 +569,7 @@ OBJS-$(CONFIG_ADPCM_ADX_DECODER) += adxdec.o adx.o
OBJS-$(CONFIG_ADPCM_ADX_ENCODER)
+=
adxenc.o
adx.o
OBJS-$(CONFIG_ADPCM_AFC_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_CT_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_DTK_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_EA_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_EA_MAXIS_XA_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_EA_R1_DECODER)
+=
adpcm.o
adpcm_data.o
...
...
libavcodec/adpcm.c
View file @
e7814ed8
...
...
@@ -95,6 +95,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
unsigned
int
max_channels
=
2
;
switch
(
avctx
->
codec
->
id
)
{
case
AV_CODEC_ID_ADPCM_DTK
:
case
AV_CODEC_ID_ADPCM_EA
:
min_channels
=
2
;
break
;
...
...
@@ -147,6 +148,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
case
AV_CODEC_ID_ADPCM_EA_XAS
:
case
AV_CODEC_ID_ADPCM_THP
:
case
AV_CODEC_ID_ADPCM_AFC
:
case
AV_CODEC_ID_ADPCM_DTK
:
avctx
->
sample_fmt
=
AV_SAMPLE_FMT_S16P
;
break
;
case
AV_CODEC_ID_ADPCM_IMA_WS
:
...
...
@@ -602,6 +604,9 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
case
AV_CODEC_ID_ADPCM_XA
:
nb_samples
=
(
buf_size
/
128
)
*
224
/
ch
;
break
;
case
AV_CODEC_ID_ADPCM_DTK
:
nb_samples
=
buf_size
/
(
16
*
ch
)
*
28
;
break
;
}
/* validate coded sample count */
...
...
@@ -1362,6 +1367,54 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
}
break
;
}
case
AV_CODEC_ID_ADPCM_DTK
:
for
(
channel
=
0
;
channel
<
avctx
->
channels
;
channel
++
)
{
samples
=
samples_p
[
channel
];
/* Read in every sample for this channel. */
for
(
i
=
0
;
i
<
nb_samples
/
28
;
i
++
)
{
int
byte
,
header
;
if
(
channel
)
bytestream2_skipu
(
&
gb
,
1
);
header
=
bytestream2_get_byteu
(
&
gb
);
bytestream2_skipu
(
&
gb
,
3
-
channel
);
/* Decode 28 samples. */
for
(
n
=
0
;
n
<
28
;
n
++
)
{
int32_t
sampledat
,
prev
;
switch
(
header
>>
4
)
{
case
1
:
prev
=
(
c
->
status
[
channel
].
sample1
*
0x3c
);
break
;
case
2
:
prev
=
(
c
->
status
[
channel
].
sample1
*
0x73
)
-
(
c
->
status
[
channel
].
sample2
*
0x34
);
break
;
case
3
:
prev
=
(
c
->
status
[
channel
].
sample1
*
0x62
)
-
(
c
->
status
[
channel
].
sample2
*
0x37
);
break
;
default:
prev
=
0
;
}
prev
=
av_clip
((
prev
+
0x20
)
>>
6
,
-
0x200000
,
0x1fffff
);
byte
=
bytestream2_get_byteu
(
&
gb
);
if
(
!
channel
)
sampledat
=
sign_extend
(
byte
,
4
);
else
sampledat
=
sign_extend
(
byte
>>
4
,
4
);
sampledat
=
(((
sampledat
<<
12
)
>>
(
header
&
0xf
))
<<
6
)
+
prev
;
*
samples
++
=
av_clip_int16
(
sampledat
>>
6
);
c
->
status
[
channel
].
sample2
=
c
->
status
[
channel
].
sample1
;
c
->
status
[
channel
].
sample1
=
sampledat
;
}
}
if
(
!
channel
)
bytestream2_seek
(
&
gb
,
0
,
SEEK_SET
);
}
break
;
default:
return
-
1
;
...
...
@@ -1403,6 +1456,7 @@ AVCodec ff_ ## name_ ## _decoder = { \
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_4XM
,
sample_fmts_s16p
,
adpcm_4xm
,
"ADPCM 4X Movie"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_AFC
,
sample_fmts_s16p
,
adpcm_afc
,
"ADPCM Nintendo Gamecube AFC"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_CT
,
sample_fmts_s16
,
adpcm_ct
,
"ADPCM Creative Technology"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_DTK
,
sample_fmts_s16p
,
adpcm_dtk
,
"ADPCM Nintendo Gamecube DTK"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_EA
,
sample_fmts_s16
,
adpcm_ea
,
"ADPCM Electronic Arts"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_EA_MAXIS_XA
,
sample_fmts_s16
,
adpcm_ea_maxis_xa
,
"ADPCM Electronic Arts Maxis CDROM XA"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_EA_R1
,
sample_fmts_s16p
,
adpcm_ea_r1
,
"ADPCM Electronic Arts R1"
);
...
...
libavcodec/adpcm.h
View file @
e7814ed8
...
...
@@ -38,8 +38,8 @@ typedef struct ADPCMChannelStatus {
int
prev_sample
;
/* MS version */
int
16_t
sample1
;
int
16_t
sample2
;
int
sample1
;
int
sample2
;
int
coeff1
;
int
coeff2
;
int
idelta
;
...
...
libavcodec/allcodecs.c
View file @
e7814ed8
...
...
@@ -419,6 +419,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC
(
ADPCM_ADX
,
adpcm_adx
);
REGISTER_DECODER
(
ADPCM_AFC
,
adpcm_afc
);
REGISTER_DECODER
(
ADPCM_CT
,
adpcm_ct
);
REGISTER_DECODER
(
ADPCM_DTK
,
adpcm_dtk
);
REGISTER_DECODER
(
ADPCM_EA
,
adpcm_ea
);
REGISTER_DECODER
(
ADPCM_EA_MAXIS_XA
,
adpcm_ea_maxis_xa
);
REGISTER_DECODER
(
ADPCM_EA_R1
,
adpcm_ea_r1
);
...
...
libavcodec/avcodec.h
View file @
e7814ed8
...
...
@@ -362,6 +362,7 @@ enum AVCodecID {
AV_CODEC_ID_VIMA
=
MKBETAG
(
'V'
,
'I'
,
'M'
,
'A'
),
AV_CODEC_ID_ADPCM_AFC
=
MKBETAG
(
'A'
,
'F'
,
'C'
,
' '
),
AV_CODEC_ID_ADPCM_IMA_OKI
=
MKBETAG
(
'O'
,
'K'
,
'I'
,
' '
),
AV_CODEC_ID_ADPCM_DTK
=
MKBETAG
(
'D'
,
'T'
,
'K'
,
' '
),
/* AMR */
AV_CODEC_ID_AMR_NB
=
0x12000
,
...
...
libavcodec/codec_desc.c
View file @
e7814ed8
...
...
@@ -1816,6 +1816,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"ADPCM IMA Dialogic OKI"
),
.
props
=
AV_CODEC_PROP_LOSSY
,
},
{
.
id
=
AV_CODEC_ID_ADPCM_DTK
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
name
=
"adpcm_dtk"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"ADPCM Nintendo Gamecube DTK"
),
.
props
=
AV_CODEC_PROP_LOSSY
,
},
/* AMR */
{
...
...
libavcodec/utils.c
View file @
e7814ed8
...
...
@@ -2835,6 +2835,8 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
switch
(
id
)
{
case
AV_CODEC_ID_ADPCM_AFC
:
return
frame_bytes
/
(
9
*
ch
)
*
16
;
case
AV_CODEC_ID_ADPCM_DTK
:
return
frame_bytes
/
(
16
*
ch
)
*
28
;
case
AV_CODEC_ID_ADPCM_4XM
:
case
AV_CODEC_ID_ADPCM_IMA_ISS
:
return
(
frame_bytes
-
4
*
ch
)
*
2
/
ch
;
...
...
libavcodec/version.h
View file @
e7814ed8
...
...
@@ -29,7 +29,7 @@
#include "libavutil/avutil.h"
#define LIBAVCODEC_VERSION_MAJOR 55
#define LIBAVCODEC_VERSION_MINOR
7
#define LIBAVCODEC_VERSION_MINOR
8
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
...
...
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