2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "libavutil/mem.h"
24 #include "vda_vt_internal.h"
26 #if CONFIG_H264_VDA_HWACCEL
27 AVVDAContext *av_vda_alloc_context(void)
29 AVVDAContext *ret = av_mallocz(sizeof(*ret));
32 ret->output_callback = ff_vda_output_callback;
33 ret->cv_pix_fmt_type = kCVPixelFormatType_422YpCbCr8;
39 int av_vda_default_init(AVCodecContext *avctx)
41 return av_vda_default_init2(avctx, NULL);
44 int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx)
46 avctx->hwaccel_context = vdactx ?: av_vda_alloc_context();
47 if (!avctx->hwaccel_context)
48 return AVERROR(ENOMEM);
49 return ff_vda_default_init(avctx);
52 void av_vda_default_free(AVCodecContext *avctx)
54 ff_vda_default_free(avctx);
55 av_freep(&avctx->hwaccel_context);
58 void ff_vda_default_free(AVCodecContext *avctx)
60 AVVDAContext *vda = avctx->hwaccel_context;
61 if (vda && vda->decoder)
62 VDADecoderDestroy(vda->decoder);
66 AVVDAContext *av_vda_alloc_context(void)
71 int av_vda_default_init(AVCodecContext *avctx)
73 return AVERROR(ENOSYS);
76 int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx)
78 return AVERROR(ENOSYS);
81 void av_vda_default_free(AVCodecContext *ctx)