summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorArttu Ylä-Outinen <arttu.yla-outinen@tut.fi>2015-09-28 11:27:16 +0300
committerArttu Ylä-Outinen <arttu.yla-outinen@tut.fi>2015-10-07 17:09:08 +0300
commit5fefa7b512cc8e2141d595a6a7ed77de13da4e18 (patch)
treeab5d290297908914e56d7d92c0faf83bd796446f /libavcodec
parent8db62f04191ab559bb44bbdaec86da6a9c44aa2c (diff)
libkvazaar: Use av_image_copy for copying pixels
Replaces a for loop for copying pixels by a call to av_image_copy. Signed-off-by: Arttu Ylä-Outinen <arttu.yla-outinen@tut.fi>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/libkvazaar.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 9c59cadcfc..08798440c3 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -24,6 +24,7 @@
#include <string.h>
#include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
#include "libavutil/dict.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
@@ -149,8 +150,6 @@ static int libkvazaar_encode(AVCodecContext *avctx,
*got_packet_ptr = 0;
if (frame) {
- int i = 0;
-
if (frame->width != ctx->config->width ||
frame->height != ctx->config->height) {
av_log(avctx, AV_LOG_ERROR,
@@ -181,17 +180,16 @@ static int libkvazaar_encode(AVCodecContext *avctx,
}
// Copy pixels from frame to img_in.
- for (i = 0; i < 3; ++i) {
- uint8_t *dst = img_in->data[i];
- uint8_t *src = frame->data[i];
- int width = (i == 0) ? frame->width : (frame->width / 2);
- int height = (i == 0) ? frame->height : (frame->height / 2);
- int y = 0;
- for (y = 0; y < height; ++y) {
- memcpy(dst, src, width);
- src += frame->linesize[i];
- dst += width;
- }
+ {
+ int dst_linesizes[4] = {
+ frame->width,
+ frame->width / 2,
+ frame->width / 2,
+ 0
+ };
+ av_image_copy(img_in->data, dst_linesizes,
+ frame->data, frame->linesize,
+ frame->format, frame->width, frame->height);
}
img_in->pts = frame->pts;