Ticket #643: 10-vaapi_dynamic_load.patch
| File 10-vaapi_dynamic_load.patch, 7.5 KB (added by , 15 years ago) |
|---|
-
configure
2858 2858 done 2859 2859 2860 2860 check_lib math.h sin -lm && LIBM="-lm" 2861 enabled vaapi && require vaapi va/va.h vaInitialize -lva2861 enabled vaapi && check_header va/va.h 2862 2862 2863 2863 check_mathfunc exp2 2864 2864 check_mathfunc exp2f -
libavcodec/vaapi.c
29 29 * @{ 30 30 */ 31 31 32 static void destroy_buffers( VADisplay display, VABufferID *buffers, unsigned int n_buffers)32 static void destroy_buffers(struct vaapi_context *vactx, VADisplay display, VABufferID *buffers, unsigned int n_buffers) 33 33 { 34 34 unsigned int i; 35 36 if (!vactx->va_destroy_buffer_function) 37 return; 38 35 39 for (i = 0; i < n_buffers; i++) { 36 40 if (buffers[i]) { 37 va DestroyBuffer(display, buffers[i]);41 vactx->va_destroy_buffer_function(display, buffers[i]); 38 42 buffers[i] = 0; 39 43 } 40 44 } … … 45 49 VABufferID va_buffers[3]; 46 50 unsigned int n_va_buffers = 0; 47 51 48 vaUnmapBuffer(vactx->display, vactx->pic_param_buf_id); 52 if (!vactx->va_unmap_buffer_function) 53 return -1; 54 55 vactx->va_unmap_buffer_function(vactx->display, vactx->pic_param_buf_id); 49 56 va_buffers[n_va_buffers++] = vactx->pic_param_buf_id; 50 57 51 58 if (vactx->iq_matrix_buf_id) { 52 va UnmapBuffer(vactx->display, vactx->iq_matrix_buf_id);59 vactx->va_unmap_buffer_function(vactx->display, vactx->iq_matrix_buf_id); 53 60 va_buffers[n_va_buffers++] = vactx->iq_matrix_buf_id; 54 61 } 55 62 56 63 if (vactx->bitplane_buf_id) { 57 va UnmapBuffer(vactx->display, vactx->bitplane_buf_id);64 vactx->va_unmap_buffer_function(vactx->display, vactx->bitplane_buf_id); 58 65 va_buffers[n_va_buffers++] = vactx->bitplane_buf_id; 59 66 } 60 67 61 if (va BeginPicture(vactx->display, vactx->context_id,68 if (vactx->va_begin_picture_function && vactx->va_begin_picture_function(vactx->display, vactx->context_id, 62 69 surface) != VA_STATUS_SUCCESS) 63 70 return -1; 64 71 65 if (va RenderPicture(vactx->display, vactx->context_id,72 if (vactx->va_render_picture_function && vactx->va_render_picture_function(vactx->display, vactx->context_id, 66 73 va_buffers, n_va_buffers) != VA_STATUS_SUCCESS) 67 74 return -1; 68 75 69 if (va RenderPicture(vactx->display, vactx->context_id,76 if (vactx->va_render_picture_function && vactx->va_render_picture_function(vactx->display, vactx->context_id, 70 77 vactx->slice_buf_ids, 71 78 vactx->n_slice_buf_ids) != VA_STATUS_SUCCESS) 72 79 return -1; 73 80 74 if (va EndPicture(vactx->display, vactx->context_id) != VA_STATUS_SUCCESS)81 if (vactx->va_end_picture_function && vactx->va_end_picture_function(vactx->display, vactx->context_id) != VA_STATUS_SUCCESS) 75 82 return -1; 76 83 77 84 return 0; … … 85 92 if (vactx->slice_count == 0) 86 93 return 0; 87 94 95 if (!vactx->va_create_buffer_function) 96 return -1; 97 88 98 slice_buf_ids = 89 99 av_fast_realloc(vactx->slice_buf_ids, 90 100 &vactx->slice_buf_ids_alloc, … … 94 104 vactx->slice_buf_ids = slice_buf_ids; 95 105 96 106 slice_param_buf_id = 0; 97 if (va CreateBuffer(vactx->display, vactx->context_id,107 if (vactx->va_create_buffer_function(vactx->display, vactx->context_id, 98 108 VASliceParameterBufferType, 99 109 vactx->slice_param_size, 100 110 vactx->slice_count, vactx->slice_params, … … 103 113 vactx->slice_count = 0; 104 114 105 115 slice_data_buf_id = 0; 106 if (va CreateBuffer(vactx->display, vactx->context_id,116 if (vactx->va_create_buffer_function(vactx->display, vactx->context_id, 107 117 VASliceDataBufferType, 108 118 vactx->slice_data_size, 109 119 1, (void *)vactx->slice_data, … … 121 131 { 122 132 void *data = NULL; 123 133 134 if (!vactx->va_map_buffer_function || !vactx->va_create_buffer_function) 135 return NULL; 136 124 137 *buf_id = 0; 125 if (va CreateBuffer(vactx->display, vactx->context_id,138 if (vactx->va_create_buffer_function(vactx->display, vactx->context_id, 126 139 type, size, 1, NULL, buf_id) == VA_STATUS_SUCCESS) 127 va MapBuffer(vactx->display, *buf_id, &data);140 vactx->va_map_buffer_function(vactx->display, *buf_id, &data); 128 141 129 142 return data; 130 143 } … … 192 205 ret = 0; 193 206 194 207 done: 195 destroy_buffers(vactx ->display, &vactx->pic_param_buf_id, 1);196 destroy_buffers(vactx ->display, &vactx->iq_matrix_buf_id, 1);197 destroy_buffers(vactx ->display, &vactx->bitplane_buf_id, 1);198 destroy_buffers(vactx ->display, vactx->slice_buf_ids, vactx->n_slice_buf_ids);208 destroy_buffers(vactx, vactx->display, &vactx->pic_param_buf_id, 1); 209 destroy_buffers(vactx, vactx->display, &vactx->iq_matrix_buf_id, 1); 210 destroy_buffers(vactx, vactx->display, &vactx->bitplane_buf_id, 1); 211 destroy_buffers(vactx, vactx->display, vactx->slice_buf_ids, vactx->n_slice_buf_ids); 199 212 av_freep(&vactx->slice_buf_ids); 200 213 av_freep(&vactx->slice_params); 201 214 vactx->n_slice_buf_ids = 0; -
libavcodec/vaapi.h
25 25 #define AVCODEC_VAAPI_H 26 26 27 27 #include <stdint.h> 28 #include <va/va.h> 28 29 29 30 /** 30 31 * \defgroup VAAPI_Decoding VA API Decoding … … 67 68 uint32_t context_id; 68 69 69 70 /** 71 * vaCreateBuffer function pointer from the VA-API library 72 * 73 * - encoding: unused 74 * - decoding: Set by user 75 */ 76 VAStatus (*va_create_buffer_function)( 77 VADisplay, 78 VAContextID, 79 VABufferType, 80 unsigned int, 81 unsigned int, 82 void *, 83 VABufferID * 84 ); 85 86 /** 87 * vaDestroyBuffer function pointer from the VA-API library 88 * 89 * - encoding: unused 90 * - decoding: Set by user 91 */ 92 VAStatus (*va_destroy_buffer_function)( 93 VADisplay, 94 VABufferID 95 ); 96 97 /** 98 * vaMapBuffer function pointer from the VA-API library 99 * 100 * - encoding: unused 101 * - decoding: Set by user 102 */ 103 VAStatus (*va_map_buffer_function)( 104 VADisplay, 105 VABufferID, 106 void ** 107 ); 108 109 /** 110 * vaUnmapBuffer function pointer from the VA-API library 111 * 112 * - encoding: unused 113 * - decoding: Set by user 114 */ 115 VAStatus (*va_unmap_buffer_function)( 116 VADisplay, 117 VABufferID 118 ); 119 120 /** 121 * vaBeginPicture function pointer from the VA-API library 122 * 123 * - encoding: unused 124 * - decoding: Set by user 125 */ 126 VAStatus (*va_begin_picture_function)( 127 VADisplay, 128 VAContextID, 129 VASurfaceID 130 ); 131 132 /** 133 * vaRenderPicture function pointer from the VA-API library 134 * 135 * - encoding: unused 136 * - decoding: Set by user 137 */ 138 VAStatus (*va_render_picture_function)( 139 VADisplay, 140 VAContextID, 141 VABufferID *, 142 int 143 ); 144 145 /** 146 * vaEndPicture function pointer from the VA-API library 147 * 148 * - encoding: unused 149 * - decoding: Set by user 150 */ 151 VAStatus (*va_end_picture_function)( 152 VADisplay, 153 VAContextID 154 ); 155 156 /** 70 157 * VAPictureParameterBuffer ID 71 158 * 72 159 * - encoding: unused
