Changeset fd4d779342a16f50de84c3747aaede85d3953f77
- Timestamp:
- 03/01/10 21:43:01 (2 years ago)
- Author:
- Robin Gareus <rgareus@…>
- Parents:
- 53f2ac9a8feb65055412c1c457fbbedaf8d4b201
- Children:
- ce71472e000c3a08cbc59ec63629eb4669e16f71
- git-committer:
- Robin Gareus <rgareus@priroda.local> / 2010-03-01T22:43:01Z+0100
- Message:
-
fixed PPC color
- Location:
- oggzcap/src
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r53f2ac9
|
rfd4d779
|
|
| 87 | 87 | |
| 88 | 88 | CGDirectDisplayID displayID = CGMainDisplayID(); |
| 89 | | NSAssert( displayID != nil, @"CGMainDisplayID failure"); |
| | 89 | //NSAssert( displayID != nil, @"CGMainDisplayID failure"); |
| 90 | 90 | if (displayID) |
| 91 | 91 | { |
-
|
r9fd2977
|
rfd4d779
|
|
| 176 | 176 | #endif |
| 177 | 177 | #else |
| 178 | | // [attributes setObject:[NSNumber numberWithUnsignedInt:k32ARGBPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; |
| 179 | | [attributes setObject:[NSNumber numberWithUnsignedInt:k32BGRAPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; |
| | 178 | #if __BIG_ENDIAN__ |
| | 179 | [attributes setObject:[NSNumber numberWithUnsignedInt:k32ARGBPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; |
| | 180 | #else |
| | 181 | [attributes setObject:[NSNumber numberWithUnsignedInt:k32BGRAPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; |
| | 182 | #endif |
| 180 | 183 | #endif |
| 181 | 184 | |
-
|
r53f2ac9
|
rfd4d779
|
|
| 53 | 53 | int keyframe_frequency=1; |
| 54 | 54 | |
| 55 | | int yuv_copy__bgra_to_420(void *b_2vuy, SInt32 b_2vuy_stride, size_t width, size_t height, size_t offset_x, size_t offset_y, yuv_buffer *dst); |
| 56 | | //// InOut conversion (from theoraEncoder (xiph)) |
| 57 | 55 | int yuv_copy__bgra_to_420(void *b_2vuy, SInt32 b_2vuy_stride, size_t width, size_t height, size_t offset_x, size_t offset_y, yuv_buffer *dst) |
| 58 | 56 | { |
| … |
… |
|
| 88 | 86 | #else // RGBA -> 420 |
| 89 | 87 | // TODO: offset ! & strides |
| 90 | | |
| | 88 | |
| | 89 | #ifdef __BIG_ENDIAN__ |
| | 90 | |
| | 91 | #define _CR ((bptr[(4*i)+1])&0xff) |
| | 92 | #define _CG ((bptr[(4*i)+2])&0xff) |
| | 93 | #define _CB ((bptr[(4*i)+3])&0xff) |
| | 94 | |
| | 95 | #define _CRX ( ( ((bptr[(4*i)+1])&0xff) + ((bptr[(4*(i+1))+1])&0xff) + ((bptr[(4*(i+1+width))+1])&0xff) + ((bptr[(4*(i+1+width))+1])&0xff) )>>2) |
| | 96 | #define _CGX ( ( ((bptr[(4*i)+2])&0xff) + ((bptr[(4*(i+1))+2])&0xff) + ((bptr[(4*(i+1+width))+2])&0xff) + ((bptr[(4*(i+1+width))+2])&0xff) )>>2) |
| | 97 | #define _CBX ( ( ((bptr[(4*i)+3])&0xff) + ((bptr[(4*(i+1))+3])&0xff) + ((bptr[(4*(i+1+width))+3])&0xff) + ((bptr[(4*(i+1+width))+3])&0xff) )>>2) |
| | 98 | |
| | 99 | #else |
| 91 | 100 | #define _CR ((bptr[(4*i)+2])&0xff) |
| 92 | 101 | #define _CG ((bptr[(4*i)+1])&0xff) |
| … |
… |
|
| 96 | 105 | #define _CGX ( ( ((bptr[(4*i)+1])&0xff) + ((bptr[(4*(i+1))+1])&0xff) + ((bptr[(4*(i+1+width))+1])&0xff) + ((bptr[(4*(i+1+width))+1])&0xff) )>>2) |
| 97 | 106 | #define _CBX ( ( ((bptr[(4*i)+0])&0xff) + ((bptr[(4*(i+1))+0])&0xff) + ((bptr[(4*(i+1+width))+0])&0xff) + ((bptr[(4*(i+1+width))+0])&0xff) )>>2) |
| 98 | | |
| 99 | | uint8_t *bptr = (uint8_t*) b_2vuy; |
| 100 | | int i; int c=0; |
| 101 | | for (i=0;i<width*height;i++) { |
| 102 | | double Y = (0.299 * _CR) + (0.587 * _CG) + (0.114 * _CB); |
| 103 | | if (Y<0) dst->y[i]=0; |
| 104 | | else if (Y>255) dst->y[i]=255; |
| 105 | | else dst->y[i]=(uint8_t) floor(Y+.5); |
| 106 | | #if 1 |
| 107 | | if (i%2==0 && ((i/width)%2)==0) { |
| 108 | | double V = (0.500 * _CRX) - (0.419 * _CGX) - (0.081 * _CBX) + 128; |
| 109 | | double U = -(0.169 * _CRX) - (0.331 * _CGX) + (0.500 * _CBX) + 128; |
| 110 | | |
| 111 | | if (U<0) dst->u[c]=0; |
| 112 | | else if (U>255) dst->u[c]=255; |
| 113 | | else dst->u[c]=(uint8_t) floor(U+.5); |
| 114 | | |
| 115 | | if (V<0) dst->v[c]=0; |
| 116 | | else if (V>255) dst->v[c]=255; |
| 117 | | else dst->v[c]=(uint8_t) floor(V+.5); |
| 118 | | c++; |
| 119 | | } |
| | 107 | |
| 120 | 108 | #endif |
| 121 | | |
| 122 | | |
| | 109 | |
| | 110 | uint8_t *bptr = (uint8_t*) b_2vuy; |
| | 111 | int i; int c=0; |
| | 112 | for (i=0;i<width*height;i++) { |
| | 113 | double Y = (0.299 * _CR) + (0.587 * _CG) + (0.114 * _CB); |
| | 114 | if (Y<0) dst->y[i]=0; |
| | 115 | else if (Y>255) dst->y[i]=255; |
| | 116 | else dst->y[i]=(uint8_t) floor(Y+.5); |
| | 117 | |
| | 118 | if (i%2==0 && ((i/width)%2)==0) { |
| | 119 | double V = (0.500 * _CRX) - (0.419 * _CGX) - (0.081 * _CBX) + 128; |
| | 120 | double U = -(0.169 * _CRX) - (0.331 * _CGX) + (0.500 * _CBX) + 128; |
| | 121 | |
| | 122 | if (U<1) dst->u[c]=(uint8_t) 0; |
| | 123 | else if (U>254) dst->u[c]=(uint8_t) 255; |
| | 124 | else dst->u[c]=(uint8_t) floor(U+.5); |
| | 125 | |
| | 126 | if (V<1) dst->v[c]=(uint8_t) 0; |
| | 127 | else if (V>254) dst->v[c]=(uint8_t) 255; |
| | 128 | else dst->v[c]=(uint8_t) floor(V+.5); |
| | 129 | c++; |
| | 130 | } |
| 123 | 131 | } |
| 124 | 132 | #endif |