2 * This file is part of FFmpeg.
4 * FFmpeg 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.
9 * FFmpeg 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.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef AVCODEC_VAAPI_DECODE_H
20 #define AVCODEC_VAAPI_DECODE_H
24 #include "libavutil/frame.h"
25 #include "libavutil/hwcontext.h"
26 #include "libavutil/hwcontext_vaapi.h"
31 #if FF_API_STRUCT_VAAPI_CONTEXT
35 static inline VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
37 return (uintptr_t)pic->data[3];
41 MAX_PARAM_BUFFERS = 16,
44 typedef struct VAAPIDecodePicture {
45 VASurfaceID output_surface;
48 VABufferID param_buffers[MAX_PARAM_BUFFERS];
51 VABufferID *slice_buffers;
55 typedef struct VAAPIDecodeContext {
57 VAContextID va_context;
59 #if FF_API_STRUCT_VAAPI_CONTEXT
60 FF_DISABLE_DEPRECATION_WARNINGS
62 struct vaapi_context *old_context;
63 AVBufferRef *device_ref;
64 FF_ENABLE_DEPRECATION_WARNINGS
67 AVHWDeviceContext *device;
68 AVVAAPIDeviceContext *hwctx;
70 AVHWFramesContext *frames;
71 AVVAAPIFramesContext *hwfc;
73 enum AVPixelFormat surface_format;
76 VASurfaceAttrib pixel_format_attribute;
80 int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
81 VAAPIDecodePicture *pic,
86 int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx,
87 VAAPIDecodePicture *pic,
88 const void *params_data,
90 const void *slice_data,
93 int ff_vaapi_decode_issue(AVCodecContext *avctx,
94 VAAPIDecodePicture *pic);
95 int ff_vaapi_decode_cancel(AVCodecContext *avctx,
96 VAAPIDecodePicture *pic);
98 int ff_vaapi_decode_init(AVCodecContext *avctx);
99 int ff_vaapi_decode_uninit(AVCodecContext *avctx);
101 int ff_vaapi_common_frame_params(AVCodecContext *avctx,
102 AVBufferRef *hw_frames_ctx);
104 #endif /* AVCODEC_VAAPI_DECODE_H */