Changeset 1173

Show
Ignore:
Timestamp:
10/23/09 17:32:03 (9 months ago)
Author:
astrange
Message:

Use av_fast_malloc instead of av_fast_realloc in some places.
Also use av_malloc instead of malloc (just for style reasons).
Also use input buffer padding properly.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/CommonUtils.c

    r1139 r1173  
    442442                pthread_mutex_unlock(&init_mutex); 
    443443} 
     444 
     445void *fast_realloc_with_padding(void *ptr, unsigned int *size, unsigned int min_size) 
     446{ 
     447        void *res = ptr; 
     448        av_fast_malloc(&res, size, min_size + FF_INPUT_BUFFER_PADDING_SIZE); 
     449        if (res) memset(res + min_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); 
     450        return res; 
     451} 
  • trunk/CommonUtils.h

    r1139 r1173  
    6666int PerianInitEnter(volatile Boolean *inited); 
    6767void PerianInitExit(int unlock); 
    68          
     68 
     69void *fast_realloc_with_padding(void *ptr, unsigned int *size, unsigned int min_size); 
     70 
    6971#define PERIAN_PREF_DOMAIN CFSTR("org.perian.Perian") 
    7072 
  • trunk/FrameBuffer.c

    r1075 r1173  
    7676uint8_t *FFusionCreateEntireDataBuffer(FFusionData *data, uint8_t *buffer, int bufferSize) 
    7777{ 
    78         data->ringBuffer = av_fast_realloc(data->ringBuffer, &(data->ringSize), bufferSize + FF_INPUT_BUFFER_PADDING_SIZE); 
     78        data->ringBuffer = fast_realloc_with_padding(data->ringBuffer, &data->ringSize, bufferSize); 
    7979        if (data->ringBuffer) { 
    80                 uint8_t *dataPtr = data->ringBuffer; 
    81                 memcpy(dataPtr, buffer, bufferSize); 
    82                 memset(dataPtr + bufferSize, 0, FF_INPUT_BUFFER_PADDING_SIZE); 
     80                memcpy(data->ringBuffer, buffer, bufferSize); 
    8381        } 
    8482        return data->ringBuffer; 
  • trunk/VobSubCodec.c

    r1171 r1173  
    293293        // reallocate our buffer to be big enough to store the decompressed packet 
    294294        *bufferSize = AV_RB16(glob->codecData); 
    295         glob->codecData = av_fast_realloc(glob->codecData, &glob->bufferSize, *bufferSize); 
     295        glob->codecData = fast_realloc_with_padding(glob->codecData, &glob->bufferSize, *bufferSize); 
    296296         
    297297        // then decompress the rest of it 
     
    317317         
    318318        if (glob->codecData == NULL) { 
    319                 glob->codecData = malloc(myDrp->bufferSize + 2); 
     319                glob->codecData = av_malloc(myDrp->bufferSize + 2); 
    320320                glob->bufferSize = myDrp->bufferSize + 2; 
    321321        } 
    322322         
    323323        // make sure we have enough space to store the packet 
    324         glob->codecData = av_fast_realloc(glob->codecData, &glob->bufferSize, myDrp->bufferSize + 2); 
     324        glob->codecData = fast_realloc_with_padding(glob->codecData, &glob->bufferSize, myDrp->bufferSize + 2); 
    325325         
    326326        if (glob->compressed) {