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
19b2cb26
Commit
19b2cb26
authored
Dec 23, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libopus: decode directly to the user-provided AVFrame
parent
0cd08367
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
libopusdec.c
libavcodec/libopusdec.c
+12
-13
No files found.
libavcodec/libopusdec.c
View file @
19b2cb26
...
...
@@ -32,7 +32,6 @@
struct
libopus_context
{
OpusMSDecoder
*
dec
;
AVFrame
frame
;
};
#define OPUS_HEAD_SIZE 19
...
...
@@ -95,8 +94,7 @@ static av_cold int libopus_decode_init(AVCodecContext *avc)
opus_strerror
(
ret
));
avc
->
delay
=
3840
;
/* Decoder delay (in samples) at 48kHz */
avcodec_get_frame_defaults
(
&
opus
->
frame
);
avc
->
coded_frame
=
&
opus
->
frame
;
return
0
;
}
...
...
@@ -110,14 +108,15 @@ static av_cold int libopus_decode_close(AVCodecContext *avc)
#define MAX_FRAME_SIZE (960 * 6)
static
int
libopus_decode
(
AVCodecContext
*
avc
,
void
*
frame
,
static
int
libopus_decode
(
AVCodecContext
*
avc
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
pkt
)
{
struct
libopus_context
*
opus
=
avc
->
priv_data
;
AVFrame
*
frame
=
data
;
int
ret
,
nb_samples
;
opus
->
frame
.
nb_samples
=
MAX_FRAME_SIZE
;
ret
=
ff_get_buffer
(
avc
,
&
opus
->
frame
);
frame
->
nb_samples
=
MAX_FRAME_SIZE
;
ret
=
ff_get_buffer
(
avc
,
frame
);
if
(
ret
<
0
)
{
av_log
(
avc
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
ret
;
...
...
@@ -125,12 +124,12 @@ static int libopus_decode(AVCodecContext *avc, void *frame,
if
(
avc
->
sample_fmt
==
AV_SAMPLE_FMT_S16
)
nb_samples
=
opus_multistream_decode
(
opus
->
dec
,
pkt
->
data
,
pkt
->
size
,
(
opus_int16
*
)
opus
->
frame
.
data
[
0
],
opus
->
frame
.
nb_samples
,
0
);
(
opus_int16
*
)
frame
->
data
[
0
],
frame
->
nb_samples
,
0
);
else
nb_samples
=
opus_multistream_decode_float
(
opus
->
dec
,
pkt
->
data
,
pkt
->
size
,
(
float
*
)
opus
->
frame
.
data
[
0
],
opus
->
frame
.
nb_samples
,
0
);
(
float
*
)
frame
->
data
[
0
],
frame
->
nb_samples
,
0
);
if
(
nb_samples
<
0
)
{
av_log
(
avc
,
AV_LOG_ERROR
,
"Decoding error: %s
\n
"
,
...
...
@@ -138,9 +137,9 @@ static int libopus_decode(AVCodecContext *avc, void *frame,
return
ff_opus_error_to_averror
(
nb_samples
);
}
opus
->
frame
.
nb_samples
=
nb_samples
;
*
(
AVFrame
*
)
frame
=
opus
->
frame
;
*
got_frame_ptr
=
1
;
frame
->
nb_samples
=
nb_samples
;
*
got_frame_ptr
=
1
;
return
pkt
->
size
;
}
...
...
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