FFmpeg
videotoolbox.h
Go to the documentation of this file.
1 /*
2  * Videotoolbox hardware acceleration
3  *
4  * copyright (c) 2012 Sebastien Zwickert
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef AVCODEC_VIDEOTOOLBOX_H
24 #define AVCODEC_VIDEOTOOLBOX_H
25 
26 /**
27  * @file
28  * @ingroup lavc_codec_hwaccel_videotoolbox
29  * Public libavcodec Videotoolbox header.
30  */
31 
32 /**
33  * @defgroup lavc_codec_hwaccel_videotoolbox VideoToolbox Decoder
34  * @ingroup lavc_codec_hwaccel
35  *
36  * Hardware accelerated decoding using VideoToolbox on Apple Platforms
37  *
38  * @{
39  */
40 
41 #include <stdint.h>
42 
43 #define Picture QuickdrawPicture
44 #include <VideoToolbox/VideoToolbox.h>
45 #undef Picture
46 
47 #include "libavcodec/avcodec.h"
48 
49 #include "libavutil/attributes.h"
50 
51 /**
52  * This struct holds all the information that needs to be passed
53  * between the caller and libavcodec for initializing Videotoolbox decoding.
54  * Its size is not a part of the public ABI, it must be allocated with
55  * av_videotoolbox_alloc_context() and freed with av_free().
56  */
57 typedef struct AVVideotoolboxContext {
58  /**
59  * Videotoolbox decompression session object.
60  * Created and freed the caller.
61  */
62  VTDecompressionSessionRef session;
63 
64 #if FF_API_VT_OUTPUT_CALLBACK
65  /**
66  * The output callback that must be passed to the session.
67  * Set by av_videottoolbox_default_init()
68  */
70  VTDecompressionOutputCallback output_callback;
71 #endif
72 
73  /**
74  * CVPixelBuffer Format Type that Videotoolbox will use for decoded frames.
75  * set by the caller. If this is set to 0, then no specific format is
76  * requested from the decoder, and its native format is output.
77  */
79 
80  /**
81  * CoreMedia Format Description that Videotoolbox will use to create the decompression session.
82  * Set by the caller.
83  */
84  CMVideoFormatDescriptionRef cm_fmt_desc;
85 
86  /**
87  * CoreMedia codec type that Videotoolbox will use to create the decompression session.
88  * Set by the caller.
89  */
92 
93 /**
94  * Allocate and initialize a Videotoolbox context.
95  *
96  * This function should be called from the get_format() callback when the caller
97  * selects the AV_PIX_FMT_VIDETOOLBOX format. The caller must then create
98  * the decoder object (using the output callback provided by libavcodec) that
99  * will be used for Videotoolbox-accelerated decoding.
100  *
101  * When decoding with Videotoolbox is finished, the caller must destroy the decoder
102  * object and free the Videotoolbox context using av_free().
103  *
104  * @return the newly allocated context or NULL on failure
105  */
107 
108 /**
109  * This is a convenience function that creates and sets up the Videotoolbox context using
110  * an internal implementation.
111  *
112  * @param avctx the corresponding codec context
113  *
114  * @return >= 0 on success, a negative AVERROR code on failure
115  */
117 
118 /**
119  * This is a convenience function that creates and sets up the Videotoolbox context using
120  * an internal implementation.
121  *
122  * @param avctx the corresponding codec context
123  * @param vtctx the Videotoolbox context to use
124  *
125  * @return >= 0 on success, a negative AVERROR code on failure
126  */
128 
129 /**
130  * This function must be called to free the Videotoolbox context initialized with
131  * av_videotoolbox_default_init().
132  *
133  * @param avctx the corresponding codec context
134  */
136 
137 /**
138  * @}
139  */
140 
141 #endif /* AVCODEC_VIDEOTOOLBOX_H */
AVVideotoolboxContext::cm_codec_type
int cm_codec_type
CoreMedia codec type that Videotoolbox will use to create the decompression session.
Definition: videotoolbox.h:90
AVVideotoolboxContext
This struct holds all the information that needs to be passed between the caller and libavcodec for i...
Definition: videotoolbox.h:57
av_videotoolbox_default_free
void av_videotoolbox_default_free(AVCodecContext *avctx)
This function must be called to free the Videotoolbox context initialized with av_videotoolbox_defaul...
av_videotoolbox_default_init
int av_videotoolbox_default_init(AVCodecContext *avctx)
This is a convenience function that creates and sets up the Videotoolbox context using an internal im...
output_callback
static void output_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
Definition: mmaldec.c:219
AVVideotoolboxContext::session
VTDecompressionSessionRef session
Videotoolbox decompression session object.
Definition: videotoolbox.h:62
AVVideotoolboxContext::cm_fmt_desc
CMVideoFormatDescriptionRef cm_fmt_desc
CoreMedia Format Description that Videotoolbox will use to create the decompression session.
Definition: videotoolbox.h:84
attribute_deprecated
#define attribute_deprecated
Definition: attributes.h:104
attributes.h
av_videotoolbox_default_init2
int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx)
This is a convenience function that creates and sets up the Videotoolbox context using an internal im...
avcodec.h
AVCodecContext
main external API structure.
Definition: avcodec.h:398
av_videotoolbox_alloc_context
AVVideotoolboxContext * av_videotoolbox_alloc_context(void)
Allocate and initialize a Videotoolbox context.
AVVideotoolboxContext::cv_pix_fmt_type
OSType cv_pix_fmt_type
CVPixelBuffer Format Type that Videotoolbox will use for decoded frames.
Definition: videotoolbox.h:78