vdpau.h 187 KB
Newer Older
Aaron Plattner's avatar
Aaron Plattner committed
1 2 3 4 5 6 7 8
/*
 * This source file is documented using Doxygen markup.
 * See http://www.stack.nl/~dimitri/doxygen/
 */

/*
 * This copyright notice applies to this header file:
 *
9
 * Copyright (c) 2008-2015 NVIDIA Corporation
10
 *
Aaron Plattner's avatar
Aaron Plattner committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

/**
 * \mainpage Video Decode and Presentation API for Unix
35
 *
Aaron Plattner's avatar
Aaron Plattner committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
 * \section intro Introduction
 *
 * The Video Decode and Presentation API for Unix (VDPAU) provides
 * a complete solution for decoding, post-processing, compositing,
 * and displaying compressed or uncompressed video streams. These
 * video streams may be combined (composited) with bitmap content,
 * to implement OSDs and other application user interfaces.
 *
 * \section api_partitioning API Partitioning
 *
 * VDPAU is split into two distinct modules:
 * - \ref api_core
 * - \ref api_winsys
 *
 * The intent is that most VDPAU functionality exists and
 * operates identically across all possible Windowing Systems.
 * This functionality is the \ref api_core.
 *
 * However, a small amount of functionality must be included that
 * is tightly coupled to the underlying Windowing System. This
 * functionality is the \ref api_winsys. Possibly examples
 * include:
 * - Creation of the initial VDPAU \ref VdpDevice "VdpDevice"
 *   handle, since this act requires intimate knowledge of the
 *   underlying Window System, such as specific display handle or
 *   driver identification.
 * - Conversion of VDPAU surfaces to/from underlying Window
 *   System surface types, e.g. to allow manipulation of
 *   VDPAU-generated surfaces via native Window System APIs.
 *
 * \section objects Object Types
 *
 * VDPAU is roughly object oriented; most functionality is
 * exposed by creating an object (handle) of a certain class
 * (type), then executing various functions against that handle.
 * The set of object classes supported, and their purpose, is
 * discussed below.
 *
 * \subsection device_type Device Type
 *
 * A \ref VdpDevice "VdpDevice" is the root object in VDPAU's
 * object system. The \ref api_winsys allows creation of a \ref
 * VdpDevice "VdpDevice" object handle, from which all other API
 * entry points can be retrieved and invoked.
 *
 * \subsection surface_types Surface Types
 *
 * A surface stores pixel information. Various types of surfaces
 * existing for different purposes:
 *
86
 * - \ref VdpVideoSurface "VdpVideoSurface"s store decompressed
Aaron Plattner's avatar
Aaron Plattner committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
 *   YCbCr video frames in an implementation-defined internal
 *   format.
 * - \ref VdpOutputSurface "VdpOutputSurface"s store RGB 4:4:4
 *   data. They are legal render targets for video
 *   post-processing and compositing operations.
 * - \ref VdpBitmapSurface "VdpBitmapSurface"s store RGB 4:4:4
 *   data. These surfaces are designed to contain read-only
 *   bitmap data, to be used for OSD or application UI
 *   compositing.
 *
 * \subsection transfer_types Transfer Types
 *
 * A data transfer object reads data from a surface (or
 * surfaces), processes it, and writes the result to another
 * surface. Various types of processing are possible:
 *
 * - \ref VdpDecoder "VdpDecoder" objects process compressed video
 *   data, and generate decompressed images.
 * - \ref VdpOutputSurface "VdpOutputSurface"s have their own \ref
 *   VdpOutputSurfaceRender "rendering functionality".
 * - \ref VdpVideoMixer "VdpVideoMixer" objects perform video
 *   post-processing, de-interlacing, and compositing.
 * - \ref VdpPresentationQueue "VdpPresentationQueue" is
 *   responsible for timestamp-based display of surfaces.
 *
 * \section data_flow Data Flow
 *
 * Compressed video data originates in the application's memory
 * space. This memory is typically obtained using \c malloc, and
 * filled via regular file or network read system calls.
 * Alternatively, the application may \c mmap a file.
 *
 * The compressed data is then processed using a \ref VdpDecoder
 * "VdpDecoder", which will decompress the field or frame,
 * and write the result into a \ref VdpVideoSurface
 * "VdpVideoSurface". This action may require reading pixel data
 * from some number of other \ref VdpVideoSurface "VdpVideoSurface"
 * objects, depending on the type of compressed data and
 * field/frame in question.
 *
 * If the application wishes to display any form of OSD or
 * user-interface, this must be created in a \ref
 * VdpOutputSurface "VdpOutputSurface".
 *
 * This process begins with the creation of \ref VdpBitmapSurface
 * "VdpBitmapSurface" objects to contain the OSD/UI's static data,
 * such as individual glyphs.
 *
 * \ref VdpOutputSurface "VdpOutputSurface" \ref
 * VdpOutputSurfaceRender "rendering functionality" may be used
 * to composite together various \ref VdpBitmapSurface
 * "VdpBitmapSurface"s and \ref VdpOutputSurface
 * "VdpOutputSurface"s, into another VdpOutputSurface
 * "VdpOutputSurface".
 *
 * Once video has been decoded, it must be post-processed. This
 * involves various steps such as color space conversion,
 * de-interlacing, and other video adjustments. This step is
 * performed using an \ref VdpVideoMixer "VdpVideoMixer" object.
 * This object can not only perform the aforementioned video
 * post-processing, but also composite the video with a number of
 * \ref VdpOutputSurface "VdpOutputSurface"s, thus allowing complex
 * user interfaces to be built. The final result is written into
 * another \ref VdpOutputSurface "VdpOutputSurface".
 *
 * Note that at this point, the resultant \ref VdpOutputSurface
 * "VdpOutputSurface" may be fed back through the above path,
 * either using \ref VdpOutputSurface "VdpOutputSurface" \ref
 * VdpOutputSurfaceRender "rendering functionality",
 * or as input to the \ref VdpVideoMixer "VdpVideoMixer" object.
 *
 * Finally, the resultant \ref VdpOutputSurface
 * "VdpOutputSurface" must be displayed on screen. This is the job
 * of the \ref VdpPresentationQueue "VdpPresentationQueue" object.
 *
 * \image html vdpau_data_flow.png
 *
 * \section entry_point_retrieval Entry Point Retrieval
 *
 * VDPAU is designed so that multiple implementations can be
 * used without application changes. For example, VDPAU could be
168
 * hosted on X11, or via direct GPU access.
Aaron Plattner's avatar
Aaron Plattner committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
 *
 * The key technology behind this is the use of function
 * pointers and a "get proc address" style API for all entry
 * points. Put another way, functions are not called directly
 * via global symbols set up by the linker, but rather through
 * pointers.
 *
 * In practical terms, the \ref api_winsys provides factory
 * functions which not only create and return \ref VdpDevice
 * "VdpDevice" objects, but also a function pointer to a \ref
 * VdpGetProcAddress function, through which all entry point
 * function pointers will be retrieved.
 *
 * \subsection entry_point_philosophy Philosophy
 *
 * It is entirely possible to envisage a simpler scheme whereby
 * such function pointers are hidden. That is, the application
 * would link against a wrapper library that exposed "real"
 * functions. The application would then call such functions
 * directly, by symbol, like any other function. The wrapper
 * library would handle loading the appropriate back-end, and
 * implementing a similar "get proc address" scheme internally.
 *
192 193
 * However, the above scheme does not work well in the context
 * of separated \ref api_core and \ref api_winsys. In this
Aaron Plattner's avatar
Aaron Plattner committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
 * scenario, one would require a separate wrapper library per
 * Window System, since each Window System would have a
 * different function name and prototype for the main factory
 * function. If an application then wanted to be Window System
 * agnostic (making final determination at run-time via some
 * form of plugin), it may then need to link against two
 * wrapper libraries, which would cause conflicts for all
 * symbols other than the main factory function.
 *
 * Another disadvantage of the wrapper library approach is the
 * extra level of function call required; the wrapper library
 * would internally implement the existing "get proc address"
 * and "function pointer" style dispatch anyway. Exposing this
 * directly to the application is slightly more efficient.
 *
 * \section threading Multi-threading
 *
211
 * All VDPAU functionality is fully thread-safe; any number of
Aaron Plattner's avatar
Aaron Plattner committed
212 213
 * threads may call into any VDPAU functions at any time. VDPAU
 * may not be called from signal-handlers.
214 215 216
 *
 * Note, however, that this simply guarantees that internal
 * VDPAU state will not be corrupted by thread usage, and that
Aaron Plattner's avatar
Aaron Plattner committed
217 218 219 220
 * crashes and deadlocks will not occur. Completely arbitrary
 * thread usage may not generate the results that an application
 * desires. In particular, care must be taken when multiple
 * threads are performing operations on the same VDPAU objects.
221 222 223
 *
 * VDPAU implementations guarantee correct flow of surface
 * content through the rendering pipeline, but only when
Aaron Plattner's avatar
Aaron Plattner committed
224 225 226 227
 * function calls that read from or write to a surface return to
 * the caller prior to any thread calling any other function(s)
 * that read from or write to the surface. Invoking multiple
 * reads from a surface in parallel is OK.
228 229 230 231 232 233 234 235 236 237 238 239
 *
 * Note that this restriction is placed upon VDPAU function
 * invocations, and specifically not upon any back-end
 * hardware's physical rendering operations. VDPAU
 * implementations are expected to internally synchronize such
 * hardware operations.
 *
 * In a single-threaded application, the above restriction comes
 * naturally; each function call completes before it is possible
 * to begin a new function call.
 *
 * In a multi-threaded application, threads may need to be
Aaron Plattner's avatar
Aaron Plattner committed
240
 * synchronized. For example, consider the situation where:
241 242
 *
 * - Thread 1 is parsing compressed video data, passing them
Aaron Plattner's avatar
Aaron Plattner committed
243 244
 *   through a \ref VdpDecoder "VdpDecoder" object, and filling a
 *   ring-buffer of \ref VdpVideoSurface "VdpVideoSurface"s
245
 * - Thread 2 is consuming those \ref VdpVideoSurface
Aaron Plattner's avatar
Aaron Plattner committed
246 247
 *   "VdpVideoSurface"s, and using a \ref VdpVideoMixer
 *   "VdpVideoMixer" to process them and composite them with UI.
248 249 250 251 252 253 254
 *
 * In this case, the threads must synchronize to ensure that
 * thread 1's call to \ref VdpDecoderRender has returned prior to
 * thread 2's call(s) to \ref VdpVideoMixerRender that use that
 * specific surface. This could be achieved using the following
 * pseudo-code:
 *
Aaron Plattner's avatar
Aaron Plattner committed
255
 * \code
256 257 258 259
 * Queue<VdpVideoSurface> q_full_surfaces;
 * Queue<VdpVideoSurface> q_empty_surfaces;
 *
 * thread_1() {
Aaron Plattner's avatar
Aaron Plattner committed
260 261 262 263 264 265
 *     for (;;) {
 *         VdpVideoSurface s = q_empty_surfaces.get();
 *         // Parse compressed stream here
 *         VdpDecoderRender(s, ...);
 *         q_full_surfaces.put(s);
 *     }
266 267
 * }
 *
Aaron Plattner's avatar
Aaron Plattner committed
268 269 270
 * // This would need to be more complex if
 * // VdpVideoMixerRender were to be provided with more
 * // than one field/frame at a time.
271
 * thread_2() {
Aaron Plattner's avatar
Aaron Plattner committed
272 273 274 275 276 277 278 279 280 281 282 283 284
 *     for (;;) {
 *         // Possibly, other rendering operations to mixer
 *         // layer surfaces here.
 *         VdpOutputSurface t = ...;
 *         VdpPresentationQueueBlockUntilSurfaceIdle(t);
 *         VdpVideoSurface s = q_full_surfaces.get();
 *         VdpVideoMixerRender(s, t, ...);
 *         q_empty_surfaces.put(s);
 *         // Possibly, other rendering operations to "t" here
 *         VdpPresentationQueueDisplay(t, ...);
 *     }
 * }
 * \endcode
285
 *
Aaron Plattner's avatar
Aaron Plattner committed
286 287 288 289 290
 * Finally, note that VDPAU makes no guarantees regarding any
 * level of parallelism in any given implementation. Put another
 * way, use of multi-threading is not guaranteed to yield any
 * performance gain, and in theory could even slightly reduce
 * performance due to threading/synchronization overhead.
291
 *
Aaron Plattner's avatar
Aaron Plattner committed
292
 * However, the intent of the threading requirements is to allow
293 294 295 296 297
 * for e.g. video decoding and video mixer operations to proceed
 * in parallel in hardware. Given a (presumably multi-threaded)
 * application that kept each portion of the hardware busy, this
 * would yield a performance increase.
 *
Aaron Plattner's avatar
Aaron Plattner committed
298 299
 * \section endianness Surface Endianness
 *
300 301 302 303 304
 * When dealing with surface content, i.e. the input/output of
 * Put/GetBits functions, applications must take care to access
 * memory in the correct fashion, so as to avoid endianness
 * issues.
 *
Aaron Plattner's avatar
Aaron Plattner committed
305 306 307 308 309 310 311 312 313
 * By established convention in the 3D graphics world, RGBA data
 * is defined to be an array of 32-bit pixels containing packed
 * RGBA components, not as an array of bytes or interleaved RGBA
 * components. VDPAU follows this convention. As such,
 * applications are expected to access such surfaces as arrays
 * of 32-bit components (i.e. using a 32-bit pointer), and not
 * as interleaved arrays of 8-bit components (i.e. using an
 * 8-bit pointer.) Deviation from this convention will lead to
 * endianness issues, unless appropriate care is taken.
314
 *
Aaron Plattner's avatar
Aaron Plattner committed
315 316 317 318
 * The same convention is followed for some packed YCbCr formats
 * such as \ref VDP_YCBCR_FORMAT_Y8U8V8A8; i.e. they are
 * considered arrays of 32-bit pixels, and hence should be
 * accessed as such.
319
 *
Aaron Plattner's avatar
Aaron Plattner committed
320
 * For YCbCr formats with chroma decimation and/or planar
321
 * formats, however, this convention is awkward. Therefore,
Aaron Plattner's avatar
Aaron Plattner committed
322 323 324 325
 * formats such as \ref VDP_YCBCR_FORMAT_NV12 are defined as
 * arrays of (potentially interleaved) byte-sized components.
 * Hence, applications should manipulate such data 8-bits at a
 * time, using 8-bit pointers.
326
 *
Aaron Plattner's avatar
Aaron Plattner committed
327 328 329 330 331 332
 * Note that one common usage for the input/output of
 * Put/GetBits APIs is file I/O. Typical file I/O APIs treat all
 * memory as a simple array of 8-bit values. This violates the
 * rule requiring surface data to be accessed in its true native
 * format. As such, applications may be required to solve
 * endianness issues. Possible solutions include:
333
 *
Aaron Plattner's avatar
Aaron Plattner committed
334 335 336 337
 * - Authoring static UI data files according to the endianness
 *   of the target execution platform.
 * - Conditionally byte-swapping Put/GetBits data buffers at
 *   run-time based on execution platform.
338 339 340 341 342
 *
 * Note: Complete details regarding each surface format's
 * precise pixel layout is included with the documentation of
 * each surface type. For example, see \ref
 * VDP_RGBA_FORMAT_B8G8R8A8.
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
 *
 * \section video_decoder_usage Video Decoder Usage
 *
 * VDPAU is a slice-level API. Put another way, VDPAU implementations accept
 * "slice" data from the bitstream, and perform all required processing of
 * those slices (e.g VLD decoding, IDCT, motion compensation, in-loop
 * deblocking, etc.).
 *
 * The client application is responsible for:
 *
 * - Extracting the slices from the bitstream (e.g. parsing/demultiplexing
 *   container formats, scanning the data to determine slice start positions
 *   and slice sizes).
 * - Parsing various bitstream headers/structures (e.g. sequence header,
 *   sequence parameter set, picture parameter set, entry point structures,
 *   etc.) Various fields from the parsed header structures needs to be
 *   provided to VDPAU alongside the slice bitstream in a "picture info"
 *   structure.
 * - Surface management (e.g. H.264 DPB processing, display re-ordering)
 *
 * It is recommended that applications pass solely the slice data to VDPAU;
 * specifically that any header data structures be excluded from the portion
 * of the bitstream passed to VDPAU. VDPAU implementations must operate
 * correctly if non-slice data is included, at least for formats employing
 * start codes to delimit slice data. However, any extra data may need
 * to be uploaded to hardware for parsing thus lowering performance, and/or,
 * in the worst case, may even overflow internal buffers that are sized solely
 * for slice data.
 *
 * The exact data that should be passed to VDPAU is detailed below for each
 * supported format:
 *
375
 * \subsection bitstream_mpeg1_mpeg2 MPEG-1 and MPEG-2
376 377 378 379
 *
 * Include all slices beginning with start codes 0x00000101 through
 * 0x000001AF. The slice start code must be included for all slices.
 *
380
 * \subsection bitstream_h264 H.264
381 382 383 384 385 386 387 388 389 390 391
 *
 * Include all NALs with nal_unit_type of 1 or 5 (coded slice of non-IDR/IDR
 * picture respectively). The complete slice start code (including 0x000001
 * prefix) must be included for all slices, even when the prefix is not
 * included in the bitstream.
 *
 * Note that if desired:
 *
 * - The slice start code prefix may be included in a separate bitstream
 *   buffer array entry to the actual slice data extracted from the bitstream.
 * - Multiple bitstream buffer array entries (e.g. one per slice) may point at
392
 *   the same physical data storage for the slice start code prefix.
393
 *
394
 * \subsection bitstream_vc1_sp_mp VC-1 Simple and Main Profile
395 396 397 398 399 400 401 402 403 404 405 406 407
 *
 * VC-1 simple/main profile bitstreams always consist of a single slice per
 * picture, and do not use start codes to delimit pictures. Instead, the
 * container format must indicate where each picture begins/ends.
 *
 * As such, no slice start codes should be included in the data passed to
 * VDPAU; simply pass in the exact data from the bitstream.
 *
 * Header information contained in the bitstream should be parsed by the
 * application and passed to VDPAU using the "picture info" data structure;
 * this header information explicitly must not be included in the bitstream
 * data passed to VDPAU for this encoding format.
 *
408
 * \subsection bitstream_vc1_ap VC-1 Advanced Profile
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
 *
 * Include all slices beginning with start codes 0x0000010D (frame),
 * 0x0000010C (field) or 0x0000010B (slice). The slice start code should be
 * included in all cases.
 *
 * Some VC-1 advanced profile streams do not contain slice start codes; again,
 * the container format must indicate where picture data begins and ends. In
 * this case, pictures are assumed to be progressive and to contain a single
 * slice. It is highly recommended that applications detect this condition,
 * and add the missing start codes to the bitstream passed to VDPAU. However,
 * VDPAU implementations must allow bitstreams with missing start codes, and
 * act as if a 0x0000010D (frame) start code had been present.
 *
 * Note that pictures containing multiple slices, or interlace streams, must
 * contain a complete set of slice start codes in the original bitstream;
 * without them, it is not possible to correctly parse and decode the stream.
 *
 * The bitstream passed to VDPAU should contain all original emulation
 * prevention bytes present in the original bitstream; do not remove these
 * from the bitstream.
 *
430 431 432 433 434
 * \subsection bitstream_mpeg4part2 MPEG-4 Part 2 and DivX
 *
 * Include all slices beginning with start codes 0x000001B6. The slice start
 * code must be included for all slices.
 *
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
 * \subsection bitstream_hevc H.265/HEVC - High Efficiency Video Codec
 *
 * Include all video coding layer (VCL) NAL units, with nal_unit_type values
 * of 0 (TRAIL_N) through 31 (RSV_VCL31) inclusive. In addition to parsing
 * and providing NAL units, an H.265/HEVC decoder application using VDPAU
 * for decoding must parse certain values of the first slice segment header
 * in a VCL NAL unit and provide it through VdpPictureInfoHEVC. Please see
 * the documentation for VdpPictureInfoHEVC below for further details.
 *
 * The complete slice start code (including the 0x000001 prefix) must be
 * included for all slices, even when the prefix is not included in the
 * bitstream.
 *
 * Note that if desired:
 *
 * - The slice start code prefix may be included in a separate bitstream
 *   buffer array entry to the actual slice data extracted from the bitstream.
 * - Multiple bitstream buffer array entries (e.g. one per slice) may point at
 *   the same physical data storage for the slice start code prefix.
 *
Aaron Plattner's avatar
Aaron Plattner committed
455
 * \section video_mixer_usage Video Mixer Usage
456 457 458
 *
 * \subsection video_surface_content VdpVideoSurface Content
 *
459 460
 * Each \ref VdpVideoSurface "VdpVideoSurface" is expected to contain an
 * entire frame's-worth of data, irrespective of whether an interlaced of
461 462
 * progressive sequence is being decoded.
 *
463 464 465 466 467 468 469
 * Depending on the exact encoding structure of the compressed video stream,
 * the application may need to call \ref VdpDecoderRender twice to fill a
 * single \ref VdpVideoSurface "VdpVideoSurface". When the stream contains an
 * encoded progressive frame, or a "frame coded" interlaced field-pair, a
 * single \ref VdpDecoderRender call will fill the entire surface. When the
 * stream contains separately encoded interlaced fields, two
 * \ref VdpDecoderRender calls will be required; one for the top field, and
470 471
 * one for the bottom field.
 *
472 473
 * Implementation note: When \ref VdpDecoderRender renders an interlaced
 * field, this operation must not disturb the content of the other field in
474 475
 * the surface.
 *
476 477 478 479 480 481 482
 * \subsection vm_surf_list VdpVideoMixer Surface List
 *
 * An video stream is logically composed of a sequence of fields. An
 * example is shown below, in display order, assuming top field first:
 *
 * <pre>t0 b0 t1 b1 t2 b2 t3 b3 t4 b4 t5 b5 t6 b6 t7 b7 t8 b8 t9 b9</pre>
 *
483
 * The canonical usage is to call \ref VdpVideoMixerRender once for decoded
484 485
 * field, in display order, to yield one post-processed frame for display.
 *
486 487
 * For each call to \ref VdpVideoMixerRender, the field to be processed should
 * be provided as the \b video_surface_current parameter.
488 489 490 491 492 493 494 495 496
 *
 * To enable operation of advanced de-interlacing algorithms and/or
 * post-processing algorithms, some past and/or future surfaces should be
 * provided as context. These are provided in the \b video_surface_past and
 * \b video_surface_future lists. In general, these lists may contain any
 * number of surfaces. Specific implementations may have specific requirements
 * determining the minimum required number of surfaces for optimal operation,
 * and the maximum number of useful surfaces, beyond which surfaces are not
 * used. It is recommended that in all cases other than plain bob/weave, at
497
 * least 2 past and 1 future field be provided.
498 499 500 501 502 503
 *
 * Note that it is entirely possible, in general, for any of the
 * \ref VdpVideoMixer "VdpVideoMixer" post-processing steps other than
 * de-interlacing to require access to multiple input fields/frames. For
 * example, an motion-sensitive noise-reduction algorithm.
 *
504 505 506
 * For example, when processing field t4, the \ref VdpVideoMixerRender
 * parameters may contain the following values, if the application chose to
 * provide 3 fields of context for both the past and future:
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
 *
 * <pre>
 * current_picture_structure: VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD
 * past:    [b3, t3, b2]
 * current: t4
 * future:  [b4, t5, b5]
 * </pre>
 *
 * Note that for both the past/future lists, array index 0 represents the
 * field temporally closest to current, in display order.
 *
 * The \ref VdpVideoMixerRender parameter \b current_picture_structure applies
 * to \b video_surface_current. The picture structure for the other surfaces
 * will be automatically derived from that for the current picture. The
 * derivation algorithm is extremely simple; the concatenated list
 * past/current/future is simply assumed to have an alternating top/bottom
 * pattern throughout.
 *
 * Continuing the example above, subsequent calls to \ref VdpVideoMixerRender
 * would provide the following sets of parameters:
 *
 * <pre>
 * current_picture_structure: VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD
 * past:    [t4, b3, t3]
 * current: b4
 * future:  [t5, b5, t6]
 * </pre>
 *
 * then:
536
 *
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
 * <pre>
 * current_picture_structure: VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD
 * past:    [b4, t4, b3]
 * current: t5
 * future:  [b5, t6, b7]
 * </pre>
 *
 * In other words, the concatenated list of past/current/future frames simply
 * forms a window that slides through the sequence of decoded fields.
 *
 * It is syntactically legal for an application to choose not to provide a
 * particular entry in the past or future lists. In this case, the "slot" in
 * the surface list must be filled with the special value
 * \ref VDP_INVALID_HANDLE, to explicitly indicate that the picture is
 * missing; do not simply shuffle other surfaces together to fill in the gap.
 * Note that entries should only be omitted under special circumstances, such
 * as failed decode due to bitstream error during picture header parsing,
 * since missing entries will typically cause advanced de-interlacing
 * algorithms to experience significantly degraded operation.
 *
 * Specific examples for different de-interlacing types are presented below.
 *
 * \subsection deint_weave Weave De-interlacing
 *
 * Weave de-interlacing is the act of interleaving the lines of two temporally
 * adjacent fields to form a frame for display.
 *
 * To disable de-interlacing for progressive streams, simply specify
 * \b current_picture_structure as \ref VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
 * no de-interlacing will be applied.
 *
 * Weave de-interlacing for interlaced streams is identical to disabling
 * de-interlacing, as describe immediately above, because each
 * \ref VdpVideoSurface already contains an entire frame's worth (i.e. two
 * fields) of picture data.
 *
 * Inverse telecine is disabled when using weave de-interlacing.
 *
 * Weave de-interlacing produces one output frame for each input frame. The
 * application should make one \ref VdpVideoMixerRender call per pair of
 * decoded fields, or per decoded frame.
 *
 * Weave de-interlacing requires no entries in the past/future lists.
 *
 * All implementations must support weave de-interlacing.
 *
 * \subsection deint_bob Bob De-interlacing
 *
 * Bob de-interlacing is the act of vertically scaling a single field to the
 * size of a single frame.
 *
 * To achieve bob de-interlacing, simply provide a single field as
 * \b video_surface_current, and set \b current_picture_structure
 * appropriately, to indicate whether a top or bottom field was provided.
 *
 * Inverse telecine is disabled when using bob de-interlacing.
 *
 * Bob de-interlacing produces one output frame for each input field. The
 * application should make one \ref VdpVideoMixerRender call per decoded
 * field.
 *
 * Bob de-interlacing requires no entries in the past/future lists.
 *
 * Bob de-interlacing is the default when no advanced method is requested and
 * enabled. Advanced de-interlacing algorithms may fall back to bob e.g. when
 * required past/future fields are missing.
603
 *
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642
 * All implementations must support bob de-interlacing.
 *
 * \subsection deint_adv Advanced De-interlacing
 *
 * Operation of both temporal and temporal-spatial de-interlacing is
 * identical; the only difference is the internal processing the algorithm
 * performs in generating the output frame.
 *
 * These algorithms use various advanced processing on the pixels of both the
 * current and various past/future fields in order to determine how best to
 * de-interlacing individual portions of the image.
 *
 * Inverse telecine may be enabled when using advanced de-interlacing.
 *
 * Advanced de-interlacing produces one output frame for each input field. The
 * application should make one \ref VdpVideoMixerRender call per decoded
 * field.
 *
 * Advanced de-interlacing requires entries in the past/future lists.
 *
 * Availability of advanced de-interlacing algorithms is implementation
 * dependent.
 *
 * \subsection deint_rate De-interlacing Rate
 *
 * For all de-interlacing algorithms except weave, a choice may be made to
 * call \ref VdpVideoMixerRender for either each decoded field, or every
 * second decoded field.
 *
 * If \ref VdpVideoMixerRender is called for every decoded field, the
 * generated post-processed frame rate is equal to the decoded field rate.
 * Put another way, the generated post-processed nominal field rate is equal
 * to 2x the decoded field rate. This is standard practice.
 *
 * If \ref VdpVideoMixerRender is called for every second decoded field (say
 * every top field), the generated post-processed frame rate is half to the
 * decoded field rate. This mode of operation is thus referred to as
 * "half-rate".
 *
643 644 645
 * Implementations may choose whether to support half-rate de-interlacing
 * or not. Regular full-rate de-interlacing should be supported by any
 * supported advanced de-interlacing algorithm.
646 647 648
 *
 * The descriptions of de-interlacing algorithms above assume that regular
 * (not half-rate) operation is being performed, when detailing the number of
649
 * VdpVideoMixerRender calls.
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
 *
 * Recall that the concatenation of past/current/future surface lists simply
 * forms a window into the stream of decoded fields. To achieve standard
 * de-interlacing, the window is slid through the list of decoded fields one
 * field at a time, and a call is made to \ref VdpVideoMixerRender for each
 * movement of the window. To achieve half-rate de-interlacing, the window is
 * slid through the* list of decoded fields two fields at a time, and a
 * call is made to \ref VdpVideoMixerRender for each movement of the window.
 *
 * \subsection invtc Inverse Telecine
 *
 * Assuming the implementation supports it, inverse telecine may be enabled
 * alongside any advanced de-interlacing algorithm. Inverse telecine is never
 * active for bob or weave.
 *
 * Operation of \ref VdpVideoMixerRender with inverse telecine active is
 * identical to the basic operation mechanisms describe above in every way;
 * all inverse telecine processing is performed internally to the
 * \ref VdpVideoMixer "VdpVideoMixer".
 *
 * In particular, there is no provision way for \ref VdpVideoMixerRender to
 * indicate when identical input fields have been observed, and consequently
 * identical output frames may have been produced.
 *
 * De-interlacing (and inverse telecine) may be applied to streams that are
 * marked as being progressive. This will allow detection of, and correct
 * de-interlacing of, mixed interlace/progressive streams, bad edits, etc.
 * To implement de-interlacing/inverse-telecine on progressive material,
 * simply treat the stream of decoded frames as a stream of decoded fields,
 * apply any telecine flags (see the next section), and then apply
 * de-interlacing to those fields as described above.
 *
 * Implementations are free to determine whether inverse telecine operates
 * in conjunction with half-rate de-interlacing or not. It should always
 * operate with regular de-interlacing, when advertized.
 *
 * \subsection tcflags Telecine (Pull-Down) Flags
 *
 * Some media delivery formats, e.g. DVD-Video, include flags that are
 * intended to modify the decoded field sequence before display. This allows
 * e.g. 24p content to be encoded at 48i, which saves space relative to a 60i
 * encoded stream, but still displayed at 60i, to match target consumer
 * display equipment.
 *
 * If the inverse telecine option is not activated in the
 * \ref VdpVideoMixer "VdpVideoMixer", these flags should be ignored, and the
 * decoded fields passed directly to \ref VdpVideoMixerRender as detailed
 * above.
 *
 * However, to make full use of the inverse telecine feature, these flags
 * should be applied to the field stream, yielding another field stream with
 * some repeated fields, before passing the field stream to
 * \ref VdpVideoMixerRender. In this scenario, the sliding window mentioned
 * in the descriptions above applies to the field stream after application of
 * flags.
 *
706 707
 * \section extending Extending the API
 *
Aaron Plattner's avatar
Aaron Plattner committed
708
 * \subsection extend_enums Enumerations and Other Constants
709
 *
Aaron Plattner's avatar
Aaron Plattner committed
710
 * VDPAU defines a number of enumeration types.
711
 *
Aaron Plattner's avatar
Aaron Plattner committed
712 713 714
 * When modifying VDPAU, existing enumeration constants must
 * continue to exist (although they may be deprecated), and do
 * so in the existing order.
715 716 717 718
 *
 * The above discussion naturally applies to "manually" defined
 * enumerations, using pre-processor macros, too.
 *
Aaron Plattner's avatar
Aaron Plattner committed
719
 * \subsection extend_structs Structures
720
 *
Aaron Plattner's avatar
Aaron Plattner committed
721 722
 * In most case, VDPAU includes no provision for modifying existing
 * structure definitions, although they may be deprecated.
723
 *
Aaron Plattner's avatar
Aaron Plattner committed
724
 * New structures may be created, together with new API entry
725 726
 * points or feature/attribute/parameter values, to expose new
 * functionality.
Aaron Plattner's avatar
Aaron Plattner committed
727 728 729
 *
 * A few structures are considered plausible candidates for future extension.
 * Such structures include a version number as the first field, indicating the
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748
 * exact layout of the client-provided data. When changing such structures, the
 * old structure must be preserved and a new structure created. This allows
 * applications built against the old version of the structure to continue to
 * interoperate. For example, to extend the VdpProcamp structure, define a new
 * VdpProcamp1 and update VdpGenerateCSCMatrix to take the new structure as an
 * argument. Document in a comment that the caller must fill the struct_version
 * field with the value 1. VDPAU implementations should use the struct_version
 * field to determine which version of the structure the application was built
 * against.  Note that you cannot simply increment the value of
 * VDP_PROCAMP_VERSION because applications recompiled against a newer version
 * of vdpau.h but that have not been updated to use the new structure must still
 * report that they're using version 0.
 *
 * Note that the layouts of VdpPictureInfo structures are defined by their
 * corresponding VdpDecoderProfile numbers, so no struct_version field is
 * needed for them. This layout includes the size of the structure, so new
 * profiles that extend existing functionality may incorporate the old
 * VdpPictureInfo as a substructure, but may not modify existing VdpPictureInfo
 * structures.
749
 *
Aaron Plattner's avatar
Aaron Plattner committed
750
 * \subsection extend_functions Functions
751
 *
Aaron Plattner's avatar
Aaron Plattner committed
752 753
 * Existing functions may not be modified, although they may be
 * deprecated.
754
 *
Aaron Plattner's avatar
Aaron Plattner committed
755 756 757
 * New functions may be added at will. Note the enumeration
 * requirements when modifying the enumeration that defines the
 * list of entry points.
758 759 760 761 762 763
 *
 * \section preemption_note Display Preemption
 *
 * Please note that the display may be preempted away from
 * VDPAU at any time. See \ref display_preemption for more
 * details.
Aaron Plattner's avatar
Aaron Plattner committed
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798
 *
 * \subsection trademarks Trademarks
 *
 * VDPAU is a trademark of NVIDIA Corporation. You may freely use the
 * VDPAU trademark, as long as trademark ownership is attributed to
 * NVIDIA Corporation.
 */

