xref: /utopia/UTPA2-700.0.x/modules/mfe/api/mfe_ex/yuvgen.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 //    Software and any modification/derivatives thereof.
18 //    No right, ownership, or interest to MStar Software and any
19 //    modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 //    supplied together with third party`s software and the use of MStar
23 //    Software may require additional licenses from third parties.
24 //    Therefore, you hereby agree it is your sole responsibility to separately
25 //    obtain any and all third party right and license necessary for your use of
26 //    such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 //    MStar`s confidential information and you agree to keep MStar`s
30 //    confidential information in strictest confidence and not disclose to any
31 //    third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35 //    without limitation, any warranties of merchantability, non-infringement of
36 //    intellectual property rights, fitness for a particular purpose, error free
37 //    and in conformity with any international standard.  You agree to waive any
38 //    claim against MStar for any loss, damage, cost or expense that you may
39 //    incur related to your use of MStar Software.
40 //    In no event shall MStar be liable for any direct, indirect, incidental or
41 //    consequential damages, including without limitation, lost of profit or
42 //    revenues, lost or damage of data, and unauthorized system use.
43 //    You agree that this Section 4 shall still apply without being affected
44 //    even if MStar Software has been modified by MStar in accordance with your
45 //    request or instruction for your use, except otherwise agreed by both
46 //    parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 //    services in relation with MStar Software to you for your use of
50 //    MStar Software in conjunction with your or your customer`s product
51 //    ("Services").
52 //    You understand and agree that, except otherwise agreed by both parties in
53 //    writing, Services are provided on an "AS IS" basis and the warranty
54 //    disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 //    or otherwise:
58 //    (a) conferring any license or right to use MStar name, trademark, service
59 //        mark, symbol or any other identification;
60 //    (b) obligating MStar or any of its affiliates to furnish any person,
61 //        including without limitation, you and your customers, any assistance
62 //        of any kind whatsoever, or any information; or
63 //    (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 //    of Taiwan, R.O.C., excluding its conflict of law rules.
67 //    Any and all dispute arising out hereof or related hereto shall be finally
68 //    settled by arbitration referred to the Chinese Arbitration Association,
69 //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 //    Rules of the Association by three (3) arbitrators appointed in accordance
71 //    with the said Rules.
72 //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73 //    be English.
74 //    The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2006-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // (�uMStar Confidential Information�v) by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94 
95 #include "mdrv_mfe_io.h"
96 #include "MFE_chip.h"
97 //#include <linux/string.h>
98 //#else
99 #ifndef __UBOOT__
100 #include <stdio.h>
101 #include <string.h>
102 #include <sys/types.h>
103 #endif
104 //#include "madp_ms_dprintf.h"
105 
106 #define U8 MS_U8
107 #define U32 MS_U32
108 
109 MS_U8 *YUV = 0;    // yuv buffer start point
110 MS_U8 *TILE = 0;    // yuv buffer start point
111 
112 void copy8pixel(MS_U8 *p);
113 void YuvGen(MS_U8 seed, MS_S32 width, MS_S32 height, volatile MS_U8 *buff);
114 void YuvGen_422(MS_U8 seed, MS_S32 width, MS_S32 height, volatile MS_U8 *buff);
115 
116 #ifdef _MAIN_
117 
118 #define MFE_DEBUG //x
119 
120 FILE *fp;
121 void (*do_copy)(MS_U8 *) ;
122 static MS_U8 *ptrInTileFormat;
123 MS_S32 debug = 0;
124 
125 MS_S32 W = 720;
126 MS_S32 H = 480;
127 
128 
129 #define YUV_LEN 50UL
130 
main(MS_S32 argc,MS_S8 * argv[])131 main(MS_S32 argc, MS_S8 *argv[])
132 {
133 
134 #if 0
135 	MS_S32 i;
136 	YUV = (MS_U8 *) malloc( W * H * 1.5 );
137 	TILE = (MS_U8 *) malloc( W * H * 1.5 );
138 
139 	fp = fopen(argv[1], "w");
140 	if( fp == NULL || YUV == NULL || TILE == NULL ) exit(-1);
141 
142 	do_copy = copy8pixel;
143 
144 	for( i = 0 ; i < YUV_LEN ; i ++ ) {
145 		ptrInTileFormat = TILE;
146 		YuvGen( 100 +i*5, W, H, TILE );
147 		ConvertYuvFromTile(W,H,0, YUV);
148 		ConvertYuvFromTile(W,H,1, YUV);
149 		fwrite(YUV, W * H * 1.5 , 1 , fp);
150 	}
151 
152 	fclose(fp);
153 	free(YUV);
154 	free(TILE);
155 #else
156 	MS_S32 i;
157 	FILE *fpr= NULL;
158 	YUV = (MS_U8 *) malloc( W * H * 1.5 );
159 	TILE = (MS_U8 *) malloc( W * H * 1.5 );
160 	fp = fopen(argv[1], "wb");
161 	fpr = fopen(argv[2], "rb");
162 	if( fpr == NULL || fp == NULL || YUV == NULL || TILE == NULL ) exit(-1);
163 
164 	do_copy = copy8pixel;
165 
166 	while( fread(TILE, W * H * 1.5, 1, fpr) > 0 ) {
167 		ptrInTileFormat = TILE;
168 		ConvertYuvFromTile(W,H,0, YUV);
169 		ConvertYuvFromTile(W,H,1, YUV);
170 		fwrite(YUV, W * H * 1.5 , 1 , fp);
171 
172 	}
173 
174 #endif
175 }
176 
177 
178 
179 
180 
copy8pixel(MS_U8 * p)181 void copy8pixel(MS_U8 *p)
182 {
183 	MS_S32 i ;
184 	for(i = 0; i < 8; i ++ ) {
185 		*p++ = *ptrInTileFormat++;
186 	}
187 }
188 
189 
copy_row(MS_U8 * p)190 void copy_row(MS_U8 *p)
191 {
192 	MS_U8 buff[512];
193 
194 	MS_U8 tmpbuf[9];
195 
196 	MS_S32 i,j;
197 
198 	if( fgets(buff,512,fp) != NULL )
199 	{
200 
201 		for( j = 0; j < 8 ; j ++ ) {
202 			MS_U8 tmp = 0;
203 			for( i = 0; i < 8 ; i ++ ) {
204 				// MS_U8 k = buff[j*8+i] - '0';
205 				MS_U8 k = buff[(7-j)*8+i] - '0';
206 				if( k != 0 && k != 1 )  {
207 					printf("Err inupt\n");
208 					exit(-3);
209 				}
210 				tmp <<= 1;
211 				tmp |= k;
212 			}
213 			p[j] = tmp;
214 
215 			if( debug ) fprintf(stderr,"%4d",p[j]);
216 		}
217 		if( debug ) fprintf(stderr,"\r\n");
218 	}
219 	else {
220 		printf("read failure\n");
221 		exit(-4);
222 	}
223 }
224 
225 
226 // copy_row2 is used to verify the binary format
copy_row2(MS_U8 * p)227 void copy_row2(MS_U8 *p)
228 {
229 	if( fread(p, 8,1,fp) == 0 )  {
230 		printf("read error in fread\n");
231 		return ;
232 	}
233 }
234 
235 #endif
236 
ConvertYuvFromTile(MS_S32 width,MS_S32 height,MS_S32 mode,MS_U8 * in_yuv,MS_U8 * out_yuv)237 void ConvertYuvFromTile(MS_S32 width, MS_S32 height, MS_S32 mode, MS_U8 *in_yuv, MS_U8 *out_yuv)
238 {
239 
240 	MS_S32 mbx, mby;
241 	MS_S32 image_x, image_x2;
242 	MS_S32 MB_in_width, MB_in_height;
243 	MS_S32 k,l,lumstart,chrstart;
244 	MS_U8 *y_point, *u_point, *v_point;
245 	MS_U8 *y_point2;
246 	MS_U8 *blk_point;
247 	MS_S32 blk, row;
248 
249 	image_x = width;
250 
251 	MB_in_width  = width >> 4 ;
252 	MB_in_height = height >> 4 ;
253 
254 	if( mode == 0 ) {  // Y component
255 		for (mby = 0; mby < MB_in_height; mby++)
256 		{
257 			for (mbx = 0; mbx < MB_in_width; mbx++)
258 			{
259 				k = mby * image_x << 4 /* * MB_SIZE*/;
260 				l = mbx << 4/** MB_SIZE*/;
261 				lumstart =k+l;
262 
263 				y_point = out_yuv + lumstart;
264 				y_point2 = y_point + (image_x << 3) /** 8 */;
265 				for (blk = 0; blk < 4; blk++)
266 				{
267 					blk_point = (blk>>1)? y_point2 : y_point;
268 					blk_point += (blk&1)? 8/*B_SIZE*/ : 0;
269 
270 					for (row = 0; row < 8; row++)
271 					{
272 						// fwrite(blk_point, 8, 1, fp);
273 						//do_copy(blk_point); /* 8 points  */
274 						memcpy(blk_point, in_yuv, 8);
275 //                        ms_dprintk(DRV_L3,"0x%x 0x%x %d %d %d %d %d %d %d %d\n", (U32)blk_point, (U32)in_yuv, in_yuv[0], in_yuv[1]
276 //                            , in_yuv[2], in_yuv[3], blk_point[0], blk_point[1], blk_point[2], blk_point[3]);
277 						blk_point += image_x;
278                         in_yuv += 8;
279 					}
280 				}
281 			}
282 		}
283 	}
284 	else { /* U & V */
285 		image_x2 = image_x >> 1 ;
286 		for (mby = 0; mby < MB_in_height; mby++)
287 		{
288 			for (mbx = 0; mbx < MB_in_width; mbx++)
289 			{
290 				k= mby * image_x << 4 /* * MB_SIZE*/;
291 				l= mbx << 4   /** MB_SIZE*/;
292 				chrstart =(k>>2)+(l>>1);
293 
294 				u_point = out_yuv + width * height + chrstart;
295 				v_point = out_yuv + width * height + ( width >> 1 ) * ( height >> 1 )  + chrstart;
296 
297 				for (blk = 0; blk < 2; blk++) // U block then V block..
298 				{
299 					blk_point = ( blk == 0 ) ? u_point : v_point;
300 
301 					for (row = 0; row < 8; row++)
302 					{
303 						//for (col = 0; col < 8; col++)
304 						//{
305 							//mem_uv_point[col] = blk_point[col];
306 						//}
307 //						do_copy(blk_point);
308 						memcpy(blk_point, in_yuv, 8);
309 						blk_point += image_x2;
310                         in_yuv += 8;
311 					}
312 				}
313 			}
314 		}
315 	}
316 }
317 
318 
319 #if 0
320 main(MS_S32 argc, MS_S8 *argv[])
321 {
322 	FILE *fpout = NULL;
323 	MS_S32 width;
324 	MS_S32 height;
325 
326 	MS_S8 buff[512];
327 	MS_U32 num[8];
328 
329 	MS_S32 i = 0;
330 	MS_S32 j = 0;
331 	MS_S32 m = 0;
332 
333 	if( argc < 3 )  {
334 		printf("%s width height input_y input_c out.yuv\n",argv[0]);
335 		exit(-1);
336 	}
337 	width  = atoi(argv[1]);
338 	height = atoi(argv[2]);
339 
340 	fp = fopen(argv[3], "r");
341 	if( fp == NULL) exit(-1);
342 
343 	fpout = fopen(argv[5], "w");
344 	if( fpout == NULL) exit(-1);
345 
346 	yuv = ( MS_U8 *) malloc( width * height * 1.5 ) ;
347 	if( yuv == NULL ) {
348 		printf("malloc fail");
349 		exit(-5);
350 	}
351 
352 	// do_copy = copy_row2;
353 	do_copy = copy_row;
354 
355     gogo(width,height,0);
356 	fclose(fp);
357 
358 	debug = 1;
359 	fopen( argv[4] , "rb");
360 	if( fp == NULL) {ms_dprintk(DRV_L1,"open %s failure\n",argv[4]); exit(-1); }
361     gogo(width,height,1);
362 	fclose(fp);
363 
364 	fwrite(yuv, width * height * 1.5 , 1 , fpout);
365 
366 	fclose(fpout);
367 	free(yuv);
368 }
369 #endif
370 
YuvGen(MS_U8 seed,MS_S32 width,MS_S32 height,volatile MS_U8 * buff)371 void YuvGen(MS_U8 seed, MS_S32 width, MS_S32 height, volatile MS_U8 *buff)
372 {
373 	MS_S32 i, j,k,m,n;
374 
375 	MS_S32 inc = 5 ;
376 	MS_S32 MB_width = width >> 4;
377 	MS_S32 MB_height = height >> 4 ;
378 
379 	//ms_dprintf(ADP_L1,"YuvGen begin: MB_width: %d MB_height: %d seed:%d\n",MB_width, MB_height,seed);
380 
381     // Y component
382 
383 	for( i = 0; i < MB_height ; i ++ ) {
384 		for( j = 0; j < MB_width ; j ++ ) {
385 			for( m = 0; m < 4 ; m ++ ) {  // 4 block
386                 for( k = 0; k < 8 ; k ++ ) {
387                     for( n = 0; n < 8; n ++ )
388                         *buff++ = seed;
389                 }
390             }
391             if( inc ) {
392                 seed += inc ;
393                 if( seed >= 255 ) seed = 0;
394 			}
395 //			printf("buff addr: 0x%x block[%2d][%2d][%d]\n",(U32)buff,i,j,m);
396 		}
397 	}
398     //MFE_DEBUG(printf("UV component begin\n"));
399     // U V component
400     height <<= 1 ;
401     width <<= 1 ;
402 
403 	for( i = 0; i < MB_height ; i ++ ) {
404 		for( j = 0; j < MB_width ; j ++ ) {
405 			for( k = 0; k < 8 ; k ++ ) {    // U
406                 for( n = 0; n < 8; n ++ ) {
407                     //*buff++ = seed;
408                     *buff = seed;
409                     buff++;
410                 }
411 			}
412 			for( k = 0; k < 8 ; k ++ ) {    // V
413                 for( n = 0; n < 8; n ++ ) {
414                     //*buff++ = seed;
415                     *buff = seed;
416                     buff++;
417                 }
418 			}
419 			if( inc ) {
420 				seed += inc ;
421 				if( seed >= 255 ) seed = 0;
422 			}
423 		}
424 	}
425     //ms_dprintf(ADP_L1,"YuvGen Done. seed:%d\n",seed);
426 }
427 
YuvGen_422(MS_U8 seed,MS_S32 width,MS_S32 height,volatile MS_U8 * buff)428 void YuvGen_422(MS_U8 seed, MS_S32 width, MS_S32 height, volatile MS_U8 *buff)
429 {
430 	MS_S32 i, j,k,m,n;
431 
432 	MS_S32 inc = 5 ;
433 	MS_S32 MB_width = width >> 4 ;
434 	MS_S32 MB_height = height >> 4 ;
435 
436 	//ms_dprintf(ADP_L1,"YuvGen begin: MB_width: %d MB_height: %d seed:%d\n",MB_width, MB_height,seed);
437 
438 	// Y component
439 
440 	for( i = 0; i < MB_height ; i ++ ) {
441 		for( j = 0; j < MB_width ; j ++ ) {
442 			for( m = 0; m < 4 ; m ++ ) {  // 4 block
443 				for( k = 0; k < 8 ; k ++ ) {
444 					for( n = 0; n < 8; n ++ )
445                         *buff++ = seed;
446 				}
447 			}
448 			if( inc ) {
449 				seed += inc ;
450 				if( seed >= 255 ) seed = 0;
451 			}
452 //			printf("buff addr: 0x%x block[%2d][%2d][%d]\n",(U32)buff,i,j,m);
453 		}
454 	}
455 	//ms_dprintf(ADP_L1,"UV component begin\n");
456 	// U V component
457 	width <<= 1 ;
458 
459 	for( i = 0; i < MB_height ; i ++ ) {
460 		for( j = 0; j < MB_width ; j ++ ) {
461 			for( k = 0; k < 16 ; k ++ ) {    // U
462 				for( n = 0; n < 8; n ++ )
463                     *buff++ = seed;
464 			}
465 
466 			for( k = 0; k < 16 ; k ++ ) {    // V
467 				for( n = 0; n < 8; n ++ )
468                     *buff++ = seed;
469 			}
470 			if( inc ) {
471 				seed += inc ;
472 				if( seed >= 255 ) seed = 0;
473 			}
474 		}
475 	}
476 	//ms_dprintf(ADP_L1,"YuvGen Done. seed:%d\n",seed);
477 }
478 
479 #define CEILING_ALIGN(value, align) (((MS_U32)(value)+((align)-1UL)) & ~((align)-1UL))
480 
PutTileY(MS_U8 * pY,MS_U8 * pDst,MS_S32 nStride,MS_S32 nMaxX,MS_S32 nMaxY)481 static void PutTileY(MS_U8 *pY, MS_U8 *pDst, MS_S32 nStride, MS_S32 nMaxX, MS_S32 nMaxY)
482 {
483     MS_U8 *s = pY;
484     MS_U8 *t = pDst;
485     MS_S32 y;
486     for (y=0; y<nMaxY; y++) {
487         memcpy(t, s, nMaxX);
488         s += nStride;
489         t += 16;
490     }
491 }
492 
PutTileUV(MS_U8 * pU,MS_U8 * pV,MS_U8 * pDst,MS_S32 nStride,MS_S32 nMaxX,MS_S32 nMaxY)493 static void PutTileUV(MS_U8 *pU, MS_U8 *pV, MS_U8 *pDst, MS_S32 nStride, MS_S32 nMaxX, MS_S32 nMaxY)
494 {
495     MS_U8 *s1 = pU;
496     MS_U8 *s2 = pV;
497     MS_U8 *t = pDst;
498     MS_S32 x, y;
499     for (y=0; y<nMaxY; y++) {
500         for (x=0; x<nMaxX; x++) {
501             t[x<<1] = s1[x];
502             t[(x<<1)+1] = s2[x];
503         }
504         s1 += nStride;
505         s2 += nStride;
506         t += 16;
507     }
508 }
509 
ConvertYV12ToHVDTile(MS_U8 * pSrc1,MS_U8 * pSrc2,MS_S32 nSrcWidth,MS_S32 nSrcHeight,MS_S32 nSrcStride,MS_U8 * pDst,MS_S32 nDstSize,MS_S32 YPlane)510 MS_BOOL ConvertYV12ToHVDTile(MS_U8 *pSrc1, MS_U8 *pSrc2, MS_S32 nSrcWidth, MS_S32 nSrcHeight, MS_S32 nSrcStride, MS_U8 *pDst, MS_S32 nDstSize, MS_S32 YPlane)
511 {
512     MS_S32 nHvdWidth, nHvdHeight, nSize;
513     MS_S32 x, y, nTileWidth, nTileHeight;
514     MS_U8 *pSrcPtr1, *pSrcPtr2, *pDstPtr;
515 
516     // Calculate dst width and height
517     if (YPlane) {
518         nHvdWidth  = CEILING_ALIGN(nSrcWidth, 16);
519         nHvdHeight = CEILING_ALIGN(nSrcHeight, 32);
520     }
521     else {
522         nHvdWidth  = CEILING_ALIGN(nSrcWidth<<1, 16); // U,V interleave
523         nHvdHeight = CEILING_ALIGN(nSrcHeight, 32);
524     }
525     // Check dst size
526     nSize = nHvdWidth * nHvdHeight;
527     if (nDstSize < nSize) {
528         //MS_ASSERT(0);
529         return FALSE;
530     }
531 
532     // tile by tile conversion
533     nTileWidth  = nHvdWidth /16;
534     nTileHeight = nHvdHeight/32;
535     if (!YPlane)
536         goto TILE_LOOP_UV;
537 
538     // Y Plane
539     pDstPtr = pDst;
540     for (y=0; y<nTileHeight; y++) {
541         for (x=0; x<nTileWidth; x++) {
542             pSrcPtr1 = pSrc1 + (y*32*nSrcStride) + (x*16);
543             PutTileY(pSrcPtr1, pDstPtr, nSrcStride,
544                 (x==nTileWidth-1) ? nSrcWidth -nHvdWidth +16 : 16,
545                 (y==nTileHeight-1)? nSrcHeight-nHvdHeight+32 : 32);
546             pDstPtr += 16*32;
547         }
548     }
549     return TRUE;
550 
551 TILE_LOOP_UV:
552     // U,V planes
553     pDstPtr = pDst;
554     for (y=0; y<nTileHeight; y++) {
555         for (x=0; x<nTileWidth; x++) {
556             pSrcPtr1 = pSrc1 + (y*32*nSrcStride) + (x*8);
557             pSrcPtr2 = pSrc2 + (y*32*nSrcStride) + (x*8);
558             PutTileUV(pSrcPtr1, pSrcPtr2, pDstPtr, nSrcStride,
559                 (x==nTileWidth-1) ? nSrcWidth -(nHvdWidth>>1) +8  : 8,
560                 (y==nTileHeight-1)? nSrcHeight-nHvdHeight     +32 : 32);
561             pDstPtr += 16*32;
562         }
563     }
564     return TRUE;
565 }
566 
yuv2tile(MS_U8 * output,MS_S32 width,MS_S32 height,MS_U8 * buff,MS_S32 Ypart)567 void yuv2tile(/*FILE *fp*/MS_U8 *output, MS_S32 width, MS_S32 height, MS_U8 *buff , MS_S32 Ypart)
568 {
569     MS_S32 mbx, mby;
570     MS_S32 image_x, image_x2;
571     MS_S32 MB_in_width, MB_in_height;
572     MS_S32 k,l,lumstart,chrstart;
573     U8 *y_point, *u_point, *v_point;
574     U8 *y_point2;
575     U8 *blk_point;
576     volatile MS_U8 *tmp_out=output;
577     MS_S32 blk, row;
578 
579 
580     if (buff != 0)
581     {
582         image_x = width;
583         MB_in_width = image_x >>4/*/ MB_SIZE*/;
584         MB_in_height = height >> 4;
585 
586         if (Ypart == 1)
587         {
588             // dump Y plane first
589             for (mby = 0; mby < MB_in_height; mby++)
590             {
591                 for (mbx = 0; mbx < MB_in_width; mbx++)
592                 {
593                     k = mby * image_x << 4 /* * MB_SIZE*/;
594                     l = mbx << 4/** MB_SIZE*/;
595                     lumstart =k+l;
596 
597                     y_point = buff + lumstart;
598                     y_point2 = y_point + (image_x << 3) /** 8 */;
599 
600                     for (blk = 0; blk < 4; blk++)
601                     {
602                         blk_point = (blk>>1)? y_point2 : y_point;
603                         blk_point += (blk&1)? 8/*B_SIZE*/ : 0;
604 
605                         for (row = 0; row < 8; row++)
606                         {
607                             //for (col = 0; col < 8; col++)
608                             //{
609                             //	mem_y_point[col] = blk_point[col];
610                             //}
611 //                           ms_dprintk(DRV_L3,"in 0x%2x 0x%2x 0x%2x\n", blk_point[0], blk_point[1], blk_point[2]);
612                             memcpy((void *)tmp_out, (const void *)blk_point, 8);
613 //                            ms_dprintk(DRV_L3,"out 0x%2x 0x%2x 0x%2x\n", tmp_out[0], tmp_out[1], tmp_out[2]);
614                             tmp_out+=8;
615                             //fwrite(blk_point, 8, 1, fp);
616                             blk_point += image_x;
617                             //mem_y_point += 8;
618                         }
619                     }
620                 }
621             }
622         }
623         else
624         {
625             // dump UV plane
626             image_x2 = image_x >> 1;
627             for (mby = 0; mby < MB_in_height; mby++)
628             {
629                 for (mbx = 0; mbx < MB_in_width; mbx++)
630                 {
631                     k= mby * image_x <<4 /* * MB_SIZE*/;
632                     l= mbx <<4/** MB_SIZE*/;
633                     chrstart =(k>>2)+(l>>1);
634 
635                     u_point = buff + /*width * height +*/ chrstart;
636                     v_point = buff + /*width * height +*/ ( (width*height) >> 2 ) + chrstart;
637 
638                     for (blk = 0; blk < 2; blk++) // U block then V block..
639                     {
640                         blk_point = (blk==0)? u_point : v_point;
641 
642                         for (row = 0; row < 8; row++)
643                         {
644                             memcpy((void *)tmp_out, (const void *)blk_point, 8);
645                             tmp_out+=8;
646                             //fwrite(blk_point, 8, 1, fp);
647                             blk_point += image_x2;
648                         }
649                     }
650                 }
651             }
652         }
653     } else {
654     //    ms_dprintf(ADP_L1,"input buffer in yuv2tile() is zero\n");
655 
656 	}
657 }
658