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
764852d6
Commit
764852d6
authored
Feb 03, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alacenc: use AVCodec.encode2()
parent
bee80054
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
alacenc.c
libavcodec/alacenc.c
+17
-13
No files found.
libavcodec/alacenc.c
View file @
764852d6
...
...
@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "put_bits.h"
#include "dsputil.h"
#include "internal.h"
#include "lpc.h"
#include "mathops.h"
...
...
@@ -346,14 +347,14 @@ static void alac_entropy_coder(AlacEncodeContext *s)
}
}
static
int
write_frame
(
AlacEncodeContext
*
s
,
uint8_t
*
data
,
int
size
,
static
int
write_frame
(
AlacEncodeContext
*
s
,
AVPacket
*
avpkt
,
const
int16_t
*
samples
)
{
int
i
,
j
;
int
prediction_type
=
0
;
PutBitContext
*
pb
=
&
s
->
pbctx
;
init_put_bits
(
pb
,
data
,
size
);
init_put_bits
(
pb
,
avpkt
->
data
,
avpkt
->
size
);
if
(
s
->
verbatim
)
{
write_frame_header
(
s
);
...
...
@@ -536,13 +537,14 @@ error:
return
ret
;
}
static
int
alac_encode_frame
(
AVCodecContext
*
avctx
,
uint8_t
*
frame
,
int
buf_size
,
void
*
data
)
static
int
alac_encode_frame
(
AVCodecContext
*
avctx
,
AVPacket
*
avpkt
,
const
AVFrame
*
frame
,
int
*
got_packet_ptr
)
{
AlacEncodeContext
*
s
=
avctx
->
priv_data
;
int
out_bytes
,
max_frame_size
;
int
out_bytes
,
max_frame_size
,
ret
;
const
int16_t
*
samples
=
(
const
int16_t
*
)
frame
->
data
[
0
];
s
->
frame_size
=
avctx
->
frame_size
;
s
->
frame_size
=
frame
->
nb_samples
;
if
(
avctx
->
frame_size
<
DEFAULT_FRAME_SIZE
)
max_frame_size
=
get_max_frame_size
(
s
->
frame_size
,
avctx
->
channels
,
...
...
@@ -550,23 +552,25 @@ static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame,
else
max_frame_size
=
s
->
max_coded_frame_size
;
if
(
buf_size
<
2
*
max_frame_size
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"
buffer size is too small
\n
"
);
return
AVERROR
(
EINVAL
)
;
if
(
(
ret
=
ff_alloc_packet
(
avpkt
,
2
*
max_frame_size
))
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"
Error getting output packet
\n
"
);
return
ret
;
}
/* use verbatim mode for compression_level 0 */
s
->
verbatim
=
!
s
->
compression_level
;
out_bytes
=
write_frame
(
s
,
frame
,
buf_size
,
data
);
out_bytes
=
write_frame
(
s
,
avpkt
,
samples
);
if
(
out_bytes
>
max_frame_size
)
{
/* frame too large. use verbatim mode */
s
->
verbatim
=
1
;
out_bytes
=
write_frame
(
s
,
frame
,
buf_size
,
data
);
out_bytes
=
write_frame
(
s
,
avpkt
,
samples
);
}
return
out_bytes
;
avpkt
->
size
=
out_bytes
;
*
got_packet_ptr
=
1
;
return
0
;
}
AVCodec
ff_alac_encoder
=
{
...
...
@@ -575,7 +579,7 @@ AVCodec ff_alac_encoder = {
.
id
=
CODEC_ID_ALAC
,
.
priv_data_size
=
sizeof
(
AlacEncodeContext
),
.
init
=
alac_encode_init
,
.
encode
=
alac_encode_frame
,
.
encode
2
=
alac_encode_frame
,
.
close
=
alac_encode_close
,
.
capabilities
=
CODEC_CAP_SMALL_LAST_FRAME
,
.
sample_fmts
=
(
const
enum
AVSampleFormat
[]){
AV_SAMPLE_FMT_S16
,
...
...
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