[vlc-devel] [PATCH] vpx: encode: fix alignment to avoid copying line by line
Thomas Guillem
thomas at gllm.fr
Thu Mar 29 09:33:55 CEST 2018
Using vpx_img_wrap() will really improve performances for > 1080p encoding.
On Thu, Mar 29, 2018, at 09:30, Thomas Guillem wrote:
>
>
> On Wed, Mar 28, 2018, at 20:29, Tristan Matthews wrote:
> > On Tue, Mar 20, 2018 at 8:38 PM, Tristan Matthews <tmatth at videolan.org> wrote:
> > > This is based on a suggestion by François for the aom encoder.
> > >
> > > ---
> > > modules/codec/vpx.c | 15 +++++++--------
> > > 1 file changed, 7 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/modules/codec/vpx.c b/modules/codec/vpx.c
> > > index 76331a714b..fdd75ba256 100644
> > > --- a/modules/codec/vpx.c
> > > +++ b/modules/codec/vpx.c
> > > @@ -441,23 +441,22 @@ 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)) {
> > > + if (!vpx_img_alloc(&img, VPX_IMG_FMT_I420, i_w, i_h, 32)) {
> > > VPX_ERR(p_enc, ctx, "Failed to allocate 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;
> > > + if (unlikely(dst_stride != p_pict->p[plane].i_pitch)) {
> > > + VPX_ERR(p_enc, ctx, "Unexpected stride mismatch");
> > > + vpx_img_free(&img);
>
> I think that this case could happen, maybe you should foreach (lines)
> { memcpy() } here, no ?
>
> > > + return NULL;
> > > }
> > > +
> > > + memcpy(dst, src, dst_stride*p_pict->p[plane].i_visible_lines);
> > > }
> > >
> > > int flags = 0;
> > > --
> > > 2.16.2
> > >
> >
> > Thomas, any thoughts on this? I see that you've been using vpx
> > encoding as a fallback for chromecast.
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list