4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
\r
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
22 /*===========================================================================================
\r
26 ========================================================================================== */
\r
27 #include "mm_player_capture.h"
\r
28 #include "mm_player_priv.h"
\r
30 #include <mm_util_imgp.h>
\r
32 /*---------------------------------------------------------------------------
\r
33 | LOCAL VARIABLE DEFINITIONS for internal |
\r
34 ---------------------------------------------------------------------------*/
\r
36 /*---------------------------------------------------------------------------
\r
37 | LOCAL FUNCTION PROTOTYPES: |
\r
38 ---------------------------------------------------------------------------*/
\r
39 static gboolean __mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data);
\r
40 static int __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer);
\r
41 static gpointer __mmplayer_capture_thread(gpointer data);
\r
42 static void __csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, int yuv420_width, int yuv420_height, int left, int top, int right, int buttom);
\r
43 static int __tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos);
\r
44 static int __mm_player_convert_colorspace(mm_player_t* player, unsigned char* src_data, mm_util_img_format src_fmt, unsigned int src_w, unsigned int src_h, mm_util_img_format dst_fmt);
\r
46 /*===========================================================================================
\r
48 | FUNCTION DEFINITIONS |
\r
50 ========================================================================================== */
\r
52 _mmplayer_initialize_video_capture(mm_player_t* player)
\r
54 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
\r
55 /* create capture mutex */
\r
56 player->capture_thread_mutex = g_mutex_new();
\r
57 if ( ! player->capture_thread_mutex )
\r
59 debug_critical("Cannot create capture mutex");
\r
63 /* create capture cond */
\r
64 player->capture_thread_cond = g_cond_new();
\r
65 if ( ! player->capture_thread_cond )
\r
67 debug_critical("Cannot create capture cond");
\r
71 player->capture_thread_exit = FALSE;
\r
73 /* create video capture thread */
\r
74 player->capture_thread =
\r
75 g_thread_create (__mmplayer_capture_thread, (gpointer)player, TRUE, NULL);
\r
76 if ( ! player->capture_thread )
\r
81 return MM_ERROR_NONE;
\r
84 /* capture thread */
\r
85 if ( player->capture_thread_mutex )
\r
86 g_mutex_free ( player->capture_thread_mutex );
\r
88 if ( player->capture_thread_cond )
\r
89 g_cond_free ( player->capture_thread_cond );
\r
91 return MM_ERROR_PLAYER_INTERNAL;
\r
95 _mmplayer_release_video_capture(mm_player_t* player)
\r
97 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
\r
98 /* release capture thread */
\r
99 if ( player->capture_thread_cond &&
\r
100 player->capture_thread_mutex &&
\r
101 player->capture_thread )
\r
103 g_mutex_lock(player->capture_thread_mutex);
\r
104 player->capture_thread_exit = TRUE;
\r
105 g_cond_signal( player->capture_thread_cond );
\r
106 g_mutex_unlock(player->capture_thread_mutex);
\r
108 debug_log("waitting for capture thread exit");
\r
109 g_thread_join ( player->capture_thread );
\r
110 g_mutex_free ( player->capture_thread_mutex );
\r
111 g_cond_free ( player->capture_thread_cond );
\r
112 debug_log("capture thread released");
\r
115 return MM_ERROR_NONE;
\r
119 _mmplayer_do_video_capture(MMHandleType hplayer)
\r
121 mm_player_t* player = (mm_player_t*) hplayer;
\r
122 int ret = MM_ERROR_NONE;
\r
123 GstPad *pad = NULL;
\r
127 return_val_if_fail(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
\r
129 /* capturing or not */
\r
130 if (player->video_capture_cb_probe_id || player->capture.data || player->captured.a[0] || player->captured.a[1])
\r
132 debug_warning("capturing... we can't do any more");
\r
133 return MM_ERROR_PLAYER_INVALID_STATE;
\r
136 /* check if video pipeline is linked or not */
\r
137 if (!player->pipeline->videobin || !player->sent_bos)
\r
139 debug_warning("not ready to capture");
\r
140 return MM_ERROR_PLAYER_INVALID_STATE;
\r
143 if (player->state != MM_PLAYER_STATE_PLAYING)
\r
145 if (player->state == MM_PLAYER_STATE_PAUSED) // get last buffer from video sink
\r
147 GstBuffer *buf = NULL;
\r
148 g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "last-buffer", &buf, NULL);
\r
152 ret = __mmplayer_get_video_frame_from_buffer(player, buf);
\r
153 gst_buffer_unref(buf);
\r
159 debug_warning("invalid state(%d) to capture", player->state);
\r
160 return MM_ERROR_PLAYER_INVALID_STATE;
\r
164 pad = gst_element_get_static_pad(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink" );
\r
166 /* register probe */
\r
167 player->video_capture_cb_probe_id = gst_pad_add_buffer_probe (pad,
\r
168 G_CALLBACK (__mmplayer_video_capture_probe), player);
\r
170 gst_object_unref(GST_OBJECT(pad));
\r
179 __mmplayer_capture_thread(gpointer data)
\r
181 mm_player_t* player = (mm_player_t*) data;
\r
182 MMMessageParamType msg = {0, };
\r
183 unsigned char * linear_y_plane = NULL;
\r
184 unsigned char * linear_uv_plane = NULL;
\r
186 return_val_if_fail(player, NULL);
\r
188 while (!player->capture_thread_exit)
\r
190 debug_log("capture thread started. waiting for signal");
\r
192 g_mutex_lock(player->capture_thread_mutex);
\r
193 g_cond_wait( player->capture_thread_cond, player->capture_thread_mutex );
\r
195 if ( player->capture_thread_exit )
\r
197 debug_log("exiting capture thread");
\r
200 debug_log("capture thread is recieved signal");
\r
202 /* NOTE: Don't use MMPLAYER_CMD_LOCK() here.
\r
203 * Because deadlock can be happened if other player api is used in message callback.
\r
205 if (player->video_cs == MM_PLAYER_COLORSPACE_NV12_TILED)
\r
207 /* Colorspace conversion : NV12T-> NV12-> RGB888 */
\r
209 int linear_y_plane_size;
\r
210 int linear_uv_plane_size;
\r
211 unsigned char * src_buffer = NULL;
\r
213 debug_log("w[0]=%d, w[1]=%d", player->captured.w[0], player->captured.w[1]);
\r
214 debug_log("h[0]=%d, h[1]=%d", player->captured.h[0], player->captured.h[1]);
\r
215 debug_log("s[0]=%d, s[1]=%d", player->captured.s[0], player->captured.s[1]);
\r
216 debug_log("e[0]=%d, e[1]=%d", player->captured.e[0], player->captured.e[1]);
\r
217 debug_log("a[0]=%p, a[1]=%p", player->captured.a[0], player->captured.a[1]);
\r
220 if (mm_attrs_get_int_by_name(player->attrs, "content_video_width", &(player->captured.w[0])) != MM_ERROR_NONE)
\r
222 debug_error("failed to get content width attribute");
\r
226 if (mm_attrs_get_int_by_name(player->attrs, "content_video_height", &(player->captured.h[0])) != MM_ERROR_NONE)
\r
228 debug_error("failed to get content height attribute");
\r
233 linear_y_plane_size = (player->captured.w[0] * player->captured.h[0]);
\r
234 linear_uv_plane_size = (player->captured.w[0] * player->captured.h[0]/2);
\r
236 linear_y_plane = (unsigned char*) g_try_malloc(linear_y_plane_size);
\r
237 if (linear_y_plane == NULL)
\r
239 msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;
\r
243 linear_uv_plane = (unsigned char*) g_try_malloc(linear_uv_plane_size);
\r
244 if (linear_uv_plane == NULL)
\r
246 msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;
\r
249 /* NV12 tiled to linear */
\r
250 __csc_tiled_to_linear_crop(linear_y_plane, player->captured.a[0], player->captured.w[0], player->captured.h[0], 0,0,0,0);
\r
251 __csc_tiled_to_linear_crop(linear_uv_plane, player->captured.a[1], player->captured.w[0], player->captured.h[0]/2, 0,0,0,0);
\r
253 MMPLAYER_FREEIF(player->captured.a[0]);
\r
254 MMPLAYER_FREEIF(player->captured.a[1]);
\r
256 src_buffer = (unsigned char*) g_try_malloc(linear_y_plane_size+linear_uv_plane_size);
\r
258 if (src_buffer == NULL)
\r
260 msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;
\r
263 memset(src_buffer, 0x00, linear_y_plane_size+linear_uv_plane_size);
\r
264 memcpy(src_buffer, linear_y_plane, linear_y_plane_size);
\r
265 memcpy(src_buffer+linear_y_plane_size, linear_uv_plane, linear_uv_plane_size);
\r
267 /* NV12 linear to RGB888 */
\r
268 ret = __mm_player_convert_colorspace(player, src_buffer, MM_UTIL_IMG_FMT_NV12,
\r
269 player->captured.w[0], player->captured.h[0], MM_UTIL_IMG_FMT_RGB888);
\r
271 if (ret != MM_ERROR_NONE)
\r
273 debug_error("failed to convert nv12 linear");
\r
277 MMPLAYER_FREEIF(src_buffer);
\r
278 MMPLAYER_FREEIF(linear_y_plane);
\r
279 MMPLAYER_FREEIF(linear_uv_plane);
\r
282 player->capture.fmt = MM_PLAYER_COLORSPACE_RGB888;
\r
283 msg.data = &player->capture;
\r
284 msg.size = player->capture.size;
\r
286 if (player->cmd >= MMPLAYER_COMMAND_START)
\r
288 MMPLAYER_POST_MSG( player, MM_MESSAGE_VIDEO_CAPTURED, &msg );
\r
289 debug_log("returned from capture message callback");
\r
292 g_mutex_unlock(player->capture_thread_mutex);
\r
294 //MMPLAYER_FREEIF(player->capture.data);
\r
297 if (player->video_cs == MM_PLAYER_COLORSPACE_NV12_TILED)
\r
300 MMPLAYER_FREEIF(linear_y_plane);
\r
301 MMPLAYER_FREEIF(linear_uv_plane);
\r
302 MMPLAYER_FREEIF(player->captured.a[0]);
\r
303 MMPLAYER_FREEIF(player->captured.a[1]);
\r
306 msg.union_type = MM_MSG_UNION_CODE;
\r
308 g_mutex_unlock(player->capture_thread_mutex);
\r
309 MMPLAYER_POST_MSG( player, MM_MESSAGE_VIDEO_NOT_CAPTURED, &msg );
\r
313 g_mutex_unlock(player->capture_thread_mutex);
\r
318 * The output is fixed as RGB888
\r
321 __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer)
\r
323 gint yplane_size = 0;
\r
324 gint uvplane_size = 0;
\r
325 gint src_width = 0;
\r
326 gint src_height = 0;
\r
327 guint32 fourcc = 0;
\r
328 GstCaps *caps = NULL;
\r
329 GstStructure *structure = NULL;
\r
330 mm_util_img_format src_fmt = MM_UTIL_IMG_FMT_YUV420;
\r
331 mm_util_img_format dst_fmt = MM_UTIL_IMG_FMT_RGB888; // fixed
\r
335 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
\r
336 return_val_if_fail ( buffer, MM_ERROR_INVALID_ARGUMENT );
\r
339 caps = GST_BUFFER_CAPS(buffer);
\r
341 return_val_if_fail ( caps, MM_ERROR_INVALID_ARGUMENT );
\r
342 debug_log("caps to capture: %s\n", gst_caps_to_string(caps));
\r
344 structure = gst_caps_get_structure (caps, 0);
\r
346 return_val_if_fail (structure != NULL, MM_ERROR_PLAYER_INTERNAL);
\r
348 /* init capture image buffer */
\r
349 memset(&player->capture, 0x00, sizeof(MMPlayerVideoCapture));
\r
351 gst_structure_get_int (structure, "width", &src_width);
\r
352 gst_structure_get_int (structure, "height", &src_height);
\r
354 /* check rgb or yuv */
\r
355 if (gst_structure_has_name(structure, "video/x-raw-yuv"))
\r
357 gst_structure_get_fourcc (structure, "format", &fourcc);
\r
362 case GST_MAKE_FOURCC ('S', 'T', '1', '2'):
\r
364 debug_msg ("captured format is ST12\n");
\r
366 MMPlayerMPlaneImage *proved = NULL;
\r
367 player->video_cs = MM_PLAYER_COLORSPACE_NV12_TILED;
\r
369 /* get video frame info from proved buffer */
\r
370 proved = (MMPlayerMPlaneImage *)GST_BUFFER_MALLOCDATA(buffer);
\r
372 if ( !proved || !proved->a[0] || !proved->a[1] )
\r
373 return MM_ERROR_PLAYER_INTERNAL;
\r
375 yplane_size = proved->y_size;
\r
376 uvplane_size = proved->uv_size;
\r
378 debug_msg ("yplane_size=%d, uvplane_size=%d\n",yplane_size,uvplane_size);
\r
379 memset(&player->captured, 0x00, sizeof(MMPlayerMPlaneImage));
\r
380 memcpy(&player->captured, proved, sizeof(MMPlayerMPlaneImage));
\r
382 player->captured.a[0] = g_try_malloc(yplane_size);
\r
383 if ( !player->captured.a[0] )
\r
384 return MM_ERROR_SOUND_NO_FREE_SPACE;
\r
386 player->captured.a[1] = g_try_malloc(uvplane_size);
\r
387 if ( !player->captured.a[1] )
\r
388 return MM_ERROR_SOUND_NO_FREE_SPACE;
\r
390 memcpy(player->captured.a[0], proved->a[0], yplane_size);
\r
391 memcpy(player->captured.a[1], proved->a[1], uvplane_size);
\r
396 case GST_MAKE_FOURCC ('I', '4', '2', '0'):
\r
398 src_fmt = MM_UTIL_IMG_FMT_I420;
\r
409 else if (gst_structure_has_name(structure, "video/x-raw-rgb"))
\r
415 gboolean bigendian = FALSE;
\r
416 gboolean isbluefirst = FALSE;
\r
419 * The followings will be considered.
\r
420 * RGBx, xRGB, BGRx, xBGR
\r
425 gst_structure_get_int (structure, "bpp", &bpp);
\r
426 gst_structure_get_int (structure, "depth", &depth);
\r
427 gst_structure_get_int (structure, "endianness", &endianess);
\r
428 gst_structure_get_int (structure, "blue_mask", &blue_mask);
\r
430 if (endianess == 4321)
\r
433 if (blue_mask == -16777216)
\r
434 isbluefirst = TRUE;
\r
443 if (bigendian && isbluefirst)
\r
444 src_fmt = MM_UTIL_IMG_FMT_BGRA8888;
\r
446 if (bigendian && isbluefirst)
\r
447 src_fmt = MM_UTIL_IMG_FMT_BGRX8888;
\r
468 __mm_player_convert_colorspace(player, GST_BUFFER_DATA(buffer), src_fmt, src_width, src_height, dst_fmt);
\r
471 /* do convert colorspace */
\r
472 g_cond_signal( player->capture_thread_cond );
\r
476 return MM_ERROR_NONE;
\r
479 debug_error("unknown format to capture\n");
\r
480 return MM_ERROR_PLAYER_INTERNAL;
\r
484 __mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data)
\r
486 mm_player_t* player = (mm_player_t*) u_data;
\r
487 int ret = MM_ERROR_NONE;
\r
489 return_val_if_fail ( buffer, FALSE);
\r
492 ret = __mmplayer_get_video_frame_from_buffer(player, buffer);
\r
494 if ( ret != MM_ERROR_NONE)
\r
496 debug_error("faild to get video frame. %x\n", ret);
\r
500 /* remove probe to be called at one time */
\r
501 if (player->video_capture_cb_probe_id)
\r
503 gst_pad_remove_buffer_probe (pad, player->video_capture_cb_probe_id);
\r
504 player->video_capture_cb_probe_id = 0;
\r
513 __mm_player_convert_colorspace(mm_player_t* player, unsigned char* src_data, mm_util_img_format src_fmt, unsigned int src_w, unsigned int src_h, mm_util_img_format dst_fmt)
\r
515 unsigned char *dst_data = NULL;
\r
516 unsigned int dst_size;
\r
517 int ret = MM_ERROR_NONE;
\r
519 return_val_if_fail(player, MM_ERROR_PLAYER_INTERNAL);
\r
520 ret = mm_util_get_image_size(dst_fmt, src_w, src_h, &dst_size);
\r
522 if (ret != MM_ERROR_NONE)
\r
524 debug_error("failed to get image size for capture, %d\n", ret);
\r
525 return MM_ERROR_PLAYER_INTERNAL;
\r
528 debug_log("width: %d, height: %d to capture, dest size: %d\n", src_w, src_h, dst_size);
\r
530 dst_data = (unsigned char*)g_malloc0(dst_size);
\r
534 debug_error("no free space to capture\n");
\r
535 return MM_ERROR_PLAYER_NO_FREE_SPACE;
\r
538 ret = mm_util_convert_colorspace(src_data, src_w, src_h, src_fmt, dst_data, dst_fmt);
\r
540 if (ret != MM_ERROR_NONE)
\r
542 debug_error("failed to convert for capture, %d\n", ret);
\r
543 return MM_ERROR_PLAYER_INTERNAL;
\r
546 player->capture.size = dst_size;
\r
547 player->capture.data = dst_data;
\r
549 return MM_ERROR_NONE;
\r
553 * Get tiled address of position(x,y)
\r
556 * width of tiled[in]
\r
559 * height of tiled[in]
\r
562 * x position of tield[in]
\r
565 * y position of tield[in]
\r
568 * address of tiled data
\r
571 __tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos)
\r
573 int pixel_x_m1, pixel_y_m1;
\r
574 int roundup_x, roundup_y;
\r
575 int linear_addr0, linear_addr1, bank_addr ;
\r
579 pixel_x_m1 = x_size -1;
\r
580 pixel_y_m1 = y_size -1;
\r
582 roundup_x = ((pixel_x_m1 >> 7) + 1);
\r
583 roundup_y = ((pixel_x_m1 >> 6) + 1);
\r
585 x_addr = x_pos >> 2;
\r
587 if ((y_size <= y_pos+32) && ( y_pos < y_size) &&
\r
588 (((pixel_y_m1 >> 5) & 0x1) == 0) && (((y_pos >> 5) & 0x1) == 0)) {
\r
589 linear_addr0 = (((y_pos & 0x1f) <<4) | (x_addr & 0xf));
\r
590 linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 6) & 0x3f));
\r
592 if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))
\r
593 bank_addr = ((x_addr >> 4) & 0x1);
\r
595 bank_addr = 0x2 | ((x_addr >> 4) & 0x1);
\r
597 linear_addr0 = (((y_pos & 0x1f) << 4) | (x_addr & 0xf));
\r
598 linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 5) & 0x7f));
\r
600 if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))
\r
601 bank_addr = ((x_addr >> 4) & 0x1);
\r
603 bank_addr = 0x2 | ((x_addr >> 4) & 0x1);
\r
606 linear_addr0 = linear_addr0 << 2;
\r
607 trans_addr = (linear_addr1 <<13) | (bank_addr << 11) | linear_addr0;
\r
613 * Converts tiled data to linear
\r
614 * Crops left, top, right, buttom
\r
615 * 1. Y of NV12T to Y of YUV420P
\r
616 * 2. Y of NV12T to Y of YUV420S
\r
617 * 3. UV of NV12T to UV of YUV420S
\r
619 * @param yuv420_dest
\r
620 * Y or UV plane address of YUV420[out]
\r
623 * Y or UV plane address of NV12T[in]
\r
625 * @param yuv420_width
\r
626 * Width of YUV420[in]
\r
628 * @param yuv420_height
\r
629 * Y: Height of YUV420, UV: Height/2 of YUV420[in]
\r
632 * Crop size of left
\r
638 * Crop size of right
\r
641 * Crop size of buttom
\r
644 __csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, int yuv420_width, int yuv420_height,
\r
645 int left, int top, int right, int buttom)
\r
648 int tiled_offset = 0, tiled_offset1 = 0;
\r
649 int linear_offset = 0;
\r
650 int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0;
\r
652 temp3 = yuv420_width-right;
\r
653 temp1 = temp3-left;
\r
654 /* real width is greater than or equal 256 */
\r
655 if (temp1 >= 256) {
\r
656 for (i=top; i<yuv420_height-buttom; i=i+1) {
\r
662 /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
\r
663 tiled_offset = temp4-1;
\r
664 temp1 = ((yuv420_width+127)>>7)<<7;
\r
665 tiled_offset = tiled_offset*(temp1>>6);
\r
666 tiled_offset = tiled_offset+temp3;
\r
667 tiled_offset = tiled_offset+2;
\r
668 temp1 = (temp3>>2)<<2;
\r
669 tiled_offset = tiled_offset+temp1;
\r
670 tiled_offset = tiled_offset<<11;
\r
671 tiled_offset1 = tiled_offset+2048*2;
\r
674 temp2 = ((yuv420_height+31)>>5)<<5;
\r
675 if ((i+32)<temp2) {
\r
676 /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
\r
678 temp1 = (temp1>>2)<<2;
\r
679 tiled_offset = temp3+temp1;
\r
680 temp1 = ((yuv420_width+127)>>7)<<7;
\r
681 tiled_offset = tiled_offset+temp4*(temp1>>6);
\r
682 tiled_offset = tiled_offset<<11;
\r
683 tiled_offset1 = tiled_offset+2048*6;
\r
686 /* even2 fomula: x+x_block_num*y */
\r
687 temp1 = ((yuv420_width+127)>>7)<<7;
\r
688 tiled_offset = temp4*(temp1>>6);
\r
689 tiled_offset = tiled_offset+temp3;
\r
690 tiled_offset = tiled_offset<<11;
\r
691 tiled_offset1 = tiled_offset+2048*2;
\r
697 tiled_offset = tiled_offset+64*(temp1);
\r
698 tiled_offset1 = tiled_offset1+64*(temp1);
\r
699 temp2 = yuv420_width-left-right;
\r
700 linear_offset = temp2*(i-top);
\r
701 temp3 = ((j+256)>>8)<<8;
\r
705 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+temp1, 64-temp1);
\r
706 temp2 = ((left+63)>>6)<<6;
\r
707 temp3 = ((yuv420_width-right)>>6)<<6;
\r
708 if (temp2 == temp3) {
\r
709 temp2 = yuv420_width-right-(64-temp1);
\r
711 memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset+2048, 64);
\r
712 memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1, 64);
\r
713 memcpy(yuv420_dest+linear_offset+192-temp1, nv12t_src+tiled_offset1+2048, 64);
\r
714 linear_offset = linear_offset+256-temp1;
\r
715 } else if (temp3 > 128) {
\r
716 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+2048+temp1, 64-temp1);
\r
717 memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1, 64);
\r
718 memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1+2048, 64);
\r
719 linear_offset = linear_offset+192-temp1;
\r
720 } else if (temp3 > 64) {
\r
721 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+temp1, 64-temp1);
\r
722 memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1+2048, 64);
\r
723 linear_offset = linear_offset+128-temp1;
\r
724 } else if (temp3 > 0) {
\r
725 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+2048+temp1, 64-temp1);
\r
726 linear_offset = linear_offset+64-temp1;
\r
729 tiled_offset = tiled_offset+temp4*2048;
\r
732 temp2 = yuv420_width-right-256;
\r
733 for (; j<=temp2; j=j+256) {
\r
734 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
735 tiled_offset1 = tiled_offset1+temp4*2048;
\r
736 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
\r
737 memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);
\r
738 tiled_offset = tiled_offset+temp4*2048;
\r
739 memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, 64);
\r
740 linear_offset = linear_offset+256;
\r
743 tiled_offset1 = tiled_offset1+temp4*2048;
\r
744 temp2 = yuv420_width-right-j;
\r
746 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
747 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
\r
748 memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);
\r
749 memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, temp2-192);
\r
750 } else if (temp2 > 128) {
\r
751 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
752 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
\r
753 memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, temp2-128);
\r
754 } else if (temp2 > 64) {
\r
755 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
756 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, temp2-64);
\r
758 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
\r
761 } else if (temp1 >= 64) {
\r
762 for (i=top; i<(yuv420_height-buttom); i=i+1) {
\r
764 tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
\r
765 temp2 = ((j+64)>>6)<<6;
\r
767 linear_offset = temp1*(i-top);
\r
769 tiled_offset = tiled_offset+temp4;
\r
770 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
\r
771 linear_offset = linear_offset+temp2;
\r
773 if ((j+64) <= temp3) {
\r
774 tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
\r
775 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
776 linear_offset = linear_offset+64;
\r
779 if ((j+64) <= temp3) {
\r
780 tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
\r
781 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
782 linear_offset = linear_offset+64;
\r
786 tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
\r
788 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
\r
792 for (i=top; i<(yuv420_height-buttom); i=i+1) {
\r
793 linear_offset = temp1*(i-top);
\r
794 for (j=left; j<(yuv420_width-right); j=j+2) {
\r
795 tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
\r
797 tiled_offset = tiled_offset+temp4;
\r
798 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 2);
\r
799 linear_offset = linear_offset+2;
\r