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