- Timestamp:
- 02/21/10 22:44:27 (2 years ago)
- Parents:
- 41dcfc0d39c224f0f2aef6cb2c5fc6541643e4b4
- Children:
- 9759199714df0cd85f695766c4c5c5d712570365
- git-committer:
- Robin Gareus <rgareus@priroda.local> / 2010-02-21T23:44:27Z+0100
- Files:
-
- 1 modified
-
oggzcap/src/videoout/FrameReader.m (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
oggzcap/src/videoout/FrameReader.m
r0a70e0d r9fd2977 19 19 20 20 @implementation FrameReader (PrivateReaderMethods) 21 22 // http://developer.apple.com/mac/library/samplecode/QuartzComposer_WWDC_QCTV/listing12.html 21 23 22 24 // Initiate an asynchronous screen read operation. … … 69 71 unsigned char* src; 70 72 unsigned char* dst; 73 #if 0 71 74 unsigned char temp[(mWidth * 2 + 63) & ~63]; 72 75 … … 79 82 bcopy(temp, src, mWidth * 2); 80 83 } 84 85 #else 86 unsigned char temp[(mWidth * 4 + 63) & ~63]; 87 for(i = 0; i < mHeight/2; ++i) { 88 src = mBaseAddress + mBufferRowBytes * i; 89 dst = mBaseAddress + mBufferRowBytes * (mHeight - 1 - i); 90 bcopy(dst, temp, mWidth * 4); 91 bcopy(src, dst, mWidth * 4); 92 bcopy(temp, src, mWidth * 4); 93 } 94 #endif 95 81 96 } 82 97 … … 154 169 155 170 attributes = [NSMutableDictionary dictionary]; 171 #if 0 156 172 #if __BIG_ENDIAN__ 157 173 [attributes setObject:[NSNumber numberWithUnsignedInt:k422YpCbCr8PixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; … … 159 175 [attributes setObject:[NSNumber numberWithUnsignedInt:k422YpCbCr8PixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; 160 176 #endif 177 #else 178 // [attributes setObject:[NSNumber numberWithUnsignedInt:k32ARGBPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; 179 [attributes setObject:[NSNumber numberWithUnsignedInt:k32BGRAPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; 180 #endif 181 161 182 [attributes setObject:[NSNumber numberWithUnsignedInt:width] forKey:(NSString*)kCVPixelBufferWidthKey]; 162 183 [attributes setObject:[NSNumber numberWithUnsignedInt:height] forKey:(NSString*)kCVPixelBufferHeightKey]; … … 184 205 mBaseAddress = (unsigned char*)CVPixelBufferGetBaseAddress(mPixelBuffer); 185 206 mBufferRowBytes = CVPixelBufferGetBytesPerRow(mPixelBuffer); 207 186 208 187 209 // Do setup for asynchronous texture reading … … 209 231 210 232 glGetIntegerv(GL_UNPACK_ALIGNMENT, &save2); 211 glPixelStorei(GL_UNPACK_ALIGNMENT, 2);233 glPixelStorei(GL_UNPACK_ALIGNMENT, 4); 212 234 glGetIntegerv(GL_UNPACK_ROW_LENGTH, &save3); 213 glPixelStorei(GL_UNPACK_ROW_LENGTH, mBufferRowBytes / 2);235 glPixelStorei(GL_UNPACK_ROW_LENGTH, mBufferRowBytes / 4); 214 236 215 237 // specify that our application retains storage for textures: … … 218 240 219 241 // define our texture 220 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB,0,GL_RGBA, mWidth,mHeight,0,GL_YCBCR_422_APPLE, 221 inoutTexEndianFormat, 242 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB,0,GL_RGBA, mWidth,mHeight,0, 243 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 244 // GL_YCBCR_422_APPLE, inoutTexEndianFormat, 222 245 mBaseAddress); 223 246 … … 362 385 glGetIntegerv(GL_PACK_ROW_LENGTH, &save3); 363 386 364 glPixelStorei(GL_PACK_ROW_LENGTH, mBufferRowBytes / 2);387 glPixelStorei(GL_PACK_ROW_LENGTH, mBufferRowBytes / 4); 365 388 366 389 // You should have previously called glCopyTexSubImage2D/glFlush to initiate … … 369 392 // glGetTexImage actually copies the texture from AGP memory to system memory. 370 393 // This is the synchronization point; it waits until the transfer is finished. 371 glGetTexImage(GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_422_APPLE, 372 inoutTexEndianFormat, 394 glGetTexImage(GL_TEXTURE_RECTANGLE_ARB, 0, 395 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 396 // GL_YCBCR_422_APPLE, inoutTexEndianFormat, 373 397 mBaseAddress); 374 398
