]> git.sesse.net Git - ffmpeg/blob - libavcodec/vaapi_decode.h
lavc: Rewrite VAAPI decode infrastructure
[ffmpeg] / libavcodec / vaapi_decode.h
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"
29 #include "vaapi.h"
30
31 static inline VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
32 {
33     return (uintptr_t)pic->data[3];
34 }
35
36 enum {
37     MAX_PARAM_BUFFERS = 16,
38 };
39
40 typedef struct VAAPIDecodePicture {
41     VASurfaceID           output_surface;
42
43     int                nb_param_buffers;
44     VABufferID            param_buffers[MAX_PARAM_BUFFERS];
45
46     int                nb_slices;
47     VABufferID           *slice_buffers;
48     int                   slices_allocated;
49 } VAAPIDecodePicture;
50
51 typedef struct VAAPIDecodeContext {
52     VAProfile             va_profile;
53     VAEntrypoint          va_entrypoint;
54     VAConfigID            va_config;
55     VAContextID           va_context;
56
57     int                   have_old_context;
58     struct vaapi_context *old_context;
59     AVBufferRef          *device_ref;
60
61     AVHWDeviceContext    *device;
62     AVVAAPIDeviceContext *hwctx;
63
64     AVHWFramesContext    *frames;
65     AVVAAPIFramesContext *hwfc;
66 } VAAPIDecodeContext;
67
68
69 int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
70                                       VAAPIDecodePicture *pic,
71                                       int type,
72                                       const void *data,
73                                       size_t size);
74
75 int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx,
76                                       VAAPIDecodePicture *pic,
77                                       const void *params_data,
78                                       size_t params_size,
79                                       const void *slice_data,
80                                       size_t slice_size);
81
82 int ff_vaapi_decode_issue(AVCodecContext *avctx,
83                           VAAPIDecodePicture *pic);
84 int ff_vaapi_decode_cancel(AVCodecContext *avctx,
85                            VAAPIDecodePicture *pic);
86
87 int ff_vaapi_decode_init(AVCodecContext *avctx);
88 int ff_vaapi_decode_uninit(AVCodecContext *avctx);
89
90 #endif /* AVCODEC_VAAPI_DECODE_H */