[Mesa-dev] [PATCH 2/3] omx: clean up enc_LoadImage_common
Marek Olšák
maraeo at gmail.com
Wed Feb 27 22:19:54 UTC 2019
From: Marek Olšák <marek.olsak at amd.com>
- add *pipe
- add documentation
---
.../state_trackers/omx/vid_enc_common.c | 53 +++++++++++++------
1 file 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
@@ -303,85 +303,106 @@ void enc_ControlPicture_common(vid_enc_PrivateType * priv, struct pipe_h264_enc_
picture->ref_idx_l0 = priv->ref_idx_l0;
picture->ref_idx_l1 = priv->ref_idx_l1;
picture->enable_vui = (picture->rate_ctrl.frame_rate_num != 0);
enc_GetPictureParamPreset(picture);
}
OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEFINITIONTYPE *def,
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;
if (!inp->resource) {
struct pipe_sampler_view **views;
void *ptr;
views = vbuf->get_sampler_view_planes(vbuf);
if (!views)
return OMX_ErrorInsufficientResources;
ptr = buf->pBuffer;
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;
blit.src.box.x = -1;
blit.src.box.y = def->nFrameHeight;
blit.src.box.width = def->nFrameWidth;
blit.src.box.height = def->nFrameHeight / 2 ;
blit.src.box.depth = 1;
blit.dst.resource = dst_buf->resources[1];
blit.dst.format = blit.dst.resource->format;
blit.dst.box.width = def->nFrameWidth / 2;
blit.dst.box.height = def->nFrameHeight / 2;
blit.dst.box.depth = 1;
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;
}
--
2.17.1
More information about the mesa-dev
mailing list