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
898ea658
Commit
898ea658
authored
Aug 18, 2017
by
Carl Eugen Hoyos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/g726: Add a little-endian G.726 encoder.
Fixes ticket #6596.
parent
8754ccd3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
11 deletions
+88
-11
Makefile
libavcodec/Makefile
+1
-0
allcodecs.c
libavcodec/allcodecs.c
+1
-1
g726.c
libavcodec/g726.c
+45
-9
put_bits.h
libavcodec/put_bits.h
+40
-0
version.h
libavcodec/version.h
+1
-1
No files found.
libavcodec/Makefile
View file @
898ea658
...
...
@@ -763,6 +763,7 @@ OBJS-$(CONFIG_ADPCM_G722_ENCODER) += g722.o g722dsp.o g722enc.o
OBJS-$(CONFIG_ADPCM_G726_DECODER)
+=
g726.o
OBJS-$(CONFIG_ADPCM_G726_ENCODER)
+=
g726.o
OBJS-$(CONFIG_ADPCM_G726LE_DECODER)
+=
g726.o
OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)
+=
g726.o
OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)
+=
adpcm.o
adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER)
+=
adpcm.o
adpcm_data.o
...
...
libavcodec/allcodecs.c
View file @
898ea658
...
...
@@ -549,7 +549,7 @@ static void register_all(void)
REGISTER_DECODER
(
ADPCM_EA_XAS
,
adpcm_ea_xas
);
REGISTER_ENCDEC
(
ADPCM_G722
,
adpcm_g722
);
REGISTER_ENCDEC
(
ADPCM_G726
,
adpcm_g726
);
REGISTER_
DECODER
(
ADPCM_G726LE
,
adpcm_g726le
);
REGISTER_
ENCDEC
(
ADPCM_G726LE
,
adpcm_g726le
);
REGISTER_DECODER
(
ADPCM_IMA_AMV
,
adpcm_ima_amv
);
REGISTER_DECODER
(
ADPCM_IMA_APC
,
adpcm_ima_apc
);
REGISTER_DECODER
(
ADPCM_IMA_DAT4
,
adpcm_ima_dat4
);
...
...
libavcodec/g726.c
View file @
898ea658
...
...
@@ -292,7 +292,7 @@ static av_cold int g726_reset(G726Context *c)
return
0
;
}
#if CONFIG_ADPCM_G726_ENCODER
#if CONFIG_ADPCM_G726_ENCODER
|| CONFIG_ADPCM_G726LE_ENCODER
static
int16_t
g726_encode
(
G726Context
*
c
,
int16_t
sig
)
{
uint8_t
i
;
...
...
@@ -308,6 +308,8 @@ static av_cold int g726_encode_init(AVCodecContext *avctx)
{
G726Context
*
c
=
avctx
->
priv_data
;
c
->
little_endian
=
!
strcmp
(
avctx
->
codec
->
name
,
"g726le"
);
if
(
avctx
->
strict_std_compliance
>
FF_COMPLIANCE_UNOFFICIAL
&&
avctx
->
sample_rate
!=
8000
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Sample rates other than 8kHz are not "
...
...
@@ -356,9 +358,17 @@ static int g726_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
init_put_bits
(
&
pb
,
avpkt
->
data
,
avpkt
->
size
);
for
(
i
=
0
;
i
<
frame
->
nb_samples
;
i
++
)
put_bits
(
&
pb
,
c
->
code_size
,
g726_encode
(
c
,
*
samples
++
));
flush_put_bits
(
&
pb
);
if
(
c
->
little_endian
)
{
put_bits_le
(
&
pb
,
c
->
code_size
,
g726_encode
(
c
,
*
samples
++
));
}
else
{
put_bits
(
&
pb
,
c
->
code_size
,
g726_encode
(
c
,
*
samples
++
));
}
if
(
c
->
little_endian
)
{
flush_put_bits_le
(
&
pb
);
}
else
{
flush_put_bits
(
&
pb
);
}
avpkt
->
size
=
out_size
;
*
got_packet_ptr
=
1
;
...
...
@@ -372,6 +382,13 @@ static const AVOption options[] = {
{
NULL
},
};
static
const
AVCodecDefault
defaults
[]
=
{
{
"b"
,
"0"
},
{
NULL
},
};
#endif
#if CONFIG_ADPCM_G726_ENCODER
static
const
AVClass
g726_class
=
{
.
class_name
=
"g726"
,
.
item_name
=
av_default_item_name
,
...
...
@@ -379,11 +396,6 @@ static const AVClass g726_class = {
.
version
=
LIBAVUTIL_VERSION_INT
,
};
static
const
AVCodecDefault
defaults
[]
=
{
{
"b"
,
"0"
},
{
NULL
},
};
AVCodec
ff_adpcm_g726_encoder
=
{
.
name
=
"g726"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"G.726 ADPCM"
),
...
...
@@ -400,6 +412,30 @@ AVCodec ff_adpcm_g726_encoder = {
};
#endif
#if CONFIG_ADPCM_G726LE_ENCODER
static
const
AVClass
g726le_class
=
{
.
class_name
=
"g726le"
,
.
item_name
=
av_default_item_name
,
.
option
=
options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
AVCodec
ff_adpcm_g726le_encoder
=
{
.
name
=
"g726le"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"G.726 little endian ADPCM (
\"
right-justified
\"
)"
),
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
id
=
AV_CODEC_ID_ADPCM_G726LE
,
.
priv_data_size
=
sizeof
(
G726Context
),
.
init
=
g726_encode_init
,
.
encode2
=
g726_encode_frame
,
.
capabilities
=
AV_CODEC_CAP_SMALL_LAST_FRAME
,
.
sample_fmts
=
(
const
enum
AVSampleFormat
[]){
AV_SAMPLE_FMT_S16
,
AV_SAMPLE_FMT_NONE
},
.
priv_class
=
&
g726le_class
,
.
defaults
=
defaults
,
};
#endif
#if CONFIG_ADPCM_G726_DECODER || CONFIG_ADPCM_G726LE_DECODER
static
av_cold
int
g726_decode_init
(
AVCodecContext
*
avctx
)
{
...
...
libavcodec/put_bits.h
View file @
898ea658
...
...
@@ -119,6 +119,18 @@ static inline void flush_put_bits(PutBitContext *s)
s
->
bit_buf
=
0
;
}
static
inline
void
flush_put_bits_le
(
PutBitContext
*
s
)
{
while
(
s
->
bit_left
<
32
)
{
av_assert0
(
s
->
buf_ptr
<
s
->
buf_end
);
*
s
->
buf_ptr
++
=
s
->
bit_buf
;
s
->
bit_buf
>>=
8
;
s
->
bit_left
+=
8
;
}
s
->
bit_left
=
32
;
s
->
bit_buf
=
0
;
}
#ifdef BITSTREAM_WRITER_LE
#define avpriv_align_put_bits align_put_bits_unsupported_here
#define avpriv_put_string ff_put_string_unsupported_here
...
...
@@ -197,6 +209,34 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
s
->
bit_left
=
bit_left
;
}
static
inline
void
put_bits_le
(
PutBitContext
*
s
,
int
n
,
unsigned
int
value
)
{
unsigned
int
bit_buf
;
int
bit_left
;
av_assert2
(
n
<=
31
&&
value
<
(
1U
<<
n
));
bit_buf
=
s
->
bit_buf
;
bit_left
=
s
->
bit_left
;
bit_buf
|=
value
<<
(
32
-
bit_left
);
if
(
n
>=
bit_left
)
{
if
(
3
<
s
->
buf_end
-
s
->
buf_ptr
)
{
AV_WL32
(
s
->
buf_ptr
,
bit_buf
);
s
->
buf_ptr
+=
4
;
}
else
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Internal error, put_bits buffer too small
\n
"
);
av_assert2
(
0
);
}
bit_buf
=
value
>>
bit_left
;
bit_left
+=
32
;
}
bit_left
-=
n
;
s
->
bit_buf
=
bit_buf
;
s
->
bit_left
=
bit_left
;
}
static
inline
void
put_sbits
(
PutBitContext
*
pb
,
int
n
,
int32_t
value
)
{
av_assert2
(
n
>=
0
&&
n
<=
31
);
...
...
libavcodec/version.h
View file @
898ea658
...
...
@@ -28,7 +28,7 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 57
#define LIBAVCODEC_VERSION_MINOR 10
2
#define LIBAVCODEC_VERSION_MINOR 10
3
#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