• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/common/libva


Commit MetaInfo

Revisión5f4d73d1656f5d38b8ece20bb65055d0cf74f401 (tree)
Tiempo2009-11-18 12:51:11
AutorGwenole Beauchesne <gbeauchesne@spli...>
CommiterXiang, Haihao

Log Message

cleanup vaCreateImage, make it possible to add formats later

Cambiar Resumen

Diferencia incremental

--- a/i965_drv_video/i965_drv_video.c
+++ b/i965_drv_video/i965_drv_video.c
@@ -410,11 +410,10 @@ i965_CreateSubpicture(VADriverContextP ctx,
410410 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
411411 }
412412 *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;
418417 return vaStatus;
419418 }
420419
@@ -1119,44 +1118,81 @@ i965_destroy_heap(struct object_heap *heap,
11191118 }
11201119
11211120
1121+VAStatus
1122+i965_DestroyImage(VADriverContextP ctx, VAImageID image);
11221123
11231124 VAStatus
11241125 i965_CreateImage(VADriverContextP ctx,
11251126 VAImageFormat *format,
11261127 int width,
11271128 int height,
1128- VAImage *image) /* out */
1129+ VAImage *out_image) /* out */
11291130 {
11301131 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;
11361136
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;
11391139
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;
11591191 return VA_STATUS_SUCCESS;
1192+
1193+ error:
1194+ i965_DestroyImage(ctx, image_id);
1195+ return va_status;
11601196 }
11611197
11621198 VAStatus i965_DeriveImage(VADriverContextP ctx,
@@ -1179,9 +1215,9 @@ i965_DestroyImage(VADriverContextP ctx, VAImageID image)
11791215 struct i965_driver_data *i965 = i965_driver_data(ctx);
11801216 struct object_image *obj_image = IMAGE(image);
11811217
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;
11851221 }
11861222
11871223 i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image);
--- a/i965_drv_video/i965_drv_video.h
+++ b/i965_drv_video/i965_drv_video.h
@@ -106,13 +106,11 @@ struct object_buffer
106106 int size_element;
107107 VABufferType type;
108108 };
109+
109110 struct object_image
110111 {
111112 struct object_base base;
112- VABufferID buf;
113- int width;
114- int height;
115- int size;
113+ VAImage image;
116114 dri_bo *bo;
117115 };
118116
--- a/i965_drv_video/i965_render.c
+++ b/i965_drv_video/i965_render.c
@@ -677,8 +677,8 @@ i965_subpic_render_src_surfaces_state(VADriverContextP ctx,
677677 region = obj_surface->bo;
678678 subpic_region = obj_image->bo;
679679 /*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);
682682 }
683683
684684 static void