Show
Ignore:
Timestamp:
02/21/10 22:44:27 (2 years ago)
Author:
Robin Gareus <rgareus@…>
Parents:
41dcfc0d39c224f0f2aef6cb2c5fc6541643e4b4
Children:
9759199714df0cd85f695766c4c5c5d712570365
git-committer:
Robin Gareus <rgareus@priroda.local> / 2010-02-21T23:44:27Z+0100
Message:

capture working again

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • oggzcap/src/videoout/FrameReader.m

    r0a70e0d r9fd2977  
    1919 
    2020@implementation FrameReader (PrivateReaderMethods) 
     21 
     22// http://developer.apple.com/mac/library/samplecode/QuartzComposer_WWDC_QCTV/listing12.html 
    2123 
    2224// Initiate an asynchronous screen read operation. 
     
    6971        unsigned char*          src; 
    7072        unsigned char*          dst; 
     73#if 0 
    7174        unsigned char           temp[(mWidth * 2 + 63) & ~63]; 
    7275 
     
    7982                bcopy(temp, src, mWidth * 2); 
    8083        } 
     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         
    8196} 
    8297 
     
    154169                 
    155170                attributes = [NSMutableDictionary dictionary]; 
     171#if 0            
    156172                #if __BIG_ENDIAN__ 
    157173                        [attributes setObject:[NSNumber numberWithUnsignedInt:k422YpCbCr8PixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; 
     
    159175                        [attributes setObject:[NSNumber numberWithUnsignedInt:k422YpCbCr8PixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; 
    160176                #endif 
     177#else 
     178        //      [attributes setObject:[NSNumber numberWithUnsignedInt:k32ARGBPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; 
     179                [attributes setObject:[NSNumber numberWithUnsignedInt:k32BGRAPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; 
     180#endif 
     181                 
    161182                [attributes setObject:[NSNumber numberWithUnsignedInt:width] forKey:(NSString*)kCVPixelBufferWidthKey]; 
    162183                [attributes setObject:[NSNumber numberWithUnsignedInt:height] forKey:(NSString*)kCVPixelBufferHeightKey]; 
     
    184205                mBaseAddress = (unsigned char*)CVPixelBufferGetBaseAddress(mPixelBuffer); 
    185206                mBufferRowBytes = CVPixelBufferGetBytesPerRow(mPixelBuffer); 
     207                 
    186208                 
    187209                // Do setup for asynchronous texture reading 
     
    209231                 
    210232                glGetIntegerv(GL_UNPACK_ALIGNMENT, &save2); 
    211                 glPixelStorei(GL_UNPACK_ALIGNMENT, 2); 
     233                glPixelStorei(GL_UNPACK_ALIGNMENT, 4); 
    212234                glGetIntegerv(GL_UNPACK_ROW_LENGTH, &save3); 
    213                 glPixelStorei(GL_UNPACK_ROW_LENGTH, mBufferRowBytes / 2); 
     235                glPixelStorei(GL_UNPACK_ROW_LENGTH, mBufferRowBytes / 4); 
    214236         
    215237                // specify that our application retains storage for textures: 
     
    218240         
    219241                // 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, 
    222245                                        mBaseAddress); 
    223246                                         
     
    362385        glGetIntegerv(GL_PACK_ROW_LENGTH, &save3); 
    363386 
    364         glPixelStorei(GL_PACK_ROW_LENGTH, mBufferRowBytes / 2); 
     387        glPixelStorei(GL_PACK_ROW_LENGTH, mBufferRowBytes / 4); 
    365388 
    366389        // You should have previously called glCopyTexSubImage2D/glFlush to initiate 
     
    369392        // glGetTexImage actually copies the texture from AGP memory to system memory. 
    370393        // 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, 
    373397                                        mBaseAddress); 
    374398