hardware/intel/common/libva
Revisión | 5f4d73d1656f5d38b8ece20bb65055d0cf74f401 (tree) |
---|---|
Tiempo | 2009-11-18 12:51:11 |
Autor | Gwenole Beauchesne <gbeauchesne@spli...> |
Commiter | Xiang, Haihao |
cleanup vaCreateImage, make it possible to add formats later
@@ -410,11 +410,10 @@ i965_CreateSubpicture(VADriverContextP ctx, | ||
410 | 410 | vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; |
411 | 411 | } |
412 | 412 | *subpicture = subpicID; |
413 | - obj_subpic->image = image; | |
414 | - obj_subpic->width = obj_image->width; | |
415 | - obj_subpic->height = obj_image->height; | |
416 | - obj_subpic->bo = obj_image->bo; | |
417 | - | |
413 | + obj_subpic->image = image; | |
414 | + obj_subpic->width = obj_image->image.width; | |
415 | + obj_subpic->height = obj_image->image.height; | |
416 | + obj_subpic->bo = obj_image->bo; | |
418 | 417 | return vaStatus; |
419 | 418 | } |
420 | 419 |
@@ -1119,44 +1118,81 @@ i965_destroy_heap(struct object_heap *heap, | ||
1119 | 1118 | } |
1120 | 1119 | |
1121 | 1120 | |
1121 | +VAStatus | |
1122 | +i965_DestroyImage(VADriverContextP ctx, VAImageID image); | |
1122 | 1123 | |
1123 | 1124 | VAStatus |
1124 | 1125 | i965_CreateImage(VADriverContextP ctx, |
1125 | 1126 | VAImageFormat *format, |
1126 | 1127 | int width, |
1127 | 1128 | int height, |
1128 | - VAImage *image) /* out */ | |
1129 | + VAImage *out_image) /* out */ | |
1129 | 1130 | { |
1130 | 1131 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
1131 | - VAStatus va_status; | |
1132 | - /*we will receive the actual subpicture size from the player,now we assume it is 720*32*/ | |
1133 | - char subpic_buf[width*height]; | |
1134 | - int subpic_size = 720*32; | |
1135 | - unsigned int img_buf_id; | |
1132 | + struct object_image *obj_image; | |
1133 | + VAStatus va_status = VA_STATUS_ERROR_OPERATION_FAILED; | |
1134 | + VAImageID image_id; | |
1135 | + unsigned int width2, height2, size2, size; | |
1136 | 1136 | |
1137 | - image->image_id = NEW_IMAGE_ID(); | |
1138 | - struct object_image *obj_image = IMAGE(image->image_id); | |
1137 | + out_image->image_id = VA_INVALID_ID; | |
1138 | + out_image->buf = VA_INVALID_ID; | |
1139 | 1139 | |
1140 | - /*assume we got IA44 in format[0]*/ | |
1141 | - image->format = *format; | |
1142 | - | |
1143 | - /*create empty buffer*/ | |
1144 | - va_status = i965_CreateBuffer(ctx, 0, VAImageBufferType, | |
1145 | - subpic_size, 1, subpic_buf, &img_buf_id); | |
1146 | - assert( VA_STATUS_SUCCESS == va_status ); | |
1147 | - struct object_buffer *obj_buf = BUFFER(img_buf_id); | |
1148 | - | |
1149 | - image->buf = img_buf_id; | |
1150 | - image->width = width; | |
1151 | - image->height = height; | |
1152 | - | |
1153 | - obj_image->buf = img_buf_id; | |
1154 | - obj_image->width = width; | |
1155 | - obj_image->height = height; | |
1156 | - obj_image->size = subpic_size; | |
1157 | - obj_image->bo = obj_buf->buffer_store->bo; | |
1158 | - | |
1140 | + image_id = NEW_IMAGE_ID(); | |
1141 | + if (image_id == VA_INVALID_ID) | |
1142 | + return VA_STATUS_ERROR_ALLOCATION_FAILED; | |
1143 | + | |
1144 | + obj_image = IMAGE(image_id); | |
1145 | + if (!obj_image) | |
1146 | + return VA_STATUS_ERROR_ALLOCATION_FAILED; | |
1147 | + | |
1148 | + VAImage * const image = &obj_image->image; | |
1149 | + image->image_id = image_id; | |
1150 | + image->buf = VA_INVALID_ID; | |
1151 | + | |
1152 | + size = width * height; | |
1153 | + width2 = (width + 1) / 2; | |
1154 | + height2 = (height + 1) / 2; | |
1155 | + size2 = width2 * height2; | |
1156 | + | |
1157 | + image->num_palette_entries = 0; | |
1158 | + image->entry_bytes = 0; | |
1159 | + memset(image->component_order, 0, sizeof(image->component_order)); | |
1160 | + | |
1161 | + switch (format->fourcc) { | |
1162 | + case VA_FOURCC('I','A','4','4'): | |
1163 | + case VA_FOURCC('A','I','4','4'): | |
1164 | + image->num_planes = 1; | |
1165 | + image->pitches[0] = width; | |
1166 | + image->offsets[0] = 0; | |
1167 | + image->data_size = image->offsets[0] + image->pitches[0] * height; | |
1168 | + image->num_palette_entries = 16; | |
1169 | + image->entry_bytes = 3; | |
1170 | + image->component_order[0] = 'R'; | |
1171 | + image->component_order[1] = 'G'; | |
1172 | + image->component_order[2] = 'B'; | |
1173 | + break; | |
1174 | + default: | |
1175 | + goto error; | |
1176 | + } | |
1177 | + | |
1178 | + va_status = i965_CreateBuffer(ctx, 0, VAImageBufferType, | |
1179 | + image->data_size, 1, NULL, &image->buf); | |
1180 | + if (va_status != VA_STATUS_SUCCESS) | |
1181 | + goto error; | |
1182 | + | |
1183 | + obj_image->bo = BUFFER(image->buf)->buffer_store->bo; | |
1184 | + | |
1185 | + image->image_id = image_id; | |
1186 | + image->format = *format; | |
1187 | + image->width = width; | |
1188 | + image->height = height; | |
1189 | + | |
1190 | + *out_image = *image; | |
1159 | 1191 | return VA_STATUS_SUCCESS; |
1192 | + | |
1193 | + error: | |
1194 | + i965_DestroyImage(ctx, image_id); | |
1195 | + return va_status; | |
1160 | 1196 | } |
1161 | 1197 | |
1162 | 1198 | VAStatus i965_DeriveImage(VADriverContextP ctx, |
@@ -1179,9 +1215,9 @@ i965_DestroyImage(VADriverContextP ctx, VAImageID image) | ||
1179 | 1215 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
1180 | 1216 | struct object_image *obj_image = IMAGE(image); |
1181 | 1217 | |
1182 | - if (obj_image && obj_image->buf != VA_INVALID_ID) { | |
1183 | - i965_DestroyBuffer(ctx, obj_image->buf); | |
1184 | - obj_image->buf = VA_INVALID_ID; | |
1218 | + if (obj_image && obj_image->image.buf != VA_INVALID_ID) { | |
1219 | + i965_DestroyBuffer(ctx, obj_image->image.buf); | |
1220 | + obj_image->image.buf = VA_INVALID_ID; | |
1185 | 1221 | } |
1186 | 1222 | |
1187 | 1223 | i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image); |
@@ -106,13 +106,11 @@ struct object_buffer | ||
106 | 106 | int size_element; |
107 | 107 | VABufferType type; |
108 | 108 | }; |
109 | + | |
109 | 110 | struct object_image |
110 | 111 | { |
111 | 112 | struct object_base base; |
112 | - VABufferID buf; | |
113 | - int width; | |
114 | - int height; | |
115 | - int size; | |
113 | + VAImage image; | |
116 | 114 | dri_bo *bo; |
117 | 115 | }; |
118 | 116 |
@@ -677,8 +677,8 @@ i965_subpic_render_src_surfaces_state(VADriverContextP ctx, | ||
677 | 677 | region = obj_surface->bo; |
678 | 678 | subpic_region = obj_image->bo; |
679 | 679 | /*subpicture surface*/ |
680 | - i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_image->width, obj_image->height); | |
681 | - i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_image->width, obj_image->height); | |
680 | + i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_image->image.width, obj_image->image.height); | |
681 | + i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_image->image.width, obj_image->image.height); | |
682 | 682 | } |
683 | 683 | |
684 | 684 | static void |