vaapi: Implement device-only setup
[libav.git] / libavcodec / vaapi_decode.h
CommitLineData
123ccd07
MT
1/*
2 * This file is part of Libav.
3 *
4 * Libav is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * Libav is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVCODEC_VAAPI_DECODE_H
20#define AVCODEC_VAAPI_DECODE_H
21
22#include <va/va.h>
23
24#include "libavutil/frame.h"
25#include "libavutil/hwcontext.h"
26#include "libavutil/hwcontext_vaapi.h"
27
28#include "avcodec.h"
851960f6
MT
29
30#include "version.h"
31#if FF_API_VAAPI_CONTEXT
123ccd07 32#include "vaapi.h"
851960f6 33#endif
123ccd07
MT
34
35static inline VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
36{
37 return (uintptr_t)pic->data[3];
38}
39
40enum {
41 MAX_PARAM_BUFFERS = 16,
42};
43
44typedef struct VAAPIDecodePicture {
45 VASurfaceID output_surface;
46
47 int nb_param_buffers;
48 VABufferID param_buffers[MAX_PARAM_BUFFERS];
49
50 int nb_slices;
51 VABufferID *slice_buffers;
52 int slices_allocated;
53} VAAPIDecodePicture;
54
55typedef struct VAAPIDecodeContext {
56 VAProfile va_profile;
57 VAEntrypoint va_entrypoint;
58 VAConfigID va_config;
59 VAContextID va_context;
60
851960f6 61#if FF_API_VAAPI_CONTEXT
123ccd07
MT
62 int have_old_context;
63 struct vaapi_context *old_context;
64 AVBufferRef *device_ref;
851960f6 65#endif
123ccd07
MT
66
67 AVHWDeviceContext *device;
68 AVVAAPIDeviceContext *hwctx;
69
70 AVHWFramesContext *frames;
71 AVVAAPIFramesContext *hwfc;
5dd9a4b8
MT
72
73 enum AVPixelFormat surface_format;
74 int surface_count;
123ccd07
MT
75} VAAPIDecodeContext;
76
77
78int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
79 VAAPIDecodePicture *pic,
80 int type,
81 const void *data,
82 size_t size);
83
84int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx,
85 VAAPIDecodePicture *pic,
86 const void *params_data,
87 size_t params_size,
88 const void *slice_data,
89 size_t slice_size);
90
91int ff_vaapi_decode_issue(AVCodecContext *avctx,
92 VAAPIDecodePicture *pic);
93int ff_vaapi_decode_cancel(AVCodecContext *avctx,
94 VAAPIDecodePicture *pic);
95
96int ff_vaapi_decode_init(AVCodecContext *avctx);
97int ff_vaapi_decode_uninit(AVCodecContext *avctx);
98
99#endif /* AVCODEC_VAAPI_DECODE_H */