Linux: Fixed bug and compilation errors/warnings for avi recording

This commit is contained in:
Souryo 2016-12-30 14:47:19 -05:00
parent b9f806d6f4
commit 5cc9c3915d
5 changed files with 45 additions and 47 deletions

View file

@ -21,6 +21,7 @@
#include "stdafx.h"
#include <fstream>
#include <cstring>
#include "AviWriter.h"
#include "BaseCodec.h"
#include "RawCodec.h"

View file

@ -37,8 +37,6 @@ private:
uint8_t* _frameBuffer = nullptr;
int _bufSize = 0;
void *_buf = nullptr;
vector<uint8_t> _aviIndex;
SimpleLock _audioLock;

View file

@ -1,5 +1,6 @@
#pragma once
#include "stdafx.h"
#include <cstring>
#include "BaseCodec.h"
class RawCodec : public BaseCodec

View file

@ -189,13 +189,9 @@ INLINE void ZmbvCodec::AddXorBlock(int vx,int vy,FrameBlock * block) {
template<class P>
void ZmbvCodec::AddXorFrame(void) {
int written=0;
int lastvector=0;
signed char * vectors=(signed char*)&work[workUsed];
/* Align the following xor data on 4 byte boundary*/
workUsed=(workUsed + blockcount*2 +3) & ~3;
int totalx=0;
int totaly=0;
for (int b=0;b<blockcount;b++) {
FrameBlock * block=&blocks[b];
int bestvx = 0;
@ -208,7 +204,6 @@ void ZmbvCodec::AddXorFrame(void) {
int vy = VectorTable[v].y;
if (PossibleBlock<P>(vx, vy, block) < 4) {
possibles--;
// if (!possibles) Msg("Ran out of possibles, at %d of %d best %d\n",v,VectorCount,bestchange);
int testchange=CompareBlock<P>(vx,vy, block);
if (testchange<bestchange) {
bestchange=testchange;
@ -329,16 +324,18 @@ int ZmbvCodec::FinishCompressFrame(uint8_t** compressedData)
} else {
/* Add the delta frame data */
switch (format) {
case ZMBV_FORMAT_8BPP:
AddXorFrame<char>();
break;
case ZMBV_FORMAT_15BPP:
case ZMBV_FORMAT_16BPP:
AddXorFrame<short>();
break;
case ZMBV_FORMAT_32BPP:
AddXorFrame<long>();
break;
case ZMBV_FORMAT_8BPP:
AddXorFrame<int8_t>();
break;
case ZMBV_FORMAT_15BPP:
case ZMBV_FORMAT_16BPP:
AddXorFrame<int16_t>();
break;
default:
case ZMBV_FORMAT_32BPP:
AddXorFrame<int32_t>();
break;
}
}
/* Create the actual frame with compression */
@ -349,7 +346,8 @@ int ZmbvCodec::FinishCompressFrame(uint8_t** compressedData)
zstream.next_out = (Bytef *)(compressInfo.writeBuf + compressInfo.writeDone);
zstream.avail_out = compressInfo.writeSize - compressInfo.writeDone;
zstream.total_out = 0;
int res = deflate(&zstream, Z_SYNC_FLUSH);
deflate(&zstream, Z_SYNC_FLUSH);
*compressedData = _buf;

View file

@ -46,50 +46,50 @@ class ZmbvCodec : public BaseCodec
{
private:
struct FrameBlock {
int start;
int dx,dy;
int start = 0;
int dx = 0,dy = 0;
};
struct CodecVector {
int x,y;
int slot;
int x = 0,y = 0;
int slot = 0;
};
struct KeyframeHeader {
unsigned char high_version;
unsigned char low_version;
unsigned char compression;
unsigned char format;
unsigned char blockwidth,blockheight;
unsigned char high_version = 0;
unsigned char low_version = 0;
unsigned char compression = 0;
unsigned char format = 0;
unsigned char blockwidth = 0,blockheight = 0;
};
struct {
int linesDone;
int writeSize;
int writeDone;
unsigned char *writeBuf;
int linesDone = 0;
int writeSize = 0;
int writeDone = 0;
unsigned char *writeBuf = nullptr;
} compressInfo;
CodecVector VectorTable[512];
int VectorCount;
CodecVector VectorTable[512] = {};
int VectorCount = 0;
unsigned char *oldframe, *newframe;
unsigned char *buf1, *buf2, *work;
int bufsize;
unsigned char *oldframe=nullptr, *newframe=nullptr;
unsigned char *buf1=nullptr, *buf2=nullptr, *work=nullptr;
int bufsize = 0;
int blockcount;
FrameBlock * blocks;
int blockcount = 0;
FrameBlock * blocks = nullptr;
int workUsed, workPos;
int workUsed = 0, workPos = 0;
int palsize;
char palette[256*4];
int height, width, pitch;
zmbv_format_t format;
int pixelsize;
int palsize = 0;
char palette[256*4] = {};
int height = 0, width = 0, pitch = 0;
zmbv_format_t format = zmbv_format_t::ZMBV_FORMAT_NONE;
int pixelsize = 0;
uint8_t* _buf;
uint32_t _bufSize;
uint8_t* _buf = nullptr;
uint32_t _bufSize = 0;
z_stream zstream;
z_stream zstream = {};
// methods
void FreeBuffers(void);