[vlc-devel] [PATCH 5/5] aom: add AV1 encoding

Francois Cartegnie fcvlcdev at free.fr
Wed Dec 27 12:13:44 CET 2017


Le 18/12/2017 à 16:10, Tristan Matthews a écrit :
> +/****************************************************************************
> + * Encode: the whole thing
> + ****************************************************************************/
> +static block_t *Encode(encoder_t *p_enc, picture_t *p_pict)
> +{
> +    encoder_sys_t *p_sys = p_enc->p_sys;
> +    struct aom_codec_ctx *ctx = &p_sys->ctx;
> +
> +    if (!p_pict) return NULL;
> +
> +    aom_image_t img = {};
> +    unsigned i_w = p_enc->fmt_in.video.i_visible_width;
> +    unsigned i_h = p_enc->fmt_in.video.i_visible_height;
> +
> +    /* Create and initialize the aom_image */
> +    if (!aom_img_alloc(&img, AOM_IMG_FMT_I420, i_w, i_h, 16))
> +    {
> +        AOM_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++)
> +        {
> +            /* FIXME: do this in-place */
> +            memcpy(dst, src, size);
> +            src += src_stride;
> +            dst += dst_stride;
> +        }
> +    }

Since I believe 16 is alignment, why not allocate same stride and just
memcpy (or not!) the whole ?

> +            int keyframe = pkt->data.frame.flags & AOM_FRAME_IS_KEY;
> +            block_t *p_block = block_Alloc(pkt->data.frame.sz);
> +
> +            /* FIXME: do this in-place */
> +            memcpy(p_block->p_buffer, pkt->data.frame.buf, pkt->data.frame.sz);

no check

-- 
Francois Cartegnie
VideoLAN - VLC Developer


More information about the vlc-devel mailing list