• 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/libva


Commit MetaInfo

Revisão558b07976c56ad73f3d6fb87aa925016edf4fa2b (tree)
Hora2010-07-13 16:29:16
AutorGwenole Beauchesne <gbeauchesne@spli...>
CommiterXiang, Haihao

Mensagem de Log

Simplify vaGetImage().

Mudança Sumário

Diff

--- a/i965_drv_video/i965_drv_video.c
+++ b/i965_drv_video/i965_drv_video.c
@@ -1469,13 +1469,26 @@ i965_SetImagePalette(VADriverContextP ctx,
14691469 return VA_STATUS_SUCCESS;
14701470 }
14711471
1472+static inline void
1473+memcpy_pic(uint8_t *dst, unsigned int dst_stride,
1474+ const uint8_t *src, unsigned int src_stride,
1475+ unsigned int len, unsigned int height)
1476+{
1477+ unsigned int i;
1478+
1479+ for (i = 0; i < height; i++) {
1480+ memcpy(dst, src, len);
1481+ dst += dst_stride;
1482+ src += src_stride;
1483+ }
1484+}
1485+
14721486 static void
1473-get_image_yv12(struct object_image *obj_image, uint8_t *image_data,
1487+get_image_i420(struct object_image *obj_image, uint8_t *image_data,
14741488 struct object_surface *obj_surface,
14751489 const VARectangle *rect)
14761490 {
14771491 uint8_t *dst[3], *src[3];
1478- int i, x, y, w, h;
14791492
14801493 if (!obj_surface->bo)
14811494 return;
@@ -1485,11 +1498,8 @@ get_image_yv12(struct object_image *obj_image, uint8_t *image_data,
14851498 if (!obj_surface->bo->virtual)
14861499 return;
14871500
1488- x = rect->x;
1489- y = rect->y;
1490- w = rect->width;
1491- h = rect->height;
1492-
1501+ /* Dest VA image has either I420 or YV12 format.
1502+ Source VA surface alway has I420 format */
14931503 dst[0] = image_data + obj_image->image.offsets[0];
14941504 src[0] = (uint8_t *)obj_surface->bo->virtual;
14951505 dst[1] = image_data + obj_image->image.offsets[1];
@@ -1497,34 +1507,26 @@ get_image_yv12(struct object_image *obj_image, uint8_t *image_data,
14971507 dst[2] = image_data + obj_image->image.offsets[2];
14981508 src[2] = src[1] + (obj_surface->width / 2) * (obj_surface->height / 2);
14991509
1500- dst[0] += y * obj_image->image.pitches[0] + x;
1501- src[0] += y * obj_surface->width + x;
1502- for (i = 0; i < h; i++) {
1503- memcpy(dst[0], src[0], w);
1504- dst[0] += obj_image->image.pitches[0];
1505- src[0] += obj_surface->width;
1506- }
1507-
1508- x /= 2;
1509- y /= 2;
1510- w /= 2;
1511- h /= 2;
1512-
1513- dst[1] += y * obj_image->image.pitches[1] + x;
1514- src[1] += y * obj_surface->width / 2 + x;
1515- for (i = 0; i < h; i++) {
1516- memcpy(dst[1], src[1], w);
1517- dst[1] += obj_image->image.pitches[1];
1518- src[1] += obj_surface->width / 2;
1519- }
1520-
1521- dst[2] += y * obj_image->image.pitches[2] + y;
1522- src[2] += y * obj_surface->width / 2 + x;
1523- for (i = 0; i < h; i++) {
1524- memcpy(dst[2], src[2], w);
1525- dst[2] += obj_image->image.pitches[2];
1526- src[2] += obj_surface->width / 2;
1527- }
1510+ /* Y plane */
1511+ dst[0] += rect->y * obj_image->image.pitches[0] + rect->x;
1512+ src[0] += rect->y * obj_surface->width + rect->x;
1513+ memcpy_pic(dst[0], obj_image->image.pitches[0],
1514+ src[0], obj_surface->width,
1515+ rect->width, rect->height);
1516+
1517+ /* U plane */
1518+ dst[1] += (rect->y / 2) * obj_image->image.pitches[1] + rect->x / 2;
1519+ src[1] += (rect->y / 2) * obj_surface->width / 2 + rect->x / 2;
1520+ memcpy_pic(dst[1], obj_image->image.pitches[1],
1521+ src[1], obj_surface->width / 2,
1522+ rect->width / 2, rect->height / 2);
1523+
1524+ /* V plane */
1525+ dst[2] += (rect->y / 2) * obj_image->image.pitches[2] + rect->x / 2;
1526+ src[2] += (rect->y / 2) * obj_surface->width / 2 + rect->x / 2;
1527+ memcpy_pic(dst[2], obj_image->image.pitches[2],
1528+ src[2], obj_surface->width / 2,
1529+ rect->width / 2, rect->height / 2);
15281530
15291531 dri_bo_unmap(obj_surface->bo);
15301532 }
@@ -1534,8 +1536,7 @@ get_image_nv12(struct object_image *obj_image, uint8_t *image_data,
15341536 struct object_surface *obj_surface,
15351537 const VARectangle *rect)
15361538 {
1537- uint8_t *dst, *src;
1538- int i, x, y, w, h;
1539+ uint8_t *dst[2], *src[2];
15391540
15401541 if (!obj_surface->bo)
15411542 return;
@@ -1545,30 +1546,25 @@ get_image_nv12(struct object_image *obj_image, uint8_t *image_data,
15451546 if (!obj_surface->bo->virtual)
15461547 return;
15471548
1548- x = rect->x;
1549- y = rect->y;
1550- w = rect->width;
1551- h = rect->height;
1552-
1553- dst = image_data + obj_image->image.offsets[0] + y * obj_image->image.pitches[0] + x;
1554- src = (uint8_t *)obj_surface->bo->virtual + y * obj_surface->width + x;
1555- for (i = 0; i < h; i++) {
1556- memcpy(dst, src, w);
1557- dst += obj_image->image.pitches[0];
1558- src += obj_surface->width;
1559- }
1549+ /* Both dest VA image and source surface have NV12 format */
1550+ dst[0] = image_data + obj_image->image.offsets[0];
1551+ src[0] = (uint8_t *)obj_surface->bo->virtual;
1552+ dst[1] = image_data + obj_image->image.offsets[1];
1553+ src[1] = src[0] + obj_surface->width * obj_surface->height;
15601554
1561- x /= 2;
1562- y /= 2;
1563- h /= 2;
1555+ /* Y plane */
1556+ dst[0] += rect->y * obj_image->image.pitches[0] + rect->x;
1557+ src[0] += rect->y * obj_surface->width + rect->x;
1558+ memcpy_pic(dst[0], obj_image->image.pitches[0],
1559+ src[0], obj_surface->width,
1560+ rect->width, rect->height);
15641561
1565- dst = image_data + obj_image->image.offsets[1] + y * obj_image->image.pitches[1] + x * 2;
1566- src = (uint8_t *)obj_surface->bo->virtual + obj_surface->width * obj_surface->height + y * obj_surface->width + x * 2;
1567- for (i = 0; i < h; i++) {
1568- memcpy(dst, src, w);
1569- dst += obj_image->image.pitches[1];
1570- src += obj_surface->width;
1571- }
1562+ /* UV plane */
1563+ dst[1] += (rect->y / 2) * obj_image->image.pitches[1] + (rect->x & -2);
1564+ src[1] += (rect->y / 2) * obj_surface->width + (rect->x & -2);
1565+ memcpy_pic(dst[1], obj_image->image.pitches[1],
1566+ src[1], obj_surface->width,
1567+ rect->width, rect->height / 2);
15721568
15731569 dri_bo_unmap(obj_surface->bo);
15741570 }
@@ -1624,7 +1620,7 @@ i965_GetImage(VADriverContextP ctx,
16241620 /* I420 is native format for MPEG-2 decoded surfaces */
16251621 if (render_state->interleaved_uv)
16261622 goto operation_failed;
1627- get_image_yv12(obj_image, image_data, obj_surface, &rect);
1623+ get_image_i420(obj_image, image_data, obj_surface, &rect);
16281624 break;
16291625 case VA_FOURCC('N','V','1','2'):
16301626 /* NV12 is native format for H.264 decoded surfaces */