Exemple #1
0
XIRef<XMemory> H264Encoder::EncodeYUV420P( XIRef<XMemory> pic,
                                           FrameType type )
{
    XIRef<XMemory> frame = new XMemory( DEFAULT_ENCODE_BUFFER_SIZE + DEFAULT_PADDING );

    uint8_t* p = &frame->Extend( DEFAULT_ENCODE_BUFFER_SIZE );

    size_t outputSize = EncodeYUV420P( pic->Map(),
                                       frame->Map(),
                                       frame->GetDataSize(),
                                       type );
    frame->ResizeData( outputSize );
    return frame;
}
Exemple #2
0
void AVMuxer::FinalizeBuffer( XIRef<XSDK::XMemory> buffer )
{
    if( _location != OUTPUT_LOCATION_BUFFER )
        X_THROW(("Unable to finalize a non buffer IO object."));

    _FinalizeCommon();

    uint8_t* fileBytes = NULL;
    int fileSize = avio_close_dyn_buf( _context->pb, &fileBytes );
    _context->pb = NULL;

    if( fileBytes == NULL || fileSize == 0 )
        X_THROW(("Unable to finalize empty buffer."));

    buffer->ResizeData( fileSize );

    memcpy( buffer->Map(), fileBytes, fileSize );

    av_freep( &fileBytes );
}