Commit 1524b0fa authored by Peter Ross's avatar Peter Ross Committed by Michael Niedermayer

libavcodec/rawdec: avoid memcpy when performing 16-bit samples shift

Signed-off-by: 's avatarPeter Ross <pross@xvid.org>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent baa650cc
...@@ -226,6 +226,17 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -226,6 +226,17 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
linesize_align = 16; linesize_align = 16;
} }
buf = dst; 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) { } else if (need_copy) {
memcpy(frame->buf[0]->data, buf, buf_size); memcpy(frame->buf[0]->data, buf, buf_size);
buf = frame->buf[0]->data; buf = frame->buf[0]->data;
...@@ -242,19 +253,6 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -242,19 +253,6 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
return AVERROR(EINVAL); 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, if ((res = avpicture_fill(picture, buf, avctx->pix_fmt,
avctx->width, avctx->height)) < 0) { avctx->width, avctx->height)) < 0) {
av_buffer_unref(&frame->buf[0]); av_buffer_unref(&frame->buf[0]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment