Search
lxdream.org :: lxdream :: r293:fe191b6381b5
lxdream 0.9.1
released Jun 29
Download Now
changeset293:fe191b6381b5
parent292:3b78f6d301b7
child294:a5beff9b2b85
authornkeynes
dateTue Jan 16 09:17:22 2007 +0000 (13 years ago)
Add yuv422 and save/load state routines
src/pvr2/yuv.c
1.1 --- a/src/pvr2/yuv.c Mon Jan 15 12:58:05 2007 +0000
1.2 +++ b/src/pvr2/yuv.c Tue Jan 16 09:17:22 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: yuv.c,v 1.3 2007-01-15 08:32:09 nkeynes Exp $
1.6 + * $Id: yuv.c,v 1.4 2007-01-16 09:17:22 nkeynes Exp $
1.7 *
1.8 * YUV420 and YUV422 decoding
1.9 *
1.10 @@ -58,6 +58,25 @@
1.11 56, 304, 120, 305, 57, 306, 121, 307, 58, 308, 122, 309, 59, 310, 123, 311, 60, 368, 124, 369, 61, 370, 125, 371, 62, 372, 126, 373, 63, 374, 127, 375,
1.12 56, 312, 120, 313, 57, 314, 121, 315, 58, 316, 122, 317, 59, 318, 123, 319, 60, 376, 124, 377, 61, 378, 125, 379, 62, 380, 126, 381, 63, 382, 127, 383 };
1.13
1.14 +/**
1.15 + * Transformation table for YUV422 inputs
1.16 + */
1.17 +uint16_t yuv422_lut[512] = { 0, 128, 64, 129, 1, 130, 65, 131, 2, 132, 66, 133, 3, 134, 67, 135, 4, 192, 68, 193, 5, 194, 69, 195, 6, 196, 70, 197, 7, 198, 71, 199,
1.18 + 8, 136, 72, 137, 9, 138, 73, 139, 10, 140, 74, 141, 11, 142, 75, 143, 12, 200, 76, 201, 13, 202, 77, 203, 14, 204, 78, 205, 15, 206, 79, 207,
1.19 + 16, 144, 80, 145, 17, 146, 81, 147, 18, 148, 82, 149, 19, 150, 83, 151, 20, 208, 84, 209, 21, 210, 85, 211, 22, 212, 86, 213, 23, 214, 87, 215,
1.20 + 24, 152, 88, 153, 25, 154, 89, 155, 26, 156, 90, 157, 27, 158, 91, 159, 28, 216, 92, 217, 29, 218, 93, 219, 30, 220, 94, 221, 31, 222, 95, 223,
1.21 + 32, 160, 96, 161, 33, 162, 97, 163, 34, 164, 98, 165, 35, 166, 99, 167, 36, 224, 100, 225, 37, 226, 101, 227, 38, 228, 102, 229, 39, 230, 103, 231,
1.22 + 40, 168, 104, 169, 41, 170, 105, 171, 42, 172, 106, 173, 43, 174, 107, 175, 44, 232, 108, 233, 45, 234, 109, 235, 46, 236, 110, 237, 47, 238, 111, 239,
1.23 + 48, 176, 112, 177, 49, 178, 113, 179, 50, 180, 114, 181, 51, 182, 115, 183, 52, 240, 116, 241, 53, 242, 117, 243, 54, 244, 118, 245, 55, 246, 119, 247,
1.24 + 56, 184, 120, 185, 57, 186, 121, 187, 58, 188, 122, 189, 59, 190, 123, 191, 60, 248, 124, 249, 61, 250, 125, 251, 62, 252, 126, 253, 63, 254, 127, 255,
1.25 + 256, 384, 320, 385, 257, 386, 321, 387, 258, 388, 322, 389, 259, 390, 323, 391, 260, 448, 324, 449, 261, 450, 325, 451, 262, 452, 326, 453, 263, 454, 327, 455,
1.26 + 264, 392, 328, 393, 265, 394, 329, 395, 266, 396, 330, 397, 267, 398, 331, 399, 268, 456, 332, 457, 269, 458, 333, 459, 270, 460, 334, 461, 271, 462, 335, 463,
1.27 + 272, 400, 336, 401, 273, 402, 337, 403, 274, 404, 338, 405, 275, 406, 339, 407, 276, 464, 340, 465, 277, 466, 341, 467, 278, 468, 342, 469, 279, 470, 343, 471,
1.28 + 280, 408, 344, 409, 281, 410, 345, 411, 282, 412, 346, 413, 283, 414, 347, 415, 284, 472, 348, 473, 285, 474, 349, 475, 286, 476, 350, 477, 287, 478, 351, 479,
1.29 + 288, 416, 352, 417, 289, 418, 353, 419, 290, 420, 354, 421, 291, 422, 355, 423, 292, 480, 356, 481, 293, 482, 357, 483, 294, 484, 358, 485, 295, 486, 359, 487,
1.30 + 296, 424, 360, 425, 297, 426, 361, 427, 298, 428, 362, 429, 299, 430, 363, 431, 300, 488, 364, 489, 301, 490, 365, 491, 302, 492, 366, 493, 303, 494, 367, 495,
1.31 + 304, 432, 368, 433, 305, 434, 369, 435, 306, 436, 370, 437, 307, 438, 371, 439, 308, 496, 372, 497, 309, 498, 373, 499, 310, 500, 374, 501, 311, 502, 375, 503,
1.32 + 312, 440, 376, 441, 313, 442, 377, 443, 314, 444, 378, 445, 315, 446, 379, 447, 316, 504, 380, 505, 317, 506, 381, 507, 318, 508, 382, 509, 319, 510, 383, 511 };
1.33
1.34 /**
1.35 * Input is 8x8 U, 8x8 V, 8x8 Y00, 8x8 Y01, 8x8 Y10, 8x8 Y11, 8 bits each,
1.36 @@ -74,7 +93,10 @@
1.37
1.38 void pvr2_decode_yuv422( char *dest, char *src )
1.39 {
1.40 -
1.41 + int i;
1.42 + for( i=0; i<512; i++ ) {
1.43 + dest[i] = src[yuv422_lut[i]];
1.44 + }
1.45 }
1.46
1.47 /**
1.48 @@ -160,3 +182,17 @@
1.49 pvr2_yuv_state.width = 1;
1.50 }
1.51 }
1.52 +
1.53 +void pvr2_yuv_save_state( FILE * f )
1.54 +{
1.55 + fwrite( &pvr2_yuv_state, sizeof(pvr2_yuv_state), 1, f );
1.56 +}
1.57 +
1.58 +int pvr2_yuv_load_state( FILE *f )
1.59 +{
1.60 + if( fread( &pvr2_yuv_state, sizeof(pvr2_yuv_state), 1, f ) != 1 ) {
1.61 + return 1;
1.62 + } else {
1.63 + return 0;
1.64 + }
1.65 +}
.