Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
64c64cb4
Commit
64c64cb4
authored
May 29, 2019
by
Anton Khirnov
Committed by
James Almer
Mar 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
g729: convert to new channel layout API
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
e763a7cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
g729_parser.c
libavcodec/g729_parser.c
+2
-2
g729dec.c
libavcodec/g729dec.c
+11
-9
No files found.
libavcodec/g729_parser.c
View file @
64c64cb4
...
...
@@ -49,9 +49,9 @@ static int g729_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
if
(
avctx
->
codec_id
==
AV_CODEC_ID_ACELP_KELVIN
)
s
->
block_size
++
;
// channels > 2 is invalid, we pass the packet on unchanged
if
(
avctx
->
channels
>
2
)
if
(
avctx
->
ch
_layout
.
nb_ch
annels
>
2
)
s
->
block_size
=
0
;
s
->
block_size
*=
avctx
->
channels
;
s
->
block_size
*=
avctx
->
ch
_layout
.
nb_ch
annels
;
s
->
duration
=
avctx
->
frame_size
;
}
...
...
libavcodec/g729dec.c
View file @
64c64cb4
...
...
@@ -350,10 +350,11 @@ static av_cold int decoder_init(AVCodecContext * avctx)
{
G729Context
*
s
=
avctx
->
priv_data
;
G729ChannelContext
*
ctx
;
int
channels
=
avctx
->
ch_layout
.
nb_channels
;
int
c
,
i
,
k
;
if
(
avctx
->
channels
<
1
||
avctx
->
channels
>
2
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Only mono and stereo are supported (requested channels: %d).
\n
"
,
avctx
->
channels
);
if
(
channels
<
1
||
channels
>
2
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Only mono and stereo are supported (requested channels: %d).
\n
"
,
channels
);
return
AVERROR
(
EINVAL
);
}
avctx
->
sample_fmt
=
AV_SAMPLE_FMT_S16P
;
...
...
@@ -362,11 +363,11 @@ static av_cold int decoder_init(AVCodecContext * avctx)
avctx
->
frame_size
=
SUBFRAME_SIZE
<<
1
;
ctx
=
s
->
channel_context
=
av_mallocz
(
sizeof
(
G729ChannelContext
)
*
avctx
->
channels
);
s
->
channel_context
=
av_mallocz
(
sizeof
(
G729ChannelContext
)
*
channels
);
if
(
!
ctx
)
return
AVERROR
(
ENOMEM
);
for
(
c
=
0
;
c
<
avctx
->
channels
;
c
++
)
{
for
(
c
=
0
;
c
<
channels
;
c
++
)
{
ctx
->
gain_coeff
=
16384
;
// 1.0 in (1.14)
for
(
k
=
0
;
k
<
MA_NP
+
1
;
k
++
)
{
...
...
@@ -412,6 +413,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
G729Formats
packet_type
;
G729Context
*
s
=
avctx
->
priv_data
;
G729ChannelContext
*
ctx
=
s
->
channel_context
;
int
channels
=
avctx
->
ch_layout
.
nb_channels
;
int16_t
lp
[
2
][
11
];
// (3.12)
uint8_t
ma_predictor
;
///< switched MA predictor of LSP quantizer
uint8_t
quantizer_1st
;
///< first stage vector of quantizer
...
...
@@ -430,14 +432,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
if
((
ret
=
ff_get_buffer
(
avctx
,
frame
,
0
))
<
0
)
return
ret
;
if
(
buf_size
&&
buf_size
%
((
G729_8K_BLOCK_SIZE
+
(
avctx
->
codec_id
==
AV_CODEC_ID_ACELP_KELVIN
))
*
avctx
->
channels
)
==
0
)
{
if
(
buf_size
&&
buf_size
%
((
G729_8K_BLOCK_SIZE
+
(
avctx
->
codec_id
==
AV_CODEC_ID_ACELP_KELVIN
))
*
channels
)
==
0
)
{
packet_type
=
FORMAT_G729_8K
;
format
=
&
format_g729_8k
;
//Reset voice decision
ctx
->
onset
=
0
;
ctx
->
voice_decision
=
DECISION_VOICE
;
av_log
(
avctx
,
AV_LOG_DEBUG
,
"Packet type: %s
\n
"
,
"G.729 @ 8kbit/s"
);
}
else
if
(
buf_size
==
G729D_6K4_BLOCK_SIZE
*
avctx
->
channels
&&
avctx
->
codec_id
!=
AV_CODEC_ID_ACELP_KELVIN
)
{
}
else
if
(
buf_size
==
G729D_6K4_BLOCK_SIZE
*
channels
&&
avctx
->
codec_id
!=
AV_CODEC_ID_ACELP_KELVIN
)
{
packet_type
=
FORMAT_G729D_6K4
;
format
=
&
format_g729d_6k4
;
av_log
(
avctx
,
AV_LOG_DEBUG
,
"Packet type: %s
\n
"
,
"G.729D @ 6.4kbit/s"
);
...
...
@@ -446,13 +448,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
return
AVERROR_INVALIDDATA
;
}
for
(
c
=
0
;
c
<
avctx
->
channels
;
c
++
)
{
for
(
c
=
0
;
c
<
channels
;
c
++
)
{
int
frame_erasure
=
0
;
///< frame erasure detected during decoding
int
bad_pitch
=
0
;
///< parity check failed
int
is_periodic
=
0
;
///< whether one of the subframes is declared as periodic or not
out_frame
=
(
int16_t
*
)
frame
->
data
[
c
];
if
(
avctx
->
codec_id
==
AV_CODEC_ID_ACELP_KELVIN
)
{
if
(
*
buf
!=
((
avctx
->
channels
-
1
-
c
)
*
0x80
|
2
))
if
(
*
buf
!=
((
avctx
->
ch
_layout
.
nb_ch
annels
-
1
-
c
)
*
0x80
|
2
))
avpriv_request_sample
(
avctx
,
"First byte value %x for channel %d"
,
*
buf
,
c
);
buf
++
;
}
...
...
@@ -739,7 +741,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
}
*
got_frame_ptr
=
1
;
return
(
format
->
block_size
+
(
avctx
->
codec_id
==
AV_CODEC_ID_ACELP_KELVIN
))
*
avctx
->
channels
;
return
(
format
->
block_size
+
(
avctx
->
codec_id
==
AV_CODEC_ID_ACELP_KELVIN
))
*
channels
;
}
static
av_cold
int
decode_close
(
AVCodecContext
*
avctx
)
...
...
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