vdpau: Support for VDPAU accelerated HEVC decoding
[libav.git] / libavcodec / vdpau_internal.h
CommitLineData
369122dd
NC
1/*
2 * Video Decode and Presentation API for UNIX (VDPAU) is used for
3 * HW decode acceleration for MPEG-1/2, H.264 and VC-1.
4 *
406792e7 5 * Copyright (C) 2008 NVIDIA
369122dd 6 *
2912e87a 7 * This file is part of Libav.
369122dd 8 *
2912e87a 9 * Libav is free software; you can redistribute it and/or
369122dd
NC
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
2912e87a 14 * Libav is distributed in the hope that it will be useful,
369122dd
NC
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
2912e87a 20 * License along with Libav; if not, write to the Free Software
369122dd
NC
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef AVCODEC_VDPAU_INTERNAL_H
25#define AVCODEC_VDPAU_INTERNAL_H
26
0d9efa28 27#include <stdint.h>
2852740e 28#include <vdpau/vdpau.h>
70cbf334 29
ecbcebde
DB
30#include "libavutil/frame.h"
31
70cbf334 32#include "avcodec.h"
ecbcebde 33#include "vdpau.h"
0d9efa28 34
1b1094a1 35/** Extract VdpVideoSurface from an AVFrame */
36static inline uintptr_t ff_vdpau_get_surface_id(AVFrame *pic)
44e065d5 37{
1b1094a1 38 return (uintptr_t)pic->data[3];
44e065d5
RDC
39}
40
737d35e3 41union VDPAUPictureInfo {
f824535a
RDC
42 VdpPictureInfoH264 h264;
43 VdpPictureInfoMPEG1Or2 mpeg;
44 VdpPictureInfoVC1 vc1;
45 VdpPictureInfoMPEG4Part2 mpeg4;
737d35e3
RDC
46#ifdef VDP_DECODER_PROFILE_H264_HIGH_444_PREDICTIVE
47 VdpPictureInfoH264Predictive h264_predictive;
f824535a 48#endif
8d34a2f8
PL
49#ifdef VDP_DECODER_PROFILE_HEVC_MAIN
50 VdpPictureInfoHEVC hevc;
51#endif
737d35e3 52};
f824535a 53
ce083282
RDC
54typedef struct VDPAUHWContext {
55 AVVDPAUContext context;
56 VdpDevice device;
57 VdpGetProcAddress *get_proc_address;
e3e158e8 58 char reset;
d565fef1 59 unsigned char flags;
ce083282
RDC
60} VDPAUHWContext;
61
62typedef struct VDPAUContext {
63 /**
64 * VDPAU device handle
65 */
66 VdpDevice device;
67
68 /**
69 * VDPAU decoder handle
70 */
71 VdpDecoder decoder;
72
73 /**
74 * VDPAU device driver
75 */
76 VdpGetProcAddress *get_proc_address;
77
78 /**
79 * VDPAU decoder render callback
80 */
81 VdpDecoderRender *render;
502cde40
RDC
82
83 uint32_t width;
84 uint32_t height;
ce083282
RDC
85} VDPAUContext;
86
2852740e
RDC
87struct vdpau_picture_context {
88 /**
89 * VDPAU picture information.
90 */
737d35e3 91 union VDPAUPictureInfo info;
2852740e
RDC
92
93 /**
94 * Allocated size of the bitstream_buffers table.
95 */
96 int bitstream_buffers_allocated;
97
98 /**
99 * Useful bitstream buffers in the bitstream buffers table.
100 */
101 int bitstream_buffers_used;
102
103 /**
104 * Table of bitstream buffers.
105 */
106 VdpBitstreamBuffer *bitstream_buffers;
107};
108
ce083282
RDC
109int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
110 int level);
111int ff_vdpau_common_uninit(AVCodecContext *avctx);
112
7948a51b 113int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic,
171f1446 114 const uint8_t *buffer, uint32_t size);
fcc10226
RDC
115int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
116 struct vdpau_picture_context *pic);
2c541554 117int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx);
7948a51b 118int ff_vdpau_add_buffer(struct vdpau_picture_context *pic, const uint8_t *buf,
119 uint32_t buf_size);
44e065d5 120
369122dd 121#endif /* AVCODEC_VDPAU_INTERNAL_H */