aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-12-23 19:54:24 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2013-02-12 12:22:38 -0500
commit5d5c248c3df30fa91a8dde639618c985b9a11c53 (patch)
tree76ae4e5833673f3126723d81258bbab495b7f9eb
parent79fb2a1f1725d7b74355eb1ed79f080b3d7e3cd7 (diff)
downloadffmpeg-5d5c248c3df30fa91a8dde639618c985b9a11c53.tar.gz
s302m: decode directly to the user-provided AVFrame
-rw-r--r--libavcodec/s302m.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c
index 76fab59e9a..061f0158bb 100644
--- a/libavcodec/s302m.c
+++ b/libavcodec/s302m.c
@@ -28,10 +28,6 @@
#define AES3_HEADER_LEN 4
-typedef struct S302MDecodeContext {
- AVFrame frame;
-} S302MDecodeContext;
-
static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf,
int buf_size)
{
@@ -82,7 +78,7 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf,
static int s302m_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
- S302MDecodeContext *s = avctx->priv_data;
+ AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int block_size, ret;
@@ -96,16 +92,16 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
/* get output buffer */
block_size = (avctx->bits_per_coded_sample + 4) / 4;
- s->frame.nb_samples = 2 * (buf_size / block_size) / avctx->channels;
- if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
+ frame->nb_samples = 2 * (buf_size / block_size) / avctx->channels;
+ if ((ret = ff_get_buffer(avctx, frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
- buf_size = (s->frame.nb_samples * avctx->channels / 2) * block_size;
+ buf_size = (frame->nb_samples * avctx->channels / 2) * block_size;
if (avctx->bits_per_coded_sample == 24) {
- uint32_t *o = (uint32_t *)s->frame.data[0];
+ uint32_t *o = (uint32_t *)frame->data[0];
for (; buf_size > 6; buf_size -= 7) {
*o++ = (ff_reverse[buf[2]] << 24) |
(ff_reverse[buf[1]] << 16) |
@@ -117,7 +113,7 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
buf += 7;
}
} else if (avctx->bits_per_coded_sample == 20) {
- uint32_t *o = (uint32_t *)s->frame.data[0];
+ uint32_t *o = (uint32_t *)frame->data[0];
for (; buf_size > 5; buf_size -= 6) {
*o++ = (ff_reverse[buf[2] & 0xf0] << 28) |
(ff_reverse[buf[1]] << 20) |
@@ -128,7 +124,7 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
buf += 6;
}
} else {
- uint16_t *o = (uint16_t *)s->frame.data[0];
+ uint16_t *o = (uint16_t *)frame->data[0];
for (; buf_size > 4; buf_size -= 5) {
*o++ = (ff_reverse[buf[1]] << 8) |
ff_reverse[buf[0]];
@@ -139,29 +135,15 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
}
}
- *got_frame_ptr = 1;
- *(AVFrame *)data = s->frame;
+ *got_frame_ptr = 1;
return avpkt->size;
}
-static int s302m_decode_init(AVCodecContext *avctx)
-{
- S302MDecodeContext *s = avctx->priv_data;
-
- avcodec_get_frame_defaults(&s->frame);
- avctx->coded_frame = &s->frame;
-
- return 0;
-}
-
-
AVCodec ff_s302m_decoder = {
.name = "s302m",
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_S302M,
- .priv_data_size = sizeof(S302MDecodeContext),
- .init = s302m_decode_init,
.decode = s302m_decode_frame,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"),