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
22238d0b
Commit
22238d0b
authored
Oct 12, 2018
by
Cameron Cawley
Committed by
Paul B Mahol
Oct 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec: Implement Archimedes VIDC encoder/decoder
Signed-off-by:
Cameron Cawley
<
ccawley2011@gmail.com
>
parent
fb7925ba
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
72 additions
and
2 deletions
+72
-2
Changelog
Changelog
+1
-0
general.texi
doc/general.texi
+2
-0
Makefile
libavcodec/Makefile
+2
-0
allcodecs.c
libavcodec/allcodecs.c
+2
-0
avcodec.h
libavcodec/avcodec.h
+1
-0
codec_desc.c
libavcodec/codec_desc.c
+7
-0
pcm.c
libavcodec/pcm.c
+15
-0
pcm_tablegen.c
libavcodec/pcm_tablegen.c
+2
-0
pcm_tablegen.h
libavcodec/pcm_tablegen.h
+27
-0
utils.c
libavcodec/utils.c
+1
-0
version.h
libavcodec/version.h
+2
-2
Makefile
libavformat/Makefile
+2
-0
allformats.c
libavformat/allformats.c
+2
-0
pcmdec.c
libavformat/pcmdec.c
+3
-0
pcmenc.c
libavformat/pcmenc.c
+3
-0
No files found.
Changelog
View file @
22238d0b
...
...
@@ -40,6 +40,7 @@ version <next>:
- vibrance filter
- decoding S12M timecode in h264
- xstack filter
- pcm vidc decoder and encoder
version 4.0:
...
...
doc/general.texi
View file @
22238d0b
...
...
@@ -545,6 +545,7 @@ library:
@item raw VC-1 @tab X @tab X
@item raw PCM A-law @tab X @tab X
@item raw PCM mu-law @tab X @tab X
@item raw PCM Archimedes VIDC @tab X @tab X
@item raw PCM signed 8 bit @tab X @tab X
@item raw PCM signed 16 bit big-endian @tab X @tab X
@item raw PCM signed 16 bit little-endian @tab X @tab X
...
...
@@ -1147,6 +1148,7 @@ following image formats are supported:
@tab encoding supported through external library libopus
@item PCM A-law @tab X @tab X
@item PCM mu-law @tab X @tab X
@item PCM Archimedes VIDC @tab X @tab X
@item PCM signed 8-bit planar @tab X @tab X
@item PCM signed 16-bit big-endian planar @tab X @tab X
@item PCM signed 16-bit little-endian planar @tab X @tab X
...
...
libavcodec/Makefile
View file @
22238d0b
...
...
@@ -794,6 +794,8 @@ OBJS-$(CONFIG_PCM_U32BE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_U32BE_ENCODER)
+=
pcm.o
OBJS-$(CONFIG_PCM_U32LE_DECODER)
+=
pcm.o
OBJS-$(CONFIG_PCM_U32LE_ENCODER)
+=
pcm.o
OBJS-$(CONFIG_PCM_VIDC_DECODER)
+=
pcm.o
OBJS-$(CONFIG_PCM_VIDC_ENCODER)
+=
pcm.o
OBJS-$(CONFIG_PCM_ZORK_DECODER)
+=
pcm.o
OBJS-$(CONFIG_ADPCM_4XM_DECODER)
+=
adpcm.o
adpcm_data.o
...
...
libavcodec/allcodecs.c
View file @
22238d0b
...
...
@@ -552,6 +552,8 @@ extern AVCodec ff_pcm_u32be_encoder;
extern
AVCodec
ff_pcm_u32be_decoder
;
extern
AVCodec
ff_pcm_u32le_encoder
;
extern
AVCodec
ff_pcm_u32le_decoder
;
extern
AVCodec
ff_pcm_vidc_encoder
;
extern
AVCodec
ff_pcm_vidc_decoder
;
extern
AVCodec
ff_pcm_zork_decoder
;
/* DPCM codecs */
...
...
libavcodec/avcodec.h
View file @
22238d0b
...
...
@@ -491,6 +491,7 @@ enum AVCodecID {
AV_CODEC_ID_PCM_S64BE
,
AV_CODEC_ID_PCM_F16LE
,
AV_CODEC_ID_PCM_F24LE
,
AV_CODEC_ID_PCM_VIDC
,
/* various ADPCM codecs */
AV_CODEC_ID_ADPCM_IMA_QT
=
0x11000
,
...
...
libavcodec/codec_desc.c
View file @
22238d0b
...
...
@@ -1936,6 +1936,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"PCM 24.0 floating point little-endian"
),
.
props
=
AV_CODEC_PROP_LOSSLESS
,
},
{
.
id
=
AV_CODEC_ID_PCM_VIDC
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
name
=
"pcm_vidc"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"PCM Archimedes VIDC"
),
.
props
=
AV_CODEC_PROP_LOSSY
,
},
/* various ADPCM codecs */
{
...
...
libavcodec/pcm.c
View file @
22238d0b
...
...
@@ -42,6 +42,9 @@ static av_cold int pcm_encode_init(AVCodecContext *avctx)
case
AV_CODEC_ID_PCM_MULAW
:
pcm_ulaw_tableinit
();
break
;
case
AV_CODEC_ID_PCM_VIDC
:
pcm_vidc_tableinit
();
break
;
default:
break
;
}
...
...
@@ -216,6 +219,12 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
*
dst
++
=
linear_to_ulaw
[(
v
+
32768
)
>>
2
];
}
break
;
case
AV_CODEC_ID_PCM_VIDC
:
for
(;
n
>
0
;
n
--
)
{
v
=
*
samples
++
;
*
dst
++
=
linear_to_vidc
[(
v
+
32768
)
>>
2
];
}
break
;
default:
return
-
1
;
}
...
...
@@ -249,6 +258,10 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
for
(
i
=
0
;
i
<
256
;
i
++
)
s
->
table
[
i
]
=
ulaw2linear
(
i
);
break
;
case
AV_CODEC_ID_PCM_VIDC
:
for
(
i
=
0
;
i
<
256
;
i
++
)
s
->
table
[
i
]
=
vidc2linear
(
i
);
break
;
case
AV_CODEC_ID_PCM_F16LE
:
case
AV_CODEC_ID_PCM_F24LE
:
s
->
scale
=
1
.
/
(
1
<<
(
avctx
->
bits_per_coded_sample
-
1
));
...
...
@@ -485,6 +498,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
break
;
case
AV_CODEC_ID_PCM_ALAW
:
case
AV_CODEC_ID_PCM_MULAW
:
case
AV_CODEC_ID_PCM_VIDC
:
for
(;
n
>
0
;
n
--
)
{
AV_WN16A
(
samples
,
s
->
table
[
*
src
++
]);
samples
+=
2
;
...
...
@@ -612,3 +626,4 @@ PCM_CODEC (PCM_U32LE, AV_SAMPLE_FMT_S32, pcm_u32le, "PCM unsigned
PCM_DECODER
(
PCM_ZORK
,
AV_SAMPLE_FMT_U8
,
pcm_zork
,
"PCM Zork"
);
PCM_CODEC
(
PCM_S64BE
,
AV_SAMPLE_FMT_S64
,
pcm_s64be
,
"PCM signed 64-bit big-endian"
);
PCM_CODEC
(
PCM_S64LE
,
AV_SAMPLE_FMT_S64
,
pcm_s64le
,
"PCM signed 64-bit little-endian"
);
PCM_CODEC
(
PCM_VIDC
,
AV_SAMPLE_FMT_S16
,
pcm_vidc
,
"PCM Archimedes VIDC"
);
libavcodec/pcm_tablegen.c
View file @
22238d0b
...
...
@@ -29,11 +29,13 @@ int main(void)
{
pcm_alaw_tableinit
();
pcm_ulaw_tableinit
();
pcm_vidc_tableinit
();
write_fileheader
();
WRITE_ARRAY
(
"static const"
,
uint8_t
,
linear_to_alaw
);
WRITE_ARRAY
(
"static const"
,
uint8_t
,
linear_to_ulaw
);
WRITE_ARRAY
(
"static const"
,
uint8_t
,
linear_to_vidc
);
return
0
;
}
libavcodec/pcm_tablegen.h
View file @
22238d0b
...
...
@@ -36,6 +36,12 @@
#define BIAS (0x84)
/* Bias for linear code. */
#define VIDC_SIGN_BIT (1)
#define VIDC_QUANT_MASK (0x1E)
#define VIDC_QUANT_SHIFT (1)
#define VIDC_SEG_SHIFT (5)
#define VIDC_SEG_MASK (0xE0)
/* alaw2linear() - Convert an A-law value to 16-bit linear PCM */
static
av_cold
int
alaw2linear
(
unsigned
char
a_val
)
{
...
...
@@ -69,14 +75,30 @@ static av_cold int ulaw2linear(unsigned char u_val)
return
(
u_val
&
SIGN_BIT
)
?
(
BIAS
-
t
)
:
(
t
-
BIAS
);
}
static
av_cold
int
vidc2linear
(
unsigned
char
u_val
)
{
int
t
;
/*
* Extract and bias the quantization bits. Then
* shift up by the segment number and subtract out the bias.
*/
t
=
(((
u_val
&
VIDC_QUANT_MASK
)
>>
VIDC_QUANT_SHIFT
)
<<
3
)
+
BIAS
;
t
<<=
((
unsigned
)
u_val
&
VIDC_SEG_MASK
)
>>
VIDC_SEG_SHIFT
;
return
(
u_val
&
VIDC_SIGN_BIT
)
?
(
BIAS
-
t
)
:
(
t
-
BIAS
);
}
#if CONFIG_HARDCODED_TABLES
#define pcm_alaw_tableinit()
#define pcm_ulaw_tableinit()
#define pcm_vidc_tableinit()
#include "libavcodec/pcm_tables.h"
#else
/* 16384 entries per table */
static
uint8_t
linear_to_alaw
[
16384
];
static
uint8_t
linear_to_ulaw
[
16384
];
static
uint8_t
linear_to_vidc
[
16384
];
static
av_cold
void
build_xlaw_table
(
uint8_t
*
linear_to_xlaw
,
int
(
*
xlaw2linear
)(
unsigned
char
),
...
...
@@ -111,6 +133,11 @@ static void pcm_ulaw_tableinit(void)
{
build_xlaw_table
(
linear_to_ulaw
,
ulaw2linear
,
0xff
);
}
static
void
pcm_vidc_tableinit
(
void
)
{
build_xlaw_table
(
linear_to_vidc
,
vidc2linear
,
0xff
);
}
#endif
/* CONFIG_HARDCODED_TABLES */
#endif
/* AVCODEC_PCM_TABLEGEN_H */
libavcodec/utils.c
View file @
22238d0b
...
...
@@ -1438,6 +1438,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
case
AV_CODEC_ID_DSD_MSBF_PLANAR
:
case
AV_CODEC_ID_PCM_ALAW
:
case
AV_CODEC_ID_PCM_MULAW
:
case
AV_CODEC_ID_PCM_VIDC
:
case
AV_CODEC_ID_PCM_S8
:
case
AV_CODEC_ID_PCM_S8_PLANAR
:
case
AV_CODEC_ID_PCM_U8
:
...
...
libavcodec/version.h
View file @
22238d0b
...
...
@@ -28,8 +28,8 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 3
3
#define LIBAVCODEC_VERSION_MICRO 10
2
#define LIBAVCODEC_VERSION_MINOR 3
4
#define LIBAVCODEC_VERSION_MICRO 10
0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
...
...
libavformat/Makefile
View file @
22238d0b
...
...
@@ -411,6 +411,8 @@ OBJS-$(CONFIG_PCM_U32LE_DEMUXER) += pcmdec.o pcm.o
OBJS-$(CONFIG_PCM_U32LE_MUXER)
+=
pcmenc.o
rawenc.o
OBJS-$(CONFIG_PCM_U8_DEMUXER)
+=
pcmdec.o
pcm.o
OBJS-$(CONFIG_PCM_U8_MUXER)
+=
pcmenc.o
rawenc.o
OBJS-$(CONFIG_PCM_VIDC_DEMUXER)
+=
pcmdec.o
pcm.o
OBJS-$(CONFIG_PCM_VIDC_MUXER)
+=
pcmenc.o
rawenc.o
OBJS-$(CONFIG_PJS_DEMUXER)
+=
pjsdec.o
subtitles.o
OBJS-$(CONFIG_PMP_DEMUXER)
+=
pmpdec.o
OBJS-$(CONFIG_PVA_DEMUXER)
+=
pva.o
...
...
libavformat/allformats.c
View file @
22238d0b
...
...
@@ -289,6 +289,8 @@ extern AVInputFormat ff_pcm_alaw_demuxer;
extern
AVOutputFormat
ff_pcm_alaw_muxer
;
extern
AVInputFormat
ff_pcm_mulaw_demuxer
;
extern
AVOutputFormat
ff_pcm_mulaw_muxer
;
extern
AVInputFormat
ff_pcm_vidc_demuxer
;
extern
AVOutputFormat
ff_pcm_vidc_muxer
;
extern
AVInputFormat
ff_pcm_f64be_demuxer
;
extern
AVOutputFormat
ff_pcm_f64be_muxer
;
extern
AVInputFormat
ff_pcm_f64le_demuxer
;
...
...
libavformat/pcmdec.c
View file @
22238d0b
...
...
@@ -177,6 +177,9 @@ PCMDEF(alaw, "PCM A-law",
PCMDEF
(
mulaw
,
"PCM mu-law"
,
"ul"
,
AV_CODEC_ID_PCM_MULAW
)
PCMDEF
(
vidc
,
"PCM Archimedes VIDC"
,
NULL
,
AV_CODEC_ID_PCM_VIDC
)
static
const
AVOption
sln_options
[]
=
{
{
"sample_rate"
,
""
,
offsetof
(
PCMAudioDemuxerContext
,
sample_rate
),
AV_OPT_TYPE_INT
,
{.
i64
=
8000
},
0
,
INT_MAX
,
AV_OPT_FLAG_DECODING_PARAM
},
{
"channels"
,
""
,
offsetof
(
PCMAudioDemuxerContext
,
channels
),
AV_OPT_TYPE_INT
,
{.
i64
=
1
},
0
,
INT_MAX
,
AV_OPT_FLAG_DECODING_PARAM
},
...
...
libavformat/pcmenc.c
View file @
22238d0b
...
...
@@ -92,3 +92,6 @@ PCMDEF(alaw, "PCM A-law",
PCMDEF
(
mulaw
,
"PCM mu-law"
,
"ul"
,
AV_CODEC_ID_PCM_MULAW
)
PCMDEF
(
vidc
,
"PCM Archimedes VIDC"
,
NULL
,
AV_CODEC_ID_PCM_VIDC
)
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