changed copying files to patching

This commit is contained in:
Katarzyna Miernikiewicz 2020-09-01 11:06:12 +00:00
parent 28089de353
commit 490bc569ed
5 changed files with 22 additions and 32 deletions

View File

@ -1,3 +1 @@
build/ build/
examples/convert_lib.cc
examples/convert_lib.h

View File

@ -12,27 +12,26 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_custom_target(patching_reverse_before # we need to use modified versions of some of the library tools
COMMAND cd ${PROJECT_SOURCE_DIR}/openjpeg/src/bin/jp2/ && patch -R --no-backup-if-mismatch -r /dev/null convert.c < ${PROJECT_SOURCE_DIR}/examples/convert.patch > /dev/null || (exit 0)
COMMAND cd ${PROJECT_SOURCE_DIR}/openjpeg/src/bin/jp2/ && patch -R --no-backup-if-mismatch -r /dev/null convert.h < ${PROJECT_SOURCE_DIR}/examples/convert_h.patch > /dev/null || (exit 0) file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/gen_files")
) file(COPY "${PROJECT_SOURCE_DIR}/openjpeg/src/bin/jp2/convert.c" DESTINATION "${PROJECT_BINARY_DIR}/gen_files/")
file(COPY "${PROJECT_SOURCE_DIR}/openjpeg/src/bin/jp2/convert.h" DESTINATION "${PROJECT_BINARY_DIR}/gen_files/")
file(COPY "${PROJECT_SOURCE_DIR}/examples/convert.patch" DESTINATION "${PROJECT_BINARY_DIR}/gen_files/")
file(COPY "${PROJECT_SOURCE_DIR}/examples/convert_h.patch" DESTINATION "${PROJECT_BINARY_DIR}/gen_files/")
add_custom_command( add_custom_command(
DEPENDS opj_decompress opj_compress opj_dump OUTPUT ${PROJECT_BINARY_DIR}/gen_files/convert.cc ${PROJECT_BINARY_DIR}/gen_files/convert.h
OUTPUT ${PROJECT_SOURCE_DIR}/examples/convert_lib.cc ${PROJECT_SOURCE_DIR}/examples/convert_lib.h COMMAND cd ${PROJECT_BINARY_DIR}/gen_files && patch < ${PROJECT_SOURCE_DIR}/examples/convert.patch > /dev/null
COMMAND cd ${PROJECT_SOURCE_DIR}/openjpeg/src/bin/jp2/ && patch convert.c < ${PROJECT_SOURCE_DIR}/examples/convert.patch > /dev/null && cp convert.c ${PROJECT_SOURCE_DIR}/examples/convert_lib.cc COMMAND cd ${PROJECT_BINARY_DIR}/gen_files && patch < ${PROJECT_SOURCE_DIR}/examples/convert_h.patch > /dev/null
COMMAND cd ${PROJECT_SOURCE_DIR}/openjpeg/src/bin/jp2/ && patch convert.h < ${PROJECT_SOURCE_DIR}/examples/convert_h.patch > /dev/null && cp convert.h ${PROJECT_SOURCE_DIR}/examples/convert_lib.h COMMAND mv ${PROJECT_BINARY_DIR}/gen_files/convert.c ${PROJECT_BINARY_DIR}/gen_files/convert.cc
) )
add_library(convert_helper STATIC add_library(convert_helper STATIC
${PROJECT_SOURCE_DIR}/examples/convert_lib.cc ${PROJECT_BINARY_DIR}/gen_files/convert.cc
${PROJECT_SOURCE_DIR}/examples/convert_lib.h ${PROJECT_BINARY_DIR}/gen_files/convert.h
) )
add_dependencies(opj_decompress patching_reverse_before)
add_dependencies(opj_compress patching_reverse_before)
add_dependencies(opj_dump patching_reverse_before)
add_executable(decompress_sandboxed add_executable(decompress_sandboxed
decompress_example.cc decompress_example.cc
) )
@ -47,10 +46,3 @@ target_link_libraries(convert_helper PRIVATE
openjp2_sapi openjp2_sapi
sapi::sapi sapi::sapi
) )
add_custom_target(patching_reverse ALL
COMMAND cd ${PROJECT_SOURCE_DIR}/openjpeg/src/bin/jp2/ && patch -R convert.c < ${PROJECT_SOURCE_DIR}/examples/convert.patch > /dev/null
COMMAND cd ${PROJECT_SOURCE_DIR}/openjpeg/src/bin/jp2/ && patch -R convert.h < ${PROJECT_SOURCE_DIR}/examples/convert_h.patch > /dev/null
)
add_dependencies(patching_reverse decompress_sandboxed)

View File

@ -1,5 +1,5 @@
--- convert.c 2020-08-27 15:46:32.911584344 +0000 --- convert.c 2020-08-27 15:46:32.911584344 +0000
+++ ../../../../examples/convert_helper.cc 2020-08-27 15:10:52.695231032 +0000 +++ convert_helper.cc 2020-08-27 15:10:52.695231032 +0000
@@ -35,2605 +35,311 @@ @@ -35,2605 +35,311 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
@ -62,7 +62,7 @@
- } - }
- component->prec = precision; - component->prec = precision;
-} -}
+// copies of a few library tools +// patched versions of a few library tools
-/* Component precision scaling */ -/* Component precision scaling */
-static void scale_component_up(opj_image_comp_t* component, -static void scale_component_up(opj_image_comp_t* component,
@ -181,7 +181,7 @@
-{ -{
- OPJ_SIZE_T i; - OPJ_SIZE_T i;
- const OPJ_INT32* pSrc0 = pSrc[0]; - const OPJ_INT32* pSrc0 = pSrc[0];
+#include "convert_lib.h" +#include "convert.h"
- for (i = 0; i < length; i++) { - for (i = 0; i < length; i++) {
- pDst[i] = pSrc0[i] + adjust; - pDst[i] = pSrc0[i] + adjust;

View File

@ -1,5 +1,5 @@
--- convert.h 2020-08-27 15:46:45.028628305 +0000 --- convert.h 2020-08-27 15:46:45.028628305 +0000
+++ ../../../../examples/convert_helper.h 2020-08-27 14:26:02.155455250 +0000 +++ convert_helper.h 2020-08-27 14:26:02.155455250 +0000
@@ -1,126 +1,8 @@ @@ -1,126 +1,8 @@
-/* -/*
- * The copyright in this software is being made available under the 2-clauses - * The copyright in this software is being made available under the 2-clauses
@ -39,8 +39,8 @@
- */ - */
-#ifndef __J2K_CONVERT_H -#ifndef __J2K_CONVERT_H
-#define __J2K_CONVERT_H -#define __J2K_CONVERT_H
+// imagetopnm and the two functions it calls internaly are copied from the +// imagetopnm and the two functions it calls internaly are patched
+// library's tools; from openjpeg/src/bin/jp2/convert.c +// versions of the library's tools; from openjpeg/src/bin/jp2/convert.c
-/**@name RAW component encoding parameters */ -/**@name RAW component encoding parameters */
-/*@{*/ -/*@{*/

View File

@ -21,7 +21,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include "convert_lib.h" #include "gen_files/convert.h"
#include "openjp2_sapi.sapi.h" #include "openjp2_sapi.sapi.h"
class Openjp2SapiSandbox : public Openjp2Sandbox { class Openjp2SapiSandbox : public Openjp2Sandbox {