diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-02-13 12:28:22 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-02-13 12:28:27 +0100 |
commit | 08059f6150fcf75d884670cdbdbdf8830fa199bd (patch) | |
tree | 3e3c42784e6b34b0de16fa3fad2fbd852f59137c /libavcodec/s302m.c | |
parent | 65da7007043cf4fb99b72c7f823cfc15e429b45f (diff) | |
parent | 5d5c248c3df30fa91a8dde639618c985b9a11c53 (diff) | |
download | ffmpeg-08059f6150fcf75d884670cdbdbdf8830fa199bd.tar.gz |
Merge commit '5d5c248c3df30fa91a8dde639618c985b9a11c53'
* commit '5d5c248c3df30fa91a8dde639618c985b9a11c53':
s302m: decode directly to the user-provided AVFrame
ra288: decode directly to the user-provided AVFrame
ra144: decode directly to the user-provided AVFrame
ralf: decode directly to the user-provided AVFrame
qdm2: decode directly to the user-provided AVFrame
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/s302m.c')
-rw-r--r-- | libavcodec/s302m.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c index a06192c488..d641c2ec6a 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) { @@ -95,7 +91,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; @@ -109,16 +105,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) | @@ -130,7 +126,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) | @@ -141,7 +137,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]]; @@ -152,29 +148,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"), |