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
d0f24df6
Commit
d0f24df6
authored
Apr 10, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec: add ADPCM AGM decoder
parent
7be8f7ac
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
3 deletions
+72
-3
Makefile
libavcodec/Makefile
+1
-0
adpcm.c
libavcodec/adpcm.c
+58
-0
allcodecs.c
libavcodec/allcodecs.c
+1
-0
avcodec.h
libavcodec/avcodec.h
+1
-0
codec_desc.c
libavcodec/codec_desc.c
+7
-0
version.h
libavcodec/version.h
+2
-2
riff.c
libavformat/riff.c
+1
-0
version.h
libavformat/version.h
+1
-1
No files found.
libavcodec/Makefile
View file @
d0f24df6
...
...
@@ -808,6 +808,7 @@ OBJS-$(CONFIG_ADPCM_4XM_DECODER) += adpcm.o adpcm_data.o
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_AGM_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_AICA_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
...
...
libavcodec/adpcm.c
View file @
d0f24df6
...
...
@@ -177,6 +177,50 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
return
0
;
}
static
inline
int16_t
adpcm_agm_expand_nibble
(
ADPCMChannelStatus
*
c
,
int8_t
nibble
)
{
int
delta
,
pred
,
step
,
add
;
pred
=
c
->
predictor
;
delta
=
nibble
&
7
;
step
=
c
->
step
;
add
=
(
delta
*
2
+
1
)
*
step
;
if
(
add
<
0
)
add
=
add
+
7
;
if
((
nibble
&
8
)
==
0
)
pred
=
av_clip
(
pred
+
(
add
>>
3
),
-
32767
,
32767
);
else
pred
=
av_clip
(
pred
-
(
add
>>
3
),
-
32767
,
32767
);
switch
(
delta
)
{
case
7
:
step
*=
0x99
;
break
;
case
6
:
c
->
step
=
av_clip
(
c
->
step
*
2
,
127
,
24576
);
c
->
predictor
=
pred
;
return
pred
;
case
5
:
step
*=
0x66
;
break
;
case
4
:
step
*=
0x4d
;
break
;
default:
step
*=
0x39
;
break
;
}
if
(
step
<
0
)
step
+=
0x3f
;
c
->
step
=
step
>>
6
;
c
->
step
=
av_clip
(
c
->
step
,
127
,
24576
);
c
->
predictor
=
pred
;
return
pred
;
}
static
inline
int16_t
adpcm_ima_expand_nibble
(
ADPCMChannelStatus
*
c
,
int8_t
nibble
,
int
shift
)
{
int
step_index
;
...
...
@@ -549,6 +593,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
header_size
=
0
;
switch
(
avctx
->
codec
->
id
)
{
case
AV_CODEC_ID_ADPCM_4XM
:
case
AV_CODEC_ID_ADPCM_AGM
:
case
AV_CODEC_ID_ADPCM_IMA_DAT4
:
case
AV_CODEC_ID_ADPCM_IMA_ISS
:
header_size
=
4
*
ch
;
break
;
case
AV_CODEC_ID_ADPCM_IMA_AMV
:
header_size
=
8
;
break
;
...
...
@@ -863,6 +908,18 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
}
}
break
;
case
AV_CODEC_ID_ADPCM_AGM
:
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
c
->
status
[
i
].
predictor
=
sign_extend
(
bytestream2_get_le16u
(
&
gb
),
16
);
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
c
->
status
[
i
].
step
=
sign_extend
(
bytestream2_get_le16u
(
&
gb
),
16
);
for
(
n
=
0
;
n
<
nb_samples
>>
(
1
-
st
);
n
++
)
{
int
v
=
bytestream2_get_byteu
(
&
gb
);
*
samples
++
=
adpcm_agm_expand_nibble
(
&
c
->
status
[
0
],
v
&
0xF
);
*
samples
++
=
adpcm_agm_expand_nibble
(
&
c
->
status
[
st
],
v
>>
4
);
}
break
;
case
AV_CODEC_ID_ADPCM_MS
:
{
int
block_predictor
;
...
...
@@ -1729,6 +1786,7 @@ AVCodec ff_ ## name_ ## _decoder = { \
/* Note: Do not forget to add new entries to the Makefile as well. */
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_AGM
,
sample_fmts_s16
,
adpcm_agm
,
"ADPCM AmuseGraphics Movie"
);
ADPCM_DECODER
(
AV_CODEC_ID_ADPCM_AICA
,
sample_fmts_s16p
,
adpcm_aica
,
"ADPCM Yamaha AICA"
);
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"
);
...
...
libavcodec/allcodecs.c
View file @
d0f24df6
...
...
@@ -574,6 +574,7 @@ extern AVCodec ff_adpcm_4xm_decoder;
extern
AVCodec
ff_adpcm_adx_encoder
;
extern
AVCodec
ff_adpcm_adx_decoder
;
extern
AVCodec
ff_adpcm_afc_decoder
;
extern
AVCodec
ff_adpcm_agm_decoder
;
extern
AVCodec
ff_adpcm_aica_decoder
;
extern
AVCodec
ff_adpcm_ct_decoder
;
extern
AVCodec
ff_adpcm_dtk_decoder
;
...
...
libavcodec/avcodec.h
View file @
d0f24df6
...
...
@@ -539,6 +539,7 @@ enum AVCodecID {
AV_CODEC_ID_ADPCM_AICA
,
AV_CODEC_ID_ADPCM_IMA_DAT4
,
AV_CODEC_ID_ADPCM_MTAF
,
AV_CODEC_ID_ADPCM_AGM
,
/* AMR */
AV_CODEC_ID_AMR_NB
=
0x12000
,
...
...
libavcodec/codec_desc.c
View file @
d0f24df6
...
...
@@ -2255,6 +2255,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"ADPCM MTAF"
),
.
props
=
AV_CODEC_PROP_LOSSY
,
},
{
.
id
=
AV_CODEC_ID_ADPCM_AGM
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
name
=
"adpcm_agm"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"ADPCM AmuseGraphics Movie AGM"
),
.
props
=
AV_CODEC_PROP_LOSSY
,
},
/* AMR */
{
...
...
libavcodec/version.h
View file @
d0f24df6
...
...
@@ -28,8 +28,8 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 4
8
#define LIBAVCODEC_VERSION_MICRO 10
1
#define LIBAVCODEC_VERSION_MINOR 4
9
#define LIBAVCODEC_VERSION_MICRO 10
0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
...
...
libavformat/riff.c
View file @
d0f24df6
...
...
@@ -605,5 +605,6 @@ const AVCodecGuid ff_codec_wav_guids[] = {
{
AV_CODEC_ID_ATRAC9
,
{
0xD2
,
0x42
,
0xE1
,
0x47
,
0xBA
,
0x36
,
0x8D
,
0x4D
,
0x88
,
0xFC
,
0x61
,
0x65
,
0x4F
,
0x8C
,
0x83
,
0x6C
}
},
{
AV_CODEC_ID_EAC3
,
{
0xAF
,
0x87
,
0xFB
,
0xA7
,
0x02
,
0x2D
,
0xFB
,
0x42
,
0xA4
,
0xD4
,
0x05
,
0xCD
,
0x93
,
0x84
,
0x3B
,
0xDD
}
},
{
AV_CODEC_ID_MP2
,
{
0x2B
,
0x80
,
0x6D
,
0xE0
,
0x46
,
0xDB
,
0xCF
,
0x11
,
0xB4
,
0xD1
,
0x00
,
0x80
,
0x5F
,
0x6C
,
0xBB
,
0xEA
}
},
{
AV_CODEC_ID_ADPCM_AGM
,{
0x82
,
0xEC
,
0x1F
,
0x6A
,
0xCA
,
0xDB
,
0x19
,
0x45
,
0xBD
,
0xE7
,
0x56
,
0xD3
,
0xB3
,
0xEF
,
0x98
,
0x1D
}
},
{
AV_CODEC_ID_NONE
}
};
libavformat/version.h
View file @
d0f24df6
...
...
@@ -33,7 +33,7 @@
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 58
#define LIBAVFORMAT_VERSION_MINOR 27
#define LIBAVFORMAT_VERSION_MICRO 10
0
#define LIBAVFORMAT_VERSION_MICRO 10
1
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
...
...
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