aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/rawdec.c
diff options
context:
space:
mode:
authorPeter Ross <pross@xvid.org>2014-02-26 21:03:52 +1100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-26 19:44:34 +0100
commit1524b0fa68e0ebe94959eb4554301053f62f87ef (patch)
tree98ba2964819a85900eca3cccb18b188df5cb9cf8 /libavcodec/rawdec.c
parentbaa650cc7946a9eb1cf5a083f61a581a97122f03 (diff)
downloadffmpeg-1524b0fa68e0ebe94959eb4554301053f62f87ef.tar.gz
libavcodec/rawdec: avoid memcpy when performing 16-bit samples shift
Signed-off-by: Peter Ross <pross@xvid.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/rawdec.c')
-rw-r--r--libavcodec/rawdec.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 5448b47bd3..1a63f9e5cc 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -226,6 +226,17 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
linesize_align = 16;
}
buf = dst;
+ } else if (context->is_lt_16bpp) {
+ int i;
+ uint8_t *dst = frame->buf[0]->data;
+ if (desc->flags & AV_PIX_FMT_FLAG_BE) {
+ for (i = 0; i + 1 < buf_size; i += 2)
+ AV_WB16(dst + i, AV_RB16(buf + i) << (16 - avctx->bits_per_coded_sample));
+ } else {
+ for (i = 0; i + 1 < buf_size; i += 2)
+ AV_WL16(dst + i, AV_RL16(buf + i) << (16 - avctx->bits_per_coded_sample));
+ }
+ buf = dst;
} else if (need_copy) {
memcpy(frame->buf[0]->data, buf, buf_size);
buf = frame->buf[0]->data;
@@ -242,19 +253,6 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
return AVERROR(EINVAL);
}
- if (context->is_lt_16bpp) {
- int i;
- uint8_t *dst = frame->buf[0]->data;
- if (desc->flags & AV_PIX_FMT_FLAG_BE) {
- for (i = 0; i + 1 < buf_size; i += 2)
- AV_WB16(dst + i, AV_RB16(buf + i) << (16 - avctx->bits_per_coded_sample));
- } else {
- for (i = 0; i + 1 < buf_size; i += 2)
- AV_WL16(dst + i, AV_RL16(buf + i) << (16 - avctx->bits_per_coded_sample));
- }
- buf = dst;
- }
-
if ((res = avpicture_fill(picture, buf, avctx->pix_fmt,
avctx->width, avctx->height)) < 0) {
av_buffer_unref(&frame->buf[0]);