diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-02-13 11:53:23 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-02-13 11:53:23 +0100 |
commit | 0a5138695aa441ab341b2f00d946c239db69edbf (patch) | |
tree | 900049ab4690d9511ae2ccad787e0000694529cb /libavcodec/pcm.c | |
parent | f03cdbd0454fbdba53a123a8f95186a519fade8d (diff) | |
parent | 182821cff43f5f977004d105b86c47ceb20d00d6 (diff) | |
download | ffmpeg-0a5138695aa441ab341b2f00d946c239db69edbf.tar.gz |
Merge commit '182821cff43f5f977004d105b86c47ceb20d00d6'
* commit '182821cff43f5f977004d105b86c47ceb20d00d6':
dca: decode directly to the user-provided AVFrame
cook: decode directly to the user-provided AVFrame
comfortnoise: decode directly to the user-provided AVFrame
bmvaudio: decode directly to the user-provided AVFrame
pcm: decode directly to the user-provided AVFrame
Conflicts:
libavcodec/pcm.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pcm.c')
-rw-r--r-- | libavcodec/pcm.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index ea6fabd47b..bae338d8f9 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -230,7 +230,6 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } typedef struct PCMDecode { - AVFrame frame; short table[256]; } PCMDecode; @@ -262,9 +261,6 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx) if (avctx->sample_fmt == AV_SAMPLE_FMT_S32) avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec_id); - avcodec_get_frame_defaults(&s->frame); - avctx->coded_frame = &s->frame; - return 0; } @@ -289,7 +285,7 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx) n /= avctx->channels; \ for (c = 0; c < avctx->channels; c++) { \ int i; \ - dst = s->frame.extended_data[c]; \ + dst = frame->extended_data[c]; \ for (i = n; i > 0; i--) { \ uint ## size ## _t v = bytestream_get_ ## endian(&src); \ AV_WN ## size ## A(dst, (v - offset) << shift); \ @@ -303,6 +299,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, const uint8_t *src = avpkt->data; int buf_size = avpkt->size; PCMDecode *s = avctx->priv_data; + AVFrame *frame = data; int sample_size, c, n, ret, samples_per_block; uint8_t *samples; int32_t *dst_int32_t; @@ -358,12 +355,12 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, n = buf_size / sample_size; /* get output buffer */ - s->frame.nb_samples = n * samples_per_block / avctx->channels; - if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) { + frame->nb_samples = n * samples_per_block / avctx->channels; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - samples = s->frame.data[0]; + samples = frame->data[0]; switch (avctx->codec_id) { case AV_CODEC_ID_PCM_U32LE: @@ -410,7 +407,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, n /= avctx->channels; for (c = 0; c < avctx->channels; c++) { int i; - samples = s->frame.extended_data[c]; + samples = frame->extended_data[c]; for (i = n; i > 0; i--) *samples++ = *src++ + 128; } @@ -466,7 +463,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, #endif /* HAVE_BIGENDIAN */ n /= avctx->channels; for (c = 0; c < avctx->channels; c++) { - samples = s->frame.extended_data[c]; + samples = frame->extended_data[c]; bytestream_get_buffer(&src, samples, n * sample_size); } break; @@ -488,7 +485,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, case AV_CODEC_ID_PCM_DVD: { const uint8_t *src8; - dst_int32_t = (int32_t *)s->frame.data[0]; + dst_int32_t = (int32_t *)frame->data[0]; n /= avctx->channels; switch (avctx->bits_per_coded_sample) { case 20: @@ -521,7 +518,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, int i; n /= avctx->channels; for (c = 0; c < avctx->channels; c++) { - dst_int32_t = (int32_t *)s->frame.extended_data[c]; + dst_int32_t = (int32_t *)frame->extended_data[c]; for (i = 0; i < n; i++) { // extract low 20 bits and expand to 32 bits *dst_int32_t++ = (src[2] << 28) | @@ -544,8 +541,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, return -1; } - *got_frame_ptr = 1; - *(AVFrame *)data = s->frame; + *got_frame_ptr = 1; return buf_size; } |