2 * Videotoolbox hardware acceleration
4 * copyright (c) 2012 Sebastien Zwickert
6 * This file is part of FFmpeg.
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.
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.
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
23 #ifndef AVCODEC_VIDEOTOOLBOX_H
24 #define AVCODEC_VIDEOTOOLBOX_H
28 * @ingroup lavc_codec_hwaccel_videotoolbox
29 * Public libavcodec Videotoolbox header.
34 #define Picture QuickdrawPicture
35 #include <VideoToolbox/VideoToolbox.h>
38 #include "libavcodec/avcodec.h"
41 * This struct holds all the information that needs to be passed
42 * between the caller and libavcodec for initializing Videotoolbox decoding.
43 * Its size is not a part of the public ABI, it must be allocated with
44 * av_videotoolbox_alloc_context() and freed with av_free().
46 typedef struct AVVideotoolboxContext {
48 * Videotoolbox decompression session object.
49 * Created and freed the caller.
51 VTDecompressionSessionRef session;
54 * The output callback that must be passed to the session.
55 * Set by av_videottoolbox_default_init()
57 VTDecompressionOutputCallback output_callback;
60 * CVPixelBuffer Format Type that Videotoolbox will use for decoded frames.
61 * set by the caller. If this is set to 0, then no specific format is
62 * requested from the decoder, and its native format is output.
64 OSType cv_pix_fmt_type;
67 * CoreMedia Format Description that Videotoolbox will use to create the decompression session.
70 CMVideoFormatDescriptionRef cm_fmt_desc;
73 * CoreMedia codec type that Videotoolbox will use to create the decompression session.
77 } AVVideotoolboxContext;
80 * Allocate and initialize a Videotoolbox context.
82 * This function should be called from the get_format() callback when the caller
83 * selects the AV_PIX_FMT_VIDETOOLBOX format. The caller must then create
84 * the decoder object (using the output callback provided by libavcodec) that
85 * will be used for Videotoolbox-accelerated decoding.
87 * When decoding with Videotoolbox is finished, the caller must destroy the decoder
88 * object and free the Videotoolbox context using av_free().
90 * @return the newly allocated context or NULL on failure
92 AVVideotoolboxContext *av_videotoolbox_alloc_context(void);
95 * This is a convenience function that creates and sets up the Videotoolbox context using
96 * an internal implementation.
98 * @param avctx the corresponding codec context
100 * @return >= 0 on success, a negative AVERROR code on failure
102 int av_videotoolbox_default_init(AVCodecContext *avctx);
105 * This is a convenience function that creates and sets up the Videotoolbox context using
106 * an internal implementation.
108 * @param avctx the corresponding codec context
109 * @param vtctx the Videotoolbox context to use
111 * @return >= 0 on success, a negative AVERROR code on failure
113 int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx);
116 * This function must be called to free the Videotoolbox context initialized with
117 * av_videotoolbox_default_init().
119 * @param avctx the corresponding codec context
121 void av_videotoolbox_default_free(AVCodecContext *avctx);
127 #endif /* AVCODEC_VIDEOTOOLBOX_H */