diff options
author | Marek Olšák <[email protected]> | 2019-02-27 17:19:54 -0500 |
---|---|---|
committer | Leo Liu <[email protected]> | 2019-03-15 11:53:08 -0400 |
commit | 323e7be91cbed72a0978f5b784879b17155448ee (patch) | |
tree | d3275c1e88117cffaef7d445d950375e803298b5 /src/gallium/state_trackers/omx | |
parent | b9e02fe138ef181f02fd739129517fbe70604af6 (diff) |
omx: clean up enc_LoadImage_common
- add *pipe
- add documentation
Acked-by: Leo Liu <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/omx')
-rw-r--r-- | src/gallium/state_trackers/omx/vid_enc_common.c | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/src/gallium/state_trackers/omx/vid_enc_common.c b/src/gallium/state_trackers/omx/vid_enc_common.c index 2aa739da22a..4d3f48671f9 100644 --- a/src/gallium/state_trackers/omx/vid_enc_common.c +++ b/src/gallium/state_trackers/omx/vid_enc_common.c @@ -310,6 +310,7 @@ OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEF OMX_BUFFERHEADERTYPE *buf, struct pipe_video_buffer *vbuf) { + struct pipe_context *pipe = priv->s_pipe; struct pipe_box box = {}; struct input_buf_private *inp = buf->pInputPortPrivate; @@ -325,30 +326,49 @@ OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEF box.width = def->nFrameWidth; box.height = def->nFrameHeight; box.depth = 1; - priv->s_pipe->texture_subdata(priv->s_pipe, views[0]->texture, 0, - PIPE_TRANSFER_WRITE, &box, - ptr, def->nStride, 0); + pipe->texture_subdata(pipe, views[0]->texture, 0, + PIPE_TRANSFER_WRITE, &box, + ptr, def->nStride, 0); ptr = ((uint8_t*)buf->pBuffer) + (def->nStride * box.height); box.width = def->nFrameWidth / 2; box.height = def->nFrameHeight / 2; box.depth = 1; - priv->s_pipe->texture_subdata(priv->s_pipe, views[1]->texture, 0, - PIPE_TRANSFER_WRITE, &box, - ptr, def->nStride, 0); + pipe->texture_subdata(pipe, views[1]->texture, 0, + PIPE_TRANSFER_WRITE, &box, + ptr, def->nStride, 0); } else { struct pipe_blit_info blit; struct vl_video_buffer *dst_buf = (struct vl_video_buffer *)vbuf; - pipe_transfer_unmap(priv->s_pipe, inp->transfer); + pipe_transfer_unmap(pipe, inp->transfer); + + /* inp->resource uses PIPE_FORMAT_I8 and the layout looks like this: + * + * def->nFrameWidth = 4, def->nFrameHeight = 4: + * |----| + * |YYYY| + * |YYYY| + * |YYYY| + * |YYYY| + * |UVUV| + * |UVUV| + * |----| + * + * The copy has 2 steps: + * - Copy Y to dst_buf->resources[0] as R8. + * - Copy UV to dst_buf->resources[1] as R8G8. + */ box.width = def->nFrameWidth; box.height = def->nFrameHeight; box.depth = 1; - priv->s_pipe->resource_copy_region(priv->s_pipe, - dst_buf->resources[0], - 0, 0, 0, 0, inp->resource, 0, &box); + /* Copy Y */ + pipe->resource_copy_region(pipe, + dst_buf->resources[0], + 0, 0, 0, 0, inp->resource, 0, &box); + /* Copy U */ memset(&blit, 0, sizeof(blit)); blit.src.resource = inp->resource; blit.src.format = inp->resource->format; @@ -368,19 +388,20 @@ OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEF blit.filter = PIPE_TEX_FILTER_NEAREST; blit.mask = PIPE_MASK_R; - priv->s_pipe->blit(priv->s_pipe, &blit); + pipe->blit(pipe, &blit); + /* Copy V */ blit.src.box.x = 0; blit.mask = PIPE_MASK_G; - priv->s_pipe->blit(priv->s_pipe, &blit); - priv->s_pipe->flush(priv->s_pipe, NULL, 0); + pipe->blit(pipe, &blit); + pipe->flush(pipe, NULL, 0); box.width = inp->resource->width0; box.height = inp->resource->height0; box.depth = inp->resource->depth0; - buf->pBuffer = priv->s_pipe->transfer_map(priv->s_pipe, inp->resource, 0, - PIPE_TRANSFER_WRITE, &box, - &inp->transfer); + buf->pBuffer = pipe->transfer_map(pipe, inp->resource, 0, + PIPE_TRANSFER_WRITE, &box, + &inp->transfer); } return OMX_ErrorNone; |