Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
6aba117f
Commit
6aba117f
authored
Mar 21, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adxenc: use AVCodec.encode2()
parent
54e6cf8a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
+20
-16
adxenc.c
libavcodec/adxenc.c
+20
-16
No files found.
libavcodec/adxenc.c
View file @
6aba117f
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "avcodec.h"
#include "adx.h"
#include "adx.h"
#include "bytestream.h"
#include "bytestream.h"
#include "internal.h"
#include "put_bits.h"
#include "put_bits.h"
/**
/**
...
@@ -87,9 +88,6 @@ static int adx_encode_header(AVCodecContext *avctx, uint8_t *buf, int bufsize)
...
@@ -87,9 +88,6 @@ static int adx_encode_header(AVCodecContext *avctx, uint8_t *buf, int bufsize)
{
{
ADXContext
*
c
=
avctx
->
priv_data
;
ADXContext
*
c
=
avctx
->
priv_data
;
if
(
bufsize
<
HEADER_SIZE
)
return
AVERROR
(
EINVAL
);
bytestream_put_be16
(
&
buf
,
0x8000
);
/* header signature */
bytestream_put_be16
(
&
buf
,
0x8000
);
/* header signature */
bytestream_put_be16
(
&
buf
,
HEADER_SIZE
-
4
);
/* copyright offset */
bytestream_put_be16
(
&
buf
,
HEADER_SIZE
-
4
);
/* copyright offset */
bytestream_put_byte
(
&
buf
,
3
);
/* encoding */
bytestream_put_byte
(
&
buf
,
3
);
/* encoding */
...
@@ -119,8 +117,10 @@ static av_cold int adx_encode_init(AVCodecContext *avctx)
...
@@ -119,8 +117,10 @@ static av_cold int adx_encode_init(AVCodecContext *avctx)
}
}
avctx
->
frame_size
=
BLOCK_SAMPLES
;
avctx
->
frame_size
=
BLOCK_SAMPLES
;
#if FF_API_OLD_ENCODE_AUDIO
avcodec_get_frame_defaults
(
&
c
->
frame
);
avcodec_get_frame_defaults
(
&
c
->
frame
);
avctx
->
coded_frame
=
&
c
->
frame
;
avctx
->
coded_frame
=
&
c
->
frame
;
#endif
/* the cutoff can be adjusted, but this seems to work pretty well */
/* the cutoff can be adjusted, but this seems to work pretty well */
c
->
cutoff
=
500
;
c
->
cutoff
=
500
;
...
@@ -129,34 +129,38 @@ static av_cold int adx_encode_init(AVCodecContext *avctx)
...
@@ -129,34 +129,38 @@ static av_cold int adx_encode_init(AVCodecContext *avctx)
return
0
;
return
0
;
}
}
static
int
adx_encode_frame
(
AVCodecContext
*
avctx
,
uint8_t
*
frame
,
static
int
adx_encode_frame
(
AVCodecContext
*
avctx
,
AVPacket
*
avpkt
,
int
buf_size
,
void
*
data
)
const
AVFrame
*
frame
,
int
*
got_packet_ptr
)
{
{
ADXContext
*
c
=
avctx
->
priv_data
;
ADXContext
*
c
=
avctx
->
priv_data
;
const
int16_t
*
samples
=
data
;
const
int16_t
*
samples
=
(
const
int16_t
*
)
frame
->
data
[
0
];
uint8_t
*
dst
=
frame
;
uint8_t
*
dst
;
int
ch
;
int
ch
,
out_size
,
ret
;
out_size
=
BLOCK_SIZE
*
avctx
->
channels
+
!
c
->
header_parsed
*
HEADER_SIZE
;
if
((
ret
=
ff_alloc_packet
(
avpkt
,
out_size
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error getting output packet
\n
"
);
return
ret
;
}
dst
=
avpkt
->
data
;
if
(
!
c
->
header_parsed
)
{
if
(
!
c
->
header_parsed
)
{
int
hdrsize
;
int
hdrsize
;
if
((
hdrsize
=
adx_encode_header
(
avctx
,
dst
,
buf_
size
))
<
0
)
{
if
((
hdrsize
=
adx_encode_header
(
avctx
,
dst
,
avpkt
->
size
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"output buffer is too small
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"output buffer is too small
\n
"
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
dst
+=
hdrsize
;
dst
+=
hdrsize
;
buf_size
-=
hdrsize
;
c
->
header_parsed
=
1
;
c
->
header_parsed
=
1
;
}
}
if
(
buf_size
<
BLOCK_SIZE
*
avctx
->
channels
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"output buffer is too small
\n
"
);
return
AVERROR
(
EINVAL
);
}
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
{
adx_encode
(
c
,
dst
,
samples
+
ch
,
&
c
->
prev
[
ch
],
avctx
->
channels
);
adx_encode
(
c
,
dst
,
samples
+
ch
,
&
c
->
prev
[
ch
],
avctx
->
channels
);
dst
+=
BLOCK_SIZE
;
dst
+=
BLOCK_SIZE
;
}
}
return
dst
-
frame
;
*
got_packet_ptr
=
1
;
return
0
;
}
}
AVCodec
ff_adpcm_adx_encoder
=
{
AVCodec
ff_adpcm_adx_encoder
=
{
...
@@ -165,7 +169,7 @@ AVCodec ff_adpcm_adx_encoder = {
...
@@ -165,7 +169,7 @@ AVCodec ff_adpcm_adx_encoder = {
.
id
=
CODEC_ID_ADPCM_ADX
,
.
id
=
CODEC_ID_ADPCM_ADX
,
.
priv_data_size
=
sizeof
(
ADXContext
),
.
priv_data_size
=
sizeof
(
ADXContext
),
.
init
=
adx_encode_init
,
.
init
=
adx_encode_init
,
.
encode
=
adx_encode_frame
,
.
encode
2
=
adx_encode_frame
,
.
sample_fmts
=
(
const
enum
AVSampleFormat
[])
{
AV_SAMPLE_FMT_S16
,
.
sample_fmts
=
(
const
enum
AVSampleFormat
[])
{
AV_SAMPLE_FMT_S16
,
AV_SAMPLE_FMT_NONE
},
AV_SAMPLE_FMT_NONE
},
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"SEGA CRI ADX ADPCM"
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"SEGA CRI ADX ADPCM"
),
...
...
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