nanojpeg: signedness fixes
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1813 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -153,7 +153,7 @@ bool NanoJPEGExperiment::run()
|
||||
uint32_t newdata = data ^ (1 << bitnr);
|
||||
reg->setData(newdata);
|
||||
// note at what IP we did it
|
||||
int32_t injection_ip = simulator.getRegisterManager().getInstructionPointer();
|
||||
uint32_t injection_ip = simulator.getRegisterManager().getInstructionPointer();
|
||||
param.msg.set_injection_ip(injection_ip);
|
||||
log << "fault injected @ ip " << injection_ip << " reg " << reg->getName()
|
||||
<< " 0x" << hex << ((int)data) << " -> 0x" << ((int)newdata) << endl;
|
||||
@ -217,7 +217,7 @@ bool NanoJPEGExperiment::run()
|
||||
MemoryManager& mm = simulator.getMemoryManager();
|
||||
uint32_t output_image_addr;
|
||||
mm.getBytes(addr_output_image_ptr, 4, &output_image_addr);
|
||||
int32_t output_image_size;
|
||||
uint32_t output_image_size;
|
||||
mm.getBytes(addr_output_image_size, 4, &output_image_size);
|
||||
log << "image address " << hex << output_image_addr << " size " << dec << output_image_size << endl;
|
||||
if (output_image_size != 3 * psnr.getWidth() * psnr.getHeight()) {
|
||||
|
||||
@ -20,11 +20,11 @@ static inline double square(double x)
|
||||
return x*x;
|
||||
}
|
||||
|
||||
static double image_rgb_mse(const unsigned char *f1, const unsigned char *f2, int width, int height, double max)
|
||||
static double image_rgb_mse(const unsigned char *f1, const unsigned char *f2, unsigned width, unsigned height, double max)
|
||||
{
|
||||
double sum = 0.0;
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (unsigned y = 0; y < height; ++y) {
|
||||
for (unsigned x = 0; x < width; ++x) {
|
||||
sum += square(f1[x*y*3+0] - f2[x*y*3+0]);
|
||||
sum += square(f1[x*y*3+1] - f2[x*y*3+1]);
|
||||
sum += square(f1[x*y*3+2] - f2[x*y*3+2]);
|
||||
@ -33,7 +33,7 @@ static double image_rgb_mse(const unsigned char *f1, const unsigned char *f2, in
|
||||
return sum / (3 * height * width);
|
||||
}
|
||||
|
||||
static double image_rgb_psnr(const unsigned char *f1, const unsigned char *f2, int width, int height, double max)
|
||||
static double image_rgb_psnr(const unsigned char *f1, const unsigned char *f2, unsigned width, unsigned height, double max)
|
||||
{
|
||||
double mse = image_rgb_mse(f1, f2, width, height, max);
|
||||
return 20.0 * log10(max / sqrt(mse));
|
||||
@ -76,4 +76,5 @@ bool PSNR::load_refimage(char const *refimage_filename)
|
||||
std::cerr << "image too small" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
class PSNR {
|
||||
private:
|
||||
std::string refimg;
|
||||
int refimg_width, refimg_height, refimg_max;
|
||||
unsigned refimg_width, refimg_height, refimg_max;
|
||||
|
||||
public:
|
||||
PSNR(char const *refimage_filename)
|
||||
@ -19,8 +19,8 @@ public:
|
||||
// we only accept P6 without comments
|
||||
bool load_refimage(char const *refimage_filename);
|
||||
double calculate(const std::string& img);
|
||||
int getWidth() { return refimg_width; }
|
||||
int getHeight() { return refimg_height; }
|
||||
unsigned getWidth() { return refimg_width; }
|
||||
unsigned getHeight() { return refimg_height; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user