Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
f4a283ee
Commit
f4a283ee
authored
12 years ago
by
Justin Ruggles
Browse files
Options
Downloads
Patches
Plain Diff
wmapro: decode directly to the user-provided AVFrame
parent
9873d71f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/wmaprodec.c
+7
-14
7 additions, 14 deletions
libavcodec/wmaprodec.c
with
7 additions
and
14 deletions
libavcodec/wmaprodec.c
+
7
−
14
View file @
f4a283ee
...
@@ -169,7 +169,6 @@ typedef struct {
...
@@ -169,7 +169,6 @@ typedef struct {
typedef
struct
WMAProDecodeCtx
{
typedef
struct
WMAProDecodeCtx
{
/* generic decoder variables */
/* generic decoder variables */
AVCodecContext
*
avctx
;
///< codec context for av_log
AVCodecContext
*
avctx
;
///< codec context for av_log
AVFrame
frame
;
///< AVFrame for decoded output
AVFloatDSPContext
fdsp
;
AVFloatDSPContext
fdsp
;
uint8_t
frame_data
[
MAX_FRAMESIZE
+
uint8_t
frame_data
[
MAX_FRAMESIZE
+
FF_INPUT_BUFFER_PADDING_SIZE
];
///< compressed frame data
FF_INPUT_BUFFER_PADDING_SIZE
];
///< compressed frame data
...
@@ -461,9 +460,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
...
@@ -461,9 +460,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
avctx
->
channel_layout
=
channel_mask
;
avctx
->
channel_layout
=
channel_mask
;
avcodec_get_frame_defaults
(
&
s
->
frame
);
avctx
->
coded_frame
=
&
s
->
frame
;
return
0
;
return
0
;
}
}
...
@@ -1293,7 +1289,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
...
@@ -1293,7 +1289,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
*@return 0 if the trailer bit indicates that this is the last frame,
*@return 0 if the trailer bit indicates that this is the last frame,
* 1 if there are additional frames
* 1 if there are additional frames
*/
*/
static
int
decode_frame
(
WMAProDecodeCtx
*
s
,
int
*
got_frame_ptr
)
static
int
decode_frame
(
WMAProDecodeCtx
*
s
,
AVFrame
*
frame
,
int
*
got_frame_ptr
)
{
{
AVCodecContext
*
avctx
=
s
->
avctx
;
AVCodecContext
*
avctx
=
s
->
avctx
;
GetBitContext
*
gb
=
&
s
->
gb
;
GetBitContext
*
gb
=
&
s
->
gb
;
...
@@ -1366,8 +1362,8 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
...
@@ -1366,8 +1362,8 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
}
}
/* get output buffer */
/* get output buffer */
s
->
frame
.
nb_samples
=
s
->
samples_per_frame
;
frame
->
nb_samples
=
s
->
samples_per_frame
;
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
"
);
s
->
packet_loss
=
1
;
s
->
packet_loss
=
1
;
return
0
;
return
0
;
...
@@ -1375,7 +1371,7 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
...
@@ -1375,7 +1371,7 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
/** copy samples to the output buffer */
/** copy samples to the output buffer */
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
memcpy
(
s
->
frame
.
extended_data
[
i
],
s
->
channel
[
i
].
out
,
memcpy
(
frame
->
extended_data
[
i
],
s
->
channel
[
i
].
out
,
s
->
samples_per_frame
*
sizeof
(
*
s
->
channel
[
i
].
out
));
s
->
samples_per_frame
*
sizeof
(
*
s
->
channel
[
i
].
out
));
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
{
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
{
...
@@ -1543,7 +1539,7 @@ static int decode_packet(AVCodecContext *avctx, void *data,
...
@@ -1543,7 +1539,7 @@ static int decode_packet(AVCodecContext *avctx, void *data,
/** decode the cross packet frame if it is valid */
/** decode the cross packet frame if it is valid */
if
(
!
s
->
packet_loss
)
if
(
!
s
->
packet_loss
)
decode_frame
(
s
,
got_frame_ptr
);
decode_frame
(
s
,
data
,
got_frame_ptr
);
}
else
if
(
s
->
num_saved_bits
-
s
->
frame_offset
)
{
}
else
if
(
s
->
num_saved_bits
-
s
->
frame_offset
)
{
av_dlog
(
avctx
,
"ignoring %x previously saved bits
\n
"
,
av_dlog
(
avctx
,
"ignoring %x previously saved bits
\n
"
,
s
->
num_saved_bits
-
s
->
frame_offset
);
s
->
num_saved_bits
-
s
->
frame_offset
);
...
@@ -1566,7 +1562,7 @@ static int decode_packet(AVCodecContext *avctx, void *data,
...
@@ -1566,7 +1562,7 @@ static int decode_packet(AVCodecContext *avctx, void *data,
(
frame_size
=
show_bits
(
gb
,
s
->
log2_frame_size
))
&&
(
frame_size
=
show_bits
(
gb
,
s
->
log2_frame_size
))
&&
frame_size
<=
remaining_bits
(
s
,
gb
))
{
frame_size
<=
remaining_bits
(
s
,
gb
))
{
save_bits
(
s
,
gb
,
frame_size
,
0
);
save_bits
(
s
,
gb
,
frame_size
,
0
);
s
->
packet_done
=
!
decode_frame
(
s
,
got_frame_ptr
);
s
->
packet_done
=
!
decode_frame
(
s
,
data
,
got_frame_ptr
);
}
else
if
(
!
s
->
len_prefix
}
else
if
(
!
s
->
len_prefix
&&
s
->
num_saved_bits
>
get_bits_count
(
&
s
->
gb
))
{
&&
s
->
num_saved_bits
>
get_bits_count
(
&
s
->
gb
))
{
/** when the frames do not have a length prefix, we don't know
/** when the frames do not have a length prefix, we don't know
...
@@ -1576,7 +1572,7 @@ static int decode_packet(AVCodecContext *avctx, void *data,
...
@@ -1576,7 +1572,7 @@ static int decode_packet(AVCodecContext *avctx, void *data,
therefore we save the incoming packet first, then we append
therefore we save the incoming packet first, then we append
the "previous frame" data from the next packet so that
the "previous frame" data from the next packet so that
we get a buffer that only contains full frames */
we get a buffer that only contains full frames */
s
->
packet_done
=
!
decode_frame
(
s
,
got_frame_ptr
);
s
->
packet_done
=
!
decode_frame
(
s
,
data
,
got_frame_ptr
);
}
else
}
else
s
->
packet_done
=
1
;
s
->
packet_done
=
1
;
}
}
...
@@ -1592,9 +1588,6 @@ static int decode_packet(AVCodecContext *avctx, void *data,
...
@@ -1592,9 +1588,6 @@ static int decode_packet(AVCodecContext *avctx, void *data,
if
(
s
->
packet_loss
)
if
(
s
->
packet_loss
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
if
(
*
got_frame_ptr
)
*
(
AVFrame
*
)
data
=
s
->
frame
;
return
get_bits_count
(
gb
)
>>
3
;
return
get_bits_count
(
gb
)
>>
3
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment