1 /**************************************************************************
3 * Copyright 2013 Advanced Micro Devices, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #if ENABLE_ST_OMX_TIZONIA
29 #include <tizkernel.h>
32 #include "util/u_memory.h"
33 #include "vl/vl_winsys.h"
34 #include "vl/vl_video_buffer.h"
35 #include "util/u_surface.h"
37 #include "vid_dec_common.h"
38 #include "vid_dec_h264_common.h"
40 void vid_dec_NeedTarget(vid_dec_PrivateType
*priv
)
42 struct pipe_video_buffer templat
= {};
43 struct vl_screen
*omx_screen
;
44 struct pipe_screen
*pscreen
;
46 omx_screen
= priv
->screen
;
49 pscreen
= omx_screen
->pscreen
;
53 memset(&templat
, 0, sizeof(templat
));
55 templat
.width
= priv
->codec
->width
;
56 templat
.height
= priv
->codec
->height
;
57 templat
.buffer_format
= pscreen
->get_video_param(
59 PIPE_VIDEO_PROFILE_UNKNOWN
,
60 PIPE_VIDEO_ENTRYPOINT_BITSTREAM
,
61 PIPE_VIDEO_CAP_PREFERED_FORMAT
63 templat
.interlaced
= pscreen
->get_video_param(
65 PIPE_VIDEO_PROFILE_UNKNOWN
,
66 PIPE_VIDEO_ENTRYPOINT_BITSTREAM
,
67 PIPE_VIDEO_CAP_PREFERS_INTERLACED
70 priv
->target
= priv
->pipe
->create_video_buffer(priv
->pipe
, &templat
);
74 void vid_dec_FillOutput(vid_dec_PrivateType
*priv
, struct pipe_video_buffer
*buf
,
75 OMX_BUFFERHEADERTYPE
* output
)
77 #if ENABLE_ST_OMX_TIZONIA
78 tiz_port_t
*out_port
= tiz_krn_get_port(tiz_get_krn(handleOf(priv
)),
79 OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX
);
80 OMX_VIDEO_PORTDEFINITIONTYPE
*def
= &out_port
->portdef_
.format
.video
;
82 omx_base_PortType
*port
= priv
->ports
[OMX_BASE_FILTER_OUTPUTPORT_INDEX
];
83 OMX_VIDEO_PORTDEFINITIONTYPE
*def
= &port
->sPortParam
.format
.video
;
86 struct pipe_sampler_view
**views
;
88 unsigned width
, height
;
90 views
= buf
->get_sampler_view_planes(buf
);
92 #if ENABLE_ST_OMX_TIZONIA
93 if (!output
->pBuffer
) {
94 struct pipe_video_buffer
*dst_buf
= NULL
;
95 struct pipe_surface
**dst_surface
= NULL
;
96 struct u_rect src_rect
;
97 struct u_rect dst_rect
;
98 struct vl_compositor
*compositor
= &priv
->compositor
;
99 struct vl_compositor_state
*s
= &priv
->cstate
;
100 enum vl_compositor_deinterlace deinterlace
= VL_COMPOSITOR_WEAVE
;
102 dst_buf
= util_hash_table_get(priv
->video_buffer_map
, output
);
105 dst_surface
= dst_buf
->get_surfaces(dst_buf
);
110 src_rect
.x1
= def
->nFrameWidth
;
111 src_rect
.y1
= def
->nFrameHeight
;
115 dst_rect
.x1
= def
->nFrameWidth
;
116 dst_rect
.y1
= def
->nFrameHeight
;
118 vl_compositor_clear_layers(s
);
119 vl_compositor_set_buffer_layer(s
, compositor
, 0, buf
,
120 &src_rect
, NULL
, deinterlace
);
121 vl_compositor_set_layer_dst_area(s
, 0, &dst_rect
);
122 vl_compositor_render(s
, compositor
, dst_surface
[0], NULL
, false);
124 priv
->pipe
->flush(priv
->pipe
, NULL
, 0);
130 for (i
= 0; i
< 2 /* NV12 */; i
++) {
131 if (!views
[i
]) continue;
132 width
= def
->nFrameWidth
;
133 height
= def
->nFrameHeight
;
134 vl_video_buffer_adjust_size(&width
, &height
, i
,
135 pipe_format_to_chroma_format(buf
->buffer_format
),
137 for (j
= 0; j
< views
[i
]->texture
->array_size
; ++j
) {
138 struct pipe_box box
= {0, 0, j
, width
, height
, 1};
139 struct pipe_transfer
*transfer
;
141 map
= priv
->pipe
->transfer_map(priv
->pipe
, views
[i
]->texture
, 0,
142 PIPE_TRANSFER_READ
, &box
, &transfer
);
146 dst
= ((uint8_t*)output
->pBuffer
+ output
->nOffset
) + j
* def
->nStride
+
147 i
* def
->nFrameWidth
* def
->nFrameHeight
;
149 views
[i
]->texture
->format
,
150 def
->nStride
* views
[i
]->texture
->array_size
, 0, 0,
151 box
.width
, box
.height
, map
, transfer
->stride
, 0, 0);
153 pipe_transfer_unmap(priv
->pipe
, transfer
);