From 20d5c4c1a806e9c3602a36499f0873029a9ad232 Mon Sep 17 00:00:00 2001 From: Francois-Olivier Devaux Date: Fri, 5 Mar 2010 21:17:11 +0000 Subject: [PATCH] First import of OPJ_Validate tool --- ChangeLog | 3 + OPJ_Validate/Makefile | 2 + OPJ_Validate/OPJ_Param_File_v0_1.txt | 100 +++++++ OPJ_Validate/OPJ_Validate.c | 244 ++++++++++++++++ OPJ_Validate/OPJ_Validate.dsp | 108 +++++++ OPJ_Validate/OPJ_Validate.dsw | 29 ++ .../OPJ_Validate_Candidate_vs_Ref.bat | 8 + OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.sh | 16 + OPJ_Validate/OPJ_Validate_Create_Ref.bat | 4 + OPJ_Validate/OPJ_Validate_Create_Ref.sh | 13 + OPJ_Validate/README.txt | 46 +++ OPJ_Validate/linux_OPJ_Param_File_v0_1.txt | 89 ++++++ OPJ_Validate/md5.c | 276 ++++++++++++++++++ OPJ_Validate/md5.h | 59 ++++ OPJ_Validate/original/README.txt | 1 + 15 files changed, 998 insertions(+) create mode 100644 OPJ_Validate/Makefile create mode 100644 OPJ_Validate/OPJ_Param_File_v0_1.txt create mode 100644 OPJ_Validate/OPJ_Validate.c create mode 100644 OPJ_Validate/OPJ_Validate.dsp create mode 100644 OPJ_Validate/OPJ_Validate.dsw create mode 100644 OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.bat create mode 100644 OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.sh create mode 100644 OPJ_Validate/OPJ_Validate_Create_Ref.bat create mode 100644 OPJ_Validate/OPJ_Validate_Create_Ref.sh create mode 100644 OPJ_Validate/README.txt create mode 100644 OPJ_Validate/linux_OPJ_Param_File_v0_1.txt create mode 100644 OPJ_Validate/md5.c create mode 100644 OPJ_Validate/md5.h create mode 100644 OPJ_Validate/original/README.txt diff --git a/ChangeLog b/ChangeLog index 6969b936..1339fa8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ What's New for OpenJPEG ! : changed + : added +March 5, 2010 ++ [FOD] First import of OPJ_Validate tool + February 18, 2010 * [FOD] JP3D Module. Fixed issue when computing the number of elements in an array that leads to crash (thanks Kristof). Updated JP3D makefiles. diff --git a/OPJ_Validate/Makefile b/OPJ_Validate/Makefile new file mode 100644 index 00000000..c5434f08 --- /dev/null +++ b/OPJ_Validate/Makefile @@ -0,0 +1,2 @@ +OPJ_Validate_Makee: OPJ_Validate.c md5.c + gcc -o OPJ_Validate OPJ_Validate.c md5.c -I. diff --git a/OPJ_Validate/OPJ_Param_File_v0_1.txt b/OPJ_Validate/OPJ_Param_File_v0_1.txt new file mode 100644 index 00000000..881c92d9 --- /dev/null +++ b/OPJ_Validate/OPJ_Param_File_v0_1.txt @@ -0,0 +1,100 @@ +#Version 0.1 - February 9th 2007 +#Usage: OPJ_Validate OpenJPEG_command_line +#Example: OPJ_Validate image_to_j2k.exe -i original/Bretagne1.ppm -o original/Bretagne1.j2k -r 200, 50, 10 +#Attention: don't forget the *.exe extension for the executable file, and check the paths + +image_to_j2k.exe -i original/Bretagne1.ppm -o temp/Bretagne1_0.j2k -r 200,50,10 +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.ppm +image_to_j2k.exe -i original/Bretagne2.ppm -o temp/Bretagne2_0.j2k -c [128,128],[128,128],[128,128] -r 100,20,2 -t 640,480 -b 32,32 +j2k_to_image.exe -i original/Bretagne2.j2k -o temp/Bretagne2.ppm -r 2 +image_to_j2k.exe -i original/Cevennes1.bmp -o temp/Cevennes1.j2k -r 10 +j2k_to_image.exe -i original/Cevennes1.j2k -o temp/Cevennes1.bmp -l 2 +image_to_j2k.exe -i original/Cevennes2.ppm -o temp/Cevennes2.jp2 -r 50 +j2k_to_image.exe -i original/Cevennes2.jp2 -o temp/Cevennes2.ppm +image_to_j2k.exe -i original/Rome.bmp -o temp/Rome.jp2 -q 30,35,50 -p LRCP -n 3 +j2k_to_image.exe -i original/Rome.jp2 -o temp/Rome.ppm +image_to_j2k.exe -i original/Bretagne1.ppm -o temp/Bretagne1_1.j2k -q 30,35,40 -n 2 +image_to_j2k.exe -i original/Bretagne1.ppm -o temp/Bretagne1_2.j2k -q 30,35,40 -b 16,16 -c [101,101] +image_to_j2k.exe -i original/Bretagne2.ppm -o temp/Bretagne2_1.j2k -t 127,127 -p PCRL +image_to_j2k.exe -i original/X_4_2K_24_185_CBR_WB_000.tif -o temp/X_4_2K_24_185_CBR_WB_000.j2k -cinema2K 24 +image_to_j2k.exe -i original/X_5_2K_24_235_CBR_STEM24_000.tif -o temp/X_5_2K_24_235_CBR_STEM24_000.j2k -cinema2K 48 +image_to_j2k.exe -i original/X_6_2K_24_FULL_CBR_CIRCLE_000.tif -o temp/X_6_2K_24_FULL_CBR_CIRCLE_000.j2k -cinema2K 24 +#à remettre +#image_to_j2k.exe -i original/X_16_4K_24_185_CBR_WB_000.tif -o temp/X_16_4K_24_185_CBR_WB_000.j2k -cinema4K +j2k_to_image.exe -i original/A_4_2K_24_185_CBR_WB_000.j2k -o temp/A_4_2K_24_185_CBR_WB_000.tif +j2k_to_image.exe -i original/B_5_2K_24_235_CBR_STEM24_000.j2k -o temp/B_5_2K_24_235_CBR_STEM24_000.tif +j2k_to_image.exe -i original/C_6_2K_24_FULL_CBR_CIRCLE_000.j2k -o temp/C_6_2K_24_FULL_CBR_CIRCLE_000.tif +#à remettre +#j2k_to_image.exe -i original/C_18_4K_24_FULL_CBR_CIRCLE_000.j2k -o temp/C_18_4K_24_FULL_CBR_CIRCLE_000.tif +j2k_to_image.exe -i original/p0_01.j2k -o temp/p0_01.tif +j2k_to_image.exe -i original/p0_02.j2k -o temp/p0_02.tif +j2k_to_image.exe -i original/p0_03.j2k -o temp/p0_03.tif +j2k_to_image.exe -i original/p0_04.j2k -o temp/p0_04.tif +#à remettre +#j2k_to_image.exe -i original/p0_07.j2k -o temp/p0_07.tif +j2k_to_image.exe -i original/p0_08.j2k -o temp/p0_08.tif +j2k_to_image.exe -i original/p0_09.j2k -o temp/p0_09.tif +j2k_to_image.exe -i original/p0_10.j2k -o temp/p0_10.tif +j2k_to_image.exe -i original/p0_11.j2k -o temp/p0_11.tif +j2k_to_image.exe -i original/p0_12.j2k -o temp/p0_12.tif +j2k_to_image.exe -i original/p0_14.j2k -o temp/p0_14.tif +j2k_to_image.exe -i original/p0_15.j2k -o temp/p0_15.tif +j2k_to_image.exe -i original/p0_16.j2k -o temp/p0_16.tif +j2k_to_image.exe -i original/p1_01.j2k -o temp/p1_01.tif +j2k_to_image.exe -i original/p1_02.j2k -o temp/p1_02.tif +j2k_to_image.exe -i original/p1_04.j2k -o temp/p1_04.tif +j2k_to_image.exe -i original/p1_05.j2k -o temp/p1_05.tif +j2k_to_image.exe -i original/p1_06.j2k -o temp/p1_06.tif +image_to_j2k.exe -i original/c0p0_01.pgx -o temp/c0p0_01.j2k +image_to_j2k.exe -i original/c0p0_02.pgx -o temp/c0p0_02.j2k +image_to_j2k.exe -i original/c0p0_03r0.pgx -o temp/c0p0_03r0.j2k +image_to_j2k.exe -i original/c0p0_03r1.pgx -o temp/c0p0_03r1.j2k +image_to_j2k.exe -i original/c0p0_04.pgx -o temp/c00_p04.j2k +image_to_j2k.exe -i original/c0p0_05.pgx -o temp/c0p0_05.j2k +image_to_j2k.exe -i original/c0p0_06.pgx -o temp/c0p0_06.j2k +image_to_j2k.exe -i original/c0p0_07.pgx -o temp/c0p0_07.j2k +image_to_j2k.exe -i original/c0p0_08.pgx -o temp/c0p0_08.j2k +image_to_j2k.exe -i original/c0p0_09.pgx -o temp/c0p0_09.j2k +image_to_j2k.exe -i original/c0p0_10.pgx -o temp/c0p0_10.j2k +image_to_j2k.exe -i original/c0p0_11.pgx -o temp/c0p0_11.j2k +image_to_j2k.exe -i original/c0p0_12.pgx -o temp/c0p0_12.j2k +image_to_j2k.exe -i original/c0p0_13.pgx -o temp/c0p0_13.j2k +image_to_j2k.exe -i original/c0p0_14.pgx -o temp/c0p0_14.j2k +image_to_j2k.exe -i original/c0p0_15r0.pgx -o temp/c0p0_15r0.j2k +image_to_j2k.exe -i original/c0p0_15r1.pgx -o temp/c0p0_15r1.j2k +image_to_j2k.exe -i original/c0p0_16.pgx -o temp/c0p0_16.j2k +image_to_j2k.exe -i original/c0p1_04r0.pgx -o temp/c0p1_04r0.j2k +image_to_j2k.exe -i original/c0p1_05.pgx -o temp/c0p1_05.j2k +image_to_j2k.exe -i original/c1p0_01_0.pgx -o temp/c1p0_01_0.j2k +image_to_j2k.exe -i original/c1p0_02_0.pgx -o temp/c1p0_02_0.j2k +image_to_j2k.exe -i original/c1p0_03_0.pgx -o temp/c1p0_03_0.j2k +image_to_j2k.exe -i original/c1p0_04_0.pgx -o temp/c1p0_04_0.j2k +image_to_j2k.exe -i original/c1p0_05_0.pgx -o temp/c1p0_05_0.j2k +image_to_j2k.exe -i original/c1p0_06_0.pgx -o temp/c1p0_06_0.j2k +image_to_j2k.exe -i original/c1p0_07_0.pgx -o temp/c1p0_07_0.j2k +image_to_j2k.exe -i original/c1p0_08_0.pgx -o temp/c1p0_08_0.j2k +image_to_j2k.exe -i original/c1p0_09_0.pgx -o temp/c1p0_09_0.j2k +image_to_j2k.exe -i original/c1p0_10_0.pgx -o temp/c1p0_10_0.j2k +image_to_j2k.exe -i original/c1p0_11_0.pgx -o temp/c1p0_11_0.j2k +image_to_j2k.exe -i original/c1p0_12_0.pgx -o temp/c1p0_12_0.j2k +image_to_j2k.exe -i original/c1p0_13_0.pgx -o temp/c1p0_13_0.j2k +image_to_j2k.exe -i original/c1p0_14_0.pgx -o temp/c1p0_14_0.j2k +image_to_j2k.exe -i original/c1p0_15_0.pgx -o temp/c1p0_15_0.j2k +image_to_j2k.exe -i original/c1p0_16_0.pgx -o temp/c1p0_16_0.j2k +image_to_j2k.exe -i original/c1p1_02_0.pgx -o temp/c1p1_02_0.j2k +image_to_j2k.exe -i original/c1p1_05_0.pgx -o temp/c1p1_05_0.j2k +image_to_j2k.exe -i original/Bretagne2.ppm -o temp/Bretagne2_2.j2k -s 2,2 -SOP +image_to_j2k.exe -i original/Bretagne2.ppm -o temp/Bretagne2_3.j2k -EPH -M 38 +image_to_j2k.exe -i original/Bretagne2.ppm -o temp/Bretagne2_4.j2k -d 150,300 -r 800 +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.bmp +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.bmp -r 2 +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.tga +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.tga -r 2 +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.pnm +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.pnm -r 2 +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.ppm -r 2 +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.raw +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.raw -r 2 +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1.tif +j2k_to_image.exe -i original/Bretagne1.j2k -o temp/Bretagne1r2.tif -r 2 +j2k_to_image.exe -i original/p0_03.j2k -o p0_03.pgx diff --git a/OPJ_Validate/OPJ_Validate.c b/OPJ_Validate/OPJ_Validate.c new file mode 100644 index 00000000..e35b6294 --- /dev/null +++ b/OPJ_Validate/OPJ_Validate.c @@ -0,0 +1,244 @@ +/* +* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium +* Copyright (c) 2002-2007, Professor Benoit Macq +* Copyright (c) 2003-2007, Francois-Olivier Devaux +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef WIN32 +#include +#endif +#include +#include +#include "md5.h" + +#define OPJ_Bin_Dir "OPJ_Binaries" + +int doprocess(char programme[4096],char command_line[4096]) { + +#ifdef WIN32 + + int exit=STILL_ACTIVE; + STARTUPINFO siStartupInfo; + PROCESS_INFORMATION piProcessInfo; + + memset(&siStartupInfo, 0, sizeof(siStartupInfo)); + memset(&piProcessInfo, 0, sizeof(piProcessInfo)); + siStartupInfo.cb = sizeof(siStartupInfo); + + if(CreateProcess(programme, // Application name + command_line, // Application arguments + 0, + 0, + FALSE, + CREATE_DEFAULT_ERROR_MODE, + 0, + 0, // Working directory + &siStartupInfo, + &piProcessInfo) == FALSE) + return 1; + + exit=STILL_ACTIVE; + while(exit==STILL_ACTIVE) { + Sleep(1000); + GetExitCodeProcess(piProcessInfo.hProcess,&exit); + } + + return 0; + +#else // #ifndef WIN32 + printf("\n%s\n", command_line); + system(command_line); + return 0; + +#endif + +} + +char MD5_process(char *input_filename, char *md5_filename) { + MD5_CTX mdContext; + int bytes; + unsigned char data[1024]; + FILE *input_file, *md5_file; + + input_file = fopen(input_filename, "rb"); + if (!input_file) { + printf("Error opening file %s\n", input_filename); + return 1; + } + + md5_file = fopen(md5_filename, "wb"); + if (!md5_file) { + printf("Error opening file %s\n", md5_filename); + return 1; + } + + MD5Init (&mdContext); + while ((bytes = fread (data, 1, 1024, input_file)) != 0) + MD5Update (&mdContext, data, bytes); + MD5Final (&mdContext); + + fwrite(mdContext.digest,16,1,md5_file); + + fclose(input_file); + fclose(md5_file); + + return 0; +} + +char fcompare(char *input_filename, char *output_filename) { + FILE *input_file, *output_file; + unsigned char input_buffer[17], output_buffer[17]; + char comparison; + + input_file = fopen(input_filename, "rb"); + if (!input_file) { + printf("Error opening file %s\n", input_filename); + return -1; + } + + output_file = fopen(output_filename, "rb"); + if (!output_file) { + printf("Error opening file %s\n", output_filename); + return -1; + } + + fread(input_buffer,16,1,input_file); + fread(output_buffer,16,1,output_file); + fclose(input_file); + fclose(output_file); + input_buffer[16] = 0; + output_buffer[16] = 0; + + comparison = strcmp(input_buffer, output_buffer); + + if (comparison) + return 1; + return 0; +} + +int main(int argc, char* argv[]) { + FILE *param_file, *md5_file; + FILE *report_file; + char line[4096]; + char md5_filename[4096], tempmd5_filename[4096], temp[4096], report_filename[4096]; + char output_filename[4096]; + char input_cmdline[4096]; + char command_line[4096], exefile[4096]; + int task_counter = 0, word_counter; + char bin_dir[4096]; + unsigned int word_pointer; + char ch[4096]; + char comparison; + int num_failed = 0; + int num_inexistant = 0; + int num_passed = 0; + + if (argc != 3) { + printf("Error with command line. \nExpected: OPJ_Validate parameter_filename bin_directory\n Example: OPJ_Validate parameters_01.txt version1.1.a\n\n"); + return 1; + } + + param_file = fopen(argv[1],"rb"); + if (!param_file) { + printf("Error opening parameter file %s\n",argv[1]); + return 1; + } + + sprintf(bin_dir,"%s/%s",OPJ_Bin_Dir,argv[2]); + sprintf(tempmd5_filename,"temp/tempmd5.txt"); + sprintf(report_filename,"%s/report.txt",bin_dir); + report_file = fopen(report_filename, "wb"); + if (!report_file) { + printf("Unable to open report file %s", report_filename); + return 1; + } + + while (fgets(line, 4096, param_file) != NULL) { + + if (line[0] != '#' && line[0] != 0x0d) { // If not a comment line + sscanf(line, "%s", temp); + word_pointer = 0; + sprintf(input_cmdline,""); + sscanf(line+word_pointer,"%s",ch); + sprintf(exefile,"%s/%s",bin_dir,ch); + word_counter = 0; + while (sscanf(line+word_pointer,"%s",ch) > 0) { + if (word_counter == 4) + strcpy(output_filename, ch); + word_pointer += strlen(ch)+1; + sprintf(input_cmdline,"%s%s ",input_cmdline, ch); + word_counter++; + } + sprintf(md5_filename,"%s.md5",output_filename); + task_counter++; + sprintf(command_line,"%s/%s",bin_dir,input_cmdline); + printf("Task %d\nMD5 file: %s\nCommand line: \"%s\"\n",task_counter, md5_filename,command_line); + fprintf(report_file,"Task %d\n MD5 file: %s\n Command line: \"%s\"\n",task_counter, md5_filename,command_line); + + if (doprocess(exefile,command_line)) { + printf("Error executing: \"%s\" \n", command_line); + fprintf(report_file,"Task %d failed because command line is not valid.\n\n", task_counter); + } + else { + + // Check if MD5 reference exists + md5_file = fopen(md5_filename,"rb"); + if (md5_file) { + fclose(md5_file); + if (MD5_process(output_filename, tempmd5_filename)) + return 1; + + comparison = fcompare(tempmd5_filename, md5_filename); + if (comparison == -1) + return 1; + else if (comparison) { + printf("ERROR: %s and %s are different.\nThe codec seems to behave differently.\n\n", tempmd5_filename, md5_filename); + fprintf(report_file,"ERROR: %s and %s are different.\nThe codec seems to behave differently.\n\n", tempmd5_filename, md5_filename); + num_failed++; + } + else { + printf("%s and %s are the same.\nTask %d OK\n\n",tempmd5_filename, md5_filename, task_counter); + fprintf(report_file," %s and %s are the same.\nTask %d OK\n\n",tempmd5_filename, md5_filename, task_counter); + num_passed++; + } + remove(tempmd5_filename); + } + else { + if (MD5_process(output_filename, md5_filename)) + return 1; + printf("... MD5 of %s was inexistant. It has been created\n\n", output_filename); + fprintf(report_file,"MD5 of %s was inexistant. It has been created\n\n", output_filename); + num_inexistant++; + } + } + } + } + + printf("\n\REPORT;\n%d tests num_passed\n%d tests num_failed\n%d MD5 were num_inexistant\n", num_passed, num_failed, num_inexistant); + fprintf(report_file,"\n\REPORT;\n%d tests num_passed\n%d tests num_failed\n%d MD5 were num_inexistant\n", num_passed, num_failed, num_inexistant); + fclose(param_file); + fclose(report_file); + +} diff --git a/OPJ_Validate/OPJ_Validate.dsp b/OPJ_Validate/OPJ_Validate.dsp new file mode 100644 index 00000000..74630891 --- /dev/null +++ b/OPJ_Validate/OPJ_Validate.dsp @@ -0,0 +1,108 @@ +# Microsoft Developer Studio Project File - Name="OPJ_Validate" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=OPJ_Validate - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "OPJ_Validate.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "OPJ_Validate.mak" CFG="OPJ_Validate - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "OPJ_Validate - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "OPJ_Validate - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "OPJ_Validate - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x80c /d "NDEBUG" +# ADD RSC /l 0x80c /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "OPJ_Validate - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x80c /d "_DEBUG" +# ADD RSC /l 0x80c /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "OPJ_Validate - Win32 Release" +# Name "OPJ_Validate - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\md5.c +# End Source File +# Begin Source File + +SOURCE=.\OPJ_Validate.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\md5.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/OPJ_Validate/OPJ_Validate.dsw b/OPJ_Validate/OPJ_Validate.dsw new file mode 100644 index 00000000..05a34038 --- /dev/null +++ b/OPJ_Validate/OPJ_Validate.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "OPJ_Validate"=".\OPJ_Validate.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.bat b/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.bat new file mode 100644 index 00000000..0fd61ad2 --- /dev/null +++ b/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.bat @@ -0,0 +1,8 @@ +cd temp +erase *.ppm +erase *.j2k +erase *.bmp +erase *.tif +erase *.jp2 +cd .. +OPJ_Validate.exe OPJ_Param_File_v0_1.txt testv2 diff --git a/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.sh b/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.sh new file mode 100644 index 00000000..edd3eaa4 --- /dev/null +++ b/OPJ_Validate/OPJ_Validate_Candidate_vs_Ref.sh @@ -0,0 +1,16 @@ +#!/bin/bash +cd temp +erase *.ppm +erase *.j2k +erase *.bmp +erase *.tif +erase *.jp2 +cd .. + +echo +echo "Type the name of the directory (inside OPJ_Binaries) " +echo "containing your executables to compared with reference, followed by [ENTER] (example: rev101):" +read compdir + +./OPJ_Validate linux_OPJ_Param_File_v0_1.txt $compdir +echo diff --git a/OPJ_Validate/OPJ_Validate_Create_Ref.bat b/OPJ_Validate/OPJ_Validate_Create_Ref.bat new file mode 100644 index 00000000..83332fc8 --- /dev/null +++ b/OPJ_Validate/OPJ_Validate_Create_Ref.bat @@ -0,0 +1,4 @@ +cd temp +erase *.md5 +cd .. +OPJ_Validate.exe OPJ_Param_File_v0_1.txt rev490 diff --git a/OPJ_Validate/OPJ_Validate_Create_Ref.sh b/OPJ_Validate/OPJ_Validate_Create_Ref.sh new file mode 100644 index 00000000..e44e053b --- /dev/null +++ b/OPJ_Validate/OPJ_Validate_Create_Ref.sh @@ -0,0 +1,13 @@ +#!/bin/bash +#Create Reference images and hash + +echo +echo "Type the name of the directory (inside OPJ_Binaries) " +echo "containing your reference executables, followed by [ENTER] (example: rev100):" +read refdir +cd temp +rm *.md5 +cd .. +./OPJ_Validate linux_OPJ_Param_File_v0_1.txt $refdir +echo + diff --git a/OPJ_Validate/README.txt b/OPJ_Validate/README.txt new file mode 100644 index 00000000..364ef8e1 --- /dev/null +++ b/OPJ_Validate/README.txt @@ -0,0 +1,46 @@ +Initialization +-------------- +Download the source images into the /original directory from http://www.openjpeg.org/OPJ_Validate_OriginalImages.7z + +Usage +----- +Usage: OPJ_Validate batch_text_file bin_directory +Example: OPJ_Validate OPJ_Param_File_v0_1.txt v1.1.a +where OPJ_Param_File_v0_1.txt is a file containing a list of compression and decompression parameters +and v1.1.a is a directory inside the directory OPJ_Binaries containing the openjpeg executables (j2k_to_image.exe and image_to_j2k.exe) + +Example with batch file: You consider revision 490 (/rev490) as stable, and would like to compare it a new version, revision 493 (rev493). + +Batch mode +---------- +1) Calculate the reference by running the "OPJ_Validate_Create_Ref rev490" file (.sh or .bat depending on your os) +2) Compare the candidate revision with ther reference by running the "OPJ_Validate_Candidate_vs_Ref rev493" file +3) The results of the comparison are given at the end of the processing. They are also available in the bin directory OPJ_Binaries/rev493/report.txt + +Manual mode +----------- +1) Put the j2k_to_image.exe and image_to_j2k.exe binaries of both revisions in the OPJ_Binaries directory (OPJ_Binaries/rev490 and OPJ_Binaries/rev493) +2) Start by initializing the validation with revision 490. + a) Modify OPJ_Validate_init.bat and set the last line to "OPJ_Validate.exe OPJ_Param_File_v0_1.txt rev490" + b) Execute OPJ_Validate_init.bat +3) Compare the reference files generated in the previous step with files generated with revision 493 + a) Modify OPJ_Validate_run.bat and set the last line to "OPJ_Validate.exe OPJ_Param_File_v0_1.txt rev493" + b) Execute OPJ_Validate_run.bat +4) Read the results in the binaries directory of revision 493 (OPJ_Binaries/rev493/report.txt) + Search for the word "ERROR:" in that file. + If this word is not present in the report, this means that both codecs of rev490 and rev493 gave the same results. + Otherwise, it means that for certain encoding/decoding parameters, the codecs behave differently. + + Example of error + Task 17 + MD5 file: temp/A_4_2K_24_185_CBR_WB_000.tif.md5 + Command line: "OPJ_Binaries/rev473/j2k_to_image.exe -i original/A_4_2K_24_185_CBR_WB_000.j2k -o temp/A_4_2K_24_185_CBR_WB_000.tif " + ERROR: temp/tempmd5.txt and temp/A_4_2K_24_185_CBR_WB_000.tif.md5 are different. + The codec seems to behave differently. + + This means that the rev490 and rev493 created two different versions of file A_4_2K_24_185_CBR_WB_000.tif with the command line given above. + An error might have been caused by switching to this new revision. + + Warning: Do not take the last line of the report.txt file into account ( Cool. All files passed the tests !) as it is a bug. Search for the word "ERROR:" to detect potential errors. +5) If no error is detected, you can commit the changes to the OpenJPEG repository + diff --git a/OPJ_Validate/linux_OPJ_Param_File_v0_1.txt b/OPJ_Validate/linux_OPJ_Param_File_v0_1.txt new file mode 100644 index 00000000..0dafe2c8 --- /dev/null +++ b/OPJ_Validate/linux_OPJ_Param_File_v0_1.txt @@ -0,0 +1,89 @@ +#OPJ Parameter file +#Version 0.1 - February 9th 2007 +#Usage: OPJ_Validate OpenJPEG_command_line +#Example: OPJ_Validate image_to_j2k.exe -i original/Bretagne1.ppm -o original/Bretagne1.j2k -r 200, 50, 10 +#Attention: don't forget the *.exe extension for the executable file, and check the paths +# +image_to_j2k -i original/Bretagne1.ppm -o temp/Bretagne1_0.j2k -r 200,50,10 +j2k_to_image -i original/Bretagne1.j2k -o temp/Bretagne1.ppm +image_to_j2k -i original/Bretagne2.ppm -o temp/Bretagne2_0.j2k -c [128,128],[128,128],[128,128] -r 100,20,2 -t 640,480 -b 32,32 +j2k_to_image -i original/Bretagne2.j2k -o temp/Bretagne2.ppm -r 2 +image_to_j2k -i original/Cevennes1.bmp -o temp/Cevennes1.j2k -r 10 +j2k_to_image -i original/Cevennes1.j2k -o temp/Cevennes1.bmp -l 2 +image_to_j2k -i original/Cevennes2.ppm -o temp/Cevennes2.jp2 -r 50 +j2k_to_image -i original/Cevennes2.jp2 -o temp/Cevennes2.ppm +image_to_j2k -i original/Rome.bmp -o temp/Rome.jp2 -q 30,35,50 -p LRCP -n 3 +j2k_to_image -i original/Rome.jp2 -o temp/Rome.ppm +image_to_j2k -i original/Bretagne1.ppm -o temp/Bretagne1_1.j2k -q 30,35,40 -n 2 +image_to_j2k -i original/Bretagne1.ppm -o temp/Bretagne1_2.j2k -q 30,35,40 -b 16,16 -c [101,101] +image_to_j2k -i original/Bretagne2.ppm -o temp/Bretagne2_1.j2k -t 127,127 -p PCRL +image_to_j2k -i original/X_4_2K_24_185_CBR_WB_000.tif -o temp/X_4_2K_24_185_CBR_WB_000.j2k -cinema2K 24 +image_to_j2k -i original/X_5_2K_24_235_CBR_STEM24_000.tif -o temp/X_5_2K_24_235_CBR_STEM24_000.j2k -cinema2K 48 +image_to_j2k -i original/X_6_2K_24_FULL_CBR_CIRCLE_000.tif -o temp/X_6_2K_24_FULL_CBR_CIRCLE_000.j2k -cinema2K 24 +#à remettre +#image_to_j2k -i original/X_16_4K_24_185_CBR_WB_000.tif -o temp/X_16_4K_24_185_CBR_WB_000.j2k -cinema4K +j2k_to_image -i original/A_4_2K_24_185_CBR_WB_000.j2k -o temp/A_4_2K_24_185_CBR_WB_000.tif +j2k_to_image -i original/B_5_2K_24_235_CBR_STEM24_000.j2k -o temp/B_5_2K_24_235_CBR_STEM24_000.tif +j2k_to_image -i original/C_6_2K_24_FULL_CBR_CIRCLE_000.j2k -o temp/C_6_2K_24_FULL_CBR_CIRCLE_000.tif +#à remettre +#j2k_to_image -i original/C_18_4K_24_FULL_CBR_CIRCLE_000.j2k -o temp/C_18_4K_24_FULL_CBR_CIRCLE_000.tif +j2k_to_image -i original/p0_01.j2k -o temp/p0_01.tif +j2k_to_image -i original/p0_02.j2k -o temp/p0_02.tif +j2k_to_image -i original/p0_03.j2k -o temp/p0_03.tif +j2k_to_image -i original/p0_04.j2k -o temp/p0_04.tif +#a remettre +#j2k_to_image -i original/p0_07.j2k -o temp/p0_07.tif +j2k_to_image -i original/p0_08.j2k -o temp/p0_08.tif +j2k_to_image -i original/p0_09.j2k -o temp/p0_09.tif +j2k_to_image -i original/p0_10.j2k -o temp/p0_10.tif +j2k_to_image -i original/p0_11.j2k -o temp/p0_11.tif +j2k_to_image -i original/p0_12.j2k -o temp/p0_12.tif +j2k_to_image -i original/p0_14.j2k -o temp/p0_14.tif +j2k_to_image -i original/p0_15.j2k -o temp/p0_15.tif +j2k_to_image -i original/p0_16.j2k -o temp/p0_16.tif +j2k_to_image -i original/p1_01.j2k -o temp/p1_01.tif +j2k_to_image -i original/p1_02.j2k -o temp/p1_02.tif +j2k_to_image -i original/p1_04.j2k -o temp/p1_04.tif +j2k_to_image -i original/p1_05.j2k -o temp/p1_05.tif +j2k_to_image -i original/p1_06.j2k -o temp/p1_06.tif +image_to_j2k -i original/c0p0_01.pgx -o temp/c0p0_01.j2k +image_to_j2k -i original/c0p0_02.pgx -o temp/c0p0_02.j2k +image_to_j2k -i original/c0p0_03r0.pgx -o temp/c0p0_03r0.j2k +image_to_j2k -i original/c0p0_03r1.pgx -o temp/c0p0_03r1.j2k +image_to_j2k -i original/c0p0_04.pgx -o temp/c00_p04.j2k +image_to_j2k -i original/c0p0_05.pgx -o temp/c0p0_05.j2k +image_to_j2k -i original/c0p0_06.pgx -o temp/c0p0_06.j2k +image_to_j2k -i original/c0p0_07.pgx -o temp/c0p0_07.j2k +image_to_j2k -i original/c0p0_08.pgx -o temp/c0p0_08.j2k +image_to_j2k -i original/c0p0_09.pgx -o temp/c0p0_09.j2k +image_to_j2k -i original/c0p0_10.pgx -o temp/c0p0_10.j2k +image_to_j2k -i original/c0p0_11.pgx -o temp/c0p0_11.j2k +image_to_j2k -i original/c0p0_12.pgx -o temp/c0p0_12.j2k +image_to_j2k -i original/c0p0_13.pgx -o temp/c0p0_13.j2k +image_to_j2k -i original/c0p0_14.pgx -o temp/c0p0_14.j2k +image_to_j2k -i original/c0p0_15r0.pgx -o temp/c0p0_15r0.j2k +image_to_j2k -i original/c0p0_15r1.pgx -o temp/c0p0_15r1.j2k +image_to_j2k -i original/c0p0_16.pgx -o temp/c0p0_16.j2k +image_to_j2k -i original/c0p1_04r0.pgx -o temp/c0p1_04r0.j2k +image_to_j2k -i original/c0p1_05.pgx -o temp/c0p1_05.j2k +image_to_j2k -i original/c1p0_01_0.pgx -o temp/c1p0_01_0.j2k +image_to_j2k -i original/c1p0_02_0.pgx -o temp/c1p0_02_0.j2k +image_to_j2k -i original/c1p0_03_0.pgx -o temp/c1p0_03_0.j2k +image_to_j2k -i original/c1p0_04_0.pgx -o temp/c1p0_04_0.j2k +image_to_j2k -i original/c1p0_05_0.pgx -o temp/c1p0_05_0.j2k +image_to_j2k -i original/c1p0_06_0.pgx -o temp/c1p0_06_0.j2k +image_to_j2k -i original/c1p0_07_0.pgx -o temp/c1p0_07_0.j2k +image_to_j2k -i original/c1p0_08_0.pgx -o temp/c1p0_08_0.j2k +image_to_j2k -i original/c1p0_09_0.pgx -o temp/c1p0_09_0.j2k +image_to_j2k -i original/c1p0_10_0.pgx -o temp/c1p0_10_0.j2k +image_to_j2k -i original/c1p0_11_0.pgx -o temp/c1p0_11_0.j2k +image_to_j2k -i original/c1p0_12_0.pgx -o temp/c1p0_12_0.j2k +image_to_j2k -i original/c1p0_13_0.pgx -o temp/c1p0_13_0.j2k +image_to_j2k -i original/c1p0_14_0.pgx -o temp/c1p0_14_0.j2k +image_to_j2k -i original/c1p0_15_0.pgx -o temp/c1p0_15_0.j2k +image_to_j2k -i original/c1p0_16_0.pgx -o temp/c1p0_16_0.j2k +image_to_j2k -i original/c1p1_02_0.pgx -o temp/c1p1_02_0.j2k +image_to_j2k -i original/c1p1_05_0.pgx -o temp/c1p1_05_0.j2k +image_to_j2k -i original/Bretagne2.ppm -o temp/Bretagne2_2.j2k -s 2,2 -SOP +image_to_j2k -i original/Bretagne2.ppm -o temp/Bretagne2_3.j2k -EPH -M 38 +image_to_j2k -i original/Bretagne2.ppm -o temp/Bretagne2_4.j2k -d 150,300 -r 800 diff --git a/OPJ_Validate/md5.c b/OPJ_Validate/md5.c new file mode 100644 index 00000000..735a27cb --- /dev/null +++ b/OPJ_Validate/md5.c @@ -0,0 +1,276 @@ +/* + ********************************************************************** + ** md5.c ** + ** RSA Data Security, Inc. MD5 Message Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version ** + ********************************************************************** + */ + +/* + ********************************************************************** + ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** + ** ** + ** License to copy and use this software is granted provided that ** + ** it is identified as the "RSA Data Security, Inc. MD5 Message ** + ** Digest Algorithm" in all material mentioning or referencing this ** + ** software or this function. ** + ** ** + ** License is also granted to make and use derivative works ** + ** provided that such works are identified as "derived from the RSA ** + ** Data Security, Inc. MD5 Message Digest Algorithm" in all ** + ** material mentioning or referencing the derived work. ** + ** ** + ** RSA Data Security, Inc. makes no representations concerning ** + ** either the merchantability of this software or the suitability ** + ** of this software for any particular purpose. It is provided "as ** + ** is" without express or implied warranty of any kind. ** + ** ** + ** These notices must be retained in any copies of any part of this ** + ** documentation and/or software. ** + ********************************************************************** + */ + +/* -- include the following line if the md5.h header file is separate -- */ +#include "md5.h" + +/* forward declaration */ +static void Transform (); + +static unsigned char PADDING[64] = { + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +/* F, G and H are basic MD5 functions: selection, majority, parity */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +/* ROTATE_LEFT rotates x left n bits */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */ +/* Rotation is separate from addition to prevent recomputation */ +#define FF(a, b, c, d, x, s, ac) \ + {(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define GG(a, b, c, d, x, s, ac) \ + {(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define HH(a, b, c, d, x, s, ac) \ + {(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define II(a, b, c, d, x, s, ac) \ + {(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } + +void MD5Init (mdContext) +MD5_CTX *mdContext; +{ + mdContext->i[0] = mdContext->i[1] = (UINT4)0; + + /* Load magic initialization constants. + */ + mdContext->buf[0] = (UINT4)0x67452301; + mdContext->buf[1] = (UINT4)0xefcdab89; + mdContext->buf[2] = (UINT4)0x98badcfe; + mdContext->buf[3] = (UINT4)0x10325476; +} + +void MD5Update (mdContext, inBuf, inLen) +MD5_CTX *mdContext; +unsigned char *inBuf; +unsigned int inLen; +{ + UINT4 in[16]; + int mdi; + unsigned int i, ii; + + /* compute number of bytes mod 64 */ + mdi = (int)((mdContext->i[0] >> 3) & 0x3F); + + /* update number of bits */ + if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0]) + mdContext->i[1]++; + mdContext->i[0] += ((UINT4)inLen << 3); + mdContext->i[1] += ((UINT4)inLen >> 29); + + while (inLen--) { + /* add new character to buffer, increment mdi */ + mdContext->in[mdi++] = *inBuf++; + + /* transform if necessary */ + if (mdi == 0x40) { + for (i = 0, ii = 0; i < 16; i++, ii += 4) + in[i] = (((UINT4)mdContext->in[ii+3]) << 24) | + (((UINT4)mdContext->in[ii+2]) << 16) | + (((UINT4)mdContext->in[ii+1]) << 8) | + ((UINT4)mdContext->in[ii]); + Transform (mdContext->buf, in); + mdi = 0; + } + } +} + +void MD5Final (mdContext) +MD5_CTX *mdContext; +{ + UINT4 in[16]; + int mdi; + unsigned int i, ii; + unsigned int padLen; + + /* save number of bits */ + in[14] = mdContext->i[0]; + in[15] = mdContext->i[1]; + + /* compute number of bytes mod 64 */ + mdi = (int)((mdContext->i[0] >> 3) & 0x3F); + + /* pad out to 56 mod 64 */ + padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); + MD5Update (mdContext, PADDING, padLen); + + /* append length in bits and transform */ + for (i = 0, ii = 0; i < 14; i++, ii += 4) + in[i] = (((UINT4)mdContext->in[ii+3]) << 24) | + (((UINT4)mdContext->in[ii+2]) << 16) | + (((UINT4)mdContext->in[ii+1]) << 8) | + ((UINT4)mdContext->in[ii]); + Transform (mdContext->buf, in); + + /* store buffer in digest */ + for (i = 0, ii = 0; i < 4; i++, ii += 4) { + mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF); + mdContext->digest[ii+1] = + (unsigned char)((mdContext->buf[i] >> 8) & 0xFF); + mdContext->digest[ii+2] = + (unsigned char)((mdContext->buf[i] >> 16) & 0xFF); + mdContext->digest[ii+3] = + (unsigned char)((mdContext->buf[i] >> 24) & 0xFF); + } +} + +/* Basic MD5 step. Transform buf based on in. + */ +static void Transform (buf, in) +UINT4 *buf; +UINT4 *in; +{ + UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3]; + + /* Round 1 */ +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 + FF ( a, b, c, d, in[ 0], S11, 3614090360); /* 1 */ + FF ( d, a, b, c, in[ 1], S12, 3905402710); /* 2 */ + FF ( c, d, a, b, in[ 2], S13, 606105819); /* 3 */ + FF ( b, c, d, a, in[ 3], S14, 3250441966); /* 4 */ + FF ( a, b, c, d, in[ 4], S11, 4118548399); /* 5 */ + FF ( d, a, b, c, in[ 5], S12, 1200080426); /* 6 */ + FF ( c, d, a, b, in[ 6], S13, 2821735955); /* 7 */ + FF ( b, c, d, a, in[ 7], S14, 4249261313); /* 8 */ + FF ( a, b, c, d, in[ 8], S11, 1770035416); /* 9 */ + FF ( d, a, b, c, in[ 9], S12, 2336552879); /* 10 */ + FF ( c, d, a, b, in[10], S13, 4294925233); /* 11 */ + FF ( b, c, d, a, in[11], S14, 2304563134); /* 12 */ + FF ( a, b, c, d, in[12], S11, 1804603682); /* 13 */ + FF ( d, a, b, c, in[13], S12, 4254626195); /* 14 */ + FF ( c, d, a, b, in[14], S13, 2792965006); /* 15 */ + FF ( b, c, d, a, in[15], S14, 1236535329); /* 16 */ + + /* Round 2 */ +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 + GG ( a, b, c, d, in[ 1], S21, 4129170786); /* 17 */ + GG ( d, a, b, c, in[ 6], S22, 3225465664); /* 18 */ + GG ( c, d, a, b, in[11], S23, 643717713); /* 19 */ + GG ( b, c, d, a, in[ 0], S24, 3921069994); /* 20 */ + GG ( a, b, c, d, in[ 5], S21, 3593408605); /* 21 */ + GG ( d, a, b, c, in[10], S22, 38016083); /* 22 */ + GG ( c, d, a, b, in[15], S23, 3634488961); /* 23 */ + GG ( b, c, d, a, in[ 4], S24, 3889429448); /* 24 */ + GG ( a, b, c, d, in[ 9], S21, 568446438); /* 25 */ + GG ( d, a, b, c, in[14], S22, 3275163606); /* 26 */ + GG ( c, d, a, b, in[ 3], S23, 4107603335); /* 27 */ + GG ( b, c, d, a, in[ 8], S24, 1163531501); /* 28 */ + GG ( a, b, c, d, in[13], S21, 2850285829); /* 29 */ + GG ( d, a, b, c, in[ 2], S22, 4243563512); /* 30 */ + GG ( c, d, a, b, in[ 7], S23, 1735328473); /* 31 */ + GG ( b, c, d, a, in[12], S24, 2368359562); /* 32 */ + + /* Round 3 */ +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 + HH ( a, b, c, d, in[ 5], S31, 4294588738); /* 33 */ + HH ( d, a, b, c, in[ 8], S32, 2272392833); /* 34 */ + HH ( c, d, a, b, in[11], S33, 1839030562); /* 35 */ + HH ( b, c, d, a, in[14], S34, 4259657740); /* 36 */ + HH ( a, b, c, d, in[ 1], S31, 2763975236); /* 37 */ + HH ( d, a, b, c, in[ 4], S32, 1272893353); /* 38 */ + HH ( c, d, a, b, in[ 7], S33, 4139469664); /* 39 */ + HH ( b, c, d, a, in[10], S34, 3200236656); /* 40 */ + HH ( a, b, c, d, in[13], S31, 681279174); /* 41 */ + HH ( d, a, b, c, in[ 0], S32, 3936430074); /* 42 */ + HH ( c, d, a, b, in[ 3], S33, 3572445317); /* 43 */ + HH ( b, c, d, a, in[ 6], S34, 76029189); /* 44 */ + HH ( a, b, c, d, in[ 9], S31, 3654602809); /* 45 */ + HH ( d, a, b, c, in[12], S32, 3873151461); /* 46 */ + HH ( c, d, a, b, in[15], S33, 530742520); /* 47 */ + HH ( b, c, d, a, in[ 2], S34, 3299628645); /* 48 */ + + /* Round 4 */ +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + II ( a, b, c, d, in[ 0], S41, 4096336452); /* 49 */ + II ( d, a, b, c, in[ 7], S42, 1126891415); /* 50 */ + II ( c, d, a, b, in[14], S43, 2878612391); /* 51 */ + II ( b, c, d, a, in[ 5], S44, 4237533241); /* 52 */ + II ( a, b, c, d, in[12], S41, 1700485571); /* 53 */ + II ( d, a, b, c, in[ 3], S42, 2399980690); /* 54 */ + II ( c, d, a, b, in[10], S43, 4293915773); /* 55 */ + II ( b, c, d, a, in[ 1], S44, 2240044497); /* 56 */ + II ( a, b, c, d, in[ 8], S41, 1873313359); /* 57 */ + II ( d, a, b, c, in[15], S42, 4264355552); /* 58 */ + II ( c, d, a, b, in[ 6], S43, 2734768916); /* 59 */ + II ( b, c, d, a, in[13], S44, 1309151649); /* 60 */ + II ( a, b, c, d, in[ 4], S41, 4149444226); /* 61 */ + II ( d, a, b, c, in[11], S42, 3174756917); /* 62 */ + II ( c, d, a, b, in[ 2], S43, 718787259); /* 63 */ + II ( b, c, d, a, in[ 9], S44, 3951481745); /* 64 */ + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; +} + +/* + ********************************************************************** + ** End of md5.c ** + ******************************* (cut) ******************************** + */ diff --git a/OPJ_Validate/md5.h b/OPJ_Validate/md5.h new file mode 100644 index 00000000..6fb35cff --- /dev/null +++ b/OPJ_Validate/md5.h @@ -0,0 +1,59 @@ +/* + ********************************************************************** + ** md5.h -- Header file for implementation of MD5 ** + ** RSA Data Security, Inc. MD5 Message Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** + ** Revised (for MD5): RLR 4/27/91 ** + ** -- G modified to have y&~z instead of y&z ** + ** -- FF, GG, HH modified to add in last register done ** + ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** + ** -- distinct additive constant for each step ** + ** -- round 4 added, working mod 7 ** + ********************************************************************** + */ + +/* + ********************************************************************** + ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** + ** ** + ** License to copy and use this software is granted provided that ** + ** it is identified as the "RSA Data Security, Inc. MD5 Message ** + ** Digest Algorithm" in all material mentioning or referencing this ** + ** software or this function. ** + ** ** + ** License is also granted to make and use derivative works ** + ** provided that such works are identified as "derived from the RSA ** + ** Data Security, Inc. MD5 Message Digest Algorithm" in all ** + ** material mentioning or referencing the derived work. ** + ** ** + ** RSA Data Security, Inc. makes no representations concerning ** + ** either the merchantability of this software or the suitability ** + ** of this software for any particular purpose. It is provided "as ** + ** is" without express or implied warranty of any kind. ** + ** ** + ** These notices must be retained in any copies of any part of this ** + ** documentation and/or software. ** + ********************************************************************** + */ + +/* typedef a 32 bit type */ +typedef unsigned long int UINT4; + +/* Data structure for MD5 (Message Digest) computation */ +typedef struct { + UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ + UINT4 buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after MD5Final call */ +} MD5_CTX; + +void MD5Init (); +void MD5Update (); +void MD5Final (); + +/* + ********************************************************************** + ** End of md5.h ** + ******************************* (cut) ******************************** + */ diff --git a/OPJ_Validate/original/README.txt b/OPJ_Validate/original/README.txt new file mode 100644 index 00000000..d78d1bde --- /dev/null +++ b/OPJ_Validate/original/README.txt @@ -0,0 +1 @@ +Download the source images into this directory from http://www.openjpeg.org/OPJ_Validate_OriginalImages.7z