diff options
| author | Mathieu Malaterre <mathieu.malaterre@gmail.com> | 2012-09-28 09:52:57 +0000 |
|---|---|---|
| committer | Mathieu Malaterre <mathieu.malaterre@gmail.com> | 2012-09-28 09:52:57 +0000 |
| commit | d84b16caf98efb94cf85247f78ed91350d6e1e69 (patch) | |
| tree | 6a2f7c8822b4f44caa3ebfbdfaeb9d489693f5a6 /src/bin | |
| parent | 95f06f0591976f4a8534c73251fe5048bbe7f770 (diff) | |
[trunk] FolderReorgProposal task: rename MJ2/JPIP CLI tools
Update issue 177
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/jpip/CMakeLists.txt | 88 | ||||
| -rw-r--r-- | src/bin/jpip/jpip_to_j2k.c | 2 | ||||
| -rw-r--r-- | src/bin/jpip/jpip_to_jp2.c | 2 | ||||
| -rw-r--r-- | src/bin/jpip/opj_jpip_addxml.c (renamed from src/bin/jpip/addXMLinJP2.c) | 0 | ||||
| -rw-r--r-- | src/bin/jpip/opj_jpip_test.c (renamed from src/bin/jpip/test_index.c) | 0 | ||||
| -rw-r--r-- | src/bin/jpip/opj_jpip_transcode.c | 49 | ||||
| -rw-r--r-- | src/bin/mj2/CMakeLists.txt | 61 | ||||
| -rw-r--r-- | src/bin/mj2/mj2_convert.c | 372 | ||||
| -rw-r--r-- | src/bin/mj2/mj2_convert.h | 45 | ||||
| -rw-r--r-- | src/bin/mj2/opj_mj2_compress.c (renamed from src/bin/mj2/frames_to_mj2.c) | 2 | ||||
| -rw-r--r-- | src/bin/mj2/opj_mj2_decompress.c (renamed from src/bin/mj2/mj2_to_frames.c) | 2 | ||||
| -rw-r--r-- | src/bin/mj2/opj_mj2_extract.c (renamed from src/bin/mj2/extract_j2k_from_mj2.c) | 0 | ||||
| -rw-r--r-- | src/bin/mj2/opj_mj2_wrap.c (renamed from src/bin/mj2/wrap_j2k_in_mj2.c) | 2 |
13 files changed, 121 insertions, 504 deletions
diff --git a/src/bin/jpip/CMakeLists.txt b/src/bin/jpip/CMakeLists.txt index 5a3fc0ff..d887aa7a 100644 --- a/src/bin/jpip/CMakeLists.txt +++ b/src/bin/jpip/CMakeLists.txt @@ -6,9 +6,9 @@ include_directories( ) # Tool to embed metadata into JP2 file -add_executable(addXMLinJP2 addXMLinJP2.c) +add_executable(opj_jpip_addxml opj_jpip_addxml.c) # Install exe -install(TARGETS addXMLinJP2 +install(TARGETS opj_jpip_addxml EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications ) @@ -42,12 +42,18 @@ endif() set(EXES opj_dec_server - jpip_to_jp2 - jpip_to_j2k - test_index + opj_jpip_transcode + opj_jpip_test ) foreach(exe ${EXES}) - add_executable(${exe} ${exe}.c) + if(${exe} STREQUAL "opj_jpip_transcode") + add_executable(${exe} ${exe}.c + jpip_to_jp2.c + jpip_to_j2k.c + ) + else() + add_executable(${exe} ${exe}.c) + endif() target_link_libraries(${exe} openjpip_local) install(TARGETS ${exe} EXPORT OpenJPEGTargets @@ -61,36 +67,6 @@ find_package(Java 1.5 COMPONENTS Development) # javac, jar # Only build the java viewer if dev is found: if(Java_Development_FOUND AND Java_JAVAC_EXECUTABLE) set(jflags $ENV{JFLAGS}) - # 1. opj_viewer - # build dep list: - file(GLOB java1_srcs "opj_viewer/src/*.java") - - # make sure target javac dir exists: - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes1) - # Build java - add_custom_command( - OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar - COMMAND ${Java_JAVAC_EXECUTABLE} ${jflags} - ${java1_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes1 - COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar - ${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt -C - ${CMAKE_CURRENT_BINARY_DIR}/classes1 . - DEPENDS ${java1_srcs} - ${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt - COMMENT "javac *.java; jar cvf -> opj_viewer.jar" - ) - - # name the target - add_custom_target(OPJViewerJar ALL - DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar - COMMENT "building opj_viewer.jar" - ) - - install(FILES ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar - DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule - ) - - # 2. opj_viewer_xerces # search for package org.apache.xerces.parsers find_file(APACHE_XERCES_JAR NAMES xerces-j2.jar xercesImpl.jar @@ -99,6 +75,7 @@ if(Java_Development_FOUND AND Java_JAVAC_EXECUTABLE) ) mark_as_advanced(APACHE_XERCES_JAR) + # Decide to build the simple viewer or the xerces one: if(EXISTS ${APACHE_XERCES_JAR}) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in @@ -123,11 +100,11 @@ if(Java_Development_FOUND AND Java_JAVAC_EXECUTABLE) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes2) # Build java add_custom_command( - OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar + OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar COMMAND ${Java_JAVAC_EXECUTABLE} ${jflags} -classpath ${APACHE_XERCES_JAR} ${java2_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes2 - COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar + COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar ${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt -C ${CMAKE_CURRENT_BINARY_DIR}/classes2 . DEPENDS ${java2_srcs} @@ -137,11 +114,40 @@ if(Java_Development_FOUND AND Java_JAVAC_EXECUTABLE) # name the target add_custom_target(OPJViewerXercesJar ALL - DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar - COMMENT "building opj_viewer_xerces.jar" + DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar + COMMENT "building opj_jpip_viewer.jar (xerces)" + ) + + install(FILES ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar + DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule + ) + else() + # opj_viewer (simple, no xerces) + # build dep list: + file(GLOB java1_srcs "opj_viewer/src/*.java") + + # make sure target javac dir exists: + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes1) + # Build java + add_custom_command( + OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar + COMMAND ${Java_JAVAC_EXECUTABLE} ${jflags} + ${java1_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes1 + COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar + ${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt -C + ${CMAKE_CURRENT_BINARY_DIR}/classes1 . + DEPENDS ${java1_srcs} + ${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt + COMMENT "javac *.java; jar cvf -> opj_jpip_viewer.jar" + ) + + # name the target + add_custom_target(OPJViewerJar ALL + DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar + COMMENT "building opj_jpip_viewer.jar (no xerces found)" ) - install(FILES ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar + install(FILES ${LIBRARY_OUTPUT_PATH}/opj_jpip_viewer.jar DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule ) endif() diff --git a/src/bin/jpip/jpip_to_j2k.c b/src/bin/jpip/jpip_to_j2k.c index d8b2e2b0..0f64715e 100644 --- a/src/bin/jpip/jpip_to_j2k.c +++ b/src/bin/jpip/jpip_to_j2k.c @@ -43,7 +43,7 @@ #include <stdio.h> #include "openjpip.h" -int main(int argc,char *argv[]) +int jpip_to_j2k(int argc,char *argv[]) { jpip_dec_param_t *dec; diff --git a/src/bin/jpip/jpip_to_jp2.c b/src/bin/jpip/jpip_to_jp2.c index d667ed9d..138fc8ac 100644 --- a/src/bin/jpip/jpip_to_jp2.c +++ b/src/bin/jpip/jpip_to_jp2.c @@ -43,7 +43,7 @@ #include <stdio.h> #include "openjpip.h" -int main(int argc,char *argv[]) +int jpip_to_jp2(int argc,char *argv[]) { jpip_dec_param_t *dec; diff --git a/src/bin/jpip/addXMLinJP2.c b/src/bin/jpip/opj_jpip_addxml.c index f136e913..f136e913 100644 --- a/src/bin/jpip/addXMLinJP2.c +++ b/src/bin/jpip/opj_jpip_addxml.c diff --git a/src/bin/jpip/test_index.c b/src/bin/jpip/opj_jpip_test.c index 1a22c1eb..1a22c1eb 100644 --- a/src/bin/jpip/test_index.c +++ b/src/bin/jpip/opj_jpip_test.c diff --git a/src/bin/jpip/opj_jpip_transcode.c b/src/bin/jpip/opj_jpip_transcode.c new file mode 100644 index 00000000..4bb8b354 --- /dev/null +++ b/src/bin/jpip/opj_jpip_transcode.c @@ -0,0 +1,49 @@ +/* + * $Id$ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2012, Mathieu Malaterre + * 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. + */ + +/*! \file + * \brief opj_jpip_transcode is a program to convert JPT- JPP- stream to J2K/JP2 file + * + * \section impinst Implementing instructions + * This program takes two arguments. \n + * -# Input JPT or JPP file + * -# Output J2K file\n + * % ./opj_jpip_transcode input.jpt output.j2k + * or + * % ./jpip_to_j2k input.jpp output.j2k + */ +extern int jpip_to_j2k(int argc,char *argv[]); +extern int jpip_to_jp2(int argc,char *argv[]); + +int main(int argc,char *argv[]) +{ + /* MM: FIXME */ + return jpip_to_jp2(argc,argv); +} diff --git a/src/bin/mj2/CMakeLists.txt b/src/bin/mj2/CMakeLists.txt index 601f3bd9..e27fc50e 100644 --- a/src/bin/mj2/CMakeLists.txt +++ b/src/bin/mj2/CMakeLists.txt @@ -44,52 +44,25 @@ include_directories( ${LCMS_INCLUDE_DIRNAME} ) -add_executable(frames_to_mj2 - frames_to_mj2.c - ${common_SRCS} - ${OPJ_SRCS} - ${MJ2_SRCS} - ) -target_link_libraries(frames_to_mj2 ${LCMS_LIBNAME} openmj2) - -if(UNIX) - target_link_libraries(frames_to_mj2 m) -endif() - -add_executable(mj2_to_frames - mj2_to_frames.c +foreach(exe + opj_mj2_wrap + opj_mj2_extract + opj_mj2_decompress + opj_mj2_compress +) + add_executable(${exe} + ${exe}.c ${common_SRCS} ${OPJ_SRCS} ${MJ2_SRCS} ${OPENJPEG_SOURCE_DIR}/src/bin/common/color.c ) -target_link_libraries(mj2_to_frames ${LCMS_LIBNAME}) - -if(UNIX) - target_link_libraries(mj2_to_frames m) -endif() - -add_executable(extract_j2k_from_mj2 - extract_j2k_from_mj2.c - ${OPJ_SRCS} - ${MJ2_SRCS} - ) -target_link_libraries(extract_j2k_from_mj2 ${LCMS_LIBNAME} openmj2) - -if(UNIX) - target_link_libraries(extract_j2k_from_mj2 m) -endif() - -add_executable(wrap_j2k_in_mj2 - wrap_j2k_in_mj2.c - ${OPJ_SRCS} - ${MJ2_SRCS} - ) -target_link_libraries(wrap_j2k_in_mj2 ${LCMS_LIBNAME}) - -if(UNIX) - target_link_libraries(wrap_j2k_in_mj2 m) -endif() - -install(TARGETS frames_to_mj2 mj2_to_frames extract_j2k_from_mj2 wrap_j2k_in_mj2 - DESTINATION ${OPENJPEG_INSTALL_BIN_DIR}) + target_link_libraries(${exe} ${LCMS_LIBNAME} openmj2) + + if(UNIX) + target_link_libraries(${exe} m) + endif() + + install(TARGETS ${exe} + DESTINATION ${OPENJPEG_INSTALL_BIN_DIR}) +endforeach() diff --git a/src/bin/mj2/mj2_convert.c b/src/bin/mj2/mj2_convert.c deleted file mode 100644 index ed823f8b..00000000 --- a/src/bin/mj2/mj2_convert.c +++ /dev/null @@ -1,372 +0,0 @@ -/* -* 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 and Antonin Descampe -* 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. -*/ - -#include "opj_includes.h" -#include "mj2.h" - -/* ----------------------- */ -/* */ -/* */ -/* Count the number of frames */ -/* in a YUV file */ -/* */ -/* ----------------------- */ - -unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile) -{ - unsigned int prec_size; - long end_of_f, frame_size; - FILE *f; - - f = fopen(infile,"rb"); - if (!f) { - fprintf(stderr, "failed to open %s for reading\n",infile); - return 0; - } - prec_size = (tk->depth + 7)/8;/* bytes of precision */ - - frame_size = (long) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy))); /* Calculate frame size */ - frame_size *= prec_size; - - fseek(f, 0, SEEK_END); - end_of_f = ftell(f); /* Calculate file size */ - - if (end_of_f < frame_size) { - fprintf(stderr, - "YUV does not contains any frame of %d x %d size\n", tk->w, - tk->h); - return 0; - } - fclose(f); - - return (unsigned int)(end_of_f / frame_size); -} - -/* ----------------------- */ -/* */ -/* */ -/* YUV to IMAGE */ -/* */ -/* ----------------------- */ - -opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters) -{ - opj_image_cmptparm_t cmptparm[3]; - opj_image_t * img; - int i; - int numcomps = 3; - int subsampling_dx = parameters->subsampling_dx; - int subsampling_dy = parameters->subsampling_dy; - - /* initialize image components */ - memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t)); - for(i = 0; i < numcomps; i++) { - cmptparm[i].prec = tk->depth; - cmptparm[i].bpp = tk->depth; - cmptparm[i].sgnd = 0; - cmptparm[i].dx = i ? subsampling_dx * tk->CbCr_subsampling_dx : subsampling_dx; - cmptparm[i].dy = i ? subsampling_dy * tk->CbCr_subsampling_dy : subsampling_dy; - cmptparm[i].w = tk->w; - cmptparm[i].h = tk->h; - } - /* create the image */ - img = opj_image_create(numcomps, cmptparm, CLRSPC_SRGB); - return img; -} - -char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile) -{ - int i, compno; - int offset, size, max, prec_bytes, is_16, v; - long end_of_f, position; - int numcomps = 3; - int subsampling_dx = parameters->subsampling_dx; - int subsampling_dy = parameters->subsampling_dy; - FILE *yuvfile; - int *data; - unsigned char uc; - - yuvfile = fopen(infile,"rb"); - if (!yuvfile) { - fprintf(stderr, "failed to open %s for readings\n",parameters->infile); - return 1; - } - is_16 = (tk->depth > 8); - prec_bytes = (is_16?2:1); - - offset = (int) ((double) (frame_num * tk->w * tk->h) * (1.0 + - 1.0 * (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy))); - offset *= prec_bytes; - - fseek(yuvfile, 0, SEEK_END); - end_of_f = ftell(yuvfile); - fseek(yuvfile, sizeof(unsigned char) * offset, SEEK_SET); - position = ftell(yuvfile); - if (position >= end_of_f) { - fprintf(stderr, "Cannot reach frame number %d in yuv file !!\n", - frame_num); - fclose(yuvfile); - return 1; - } - - img->x0 = tk->Dim[0]; - img->y0 = tk->Dim[1]; - img->x1 = !tk->Dim[0] ? (tk->w - 1) * subsampling_dx + 1 : tk->Dim[0] + - (tk->w - 1) * subsampling_dx + 1; - img->y1 = !tk->Dim[1] ? (tk->h - 1) * subsampling_dy + 1 : tk->Dim[1] + - (tk->h - 1) * subsampling_dy + 1; - - size = tk->w * tk->h * prec_bytes; - - for(compno = 0; compno < numcomps; compno++) - { - max = size/(img->comps[compno].dx * img->comps[compno].dy); - data = img->comps[compno].data; - - for (i = 0; i < max && !feof(yuvfile); i++) - { - v = 0; - fread(&uc, 1, 1, yuvfile); - v = uc; - - if(is_16) - { - fread(&uc, 1, 1, yuvfile); - v |= (uc<<8); - } - *data++ = v; - } - } - fclose(yuvfile); - - return 0; -} - - - -/* ----------------------- */ -/* */ -/* */ -/* IMAGE to YUV */ -/* */ -/* ----------------------- */ - - -opj_bool imagetoyuv(opj_image_t * img, char *outfile) -{ - FILE *f; - int *data; - int i, v, is_16, prec_bytes; - unsigned char buf[2]; - - if (img->numcomps == 3) { - if (img->comps[0].dx != img->comps[1].dx / 2 - || img->comps[1].dx != img->comps[2].dx) { - fprintf(stderr, - "Error with the input image components size: cannot create yuv file)\n"); - return OPJ_FALSE; - } - } else if (!(img->numcomps == 1)) { - fprintf(stderr, - "Error with the number of image components(must be one or three)\n"); - return OPJ_FALSE; - } - - f = fopen(outfile, "a+b"); - if (!f) { - fprintf(stderr, "failed to open %s for writing\n", outfile); - return OPJ_FALSE; - } - is_16 = (img->comps[0].prec > 8); - prec_bytes = (is_16?2:1); - data = img->comps[0].data; - - for (i = 0; i < (img->comps[0].w * img->comps[0].h); i++) { - v = *data++; - buf[0] = (unsigned char)v; - - if(is_16) buf[1] = (unsigned char)(v>>8); - - fwrite(buf, 1, prec_bytes, f); - } - - - if (img->numcomps == 3) { - data = img->comps[1].data; - - for (i = 0; i < (img->comps[1].w * img->comps[1].h); i++) { - v = *data++; - buf[0] = (unsigned char)v; - - if(is_16) buf[1] = (unsigned char)(v>>8); - - fwrite(buf, 1, prec_bytes, f); - } - data = img->comps[2].data; - - for (i = 0; i < (img->comps[2].w * img->comps[2].h); i++) { - v = *data++; - buf[0] = (unsigned char)v; - - if(is_16) buf[1] = (unsigned char)(v>>8); - - fwrite(buf, 1, prec_bytes, f); - } - } else if (img->numcomps == 1) { -/* fake CbCr values */ - if(is_16) - { - buf[0] = 255; - if(img->comps[0].prec == 10) buf[1] = 1; - else - if(img->comps[0].prec == 12) buf[1] = 3; - else - buf[1] = 125; - } - else buf[0] = 125; - - for (i = 0; i < (img->comps[0].w * img->comps[0].h * 0.25); i++) { - fwrite(buf, 1, prec_bytes, f); - } - - - for (i = 0; i < (img->comps[0].w * img->comps[0].h * 0.25); i++) { - fwrite(buf, 1, prec_bytes, f); - } - } - fclose(f); - return OPJ_TRUE; -} - -/* ----------------------- */ -/* */ -/* */ -/* IMAGE to BMP */ -/* */ -/* ----------------------- */ - -int imagetobmp(opj_image_t * img, char *outfile) { - int w,wr,h,hr,i,pad; - FILE *f; - - if (img->numcomps == 3 && img->comps[0].dx == img->comps[1].dx - && img->comps[1].dx == img->comps[2].dx - && img->comps[0].dy == img->comps[1].dy - && img->comps[1].dy == img->comps[2].dy - && img->comps[0].prec == img->comps[1].prec - && img->comps[1].prec == img->comps[2].prec) { - /* -->> -->> -->> -->> - - 24 bits color - - <<-- <<-- <<-- <<-- */ - - f = fopen(outfile, "wb"); - if (!f) { - fprintf(stderr, "failed to open %s for writing\n", outfile); - return 1; - } - - w = img->comps[0].w; - wr = int_ceildivpow2(img->comps[0].w, img->comps[0].factor); - - h = img->comps[0].h; - hr = int_ceildivpow2(img->comps[0].h, img->comps[0].factor); - - fprintf(f, "BM"); - - /* FILE HEADER */ - /* ------------- */ - fprintf(f, "%c%c%c%c", - (unsigned char) (hr * wr * 3 + 3 * hr * (wr % 2) + - 54) & 0xff, - (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54) - >> 8) & 0xff, - (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54) - >> 16) & 0xff, - (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54) - >> 24) & 0xff); - fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, - ((0) >> 16) & 0xff, ((0) >> 24) & 0xff); - fprintf(f, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff, - ((54) >> 16) & 0xff, ((54) >> 24) & 0xff); - - /* INFO HEADER */ - /* ------------- */ - fprintf(f, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff, - ((40) >> 16) & 0xff, ((40) >> 24) & 0xff); - fprintf(f, "%c%c%c%c", (unsigned char) ((wr) & 0xff), - (unsigned char) ((wr) >> 8) & 0xff, - (unsigned char) ((wr) >> 16) & 0xff, - (unsigned char) ((wr) >> 24) & 0xff); - fprintf(f, "%c%c%c%c", (unsigned char) ((hr) & 0xff), - (unsigned char) ((hr) >> 8) & 0xff, - (unsigned char) ((hr) >> 16) & 0xff, - (unsigned char) ((hr) >> 24) & 0xff); - fprintf(f, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff); - fprintf(f, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff); - fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, - ((0) >> 16) & 0xff, ((0) >> 24) & 0xff); - fprintf(f, "%c%c%c%c", - (unsigned char) (3 * hr * wr + - 3 * hr * (wr % 2)) & 0xff, - (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >> - 8) & 0xff, - (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >> - 16) & 0xff, - (unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >> - 24) & 0xff); - fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, - ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff); - fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, - ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff); - fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, - ((0) >> 16) & 0xff, ((0) >> 24) & 0xff); - fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, - ((0) >> 16) & 0xff, ((0) >> 24) & 0xff); - - for (i = 0; i < wr * hr; i++) { - unsigned char R, G, B; - /* a modifier */ - /* R = img->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];*/ - R = img->comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - /* G = img->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];*/ - G = img->comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - /* B = img->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];*/ - B = img->comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)]; - fprintf(f, "%c%c%c", B, G, R); - - if ((i + 1) % wr == 0) { - for (pad = (3 * wr) % 4 ? 4 - (3 * wr) % 4 : 0; pad > 0; pad--) /* ADD */ - fprintf(f, "%c", 0); - } - } - fclose(f); - } - return 0; -} diff --git a/src/bin/mj2/mj2_convert.h b/src/bin/mj2/mj2_convert.h deleted file mode 100644 index 736ef80c..00000000 --- a/src/bin/mj2/mj2_convert.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -* Copyright (c) 2003-2004, Francois-Olivier Devaux -* Copyright (c) 2002-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium -* 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. -*/ - - -#include "mj2.h" - -#ifndef __MJ2_CONVERT_H -#define __MJ2_CONVERT_H - -int imagetoyuv(opj_image_t * img, char *outfile); - -int imagetobmp(opj_image_t * img, char *outfile); - -opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters); - -char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile); - -unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile); - - -#endif diff --git a/src/bin/mj2/frames_to_mj2.c b/src/bin/mj2/opj_mj2_compress.c index dff34ab7..d05204bf 100644 --- a/src/bin/mj2/frames_to_mj2.c +++ b/src/bin/mj2/opj_mj2_compress.c @@ -776,7 +776,9 @@ int main(int argc, char **argv) cio_write(cio, JP2_JP2C, 4); // JP2C /* encode the image */ +#if 0 /* MM: FIXME */ bSuccess = opj_encode(cinfo, cio, img, NULL); +#endif if (!bSuccess) { opj_cio_close(cio); diff --git a/src/bin/mj2/mj2_to_frames.c b/src/bin/mj2/opj_mj2_decompress.c index 32679198..1cf05555 100644 --- a/src/bin/mj2/mj2_to_frames.c +++ b/src/bin/mj2/opj_mj2_decompress.c @@ -177,7 +177,9 @@ int main(int argc, char *argv[]) { /* open a byte stream */ cio = opj_cio_open((opj_common_ptr)dinfo, frame_codestream, sample->sample_size-8); +#if 0 /* MM: FIXME */ img = opj_decode(dinfo, cio); // Decode J2K to image +#endif #ifdef WANT_SYCC_TO_RGB if(img->color_space == CLRSPC_SYCC) diff --git a/src/bin/mj2/extract_j2k_from_mj2.c b/src/bin/mj2/opj_mj2_extract.c index f694d531..f694d531 100644 --- a/src/bin/mj2/extract_j2k_from_mj2.c +++ b/src/bin/mj2/opj_mj2_extract.c diff --git a/src/bin/mj2/wrap_j2k_in_mj2.c b/src/bin/mj2/opj_mj2_wrap.c index 7ce88677..5d37cd7b 100644 --- a/src/bin/mj2/wrap_j2k_in_mj2.c +++ b/src/bin/mj2/opj_mj2_wrap.c @@ -89,7 +89,9 @@ static int test_image(const char *fname, mj2_cparameters_t *cp) cio = opj_cio_open((opj_common_ptr)dinfo, src, src_len); +#if 0 /* MM: FIXME */ image = opj_decode(dinfo, cio); +#endif free(src); cio->buffer = NULL; opj_cio_close(cio); |
