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
903b62cc
Commit
903b62cc
authored
Dec 24, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
smackaud: decode directly to the user-provided AVFrame
parent
09d6831f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
17 deletions
+6
-17
smacker.c
libavcodec/smacker.c
+6
-17
No files found.
libavcodec/smacker.c
View file @
903b62cc
...
@@ -555,14 +555,8 @@ static av_cold int decode_end(AVCodecContext *avctx)
...
@@ -555,14 +555,8 @@ static av_cold int decode_end(AVCodecContext *avctx)
}
}
typedef
struct
SmackerAudioContext
{
AVFrame
frame
;
}
SmackerAudioContext
;
static
av_cold
int
smka_decode_init
(
AVCodecContext
*
avctx
)
static
av_cold
int
smka_decode_init
(
AVCodecContext
*
avctx
)
{
{
SmackerAudioContext
*
s
=
avctx
->
priv_data
;
if
(
avctx
->
channels
<
1
||
avctx
->
channels
>
2
)
{
if
(
avctx
->
channels
<
1
||
avctx
->
channels
>
2
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid number of channels
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid number of channels
\n
"
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
...
@@ -570,9 +564,6 @@ static av_cold int smka_decode_init(AVCodecContext *avctx)
...
@@ -570,9 +564,6 @@ static av_cold int smka_decode_init(AVCodecContext *avctx)
avctx
->
channel_layout
=
(
avctx
->
channels
==
2
)
?
AV_CH_LAYOUT_STEREO
:
AV_CH_LAYOUT_MONO
;
avctx
->
channel_layout
=
(
avctx
->
channels
==
2
)
?
AV_CH_LAYOUT_STEREO
:
AV_CH_LAYOUT_MONO
;
avctx
->
sample_fmt
=
avctx
->
bits_per_coded_sample
==
8
?
AV_SAMPLE_FMT_U8
:
AV_SAMPLE_FMT_S16
;
avctx
->
sample_fmt
=
avctx
->
bits_per_coded_sample
==
8
?
AV_SAMPLE_FMT_U8
:
AV_SAMPLE_FMT_S16
;
avcodec_get_frame_defaults
(
&
s
->
frame
);
avctx
->
coded_frame
=
&
s
->
frame
;
return
0
;
return
0
;
}
}
...
@@ -582,7 +573,7 @@ static av_cold int smka_decode_init(AVCodecContext *avctx)
...
@@ -582,7 +573,7 @@ static av_cold int smka_decode_init(AVCodecContext *avctx)
static
int
smka_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
static
int
smka_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
{
{
SmackerAudioContext
*
s
=
avctx
->
priv_
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
;
GetBitContext
gb
;
GetBitContext
gb
;
...
@@ -622,13 +613,13 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -622,13 +613,13 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
}
}
/* get output buffer */
/* get output buffer */
s
->
frame
.
nb_samples
=
unp_size
/
(
avctx
->
channels
*
(
bits
+
1
));
frame
->
nb_samples
=
unp_size
/
(
avctx
->
channels
*
(
bits
+
1
));
if
((
ret
=
ff_get_buffer
(
avctx
,
&
s
->
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
;
}
}
samples
=
(
int16_t
*
)
s
->
frame
.
data
[
0
];
samples
=
(
int16_t
*
)
frame
->
data
[
0
];
samples8
=
s
->
frame
.
data
[
0
];
samples8
=
frame
->
data
[
0
];
// Initialize
// Initialize
for
(
i
=
0
;
i
<
(
1
<<
(
bits
+
stereo
));
i
++
)
{
for
(
i
=
0
;
i
<
(
1
<<
(
bits
+
stereo
));
i
++
)
{
...
@@ -717,8 +708,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -717,8 +708,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
av_free
(
h
[
i
].
values
);
av_free
(
h
[
i
].
values
);
}
}
*
got_frame_ptr
=
1
;
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
s
->
frame
;
return
buf_size
;
return
buf_size
;
}
}
...
@@ -739,7 +729,6 @@ AVCodec ff_smackaud_decoder = {
...
@@ -739,7 +729,6 @@ AVCodec ff_smackaud_decoder = {
.
name
=
"smackaud"
,
.
name
=
"smackaud"
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
id
=
AV_CODEC_ID_SMACKAUDIO
,
.
id
=
AV_CODEC_ID_SMACKAUDIO
,
.
priv_data_size
=
sizeof
(
SmackerAudioContext
),
.
init
=
smka_decode_init
,
.
init
=
smka_decode_init
,
.
decode
=
smka_decode_frame
,
.
decode
=
smka_decode_frame
,
.
capabilities
=
CODEC_CAP_DR1
,
.
capabilities
=
CODEC_CAP_DR1
,
...
...
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