[FFmpeg-devel] [PATCH] libavcodec/libvpx: Add VPx alpha decode support
James Zern
jzern at google.com
Tue Jul 12 03:55:20 EEST 2016
On Thu, Jul 7, 2016 at 11:43 AM, Vignesh Venkatasubramanian
<vigneshv-at-google.com at ffmpeg.org> wrote:
> VPx (VP8/VP9) alpha encoding has been part of FFmpeg. Now, add the
> ability to decode such files with alpha channel.
>
> Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
> ---
> libavcodec/libvpxdec.c | 111 ++++++++++++++++++++++++++++-------
> tests/fate/vpx.mak | 3 +
> tests/ref/fate/vp8-alpha-decode | 125 ++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 219 insertions(+), 20 deletions(-)
> create mode 100644 tests/ref/fate/vp8-alpha-decode
>
> [...]
> +static int vpx_codec_dec_init_wrapper(AVCodecContext *avctx,
>
maybe just decoder/dec_init?
> [...]
> +static av_cold int vpx_init(AVCodecContext *avctx,
> + const struct vpx_codec_iface *iface)
> +{
> + VP8Context *ctx = avctx->priv_data;
just leave this extraction to the init wrapper.
> + return vpx_codec_dec_init_wrapper(avctx, ctx, iface, 0);
> [...]
> +static int vpx_codec_decode_wrapper(AVCodecContext *avctx,
>
maybe just decode / decode_frame?
> [...]
> + side_data = av_packet_get_side_data(avpkt,
> + AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
> + &side_data_size);
> + if (side_data_size > 1) {
> + uint64_t additional_id = AV_RB64(side_data);
>
could be const.
> + side_data += 8;
> + side_data_size -= 8;
>
this adjustment could be within the if().
> [...]
> - av_image_copy(picture->data, picture->linesize, (const uint8_t **)img->planes,
> - img->stride, avctx->pix_fmt, img->d_w, img->d_h);
> +
> + planes[0] = img->planes[VPX_PLANE_Y];
> + planes[1] = img->planes[VPX_PLANE_U];
> + planes[2] = img->planes[VPX_PLANE_V];
> + planes[3] =
> + ctx->has_alpha_channel ? img_alpha->planes[VPX_PLANE_Y] : NULL;
> + linesizes[0] = img->stride[VPX_PLANE_Y];
> + linesizes[1] = img->stride[VPX_PLANE_U];
> + linesizes[2] = img->stride[VPX_PLANE_V];
> + linesizes[3] =
> + ctx->has_alpha_channel ? img_alpha->stride[VPX_PLANE_Y] : 0;
> + av_image_copy(picture->data, picture->linesize, (const uint8_t**)planes,
> + linesizes, avctx->pix_fmt, img->d_w, img->d_h);
>
couldn't this just be 1 additional av_image_copy_plane()?
More information about the ffmpeg-devel
mailing list