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
a17ececc
Commit
a17ececc
authored
Feb 13, 2013
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libcelt: decode directly to the user-provided AVFrame.
parent
b68dd8a1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
libcelt_dec.c
libavcodec/libcelt_dec.c
+7
-10
No files found.
libavcodec/libcelt_dec.c
View file @
a17ececc
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
struct
libcelt_context
{
struct
libcelt_context
{
CELTMode
*
mode
;
CELTMode
*
mode
;
CELTDecoder
*
dec
;
CELTDecoder
*
dec
;
AVFrame
frame
;
int
discard
;
int
discard
;
};
};
...
@@ -91,8 +90,6 @@ static av_cold int libcelt_dec_init(AVCodecContext *c)
...
@@ -91,8 +90,6 @@ static av_cold int libcelt_dec_init(AVCodecContext *c)
version
,
lib_version
);
version
,
lib_version
);
}
}
c
->
sample_fmt
=
AV_SAMPLE_FMT_S16
;
c
->
sample_fmt
=
AV_SAMPLE_FMT_S16
;
avcodec_get_frame_defaults
(
&
celt
->
frame
);
c
->
coded_frame
=
&
celt
->
frame
;
return
0
;
return
0
;
}
}
...
@@ -105,31 +102,31 @@ static av_cold int libcelt_dec_close(AVCodecContext *c)
...
@@ -105,31 +102,31 @@ static av_cold int libcelt_dec_close(AVCodecContext *c)
return
0
;
return
0
;
}
}
static
int
libcelt_dec_decode
(
AVCodecContext
*
c
,
void
*
frame
,
static
int
libcelt_dec_decode
(
AVCodecContext
*
c
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
pkt
)
int
*
got_frame_ptr
,
AVPacket
*
pkt
)
{
{
struct
libcelt_context
*
celt
=
c
->
priv_data
;
struct
libcelt_context
*
celt
=
c
->
priv_data
;
AVFrame
*
frame
=
data
;
int
err
;
int
err
;
int16_t
*
pcm
;
int16_t
*
pcm
;
celt
->
frame
.
nb_samples
=
c
->
frame_size
;
frame
->
nb_samples
=
c
->
frame_size
;
err
=
ff_get_buffer
(
c
,
&
celt
->
frame
);
err
=
ff_get_buffer
(
c
,
frame
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
av_log
(
c
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
av_log
(
c
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
err
;
return
err
;
}
}
pcm
=
(
int16_t
*
)
celt
->
frame
.
data
[
0
];
pcm
=
(
int16_t
*
)
frame
->
data
[
0
];
err
=
celt_decode
(
celt
->
dec
,
pkt
->
data
,
pkt
->
size
,
pcm
,
c
->
frame_size
);
err
=
celt_decode
(
celt
->
dec
,
pkt
->
data
,
pkt
->
size
,
pcm
,
c
->
frame_size
);
if
(
err
<
0
)
if
(
err
<
0
)
return
ff_celt_error_to_averror
(
err
);
return
ff_celt_error_to_averror
(
err
);
if
(
celt
->
discard
)
{
if
(
celt
->
discard
)
{
celt
->
frame
.
nb_samples
-=
celt
->
discard
;
frame
->
nb_samples
-=
celt
->
discard
;
memmove
(
pcm
,
pcm
+
celt
->
discard
*
c
->
channels
,
memmove
(
pcm
,
pcm
+
celt
->
discard
*
c
->
channels
,
celt
->
frame
.
nb_samples
*
c
->
channels
*
sizeof
(
int16_t
));
frame
->
nb_samples
*
c
->
channels
*
sizeof
(
int16_t
));
celt
->
discard
=
0
;
celt
->
discard
=
0
;
}
}
*
got_frame_ptr
=
1
;
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
frame
=
celt
->
frame
;
return
pkt
->
size
;
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