1 #include <VLIB/P264/p264_intra_pred.h>
2 #include <VP_Os/vp_os_malloc.h>
3 #include <VP_Os/vp_os_print.h>
5 C_RESULT p264_intra_4x4_luma (intra_4x4_mode_t mode, uint8_t *picture, uint32_t picture_width, uint32_t x, uint32_t y, uint32_t linesize)
6 // all mode partially validated (not all availability cases for each mode)
8 // A-M are the boundary pixels of the 4x4 block a-p
18 uint32_t A,B,C,D,E,F,G,H,I,J,K,L,M;
21 uint32_t availability_flag=0;
22 uint8_t * picture_start;
24 // determine block availability
27 // block 4x4 is located in the first column of the frame, A pixels are not available
28 availability_flag |= A_UNAVAILABLE;
32 // block 4x4 is located in the first row of the frame, B and C pixels are not available
33 availability_flag |= B_UNAVAILABLE | C_UNAVAILABLE;
35 if (x==picture_width-4)
37 // block 4x4 is located in the last column of the frame, C pixels are not available
38 availability_flag |= C_UNAVAILABLE;
40 if ((((x>>2)&0x01) == 1) && (((y>>2)&0x01) == 1))
42 // block 4x4 is located at the 'x' position in the following MB representation:
47 // therefore C is not available.
48 availability_flag |= C_UNAVAILABLE;
50 else if ((((x>>2)&0x03) == 3) && (((y>>2)&0x03) == 2))
52 // block 4x4 is located at the 'x' position in the following MB representation:
57 // therefore C is not available.
58 availability_flag |= C_UNAVAILABLE;
61 // check availability and mode
64 case VERTICAL_4x4_MODE :
65 case DIAGONAL_DL_4x4_MODE :
66 case VERTICAL_LEFT_4x4_MODE :
67 if (availability_flag & B_UNAVAILABLE)
69 PRINT("%s : could no compute intra 4x4 mode_%d prediction on (%d,%d), B unavailable\n",__FUNCTION__,mode,x,y);
74 case HORIZONTAL_4x4_MODE :
75 case HORIZONTAL_UP_4x4_MODE :
76 if (availability_flag & A_UNAVAILABLE)
78 PRINT("%s : could no compute intra 4x4 mode_%d prediction on (%d,%d) A unavailable\n",__FUNCTION__,mode,x,y);
87 case DIAGONAL_DR_4x4_MODE :
88 case VERTICAL_RIGHT_4x4_MODE :
89 case HORIZONTAL_DOWN_4x4_MODE :
90 if (availability_flag & A_UNAVAILABLE)
92 PRINT("%s : could no compute intra 4x4 mode_%d prediction on (%d,%d) A unavailable\n",__FUNCTION__,mode,x,y);
95 if (availability_flag & B_UNAVAILABLE)
97 PRINT("%s : could no compute intra 4x4 mode_%d prediction on (%d,%d) B unavailable\n",__FUNCTION__,mode,x,y);
103 PRINT ("%s : mode_%d at block (%d,%d) is not a valid intra 4x4 prediction mode\n",__FUNCTION__,mode,x,y);
112 case VERTICAL_4x4_MODE :
114 picture += (linesize*(y-1)+x);
115 // load A-D pixel values
124 picture += (linesize-4);
133 case HORIZONTAL_4x4_MODE :
135 picture += (linesize*y+x-1);
138 // extend I-L pixels to a-d,e-h,i-l,m-p;
144 // jump to next row (pixel J,K,L)
145 picture += (linesize-4);
150 picture_start = picture;
152 // compute mean over A-D and I-L pixels if available
153 if (!(availability_flag & B_UNAVAILABLE))
156 picture += (linesize*(y-1)+x);
163 if (!(availability_flag & A_UNAVAILABLE))
165 picture = picture_start;
167 picture += (linesize*y+x-1);
176 if (!(availability_flag & A_UNAVAILABLE) && !(availability_flag & B_UNAVAILABLE))
178 else if (!(availability_flag & A_UNAVAILABLE) || !(availability_flag & B_UNAVAILABLE))
183 // jump to pixel a and make prediction
184 picture = picture_start+linesize*y+x;
192 picture = picture+linesize-4;
196 case DIAGONAL_DL_4x4_MODE :
197 picture_start = picture;
199 picture += (linesize*(y-1)+x);
200 // load A-D pixel values
205 // check block C availability
206 if (availability_flag & C_UNAVAILABLE)
208 // E,F,G,H not available, copy D value
213 // load E-H pixel values
221 picture = picture_start + linesize*y+x;
224 *picture++ = (A + C + 2*(B) + 2) >> 2; // a
225 *picture++ = (B + D + 2*(C) + 2) >> 2; // b
226 *picture++ = (C + E + 2*(D) + 2) >> 2; // c
227 *picture = (D + F + 2*(E) + 2) >> 2; // d
228 picture += linesize-3;
229 *picture++ = (B + D + 2*(C) + 2) >> 2; // e
230 *picture++ = (C + E + 2*(D) + 2) >> 2; // f
231 *picture++ = (D + F + 2*(E) + 2) >> 2; // g
232 *picture = (E + G + 2*(F) + 2) >> 2; // h
233 picture += linesize-3;
234 *picture++ = (C + E + 2*(D) + 2) >> 2; // i
235 *picture++ = (D + F + 2*(E) + 2) >> 2; // j
236 *picture++ = (E + G + 2*(F) + 2) >> 2; // k
237 *picture = (F + H + 2*(G) + 2) >> 2; // l
238 picture += linesize-3;
239 *picture++ = (D + F + 2*(E) + 2) >> 2; // m
240 *picture++ = (E + G + 2*(F) + 2) >> 2; // n
241 *picture++ = (F + H + 2*(G) + 2) >> 2; // o
242 *picture = (G + 3*(H) + 2) >> 2; // p
245 case DIAGONAL_DR_4x4_MODE :
246 picture_start = picture;
248 picture += (linesize*(y-1)+x-1);
249 // load M-D pixel values
255 // jump to pixel I & load it
256 picture += linesize-4;
258 // jump to pixel J & load it
261 // jump to pixel K & load it
264 // jump to pixel L & load it
268 picture = picture_start + linesize*y+x;
270 *picture++ = (I + 2*M + A + 2) >> 2; // a
271 *picture++ = (M + 2*A + B + 2) >> 2; // b
272 *picture++ = (A + 2*B + C + 2) >> 2; // c
273 *picture = (B + 2*C + D + 2) >> 2; // d
274 picture += linesize-3;
275 *picture++ = (J + 2*I + M + 2) >> 2; // e
276 *picture++ = (I + 2*M + A + 2) >> 2; // f
277 *picture++ = (M + 2*A + B + 2) >> 2; // g
278 *picture = (A + 2*B + C + 2) >> 2; // h
279 picture += linesize-3;
280 *picture++ = (K + 2*J + I + 2) >> 2; // i
281 *picture++ = (J + 2*I + M + 2) >> 2; // j
282 *picture++ = (I + 2*M + A + 2) >> 2; // k
283 *picture = (M + 2*A + B + 2) >> 2; // l
284 picture += linesize-3;
285 *picture++ = (L + 2*K + J + 2) >> 2; // m
286 *picture++ = (K + 2*J + I + 2) >> 2; // n
287 *picture++ = (J + 2*I + M + 2) >> 2; // o
288 *picture = (I + 2*M + A + 2) >> 2; // p
291 case VERTICAL_RIGHT_4x4_MODE :
292 picture_start = picture;
294 picture += (linesize*(y-1)+x-1);
295 // load M-D pixel values
301 // jump to pixel I & load it
302 picture += linesize-4;
304 // jump to pixel J & load it
307 // jump to pixel K & load it
310 // jump to pixel L & load it
314 picture = picture_start + linesize*y+x;
316 *picture++ = (M + A + 1) >> 1; // a
317 *picture++ = (A + B + 1) >> 1; // b
318 *picture++ = (B + C + 1) >> 1; // c
319 *picture = (C + D + 1) >> 1; // d
320 picture += linesize-3;
321 *picture++ = (I + 2*M + A + 2) >> 2; // e
322 *picture++ = (M + 2*A + B + 2) >> 2; // f
323 *picture++ = (A + 2*B + C + 2) >> 2; // g
324 *picture = (B + 2*C + D + 2) >> 2; // h
325 picture += linesize-3;
326 *picture++ = (M + 2*I + J + 2) >> 2; // i
327 *picture++ = (M + A + 1) >> 1; // j
328 *picture++ = (A + B + 1) >> 1; // k
329 *picture = (B + C + 1) >> 1; // l
330 picture += linesize-3;
331 *picture++ = (I + 2*J + K + 2) >> 2; // m
332 *picture++ = (I + 2*M + A + 2) >> 2; // n
333 *picture++ = (M + 2*A + B + 2) >> 2; // o
334 *picture = (A + 2*B + C + 2) >> 2; // p
337 case HORIZONTAL_DOWN_4x4_MODE :
338 picture_start = picture;
340 picture += (linesize*(y-1)+x-1);
341 // load M-D pixel values
347 // jump to pixel I & load it
348 picture += linesize-4;
350 // jump to pixel J & load it
353 // jump to pixel K & load it
356 // jump to pixel L & load it
360 picture = picture_start + linesize*y+x;
362 *picture++ = (M + I + 1) >> 1; // a
363 *picture++ = (I + 2*M + A + 2) >> 2; // b
364 *picture++ = (M + 2*A + B + 2) >> 2; // c
365 *picture = (A + 2*B + C + 2) >> 2; // d
366 picture += linesize-3;
367 *picture++ = (I + J + 1) >> 1; // e
368 *picture++ = (M + 2*I + J + 2) >> 2; // f
369 *picture++ = (M + I + 1) >> 1; // g
370 *picture = (I + 2*M + A + 2) >> 2; // h
371 picture += linesize-3;
372 *picture++ = (J + K + 1) >> 1; // i
373 *picture++ = (I + 2*J + K + 2) >> 2; // j
374 *picture++ = (I + J + 1) >> 1; // k
375 *picture = (M + 2*I + J + 2) >> 2; // l
376 picture += linesize-3;
377 *picture++ = (K + L + 1) >> 1; // m
378 *picture++ = (J + 2*K + L + 2) >> 2; // n
379 *picture++ = (J + K + 1) >> 1; // o
380 *picture = (I + 2*J + K + 2) >> 2; // p
384 case VERTICAL_LEFT_4x4_MODE :
385 picture_start = picture;
387 picture += (linesize*(y-1)+x);
388 // load A-D pixel values
393 // check block C availability
394 if (availability_flag & C_UNAVAILABLE)
396 // E,F,G,H not available, copy D value
401 // load E-H pixel values
408 picture = picture_start + linesize*y+x;
410 *picture++ = (A + B + 1) >> 1; // a
411 *picture++ = (B + C + 1) >> 1; // b
412 *picture++ = (C + D + 1) >> 1; // c
413 *picture = (D + E + 1) >> 1; // d
414 picture += linesize-3;
415 *picture++ = (A + 2*B + C + 2) >> 2; // e
416 *picture++ = (B + 2*C + D + 2) >> 2; // f
417 *picture++ = (C + 2*D + E + 2) >> 2; // g
418 *picture = (D + 2*E + F + 2) >> 2; // h
419 picture += linesize-3;
420 *picture++ = (B + C + 1) >> 1; // i
421 *picture++ = (C + D + 1) >> 1; // j
422 *picture++ = (D + E + 1) >> 1; // k
423 *picture = (E + F + 1) >> 1; // l
424 picture += linesize-3;
425 *picture++ = (B + 2*C + D + 2) >> 2; // m
426 *picture++ = (C + 2*D + E + 2) >> 2; // n
427 *picture++ = (D + 2*E + F + 2) >> 2; // o
428 *picture = (E + 2*F + G + 2) >> 2; // p
431 case HORIZONTAL_UP_4x4_MODE :
432 picture_start = picture;
433 // jump to pixel I & load it
434 picture += (linesize*y+x-1);
436 // jump to pixel J & load it
439 // jump to pixel K & load it
442 // jump to pixel L & load it
446 picture = picture_start + linesize*y+x;
448 *picture++ = (I + J + 1) >> 1; // a
449 *picture++ = (I + 2*J + K + 2) >> 2; // b
450 *picture++ = (J + K + 1) >> 1; // c
451 *picture = (J + 2*K + L + 2) >> 2; // d
452 picture += linesize-3;
453 *picture++ = (J + K + 1) >> 1; // e
454 *picture++ = (J + 2*K + L + 2) >> 2; // f
455 *picture++ = (K + L + 1) >> 1; // g
456 *picture = (K + 2*L + L + 2) >> 2; // h
457 picture += linesize-3;
458 *picture++ = (K + L + 1) >> 1; // i
459 *picture++ = (K + 2*L + L + 2) >> 2; // j
462 picture += linesize-3;
470 PRINT ("%s : mode_%d at block (%d,%d) is not a valid intra 4x4 prediction mode\n",__FUNCTION__,mode,x,y);
477 C_RESULT p264_intra_16x16_luma (intra_16x16_luma_mode_t mode, uint8_t *picture, uint32_t x, uint32_t y, uint32_t linesize)
478 // Hori,Verti, Plane mode validated, DC missing
480 // Ai-Bi-M are the boundary pixels of the 16x16 block p(,)
483 // A0 p(0,0) p(0,1) p(0,15)
488 // A15 p(15,0) p(15,15)
492 uint32_t availability_flag=0;
493 uint8_t * picture_start;
496 // determine block availability
499 // block 16x16 is located in the first column of the frame, A pixels are not available
500 availability_flag |= A_UNAVAILABLE;
504 // block 16x16 is located in the first row of the frame, B pixels are not available
505 availability_flag |= B_UNAVAILABLE;
508 // check availability and mode
511 case VERTICAL_16x16_LUMA_MODE :
512 if (availability_flag & B_UNAVAILABLE)
514 PRINT("%s : could no compute intra 16x16 mode_%d prediction on (%d,%d), B unavailable\n",__FUNCTION__,mode,x,y);
519 case HORIZONTAL_16x16_LUMA_MODE :
520 if (availability_flag & A_UNAVAILABLE)
522 PRINT("%s : could no compute intra 16x16 mode_%d prediction on (%d,%d) A unavailable\n",__FUNCTION__,mode,x,y);
527 case DC_16x16_LUMA_MODE :
531 case PLANE_16x16_LUMA_MODE :
532 if (availability_flag & A_UNAVAILABLE)
534 PRINT("%s : could no compute intra 16x16 mode_%d prediction on (%d,%d) A unavailable\n",__FUNCTION__,mode,x,y);
537 if (availability_flag & B_UNAVAILABLE)
539 PRINT("%s : could no compute intra 16x16 mode_%d prediction on (%d,%d) B unavailable\n",__FUNCTION__,mode,x,y);
545 PRINT ("%s : mode_%d is not a valid intra 16x16 prediction mode\n",__FUNCTION__,mode);
554 case DC_16x16_LUMA_MODE :
556 picture_start = picture;
558 // compute mean over Ai and Bi pixels if available
559 if (!(availability_flag & B_UNAVAILABLE))
562 picture += (linesize*(y-1)+x);
571 if (!(availability_flag & A_UNAVAILABLE))
573 picture = picture_start;
575 picture += (linesize*y+x-1);
585 if (!(availability_flag & A_UNAVAILABLE) && !(availability_flag & B_UNAVAILABLE))
587 else if (!(availability_flag & A_UNAVAILABLE) || !(availability_flag & B_UNAVAILABLE))
592 // jump to pixel p(0,0) and make prediction
593 picture = picture_start+linesize*y+x;
602 picture += (linesize-16);
607 case HORIZONTAL_16x16_LUMA_MODE :
610 picture += (linesize*y+x-1);
611 // extend pixel Ai horizontally
617 pixel_buf = *picture++;
622 *picture++ = pixel_buf;
625 picture += (linesize-17);
630 case VERTICAL_16x16_LUMA_MODE :
633 picture += (linesize*(y-1)+x);
634 uint8_t line_buf[16];
636 vp_os_memcpy(line_buf,picture,16*sizeof(uint8_t));
637 // extend Bi line vertically
644 vp_os_memcpy(picture,line_buf,16*sizeof(uint8_t));
649 case PLANE_16x16_LUMA_MODE :
652 picture_start = picture;
654 // H' = 1* (B8 - B6) +
662 // H = (5*H' + 32) / 64
664 picture += (linesize*(y-1)+x-1);
678 // V' = 1* (A8 - A6) +
686 // V = (5*V' + 32) / 64
689 picture = picture_start + (linesize*(y-1)+x-1);
703 // fill pixel p(i,j) of the 16x16 block with the following rule :
704 // a = 16 * (A15 + B15 + 1) - 7*(V+H)
705 // b(i,j) = a + V * j + H * i
706 // p(i,j) = SATURATE_U8(b(i,j) / 32)
707 // SATURATE_U8() function indicates that the result of the operation should be bounded to an unsigned 8-bit range (0..255)
709 int32_t a = ((A15 + B15 + 1)<<4) - 7*(V+H);
712 picture = picture_start + (linesize*y+x);
719 pixel_buf = (a + V*j + H*i)>>5;
721 if (pixel_buf > 0xFF)
723 else if (pixel_buf < 0)
725 *picture++ = pixel_buf;
728 picture += linesize - 16;
734 PRINT ("%s : mode_%d is not a valid intra 16x16 prediction mode\n",__FUNCTION__,mode);
742 // DC_8x8_CHROMA_MODE is slightly different from DC_16x16_LUMA_MODE
743 // each 8x8 block is divided into 4 blocks
744 // -------------------
746 // --------- ---------
748 // -------------------
750 // In "all" block, adjacent 4x4 blocks A and B are used to compute the DC value as in DC_16x16_LUMA_MODE.
751 // If B is not available, A is used instead of B.
752 // If A is not available, B is used instead of A.
753 // If neither A nor B are available, DC is set to 128.
754 // In "single1" priority is given to B block to compute the DC value. If B is not available, A is used instead of B.
755 // If neither A nor B are available, DC is set to 128.
756 // In "single2" priority is given to A block to compute the DC value. If A is not available, B is used instead of A.
757 // If neither A nor B are available, DC is set to 128.
759 // Next scheme summarize the block used to compute the DC value in raster scan ordered image :
761 // A -----------------
764 // l -------- -------- ...
767 // k -------- --------
770 static uint8_t chroma_DC_all(uint8_t *picture, uint32_t x, uint32_t y, uint32_t linesize)
772 // this function assumes that (x,y) corresponds to a "all" DC block 4x4
774 uint8_t *picture_start = picture;
777 // top left 8x8 chroma block, A&B are not available
784 // 8x8 chroma block is not located in the first row
786 picture = picture_start + linesize*((y&0xFFF8)-1) + x;
794 // 8x8 chroma block is not located in the first column
796 picture = picture_start + linesize*y + (x&0xFFF8)-1;
807 // only one adjacent block (A or B) is used to compute DC value
812 // both A and B blocks are used to compute DC value
819 static uint8_t chroma_DC_single(uint8_t *picture, uint32_t x, uint32_t y, uint32_t linesize)
821 // this function assumes that (x,y) corresponds to a "single" DC block 4x4
825 // top left 8x8 chroma block, A&B are not available
830 if ((x<=4) || ((y>4) && ((y&0x07) == 0)))
832 // block 4x4 is located either on the first chroma 8x8 column or at the top right of a 8x8 chroma
834 picture += linesize*((y&0xFFF8)-1) + x;
844 picture += linesize*y + (x&0xFFF8) - 1;
858 static void fill_4x4_DC(uint8_t* picture, uint32_t x, uint32_t y, uint32_t linesize, uint8_t value)
860 picture += linesize*y+x;
869 picture += linesize-4;
873 C_RESULT p264_intra_8x8_chroma (intra_8x8_chroma_mode_t mode, uint8_t *picture, uint32_t x, uint32_t y, uint32_t linesize)
874 // CHROMA DC mode validated on one MB
876 // Ai-Bi-M are the boundary pixels of the 16x16 block p(y,x)
879 // A0 p(0,0) p(0,1) p(0,7)
888 uint32_t availability_flag=0;
889 uint8_t * picture_start;
892 // determine block availability
895 // block 8x8 is located in the first column of the frame, A pixels are not available
896 availability_flag |= A_UNAVAILABLE;
900 // block 8x8 is located in the first row of the frame, B pixels are not available
901 availability_flag |= B_UNAVAILABLE;
904 // check availability and mode
907 case VERTICAL_8x8_CHROMA_MODE :
908 if (availability_flag & B_UNAVAILABLE)
910 PRINT("%s : could no compute chroma intra 8x8 mode_%d prediction on (%d,%d), B unavailable\n",__FUNCTION__,mode,x,y);
915 case HORIZONTAL_8x8_CHROMA_MODE :
916 if (availability_flag & A_UNAVAILABLE)
918 PRINT("%s : could no compute chroma intra 8x8 mode_%d prediction on (%d,%d) A unavailable\n",__FUNCTION__,mode,x,y);
923 case DC_8x8_CHROMA_MODE :
927 case PLANE_8x8_CHROMA_MODE :
928 if (availability_flag & A_UNAVAILABLE)
930 PRINT("%s : could no compute chroma intra 8x8 mode_%d prediction on (%d,%d) A unavailable\n",__FUNCTION__,mode,x,y);
933 if (availability_flag & B_UNAVAILABLE)
935 PRINT("%s : could no compute chroma intra 8x8 mode_%d prediction on (%d,%d) B unavailable\n",__FUNCTION__,mode,x,y);
941 PRINT ("%s : mode_%d is not a valid chroma intra 8x8 prediction mode\n",__FUNCTION__,mode);
950 case DC_8x8_CHROMA_MODE :
952 // DC_8x8_CHROMA_MODE is slightly different from DC_16x16_LUMA_MODE
953 // each 8x8 block is divided into 4 blocks
954 // -------------------
956 // --------- ---------
958 // -------------------
960 // In "all" block, adjacent 4x4 blocks A and B are used to compute the DC value as in DC_16x16_LUMA_MODE.
961 // If B is not available, A is used instead of B.
962 // If A is not available, B is used instead of A.
963 // If neither A nor B are available, DC is set to 128.
964 // In "single1" priority is given to B block to compute the DC value. If B is not available, A is used instead of B.
965 // If neither A nor B are available, DC is set to 128.
966 // In "single2" priority is given to A block to compute the DC value. If A is not available, B is used instead of A.
967 // If neither A nor B are available, DC is set to 128.
969 // Next scheme summarize the block used to compute the DC value in raster scan ordered image :
971 // A -----------------
974 // l -------- -------- ...
977 // k -------- --------
982 // compute DC value of block_4x4(0,0)
983 mean = chroma_DC_all(picture,x,y,linesize);
984 // fill the block with DC
985 fill_4x4_DC(picture,x,y,linesize,mean);
987 // compute DC value of block_4x4(4,0)
988 mean = chroma_DC_single(picture,x+4,y,linesize);
989 // fill the block with DC
990 fill_4x4_DC(picture,x+4,y,linesize,mean);
992 // compute DC value of block_4x4(0,4)
993 mean = chroma_DC_single(picture,x,y+4,linesize);
994 // fill the block with DC
995 fill_4x4_DC(picture,x,y+4,linesize,mean);
997 // compute DC value of block_4x4(4,4)
998 mean = chroma_DC_all(picture,x+4,y+4,linesize);
999 // fill the block with DC
1000 fill_4x4_DC(picture,x+4,y+4,linesize,mean);
1004 case HORIZONTAL_8x8_CHROMA_MODE :
1007 picture += (linesize*y+x-1);
1008 // extend pixel Ai horizontally
1014 pixel_buf = *picture++;
1019 *picture++ = pixel_buf;
1022 picture += (linesize-9);
1027 case VERTICAL_8x8_CHROMA_MODE :
1030 picture += (linesize*(y-1)+x);
1031 uint8_t line_buf[8];
1033 vp_os_memcpy(line_buf,picture,8*sizeof(uint8_t));
1034 // extend Bi line vertically
1038 // jump to next line
1039 picture += linesize;
1041 vp_os_memcpy(picture,line_buf,8*sizeof(uint8_t));
1046 case PLANE_8x8_CHROMA_MODE :
1049 picture_start = picture;
1051 // H' = 1* (B4 - B2) +
1055 // H = (34*H' + 32) / 64
1057 picture += (linesize*(y-1)+x-1);
1061 H -= i*(*picture++);
1065 H += i*(*++picture);
1071 // V' = 1* (A4 - A2) +
1075 // V = (34*V' + 32) / 64
1078 picture = picture_start + (linesize*(y-1)+x-1);
1082 picture += linesize;
1086 picture += linesize;
1092 // fill pixel p(i,j) of the 16x16 block with the following rule :
1093 // a = 16 * (A7 + B7 + 1) - 3*(V+H)
1094 // b(i,j) = a + V * j + H * i
1095 // p(i,j) = SATURATE_U8(b(i,j) / 32)
1096 // SATURATE_U8() function indicates that the result of the operation should be bounded to an unsigned 8-bit range (0..255)
1098 int32_t a = ((A7 + B7 + 1)<<4) - 3*(V+H);
1101 picture = picture_start + (linesize*y+x);
1108 pixel_buf = (a + V*j + H*i)>>5;
1110 if (pixel_buf > 0xFF)
1112 else if (pixel_buf < 0)
1114 *picture++ = pixel_buf;
1116 // jump to next line
1117 picture += linesize - 8;
1123 PRINT ("%s : mode_%d is not a valid chrome intra 8x8 prediction mode\n",__FUNCTION__,mode);