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
e3db3429
Commit
e3db3429
authored
Dec 23, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
amrnb: decode directly to the user-provided AVFrame
parent
9b0b355e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
9 deletions
+5
-9
amrnbdec.c
libavcodec/amrnbdec.c
+5
-9
No files found.
libavcodec/amrnbdec.c
View file @
e3db3429
...
@@ -96,7 +96,6 @@
...
@@ -96,7 +96,6 @@
#define AMR_AGC_ALPHA 0.9
#define AMR_AGC_ALPHA 0.9
typedef
struct
AMRContext
{
typedef
struct
AMRContext
{
AVFrame
avframe
;
///< AVFrame for decoded samples
AMRNBFrame
frame
;
///< decoded AMR parameters (lsf coefficients, codebook indexes, etc)
AMRNBFrame
frame
;
///< decoded AMR parameters (lsf coefficients, codebook indexes, etc)
uint8_t
bad_frame_indicator
;
///< bad frame ? 1 : 0
uint8_t
bad_frame_indicator
;
///< bad frame ? 1 : 0
enum
Mode
cur_frame_mode
;
enum
Mode
cur_frame_mode
;
...
@@ -177,9 +176,6 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx)
...
@@ -177,9 +176,6 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx)
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
p
->
prediction_error
[
i
]
=
MIN_ENERGY
;
p
->
prediction_error
[
i
]
=
MIN_ENERGY
;
avcodec_get_frame_defaults
(
&
p
->
avframe
);
avctx
->
coded_frame
=
&
p
->
avframe
;
return
0
;
return
0
;
}
}
...
@@ -936,6 +932,7 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -936,6 +932,7 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
{
{
AMRContext
*
p
=
avctx
->
priv_data
;
// pointer to private data
AMRContext
*
p
=
avctx
->
priv_data
;
// pointer to private data
AVFrame
*
frame
=
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
int
buf_size
=
avpkt
->
size
;
float
*
buf_out
;
// pointer to the output data buffer
float
*
buf_out
;
// pointer to the output data buffer
...
@@ -947,12 +944,12 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -947,12 +944,12 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
const
float
*
synth_fixed_vector
;
// pointer to the fixed vector that synthesis should use
const
float
*
synth_fixed_vector
;
// pointer to the fixed vector that synthesis should use
/* get output buffer */
/* get output buffer */
p
->
avframe
.
nb_samples
=
AMR_BLOCK_SIZE
;
frame
->
nb_samples
=
AMR_BLOCK_SIZE
;
if
((
ret
=
ff_get_buffer
(
avctx
,
&
p
->
av
frame
))
<
0
)
{
if
((
ret
=
ff_get_buffer
(
avctx
,
frame
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
ret
;
return
ret
;
}
}
buf_out
=
(
float
*
)
p
->
avframe
.
data
[
0
];
buf_out
=
(
float
*
)
frame
->
data
[
0
];
p
->
cur_frame_mode
=
unpack_bitstream
(
p
,
buf
,
buf_size
);
p
->
cur_frame_mode
=
unpack_bitstream
(
p
,
buf
,
buf_size
);
if
(
p
->
cur_frame_mode
==
NO_DATA
)
{
if
(
p
->
cur_frame_mode
==
NO_DATA
)
{
...
@@ -1059,7 +1056,6 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1059,7 +1056,6 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
0
.
84
,
0
.
16
,
LP_FILTER_ORDER
);
0
.
84
,
0
.
16
,
LP_FILTER_ORDER
);
*
got_frame_ptr
=
1
;
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
p
->
avframe
;
/* return the amount of bytes consumed if everything was OK */
/* return the amount of bytes consumed if everything was OK */
return
frame_sizes_nb
[
p
->
cur_frame_mode
]
+
1
;
// +7 for rounding and +8 for TOC
return
frame_sizes_nb
[
p
->
cur_frame_mode
]
+
1
;
// +7 for rounding and +8 for TOC
...
...
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