Show
Ignore:
Timestamp:
18/07/08 00:42:53 (4 months ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1216334573 +0200
git-parent:

[b65ca27b5b5445bf4814dcbc22985cfc24f0900b]

git-author:
Pierre d'Herbemont <pdherbemont@videolan.org> 1216334573 +0200
Message:

Revert "qtcapture: Use a direct block buffer, and remove a memcpy."

This reverts commit b65ca27b5b5445bf4814dcbc22985cfc24f0900b.

It doesn't work well enough.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/access/qtcapture.m

    rb65ca27 r05f184d  
    4848static int Control( demux_t *, int, va_list ); 
    4949 
    50 typedef struct qtcapture_block_t 
    51 { 
    52     block_t block; 
    53     CVImageBufferRef imageBuffer; 
    54     block_free_t pf_original_release; 
    55 } qtcapture_block_t; 
    56  
    57 static void qtcapture_block_release( block_t *p_block ) 
    58 { 
    59     qtcapture_block_t * p_qtblock = (qtcapture_block_t *)p_block; 
    60     CVBufferRelease(p_qtblock->imageBuffer); 
    61     CVPixelBufferUnlockBaseAddress(p_qtblock->imageBuffer, 0); 
    62     p_qtblock->pf_original_release( &p_qtblock->block ); 
    63 } 
    64  
    65 static block_t * qtcapture_block_new( void * p_buffer, 
    66     int i_buffer, 
    67     CVImageBufferRef imageBufferToRelease ) 
    68 { 
    69     qtcapture_block_t * p_qtblock; 
    70  
    71     /* Build block */ 
    72     p_qtblock = malloc( sizeof( qtcapture_block_t ) ); 
    73     if(!p_qtblock) return NULL; 
    74  
    75     /* Fill all fields */ 
    76     block_Init( &p_qtblock->block, p_buffer, i_buffer ); 
    77     p_qtblock->block.pf_release = qtcapture_block_release; 
    78     p_qtblock->imageBuffer = imageBufferToRelease; 
    79  
    80     return (block_t *)p_qtblock; 
    81 } 
    82  
    83  
    8450/***************************************************************************** 
    8551* Module descriptor 
     
    10773- (id)init; 
    10874- (void)outputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection; 
    109 - (block_t *)blockWithCurrentFrame
     75- (mtime_t)copyCurrentFrameToBuffer:(void *)buffer
    11076@end 
    11177 
     
    146112        currentPts = 1000000L / [sampleBuffer presentationTime].timeScale * [sampleBuffer presentationTime].timeValue; 
    147113    } 
    148  
    149114    CVBufferRelease(imageBufferToRelease); 
    150115} 
    151116 
    152 - (block_t *)blockWithCurrentFrame 
     117- (mtime_t)copyCurrentFrameToBuffer:(void *)buffer 
    153118{ 
    154119    CVImageBufferRef imageBuffer; 
    155120    mtime_t pts; 
    156     block_t * p_block = NULL; 
    157121 
    158122    if(!currentImageBuffer || currentPts == previousPts ) 
    159         return NULL
     123        return 0
    160124 
    161125    @synchronized (self) 
    162126    { 
    163         // Released in the p_block release method. 
    164127        imageBuffer = CVBufferRetain(currentImageBuffer); 
    165128        pts = previousPts = currentPts; 
    166129 
    167  
    168         // Unlocked in the p_block release method. 
    169130        CVPixelBufferLockBaseAddress(imageBuffer, 0); 
    170131        void * pixels = CVPixelBufferGetBaseAddress(imageBuffer); 
    171         p_block = qtcapture_block_new( imageBuffer, CVPixelBufferGetDataSize( imageBuffer ), 
    172                 imageBuffer ); 
    173         p_block->i_pts = currentPts; 
    174     } 
    175  
    176     return p_block; 
     132        memcpy( buffer, pixels, CVPixelBufferGetBytesPerRow(imageBuffer) * CVPixelBufferGetHeight(imageBuffer) ); 
     133        CVPixelBufferUnlockBaseAddress(imageBuffer, 0); 
     134    } 
     135 
     136    CVBufferRelease(imageBuffer); 
     137 
     138    return currentPts; 
    177139} 
    178140 
     
    380342    block_t *p_block; 
    381343 
     344    p_block = block_New( p_demux, p_sys->width * 
     345                            p_sys->height * 2 /* FIXME */ ); 
     346    if( !p_block ) 
     347    { 
     348        msg_Err( p_demux, "cannot get block" ); 
     349        return 0; 
     350    } 
     351 
    382352    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 
    383353 
    384354    @synchronized (p_sys->output) 
    385355    { 
    386         p_block = [p_sys->output blockWithCurrentFrame]; 
    387     } 
    388  
    389     if( !p_block
     356    p_block->i_pts = [p_sys->output copyCurrentFrameToBuffer: p_block->p_buffer]; 
     357    } 
     358 
     359    if( !p_block->i_pts
    390360    { 
    391361        /* Nothing to display yet, just forget */ 
     362        block_Release( p_block ); 
    392363        [pool release]; 
    393364        msleep( 10000 );