summaryrefslogtreecommitdiff
path: root/libavcodec/wmaprodec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-02-13 12:49:48 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-02-13 12:49:48 +0100
commit0dff771f31cffffec0e16944d3890564c2da16eb (patch)
tree6c6ab0759ebf48fd5a7a478f97fb2110b4c5ad6e /libavcodec/wmaprodec.c
parentdca6fb08a71b8201f0a32f9cff18e7753355733a (diff)
parent205a95f7b5178362874bc1e65eae9866723491c1 (diff)
Merge commit '205a95f7b5178362874bc1e65eae9866723491c1'
* commit '205a95f7b5178362874bc1e65eae9866723491c1': wmaenc: alloc/free coded_frame instead of keeping it in the WMACodecContext wma: decode directly to the user-provided AVFrame wmapro: decode directly to the user-provided AVFrame wavpack: decode directly to the user-provided AVFrame Conflicts: libavcodec/wavpack.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/wmaprodec.c')
-rw-r--r--libavcodec/wmaprodec.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index c90a4b605e..396b90f564 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -169,7 +169,6 @@ typedef struct {
typedef struct WMAProDecodeCtx {
/* generic decoder variables */
AVCodecContext* avctx; ///< codec context for av_log
- AVFrame frame; ///< AVFrame for decoded output
AVFloatDSPContext fdsp;
uint8_t frame_data[MAX_FRAMESIZE +
FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data
@@ -471,9 +470,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
avctx->channel_layout = channel_mask;
- avcodec_get_frame_defaults(&s->frame);
- avctx->coded_frame = &s->frame;
-
return 0;
}
@@ -1304,7 +1300,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
*@return 0 if the trailer bit indicates that this is the last frame,
* 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;
GetBitContext* gb = &s->gb;
@@ -1377,8 +1373,8 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
}
/* get output buffer */
- s->frame.nb_samples = s->samples_per_frame;
- if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
+ frame->nb_samples = s->samples_per_frame;
+ if ((ret = ff_get_buffer(avctx, frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
s->packet_loss = 1;
return 0;
@@ -1386,7 +1382,7 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)
/** copy samples to the output buffer */
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));
for (i = 0; i < avctx->channels; i++) {
@@ -1554,7 +1550,7 @@ static int decode_packet(AVCodecContext *avctx, void *data,
/** decode the cross packet frame if it is valid */
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) {
av_dlog(avctx, "ignoring %x previously saved bits\n",
s->num_saved_bits - s->frame_offset);
@@ -1577,7 +1573,7 @@ static int decode_packet(AVCodecContext *avctx, void *data,
(frame_size = show_bits(gb, s->log2_frame_size)) &&
frame_size <= remaining_bits(s, gb)) {
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
&& s->num_saved_bits > get_bits_count(&s->gb)) {
/** when the frames do not have a length prefix, we don't know
@@ -1587,7 +1583,7 @@ static int decode_packet(AVCodecContext *avctx, void *data,
therefore we save the incoming packet first, then we append
the "previous frame" data from the next packet so that
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
s->packet_done = 1;
}
@@ -1603,9 +1599,6 @@ static int decode_packet(AVCodecContext *avctx, void *data,
if (s->packet_loss)
return AVERROR_INVALIDDATA;
- if (*got_frame_ptr)
- *(AVFrame *)data = s->frame;
-
return get_bits_count(gb) >> 3;
}