[vlc-commits] vpx: encoder: use vpx_img_wrap to avoid memcpy
Tristan Matthews
git at videolan.org
Tue Apr 17 04:04:24 CEST 2018
vlc | branch: master | Tristan Matthews <tmatth at videolan.org> | Thu Apr 12 23:17:38 2018 -0400| [a0883a5e453723ef553506bdb0459724e5d7cb69] | committer: Tristan Matthews
vpx: encoder: use vpx_img_wrap to avoid memcpy
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a0883a5e453723ef553506bdb0459724e5d7cb69
---
modules/codec/vpx.c | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/modules/codec/vpx.c b/modules/codec/vpx.c
index c69b5ff768..54a787ca74 100644
--- a/modules/codec/vpx.c
+++ b/modules/codec/vpx.c
@@ -456,23 +456,15 @@ static block_t *Encode(encoder_t *p_enc, picture_t *p_pict)
unsigned i_h = p_enc->fmt_in.video.i_visible_height;
/* Create and initialize the vpx_image */
- if (!vpx_img_alloc(&img, VPX_IMG_FMT_I420, i_w, i_h, 1)) {
- VPX_ERR(p_enc, ctx, "Failed to allocate image");
+ if (!vpx_img_wrap(&img, VPX_IMG_FMT_I420, i_w, i_h, 32, p_pict->p[0].p_pixels)) {
+ VPX_ERR(p_enc, ctx, "Failed to wrap image");
return NULL;
}
- for (int plane = 0; plane < p_pict->i_planes; plane++) {
- uint8_t *src = p_pict->p[plane].p_pixels;
- uint8_t *dst = img.planes[plane];
- int src_stride = p_pict->p[plane].i_pitch;
- int dst_stride = img.stride[plane];
-
- int size = __MIN(src_stride, dst_stride);
- for (int line = 0; line < p_pict->p[plane].i_visible_lines; line++)
- {
- memcpy(dst, src, size);
- src += src_stride;
- dst += dst_stride;
- }
+
+ /* Correct chroma plane offsets. */
+ for (int plane = 1; plane < p_pict->i_planes; plane++) {
+ img.planes[plane] = p_pict->p[plane].p_pixels;
+ img.stride[plane] = p_pict->p[plane].i_pitch;
}
int flags = 0;
More information about the vlc-commits
mailing list