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>,
\r
7 * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
\r
9 * Licensed under the Apache License, Version 2.0 (the "License");
\r
10 * you may not use this file except in compliance with the License.
\r
11 * You may obtain a copy of the License at
\r
13 * http://www.apache.org/licenses/LICENSE-2.0
\r
15 * Unless required by applicable law or agreed to in writing, software
\r
16 * distributed under the License is distributed on an "AS IS" BASIS,
\r
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
18 * See the License for the specific language governing permissions and
\r
19 * limitations under the License.
\r
23 /*===========================================================================================
\r
27 ========================================================================================== */
\r
28 #include "mm_player_capture.h"
\r
29 #include "mm_player_priv.h"
\r
31 #include <mm_util_imgp.h>
\r
33 /*---------------------------------------------------------------------------
\r
34 | LOCAL VARIABLE DEFINITIONS for internal |
\r
35 ---------------------------------------------------------------------------*/
\r
37 /*---------------------------------------------------------------------------
\r
38 | LOCAL FUNCTION PROTOTYPES: |
\r
39 ---------------------------------------------------------------------------*/
\r
40 static gboolean __mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data);
\r
41 static int __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer);
\r
42 static void __mmplayer_capture_thread(gpointer data);
\r
43 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
44 static int __tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos);
\r
45 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
47 /*===========================================================================================
\r
49 | FUNCTION DEFINITIONS |
\r
51 ========================================================================================== */
\r
53 _mmplayer_initialize_video_capture(mm_player_t* player)
\r
55 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
\r
56 /* create capture mutex */
\r
57 player->capture_thread_mutex = g_mutex_new();
\r
58 if ( ! player->capture_thread_mutex )
\r
60 debug_critical("Cannot create capture mutex");
\r
64 /* create capture cond */
\r
65 player->capture_thread_cond = g_cond_new();
\r
66 if ( ! player->capture_thread_cond )
\r
68 debug_critical("Cannot create capture cond");
\r
72 player->capture_thread_exit = FALSE;
\r
74 /* create video capture thread */
\r
75 player->capture_thread =
\r
76 g_thread_create (__mmplayer_capture_thread, (gpointer)player, TRUE, NULL);
\r
77 if ( ! player->capture_thread )
\r
82 return MM_ERROR_NONE;
\r
85 /* capture thread */
\r
86 if ( player->capture_thread_mutex )
\r
87 g_mutex_free ( player->capture_thread_mutex );
\r
89 if ( player->capture_thread_cond )
\r
90 g_cond_free ( player->capture_thread_cond );
\r
92 return MM_ERROR_PLAYER_INTERNAL;
\r
96 _mmplayer_release_video_capture(mm_player_t* player)
\r
98 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
\r
99 /* release capture thread */
\r
100 if ( player->capture_thread_cond &&
\r
101 player->capture_thread_mutex &&
\r
102 player->capture_thread )
\r
104 g_mutex_lock(player->capture_thread_mutex);
\r
105 player->capture_thread_exit = TRUE;
\r
106 g_cond_signal( player->capture_thread_cond );
\r
107 g_mutex_unlock(player->capture_thread_mutex);
\r
109 debug_log("waitting for capture thread exit");
\r
110 g_thread_join ( player->capture_thread );
\r
111 g_mutex_free ( player->capture_thread_mutex );
\r
112 g_cond_free ( player->capture_thread_cond );
\r
113 debug_log("capture thread released");
\r
116 return MM_ERROR_NONE;
\r
120 _mmplayer_do_video_capture(MMHandleType hplayer)
\r
122 mm_player_t* player = (mm_player_t*) hplayer;
\r
123 int ret = MM_ERROR_NONE;
\r
124 GstPad *pad = NULL;
\r
128 return_val_if_fail(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
\r
130 /* capturing or not */
\r
131 if (player->video_capture_cb_probe_id || player->capture.data || player->captured.a[0] || player->captured.a[1])
\r
133 debug_warning("capturing... we can't do any more");
\r
134 return MM_ERROR_PLAYER_INVALID_STATE;
\r
137 /* check if video pipeline is linked or not */
\r
138 if (!player->pipeline->videobin || !player->sent_bos)
\r
140 debug_warning("not ready to capture");
\r
141 return MM_ERROR_PLAYER_INVALID_STATE;
\r
144 if (player->state != MM_PLAYER_STATE_PLAYING)
\r
146 if (player->state == MM_PLAYER_STATE_PAUSED) // get last buffer from video sink
\r
148 GstBuffer *buf = NULL;
\r
149 g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "last-buffer", &buf, NULL);
\r
153 ret = __mmplayer_get_video_frame_from_buffer(player, buf);
\r
154 gst_buffer_unref(buf);
\r
160 debug_warning("invalid state(%d) to capture", player->state);
\r
161 return MM_ERROR_PLAYER_INVALID_STATE;
\r
165 pad = gst_element_get_static_pad(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink" );
\r
167 /* register probe */
\r
168 player->video_capture_cb_probe_id = gst_pad_add_buffer_probe (pad,
\r
169 G_CALLBACK (__mmplayer_video_capture_probe), player);
\r
171 gst_object_unref(GST_OBJECT(pad));
\r
180 __mmplayer_capture_thread(gpointer data)
\r
182 mm_player_t* player = (mm_player_t*) data;
\r
183 MMMessageParamType msg = {0, };
\r
184 unsigned char * linear_y_plane = NULL;
\r
185 unsigned char * linear_uv_plane = NULL;
\r
187 return_if_fail (player);
\r
189 while (!player->capture_thread_exit)
\r
191 debug_log("capture thread started. waiting for signal");
\r
193 g_mutex_lock(player->capture_thread_mutex);
\r
194 g_cond_wait( player->capture_thread_cond, player->capture_thread_mutex );
\r
196 if ( player->capture_thread_exit )
\r
198 debug_log("exiting capture thread");
\r
201 debug_log("capture thread is recieved signal");
\r
203 /* NOTE: Don't use MMPLAYER_CMD_LOCK() here.
\r
204 * Because deadlock can be happened if other player api is used in message callback.
\r
206 if (player->video_cs == MM_PLAYER_COLORSPACE_NV12_TILED)
\r
208 /* Colorspace conversion : NV12T-> NV12-> RGB888 */
\r
210 int linear_y_plane_size;
\r
211 int linear_uv_plane_size;
\r
212 unsigned char * src_buffer = NULL;
\r
214 debug_log("w[0]=%d, w[1]=%d", player->captured.w[0], player->captured.w[1]);
\r
215 debug_log("h[0]=%d, h[1]=%d", player->captured.h[0], player->captured.h[1]);
\r
216 debug_log("s[0]=%d, s[1]=%d", player->captured.s[0], player->captured.s[1]);
\r
217 debug_log("e[0]=%d, e[1]=%d", player->captured.e[0], player->captured.e[1]);
\r
218 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
232 linear_y_plane_size = (player->captured.w[0] * player->captured.h[0]);
\r
233 linear_uv_plane_size = (player->captured.w[0] * player->captured.h[0]/2);
\r
235 linear_y_plane = (unsigned char*) g_try_malloc(linear_y_plane_size);
\r
236 if (linear_y_plane == NULL)
\r
238 msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;
\r
242 linear_uv_plane = (unsigned char*) g_try_malloc(linear_uv_plane_size);
\r
243 if (linear_uv_plane == NULL)
\r
245 msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;
\r
248 /* NV12 tiled to linear */
\r
249 __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
250 __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
252 MMPLAYER_FREEIF(player->captured.a[0]);
\r
253 MMPLAYER_FREEIF(player->captured.a[1]);
\r
255 src_buffer = (unsigned char*) g_try_malloc(linear_y_plane_size+linear_uv_plane_size);
\r
257 if (src_buffer == NULL)
\r
259 msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;
\r
262 memset(src_buffer, 0x00, sizeof(linear_y_plane_size+linear_uv_plane_size));
\r
263 memcpy(src_buffer, linear_y_plane, linear_y_plane_size);
\r
264 memcpy(src_buffer+linear_y_plane_size, linear_uv_plane, linear_uv_plane_size);
\r
266 /* NV12 linear to RGB888 */
\r
267 ret = __mm_player_convert_colorspace(player, src_buffer, MM_UTIL_IMG_FMT_NV12,
\r
268 player->captured.w[0], player->captured.h[0], MM_UTIL_IMG_FMT_RGB888);
\r
270 if (ret != MM_ERROR_NONE)
\r
272 debug_error("failed to convert nv12 linear");
\r
276 MMPLAYER_FREEIF(src_buffer);
\r
277 MMPLAYER_FREEIF(linear_y_plane);
\r
278 MMPLAYER_FREEIF(linear_uv_plane);
\r
281 player->capture.fmt = MM_PLAYER_COLORSPACE_RGB888;
\r
282 msg.data = &player->capture;
\r
283 msg.size = player->capture.size;
\r
285 if (player->cmd >= MMPLAYER_COMMAND_START)
\r
287 MMPLAYER_POST_MSG( player, MM_MESSAGE_VIDEO_CAPTURED, &msg );
\r
288 debug_log("returned from capture message callback");
\r
291 g_mutex_unlock(player->capture_thread_mutex);
\r
293 //MMPLAYER_FREEIF(player->capture.data);
\r
296 if (player->video_cs == MM_PLAYER_COLORSPACE_NV12_TILED)
\r
299 MMPLAYER_FREEIF(linear_y_plane);
\r
300 MMPLAYER_FREEIF(linear_uv_plane);
\r
301 MMPLAYER_FREEIF(player->captured.a[0]);
\r
302 MMPLAYER_FREEIF(player->captured.a[1]);
\r
305 msg.union_type = MM_MSG_UNION_CODE;
\r
307 g_mutex_unlock(player->capture_thread_mutex);
\r
308 MMPLAYER_POST_MSG( player, MM_MESSAGE_VIDEO_NOT_CAPTURED, &msg );
\r
312 g_mutex_unlock(player->capture_thread_mutex);
\r
317 * The output is fixed as RGB888
\r
320 __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer)
\r
322 gint yplane_size = 0;
\r
323 gint uvplane_size = 0;
\r
324 gint src_width = 0;
\r
325 gint src_height = 0;
\r
326 guint32 fourcc = 0;
\r
327 GstCaps *caps = NULL;
\r
328 GstStructure *structure = NULL;
\r
329 mm_util_img_format src_fmt = MM_UTIL_IMG_FMT_YUV420;
\r
330 mm_util_img_format dst_fmt = MM_UTIL_IMG_FMT_RGB888; // fixed
\r
334 return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
\r
335 return_val_if_fail ( buffer, MM_ERROR_INVALID_ARGUMENT );
\r
338 caps = GST_BUFFER_CAPS(buffer);
\r
340 return_val_if_fail ( caps, MM_ERROR_INVALID_ARGUMENT );
\r
341 debug_log("caps to capture: %s\n", gst_caps_to_string(caps));
\r
343 structure = gst_caps_get_structure (caps, 0);
\r
345 return_val_if_fail (structure != NULL, MM_ERROR_PLAYER_INTERNAL);
\r
347 /* init capture image buffer */
\r
348 memset(&player->capture, 0x00, sizeof(MMPlayerVideoCapture));
\r
350 gst_structure_get_int (structure, "width", &src_width);
\r
351 gst_structure_get_int (structure, "height", &src_height);
\r
353 /* check rgb or yuv */
\r
354 if (gst_structure_has_name(structure, "video/x-raw-yuv"))
\r
356 gst_structure_get_fourcc (structure, "format", &fourcc);
\r
361 case GST_MAKE_FOURCC ('S', 'T', '1', '2'):
\r
363 debug_msg ("captured format is ST12\n");
\r
365 MMPlayerMPlaneImage *proved = NULL;
\r
366 player->video_cs = MM_PLAYER_COLORSPACE_NV12_TILED;
\r
368 /* get video frame info from proved buffer */
\r
369 proved = (MMPlayerMPlaneImage *)GST_BUFFER_MALLOCDATA(buffer);
\r
371 if ( !proved || !proved->a[0] || !proved->a[1] )
\r
372 return MM_ERROR_PLAYER_INTERNAL;
\r
374 yplane_size = (proved->s[0] * proved->e[0]);
\r
375 uvplane_size = (proved->s[1] * proved->e[1]);
\r
377 memset(&player->captured, 0x00, sizeof(MMPlayerMPlaneImage));
\r
378 memcpy(&player->captured, proved, sizeof(MMPlayerMPlaneImage));
\r
380 player->captured.a[0] = g_try_malloc(yplane_size);
\r
381 if ( !player->captured.a[0] )
\r
382 return MM_ERROR_SOUND_NO_FREE_SPACE;
\r
384 player->captured.a[1] = g_try_malloc(uvplane_size);
\r
385 if ( !player->captured.a[1] )
\r
386 return MM_ERROR_SOUND_NO_FREE_SPACE;
\r
388 memcpy(player->captured.a[0], proved->a[0], yplane_size);
\r
389 memcpy(player->captured.a[1], proved->a[1], uvplane_size);
\r
394 case GST_MAKE_FOURCC ('I', '4', '2', '0'):
\r
396 src_fmt = MM_UTIL_IMG_FMT_I420;
\r
407 else if (gst_structure_has_name(structure, "video/x-raw-rgb"))
\r
413 gboolean bigendian = FALSE;
\r
414 gboolean isbluefirst = FALSE;
\r
417 * The followings will be considered.
\r
418 * RGBx, xRGB, BGRx, xBGR
\r
423 gst_structure_get_int (structure, "bpp", &bpp);
\r
424 gst_structure_get_int (structure, "depth", &depth);
\r
425 gst_structure_get_int (structure, "endianness", &endianess);
\r
426 gst_structure_get_int (structure, "blue_mask", &blue_mask);
\r
428 if (endianess == 4321)
\r
431 if (blue_mask == -16777216)
\r
432 isbluefirst = TRUE;
\r
441 if (bigendian && isbluefirst)
\r
442 src_fmt = MM_UTIL_IMG_FMT_BGRX8888;
\r
463 __mm_player_convert_colorspace(player, GST_BUFFER_DATA(buffer), src_fmt, src_width, src_height, dst_fmt);
\r
466 /* do convert colorspace */
\r
467 g_cond_signal( player->capture_thread_cond );
\r
471 return MM_ERROR_NONE;
\r
474 debug_error("unknown format to capture\n");
\r
475 return MM_ERROR_PLAYER_INTERNAL;
\r
479 __mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data)
\r
481 mm_player_t* player = (mm_player_t*) u_data;
\r
482 int ret = MM_ERROR_NONE;
\r
484 return_val_if_fail ( buffer, FALSE);
\r
487 ret = __mmplayer_get_video_frame_from_buffer(player, buffer);
\r
489 if ( ret != MM_ERROR_NONE)
\r
491 debug_error("faild to get video frame. %x\n", ret);
\r
495 /* remove probe to be called at one time */
\r
496 if (player->video_capture_cb_probe_id)
\r
498 gst_pad_remove_buffer_probe (pad, player->video_capture_cb_probe_id);
\r
499 player->video_capture_cb_probe_id = 0;
\r
508 __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
510 unsigned char *dst_data = NULL;
\r
511 unsigned int dst_size;
\r
512 int ret = MM_ERROR_NONE;
\r
514 return_val_if_fail(player, MM_ERROR_PLAYER_INTERNAL);
\r
515 ret = mm_util_get_image_size(dst_fmt, src_w, src_h, &dst_size);
\r
517 if (ret != MM_ERROR_NONE)
\r
519 debug_error("failed to get image size for capture, %d\n", ret);
\r
520 return MM_ERROR_PLAYER_INTERNAL;
\r
523 debug_log("width: %d, height: %d to capture, dest size: %d\n", src_w, src_h, dst_size);
\r
525 dst_data = (unsigned char*)g_malloc0(dst_size);
\r
529 debug_error("no free space to capture\n");
\r
530 return MM_ERROR_PLAYER_NO_FREE_SPACE;
\r
533 ret = mm_util_convert_colorspace(src_data, src_w, src_h, src_fmt, dst_data, dst_fmt);
\r
535 if (ret != MM_ERROR_NONE)
\r
537 debug_error("failed to convert for capture, %d\n", ret);
\r
538 return MM_ERROR_PLAYER_INTERNAL;
\r
541 player->capture.size = dst_size;
\r
542 player->capture.data = dst_data;
\r
544 return MM_ERROR_NONE;
\r
548 * Get tiled address of position(x,y)
\r
551 * width of tiled[in]
\r
554 * height of tiled[in]
\r
557 * x position of tield[in]
\r
560 * y position of tield[in]
\r
563 * address of tiled data
\r
566 __tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos)
\r
568 int pixel_x_m1, pixel_y_m1;
\r
569 int roundup_x, roundup_y;
\r
570 int linear_addr0, linear_addr1, bank_addr ;
\r
574 pixel_x_m1 = x_size -1;
\r
575 pixel_y_m1 = y_size -1;
\r
577 roundup_x = ((pixel_x_m1 >> 7) + 1);
\r
578 roundup_y = ((pixel_x_m1 >> 6) + 1);
\r
580 x_addr = x_pos >> 2;
\r
582 if ((y_size <= y_pos+32) && ( y_pos < y_size) &&
\r
583 (((pixel_y_m1 >> 5) & 0x1) == 0) && (((y_pos >> 5) & 0x1) == 0)) {
\r
584 linear_addr0 = (((y_pos & 0x1f) <<4) | (x_addr & 0xf));
\r
585 linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 6) & 0x3f));
\r
587 if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))
\r
588 bank_addr = ((x_addr >> 4) & 0x1);
\r
590 bank_addr = 0x2 | ((x_addr >> 4) & 0x1);
\r
592 linear_addr0 = (((y_pos & 0x1f) << 4) | (x_addr & 0xf));
\r
593 linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 5) & 0x7f));
\r
595 if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))
\r
596 bank_addr = ((x_addr >> 4) & 0x1);
\r
598 bank_addr = 0x2 | ((x_addr >> 4) & 0x1);
\r
601 linear_addr0 = linear_addr0 << 2;
\r
602 trans_addr = (linear_addr1 <<13) | (bank_addr << 11) | linear_addr0;
\r
608 * Converts tiled data to linear
\r
609 * Crops left, top, right, buttom
\r
610 * 1. Y of NV12T to Y of YUV420P
\r
611 * 2. Y of NV12T to Y of YUV420S
\r
612 * 3. UV of NV12T to UV of YUV420S
\r
614 * @param yuv420_dest
\r
615 * Y or UV plane address of YUV420[out]
\r
618 * Y or UV plane address of NV12T[in]
\r
620 * @param yuv420_width
\r
621 * Width of YUV420[in]
\r
623 * @param yuv420_height
\r
624 * Y: Height of YUV420, UV: Height/2 of YUV420[in]
\r
627 * Crop size of left
\r
633 * Crop size of right
\r
636 * Crop size of buttom
\r
639 __csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, int yuv420_width, int yuv420_height,
\r
640 int left, int top, int right, int buttom)
\r
643 int tiled_offset = 0, tiled_offset1 = 0;
\r
644 int linear_offset = 0;
\r
645 int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0;
\r
647 temp3 = yuv420_width-right;
\r
648 temp1 = temp3-left;
\r
649 /* real width is greater than or equal 256 */
\r
650 if (temp1 >= 256) {
\r
651 for (i=top; i<yuv420_height-buttom; i=i+1) {
\r
657 /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
\r
658 tiled_offset = temp4-1;
\r
659 temp1 = ((yuv420_width+127)>>7)<<7;
\r
660 tiled_offset = tiled_offset*(temp1>>6);
\r
661 tiled_offset = tiled_offset+temp3;
\r
662 tiled_offset = tiled_offset+2;
\r
663 temp1 = (temp3>>2)<<2;
\r
664 tiled_offset = tiled_offset+temp1;
\r
665 tiled_offset = tiled_offset<<11;
\r
666 tiled_offset1 = tiled_offset+2048*2;
\r
669 temp2 = ((yuv420_height+31)>>5)<<5;
\r
670 if ((i+32)<temp2) {
\r
671 /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
\r
673 temp1 = (temp1>>2)<<2;
\r
674 tiled_offset = temp3+temp1;
\r
675 temp1 = ((yuv420_width+127)>>7)<<7;
\r
676 tiled_offset = tiled_offset+temp4*(temp1>>6);
\r
677 tiled_offset = tiled_offset<<11;
\r
678 tiled_offset1 = tiled_offset+2048*6;
\r
681 /* even2 fomula: x+x_block_num*y */
\r
682 temp1 = ((yuv420_width+127)>>7)<<7;
\r
683 tiled_offset = temp4*(temp1>>6);
\r
684 tiled_offset = tiled_offset+temp3;
\r
685 tiled_offset = tiled_offset<<11;
\r
686 tiled_offset1 = tiled_offset+2048*2;
\r
692 tiled_offset = tiled_offset+64*(temp1);
\r
693 tiled_offset1 = tiled_offset1+64*(temp1);
\r
694 temp2 = yuv420_width-left-right;
\r
695 linear_offset = temp2*(i-top);
\r
696 temp3 = ((j+256)>>8)<<8;
\r
700 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+temp1, 64-temp1);
\r
701 temp2 = ((left+63)>>6)<<6;
\r
702 temp3 = ((yuv420_width-right)>>6)<<6;
\r
703 if (temp2 == temp3) {
\r
704 temp2 = yuv420_width-right-(64-temp1);
\r
706 memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset+2048, 64);
\r
707 memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1, 64);
\r
708 memcpy(yuv420_dest+linear_offset+192-temp1, nv12t_src+tiled_offset1+2048, 64);
\r
709 linear_offset = linear_offset+256-temp1;
\r
710 } else if (temp3 > 128) {
\r
711 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+2048+temp1, 64-temp1);
\r
712 memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1, 64);
\r
713 memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1+2048, 64);
\r
714 linear_offset = linear_offset+192-temp1;
\r
715 } else if (temp3 > 64) {
\r
716 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+temp1, 64-temp1);
\r
717 memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1+2048, 64);
\r
718 linear_offset = linear_offset+128-temp1;
\r
719 } else if (temp3 > 0) {
\r
720 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+2048+temp1, 64-temp1);
\r
721 linear_offset = linear_offset+64-temp1;
\r
724 tiled_offset = tiled_offset+temp4*2048;
\r
727 temp2 = yuv420_width-right-256;
\r
728 for (; j<=temp2; j=j+256) {
\r
729 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
730 tiled_offset1 = tiled_offset1+temp4*2048;
\r
731 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
\r
732 memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);
\r
733 tiled_offset = tiled_offset+temp4*2048;
\r
734 memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, 64);
\r
735 linear_offset = linear_offset+256;
\r
738 tiled_offset1 = tiled_offset1+temp4*2048;
\r
739 temp2 = yuv420_width-right-j;
\r
741 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
742 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
\r
743 memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);
\r
744 memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, temp2-192);
\r
745 } else if (temp2 > 128) {
\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, temp2-128);
\r
749 } else if (temp2 > 64) {
\r
750 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
751 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, temp2-64);
\r
753 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
\r
756 } else if (temp1 >= 64) {
\r
757 for (i=top; i<(yuv420_height-buttom); i=i+1) {
\r
759 tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
\r
760 temp2 = ((j+64)>>6)<<6;
\r
762 linear_offset = temp1*(i-top);
\r
764 tiled_offset = tiled_offset+temp4;
\r
765 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
\r
766 linear_offset = linear_offset+temp2;
\r
768 if ((j+64) <= temp3) {
\r
769 tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
\r
770 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
771 linear_offset = linear_offset+64;
\r
774 if ((j+64) <= temp3) {
\r
775 tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
\r
776 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
\r
777 linear_offset = linear_offset+64;
\r
781 tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
\r
783 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
\r
787 for (i=top; i<(yuv420_height-buttom); i=i+1) {
\r
788 linear_offset = temp1*(i-top);
\r
789 for (j=left; j<(yuv420_width-right); j=j+2) {
\r
790 tiled_offset = __tile_4x2_read(yuv420_width, yuv420_height, j, i);
\r
792 tiled_offset = tiled_offset+temp4;
\r
793 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 2);
\r
794 linear_offset = linear_offset+2;
\r