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
0cd08367
Commit
0cd08367
authored
Dec 23, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libopencore-amr: decode directly to the user-provided AVFrame
parent
4f69612d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
18 deletions
+10
-18
libopencore-amr.c
libavcodec/libopencore-amr.c
+10
-18
No files found.
libavcodec/libopencore-amr.c
View file @
0cd08367
...
@@ -86,7 +86,6 @@ static int get_bitrate_mode(int bitrate, void *log_ctx)
...
@@ -86,7 +86,6 @@ static int get_bitrate_mode(int bitrate, void *log_ctx)
typedef
struct
AMRContext
{
typedef
struct
AMRContext
{
AVClass
*
av_class
;
AVClass
*
av_class
;
AVFrame
frame
;
void
*
dec_state
;
void
*
dec_state
;
void
*
enc_state
;
void
*
enc_state
;
int
enc_bitrate
;
int
enc_bitrate
;
...
@@ -119,9 +118,6 @@ static av_cold int amr_nb_decode_init(AVCodecContext *avctx)
...
@@ -119,9 +118,6 @@ static av_cold int amr_nb_decode_init(AVCodecContext *avctx)
return
-
1
;
return
-
1
;
}
}
avcodec_get_frame_defaults
(
&
s
->
frame
);
avctx
->
coded_frame
=
&
s
->
frame
;
return
0
;
return
0
;
}
}
...
@@ -137,6 +133,7 @@ static av_cold int amr_nb_decode_close(AVCodecContext *avctx)
...
@@ -137,6 +133,7 @@ static av_cold int amr_nb_decode_close(AVCodecContext *avctx)
static
int
amr_nb_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
static
int
amr_nb_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
{
{
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
;
AMRContext
*
s
=
avctx
->
priv_data
;
AMRContext
*
s
=
avctx
->
priv_data
;
...
@@ -148,8 +145,8 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -148,8 +145,8 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
buf
,
buf_size
,
avctx
->
frame_number
);
buf
,
buf_size
,
avctx
->
frame_number
);
/* get output buffer */
/* get output buffer */
s
->
frame
.
nb_samples
=
160
;
frame
->
nb_samples
=
160
;
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
;
}
}
...
@@ -166,10 +163,9 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -166,10 +163,9 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
av_dlog
(
avctx
,
"packet_size=%d buf= 0x%X %X %X %X
\n
"
,
av_dlog
(
avctx
,
"packet_size=%d buf= 0x%X %X %X %X
\n
"
,
packet_size
,
buf
[
0
],
buf
[
1
],
buf
[
2
],
buf
[
3
]);
packet_size
,
buf
[
0
],
buf
[
1
],
buf
[
2
],
buf
[
3
]);
/* call decoder */
/* call decoder */
Decoder_Interface_Decode
(
s
->
dec_state
,
buf
,
(
short
*
)
s
->
frame
.
data
[
0
],
0
);
Decoder_Interface_Decode
(
s
->
dec_state
,
buf
,
(
short
*
)
frame
->
data
[
0
],
0
);
*
got_frame_ptr
=
1
;
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
s
->
frame
;
return
packet_size
;
return
packet_size
;
}
}
...
@@ -315,7 +311,6 @@ AVCodec ff_libopencore_amrnb_encoder = {
...
@@ -315,7 +311,6 @@ AVCodec ff_libopencore_amrnb_encoder = {
#include <opencore-amrwb/if_rom.h>
#include <opencore-amrwb/if_rom.h>
typedef
struct
AMRWBContext
{
typedef
struct
AMRWBContext
{
AVFrame
frame
;
void
*
state
;
void
*
state
;
}
AMRWBContext
;
}
AMRWBContext
;
...
@@ -329,15 +324,13 @@ static av_cold int amr_wb_decode_init(AVCodecContext *avctx)
...
@@ -329,15 +324,13 @@ static av_cold int amr_wb_decode_init(AVCodecContext *avctx)
s
->
state
=
D_IF_init
();
s
->
state
=
D_IF_init
();
avcodec_get_frame_defaults
(
&
s
->
frame
);
avctx
->
coded_frame
=
&
s
->
frame
;
return
0
;
return
0
;
}
}
static
int
amr_wb_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
static
int
amr_wb_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
{
{
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
;
AMRWBContext
*
s
=
avctx
->
priv_data
;
AMRWBContext
*
s
=
avctx
->
priv_data
;
...
@@ -346,8 +339,8 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -346,8 +339,8 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
static
const
uint8_t
block_size
[
16
]
=
{
18
,
24
,
33
,
37
,
41
,
47
,
51
,
59
,
61
,
6
,
6
,
0
,
0
,
0
,
1
,
1
};
static
const
uint8_t
block_size
[
16
]
=
{
18
,
24
,
33
,
37
,
41
,
47
,
51
,
59
,
61
,
6
,
6
,
0
,
0
,
0
,
1
,
1
};
/* get output buffer */
/* get output buffer */
s
->
frame
.
nb_samples
=
320
;
frame
->
nb_samples
=
320
;
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
;
}
}
...
@@ -361,10 +354,9 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -361,10 +354,9 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
D_IF_decode
(
s
->
state
,
buf
,
(
short
*
)
s
->
frame
.
data
[
0
],
_good_frame
);
D_IF_decode
(
s
->
state
,
buf
,
(
short
*
)
frame
->
data
[
0
],
_good_frame
);
*
got_frame_ptr
=
1
;
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
s
->
frame
;
return
packet_size
;
return
packet_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