Skip to content

Commit

Permalink
Linux fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dnewman-gpsw committed Oct 23, 2017
1 parent b00cfb6 commit 95f9226
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 20 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ if (WIN32)
endif (WIN32)

if (UNIX)
SET(COMPILER_FLAGS "-fPIC" )
SET(COMPILER_FLAGS_W_OMP "-fopenmp")
SET(COMPILER_FLAGS -fPIC -O3)
SET(COMPILER_FLAGS_W_OMP -fopenmp -O3)
SET(ADDITIONAL_LIBS "-luuid -lpthread -lgomp")
SET(TOY_LIBS "-lm")
endif (UNIX)
Expand Down
32 changes: 30 additions & 2 deletions Codec/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -13146,9 +13146,10 @@ void ComputeOutputDimensions(DECODER *decoder, int frame,

#if (1 && DEBUG)
FILE *logfile = decoder->logfile;
#endif
CODEC_STATE *codec = &decoder->codec;
int num_channels = codec->num_channels;
#endif

FRAME_INFO *info = &decoder->frame;

//int progressive = codec->progressive;
Expand Down Expand Up @@ -13177,21 +13178,27 @@ void ComputeOutputDimensions(DECODER *decoder, int frame,
{
case DECODED_RESOLUTION_FULL:
case DECODED_RESOLUTION_HALF_HORIZONTAL:
#if DEBUG
assert(AllTransformBandsValid(transform_array, num_channels, frame));
#endif
decoded_scale = 2;
wavelet = transform_array[0]->wavelet[0];
break;

case DECODED_RESOLUTION_HALF:
#if DEBUG
assert(AllLowpassBandsValid(transform_array, num_channels, frame));
#endif
decoded_scale = 1;
wavelet = transform_array[0]->wavelet[0];
break;

case DECODED_RESOLUTION_QUARTER:
if(decoder->codec.encoded_format == ENCODED_FORMAT_BAYER)
{
#if DEBUG
assert(AllLowpassBandsValid(transform_array, num_channels, frame));
#endif
decoded_scale = 1;
wavelet = transform_array[0]->wavelet[0];
}
Expand Down Expand Up @@ -13390,7 +13397,9 @@ void ReconstructSampleFrameToBuffer(DECODER *decoder, int frame, uint8_t *output
{
case DECODED_RESOLUTION_FULL:
case DECODED_RESOLUTION_HALF_HORIZONTAL_DEBAYER:
#if DEBUG
assert(AllTransformBandsValid(transform_array, num_channels, frame));
#endif
wavelet = transform_array[0]->wavelet[0];
// Get the decoded frame dimensions
assert(wavelet != NULL);
Expand All @@ -13401,7 +13410,9 @@ void ReconstructSampleFrameToBuffer(DECODER *decoder, int frame, uint8_t *output
break;

case DECODED_RESOLUTION_HALF:
#if DEBUG
assert(AllLowpassBandsValid(transform_array, num_channels, frame));
#endif
wavelet = transform_array[0]->wavelet[0];
// Get the decoded frame dimensions
assert(wavelet != NULL);
Expand All @@ -13412,7 +13423,9 @@ void ReconstructSampleFrameToBuffer(DECODER *decoder, int frame, uint8_t *output
break;

case DECODED_RESOLUTION_HALF_HORIZONTAL:
#if DEBUG
assert(AllLowpassBandsValid(transform_array, num_channels, frame));
#endif
wavelet = transform_array[0]->wavelet[0];
// Get the decoded frame dimensions
assert(wavelet != NULL);
Expand All @@ -13425,7 +13438,9 @@ void ReconstructSampleFrameToBuffer(DECODER *decoder, int frame, uint8_t *output
case DECODED_RESOLUTION_QUARTER:
if(decoder->codec.encoded_format == ENCODED_FORMAT_BAYER)
{
#if DEBUG
assert(AllLowpassBandsValid(transform_array, num_channels, frame));
#endif
wavelet = transform_array[0]->wavelet[0];
}
else
Expand Down Expand Up @@ -16485,8 +16500,9 @@ void ReconstructQuarterFrame(DECODER *decoder, int num_channels,
PIXEL *channel_row_ptr[CODEC_MAX_CHANNELS];

// Check that there is enough space for the intermediate results from each channel
#if DEBUG
assert(output_width * sizeof(PIXEL) < buffer_size);

#endif
ComputeCube(decoder);

// Get pointers into the wavelets for each channel
Expand Down Expand Up @@ -21309,7 +21325,9 @@ void TransformInverseFrameToYUV(TRANSFORM *transform[], int frame_index, int num
assert(0 < num_channels && num_channels <= TRANSFORM_MAX_CHANNELS);

// Check that the buffer is large enough
#if DEBUG
assert((2 * num_channels * temporal_row_size) <= buffer_size);
#endif

// Allocate buffers for a single row of lowpass and highpass temporal coefficients
// and initialize the arrays of row pointers into the horizontal transform bands
Expand Down Expand Up @@ -21854,7 +21872,9 @@ void TransformInverseFrameToRow16u(DECODER *decoder, TRANSFORM *transform[], int

// Buffer must be large enough for two rows of temporal coefficients (lowpass and highpass)
// plus the buffer used by the inverse horizontal transform for its intermediate results
#if DEBUG
assert((2 * temporal_row_size) <= buffer_size);
#endif

// Allocate buffers for one row of lowpass and highpass temporal coefficients
temporal_lowpass = (PIXEL *)&buffer[0];
Expand Down Expand Up @@ -22452,7 +22472,9 @@ void TransformInverseFrameToBuffer(TRANSFORM *transform[], int frame_index, int
// Allocate buffer space for the intermediate YUV data
yuv_buffer = buffer + temporal_buffer_size;
yuv_buffer_size = buffer_size - temporal_buffer_size;
#if DEBUG
assert(yuv_buffer_size >= 2 * yuv_row_size);
#endif

if (inverted)
{
Expand Down Expand Up @@ -24171,19 +24193,25 @@ void GetDecodedFrameDimensions(TRANSFORM **transform_array,
{
case DECODED_RESOLUTION_FULL_DEBAYER:
case DECODED_RESOLUTION_HALF_HORIZONTAL_DEBAYER:
#if DEBUG
assert(AllTransformBandsValid(transform_array, num_channels, frame_index));
#endif
decoded_scale = 2;
wavelet = transform_array[0]->wavelet[0];
break;

case DECODED_RESOLUTION_FULL:
#if DEBUG
assert(AllTransformBandsValid(transform_array, num_channels, frame_index));
#endif
decoded_scale = 2;
wavelet = transform_array[0]->wavelet[0];
break;
case DECODED_RESOLUTION_HALF_NODEBAYER:
case DECODED_RESOLUTION_HALF:
#if DEBUG
assert(AllLowpassBandsValid(transform_array, num_channels, frame_index));
#endif
decoded_scale = 1;
wavelet = transform_array[0]->wavelet[0];
break;
Expand Down
12 changes: 10 additions & 2 deletions Codec/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -7087,7 +7087,9 @@ void EncodeQuantizedGroup(ENCODER *encoder, TRANSFORM *transform[], int num_tran
int subband = 0;

// Verify that the codebooks are valid
#if DEBUG
assert(ValidCodebooks());
#endif

// Verify that there are three channels
assert(num_transforms == 3);
Expand Down Expand Up @@ -7485,7 +7487,9 @@ void EncodeQuantizedGroup(ENCODER *encoder, TRANSFORM *transform[], int num_tran


// Verify that the codebooks are valid
assert(ValidCodebooks());
#if DEBUG
assert(ValidCodebooks());;
#endif

// Verify that there are three channels
//assert(num_transforms == 3); //DAN06302004
Expand Down Expand Up @@ -10610,7 +10614,9 @@ void EncodeQuantizedGroupThreaded(ENCODER *encoder, TRANSFORM *transform[], int
int subband = 0;

// Verify that the codebooks are valid
assert(ValidCodebooks());
#if DEBUG
assert(ValidCodebooks());;
#endif

// Verify that there are three channels
assert(num_transforms == 3);
Expand Down Expand Up @@ -10878,7 +10884,9 @@ void EncodeQuantizedChannel(ENCODER *encoder, TRANSFORM *transform, int channel,
int subband = 0;

// Verify that the codebooks are valid
#if DEBUG
assert(ValidCodebooks());
#endif

// Verify that there are three channels
//assert(num_transforms == 3);
Expand Down
4 changes: 4 additions & 0 deletions Codec/wavelet.c
Original file line number Diff line number Diff line change
Expand Up @@ -3023,8 +3023,10 @@ void TransformForwardSpatialBYR3(uint8_t *input, int input_pitch, FRAME_INFO *fr
#endif

// Check the input dimensions
#if DEBUG
assert(roi.width == frame_width);
assert(roi.height == frame_height);
#endif

for (channel = 0; channel < num_channels; channel++)
{
Expand Down Expand Up @@ -3640,8 +3642,10 @@ void TransformForwardSpatialRGB30(uint8_t *input, int input_pitch, FRAME_INFO *f


// Check the input dimensions
#if DEBUG
assert(roi.width == frame_width);
assert(roi.height == frame_height);
#endif

for (channel = 0; channel < num_channels; channel++)
{
Expand Down
5 changes: 4 additions & 1 deletion EncoderSDK/CFHDEncoderPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,14 @@ CFHD_ReleaseEncoderPool(CFHD_EncoderPoolRef encoderPoolRef)
try
{
CEncoderPool *encoderPool = GetEncoderPool(encoderPoolRef);
delete encoderPool;
#ifdef _WINDOWS
delete encoderPool; //TODO need find out why this isn't working on Linux.
#endif
return CFHD_ERROR_OKAY;
}
catch (...)
{
printf("CFHD_ReleaseEncoderPool error\n");
return CFHD_ERROR_UNEXPECTED;
}
}
36 changes: 26 additions & 10 deletions Example/TestCFHD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "CFHDMetadata.h"


#include "MP4reader.h"
#include "mp4reader.h"

#define QBIST_SEED 50
#define ENABLE_3D 0 //2D or 3D-stereoscope encodign
Expand Down Expand Up @@ -69,7 +69,7 @@
#define BASENAME_OUT "OUTD"
#else
#define MAX_DEC_FRAMES 5
#define MAX_ENC_FRAMES 250
#define MAX_ENC_FRAMES 500
#define MAX_QUAL_FRAMES 10
#define POOL_THREADS 16
#define POOL_QUEUE_LENGTH 24
Expand Down Expand Up @@ -413,7 +413,11 @@ CFHD_Error DecodeMOVIE(char *filename, char *ext)
float length;
void *handle;

#ifdef _WINDOWS
if (0 == stricmp("AVI", ext)) AVI = 1;
#else
if (0 == strcasecmp("AVI", ext)) AVI = 1;
#endif

if(AVI)
handle = OpenAVISource(filename, AVI_TRAK_TYPE, AVI_TRAK_SUBTYPE);
Expand Down Expand Up @@ -1066,18 +1070,23 @@ CFHD_Error EncodeDecodeQualityTest()

int main(int argc, char **argv)
{
int showusage = 0;
CFHD_Error error = CFHD_ERROR_OKAY;

if (argc == 1)
if (argc != 2)
{
#if DO_DECODE
error = EncodeDecodeQualityTest();
#else
error = EncodeSpeedTest();
#endif
if (error) printf("error code: %d\n", error);
showusage = 1;
}
else
else if (argv[1][0] == '-')
{
if (argv[1][1] == 'd' || argv[1][1] == 'D')
error = EncodeDecodeQualityTest();
else if (argv[1][1] == 'e' || argv[1][1] == 'E')
error = EncodeSpeedTest();
else
showusage = 1;
}
else
{
char ext[4] = "";
int len = strlen(argv[1]);
Expand All @@ -1092,6 +1101,13 @@ int main(int argc, char **argv)
error = DecodeMOVIE(argv[1], ext);
}

if (showusage)
{
printf("usage: %s [switches] or <filname.MOV|MP4|AVI>\n", argv[0]);
printf(" -D = decoder tester\n");
printf(" -E = encoder tester\n");
}

if (error) printf("error code: %d\n", error);
return error;
}
7 changes: 6 additions & 1 deletion Example/mp4reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void *OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) //
#ifdef _WINDOWS
fopen_s(&mp4->mediafp, filename, "rb");
#else
mediafp = fopen(filename, "rb");
mp4->mediafp = fopen(filename, "rb");
#endif

if (mp4->mediafp)
Expand Down Expand Up @@ -478,6 +478,11 @@ void *OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) //
}
} while (len > 0);
}
else
{
printf("Could not open %s for input\n", filename);
exit(1);
}

return (void *)mp4;
}
Expand Down
7 changes: 5 additions & 2 deletions Example/readavi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ This code falls under the BSD license.
#include "fileio.h"
#include "mp4reader.h"

#ifdef _WINDOWS
#define STRINGCASECOMPARE _stricmp
//#define STRINGCASECOMPARE STRINGCASECOMPARE
#else
#define STRINGCASECOMPARE strcasecmp
#endif


#define PRINT_AVI_STRUCTURE 0
Expand Down Expand Up @@ -624,7 +627,7 @@ void *OpenAVISource(char *filename, uint32_t traktype, uint32_t subtype)
#ifdef _WINDOWS
fopen_s(&mp4->mediafp, filename, "rb");
#else
mediafp = fopen(filename, "rb");
mp4->mediafp = fopen(filename, "rb");
#endif

if (mp4->mediafp == 0)
Expand Down

0 comments on commit 95f9226

Please sign in to comment.