/**
 * \file vdpau.h
 * \brief The Core API
 *
 * This file contains the \ref api_core "Core API".
 */

#ifndef _VDPAU_H
#define _VDPAU_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \defgroup api_core Core API
 *
 * The core API encompasses all VDPAU functionality that operates
 * in the same fashion across all Window Systems.
 *
 * @{
 */

/**
 * \defgroup base_types Basic Types
799
 *
Aaron Plattner's avatar
Aaron Plattner committed
800 801 802 803 804 805 806 807 808
 * VDPAU primarily uses ISO C99 types from \c stdint.h.
 *
 * @{
 */

/** \brief A true \ref VdpBool value */
#define VDP_TRUE 1
/** \brief A false \ref VdpBool value */
#define VDP_FALSE 0
809 810
/**
 * \brief A boolean value, holding \ref VDP_TRUE or \ref
Aaron Plattner's avatar
Aaron Plattner committed
811 812 813 814
 * VDP_FALSE.
 */
typedef int VdpBool;

815
/** @} */
Aaron Plattner's avatar
Aaron Plattner committed
816 817 818 819 820 821 822 823

/**
 * \defgroup misc_types Miscellaneous Types
 *
 * @{
 */

/**
824 825 826 827 828 829 830 831
 * \brief An invalid object handle value.
 *
 * This value may be used to represent an invalid, or
 * non-existent, object (\ref VdpDevice "VdpDevice",
 * \ref VdpVideoSurface "VdpVideoSurface", etc.)
 *
 * Note that most APIs require valid object handles in all
 * cases, and will fail when presented with this value.
Aaron Plattner's avatar
Aaron Plattner committed
832 833 834 835 836 837 838 839 840
 */
#define VDP_INVALID_HANDLE 0xffffffffU

/**
 * \brief The set of all chroma formats for \ref VdpVideoSurface
 * "VdpVideoSurface"s.
 */
typedef uint32_t VdpChromaType;

841 842 843 844 845 846 847 848
/** \hideinitializer \brief 4:2:0 chroma format. Undefined field/frame based
 *  Video surfaces allocated with this chroma type have undefined
 *  field/frame structure. The implementation is free to internally morph
 *  the surface between frame/field(NV12/NV24) as required by
 *  VdpVideoDecoder operation. Interop with OpenGL allows registration
 *  of these surfaces for either field- or frame-based interop. But, an implicit
 *  field/frame structure conversion may be performed.
 */
849
#define VDP_CHROMA_TYPE_420 ((VdpChromaType)0)
850 851 852 853 854 855 856 857
/** \hideinitializer \brief 4:2:2 chroma format. Undefined field/frame based
 *  Video surfaces allocated with this chroma type have undefined
 *  field/frame structure. The implementation is free to internally morph
 *  the surface between frame/field(NV12/NV24) as required by
 *  VdpVideoDecoder operation. Interop with OpenGL allows registration
 *  of these surfaces for either field- or frame-based interop. But, an implicit
 *  field/frame structure conversion may be performed.
 */
858
#define VDP_CHROMA_TYPE_422 ((VdpChromaType)1)
859 860 861 862 863 864 865 866
/** \hideinitializer \brief 4:4:4 chroma format. Undefined field/frame based
 *  Video surfaces allocated with this chroma type have undefined
 *  field/frame structure. The implementation is free to internally morph
 *  the surface between frame/field(NV12/NV24) as required by
 *  VdpVideoDecoder operation. Interop with OpenGL allows registration
 *  of these surfaces for either field- or frame-based interop. But, an implicit
 *  field/frame structure conversion may be performed.
 */
867
#define VDP_CHROMA_TYPE_444 ((VdpChromaType)2)
Aaron Plattner's avatar
Aaron Plattner committed
868

869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899
/** \hideinitializer \brief 4:2:0 chroma format. Field based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_420_FIELD ((VdpChromaType)3)
/** \hideinitializer \brief 4:2:2 chroma format. Field based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_422_FIELD ((VdpChromaType)4)
/** \hideinitializer \brief 4:4:4 chroma format. Field based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_444_FIELD ((VdpChromaType)5)

/** \hideinitializer \brief 4:2:0 chroma format. Frame based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_420_FRAME ((VdpChromaType)6)
/** \hideinitializer \brief 4:2:2 chroma format. Frame based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_422_FRAME ((VdpChromaType)7)
/** \hideinitializer \brief 4:4:4 chroma format. Frame based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_444_FRAME ((VdpChromaType)8)
900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958
/** \hideinitializer \brief 4:2:0 chroma format. Undefined field/frame based
 *  Video surfaces allocated with this chroma type have undefined
 *  field/frame structure. The implementation is free to internally morph
 *  the surface between frame/field as required by VdpVideoDecoder operation.
 *  Interop with OpenGL allows registration of these surfaces for either
 *  field- or frame-based interop. But, an implicit field/frame structure
 *  conversion may be performed.
 */
#define VDP_CHROMA_TYPE_420_16 ((VdpChromaType)9)
/** \hideinitializer \brief 4:2:2 chroma format. Undefined field/frame based
 *  Video surfaces allocated with this chroma type have undefined
 *  field/frame structure. The implementation is free to internally morph
 *  the surface between frame/field as required by VdpVideoDecoder operation.
 *  Interop with OpenGL allows registration of these surfaces for either
 *  field- or frame-based interop. But, an implicit field/frame structure
 *  conversion may be performed.
 */
#define VDP_CHROMA_TYPE_422_16 ((VdpChromaType)10)
/** \hideinitializer \brief 4:4:4 chroma format. Undefined field/frame based
 *  Video surfaces allocated with this chroma type have undefined
 *  field/frame structure. The implementation is free to internally morph
 *  the surface between frame/field as required by VdpVideoDecoder operation.
 *  Interop with OpenGL allows registration of these surfaces for either
 *  field- or frame-based interop. But, an implicit field/frame structure
 *  conversion may be performed.
 */
#define VDP_CHROMA_TYPE_444_16 ((VdpChromaType)11)

/** \hideinitializer \brief 4:2:0 chroma format. Field based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_420_FIELD_16 ((VdpChromaType)12)
/** \hideinitializer \brief 4:2:2 chroma format. Field based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_422_FIELD_16 ((VdpChromaType)13)
/** \hideinitializer \brief 4:4:4 chroma format. Field based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_444_FIELD_16 ((VdpChromaType)14)

/** \hideinitializer \brief 4:2:0 chroma format. Frame based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_420_FRAME_16 ((VdpChromaType)15)
/** \hideinitializer \brief 4:2:2 chroma format. Frame based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_422_FRAME_16 ((VdpChromaType)16)
/** \hideinitializer \brief 4:4:4 chroma format. Frame based.
 *  Video surfaces allocated with this chroma type can only be
 *  interoped with OpenGL if the matching field/frame structure is
 *  specified in the OpenGL API */
#define VDP_CHROMA_TYPE_444_FRAME_16 ((VdpChromaType)17)
959

Aaron Plattner's avatar
Aaron Plattner committed
960 961 962 963 964
/**
 * \brief The set of all known YCbCr surface formats.
 */
typedef uint32_t VdpYCbCrFormat;

965 966 967 968 969 970 971 972 973 974 975 976 977
/**
 * \hideinitializer
 * \brief The "NV12" YCbCr surface format.
 *
 * This format has a two planes, a Y plane and a UV plane.
 *
 * The Y plane is an array of byte-sized Y components.
 * Applications should access this data via a uint8_t pointer.
 *
 * The UV plane is an array of interleaved byte-sized U and V
 * components, in the order U, V, U, V. Applications should
 * access this data via a uint8_t pointer.
 */
978
#define VDP_YCBCR_FORMAT_NV12     ((VdpYCbCrFormat)0)
979 980 981 982
/**
 * \hideinitializer
 * \brief The "YV12" YCbCr surface format.
 *
Stephen Warren's avatar
Stephen Warren committed
983
 * This format has a three planes, a Y plane, a V plane, and a U
984 985 986 987 988 989
 * plane.
 *
 * Each of the planes is an array of byte-sized components.
 *
 * Applications should access this data via a uint8_t pointer.
 */
990
#define VDP_YCBCR_FORMAT_YV12     ((VdpYCbCrFormat)1)
991 992 993 994 995 996 997 998 999 1000 1001
/**
 * \hideinitializer
 * \brief The "UYVY" YCbCr surface format.
 *
 * This format may also be known as Y422, UYNV, HDYC.
 *
 * This format has a single plane.
 *
 * This plane is an array of interleaved byte-sized Y, U, and V
 * components, in the order U, Y, V, Y, U, Y, V, Y.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1002
 * Applications should access this data via a uint8_t pointer.
1003
 */
1004
#define VDP_YCBCR_FORMAT_UYVY     ((VdpYCbCrFormat)2)
1005 1006 1007 1008
/**
 * \hideinitializer
 * \brief The "YUYV" YCbCr surface format.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1009
 * This format may also be known as YUY2, YUNV, V422.
1010 1011 1012 1013 1014 1015
 *
 * This format has a single plane.
 *
 * This plane is an array of interleaved byte-sized Y, U, and V
 * components, in the order Y, U, Y, V, Y, U, Y, V.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1016
 * Applications should access this data via a uint8_t pointer.
1017
 */
1018
#define VDP_YCBCR_FORMAT_YUYV     ((VdpYCbCrFormat)3)
1019 1020
/**
 * \hideinitializer
Aaron Plattner's avatar
Aaron Plattner committed
1021
 * \brief A packed YCbCr format.
1022 1023 1024 1025 1026 1027 1028
 *
 * This format has a single plane.
 *
 * This plane is an array packed 32-bit pixel data. Within each
 * 32-bit pixel, bits [31:24] contain A, bits [23:16] contain V,
 * bits [15:8] contain U, and bits [7:0] contain Y.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1029
 * Applications should access this data via a uint32_t pointer.
1030
 */
1031
#define VDP_YCBCR_FORMAT_Y8U8V8A8 ((VdpYCbCrFormat)4)
1032 1033
/**
 * \hideinitializer
Aaron Plattner's avatar
Aaron Plattner committed
1034
 * \brief A packed YCbCr format.
1035 1036 1037 1038
 *
 * This format has a single plane.
 *
 * This plane is an array packed 32-bit pixel data. Within each
Aaron Plattner's avatar
Aaron Plattner committed
1039
 * 32-bit pixel, bits [31:24] contain A, bits [23:16] contain Y,
1040 1041
 * bits [15:8] contain U, and bits [7:0] contain V.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1042
 * Applications should access this data via a uint32_t pointer.
1043
 */
1044
#define VDP_YCBCR_FORMAT_V8U8Y8A8 ((VdpYCbCrFormat)5)
ManojBonda's avatar
ManojBonda committed
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070
/**
 * \hideinitializer
 * \brief The "Y_UV_444" YCbCr surface format.
 *
 * This format has two planes, a Y plane and a UV plane.
 *
 * The Y plane is an array of byte-sized Y components.
 * Applications should access this data via a uint8_t pointer.
 *
 * The UV plane is an array of interleaved byte-sized U and V
 * components, in the order U, V, U, V. Applications should
 * access this data via a uint8_t pointer.
 */
#define VDP_YCBCR_FORMAT_Y_UV_444     ((VdpYCbCrFormat)6)
/**
 * \hideinitializer
 * \brief The "Y_U_V_444" YCbCr surface format.
 *
 * This format has three planes, a Y plane, a V plane, and a U
 * plane.
 *
 * Each of the planes is an array of byte-sized components.
 *
 * Applications should access this data via a uint8_t pointer.
 */
#define VDP_YCBCR_FORMAT_Y_U_V_444     ((VdpYCbCrFormat)7)
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114
/**
 * \hideinitializer
 * \brief The P010 surface format.
 *
 * This format has two planes, a Y plane and a UV plane.
 *
 * The Y plane is an array of two byte sized Y components.
 * Applications should access this data via a uint16_t pointer.
 *
 * The UV plane is an array of interleaved two byte sized U and V
 * components, in the order U, V, U, V. Applications should
 * access this data via a uint8_t pointer.
 *
 * Note that the P010 surface format has an identical memory
 * layout as the P016 surface format, with bits 0 through 5
 * set to zero.
 */
#define VDP_YCBCR_FORMAT_P010           ((VdpYCbCrFormat)8)
/**
 * \hideinitializer
 * \brief The P016 surface format.
 *
 * This format has two planes, a Y plane and a UV plane.
 *
 * The Y plane is an array of two byte sized Y components.
 * Applications should access this data via a uint16_t pointer.
 *
 * The UV plane is an array of interleaved two byte sized U and V
 * components, in the order U, V, U, V. Applications should
 * access this data via a uint8_t pointer.
 */
#define VDP_YCBCR_FORMAT_P016           ((VdpYCbCrFormat)9)
 /**
  * \hideinitializer
  * \brief The "Y_U_V_444_16" YCbCr surface format.
  *
  * This format has three planes, a Y plane, a V plane, and a U
  * plane.
  *
  * Each of the planes is an array of two byte-sized components.
  *
  * Applications should access this data via a uint16_t pointer.
  */
 #define VDP_YCBCR_FORMAT_Y_U_V_444_16     ((VdpYCbCrFormat)11)
Aaron Plattner's avatar
Aaron Plattner committed
1115 1116 1117 1118 1119 1120

/**
 * \brief  The set of all known RGB surface formats.
 */
typedef uint32_t VdpRGBAFormat;

1121 1122
/**
 * \hideinitializer
Aaron Plattner's avatar
Aaron Plattner committed
1123
 * \brief A packed RGB format.
1124 1125 1126 1127
 *
 * This format has a single plane.
 *
 * This plane is an array packed 32-bit pixel data. Within each
Aaron Plattner's avatar
Aaron Plattner committed
1128
 * 32-bit pixel, bits [31:24] contain A, bits [23:16] contain R,
1129 1130
 * bits [15:8] contain G, and bits [7:0] contain B.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1131
 * Applications should access this data via a uint32_t pointer.
1132
 */
1133
#define VDP_RGBA_FORMAT_B8G8R8A8    ((VdpRGBAFormat)0)
1134 1135
/**
 * \hideinitializer
Aaron Plattner's avatar
Aaron Plattner committed
1136
 * \brief A packed RGB format.
1137 1138 1139 1140
 *
 * This format has a single plane.
 *
 * This plane is an array packed 32-bit pixel data. Within each
Aaron Plattner's avatar
Aaron Plattner committed
1141
 * 32-bit pixel, bits [31:24] contain A, bits [23:16] contain B,
1142 1143
 * bits [15:8] contain G, and bits [7:0] contain R.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1144
 * Applications should access this data via a uint32_t pointer.
1145
 */
1146
#define VDP_RGBA_FORMAT_R8G8B8A8    ((VdpRGBAFormat)1)
1147 1148
/**
 * \hideinitializer
Aaron Plattner's avatar
Aaron Plattner committed
1149
 * \brief A packed RGB format.
1150 1151 1152 1153
 *
 * This format has a single plane.
 *
 * This plane is an array packed 32-bit pixel data. Within each
Aaron Plattner's avatar
Aaron Plattner committed
1154
 * 32-bit pixel, bits [31:30] contain A, bits [29:20] contain B,
1155 1156 1157 1158
 * bits [19:10] contain G, and bits [9:0] contain R.
 *
 * Applications should access this data via a uint32_t pointer.
 */
1159
#define VDP_RGBA_FORMAT_R10G10B10A2 ((VdpRGBAFormat)2)
1160 1161
/**
 * \hideinitializer
Aaron Plattner's avatar
Aaron Plattner committed
1162
 * \brief A packed RGB format.
1163 1164 1165 1166
 *
 * This format has a single plane.
 *
 * This plane is an array packed 32-bit pixel data. Within each
Aaron Plattner's avatar
Aaron Plattner committed
1167
 * 32-bit pixel, bits [31:30] contain A, bits [29:20] contain R,
1168 1169 1170 1171
 * bits [19:10] contain G, and bits [9:0] contain B.
 *
 * Applications should access this data via a uint32_t pointer.
 */
1172
#define VDP_RGBA_FORMAT_B10G10R10A2 ((VdpRGBAFormat)3)
1173 1174 1175 1176 1177 1178
/**
 * \hideinitializer
 * \brief An alpha-only surface format.
 *
 * This format has a single plane.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1179
 * This plane is an array of byte-sized components.
1180 1181 1182
 *
 * Applications should access this data via a uint8_t pointer.
 */
1183
#define VDP_RGBA_FORMAT_A8          ((VdpRGBAFormat)4)
Aaron Plattner's avatar
Aaron Plattner committed
1184 1185 1186 1187 1188 1189

/**
 * \brief  The set of all known indexed surface formats.
 */
typedef uint32_t VdpIndexedFormat;

1190 1191 1192 1193 1194 1195 1196
/**
 * \hideinitializer
 * \brief A 4-bit indexed format, with alpha.
 *
 * This format has a single plane.
 *
 * This plane is an array of byte-sized components. Within each
Aaron Plattner's avatar
Aaron Plattner committed
1197
 * byte, bits [7:4] contain I (index), and bits [3:0] contain A.
1198 1199 1200
 *
 * Applications should access this data via a uint8_t pointer.
 */
1201
#define VDP_INDEXED_FORMAT_A4I4 ((VdpIndexedFormat)0)
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212
/**
 * \hideinitializer
 * \brief A 4-bit indexed format, with alpha.
 *
 * This format has a single plane.
 *
 * This plane is an array of byte-sized components. Within each
 * byte, bits [7:4] contain A, and bits [3:0] contain I (index).
 *
 * Applications should access this data via a uint8_t pointer.
 */
1213
#define VDP_INDEXED_FORMAT_I4A4 ((VdpIndexedFormat)1)
1214 1215 1216 1217 1218 1219 1220 1221 1222
/**
 * \hideinitializer
 * \brief A 8-bit indexed format, with alpha.
 *
 * This format has a single plane.
 *
 * This plane is an array of interleaved byte-sized A and I
 * (index) components, in the order A, I, A, I.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1223
 * Applications should access this data via a uint8_t pointer.
1224
 */
1225
#define VDP_INDEXED_FORMAT_A8I8 ((VdpIndexedFormat)2)
1226 1227 1228 1229 1230 1231 1232 1233 1234
/**
 * \hideinitializer
 * \brief A 8-bit indexed format, with alpha.
 *
 * This format has a single plane.
 *
 * This plane is an array of interleaved byte-sized A and I
 * (index) components, in the order I, A, I, A.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1235
 * Applications should access this data via a uint8_t pointer.
1236
 */
1237
#define VDP_INDEXED_FORMAT_I8A8 ((VdpIndexedFormat)3)
Aaron Plattner's avatar
Aaron Plattner committed
1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288

/**
 * \brief A location within a surface.
 *
 * The VDPAU co-ordinate system has its origin at the top-left
 * of a surface, with x and y components increasing right and
 * down.
 */
typedef struct {
    /** X co-ordinate. */
    uint32_t x;
    /** Y co-ordinate. */
    uint32_t y;
} VdpPoint;

/**
 * \brief A rectangular region of a surface.
 *
 * The co-ordinates are top-left inclusive, bottom-right
 * exclusive.
 *
 * The VDPAU co-ordinate system has its origin at the top-left
 * of a surface, with x and y components increasing right and
 * down.
 */
typedef struct {
    /** Left X co-ordinate. Inclusive. */
    uint32_t x0;
    /** Top Y co-ordinate. Inclusive. */
    uint32_t y0;
    /** Right X co-ordinate. Exclusive. */
    uint32_t x1;
    /** Bottom Y co-ordinate. Exclusive. */
    uint32_t y1;
} VdpRect;

/**
 * A constant RGBA color.
 *
 * Note that the components are stored as float values in the
 * range 0.0...1.0 rather than format-specific integer values.
 * This allows VdpColor values to be independent from the exact
 * surface format(s) in use.
 */
typedef struct {
    float red;
    float green;
    float blue;
    float alpha;
} VdpColor;

1289
/** @} */
Aaron Plattner's avatar
Aaron Plattner committed
1290 1291 1292 1293 1294 1295 1296 1297

/**
 * \defgroup error_handling Error Handling
 *
 * @{
 */

/**
1298
 * \hideinitializer
Aaron Plattner's avatar
Aaron Plattner committed
1299 1300 1301 1302 1303 1304 1305 1306 1307
 * \brief The set of all possible error codes.
 */
typedef enum {
    /** The operation completed successfully; no error. */
    VDP_STATUS_OK = 0,
    /**
     * No backend implementation could be loaded.
     */
    VDP_STATUS_NO_IMPLEMENTATION,
1308
    /**
Aaron Plattner's avatar
Aaron Plattner committed
1309 1310
     * The display was preempted, or a fatal error occurred.
     *
1311
     * The application must re-initialize VDPAU.
Aaron Plattner's avatar
Aaron Plattner committed
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437
     */
    VDP_STATUS_DISPLAY_PREEMPTED,
    /**
     * An invalid handle value was provided.
     *
     * Either the handle does not exist at all, or refers to an object of an
     * incorrect type.
     */
    VDP_STATUS_INVALID_HANDLE,
    /**
     * An invalid pointer was provided.
     *
     * Typically, this means that a NULL pointer was provided for an "output"
     * parameter.
     */
    VDP_STATUS_INVALID_POINTER,
    /**
     * An invalid/unsupported \ref VdpChromaType value was supplied.
     */
    VDP_STATUS_INVALID_CHROMA_TYPE,
    /**
     * An invalid/unsupported \ref VdpYCbCrFormat value was supplied.
     */
    VDP_STATUS_INVALID_Y_CB_CR_FORMAT,
    /**
     * An invalid/unsupported \ref VdpRGBAFormat value was supplied.
     */
    VDP_STATUS_INVALID_RGBA_FORMAT,
    /**
     * An invalid/unsupported \ref VdpIndexedFormat value was supplied.
     */
    VDP_STATUS_INVALID_INDEXED_FORMAT,
    /**
     * An invalid/unsupported \ref VdpColorStandard value was supplied.
     */
    VDP_STATUS_INVALID_COLOR_STANDARD,
    /**
     * An invalid/unsupported \ref VdpColorTableFormat value was supplied.
     */
    VDP_STATUS_INVALID_COLOR_TABLE_FORMAT,
    /**
     * An invalid/unsupported \ref VdpOutputSurfaceRenderBlendFactor value was
     * supplied.
     */
    VDP_STATUS_INVALID_BLEND_FACTOR,
    /**
     * An invalid/unsupported \ref VdpOutputSurfaceRenderBlendEquation value
     * was supplied.
     */
    VDP_STATUS_INVALID_BLEND_EQUATION,
    /**
     * An invalid/unsupported flag value/combination was supplied.
     */
    VDP_STATUS_INVALID_FLAG,
    /**
     * An invalid/unsupported \ref VdpDecoderProfile value was supplied.
     */
    VDP_STATUS_INVALID_DECODER_PROFILE,
    /**
     * An invalid/unsupported \ref VdpVideoMixerFeature value was supplied.
     */
    VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE,
    /**
     * An invalid/unsupported \ref VdpVideoMixerParameter value was supplied.
     */
    VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER,
    /**
     * An invalid/unsupported \ref VdpVideoMixerAttribute value was supplied.
     */
    VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE,
    /**
     * An invalid/unsupported \ref VdpVideoMixerPictureStructure value was
     * supplied.
     */
    VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE,
    /**
     * An invalid/unsupported \ref VdpFuncId value was supplied.
     */
    VDP_STATUS_INVALID_FUNC_ID,
    /**
     * The size of a supplied object does not match the object it is being
     * used with.
     *
     * For example, a \ref VdpVideoMixer "VdpVideoMixer" is configured to
     * process \ref VdpVideoSurface "VdpVideoSurface" objects of a specific
     * size. If presented with a \ref VdpVideoSurface "VdpVideoSurface" of a
     * different size, this error will be raised.
     */
    VDP_STATUS_INVALID_SIZE,
    /**
     * An invalid/unsupported value was supplied.
     *
     * This is a catch-all error code for values of type other than those
     * with a specific error code.
     */
    VDP_STATUS_INVALID_VALUE,
    /**
     * An invalid/unsupported structure version was specified in a versioned
     * structure. This implies that the implementation is older than the
     * header file the application was built against.
     */
    VDP_STATUS_INVALID_STRUCT_VERSION,
    /**
     * The system does not have enough resources to complete the requested
     * operation at this time.
     */
    VDP_STATUS_RESOURCES,
    /**
     * The set of handles supplied are not all related to the same VdpDevice.
     *
     * When performing operations that operate on multiple surfaces, such as
     * \ref  VdpOutputSurfaceRenderOutputSurface or \ref VdpVideoMixerRender,
     * all supplied surfaces must have been created within the context of the
     * same \ref VdpDevice "VdpDevice" object. This error is raised if they were
     * not.
     */
    VDP_STATUS_HANDLE_DEVICE_MISMATCH,
    /**
     * A catch-all error, used when no other error code applies.
     */
    VDP_STATUS_ERROR,
} VdpStatus;

/**
 * \brief Retrieve a string describing an error code.
 * \param[in] status The error code.
1438
 * \return A pointer to the string. Note that this is a
Aaron Plattner's avatar
Aaron Plattner committed
1439 1440 1441 1442 1443 1444 1445 1446 1447
 *       statically allocated read-only string. As such, the
 *       application must not free the returned pointer. The
 *       pointer is valid as long as the VDPAU implementation is
 *       present within the application's address space.
 */
typedef char const * VdpGetErrorString(
    VdpStatus status
);

1448
/** @} */
Aaron Plattner's avatar
Aaron Plattner committed
1449

1450 1451 1452 1453 1454 1455
/**
 * \defgroup versioning Versioning
 *
 *
 * @{
 */
Aaron Plattner's avatar
Aaron Plattner committed
1456

1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473
/**
 * \brief The VDPAU interface version described by this header file.
 *
 * This version will only increase if a major incompatible change is made.
 * For example, if the parameters passed to an existing function are modified,
 * rather than simply adding new functions/enumerations), or if the mechanism
 * used to load the backend driver is modified incompatibly. Such changes are
 * unlikely.
 *
 * This value also represents the DSO version of VDPAU-related
 * shared-libraries.
 *
 * VDPAU version numbers are simple integers that increase monotonically
 * (typically by value 1).
 */
#define VDPAU_INTERFACE_VERSION 1

1474 1475 1476
/**
 * \brief The VDPAU version described by this header file.
 *
1477 1478 1479 1480 1481 1482 1483
 * This version will increase whenever any non-documentation change is made to
 * vdpau.h, or related header files such as vdpau_x11.h. Such changes
 * typically involve the addition of new functions, constants, or features.
 * Such changes are expected to be completely backwards-compatible.
 *
 * VDPAU version numbers are simple integers that increase monotonically
 * (typically by value 1).
Aaron Plattner's avatar
Aaron Plattner committed
1484
 */
1485
#define VDPAU_VERSION 1
Aaron Plattner's avatar
Aaron Plattner committed
1486 1487

/**
1488
 * \brief Retrieve the VDPAU version implemented by the backend.
Aaron Plattner's avatar
Aaron Plattner committed
1489 1490 1491 1492 1493 1494 1495 1496 1497
 * \param[out] api_version The API version.
 * \return VdpStatus The completion status of the operation.
 */
typedef VdpStatus VdpGetApiVersion(
    /* output parameters follow */
    uint32_t * api_version
);

/**
1498
 * \brief Retrieve an implementation-specific string description
Aaron Plattner's avatar
Aaron Plattner committed
1499 1500 1501 1502 1503 1504 1505 1506
 *        of the implementation. This typically includes detailed version
 *        information.
 * \param[out] information_string A pointer to the information
 *       string. Note that this is a statically allocated
 *       read-only string. As such, the application must not
 *       free the returned pointer. The pointer is valid as long
 *       as the implementation is present within the
 *       application's address space.
1507 1508 1509 1510 1511 1512
 * \return VdpStatus The completion status of the operation.
 *
 * Note that the returned string is useful for information
 * reporting. It is not intended that the application should
 * parse this string in order to determine any information about
 * the implementation.
Aaron Plattner's avatar
Aaron Plattner committed
1513 1514 1515 1516 1517 1518
 */
typedef VdpStatus VdpGetInformationString(
    /* output parameters follow */
    char const * * information_string
);

1519
/** @} */
Aaron Plattner's avatar
Aaron Plattner committed
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548

/**
 * \defgroup VdpDevice VdpDevice; Primary API object
 *
 * The VdpDevice is the root of the VDPAU object system. Using a
 * VdpDevice object, all other object types may be created. See
 * the sections describing those other object types for details
 * on object creation.
 *
 * Note that VdpDevice objects are created using the \ref
 * api_winsys.
 *
 * @{
 */

/**
 * \brief  An opaque handle representing a VdpDevice object.
 */
typedef uint32_t VdpDevice;

/**
 * \brief Destroy a VdpDevice.
 * \param[in] device The device to destroy.
 * \return VdpStatus The completion status of the operation.
 */
typedef VdpStatus VdpDeviceDestroy(
    VdpDevice device
);

1549
/** @} */
Aaron Plattner's avatar
Aaron Plattner committed
1550 1551 1552 1553 1554

/**
 * \defgroup VdpCSCMatrix VdpCSCMatrix; CSC Matrix Manipulation
 *
 * When converting from YCbCr to RGB data formats, a color space
1555 1556
 * conversion operation must be performed. This operation is
 * parameterized using a "color space conversion matrix". The
Aaron Plattner's avatar
Aaron Plattner committed
1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615
 * VdpCSCMatrix is a data structure representing this
 * information.
 *
 * @{
 */

/**
 * \brief Storage for a color space conversion matrix.
 *
 * Note that the application may choose to construct the matrix
 * content by either:
 * - Directly filling in the fields of the CSC matrix
 * - Using the \ref VdpGenerateCSCMatrix helper function.
 *
 * The color space conversion equation is as follows:
 *
 * \f[
 * \left( \begin{array}{c} R \\ G \\ B \end{array} \right)
 * =
 * \left( \begin{array}{cccc}
 * m_{0,0} & m_{0,1} & m_{0,2} & m_{0,3} \\
 * m_{1,0} & m_{1,1} & m_{1,2} & m_{1,3} \\
 * m_{2,0} & m_{2,1} & m_{2,2} & m_{2,3}
 * \end{array}
 * \right)
 * *
 * \left( \begin{array}{c} Y \\ Cb \\ Cr \\ 1.0 \end{array}
 *      \right)
 * \f]
 */
typedef float VdpCSCMatrix[3][4];

#define VDP_PROCAMP_VERSION 0

/**
 * \brief Procamp operation parameterization data.
 *
 * When performing a color space conversion operation, various
 * adjustments can be performed at the same time, such as
 * brightness and contrast. This structure defines the level of
 * adjustments to make.
 */
typedef struct {
    /**
     * This field must be filled with VDP_PROCAMP_VERSION
     */
    uint32_t struct_version;
    /**
     * Brightness adjustment amount. A value clamped between
     * -1.0 and 1.0. 0.0 represents no modification.
     */
    float brightness;
    /**
     * Contrast adjustment amount. A value clamped between
     * 0.0 and 10.0. 1.0 represents no modification.
     */
    float contrast;
    /**
     * Saturation adjustment amount. A value clamped between 0.0 and
1616
     * 10.0. 1.0 represents no modification.
Aaron Plattner's avatar
Aaron Plattner committed
1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634
     */
    float saturation;
    /**
     * Hue adjustment amount. A value clamped between
     * -PI and PI. 0.0 represents no modification.
     */
    float hue;
} VdpProcamp;

/**
 * \brief YCbCr color space specification.
 *
 * A number of YCbCr color spaces exist. This enumeration
 * defines the specifications known to VDPAU.
 */
typedef uint32_t VdpColorStandard;

/** \hideinitializer \brief ITU-R BT.601 */
1635
#define VDP_COLOR_STANDARD_ITUR_BT_601 ((VdpColorStandard)0)
Aaron Plattner's avatar
Aaron Plattner committed
1636
/** \hideinitializer \brief ITU-R BT.709 */
1637
#define VDP_COLOR_STANDARD_ITUR_BT_709 ((VdpColorStandard)1)
Aaron Plattner's avatar
Aaron Plattner committed
1638
/** \hideinitializer \brief SMPTE-240M */
1639
#define VDP_COLOR_STANDARD_SMPTE_240M  ((VdpColorStandard)2)
Aaron Plattner's avatar
Aaron Plattner committed
1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655

/**
 * \brief Generate a color space conversion matrix
 * \param[in] procamp The procamp adjustments to make. If NULL,
 *        no adjustments will be made.
 * \param[in] standard The YCbCr color space to convert from.
 * \param[out] csc_matrix The CSC matrix to initialize.
 * \return VdpStatus The completion status of the operation.
 */
typedef VdpStatus VdpGenerateCSCMatrix(
    VdpProcamp *     procamp,
    VdpColorStandard standard,
    /* output parameters follow */
    VdpCSCMatrix *   csc_matrix
);

1656
/** @} */
Aaron Plattner's avatar
Aaron Plattner committed
1657 1658 1659 1660 1661

/**
 * \defgroup VdpVideoSurface VdpVideoSurface; Video Surface object
 *
 * A VdpVideoSurface stores YCbCr data in an internal format,
1662
 * with a variety of possible chroma sub-sampling options.
Aaron Plattner's avatar
Aaron Plattner committed
1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740
 *
 * A VdpVideoSurface may be filled with:
 * - Data provided by the CPU via \ref
 *   VdpVideoSurfacePutBitsYCbCr (i.e. software decode.)
 * - The result of applying a \ref VdpDecoder "VdpDecoder" to
 *   compressed video data.
 *
 * VdpVideoSurface content may be accessed by:
 * - The application via \ref VdpVideoSurfaceGetBitsYCbCr
 * - The Hardware that implements \ref VdpOutputSurface
 *   "VdpOutputSurface" \ref VdpOutputSurfaceRender
 *   "rendering functionality".
 * - The Hardware the implements \ref VdpVideoMixer
 *   "VdpVideoMixer" functionality.
 *
 * VdpVideoSurfaces are not directly displayable. They must be
 * converted into a displayable format using \ref VdpVideoMixer
 * "VdpVideoMixer" objects.
 *
 * See \ref video_mixer_usage for additional information.
 *
 * @{
 */

/**
 * \brief Query the implementation's VdpVideoSurface
 *        capabilities.
 * \param[in] device The device to query.
 * \param[in] surface_chroma_type The type of chroma type for
 *       which information is requested.
 * \param[out] is_supported Is this chroma type supported?
 * \param[out] max_width The maximum supported surface width for
 *       this chroma type.
 * \param[out] max_height The maximum supported surface height
 *       for this chroma type.
 * \return VdpStatus The completion status of the operation.
 */
typedef VdpStatus VdpVideoSurfaceQueryCapabilities(
    VdpDevice     device,
    VdpChromaType surface_chroma_type,
    /* output parameters follow */
    VdpBool *     is_supported,
    uint32_t *    max_width,
    uint32_t *    max_height
);

/**
 * \brief Query the implementation's VdpVideoSurface
 *        GetBits/PutBits capabilities.
 * \param[in] device The device to query.
 * \param[in] surface_chroma_type The type of chroma type for
 *       which information is requested.
 * \param[in] bits_ycbcr_format The format of application "bits"
 *       buffer for which information is requested.
 * \param[out] is_supported Is this chroma type supported?
 * \return VdpStatus The completion status of the operation.
 */
typedef VdpStatus VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(
    VdpDevice      device,
    VdpChromaType  surface_chroma_type,
    VdpYCbCrFormat bits_ycbcr_format,
    /* output parameters follow */
    VdpBool *      is_supported
);

/**
 * \brief An opaque handle representing a VdpVideoSurface
 *        object.
 */
typedef uint32_t VdpVideoSurface;

/**
 * \brief Create a VdpVideoSurface.
 * \param[in] device The device that will contain the surface.
 * \param[in] chroma_type The chroma type of the new surface.
 * \param[in] width The width of the new surface.
 * \param[in] height The height of the new surface.
 * \param[out] surface The new surface's handle.
1741 1742
 * \return VdpStatus The completion status of the operation.
 *
Aaron Plattner's avatar
Aaron Plattner committed
1743
 * The memory backing the surface may not be initialized during
1744 1745 1746
 * creation. Applications are expected to initialize any region
 * that they use, via \ref VdpDecoderRender or \ref
 * VdpVideoSurfacePutBitsYCbCr.
Stephen Warren's avatar
Stephen Warren committed
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777
 *
 * Note that certain widths/heights are impossible for specific values of
 * chroma_type. For example, the definition of VDP_CHROMA_TYPE_420 implies
 * that the width must be even, since each single chroma sample covers two
 * luma samples horizontally. A similar argument applies to surface heights,
 * although doubly so, since interlaced pictures must be supported; each
 * field's height must itself be a multiple of 2. Hence the overall surface's
 * height must be a multiple of 4.
 *
 * Similar rules apply to other chroma_type values.
 *
 * Implementations may also impose additional restrictions on the surface
 * sizes they support, potentially requiring additional rounding of actual
 * surface sizes.
 *
 * In most cases, this is not an issue, since:
 * - Video streams are encoded as an array of macro-blocks, which typically
 *   have larger size alignment requirements than video surfaces do.
 * - APIs such as \ref VdpVideoMixerRender allow specification of a sub-region
 *   of the surface to read, which allows the padding data to be clipped away.
 *
 * However, other APIs such as \ref VdpVideoSurfaceGetBitsYCbCr and
 * \ref VdpVideoSurfacePutBitsYCbCr do not allow a sub-region to be specified,
 * and always operate on surface size that was actually allocated, rather
 * than the surface size that was requested. In this case, applications need
 * to be aware of the actual surface size, in order to allocate appropriately
 * sized buffers for the get-/put-bits operations.
 *
 * For this reason, applications may need to call
 * \ref VdpVideoSurfaceGetParameters after creation, in order to retrieve the
 * actual surface size.
Aaron Plattner's avatar
Aaron Plattner committed
1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863
 */
typedef VdpStatus VdpVideoSurfaceCreate(
    VdpDevice         device,
    VdpChromaType     chroma_type,
    uint32_t          width,
    uint32_t          height,
    /* output parameters follow */
    VdpVideoSurface * surface
);

/**
 * \brief Destroy a VdpVideoSurface.
 * \param[in] surface The surface's handle.
 * \return VdpStatus The completion status of the operation.
 */
typedef VdpStatus VdpVideoSurfaceDestroy(
    VdpVideoSurface surface
);

/**
 * \brief Retrieve the parameters used to create a
 *        VdpVideoSurface.
 * \param[in] surface The surface's handle.
 * \param[out] chroma_type The chroma type of the surface.
 * \param[out] width The width of the surface.
 * \param[out] height The height of the surface.
 * \return VdpStatus The completion status of the operation.
 */
typedef VdpStatus VdpVideoSurfaceGetParameters(
    VdpVideoSurface surface,
    /* output parameters follow */
    VdpChromaType * chroma_type,
    uint32_t *      width,
    uint32_t *      height
);

/**
 * \brief Copy image data from a VdpVideoSurface to application
 *        memory in a specified YCbCr format.
 * \param[in] surface The surface's handle.
 * \param[in] destination_ycbcr_format The format of the
 *       application's data buffers.
 * \param[in] destination_data Pointers to the application data
 *       buffers into which the image data will be written. Note
 *       that this is an array of pointers, one per plane. The
 *       destination_format parameter will define how many
 *       planes are required.
 * \param[in] destination_pitches Pointers to the pitch values
 *       for the application data buffers. Note that this is an
 *       array of pointers, one per plane. The
 *       destination_format parameter will define how many
 *       planes are required.
 * \return VdpStatus The completion status of the operation.
 */
typedef VdpStatus VdpVideoSurfaceGetBitsYCbCr(
    VdpVideoSurface  surface,
    VdpYCbCrFormat   destination_ycbcr_format,
    void * const *   destination_data,
    uint32_t const * destination_pitches
);

/**
 * \brief Copy image data from application memory in a specific
 *        YCbCr format to a VdpVideoSurface.
 * \param[in] surface The surface's handle.
 * \param[in] source_ycbcr_format The format of the
 *       application's data buffers.
 * \param[in] source_data Pointers to the application data
 *       buffers from which the image data will be copied. Note
 *       that this is an array of pointers, one per plane. The
 *       source_format parameter will define how many
 *       planes are required.
 * \param[in] source_pitches Pointers to the pitch values
 *       for the application data buffers. Note that this is an
 *       array of pointers, one per plane. The
 *       source_format parameter will define how many
 *       planes are required.
 * \return VdpStatus The completion status of the operation.
 */
typedef VdpStatus VdpVideoSurfacePutBitsYCbCr(
    VdpVideoSurface      surface,
    VdpYCbCrFormat       source_ycbcr_format,
    void const * const * source_data,
    uint32_t const *     source_pitches
);

1864
/** @} */
Aaron Plattner's avatar
Aaron Plattner committed
1865 1866

/**
1867
 * \defgroup VdpOutputSurface VdpOutputSurface; Output Surface object
Aaron Plattner's avatar
Aaron Plattner committed
1868
 *
1869
 * A VdpOutputSurface stores RGBA data in a defined format.
Aaron Plattner's avatar
Aaron Plattner committed
1870