1 /*
2 * Video Acceleration API (video decoding)
3 * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1
4 *
5 * Copyright (C) 2008-2009 Splitted-Desktop Systems
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
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 *
14 * FFmpeg is distributed in the hope that it will be useful,
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
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
27
28 /**
29 * @addtogroup VAAPI_Decoding
30 *
31 * @{
32 */
33
35 {
36 unsigned int i;
37 for (i = 0; i < n_buffers; i++) {
38 if (buffers[i] != VA_INVALID_ID) {
39 vaDestroyBuffer(display, buffers[i]);
40 buffers[i] = VA_INVALID_ID;
41 }
42 }
43 }
44
46 {
49
50 if (!user_vactx) {
51 av_log(avctx,
AV_LOG_ERROR,
"Hardware acceleration context (hwaccel_context) does not exist.\n");
53 }
54
58
62
63 return 0;
64 }
65
67 {
68 return 0;
69 }
70
72 {
73 VABufferID va_buffers[3];
74 unsigned int n_va_buffers = 0;
75
77 return 0;
78
81
85 }
86
90 }
91
93 surface) != VA_STATUS_SUCCESS)
94 return -1;
95
97 va_buffers, n_va_buffers) != VA_STATUS_SUCCESS)
98 return -1;
99
103 return -1;
104
106 return -1;
107
108 return 0;
109 }
110
112 {
114 VABufferID slice_param_buf_id, slice_data_buf_id;
115
117 return 0;
118
119 slice_buf_ids =
123 if (!slice_buf_ids)
124 return -1;
126
127 slice_param_buf_id = VA_INVALID_ID;
129 VASliceParameterBufferType,
132 &slice_param_buf_id) != VA_STATUS_SUCCESS)
133 return -1;
135
136 slice_data_buf_id = VA_INVALID_ID;
138 VASliceDataBufferType,
141 &slice_data_buf_id) != VA_STATUS_SUCCESS)
142 return -1;
145
148 return 0;
149 }
150
152 {
154
155 *buf_id = VA_INVALID_ID;
157 type, size, 1,
NULL, buf_id) == VA_STATUS_SUCCESS)
158 vaMapBuffer(vactx->
display, *buf_id, &data);
159
161 }
162
164 {
166 }
167
169 {
171 }
172
174 {
176 }
177
179 {
181 VASliceParameterBufferBase *slice_param;
182
189 }
190
191 slice_params =
195 if (!slice_params)
198
200 slice_param->slice_data_size =
size;
202 slice_param->slice_data_flag = VA_SLICE_DATA_FLAG_ALL;
203
206 return slice_param;
207 }
208
210 {
212
223 }
224
225 #if CONFIG_H263_VAAPI_HWACCEL || CONFIG_MPEG1_VAAPI_HWACCEL || \
226 CONFIG_MPEG2_VAAPI_HWACCEL || CONFIG_MPEG4_VAAPI_HWACCEL || \
227 CONFIG_VC1_VAAPI_HWACCEL || CONFIG_WMV3_VAAPI_HWACCEL
229 {
232 int ret;
233
235 if (ret < 0)
237
240 if (ret < 0)
242
244
247 return ret;
248 }
249 #endif
250
251 /* @} */
VASliceParameterBufferBase * ff_vaapi_alloc_slice(FFVAContext *vactx, const uint8_t *buffer, uint32_t size)
Allocate a new slice descriptor for the input slice.
int ff_vaapi_context_fini(AVCodecContext *avctx)
Common AVHWAccel.uninit() implementation.
VAContextID context_id
Context ID (video decode pipeline)
const uint8_t * slice_data
Pointer to slice data buffer base.
ptrdiff_t const GLvoid * data
int ff_vaapi_render_picture(FFVAContext *vactx, VASurfaceID surface)
VABufferID pic_param_buf_id
Picture parameter buffer.
uint32_t context_id
Context ID (video decode pipeline)
This structure is used to share data between the FFmpeg library and the client video application...
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
void * hwaccel_context
Hardware accelerator context.
unsigned int slice_param_size
Size of a slice parameter element.
VADisplay display
Windowing system dependent handle.
void * ff_vaapi_alloc_iq_matrix(FFVAContext *vactx, unsigned int size)
Allocate a new IQ matrix buffer.
static FFVAContext * ff_vaapi_get_context(AVCodecContext *avctx)
Extract vaapi_context from an AVCodecContext.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
VABufferID iq_matrix_buf_id
Inverse quantiser matrix buffer.
void ff_vaapi_common_end_frame(AVCodecContext *avctx)
Common AVHWAccel.end_frame() implementation.
int ff_vaapi_context_init(AVCodecContext *avctx)
Common AVHWAccel.init() implementation.
static void destroy_buffers(VADisplay display, VABufferID *buffers, unsigned int n_buffers)
unsigned int n_slice_buf_ids
Number of effective slice buffers.
unsigned int slice_params_alloc
Number of allocated slice parameters.
Picture * current_picture_ptr
pointer to the current picture
static VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
Extract VASurfaceID from an AVFrame.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
VABufferID * slice_buf_ids
Slice parameter/data buffers.
void * slice_params
Pointer to slice parameter buffers.
unsigned int slice_buf_ids_alloc
Number of allocated slice buffers.
void * display
Window system dependent data.
attribute_deprecated uint32_t * slice_buf_ids
Slice parameter/data buffer IDs.
main external API structure.
int ff_vaapi_commit_slices(FFVAContext *vactx)
void * ff_vaapi_alloc_pic_param(FFVAContext *vactx, unsigned int size)
Allocate a new picture parameter buffer.
unsigned int slice_data_size
Current size of slice data.
attribute_deprecated void * slice_params
Pointer to VASliceParameterBuffers.
struct AVCodecContext * avctx
unsigned int slice_count
Number of slices currently filled in.
VABufferID bitplane_buf_id
Bitplane buffer (for VC-1 decoding)
VAConfigID config_id
Configuration ID.
int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx)
uint8_t * ff_vaapi_alloc_bitplane(FFVAContext *vactx, uint32_t size)
Allocate a new bit-plane buffer.
static void * alloc_buffer(FFVAContext *vactx, int type, unsigned int size, uint32_t *buf_id)
uint32_t config_id
Configuration ID.