Skip to content

Commit 95f9226

Browse files
committed
Linux fixes
1 parent b00cfb6 commit 95f9226

File tree

8 files changed

+87
-20
lines changed

8 files changed

+87
-20
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ if (WIN32)
1414
endif (WIN32)
1515

1616
if (UNIX)
17-
SET(COMPILER_FLAGS "-fPIC" )
18-
SET(COMPILER_FLAGS_W_OMP "-fopenmp")
17+
SET(COMPILER_FLAGS -fPIC -O3)
18+
SET(COMPILER_FLAGS_W_OMP -fopenmp -O3)
1919
SET(ADDITIONAL_LIBS "-luuid -lpthread -lgomp")
2020
SET(TOY_LIBS "-lm")
2121
endif (UNIX)

Codec/decoder.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13146,9 +13146,10 @@ void ComputeOutputDimensions(DECODER *decoder, int frame,
1314613146

1314713147
#if (1 && DEBUG)
1314813148
FILE *logfile = decoder->logfile;
13149+
#endif
1314913150
CODEC_STATE *codec = &decoder->codec;
1315013151
int num_channels = codec->num_channels;
13151-
#endif
13152+
1315213153
FRAME_INFO *info = &decoder->frame;
1315313154

1315413155
//int progressive = codec->progressive;
@@ -13177,21 +13178,27 @@ void ComputeOutputDimensions(DECODER *decoder, int frame,
1317713178
{
1317813179
case DECODED_RESOLUTION_FULL:
1317913180
case DECODED_RESOLUTION_HALF_HORIZONTAL:
13181+
#if DEBUG
1318013182
assert(AllTransformBandsValid(transform_array, num_channels, frame));
13183+
#endif
1318113184
decoded_scale = 2;
1318213185
wavelet = transform_array[0]->wavelet[0];
1318313186
break;
1318413187

1318513188
case DECODED_RESOLUTION_HALF:
13189+
#if DEBUG
1318613190
assert(AllLowpassBandsValid(transform_array, num_channels, frame));
13191+
#endif
1318713192
decoded_scale = 1;
1318813193
wavelet = transform_array[0]->wavelet[0];
1318913194
break;
1319013195

1319113196
case DECODED_RESOLUTION_QUARTER:
1319213197
if(decoder->codec.encoded_format == ENCODED_FORMAT_BAYER)
1319313198
{
13199+
#if DEBUG
1319413200
assert(AllLowpassBandsValid(transform_array, num_channels, frame));
13201+
#endif
1319513202
decoded_scale = 1;
1319613203
wavelet = transform_array[0]->wavelet[0];
1319713204
}
@@ -13390,7 +13397,9 @@ void ReconstructSampleFrameToBuffer(DECODER *decoder, int frame, uint8_t *output
1339013397
{
1339113398
case DECODED_RESOLUTION_FULL:
1339213399
case DECODED_RESOLUTION_HALF_HORIZONTAL_DEBAYER:
13400+
#if DEBUG
1339313401
assert(AllTransformBandsValid(transform_array, num_channels, frame));
13402+
#endif
1339413403
wavelet = transform_array[0]->wavelet[0];
1339513404
// Get the decoded frame dimensions
1339613405
assert(wavelet != NULL);
@@ -13401,7 +13410,9 @@ void ReconstructSampleFrameToBuffer(DECODER *decoder, int frame, uint8_t *output
1340113410
break;
1340213411

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

1341413425
case DECODED_RESOLUTION_HALF_HORIZONTAL:
13426+
#if DEBUG
1341513427
assert(AllLowpassBandsValid(transform_array, num_channels, frame));
13428+
#endif
1341613429
wavelet = transform_array[0]->wavelet[0];
1341713430
// Get the decoded frame dimensions
1341813431
assert(wavelet != NULL);
@@ -13425,7 +13438,9 @@ void ReconstructSampleFrameToBuffer(DECODER *decoder, int frame, uint8_t *output
1342513438
case DECODED_RESOLUTION_QUARTER:
1342613439
if(decoder->codec.encoded_format == ENCODED_FORMAT_BAYER)
1342713440
{
13441+
#if DEBUG
1342813442
assert(AllLowpassBandsValid(transform_array, num_channels, frame));
13443+
#endif
1342913444
wavelet = transform_array[0]->wavelet[0];
1343013445
}
1343113446
else
@@ -16485,8 +16500,9 @@ void ReconstructQuarterFrame(DECODER *decoder, int num_channels,
1648516500
PIXEL *channel_row_ptr[CODEC_MAX_CHANNELS];
1648616501

1648716502
// Check that there is enough space for the intermediate results from each channel
16503+
#if DEBUG
1648816504
assert(output_width * sizeof(PIXEL) < buffer_size);
16489-
16505+
#endif
1649016506
ComputeCube(decoder);
1649116507

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

2131121327
// Check that the buffer is large enough
21328+
#if DEBUG
2131221329
assert((2 * num_channels * temporal_row_size) <= buffer_size);
21330+
#endif
2131321331

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

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

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

2245722479
if (inverted)
2245822480
{
@@ -24171,19 +24193,25 @@ void GetDecodedFrameDimensions(TRANSFORM **transform_array,
2417124193
{
2417224194
case DECODED_RESOLUTION_FULL_DEBAYER:
2417324195
case DECODED_RESOLUTION_HALF_HORIZONTAL_DEBAYER:
24196+
#if DEBUG
2417424197
assert(AllTransformBandsValid(transform_array, num_channels, frame_index));
24198+
#endif
2417524199
decoded_scale = 2;
2417624200
wavelet = transform_array[0]->wavelet[0];
2417724201
break;
2417824202

2417924203
case DECODED_RESOLUTION_FULL:
24204+
#if DEBUG
2418024205
assert(AllTransformBandsValid(transform_array, num_channels, frame_index));
24206+
#endif
2418124207
decoded_scale = 2;
2418224208
wavelet = transform_array[0]->wavelet[0];
2418324209
break;
2418424210
case DECODED_RESOLUTION_HALF_NODEBAYER:
2418524211
case DECODED_RESOLUTION_HALF:
24212+
#if DEBUG
2418624213
assert(AllLowpassBandsValid(transform_array, num_channels, frame_index));
24214+
#endif
2418724215
decoded_scale = 1;
2418824216
wavelet = transform_array[0]->wavelet[0];
2418924217
break;

Codec/encoder.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7087,7 +7087,9 @@ void EncodeQuantizedGroup(ENCODER *encoder, TRANSFORM *transform[], int num_tran
70877087
int subband = 0;
70887088

70897089
// Verify that the codebooks are valid
7090+
#if DEBUG
70907091
assert(ValidCodebooks());
7092+
#endif
70917093

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

74867488

74877489
// Verify that the codebooks are valid
7488-
assert(ValidCodebooks());
7490+
#if DEBUG
7491+
assert(ValidCodebooks());;
7492+
#endif
74897493

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

1061210616
// Verify that the codebooks are valid
10613-
assert(ValidCodebooks());
10617+
#if DEBUG
10618+
assert(ValidCodebooks());;
10619+
#endif
1061410620

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

1088010886
// Verify that the codebooks are valid
10887+
#if DEBUG
1088110888
assert(ValidCodebooks());
10889+
#endif
1088210890

1088310891
// Verify that there are three channels
1088410892
//assert(num_transforms == 3);

Codec/wavelet.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3023,8 +3023,10 @@ void TransformForwardSpatialBYR3(uint8_t *input, int input_pitch, FRAME_INFO *fr
30233023
#endif
30243024

30253025
// Check the input dimensions
3026+
#if DEBUG
30263027
assert(roi.width == frame_width);
30273028
assert(roi.height == frame_height);
3029+
#endif
30283030

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

36413643

36423644
// Check the input dimensions
3645+
#if DEBUG
36433646
assert(roi.width == frame_width);
36443647
assert(roi.height == frame_height);
3648+
#endif
36453649

36463650
for (channel = 0; channel < num_channels; channel++)
36473651
{

EncoderSDK/CFHDEncoderPool.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,11 +766,14 @@ CFHD_ReleaseEncoderPool(CFHD_EncoderPoolRef encoderPoolRef)
766766
try
767767
{
768768
CEncoderPool *encoderPool = GetEncoderPool(encoderPoolRef);
769-
delete encoderPool;
769+
#ifdef _WINDOWS
770+
delete encoderPool; //TODO need find out why this isn't working on Linux.
771+
#endif
770772
return CFHD_ERROR_OKAY;
771773
}
772774
catch (...)
773775
{
776+
printf("CFHD_ReleaseEncoderPool error\n");
774777
return CFHD_ERROR_UNEXPECTED;
775778
}
776779
}

Example/TestCFHD.cpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "CFHDMetadata.h"
3434

3535

36-
#include "MP4reader.h"
36+
#include "mp4reader.h"
3737

3838
#define QBIST_SEED 50
3939
#define ENABLE_3D 0 //2D or 3D-stereoscope encodign
@@ -69,7 +69,7 @@
6969
#define BASENAME_OUT "OUTD"
7070
#else
7171
#define MAX_DEC_FRAMES 5
72-
#define MAX_ENC_FRAMES 250
72+
#define MAX_ENC_FRAMES 500
7373
#define MAX_QUAL_FRAMES 10
7474
#define POOL_THREADS 16
7575
#define POOL_QUEUE_LENGTH 24
@@ -413,7 +413,11 @@ CFHD_Error DecodeMOVIE(char *filename, char *ext)
413413
float length;
414414
void *handle;
415415

416+
#ifdef _WINDOWS
416417
if (0 == stricmp("AVI", ext)) AVI = 1;
418+
#else
419+
if (0 == strcasecmp("AVI", ext)) AVI = 1;
420+
#endif
417421

418422
if(AVI)
419423
handle = OpenAVISource(filename, AVI_TRAK_TYPE, AVI_TRAK_SUBTYPE);
@@ -1066,18 +1070,23 @@ CFHD_Error EncodeDecodeQualityTest()
10661070

10671071
int main(int argc, char **argv)
10681072
{
1073+
int showusage = 0;
10691074
CFHD_Error error = CFHD_ERROR_OKAY;
10701075

1071-
if (argc == 1)
1076+
if (argc != 2)
10721077
{
1073-
#if DO_DECODE
1074-
error = EncodeDecodeQualityTest();
1075-
#else
1076-
error = EncodeSpeedTest();
1077-
#endif
1078-
if (error) printf("error code: %d\n", error);
1078+
showusage = 1;
10791079
}
1080-
else
1080+
else if (argv[1][0] == '-')
1081+
{
1082+
if (argv[1][1] == 'd' || argv[1][1] == 'D')
1083+
error = EncodeDecodeQualityTest();
1084+
else if (argv[1][1] == 'e' || argv[1][1] == 'E')
1085+
error = EncodeSpeedTest();
1086+
else
1087+
showusage = 1;
1088+
}
1089+
else
10811090
{
10821091
char ext[4] = "";
10831092
int len = strlen(argv[1]);
@@ -1092,6 +1101,13 @@ int main(int argc, char **argv)
10921101
error = DecodeMOVIE(argv[1], ext);
10931102
}
10941103

1104+
if (showusage)
1105+
{
1106+
printf("usage: %s [switches] or <filname.MOV|MP4|AVI>\n", argv[0]);
1107+
printf(" -D = decoder tester\n");
1108+
printf(" -E = encoder tester\n");
1109+
}
1110+
10951111
if (error) printf("error code: %d\n", error);
10961112
return error;
10971113
}

Example/mp4reader.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void *OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) //
9999
#ifdef _WINDOWS
100100
fopen_s(&mp4->mediafp, filename, "rb");
101101
#else
102-
mediafp = fopen(filename, "rb");
102+
mp4->mediafp = fopen(filename, "rb");
103103
#endif
104104

105105
if (mp4->mediafp)
@@ -478,6 +478,11 @@ void *OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) //
478478
}
479479
} while (len > 0);
480480
}
481+
else
482+
{
483+
printf("Could not open %s for input\n", filename);
484+
exit(1);
485+
}
481486

482487
return (void *)mp4;
483488
}

Example/readavi.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ This code falls under the BSD license.
1616
#include "fileio.h"
1717
#include "mp4reader.h"
1818

19+
#ifdef _WINDOWS
1920
#define STRINGCASECOMPARE _stricmp
20-
//#define STRINGCASECOMPARE STRINGCASECOMPARE
21+
#else
22+
#define STRINGCASECOMPARE strcasecmp
23+
#endif
2124

2225

2326
#define PRINT_AVI_STRUCTURE 0
@@ -624,7 +627,7 @@ void *OpenAVISource(char *filename, uint32_t traktype, uint32_t subtype)
624627
#ifdef _WINDOWS
625628
fopen_s(&mp4->mediafp, filename, "rb");
626629
#else
627-
mediafp = fopen(filename, "rb");
630+
mp4->mediafp = fopen(filename, "rb");
628631
#endif
629632

630633
if (mp4->mediafp == 0)

0 commit comments

Comments
 (0)