git commit -a
This commit is contained in:
parent
c6c49865fe
commit
98c1febceb
|
@ -0,0 +1,8 @@
|
||||||
|
**Restoring indexfile in opj_compress.c and opj_decompress.c**
|
||||||
|
|
||||||
|
This patch allows once more to get an indexfile with
|
||||||
|
|
||||||
|
opj_compress -i INFILE -o OUTFILE -x INDEXFILE
|
||||||
|
|
||||||
|
opj_decompress -i INFILE -o OUTFILE -x INDEXFILE
|
||||||
|
|
|
@ -31,12 +31,14 @@
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "opj_inttypes.h"
|
#include "opj_inttypes.h"
|
||||||
|
#include "format_defs.h"
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
@ -395,3 +397,115 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void opj_dump_file(const char *infile, const char *indexfilename,
|
||||||
|
int format, int imageno)
|
||||||
|
{
|
||||||
|
FILE *fout = NULL;
|
||||||
|
opj_dparameters_t parameters;
|
||||||
|
opj_image_t* image = NULL;
|
||||||
|
opj_codec_t* l_codec = NULL;
|
||||||
|
opj_stream_t *l_stream = NULL;
|
||||||
|
char *outfile;
|
||||||
|
int fails;
|
||||||
|
int flags = OPJ_IMG_INFO | OPJ_J2K_MH_INFO | OPJ_J2K_MH_IND;
|
||||||
|
OPJ_CODEC_FORMAT codec_format;
|
||||||
|
|
||||||
|
if(format == J2K_CFMT)
|
||||||
|
codec_format = OPJ_CODEC_J2K;
|
||||||
|
else
|
||||||
|
if(format == JP2_CFMT)
|
||||||
|
codec_format = OPJ_CODEC_JP2;
|
||||||
|
else
|
||||||
|
if(format == JPT_CFMT)
|
||||||
|
codec_format = OPJ_CODEC_JPT;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%s:%d:\n\tdump_file has wrong format %d\n",
|
||||||
|
__FILE__,__LINE__,format);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
outfile = (char*)malloc(strlen(indexfilename) + 8);
|
||||||
|
|
||||||
|
if(outfile == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%s:%d:\n\tdump_file memory out\n",
|
||||||
|
__FILE__,__LINE__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(imageno > 1)
|
||||||
|
{
|
||||||
|
sprintf(outfile, "%s-%d", indexfilename, imageno);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(outfile, indexfilename);
|
||||||
|
}
|
||||||
|
opj_set_default_decoder_parameters(¶meters);
|
||||||
|
|
||||||
|
strcpy(parameters.outfile, outfile);
|
||||||
|
|
||||||
|
parameters.decod_format = format;
|
||||||
|
|
||||||
|
fout = fopen(outfile,"w");
|
||||||
|
|
||||||
|
if(fout == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s:%d:\n\tdump_file: failed to open %s for writing\n",
|
||||||
|
__FILE__,__LINE__,outfile);
|
||||||
|
free(outfile);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
strcpy(parameters.infile, infile);
|
||||||
|
|
||||||
|
fails = 1;
|
||||||
|
|
||||||
|
l_stream =
|
||||||
|
opj_stream_create_default_file_stream(infile, 1);//1:READ
|
||||||
|
|
||||||
|
if(l_stream == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "dump_file: opj_stream_create_default_file_stream"
|
||||||
|
" failed.\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
l_codec = opj_create_decompress(codec_format);
|
||||||
|
|
||||||
|
if(l_codec == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "dump_file: opj_create_decompress failed.\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !opj_setup_decoder(l_codec, ¶meters) )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "dump_file: opj_setup_decoder failed.\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! opj_read_header(l_stream, l_codec, &image))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "dump_file: opj_read_header failed.\n");
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_dump_codec(l_codec, flags, fout );
|
||||||
|
|
||||||
|
fails = 0;
|
||||||
|
fin:
|
||||||
|
if(fails) remove(outfile);
|
||||||
|
|
||||||
|
if(l_stream) opj_stream_destroy(l_stream);
|
||||||
|
|
||||||
|
if(l_codec) opj_destroy_codec(l_codec);
|
||||||
|
|
||||||
|
if(image) opj_image_destroy(image);
|
||||||
|
|
||||||
|
fclose(fout);
|
||||||
|
|
||||||
|
free(outfile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,9 @@ Write a structured index to a file
|
||||||
*/
|
*/
|
||||||
int write_index_file(opj_codestream_info_t *cstr_info, char *index);
|
int write_index_file(opj_codestream_info_t *cstr_info, char *index);
|
||||||
|
|
||||||
|
void opj_dump_file(const char *infile, const char *indexfilename,
|
||||||
|
int format, int imageno);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -104,9 +104,7 @@ static void encode_help_display(void) {
|
||||||
fprintf(stdout," * No sub-sampling in x or y direction\n");
|
fprintf(stdout," * No sub-sampling in x or y direction\n");
|
||||||
fprintf(stdout," * No mode switch activated\n");
|
fprintf(stdout," * No mode switch activated\n");
|
||||||
fprintf(stdout," * Progression order: LRCP\n");
|
fprintf(stdout," * Progression order: LRCP\n");
|
||||||
#ifdef FIXME_INDEX
|
|
||||||
fprintf(stdout," * No index file\n");
|
fprintf(stdout," * No index file\n");
|
||||||
#endif /* FIXME_INDEX */
|
|
||||||
fprintf(stdout," * No ROI upshifted\n");
|
fprintf(stdout," * No ROI upshifted\n");
|
||||||
fprintf(stdout," * No offset of the origin of the image\n");
|
fprintf(stdout," * No offset of the origin of the image\n");
|
||||||
fprintf(stdout," * No offset of the origin of the tiles\n");
|
fprintf(stdout," * No offset of the origin of the tiles\n");
|
||||||
|
@ -214,10 +212,8 @@ static void encode_help_display(void) {
|
||||||
fprintf(stdout," Divide packets of every tile into tile-parts.\n");
|
fprintf(stdout," Divide packets of every tile into tile-parts.\n");
|
||||||
fprintf(stdout," Division is made by grouping Resolutions (R), Layers (L)\n");
|
fprintf(stdout," Division is made by grouping Resolutions (R), Layers (L)\n");
|
||||||
fprintf(stdout," or Components (C).\n");
|
fprintf(stdout," or Components (C).\n");
|
||||||
#ifdef FIXME_INDEX
|
|
||||||
fprintf(stdout,"-x <index file>\n");
|
fprintf(stdout,"-x <index file>\n");
|
||||||
fprintf(stdout," Create an index file.\n");
|
fprintf(stdout," Create an index file.\n");
|
||||||
#endif /*FIXME_INDEX*/
|
|
||||||
fprintf(stdout,"-ROI c=<component index>,U=<upshifting value>\n");
|
fprintf(stdout,"-ROI c=<component index>,U=<upshifting value>\n");
|
||||||
fprintf(stdout," Quantization indices upshifted for a component. \n");
|
fprintf(stdout," Quantization indices upshifted for a component. \n");
|
||||||
fprintf(stdout," Warning: This option does not implement the usual ROI (Region of Interest).\n");
|
fprintf(stdout," Warning: This option does not implement the usual ROI (Region of Interest).\n");
|
||||||
|
@ -312,7 +308,6 @@ static void encode_help_display(void) {
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
#ifdef FIXME_INDEX
|
|
||||||
fprintf(stdout,"Index structure:\n");
|
fprintf(stdout,"Index structure:\n");
|
||||||
fprintf(stdout,"----------------\n");
|
fprintf(stdout,"----------------\n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
|
@ -346,7 +341,6 @@ static void encode_help_display(void) {
|
||||||
fprintf(stdout,"Tpacket_Np '' '' '' '' '' '' '' ''\n");
|
fprintf(stdout,"Tpacket_Np '' '' '' '' '' '' '' ''\n");
|
||||||
fprintf(stdout,"MaxDisto\n");
|
fprintf(stdout,"MaxDisto\n");
|
||||||
fprintf(stdout,"TotalDisto\n\n");
|
fprintf(stdout,"TotalDisto\n\n");
|
||||||
#endif /*FIXME_INDEX*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static OPJ_PROG_ORDER give_progression(const char progression[4]) {
|
static OPJ_PROG_ORDER give_progression(const char progression[4]) {
|
||||||
|
@ -806,11 +800,6 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||||
{
|
{
|
||||||
char *index = opj_optarg;
|
char *index = opj_optarg;
|
||||||
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
||||||
/* FIXME ADE INDEX >> */
|
|
||||||
fprintf(stderr,
|
|
||||||
"[WARNING] Index file generation is currently broken.\n"
|
|
||||||
" '-x' option ignored.\n");
|
|
||||||
/* << FIXME ADE INDEX */
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1821,7 +1810,6 @@ int main(int argc, char **argv) {
|
||||||
remove(parameters.outfile);
|
remove(parameters.outfile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout,"[INFO] Generated outfile %s\n",parameters.outfile);
|
fprintf(stdout,"[INFO] Generated outfile %s\n",parameters.outfile);
|
||||||
/* close and free the byte stream */
|
/* close and free the byte stream */
|
||||||
opj_stream_destroy(l_stream);
|
opj_stream_destroy(l_stream);
|
||||||
|
@ -1832,6 +1820,11 @@ int main(int argc, char **argv) {
|
||||||
/* free image data */
|
/* free image data */
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
|
|
||||||
|
if(indexfilename[0])
|
||||||
|
{
|
||||||
|
opj_dump_file(parameters.outfile, indexfilename,
|
||||||
|
parameters.cod_format, imageno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free user parameters structure */
|
/* free user parameters structure */
|
||||||
|
@ -1841,3 +1834,4 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1498,7 +1498,16 @@ int main(int argc, char **argv)
|
||||||
/* destroy the codestream index */
|
/* destroy the codestream index */
|
||||||
opj_destroy_cstr_index(&cstr_index);
|
opj_destroy_cstr_index(&cstr_index);
|
||||||
|
|
||||||
if(failed) remove(parameters.outfile);
|
if(failed)
|
||||||
|
{
|
||||||
|
remove(parameters.outfile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(indexfilename[0])
|
||||||
|
{
|
||||||
|
opj_dump_file(parameters.infile, indexfilename,
|
||||||
|
parameters.decod_format, imageno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
destroy_parameters(¶meters);
|
destroy_parameters(¶meters);
|
||||||
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
|
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue