Commit 67afcefb authored by Anton Khirnov's avatar Anton Khirnov Committed by Luca Barbato

lavc: Add new VDA hwaccel

It leverages the new hwaccel 1.2 features:

- get_buffer2 is never called
- the internal context is automatically initialized/deinitialized
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent 31a46750
......@@ -1896,6 +1896,8 @@ h264_vaapi_hwaccel_deps="vaapi"
h264_vaapi_hwaccel_select="h264_decoder"
h264_vda_hwaccel_deps="vda"
h264_vda_hwaccel_select="h264_decoder"
h264_vda_old_hwaccel_deps="vda"
h264_vda_old_hwaccel_select="h264_decoder"
h264_vdpau_hwaccel_deps="vdpau"
h264_vdpau_hwaccel_select="h264_decoder"
mpeg1_vdpau_hwaccel_deps="vdpau"
......
......@@ -68,6 +68,7 @@ OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes)
OBJS-$(CONFIG_SINEWIN) += sinewin.o
OBJS-$(CONFIG_TPELDSP) += tpeldsp.o
OBJS-$(CONFIG_VAAPI) += vaapi.o
OBJS-$(CONFIG_VDA) += vda.o
OBJS-$(CONFIG_VDPAU) += vdpau.o
OBJS-$(CONFIG_VIDEODSP) += videodsp.o
OBJS-$(CONFIG_VP3DSP) += vp3dsp.o
......
......@@ -79,6 +79,7 @@ void avcodec_register_all(void)
REGISTER_HWACCEL(H264_DXVA2, h264_dxva2);
REGISTER_HWACCEL(H264_VAAPI, h264_vaapi);
REGISTER_HWACCEL(H264_VDA, h264_vda);
REGISTER_HWACCEL(H264_VDA_OLD, h264_vda_old);
REGISTER_HWACCEL(H264_VDPAU, h264_vdpau);
REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau);
REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2);
......
......@@ -153,6 +153,7 @@ static const enum AVPixelFormat h264_hwaccel_pixfmt_list_420[] = {
#endif
#if CONFIG_H264_VDA_HWACCEL
AV_PIX_FMT_VDA_VLD,
AV_PIX_FMT_VDA,
#endif
#if CONFIG_H264_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU,
......@@ -170,6 +171,7 @@ static const enum AVPixelFormat h264_hwaccel_pixfmt_list_jpeg_420[] = {
#endif
#if CONFIG_H264_VDA_HWACCEL
AV_PIX_FMT_VDA_VLD,
AV_PIX_FMT_VDA,
#endif
#if CONFIG_H264_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU,
......
/*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "libavutil/mem.h"
#include "vda.h"
#include "vda_internal.h"
#if CONFIG_H264_VDA_HWACCEL
AVVDAContext *av_vda_alloc_context(void)
{
AVVDAContext *ret = av_mallocz(sizeof(*ret));
if (ret)
ret->output_callback = ff_vda_output_callback;
return ret;
}
int av_vda_default_init(AVCodecContext *avctx)
{
avctx->hwaccel_context = av_vda_alloc_context();
if (!avctx->hwaccel_context)
return AVERROR(ENOMEM);
return ff_vda_default_init(avctx);
}
void av_vda_default_free(AVCodecContext *avctx)
{
ff_vda_default_free(avctx);
av_freep(&avctx->hwaccel_context);
}
void ff_vda_default_free(AVCodecContext *avctx)
{
AVVDAContext *vda = avctx->hwaccel_context;
if (vda && vda->decoder)
VDADecoderDestroy(vda->decoder);
}
#else
AVVDAContext *av_vda_alloc_context(void)
{
return NULL;
}
int av_vda_default_init(AVCodecContext *avctx)
{
return AVERROR(ENOSYS);
}
void av_vda_default_free(AVCodecContext *ctx)
{
}
#endif
......@@ -29,6 +29,7 @@
* Public libavcodec VDA header.
*/
#include "libavcodec/avcodec.h"
#include "libavcodec/version.h"
#include <stdint.h>
......@@ -135,6 +136,58 @@ int ff_vda_create_decoder(struct vda_context *vda_ctx,
/** Destroy the video decoder. */
int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
/**
* This struct holds all the information that needs to be passed
* between the caller and libavcodec for initializing VDA decoding.
* Its size is not a part of the public ABI, it must be allocated with
* av_vda_alloc_context() and freed with av_free().
*/
typedef struct AVVDAContext {
/**
* VDA decoder object. Created and freed by the caller.
*/
VDADecoder decoder;
/**
* The output callback that must be passed to VDADecoderCreate.
* Set by av_vda_alloc_context().
*/
VDADecoderOutputCallback output_callback;
} AVVDAContext;
/**
* Allocate and initialize a VDA context.
*
* This function should be called from the get_format() callback when the caller
* selects the AV_PIX_FMT_VDA format. The caller must then create the decoder
* object (using the output callback provided by libavcodec) that will be used
* for VDA-accelerated decoding.
*
* When decoding with VDA is finished, the caller must destroy the decoder
* object and free the VDA context using av_free().
*
* @return the newly allocated context or NULL on failure
*/
AVVDAContext *av_vda_alloc_context(void);
/**
* This is a convenience function that creates and sets up the VDA context using
* an internal implementation.
*
* @param avctx the corresponding codec context
*
* @return >= 0 on success, a negative AVERROR code on failure
*/
int av_vda_default_init(AVCodecContext *avctx);
/**
* This function must be called to free the VDA context initialized with
* av_vda_default_init().
*
* @param avctx the corresponding codec context
*/
void av_vda_default_free(AVCodecContext *avctx);
/**
* @}
*/
......
This diff is collapsed.
/*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_VDA_INTERNAL_H
#define AVCODEC_VDA_INTERNAL_H
#include "vda.h"
void ff_vda_output_callback(void *vda_hw_ctx,
CFDictionaryRef user_info,
OSStatus status,
uint32_t infoFlags,
CVImageBufferRef image_buffer);
int ff_vda_default_init(AVCodecContext *avctx);
void ff_vda_default_free(AVCodecContext *avctx);
#endif /* AVCODEC_VDA_INTERNAL_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment