diff options
author | Christian König <christian.koenig@amd.com> | 2014-02-07 11:16:36 -0700 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2014-02-09 18:17:56 +0100 |
commit | 85b8331e53beb7d2e556d5c51bed2d52448190a4 (patch) | |
tree | 36a47f5c3bdb46a786d681029943a98189613382 | |
parent | 6337dac8e162014c6ef5bec2b82b6060cbff7877 (diff) |
st/omx/enc: user separate pipe object for scale and transfer
Signed-off-by: Christian König <christian.koenig@amd.com>
-rw-r--r-- | src/gallium/state_trackers/omx/vid_enc.c | 53 | ||||
-rw-r--r-- | src/gallium/state_trackers/omx/vid_enc.h | 3 |
2 files changed, 32 insertions, 24 deletions
diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c index 7066b852d4..ec947717af 100644 --- a/src/gallium/state_trackers/omx/vid_enc.c +++ b/src/gallium/state_trackers/omx/vid_enc.c @@ -179,14 +179,18 @@ static OMX_ERRORTYPE vid_enc_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam return OMX_ErrorInsufficientResources; screen = priv->screen->pscreen; - priv->pipe = screen->context_create(screen, priv->screen); - if (!priv->pipe) + priv->s_pipe = screen->context_create(screen, priv->screen); + if (!priv->s_pipe) return OMX_ErrorInsufficientResources; - if (!vl_compositor_init(&priv->compositor, priv->pipe)) + priv->t_pipe = screen->context_create(screen, priv->screen); + if (!priv->t_pipe) return OMX_ErrorInsufficientResources; - if (!vl_compositor_init_state(&priv->cstate, priv->pipe)) + if (!vl_compositor_init(&priv->compositor, priv->s_pipe)) + return OMX_ErrorInsufficientResources; + + if (!vl_compositor_init_state(&priv->cstate, priv->s_pipe)) return OMX_ErrorInsufficientResources; priv->sPortTypesParam[OMX_PortDomainVideo].nStartPortNumber = 0; @@ -262,8 +266,11 @@ static OMX_ERRORTYPE vid_enc_Destructor(OMX_COMPONENTTYPE *comp) if (priv->scale_buffer) priv->scale_buffer->destroy(priv->scale_buffer); - if (priv->pipe) - priv->pipe->destroy(priv->pipe); + if (priv->s_pipe) + priv->s_pipe->destroy(priv->s_pipe); + + if (priv->t_pipe) + priv->t_pipe->destroy(priv->t_pipe); if (priv->screen) omx_put_screen(); @@ -470,7 +477,7 @@ static OMX_ERRORTYPE vid_enc_SetConfig(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, templat.width = priv->scale.xWidth; templat.height = priv->scale.xHeight; templat.interlaced = false; - priv->scale_buffer = priv->pipe->create_video_buffer(priv->pipe, &templat); + priv->scale_buffer = priv->s_pipe->create_video_buffer(priv->s_pipe, &templat); if (!priv->scale_buffer) return OMX_ErrorInsufficientResources; } @@ -532,7 +539,7 @@ static OMX_ERRORTYPE vid_enc_MessageHandler(OMX_COMPONENTTYPE* comp, internalReq templat.height = priv->scale_buffer ? priv->scale.xHeight : port->sPortParam.format.video.nFrameHeight; templat.max_references = 1; - priv->codec = priv->pipe->create_video_codec(priv->pipe, &templat); + priv->codec = priv->s_pipe->create_video_codec(priv->s_pipe, &templat); } else if ((msg->messageParam == OMX_StateLoaded) && (priv->state == OMX_StateIdle)) { if (priv->codec) { @@ -571,7 +578,7 @@ static OMX_ERRORTYPE vid_enc_AllocateInBuffer(omx_base_PortType *port, OMX_INOUT templat.height = def->nFrameHeight; templat.interlaced = false; - inp->buf = priv->pipe->create_video_buffer(priv->pipe, &templat); + inp->buf = priv->s_pipe->create_video_buffer(priv->s_pipe, &templat); if (!inp->buf) { FREE(inp); base_port_FreeBuffer(port, idx, *buf); @@ -607,7 +614,7 @@ static OMX_ERRORTYPE vid_enc_UseInBuffer(omx_base_PortType *port, OMX_BUFFERHEAD templat.height = def->nFrameHeight; templat.interlaced = false; - inp->buf = priv->pipe->create_video_buffer(priv->pipe, &templat); + inp->buf = priv->s_pipe->create_video_buffer(priv->s_pipe, &templat); if (!inp->buf) { FREE(inp); base_port_FreeBuffer(port, idx, *buf); @@ -650,7 +657,7 @@ static OMX_ERRORTYPE vid_enc_FreeOutBuffer(omx_base_PortType *port, OMX_U32 idx, if (buf->pOutputPortPrivate) { struct output_buf_private *outp = buf->pOutputPortPrivate; if (outp->transfer) - pipe_transfer_unmap(priv->pipe, outp->transfer); + pipe_transfer_unmap(priv->t_pipe, outp->transfer); pipe_resource_reference(&outp->bitstream, NULL); FREE(outp); buf->pOutputPortPrivate = NULL; @@ -696,9 +703,9 @@ static OMX_ERRORTYPE vid_enc_EncodeFrame(omx_base_PortType *port, OMX_BUFFERHEAD box.height = def->nFrameHeight; box.depth = 1; - priv->pipe->transfer_inline_write(priv->pipe, views[0]->texture, 0, - PIPE_TRANSFER_WRITE, &box, - ptr, def->nStride, 0); + priv->s_pipe->transfer_inline_write(priv->s_pipe, views[0]->texture, 0, + PIPE_TRANSFER_WRITE, &box, + ptr, def->nStride, 0); ptr = ((uint8_t*)buf->pBuffer) + (def->nStride * box.height); @@ -707,9 +714,9 @@ static OMX_ERRORTYPE vid_enc_EncodeFrame(omx_base_PortType *port, OMX_BUFFERHEAD box.height = def->nFrameHeight / 2; box.depth = 1; - priv->pipe->transfer_inline_write(priv->pipe, views[1]->texture, 0, - PIPE_TRANSFER_WRITE, &box, - ptr, def->nStride, 0); + priv->s_pipe->transfer_inline_write(priv->s_pipe, views[1]->texture, 0, + PIPE_TRANSFER_WRITE, &box, + ptr, def->nStride, 0); } /* -------------- scale input image --------- */ @@ -730,7 +737,7 @@ static OMX_ERRORTYPE vid_enc_EncodeFrame(omx_base_PortType *port, OMX_BUFFERHEAD vl_compositor_set_rgba_layer(s, compositor, 0, views[i], NULL, NULL, NULL); vl_compositor_render(s, compositor, dst_surface[i], NULL, false); } - priv->pipe->flush(priv->pipe, NULL, 0); + priv->s_pipe->flush(priv->s_pipe, NULL, 0); size = priv->scale.xWidth * priv->scale.xHeight * 2; vbuf = priv->scale_buffer; @@ -738,7 +745,7 @@ static OMX_ERRORTYPE vid_enc_EncodeFrame(omx_base_PortType *port, OMX_BUFFERHEAD /* -------------- allocate output buffer --------- */ - inp->bitstream = pipe_buffer_create(priv->pipe->screen, PIPE_BIND_VERTEX_BUFFER, + inp->bitstream = pipe_buffer_create(priv->s_pipe->screen, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM, size); /* -------------- decode frame --------- */ @@ -824,7 +831,7 @@ static void vid_enc_BufferEncoded(OMX_COMPONENTTYPE *comp, OMX_BUFFERHEADERTYPE* /* ------------- map result buffer ----------------- */ if (outp->transfer) - pipe_transfer_unmap(priv->pipe, outp->transfer); + pipe_transfer_unmap(priv->t_pipe, outp->transfer); pipe_resource_reference(&outp->bitstream, inp->bitstream); @@ -832,9 +839,9 @@ static void vid_enc_BufferEncoded(OMX_COMPONENTTYPE *comp, OMX_BUFFERHEADERTYPE* box.height = inp->bitstream->height0; box.depth = inp->bitstream->depth0; - output->pBuffer = priv->pipe->transfer_map(priv->pipe, outp->bitstream, 0, - PIPE_TRANSFER_READ_WRITE, - &box, &outp->transfer); + output->pBuffer = priv->t_pipe->transfer_map(priv->t_pipe, outp->bitstream, 0, + PIPE_TRANSFER_READ_WRITE, + &box, &outp->transfer); /* ------------- get size of result ----------------- */ diff --git a/src/gallium/state_trackers/omx/vid_enc.h b/src/gallium/state_trackers/omx/vid_enc.h index c8217f34a8..431ca91d4d 100644 --- a/src/gallium/state_trackers/omx/vid_enc.h +++ b/src/gallium/state_trackers/omx/vid_enc.h @@ -62,7 +62,8 @@ DERIVEDCLASS(vid_enc_PrivateType, omx_base_filter_PrivateType) #define vid_enc_PrivateType_FIELDS omx_base_filter_PrivateType_FIELDS \ struct vl_screen *screen; \ - struct pipe_context *pipe; \ + struct pipe_context *s_pipe; \ + struct pipe_context *t_pipe; \ struct pipe_video_codec *codec; \ OMX_U32 frame_rate; \ OMX_U32 frame_num; \ |