| 1107 | } |
| 1108 | |
| 1109 | static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, |
| 1110 | const AVFrame *src, int flags) |
| 1111 | { |
| 1112 | #if VA_CHECK_VERSION(1, 1, 0) |
| 1113 | VAAPIFramesContext *src_vafc = src_fc->hwctx; |
| 1114 | int use_prime2; |
| 1115 | #else |
| 1116 | int k; |
| 1117 | #endif |
| 1118 | AVHWFramesContext *dst_fc = |
| 1119 | (AVHWFramesContext*)dst->hw_frames_ctx->data; |
| 1120 | AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx; |
| 1121 | const AVDRMFrameDescriptor *desc; |
| 1122 | const VAAPIFormatDescriptor *format_desc; |
| 1123 | VASurfaceID surface_id; |
| 1124 | VAStatus vas = VA_STATUS_SUCCESS; |
| 1125 | uint32_t va_fourcc; |
| 1126 | int err, i, j; |
| 1127 | |
| 1128 | #if !VA_CHECK_VERSION(1, 1, 0) |
| 1129 | unsigned long buffer_handle; |
| 1130 | VASurfaceAttribExternalBuffers buffer_desc; |
| 1131 | VASurfaceAttrib attrs[2] = { |
| 1132 | { |
| 1133 | .type = VASurfaceAttribMemoryType, |
| 1134 | .flags = VA_SURFACE_ATTRIB_SETTABLE, |
| 1135 | .value.type = VAGenericValueTypeInteger, |
| 1136 | .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, |
| 1137 | }, |
| 1138 | { |
| 1139 | .type = VASurfaceAttribExternalBufferDescriptor, |
| 1140 | .flags = VA_SURFACE_ATTRIB_SETTABLE, |
| 1141 | .value.type = VAGenericValueTypePointer, |
| 1142 | .value.value.p = &buffer_desc, |
| 1143 | } |
| 1144 | }; |
| 1145 | #endif |
| 1146 | |
| 1147 | desc = (AVDRMFrameDescriptor*)src->data[0]; |
| 1148 | |
| 1149 | if (desc->nb_objects != 1) { |
| 1150 | av_log(dst_fc, AV_LOG_ERROR, "VAAPI can only map frames " |
| 1151 | "made from a single DRM object.\n"); |
| 1152 | return AVERROR(EINVAL); |
| 1153 | } |
| 1154 | |
| 1155 | va_fourcc = 0; |
| 1156 | for (i = 0; i < FF_ARRAY_ELEMS(vaapi_drm_format_map); i++) { |
| 1157 | if (desc->nb_layers != vaapi_drm_format_map[i].nb_layer_formats) |
| 1158 | continue; |
| 1159 | for (j = 0; j < desc->nb_layers; j++) { |
| 1160 | if (desc->layers[j].format != |
| 1161 | vaapi_drm_format_map[i].layer_formats[j]) |
| 1162 | break; |
| 1163 | } |
| 1164 | if (j != desc->nb_layers) |
| 1165 | continue; |
| 1166 | va_fourcc = vaapi_drm_format_map[i].va_fourcc; |
no test coverage detected