util: remove LIST_ADDTAIL macro
[mesa.git] / src / gallium / state_trackers / omx / vid_enc_common.c
1 /**************************************************************************
2 *
3 * Copyright 2013 Advanced Micro Devices, Inc.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 #include "vid_enc_common.h"
29
30 #include "vl/vl_video_buffer.h"
31 #include "tgsi/tgsi_text.h"
32
33 void enc_ReleaseTasks(struct list_head *head)
34 {
35 struct encode_task *i, *next;
36
37 if (!head || !head->next)
38 return;
39
40 LIST_FOR_EACH_ENTRY_SAFE(i, next, head, list) {
41 pipe_resource_reference(&i->bitstream, NULL);
42 i->buf->destroy(i->buf);
43 FREE(i);
44 }
45 }
46
47 void enc_MoveTasks(struct list_head *from, struct list_head *to)
48 {
49 to->prev->next = from->next;
50 from->next->prev = to->prev;
51 from->prev->next = to;
52 to->prev = from->prev;
53 list_inithead(from);
54 }
55
56 static void enc_GetPictureParamPreset(struct pipe_h264_enc_picture_desc *picture)
57 {
58 picture->motion_est.enc_disable_sub_mode = 0x000000fe;
59 picture->motion_est.enc_ime2_search_range_x = 0x00000001;
60 picture->motion_est.enc_ime2_search_range_y = 0x00000001;
61 picture->pic_ctrl.enc_constraint_set_flags = 0x00000040;
62 }
63
64 enum pipe_video_profile enc_TranslateOMXProfileToPipe(unsigned omx_profile)
65 {
66 switch (omx_profile) {
67 case OMX_VIDEO_AVCProfileBaseline:
68 return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
69 case OMX_VIDEO_AVCProfileMain:
70 return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
71 case OMX_VIDEO_AVCProfileExtended:
72 return PIPE_VIDEO_PROFILE_MPEG4_AVC_EXTENDED;
73 case OMX_VIDEO_AVCProfileHigh:
74 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
75 case OMX_VIDEO_AVCProfileHigh10:
76 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH10;
77 case OMX_VIDEO_AVCProfileHigh422:
78 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH422;
79 case OMX_VIDEO_AVCProfileHigh444:
80 return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH444;
81 default:
82 return PIPE_VIDEO_PROFILE_UNKNOWN;
83 }
84 }
85
86 unsigned enc_TranslateOMXLevelToPipe(unsigned omx_level)
87 {
88 switch (omx_level) {
89 case OMX_VIDEO_AVCLevel1:
90 case OMX_VIDEO_AVCLevel1b:
91 return 10;
92 case OMX_VIDEO_AVCLevel11:
93 return 11;
94 case OMX_VIDEO_AVCLevel12:
95 return 12;
96 case OMX_VIDEO_AVCLevel13:
97 return 13;
98 case OMX_VIDEO_AVCLevel2:
99 return 20;
100 case OMX_VIDEO_AVCLevel21:
101 return 21;
102 case OMX_VIDEO_AVCLevel22:
103 return 22;
104 case OMX_VIDEO_AVCLevel3:
105 return 30;
106 case OMX_VIDEO_AVCLevel31:
107 return 31;
108 case OMX_VIDEO_AVCLevel32:
109 return 32;
110 case OMX_VIDEO_AVCLevel4:
111 return 40;
112 case OMX_VIDEO_AVCLevel41:
113 return 41;
114 default:
115 case OMX_VIDEO_AVCLevel42:
116 return 42;
117 case OMX_VIDEO_AVCLevel5:
118 return 50;
119 case OMX_VIDEO_AVCLevel51:
120 return 51;
121 }
122 }
123
124 void vid_enc_BufferEncoded_common(vid_enc_PrivateType * priv, OMX_BUFFERHEADERTYPE* input, OMX_BUFFERHEADERTYPE* output)
125 {
126 struct output_buf_private *outp = output->pOutputPortPrivate;
127 struct input_buf_private *inp = input->pInputPortPrivate;
128 struct encode_task *task;
129 struct pipe_box box = {};
130 unsigned size;
131
132 #if ENABLE_ST_OMX_BELLAGIO
133 if (!inp || LIST_IS_EMPTY(&inp->tasks)) {
134 input->nFilledLen = 0; /* mark buffer as empty */
135 enc_MoveTasks(&priv->used_tasks, &inp->tasks);
136 return;
137 }
138 #endif
139
140 task = LIST_ENTRY(struct encode_task, inp->tasks.next, list);
141 LIST_DEL(&task->list);
142 list_addtail(&task->list, &priv->used_tasks);
143
144 if (!task->bitstream)
145 return;
146
147 /* ------------- map result buffer ----------------- */
148
149 if (outp->transfer)
150 pipe_transfer_unmap(priv->t_pipe, outp->transfer);
151
152 pipe_resource_reference(&outp->bitstream, task->bitstream);
153 pipe_resource_reference(&task->bitstream, NULL);
154
155 box.width = outp->bitstream->width0;
156 box.height = outp->bitstream->height0;
157 box.depth = outp->bitstream->depth0;
158
159 output->pBuffer = priv->t_pipe->transfer_map(priv->t_pipe, outp->bitstream, 0,
160 PIPE_TRANSFER_READ_WRITE,
161 &box, &outp->transfer);
162
163 /* ------------- get size of result ----------------- */
164
165 priv->codec->get_feedback(priv->codec, task->feedback, &size);
166
167 output->nOffset = 0;
168 output->nFilledLen = size; /* mark buffer as full */
169
170 /* all output buffers contain exactly one frame */
171 output->nFlags = OMX_BUFFERFLAG_ENDOFFRAME;
172
173 #if ENABLE_ST_OMX_TIZONIA
174 input->nFilledLen = 0; /* mark buffer as empty */
175 enc_MoveTasks(&priv->used_tasks, &inp->tasks);
176 #endif
177 }
178
179
180 struct encode_task *enc_NeedTask_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEFINITIONTYPE *def)
181 {
182 struct pipe_video_buffer templat = {};
183 struct encode_task *task;
184
185 if (!LIST_IS_EMPTY(&priv->free_tasks)) {
186 task = LIST_ENTRY(struct encode_task, priv->free_tasks.next, list);
187 LIST_DEL(&task->list);
188 return task;
189 }
190
191 /* allocate a new one */
192 task = CALLOC_STRUCT(encode_task);
193 if (!task)
194 return NULL;
195
196 templat.buffer_format = PIPE_FORMAT_NV12;
197 templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
198 templat.width = def->nFrameWidth;
199 templat.height = def->nFrameHeight;
200 templat.interlaced = false;
201
202 task->buf = priv->s_pipe->create_video_buffer(priv->s_pipe, &templat);
203 if (!task->buf) {
204 FREE(task);
205 return NULL;
206 }
207
208 return task;
209 }
210
211 void enc_ScaleInput_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEFINITIONTYPE *def,
212 struct pipe_video_buffer **vbuf, unsigned *size)
213 {
214 struct pipe_video_buffer *src_buf = *vbuf;
215 struct vl_compositor *compositor = &priv->compositor;
216 struct vl_compositor_state *s = &priv->cstate;
217 struct pipe_sampler_view **views;
218 struct pipe_surface **dst_surface;
219 unsigned i;
220
221 if (!priv->scale_buffer[priv->current_scale_buffer])
222 return;
223
224 views = src_buf->get_sampler_view_planes(src_buf);
225 dst_surface = priv->scale_buffer[priv->current_scale_buffer]->get_surfaces
226 (priv->scale_buffer[priv->current_scale_buffer]);
227 vl_compositor_clear_layers(s);
228
229 for (i = 0; i < VL_MAX_SURFACES; ++i) {
230 struct u_rect src_rect;
231 if (!views[i] || !dst_surface[i])
232 continue;
233 src_rect.x0 = 0;
234 src_rect.y0 = 0;
235 src_rect.x1 = def->nFrameWidth;
236 src_rect.y1 = def->nFrameHeight;
237 if (i > 0) {
238 src_rect.x1 /= 2;
239 src_rect.y1 /= 2;
240 }
241 vl_compositor_set_rgba_layer(s, compositor, 0, views[i], &src_rect, NULL, NULL);
242 vl_compositor_render(s, compositor, dst_surface[i], NULL, false);
243 }
244 *size = priv->scale.xWidth * priv->scale.xHeight * 2;
245 *vbuf = priv->scale_buffer[priv->current_scale_buffer++];
246 priv->current_scale_buffer %= OMX_VID_ENC_NUM_SCALING_BUFFERS;
247 }
248
249 void enc_ControlPicture_common(vid_enc_PrivateType * priv, struct pipe_h264_enc_picture_desc *picture)
250 {
251 struct pipe_h264_enc_rate_control *rate_ctrl = &picture->rate_ctrl;
252
253 /* Get bitrate from port */
254 switch (priv->bitrate.eControlRate) {
255 case OMX_Video_ControlRateVariable:
256 rate_ctrl->rate_ctrl_method = PIPE_H264_ENC_RATE_CONTROL_METHOD_VARIABLE;
257 break;
258 case OMX_Video_ControlRateConstant:
259 rate_ctrl->rate_ctrl_method = PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT;
260 break;
261 case OMX_Video_ControlRateVariableSkipFrames:
262 rate_ctrl->rate_ctrl_method = PIPE_H264_ENC_RATE_CONTROL_METHOD_VARIABLE_SKIP;
263 break;
264 case OMX_Video_ControlRateConstantSkipFrames:
265 rate_ctrl->rate_ctrl_method = PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT_SKIP;
266 break;
267 default:
268 rate_ctrl->rate_ctrl_method = PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE;
269 break;
270 }
271
272 rate_ctrl->frame_rate_den = OMX_VID_ENC_CONTROL_FRAME_RATE_DEN_DEFAULT;
273 rate_ctrl->frame_rate_num = ((priv->frame_rate) >> 16) * rate_ctrl->frame_rate_den;
274
275 if (rate_ctrl->rate_ctrl_method != PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE) {
276 if (priv->bitrate.nTargetBitrate < OMX_VID_ENC_BITRATE_MIN)
277 rate_ctrl->target_bitrate = OMX_VID_ENC_BITRATE_MIN;
278 else if (priv->bitrate.nTargetBitrate < OMX_VID_ENC_BITRATE_MAX)
279 rate_ctrl->target_bitrate = priv->bitrate.nTargetBitrate;
280 else
281 rate_ctrl->target_bitrate = OMX_VID_ENC_BITRATE_MAX;
282 rate_ctrl->peak_bitrate = rate_ctrl->target_bitrate;
283 if (rate_ctrl->target_bitrate < OMX_VID_ENC_BITRATE_MEDIAN)
284 rate_ctrl->vbv_buffer_size = MIN2((rate_ctrl->target_bitrate * 2.75), OMX_VID_ENC_BITRATE_MEDIAN);
285 else
286 rate_ctrl->vbv_buffer_size = rate_ctrl->target_bitrate;
287
288 if (rate_ctrl->frame_rate_num) {
289 unsigned long long t = rate_ctrl->target_bitrate;
290 t *= rate_ctrl->frame_rate_den;
291 rate_ctrl->target_bits_picture = t / rate_ctrl->frame_rate_num;
292 } else {
293 rate_ctrl->target_bits_picture = rate_ctrl->target_bitrate;
294 }
295 rate_ctrl->peak_bits_picture_integer = rate_ctrl->target_bits_picture;
296 rate_ctrl->peak_bits_picture_fraction = 0;
297 }
298
299 picture->quant_i_frames = priv->quant.nQpI;
300 picture->quant_p_frames = priv->quant.nQpP;
301 picture->quant_b_frames = priv->quant.nQpB;
302
303 picture->frame_num = priv->frame_num;
304 picture->ref_idx_l0 = priv->ref_idx_l0;
305 picture->ref_idx_l1 = priv->ref_idx_l1;
306 picture->enable_vui = (picture->rate_ctrl.frame_rate_num != 0);
307 enc_GetPictureParamPreset(picture);
308 }
309
310 static void *create_compute_state(struct pipe_context *pipe,
311 const char *source)
312 {
313 struct tgsi_token tokens[1024];
314 struct pipe_compute_state state = {0};
315
316 if (!tgsi_text_translate(source, tokens, ARRAY_SIZE(tokens))) {
317 assert(false);
318 return NULL;
319 }
320
321 state.ir_type = PIPE_SHADER_IR_TGSI;
322 state.prog = tokens;
323
324 return pipe->create_compute_state(pipe, &state);
325 }
326
327 void enc_InitCompute_common(vid_enc_PrivateType *priv)
328 {
329 struct pipe_context *pipe = priv->s_pipe;
330 struct pipe_screen *screen = pipe->screen;
331
332 /* We need the partial last block support. */
333 if (!screen->get_param(screen, PIPE_CAP_COMPUTE_GRID_INFO_LAST_BLOCK))
334 return;
335
336 static const char *copy_y =
337 "COMP\n"
338 "PROPERTY CS_FIXED_BLOCK_WIDTH 64\n"
339 "PROPERTY CS_FIXED_BLOCK_HEIGHT 1\n"
340 "PROPERTY CS_FIXED_BLOCK_DEPTH 1\n"
341 "DCL SV[0], THREAD_ID\n"
342 "DCL SV[1], BLOCK_ID\n"
343 "DCL IMAGE[0], 2D, PIPE_FORMAT_R8_UINT\n"
344 "DCL IMAGE[1], 2D, PIPE_FORMAT_R8_UINT, WR\n"
345 "DCL TEMP[0..1]\n"
346 "IMM[0] UINT32 {64, 0, 0, 0}\n"
347
348 "UMAD TEMP[0].x, SV[1], IMM[0], SV[0]\n"
349 "MOV TEMP[0].y, SV[1]\n"
350 "LOAD TEMP[1].x, IMAGE[0], TEMP[0], 2D, PIPE_FORMAT_R8_UINT\n"
351 "STORE IMAGE[1].x, TEMP[0], TEMP[1], 2D, PIPE_FORMAT_R8_UINT\n"
352 "END\n";
353
354 static const char *copy_uv =
355 "COMP\n"
356 "PROPERTY CS_FIXED_BLOCK_WIDTH 64\n"
357 "PROPERTY CS_FIXED_BLOCK_HEIGHT 1\n"
358 "PROPERTY CS_FIXED_BLOCK_DEPTH 1\n"
359 "DCL SV[0], THREAD_ID\n"
360 "DCL SV[1], BLOCK_ID\n"
361 "DCL IMAGE[0], 2D, PIPE_FORMAT_R8_UINT\n"
362 "DCL IMAGE[2], 2D, PIPE_FORMAT_R8G8_UINT, WR\n"
363 "DCL CONST[0][0]\n" /* .x = offset of the UV portion in the y direction */
364 "DCL TEMP[0..4]\n"
365 "IMM[0] UINT32 {64, 0, 2, 1}\n"
366 /* Destination R8G8 coordinates */
367 "UMAD TEMP[0].x, SV[1], IMM[0], SV[0]\n"
368 "MOV TEMP[0].y, SV[1]\n"
369 /* Source R8 coordinates of U */
370 "UMUL TEMP[1].x, TEMP[0], IMM[0].zzzz\n"
371 "UADD TEMP[1].y, TEMP[0], CONST[0].xxxx\n"
372 /* Source R8 coordinates of V */
373 "UADD TEMP[2].x, TEMP[1], IMM[0].wwww\n"
374 "MOV TEMP[2].y, TEMP[1]\n"
375
376 "LOAD TEMP[3].x, IMAGE[0], TEMP[1], 2D, PIPE_FORMAT_R8_UINT\n"
377 "LOAD TEMP[4].x, IMAGE[0], TEMP[2], 2D, PIPE_FORMAT_R8_UINT\n"
378 "MOV TEMP[3].y, TEMP[4].xxxx\n"
379 "STORE IMAGE[2], TEMP[0], TEMP[3], 2D, PIPE_FORMAT_R8G8_UINT\n"
380 "END\n";
381
382 priv->copy_y_shader = create_compute_state(pipe, copy_y);
383 priv->copy_uv_shader = create_compute_state(pipe, copy_uv);
384 }
385
386 void enc_ReleaseCompute_common(vid_enc_PrivateType *priv)
387 {
388 struct pipe_context *pipe = priv->s_pipe;
389
390 if (priv->copy_y_shader)
391 pipe->delete_compute_state(pipe, priv->copy_y_shader);
392 if (priv->copy_uv_shader)
393 pipe->delete_compute_state(pipe, priv->copy_uv_shader);
394 }
395
396 OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEFINITIONTYPE *def,
397 OMX_BUFFERHEADERTYPE *buf,
398 struct pipe_video_buffer *vbuf)
399 {
400 struct pipe_context *pipe = priv->s_pipe;
401 struct pipe_box box = {};
402 struct input_buf_private *inp = buf->pInputPortPrivate;
403
404 if (!inp->resource) {
405 struct pipe_sampler_view **views;
406 void *ptr;
407
408 views = vbuf->get_sampler_view_planes(vbuf);
409 if (!views)
410 return OMX_ErrorInsufficientResources;
411
412 ptr = buf->pBuffer;
413 box.width = def->nFrameWidth;
414 box.height = def->nFrameHeight;
415 box.depth = 1;
416 pipe->texture_subdata(pipe, views[0]->texture, 0,
417 PIPE_TRANSFER_WRITE, &box,
418 ptr, def->nStride, 0);
419 ptr = ((uint8_t*)buf->pBuffer) + (def->nStride * box.height);
420 box.width = def->nFrameWidth / 2;
421 box.height = def->nFrameHeight / 2;
422 box.depth = 1;
423 pipe->texture_subdata(pipe, views[1]->texture, 0,
424 PIPE_TRANSFER_WRITE, &box,
425 ptr, def->nStride, 0);
426 } else {
427 struct vl_video_buffer *dst_buf = (struct vl_video_buffer *)vbuf;
428
429 pipe_transfer_unmap(pipe, inp->transfer);
430
431 /* inp->resource uses PIPE_FORMAT_I8 and the layout looks like this:
432 *
433 * def->nFrameWidth = 4, def->nFrameHeight = 4:
434 * |----|
435 * |YYYY|
436 * |YYYY|
437 * |YYYY|
438 * |YYYY|
439 * |UVUV|
440 * |UVUV|
441 * |----|
442 *
443 * The copy has 2 steps:
444 * - Copy Y to dst_buf->resources[0] as R8.
445 * - Copy UV to dst_buf->resources[1] as R8G8.
446 */
447 if (priv->copy_y_shader && priv->copy_uv_shader) {
448 /* Compute path */
449 /* Set shader images for both copies. */
450 struct pipe_image_view image[3] = {0};
451 image[0].resource = inp->resource;
452 image[0].shader_access = image[0].access = PIPE_IMAGE_ACCESS_READ;
453 image[0].format = PIPE_FORMAT_R8_UINT;
454
455 image[1].resource = dst_buf->resources[0];
456 image[1].shader_access = image[1].access = PIPE_IMAGE_ACCESS_WRITE;
457 image[1].format = PIPE_FORMAT_R8_UINT;
458
459 image[2].resource = dst_buf->resources[1];
460 image[2].shader_access = image[1].access = PIPE_IMAGE_ACCESS_WRITE;
461 image[2].format = PIPE_FORMAT_R8G8_UINT;
462
463 pipe->set_shader_images(pipe, PIPE_SHADER_COMPUTE, 0, 3, image);
464
465 /* Set the constant buffer. */
466 uint32_t constants[4] = {def->nFrameHeight};
467 struct pipe_constant_buffer cb = {};
468
469 cb.buffer_size = sizeof(constants);
470 cb.user_buffer = constants;
471 pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, &cb);
472
473 /* Use the optimal block size for the linear image layout. */
474 struct pipe_grid_info info = {};
475 info.block[0] = 64;
476 info.block[1] = 1;
477 info.block[2] = 1;
478 info.grid[2] = 1;
479
480 /* Copy Y */
481 pipe->bind_compute_state(pipe, priv->copy_y_shader);
482
483 info.grid[0] = DIV_ROUND_UP(def->nFrameWidth, 64);
484 info.grid[1] = def->nFrameHeight;
485 info.last_block[0] = def->nFrameWidth % 64;
486 pipe->launch_grid(pipe, &info);
487
488 /* Copy UV */
489 pipe->bind_compute_state(pipe, priv->copy_uv_shader);
490
491 info.grid[0] = DIV_ROUND_UP(def->nFrameWidth / 2, 64);
492 info.grid[1] = def->nFrameHeight / 2;
493 info.last_block[0] = (def->nFrameWidth / 2) % 64;
494 pipe->launch_grid(pipe, &info);
495
496 /* Make the result visible to all clients. */
497 pipe->memory_barrier(pipe, PIPE_BARRIER_ALL);
498
499 /* Unbind. */
500 pipe->set_shader_images(pipe, PIPE_SHADER_COMPUTE, 0, 3, NULL);
501 pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, NULL);
502 pipe->bind_compute_state(pipe, NULL);
503 } else {
504 /* Graphics path */
505 struct pipe_blit_info blit;
506
507 box.width = def->nFrameWidth;
508 box.height = def->nFrameHeight;
509 box.depth = 1;
510
511 /* Copy Y */
512 pipe->resource_copy_region(pipe,
513 dst_buf->resources[0],
514 0, 0, 0, 0, inp->resource, 0, &box);
515
516 /* Copy U */
517 memset(&blit, 0, sizeof(blit));
518 blit.src.resource = inp->resource;
519 blit.src.format = inp->resource->format;
520
521 blit.src.box.x = -1;
522 blit.src.box.y = def->nFrameHeight;
523 blit.src.box.width = def->nFrameWidth;
524 blit.src.box.height = def->nFrameHeight / 2 ;
525 blit.src.box.depth = 1;
526
527 blit.dst.resource = dst_buf->resources[1];
528 blit.dst.format = blit.dst.resource->format;
529
530 blit.dst.box.width = def->nFrameWidth / 2;
531 blit.dst.box.height = def->nFrameHeight / 2;
532 blit.dst.box.depth = 1;
533 blit.filter = PIPE_TEX_FILTER_NEAREST;
534
535 blit.mask = PIPE_MASK_R;
536 pipe->blit(pipe, &blit);
537
538 /* Copy V */
539 blit.src.box.x = 0;
540 blit.mask = PIPE_MASK_G;
541 pipe->blit(pipe, &blit);
542 }
543
544 pipe->flush(pipe, NULL, 0);
545
546 box.width = inp->resource->width0;
547 box.height = inp->resource->height0;
548 box.depth = inp->resource->depth0;
549 buf->pBuffer = pipe->transfer_map(pipe, inp->resource, 0,
550 PIPE_TRANSFER_WRITE, &box,
551 &inp->transfer);
552 }
553
554 return OMX_ErrorNone;
555 }