FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vda.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
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.
8  *
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.
13  *
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
17  */
18 
19 #include "config.h"
20 
21 #include "libavutil/mem.h"
22 
23 #include "vda.h"
24 #include "vda_vt_internal.h"
25 
26 #if CONFIG_H264_VDA_HWACCEL
28 {
29  AVVDAContext *ret = av_mallocz(sizeof(*ret));
30 
31  if (ret) {
33  ret->cv_pix_fmt_type = kCVPixelFormatType_422YpCbCr8;
34  }
35 
36  return ret;
37 }
38 
40 {
41  return av_vda_default_init2(avctx, NULL);
42 }
43 
45 {
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);
50 }
51 
53 {
54  ff_vda_default_free(avctx);
55  av_freep(&avctx->hwaccel_context);
56 }
57 
59 {
60  AVVDAContext *vda = avctx->hwaccel_context;
61  if (vda && vda->decoder)
62  VDADecoderDestroy(vda->decoder);
63 }
64 
65 #else
67 {
68  return NULL;
69 }
70 
72 {
73  return AVERROR(ENOSYS);
74 }
75 
77 {
78  return AVERROR(ENOSYS);
79 }
80 
82 {
83 }
84 #endif
#define NULL
Definition: coverity.c:32
int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx)
This is a convenience function that creates and sets up the VDA context using an internal implementat...
Definition: vda.c:76
Memory handling functions.
void ff_vda_output_callback(void *opaque, CFDictionaryRef user_info, OSStatus status, uint32_t infoFlags, CVImageBufferRef image_buffer)
Definition: vda_h264.c:273
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:222
void av_vda_default_free(AVCodecContext *ctx)
This function must be called to free the VDA context initialized with av_vda_default_init().
Definition: vda.c:81
This struct holds all the information that needs to be passed between the caller and libavcodec for i...
Definition: vda.h:163
void * hwaccel_context
Hardware accelerator context.
Definition: avcodec.h:3064
OSType cv_pix_fmt_type
CVPixelBuffer Format Type that VDA will use for decoded frames; set by the caller.
Definition: vda.h:179
int av_vda_default_init(AVCodecContext *avctx)
This is a convenience function that creates and sets up the VDA context using an internal implementat...
Definition: vda.c:71
int ff_vda_default_init(AVCodecContext *avctx)
Definition: vda_h264.c:330
#define AVERROR(e)
Definition: error.h:43
void ff_vda_default_free(AVCodecContext *avctx)
AVFormatContext * ctx
Definition: movenc.c:48
VDADecoder decoder
VDA decoder object.
Definition: vda.h:167
VDADecoderOutputCallback output_callback
The output callback that must be passed to VDADecoderCreate.
Definition: vda.h:173
Public libavcodec VDA header.
main external API structure.
Definition: avcodec.h:1732
#define av_freep(p)
AVVDAContext * av_vda_alloc_context(void)
Allocate and initialize a VDA context.
Definition: vda.c:66