vda.h 3.86 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
 * VDA HW acceleration
 *
 * copyright (c) 2011 Sebastien Zwickert
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef AVCODEC_VDA_H
#define AVCODEC_VDA_H

26 27 28 29 30 31
/**
 * @file
 * @ingroup lavc_codec_hwaccel_vda
 * Public libavcodec VDA header.
 */

32 33 34 35 36 37
#include <stdint.h>

// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
// http://openradar.appspot.com/8026390
#undef __GNUC_STDC_INLINE__

Sebastien Zwickert's avatar
Sebastien Zwickert committed
38
#define Picture QuickdrawPicture
39
#include <VideoDecodeAcceleration/VDADecoder.h>
Sebastien Zwickert's avatar
Sebastien Zwickert committed
40
#undef Picture
41

42 43
#include "libavcodec/version.h"

44 45 46 47 48 49 50
/**
 * @defgroup lavc_codec_hwaccel_vda VDA
 * @ingroup lavc_codec_hwaccel
 *
 * @{
 */

51 52 53 54 55 56 57 58
/**
 * This structure is used to provide the necessary configurations and data
 * to the VDA FFmpeg HWAccel implementation.
 *
 * The application must make it available as AVCodecContext.hwaccel_context.
 */
struct vda_context {
    /**
59 60 61 62 63
     * VDA decoder object.
     *
     * - encoding: unused
     * - decoding: Set/Unset by libavcodec.
     */
64 65
    VDADecoder          decoder;

66
    /**
67 68 69 70 71
     * The Core Video pixel buffer that contains the current image data.
     *
     * encoding: unused
     * decoding: Set by libavcodec. Unset by user.
     */
72 73 74
    CVPixelBufferRef    cv_buffer;

    /**
75 76 77 78 79
     * Use the hardware decoder in synchronous mode.
     *
     * encoding: unused
     * decoding: Set by user.
     */
80 81
    int                 use_sync_decoding;

82
    /**
83 84 85 86 87
     * The frame width.
     *
     * - encoding: unused
     * - decoding: Set/Unset by user.
     */
88 89 90
    int                 width;

    /**
91 92 93 94 95
     * The frame height.
     *
     * - encoding: unused
     * - decoding: Set/Unset by user.
     */
96 97 98
    int                 height;

    /**
99 100 101 102 103
     * The frame format.
     *
     * - encoding: unused
     * - decoding: Set/Unset by user.
     */
104
    int                 format;
105 106

    /**
107 108 109 110 111
     * The pixel format for output image buffers.
     *
     * - encoding: unused
     * - decoding: Set/Unset by user.
     */
112
    OSType              cv_pix_fmt_type;
113 114

    /**
115
     * The current bitstream buffer.
116 117 118
     *
     * - encoding: unused
     * - decoding: Set/Unset by libavcodec.
119
     */
120
    uint8_t             *priv_bitstream;
121 122

    /**
123
     * The current size of the bitstream.
124 125 126
     *
     * - encoding: unused
     * - decoding: Set/Unset by libavcodec.
127
     */
128
    int                 priv_bitstream_size;
129 130

    /**
131
     * The reference size used for fast reallocation.
132 133 134
     *
     * - encoding: unused
     * - decoding: Set/Unset by libavcodec.
135
     */
136
    int                 priv_allocated_size;
137 138 139 140 141 142 143 144 145 146 147

    /**
     * Use av_buffer to manage buffer.
     * When the flag is set, the CVPixelBuffers returned by the decoder will
     * be released automatically, so you have to retain them if necessary.
     * Not setting this flag may cause memory leak.
     *
     * encoding: unused
     * decoding: Set by user.
     */
    int                 use_ref_buffer;
148 149
};

Sebastien Zwickert's avatar
Sebastien Zwickert committed
150
/** Create the video decoder. */
151 152 153 154
int ff_vda_create_decoder(struct vda_context *vda_ctx,
                          uint8_t *extradata,
                          int extradata_size);

Sebastien Zwickert's avatar
Sebastien Zwickert committed
155
/** Destroy the video decoder. */
156 157
int ff_vda_destroy_decoder(struct vda_context *vda_ctx);

158 159 160 161
/**
 * @}
 */

162
#endif /* AVCODEC_VDA_H */