# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
+inc_st_omx = [inc_common]
+dep_st_omx = [dep_omx, dep_x11_xcb, dep_xcb, dep_xcb_dri2, dep_xcb_dri3]
+
files_omx = files(
'vid_dec_common.c',
'vid_dec_h264_common.c',
'tizonia/h264einport.c',
'tizonia/h264eoutport.c'
)
+inc_st_omx = [
+ inc_st_omx,
+ inc_dri_common,
+ include_directories('../../state_trackers/dri'),
+ include_directories('../../../egl/drivers/dri2'),
+ include_directories('../../../egl/main'),
+ include_directories('../../../gbm/backends/dri'),
+ include_directories('../../../gbm/main'),
+ include_directories('../../../loader')
+]
+dep_st_omx = [dep_st_omx, dep_omx_other, dep_libdrm]
endif
libomx_st = static_library(
'omx_st',
files_omx,
c_args : [c_vis_args],
- include_directories : [inc_common],
- dependencies : [dep_omx, dep_omx_other, dep_x11_xcb, dep_xcb, dep_xcb_dri2, dep_xcb_dri3],
+ include_directories : inc_st_omx,
+ dependencies : dep_st_omx,
)
#include "h264eoutport.h"
#include "names.h"
+#include "util/u_debug.h"
+
+DEBUG_GET_ONCE_BOOL_OPTION(mesa_enable_omx_eglimage,
+ "MESA_ENABLE_OMX_EGLIMAGE",
+ false)
+
+static OMX_BOOL egl_image_validation_hook(const OMX_HANDLETYPE ap_hdl,
+ OMX_U32 pid, OMX_PTR ap_eglimage,
+ void *ap_args)
+{
+ const void * p_krn = NULL;
+ const tiz_port_t * p_port = NULL;
+
+ assert(ap_hdl);
+ assert(ap_eglimage);
+ assert(!ap_args);
+
+ if (!debug_get_option_mesa_enable_omx_eglimage()) {
+ return OMX_FALSE;
+ }
+
+ p_krn = tiz_get_krn(ap_hdl);
+ p_port = tiz_krn_get_port(p_krn, pid);
+
+ const OMX_VIDEO_PORTDEFINITIONTYPE * p_video_portdef
+ = &(p_port->portdef_.format.video);
+
+ if (!p_video_portdef->pNativeWindow) {
+ return OMX_FALSE;
+ }
+
+ return OMX_TRUE;
+}
+
OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE ap_hdl)
{
tiz_role_factory_t h264d_role;
&h264eprc_type,
&h264e_inport_type,
&h264e_outport_type};
+ const tiz_eglimage_hook_t egl_validation_hook = {
+ OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX,
+ egl_image_validation_hook,
+ NULL
+ };
/* Settings for roles */
strcpy ((OMX_STRING) h264d_role.role, OMX_VID_DEC_AVC_ROLE);
/* Register the component roles */
tiz_comp_register_roles (ap_hdl, rf_list, 2);
+ /* Register egl image validation hook for the decoder */
+ tiz_check_omx (tiz_comp_register_role_eglimage_hook
+ (ap_hdl, (const OMX_U8 *) OMX_VID_DEC_AVC_ROLE,
+ &egl_validation_hook));
+
return OMX_ErrorNone;
}
#include "vl/vl_video_buffer.h"
#include "vl/vl_compositor.h"
+#include "util/u_hash_table.h"
#include "util/u_surface.h"
+#include "dri_screen.h"
+#include "egl_dri2.h"
+
unsigned dec_frame_delta;
+#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
+
+static unsigned handle_hash(void *key)
+{
+ return PTR_TO_UINT(key);
+}
+
+static int handle_compare(void *key1, void *key2)
+{
+ return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
+}
+
+static enum pipe_error hash_table_clear_item_callback(void *key, void *value, void *data)
+{
+ struct pipe_video_buffer *video_buffer = (struct pipe_video_buffer *)value;
+ video_buffer->destroy(video_buffer);
+ return PIPE_OK;
+}
+
static void release_input_headers(vid_dec_PrivateType* priv) {
int i;
for (i = 0; i < priv->num_in_buffers; i++) {
return priv->p_inhdr_;
}
+static struct pipe_resource * st_omx_pipe_texture_from_eglimage(EGLDisplay egldisplay,
+ EGLImage eglimage)
+{
+ _EGLDisplay *disp = egldisplay;
+ struct dri2_egl_display *dri2_egl_dpy = disp->DriverData;
+ __DRIscreen *_dri_screen = dri2_egl_dpy->dri_screen;
+ struct dri_screen *st_dri_screen = dri_screen(_dri_screen);
+ __DRIimage *_dri_image = st_dri_screen->lookup_egl_image(st_dri_screen, eglimage);
+
+ return _dri_image->texture;
+}
+
+static void get_eglimage(vid_dec_PrivateType* priv) {
+ OMX_PTR p_eglimage = NULL;
+ OMX_NATIVE_WINDOWTYPE * p_egldisplay = NULL;
+ const tiz_port_t * p_port = NULL;
+ struct pipe_video_buffer templat = {};
+ struct pipe_video_buffer *video_buffer = NULL;
+ struct pipe_resource * p_res = NULL;
+ struct pipe_resource *resources[VL_NUM_COMPONENTS];
+
+ if (OMX_ErrorNone ==
+ tiz_krn_claim_eglimage(tiz_get_krn (handleOf (priv)),
+ OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX,
+ priv->p_outhdr_, &p_eglimage)) {
+ priv->use_eglimage = true;
+ p_port = tiz_krn_get_port(tiz_get_krn (handleOf (priv)),
+ OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX);
+ p_egldisplay = p_port->portdef_.format.video.pNativeWindow;
+
+ if (!util_hash_table_get(priv->video_buffer_map, priv->p_outhdr_)) {
+ p_res = st_omx_pipe_texture_from_eglimage(p_egldisplay, p_eglimage);
+
+ assert(p_res);
+
+ memset(&templat, 0, sizeof(templat));
+ templat.buffer_format = p_res->format;
+ templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_NONE;
+ templat.width = p_res->width0;
+ templat.height = p_res->height0;
+ templat.interlaced = 0;
+
+ memset(resources, 0, sizeof(resources));
+ pipe_resource_reference(&resources[0], p_res);
+
+ video_buffer = vl_video_buffer_create_ex2(priv->pipe, &templat, resources);
+
+ assert(video_buffer);
+ assert(video_buffer->buffer_format == p_res->format);
+
+ util_hash_table_set(priv->video_buffer_map, priv->p_outhdr_, video_buffer);
+ }
+ } else {
+ (void) tiz_krn_release_buffer(tiz_get_krn (handleOf (priv)),
+ OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX,
+ priv->p_outhdr_);
+ priv->p_outhdr_ = NULL;
+ }
+}
+
static OMX_BUFFERHEADERTYPE * get_output_buffer(vid_dec_PrivateType* priv) {
assert (priv);
}
if (!priv->p_outhdr_) {
- tiz_krn_claim_buffer(tiz_get_krn (handleOf (priv)),
- OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX, 0,
- &priv->p_outhdr_);
+ if (OMX_ErrorNone
+ == tiz_krn_claim_buffer(tiz_get_krn (handleOf (priv)),
+ OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX, 0,
+ &priv->p_outhdr_)) {
+ if (priv->p_outhdr_) {
+ /* Check pBuffer nullity to know if an eglimage has been registered. */
+ if (!priv->p_outhdr_->pBuffer) {
+ get_eglimage(priv);
+ }
+ }
+ }
}
return priv->p_outhdr_;
}
/* Realase output buffer if filled or eos
Keep if two input buffers are being decoded */
- if ((!next_is_eos) && ((priv->p_outhdr_->nFilledLen > 0) || priv->eos_)) {
+ if ((!next_is_eos) && ((priv->p_outhdr_->nFilledLen > 0) || priv->use_eglimage || priv->eos_)) {
h264d_buffer_filled(priv, priv->p_outhdr_);
}
{
vid_dec_PrivateType*priv = ap_obj;
struct pipe_screen *screen;
+ vl_csc_matrix csc;
assert (priv);
return OMX_ErrorInsufficientResources;
}
+ vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &csc);
+ if (!vl_compositor_set_csc_matrix(&priv->cstate, (const vl_csc_matrix *)&csc, 1.0f, 0.0f)) {
+ vl_compositor_cleanup(&priv->compositor);
+ priv->pipe->destroy(priv->pipe);
+ priv->pipe = NULL;
+ return OMX_ErrorInsufficientResources;
+ }
+
LIST_INITHEAD(&priv->codec_data.h264.dpb_list);
+ priv->video_buffer_map = util_hash_table_create(handle_hash, handle_compare);
+
return OMX_ErrorNone;
}
vid_dec_PrivateType*priv = ap_obj;
assert(priv);
+ /* Clear hash table */
+ util_hash_table_foreach(priv->video_buffer_map,
+ &hash_table_clear_item_callback,
+ NULL);
+ util_hash_table_destroy(priv->video_buffer_map);
+
if (priv->pipe) {
vl_compositor_cleanup_state(&priv->cstate);
vl_compositor_cleanup(&priv->compositor);
views = buf->get_sampler_view_planes(buf);
+#if ENABLE_ST_OMX_TIZONIA
+ if (!output->pBuffer) {
+ struct pipe_video_buffer *dst_buf = NULL;
+ struct pipe_surface **dst_surface = NULL;
+ struct u_rect src_rect;
+ struct u_rect dst_rect;
+ struct vl_compositor *compositor = &priv->compositor;
+ struct vl_compositor_state *s = &priv->cstate;
+ enum vl_compositor_deinterlace deinterlace = VL_COMPOSITOR_WEAVE;
+
+ dst_buf = util_hash_table_get(priv->video_buffer_map, output);
+ assert(dst_buf);
+
+ dst_surface = dst_buf->get_surfaces(dst_buf);
+ assert(views);
+
+ src_rect.x0 = 0;
+ src_rect.y0 = 0;
+ src_rect.x1 = def->nFrameWidth;
+ src_rect.y1 = def->nFrameHeight;
+
+ dst_rect.x0 = 0;
+ dst_rect.y0 = 0;
+ dst_rect.x1 = def->nFrameWidth;
+ dst_rect.y1 = def->nFrameHeight;
+
+ vl_compositor_clear_layers(s);
+ vl_compositor_set_buffer_layer(s, compositor, 0, buf,
+ &src_rect, NULL, deinterlace);
+ vl_compositor_set_layer_dst_area(s, 0, &dst_rect);
+ vl_compositor_render(s, compositor, dst_surface[0], NULL, false);
+
+ priv->pipe->flush(priv->pipe, NULL, 0);
+
+ return;
+ }
+#endif
+
for (i = 0; i < 2 /* NV12 */; i++) {
if (!views[i]) continue;
width = def->nFrameWidth;