From 86ce4d4c18cd924703a71c9096edcf0cc0e2d87a Mon Sep 17 00:00:00 2001 From: Francois-Olivier Devaux Date: Fri, 25 Mar 2005 09:44:32 +0000 Subject: [PATCH] New OpenJPEG MJ2 module: mj2_to_metadata created by Glenn Pearson. The OpenJPEG team would like to thank him for his contributions ! --- mj2/meta_out.c | 2136 +++++++++++++++++++++++++++++++++ mj2/meta_out.h | 13 + mj2/mj2_to_metadata.c | 282 +++++ mj2/mj2_to_metadata.dsp | 276 +++++ mj2/mj2_to_metadata.h | 9 + mj2/mj2_to_metadata_Notes.doc | Bin 0 -> 33792 bytes 6 files changed, 2716 insertions(+) create mode 100644 mj2/meta_out.c create mode 100644 mj2/meta_out.h create mode 100644 mj2/mj2_to_metadata.c create mode 100644 mj2/mj2_to_metadata.dsp create mode 100644 mj2/mj2_to_metadata.h create mode 100644 mj2/mj2_to_metadata_Notes.doc diff --git a/mj2/meta_out.c b/mj2/meta_out.c new file mode 100644 index 00000000..f6bac92e --- /dev/null +++ b/mj2/meta_out.c @@ -0,0 +1,2136 @@ +/* meta_out.c */ +/* Dump MJ2, JP2 metadata (partial so far) to xml file */ +/* Callable from mj2_to_metadata */ +/* Contributed to Open JPEG by Glenn Pearson, contract software developer, U.S. National Library of Medicine. + +The base code in this file was developed by the author as part of a video archiving +project for the U.S. National Library of Medicine, Bethesda, MD. +It is the policy of NLM (and U.S. government) to not assert copyright. + +A non-exclusive copy of this code has been contributed to the Open JPEG project. +Except for copyright, inclusion of the code within Open JPEG for distribution and use +can be bound by the Open JPEG open-source license and disclaimer, expressed elsewhere. +*/ +#include +#include +#include + +#include "mj2.h" +#include + +//MEMORY LEAK +#ifdef _DEBUG +#define _CRTDBG_MAP_ALLOC +#include // Must be included first +#include +#endif +//MEM + +#include /* for time functions */ +#include +#include "meta_out.h" +#include + +jmp_buf j2k_error; +extern j2k_tcp_t j2k_default_tcp; +static BOOL notes = TRUE; +static BOOL sampletables = FALSE; +static BOOL raw = TRUE; +static BOOL derived = TRUE; + +/* Forwards */ +int xml_write_overall_header(FILE *xmlout, mj2_movie_t * movie); + +void uint_to_chars(unsigned int value, char* buf); + +void xml_write_trak(FILE *file, FILE *xmlout, mj2_tk_t *track, unsigned int tnum, unsigned int sampleframe); +void xml_write_tkhd(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum); +void xml_write_udta(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum); +void xml_write_mdia(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum); +void xml_write_stbl(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum); + +void UnixTimeToFileTime(time_t t, LPFILETIME pft); +void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst); +void xml_time_out(FILE* xmlout, time_t t); + +void int16_to_3packedchars(short int value, char* buf); + +void xml_write_moov_udta(FILE* xmlout, mj2_movie_t * movie); +void xml_write_free_and_skip(FILE* xmlout, mj2_movie_t * movie); +void xml_write_uuid(FILE* xmlout, mj2_movie_t * movie); + +int xml_out_frame(FILE* file, FILE* xmlout, mj2_sample_t *sample, unsigned int snum); + +void xml_out_frame_siz(FILE* xmlout, j2k_image_t *img, j2k_cp_t *cp); +void xml_out_frame_cod(FILE* xmlout, j2k_tcp_t *tcp); +void xml_out_frame_coc(FILE* xmlout, j2k_tcp_t *tcp, int numcomps); /* j2k_image_t *img); */ +BOOL same_component_style(j2k_tccp_t *tccp1, j2k_tccp_t *tccp2); +void xml_out_frame_qcd(FILE* xmlout, j2k_tcp_t *tcp); +void xml_out_frame_qcc(FILE* xmlout, j2k_tcp_t *tcp, int numcomps); /* j2k_image_t *img); */ +BOOL same_component_quantization(j2k_tccp_t *tccp1, j2k_tccp_t *tccp2); +void xml_out_frame_rgn(FILE* xmlout, j2k_tcp_t *tcp, int numcomps);/* j2k_image_t *img);*/ +void xml_out_frame_poc(FILE* xmlout, j2k_tcp_t *tcp); +void xml_out_frame_ppm(FILE* xmlout, j2k_cp_t *cp); +void xml_out_frame_ppt(FILE* xmlout, j2k_tcp_t *tcp); +void xml_out_frame_tlm(FILE* xmlout); /* j2k_default_tcp is passed globally */ /* NO-OP. TLM NOT SAVED IN DATA STRUCTURE */ +void xml_out_frame_plm(FILE* xmlout); /* j2k_default_tcp is passed globally */ /* NO-OP. PLM NOT SAVED IN DATA STRUCTURE. opt in main; can be used in conjunction with PLT */ +void xml_out_frame_plt(FILE* xmlout, j2k_tcp_t *tcp); /* NO-OP. PLM NOT SAVED IN DATA STRUCTURE. opt in main; can be used in conjunction with PLT */ +void xml_out_frame_crg(FILE* xmlout); /* j2k_default_tcp is passed globally */ /* opt in main; */ +void xml_out_frame_com(FILE* xmlout, j2k_tcp_t *tcp); /* NO-OP. COM NOT SAVED IN DATA STRUCTURE */ /* opt in main; */ +void xml_out_dump_hex(FILE* xmlout, char *data, int data_len); +void xml_out_dump_hex_and_ascii(FILE* xmlout, char *data, int data_len); +void xml_out_frame_jp2h(FILE* xmlout, jp2_struct_t *jp2_struct); +#ifdef NOTYET +/* Shown with cp, extended, as data structure... but it could be a new different one */ +void xml_out_frame_jp2i(FILE* xmlout, j2k_cp_t *cp);/* IntellectualProperty 'jp2i' (no restrictions on location) */ +void xml_out_frame_xml(FILE* xmlout, j2k_cp_t *cp); /* XML 'xml\040' (0x786d6c20). Can appear multiply */ +void xml_out_frame_uuid(FILE* xmlout, j2k_cp_t *cp); /* UUID 'uuid' (top level only) */ +void xml_out_frame_uinf(FILE* xmlout, j2k_cp_t *cp); /* UUIDInfo 'uinf', includes UUIDList 'ulst' and URL 'url\40' */ +void xml_out_frame_unknown_type(FILE* xmlout, j2k_cp_t *cp); +#endif + + +/* ------------------------------------------------------------------------------------------- */ + +void xml_write_init(BOOL n, BOOL t, BOOL r, BOOL d) +{ + /* Init file globals */ + notes = n; + sampletables = t; + raw = r; + derived = d; +} + +int xml_write_struct(FILE* file, FILE *xmlout, mj2_movie_t * movie, unsigned int sampleframe, char* stringDTD) { + unsigned int tnum; + mj2_tk_t *track; + + if(stringDTD != NULL) + { + fprintf(xmlout,"\n"); + /* stringDTD is known to start with "SYSTEM " or "PUBLIC " */ + /* typical: SYSTEM mj2_to_metadata.dtd */ + stringDTD[6] = '\0'; /* Break into two strings at space, so quotes can be inserted. */ + fprintf(xmlout,"\n", stringDTD, stringDTD+7); + stringDTD[6] = ' '; /* restore for sake of debugger or memory allocator */ + } else + fprintf(xmlout,"\n"); + + fprintf(xmlout, "\n"); + xml_write_overall_header(xmlout, movie); + // Find first video track + tnum = 0; + while (movie->tk[tnum].track_type != 0) + tnum ++; + + track = &(movie->tk[tnum]); + + // For now, output info on first video track + xml_write_trak(file, xmlout, track, tnum, sampleframe); + + fprintf(xmlout, ""); + return 0; +} + +/* ------------- */ + +int xml_write_overall_header(FILE *xmlout, mj2_movie_t * movie) +{ + int i; + char buf[5]; + buf[4] = '\0'; + fprintf(xmlout, " \n"); + // Called after structure initialized by mj2_read_ftyp + fprintf(xmlout, " \n"); + uint_to_chars(movie->brand, buf); + fprintf(xmlout, " %s\n", buf); /* 4 character; BR */ + fprintf(xmlout, " %u\n", movie->minversion); /* 4 char; MinV */ + fprintf(xmlout, " \n",movie->num_cl); + for (i = movie->num_cl - 1; i > -1; i--) /* read routine stored in reverse order, so let's undo damage */ + { + uint_to_chars(movie->cl[i], buf); + fprintf(xmlout, " %s\n", buf); /*4 characters, each CLi */ + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " %u\n", movie->creation_time); + if(notes) + fprintf(xmlout, " \n"); + /* 2082844800 = seconds between 1/1/04 and 1/1/70 */ + /* There's still a time zone offset problem not solved... but spec is ambigous as to whether stored time + should be local or UTC */ + if(derived) { + fprintf(xmlout, " "); + xml_time_out(xmlout, movie->creation_time - 2082844800); + fprintf(xmlout,"\n"); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " %u\n", movie->modification_time); + if(derived) { + fprintf(xmlout, " "); + xml_time_out(xmlout, movie->modification_time - 2082844800); + fprintf(xmlout,"\n"); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", movie->timescale); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); /* Rate to play presentation (default = 0x00010000) */ +#define CURRENTSTRUCT +#ifdef CURRENTSTRUCT + movie->rate = movie->rate << 16; +#endif + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + if(raw) + fprintf(xmlout, " 0x%08x\n", movie->rate); + if(derived) + fprintf(xmlout, " %12.6f\n", (double)movie->rate/(double)0x00010000); +#ifdef CURRENTSTRUCT + if(notes) + fprintf(xmlout, " \n"); + movie->rate = movie->rate >> 16; +#endif + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " %u\n", movie->duration); + if(derived) + fprintf(xmlout, " %12.3f\n", (double)movie->duration/(double)movie->timescale); // Make this double later to get fractional seconds + fprintf(xmlout, " \n"); +#ifdef CURRENTSTRUCT + movie->volume = movie->volume << 8; +#endif + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + if(raw) + fprintf(xmlout, " 0x%04x\n", movie->volume); + if(derived) + fprintf(xmlout, " %6.3f\n", (double)movie->volume/(double)0x0100); + fprintf(xmlout, " \n"); +#ifdef CURRENTSTRUCT + if(notes) + fprintf(xmlout, " \n"); + movie->volume = movie->volume >> 8; +#endif + /* Transformation matrix for video */ + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " 0x%08x\n", movie->trans_matrix[0]); + fprintf(xmlout, " 0x%08x\n", movie->trans_matrix[1]); + fprintf(xmlout, " 0x%08x\n", movie->trans_matrix[2]); + fprintf(xmlout, " 0x%08x\n", movie->trans_matrix[3]); + fprintf(xmlout, " 0x%08x\n", movie->trans_matrix[4]); + fprintf(xmlout, " 0x%08x\n", movie->trans_matrix[5]); + fprintf(xmlout, " 0x%08x\n", movie->trans_matrix[6]); + fprintf(xmlout, " 0x%08x\n", movie->trans_matrix[7]); + fprintf(xmlout, " 0x%08x\n", movie->trans_matrix[8]); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + // Done elsewhere: one or more + // to come: // possibly not in Simple Profile + xml_write_moov_udta(xmlout, movie); /* NO OP so far */ /* contains */ + + fprintf(xmlout, " \n"); + // To come? // This is the container for media data that can also be accessed through track structures, + // so is redundant, and simply not of interest as metadata + // // Allows incremental build up of movie. Probably not in Simple Profile + xml_write_free_and_skip(xmlout, movie); /* NO OP so far */ /* May be a place where user squirrels metadata */ + xml_write_uuid(xmlout, movie); /* NO OP so far */ /* May be a place where user squirrels metadata */ + + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n", movie->num_vtk); + fprintf(xmlout, " \n", movie->num_stk); + fprintf(xmlout, " %d\n", movie->num_htk); + if(notes) + fprintf(xmlout, " \n"); + /* See Part 3 Amend 2 Section 4.2 for relation of MJ2 to Part 12 Sections 7 and 10 hints */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + /* Idea for the future: It would be possible to add code to verify that the file values: + 1) are legal and self-consistent + 2) comply with particular JP2 and/or MJ2 profiles. + This could be reported here as additional XML elements */ + return 0; +} + +/* ------------- */ + +void uint_to_chars(unsigned int value, char* buf) +{ + /* buf is at least char[5] */ + int i; + for (i = 3; i >= 0; i--) + { + buf[i] = (value & 0x000000ff); + value = (value >> 8); + } + buf[4] = '\0'; /* Precautionary */ +} + +/* ------------- */ + +/* WINDOWS SPECIFIC */ + +void UnixTimeToFileTime(time_t t, LPFILETIME pft) +{ + /* Windows specific. From MS Q167296 */ + /* 'time_t' represents seconds since midnight January 1, 1970 UTC (coordinated universal time). */ + /* 64-bit FILETIME structure represents the number of 100-nanosecond intervals since January 1, 1601 UTC (coordinate universal time). */ + LONGLONG ll; /* LONGLONG is a 64-bit value. */ + ll = Int32x32To64(t, 10000000) + 116444736000000000; + pft->dwLowDateTime = (DWORD)ll; + /* pft->dwLowDateTime = (DWORD)(0x00000000ffffffff & ll); */ + pft->dwHighDateTime = (DWORD)(ll >> 32); +} +// Once the UNIX time is converted to a FILETIME structure, +// other Win32 time formats can be easily obtained by using Win32 functions such +// as FileTimeToSystemTime() and FileTimeToDosDateTime(). + +/* ------------- */ + +void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst) +{ + /* Windows specific */ + FILETIME ft; + UnixTimeToFileTime(t, &ft); + FileTimeToLocalFileTime( &ft, &ft ); /* Adjust from UTC to local time zone */ + FileTimeToSystemTime(&ft, pst); +} + +/* ------------- */ + +void xml_time_out(FILE* xmlout, time_t t) +{ + /* Windows specific */ + SYSTEMTIME st; + char szLocalDate[255], szLocalTime[255]; + UnixTimeToSystemTime( t, &st ); + GetDateFormat( LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, szLocalDate, 255 ); + GetTimeFormat( LOCALE_USER_DEFAULT, 0, &st, NULL, szLocalTime, 255 ); + fprintf(xmlout, "%s %s", szLocalDate, szLocalTime ); +} + +/* END WINDOWS SPECIFIC */ + +/* ------------- */ + +void xml_write_moov_udta(FILE* xmlout, mj2_movie_t * movie) { + /* Compare with xml_write_udta */ +#ifdef NOTYET + /* NO-OP so far. Optional UserData 'udta' (zero or one in moov or each trak) + can contain multiple Copyright 'cprt' with different language codes */ + /* There may be nested non-standard boxes within udta */ + IMAGINE movie->udta, movie->copyright_count, movie->copyright_language[i] (array of 16bit ints), movie->copyright_notice[i] (array of buffers) + PROBABLY ALSO NEED movie->udta_len or special handler for non-standard boxes + char buf[5]; + int i; + + if(movie->udta != 1) + return; /* Not present */ + + fprintf(xmlout, " \n"); + for(i = 0; i < movie->copyright_count; i++) { + fprintf(xmlout, " Instance=\"%d\">\n", i+1); + int16_to_3packedchars((short int)movie->copyright_languages[i], buf); + fprintf(xmlout, " %s\n", buf); /* 3 chars */ + fprintf(xmlout, " %s\n",movie->copyright_notices[i]); + fprintf(xmlout, " \n", i+1); + } + /* TO DO: Non-standard boxes */ + fprintf(xmlout, " \n"); +#endif +} + +void xml_write_free_and_skip(FILE* xmlout, mj2_movie_t * movie) { +#ifdef NOTYET + /* NO-OP so far. There can be zero or more instances of free and/or skip + at the top level of the file. This may be a place where the user squirrel's metadata. + Let's assume unstructured, and do a dump */ + IMAGINE movie->free_and_skip, movie->free_and_skip_count, movie->free_and_skip_content[i] (array of buffers), + movie->free_and_skip_len[i] (array of ints), movie->is_skip[i] (array of BOOL) + int i; + + if(movie->free_and_skip != 1) + return; /* Not present */ + + for(i = 0; i < movie->free_and_skip_count; i++) { + if(movie->is_skip[i]) + fprintf(xmlout, " \n"); + else + fprintf(xmlout, " \n"); + + xml_out_dump_hex_and_ascii(xmlout, movie->free_and_skip_contents[i], movie->free_and_skip_len[i]); + + if(movie->is_skip[i]) + fprintf(xmlout, " \n"); + else + fprintf(xmlout, " \n"); + } +#endif +} + +void xml_write_uuid(FILE* xmlout, mj2_movie_t * movie) { +/* Univeral Unique IDs of 16 bytes. */ +#ifdef NOTYET + /* NO-OP so far. There can be zero or more instances of private uuid boxes in a file. + This function supports the top level of the file, but uuid may be elsewhere [not yet supported]. + This may be a place where the user squirrel's metadata. Let's assume unstructured, and do a dump */ + IMAGINE movie->uuid, movie->uuid_count, movie->uuid_content[i] (array of buffers), + movie->uuid_len[i] (array of ints), movie->uuid_type[i] (array of 17-byte (16+null termination) buffers) + int i; + + if(movie->uuid != 1) + return; /* Not present */ + + for(i = 0; i < movie->uuid_count; i++) { + fprintf(xmlout, " \n", movie->uuid_type[i]); + // See Part III section 5.2.1, 6.1, 6.2 + xml_out_dump_hex_and_ascii(xmlout, movie->uuid_contents[i], movie->uuid_len[i]); + fprintf(xmlout, " \n"); + } +#endif +} + +/* ------------- */ + +void xml_write_trak(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum, unsigned int sampleframe) +{ + fprintf(xmlout, " \n", tnum); + xml_write_tkhd(file, xmlout, track, tnum); + // TO DO: TrackReferenceContainer 'tref' just used in hint track + // TO DO: EditListContainer 'edts', contains EditList 'elst' with media-time, segment-duration, media-rate + xml_write_mdia(file, xmlout, track, tnum); + xml_write_udta(file, xmlout, track, tnum); // NO-OP so far. Optional UserData 'udta', can contain multiple Copyright 'cprt' + + if(track->track_type==0) { /* Only do for visual track */ + /* sampleframe is from user option -f. 1 = first frame */ + /* sampleframe of 0 is a user requests: no jp2 header */ + /* Treat out-of-bounds values in the same way */ + if(sampleframe > 0 && sampleframe <= track->num_samples) + { + mj2_sample_t *sample; + unsigned int snum; + + snum = sampleframe-1; + // Someday maybe do a smart range scan... for (snum=0; snum < track->num_samples; snum++){ + // fprintf(stdout,"Frame %d: ",snum+1); + sample = &track->sample[snum]; + if(xml_out_frame(file, xmlout, sample, snum)) + return; /* Not great error handling here */ + } + } + fprintf(xmlout, " \n"); +} + +/* ------------- */ + +void xml_write_tkhd(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum) +{ + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " %u\n", track->track_ID); + if(track->track_type==0) /* For visual track */ + { + fprintf(xmlout, " %d\n", track->layer); + if(notes) + fprintf(xmlout," \n"); + } + if(track->track_type!=0) /* volume irrelevant for visual track */ + { +#ifdef CURRENTSTRUCT + track->volume = track->volume << 8; +#endif + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout," \n"); + fprintf(xmlout," \n"); + } + if(raw) + fprintf(xmlout," 0x%04x\n", track->volume); + if(derived) + fprintf(xmlout," %6.3f\n", (double)track->volume/(double)0x0100); + fprintf(xmlout, " \n"); +#ifdef CURRENTSTRUCT + if(notes) + fprintf(xmlout, " \n"); + track->volume = track->volume >> 8; +#endif + } + if(track->track_type==0) + { + /* Transformation matrix for video */ + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout," \n"); + fprintf(xmlout," \n"); + } + fprintf(xmlout, " 0x%08x\n", track->trans_matrix[0]); + fprintf(xmlout, " 0x%08x\n", track->trans_matrix[1]); + fprintf(xmlout, " 0x%08x\n", track->trans_matrix[2]); + fprintf(xmlout, " 0x%08x\n", track->trans_matrix[3]); + fprintf(xmlout, " 0x%08x\n", track->trans_matrix[4]); + fprintf(xmlout, " 0x%08x\n", track->trans_matrix[5]); + fprintf(xmlout, " 0x%08x\n", track->trans_matrix[6]); + fprintf(xmlout, " 0x%08x\n", track->trans_matrix[7]); + fprintf(xmlout, " 0x%08x\n", track->trans_matrix[8]); + fprintf(xmlout, " \n"); + } +#ifdef CURRENTSTRUCT + track->w = track->w << 16; + track->h = track->h << 16; +#endif + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " 0x%08x\n", track->w); + if(derived) + fprintf(xmlout, " %12.6f\n", (double)track->w/(double)0x00010000); /* Rate to play presentation (default = 0x00010000) */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " 0x%08x\n", track->h); + if(derived) + fprintf(xmlout, " %12.6f\n", (double)track->h/(double)0x00010000); /* Rate to play presentation (default = 0x00010000) */ + fprintf(xmlout, " \n"); +#ifdef CURRENTSTRUCT + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + track->w = track->w >> 16; + track->h = track->h >> 16; +#endif + fprintf(xmlout, " \n"); +} + +/* ------------- */ + +void xml_write_udta(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum) { + /* NO-OP so far. Optional UserData 'udta' (zero or one in moov or each trak) + can contain multiple Copyright 'cprt' with different language codes */ + /* There may be nested non-standard boxes within udta */ +#ifdef NOTYET + IMAGINE track->udta, track->copyright_count, track->copyright_language[i] (array of 16bit ints), track->copyright_notice[i] (array of buffers) + PROBABLY ALSO NEED track->udta_len or special handler for non-standard boxes + char buf[5]; + int i; + + if(track->udta != 1) + return; /* Not present */ + + fprintf(xmlout, " \n"); + for(i = 0; i < track->copyright_count; i++) { + fprintf(xmlout, " Instance=\"%d\">\n", i+1); + int16_to_3packedchars((short int)track->copyright_languages[i], buf); + fprintf(xmlout, " %s\n", buf); /* 3 chars */ + fprintf(xmlout, " %s\n",track->copyright_notices[i]); + fprintf(xmlout, " \n", i+1); + } + /* TO DO: Non-standard boxes */ + fprintf(xmlout, " \n"); +#endif +} + +/* ------------- */ + +void xml_write_mdia(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum) +{ + char buf[5]; + int i, k; + buf[4] = '\0'; + + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " %u\n", track->creation_time); + if(notes) + fprintf(xmlout, " \n"); + /* 2082844800 = seconds between 1/1/04 and 1/1/70 */ + /* There's still a time zone offset problem not solved... but spec is ambigous as to whether stored time + should be local or UTC */ + if(derived) { + fprintf(xmlout, " "); + xml_time_out(xmlout, track->creation_time - 2082844800); + fprintf(xmlout,"\n"); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " %u\n", track->modification_time); + if(derived) { + fprintf(xmlout, " "); + xml_time_out(xmlout, track->modification_time - 2082844800); + fprintf(xmlout,"\n"); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", track->timescale); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " %u\n", track->duration); + if(derived) + fprintf(xmlout, " %12.3f\n", (double)track->duration/(double)track->timescale); // Make this double later to get fractional seconds + fprintf(xmlout, " \n"); + int16_to_3packedchars((short int)track->language, buf); + fprintf(xmlout, " %s\n", buf); /* 3 chars */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + switch(track->track_type) + { + case 0: + fprintf(xmlout, " video media track\n"); break; + case 1: + fprintf(xmlout, " Sound\n"); break; + case 2: + fprintf(xmlout, " Hint\n"); break; + } + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + switch(track->track_type) + { + case 0: + fprintf(xmlout, " \n"); + fprintf(xmlout, " 0x%02x\n", track->graphicsmode); + if(notes) { + fprintf(xmlout," \n"); + fprintf(xmlout," \n"); + fprintf(xmlout," \n"); + fprintf(xmlout," \n"); +/* fprintf(xmlout," \n"); This was evidently dropped upon amendment */ + fprintf(xmlout," \n"); + fprintf(xmlout," \n"); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " 0x%02x\n", track->opcolor[0]); + fprintf(xmlout, " 0x%02x\n",track->opcolor[1]); + fprintf(xmlout, " 0x%02x\n",track->opcolor[2]); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + break; + case 1: + fprintf(xmlout, " \n"); +#ifdef CURRENTSTRUCT + track->balance = track->balance << 8; +#endif + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout," \n"); + fprintf(xmlout," \n"); + fprintf(xmlout," \n"); + } + if(raw) + fprintf(xmlout," 0x%04x\n", track->balance); + if(derived) + fprintf(xmlout," %6.3f\n", (double)track->balance/(double)0x0100); + fprintf(xmlout, " \n"); +#ifdef CURRENTSTRUCT + if(notes) + fprintf(xmlout," \n"); + track->balance = track->balance >> 8; +#endif + fprintf(xmlout, " \n"); + break; + case 2: + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", track->maxPDUsize); + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " %d\n", track->avgPDUsize); + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " %d\n", track->maxbitrate); + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " %d\n", track->avgbitrate); + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " %d\n", track->slidingavgbitrate); + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " \n"); + break; + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n", track->num_url, track->num_urn); // table w. flags, URLs, URNs + // Data structure does not distinguish between single URL, single URN, or DREF table or URLs & URNs. + // We could infer those, but for now just present everything as a DREF table. + if(notes) + fprintf(xmlout, " \n"); + for(k = 0; k < track->num_url; k++) { + fprintf(xmlout, " \n"); // table w. flags, URLs, URNs + if(notes) + fprintf(xmlout," \n"); + for(i = 0; i < 4; i++) { + uint_to_chars(track->url[track->num_url].location[i], buf); + fprintf(xmlout, " %s\n"); + } + fprintf(xmlout, " \n"); // table w. flags, URLs, URNs + } + for(k = 0; k < track->num_urn; k++) { + fprintf(xmlout," \n"); // table w. flags, URLs, URNs + // Only the first 16 bytes are recorded in the data structure currently. + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " "); + for(i = 0; i < 4; i++) { + uint_to_chars(track->urn[track->num_urn].name[i], buf); + fprintf(xmlout,"%s", buf); + } + fprintf(xmlout, "\n"); + fprintf(xmlout, " "); + for(i = 0; i < 4; i++) { + uint_to_chars(track->urn[track->num_urn].location[i], buf); + fprintf(xmlout,"%s"); + } + fprintf(xmlout, "\n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + + xml_write_stbl(file, xmlout, track, tnum); /* SampleTable */ + + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); +} + +/* ------------- */ + +void xml_write_stbl(FILE* file, FILE* xmlout, mj2_tk_t *track, unsigned int tnum) +{ + char buf[5], buf33[33]; + int i, len; + buf[4] = '\0'; + + fprintf(xmlout, " \n"); + if(notes) + fprintf(xmlout, " \n"); + switch(track->track_type) + { + case 0: + // There could be multiple instances of this, but "entry_count" is just a local at read-time. + // And it's used wrong, too, as count of just visual type, when it's really all 3 types. + // This is referred to as "smj2" within mj2.c + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + /* No shifting required. If CURRENTSTRUCT gets changed, then may need to revisit treatment of these */ + fprintf(xmlout, " %d\n", track->w); + fprintf(xmlout, " %d\n", track->h); +// Horizresolution and vertresolution don't require shifting, already stored right in CURRENTSTRUCT + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " 0x%08x\n", track->horizresolution); + if(derived) + fprintf(xmlout, " %12.6f\n", (double)track->horizresolution/(double)0x00010000); /* Rate to play presentation (default = 0x00010000) */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " 0x%08x\n", track->vertresolution); + if(derived) + fprintf(xmlout, " %12.6f\n", (double)track->vertresolution/(double)0x00010000); /* Rate to play presentation (default = 0x00010000) */ + fprintf(xmlout, " \n"); + + buf33[0] = '\0'; + for(i = 0; i < 8; i++) { + uint_to_chars((unsigned int)track->compressorname[i], buf); + strcat(buf33, buf); /* This loads up (4 * 8) + 1 chars, but trailing ones are usually junk */ + } + len = (int)buf33[0]; /* First byte has string length in bytes. There may be garbage beyond it. */ + buf33[len+1] = '\0'; /* Suppress it */ + fprintf(xmlout, " %s\n", buf33+1); /* Start beyond first byte */ + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " 0x%02x\n",track->depth); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + + xml_out_frame_jp2h(xmlout, &(track->jp2_struct)); /* JP2 Header */ + + /* Following subboxes are optional */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", (unsigned int)track->fieldcount); /* uchar as 1 byte uint */ + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", (unsigned int)track->fieldorder); /* uchar as 1 byte uint */ + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); + + fprintf(xmlout, " \n",track->num_br); + for (i = 0; i < track->num_br; i++) /* read routine stored in reverse order, so let's undo damage */ + { + uint_to_chars(track->br[i], buf); + fprintf(xmlout, " %s\n", buf); /*4 characters, each CLi */ + } + fprintf(xmlout, " \n"); + + fprintf(xmlout, " \n",track->num_jp2x); + for (i = 0; i < track->num_jp2x; i++) + { // We'll probably need better formatting than this + fprintf(xmlout, " 0x%02x\n", track->jp2xdata[i]); /* Each entry is single byte */ + } + fprintf(xmlout, " \n"); + + fprintf(xmlout, " \n"); /* These values are all 1 byte */ + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", track->hsub); + fprintf(xmlout, " %d\n", track->vsub); + fprintf(xmlout, " %d\n", track->hoff); + fprintf(xmlout, " %d\n", track->voff); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); /* These values are all 1 byte */ + + fprintf(xmlout, " \n"); /* Part III Appx. 2 */ + fprintf(xmlout, " %u\n", (unsigned int)track->or_fieldcount); /* uchar as 1-byte uint */ + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " %u\n", (unsigned int)track->or_fieldorder); /* uchar as 1-byte uint */ + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + break; + case 1: case 2: + if(notes) + fprintf(xmlout, " \n"); break; + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", track->num_samples); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n", track->num_tts); + for (i = 0; i < track->num_tts; i++) { + fprintf(xmlout, " \n", + i+1, track->tts[i].sample_count, track->tts[i].sample_delta); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + + fprintf(xmlout, " \n", track->num_samplestochunk); + for (i = 0; i < track->num_samplestochunk; i++) { + fprintf(xmlout, " %u\n",track->sampletochunk[i].first_chunk); /* 4 bytes */ + fprintf(xmlout, " %u\n",track->sampletochunk[i].samples_per_chunk); /* 4 bytes */ + fprintf(xmlout, " %u\n",track->sampletochunk[i].sample_descr_idx); /* 4 bytes */ + } + fprintf(xmlout, " \n"); + // After reading this info in, track->num_chunks is calculated and a decompressed table established internally. + + fprintf(xmlout, " \n"); + if(track->same_sample_size) { + // all values in track->sample[i].sample_size are equal. Grab the first one. + fprintf(xmlout, " %u\n", track->sample[0].sample_size); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + } else { + fprintf(xmlout, " 0\n"); + if(notes) + if(sampletables) + fprintf(xmlout," \n"); + else + fprintf(xmlout," \n"); + fprintf(xmlout, " %u\n", track->num_samples); + if(sampletables) + for (i = 0; i < (int)track->num_samples; i++) { + fprintf(xmlout, " %u\n", i+1, track->sample[i].sample_size); + } + } + fprintf(xmlout, " \n"); + + fprintf(xmlout, " \n"); + // Structure not yet - Variant ChunkLargeOffset 'co64' + fprintf(xmlout, " %u\n", track->num_chunks); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + if(sampletables) + for (i = 0; i < (int)track->num_chunks; i++) + fprintf(xmlout, " %u\n", i+1, track->chunk[i].offset); + fprintf(xmlout, " \n"); + + fprintf(xmlout, " \n"); +} + +/* ------------- */ + +int xml_out_frame(FILE* file, FILE* xmlout, mj2_sample_t *sample, unsigned int snum) +{ + j2k_image_t img; + j2k_cp_t cp; + int i; + int numcomps; + unsigned char* frame_codestream; +/* char xmloutname[50]; */ + + frame_codestream = (unsigned char*) malloc (sample->sample_size-8); /* Skipping JP2C marker */ + if(frame_codestream == NULL) + return 1; + + fseek(file,sample->offset+8,SEEK_SET); + fread(frame_codestream,sample->sample_size-8,1, file); /* Assuming that jp and ftyp markers size do */ + /* Decode J2K to image: */ + if (!j2k_decode(frame_codestream, sample->sample_size-8, &img, &cp)) { + free(frame_codestream); + /* Do this? +#ifndef NO_PACKETS_DECODING + for (i=0; i\n", snum+1); + fprintf(xmlout, " \n"); + /* There can be multiple codestreams; a particular image is entirely within a single codestream */ + /* TO DO: A frame can be represented by two I-guess-contigious codestreams if its interleaved. */ + fprintf(xmlout, " \n"); + /* "cp" stands for "coding parameter"; "tcp" is tile coding parameters, "tccp" is tile-component coding parameters */ + xml_out_frame_siz(xmlout, &img, &cp); /* reqd in main */ + xml_out_frame_cod(xmlout, &j2k_default_tcp); /* reqd in main */ + xml_out_frame_coc(xmlout, &j2k_default_tcp, numcomps); /* opt in main, at most 1 per component */ + xml_out_frame_qcd(xmlout, &j2k_default_tcp); /* reqd in main */ + xml_out_frame_qcc(xmlout, &j2k_default_tcp, numcomps); /* opt in main, at most 1 per component */ + xml_out_frame_rgn(xmlout, &j2k_default_tcp, numcomps); /* opt, at most 1 per component */ + xml_out_frame_poc(xmlout, &j2k_default_tcp); /* opt (but reqd in main or tile for any progression order changes) */ + /* Next four get j2k_default_tcp passed globally: */ +#ifdef SUPPRESS_FOR_NOW + xml_out_frame_ppm(xmlout, &cp); /* opt (but either PPM or PPT [distributed in tile headers] or codestream packet header reqd) */ +#endif + xml_out_frame_tlm(xmlout); /* NO-OP. TLM NOT SAVED IN DATA STRUCTURE */ /* opt */ + xml_out_frame_plm(xmlout); /* NO-OP. PLM NOT SAVED IN DATA STRUCTURE */ /* opt in main; can be used in conjunction with PLT */ + xml_out_frame_crg(xmlout); /* NO-OP. CRG NOT SAVED IN DATA STRUCTURE */ /* opt in main; */ + xml_out_frame_com(xmlout, &j2k_default_tcp); /* NO-OP. COM NOT SAVED IN DATA STRUCTURE */ /* opt in main; */ + + fprintf(xmlout, " \n"); + + /* TO DO: all the tile headers (sigh) */ + fprintf(xmlout, " \n", cp.tileno_size); /* size of the vector tileno */ + for(i = 0; i < cp.tileno_size; i++) { /* I think cp.tileno_size will be same number as (cp.tw * cp.th) or as global j2k_curtileno */ + // Standard seems to use zero-based # for tile-part. + fprintf(xmlout, " \n", i, cp.tileno[i]); /* ID number of the tiles present in the codestream */ + fprintf(xmlout, " \n"); + /* All markers in tile-part headers (between SOT and SOD) are optional, unless structure requires. */ + if(i == 0) { + xml_out_frame_cod(xmlout, &(cp.tcps[i])); /* No more than 1 per tile */ + xml_out_frame_coc(xmlout, &(cp.tcps[i]), numcomps); /* No more than 1 per component */ + xml_out_frame_qcd(xmlout, &(cp.tcps[i])); /* No more than 1 per tile */ + xml_out_frame_qcc(xmlout, &(cp.tcps[i]), numcomps); /* No more than 1 per component */ + xml_out_frame_rgn(xmlout, &(cp.tcps[i]), numcomps); /* No more than 1 per component */ + } + xml_out_frame_poc(xmlout, &(cp.tcps[i])); /* Reqd only if any progression order changes different from main POC */ +#ifdef SUPPRESS_FOR_NOW + xml_out_frame_ppt(xmlout, &(cp.tcps[i])); /* Either PPT [distributed in tile headers] or PPM or codestream packet header reqd. */ +#endif + xml_out_frame_plt(xmlout, &(cp.tcps[i])); /* NO-OP. PLT NOT SAVED IN DATA STRUCTURE */ /* Can be used in conjunction with main's PLM */ + xml_out_frame_com(xmlout, &(cp.tcps[i])); /* NO-OP. COM NOT SAVED IN DATA STRUCTURE */ + /* j2k_tcp_t * cp.tcps; "tile coding parameters" */ + /* Maybe not: fprintf(xmlout, " <>%d, cp.matrice[i]; */ /* Fixed layer */ + fprintf(xmlout, " \n"); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); /* size of the vector tileno */ + +#ifdef NOTYET + IMAGINE the cp object has data to support the following... but we could use an new different data structure instead + /* I'm unclear if the span of the original fread(frame_codestream...) included the following items if they're trailing. */ + /* ALSO TO DO, BUT DATA STRUCTURE DOESN'T HANDLE YET: boxes (anywhere in file except before the Filetype box): */ + xml_out_frame_jp2i(xmlout, &cp); /* IntellectualProperty 'jp2i' (no restrictions on location) */ + xml_out_frame_xml(xmlout, &cp); /* XML 'xml\040' (0x786d6c20). Can appear multiply */ + xml_out_frame_uuid(xmlout, &cp); /* UUID 'uuid' (top level only) */ + xml_out_frame_uinf(xmlout, &cp); /* UUIDInfo 'uinf', includes UUIDList 'ulst' and URL 'url\40' */ +#endif + + fprintf(xmlout, " \n"); + + /* Extra commentary: */ + if(notes) { + fprintf(xmlout, " \n"); + if (((img.numcomps == 3) && (img.comps[0].dx == img.comps[1].dx / 2) + && (img.comps[0].dx == img.comps[2].dx / 2 ) && (img.comps[0].dx == 1)) + || (img.numcomps == 1)) { + fprintf(xmlout, " \n"); + } + else if ((img.numcomps == 3) && + (img.comps[0].dx == 1) && (img.comps[1].dx == 1)&& + (img.comps[2].dx == 1)) {// If YUV 4:4:4 input --> to bmp + fprintf(xmlout, " \n"); + } + else { + fprintf(xmlout, " \n"); + } + } + +#ifndef NO_PACKETS_DECODING + for (i=0; i= 0; i--) + { + buf[i] = (value & 0x001f) + 0x60; + value = (value >>5); + } + buf[3] = '\0'; +} + +/* ------------- */ + +void xml_out_frame_siz(FILE* xmlout, j2k_image_t *img, j2k_cp_t *cp) +{ + j2k_comp_t *comp; + int i; + + fprintf(xmlout, " \n"); + // This is similar to j2k.c's j2k_dump_image. + // Not of interest: Lsiz, Rsiz + fprintf(xmlout, " %d\n", img->x1); + fprintf(xmlout, " %d\n", img->y1); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", img->x0); + fprintf(xmlout, " %d\n", img->y0); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", cp->tdx); + fprintf(xmlout, " %d\n", cp->tdy); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", cp->tx0); + fprintf(xmlout, " %d\n", cp->ty0); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", img->numcomps); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + //fprintf(xmlout," \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + + for (i = 0; i < img->numcomps; i++) {/* image-components */ + comp = &(img->comps[i]); + fprintf(xmlout, " \n", i+1); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout," 0x%02x\n", (comp->sgnd << 7) & (comp->prec - 1)); + if(derived) { + fprintf(xmlout," %d\n", comp->sgnd); + fprintf(xmlout," %d\n", comp->prec); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", comp->dx); + fprintf(xmlout, " %d\n", comp->dy); + fprintf(xmlout, " %d\n", comp->w); + fprintf(xmlout, " %d\n", comp->h); + /* Rest of these aren't calculated when SIZ is read: + fprintf(xmlout, " %d\n", comp->x0); + fprintf(xmlout, " %d\n", comp->y0); + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " %d\n", comp->bpp); + fprintf(xmlout, " %d\n", comp->resno_decoded); */ + // SUPPRESS: n/a to mj2_to_metadata. fprintf(xmlout," %dfactor); + /* factor = number of division by 2 of the out image compare to the original size of image */ + // TO DO comp->data: int *data; /* image-component data */ + + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); +} + +/* ------------- */ + +void xml_out_frame_cod(FILE* xmlout, j2k_tcp_t *tcp) +{ +/* Could be called with tcp = &j2k_default_tcp; +/* Or, for tile-part header, with &j2k_cp->tcps[j2k_curtileno] +/* Alignment for main:" < < < < To help maintain xml pretty-printing */ +/* Alignment for tile:" < < < To help maintain xml pretty-printing */ + j2k_tccp_t *tccp; + int i; + char spaces[11] = " "; /* 10 spaces if tilepart*/ + char* s = spaces; + if(tcp == &j2k_default_tcp) { + s++;s++; /* shorten s to 8 spaces if main */ + } + tccp = &(tcp->tccps[0]); + + fprintf(xmlout, "%s\n",s); /* Required in main header */ + /* Not retained or of interest: Lcod */ + fprintf(xmlout, "%s 0x%02x\n", s, tcp->csty); /* 1 byte */ + if(notes) { + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + } + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s %d\n", s, tcp->prg); /* 1 byte, SGcod (A) */ + if(notes) { + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + } + fprintf(xmlout, "%s %d\n", s, tcp->numlayers); /* 2 bytes, SGcod (B) */ + fprintf(xmlout, "%s %d\n", s, tcp->mct); /* 1 byte, SGcod (C). More or less boolean */ + if(notes) + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */ + fprintf(xmlout, "%s \n",s); + /* Internal data structure tccp defines separate defaults for each component, but they all get the same values */ + /* So we only have to report the first component's values here. */ + /* Compare j2k_read_cox(...) */ + fprintf(xmlout, "%s %d\n", s, tccp->numresolutions - 1); /* 1 byte, SPcox (D) */ + fprintf(xmlout, "%s %d\n", s, tccp->cblkw - 2); /* 1 byte, SPcox (E) */ + fprintf(xmlout, "%s %d\n", s, tccp->cblkh - 2); /* 1 byte, SPcox (F) */ + if(notes) { + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n", s); + } + fprintf(xmlout, "%s 0x%02x\n", s, tccp->cblksty); /* 1 byte, SPcox (G) */ + if(notes) { + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s \n",s); + } + fprintf(xmlout, "%s %d\n", s, tccp->qmfbid); /* 1 byte, SPcox (H) */ + if(notes) + fprintf(xmlout, "%s \n",s); + if (tccp->csty & J2K_CP_CSTY_PRT) { + fprintf(xmlout, "%s \n",s); /* 1 byte, SPcox (I_i) */ + if(notes) + fprintf(xmlout, "%s \n",s); + for (i = 0; i < tccp->numresolutions; i++) { + fprintf(xmlout, "%s \n", s, i); + if(raw) + fprintf(xmlout,"%s 0x%02x\n", s, (tccp->prch[i] << 4) | tccp->prcw[i]); /* packed into 1 byte, SPcox (G) */ + if(derived) { + fprintf(xmlout,"%s %d\n", s, tccp->prcw[i]); + fprintf(xmlout,"%s %d\n", s, tccp->prch[i]); + } + fprintf(xmlout, "%s \n", s, i); + } + fprintf(xmlout, "%s \n",s); /* 1 byte, SPcox (I_i) */ + } + fprintf(xmlout, "%s \n",s); + fprintf(xmlout, "%s\n",s); +} + +/* ------------- */ + +void xml_out_frame_coc(FILE* xmlout, j2k_tcp_t *tcp, int numcomps) +{ +/* Uses global j2k_default_tcp */ + j2k_tccp_t *tccp, *firstcomp_tccp; + int i, compno; + + firstcomp_tccp = &(tcp->tccps[0]); + /* Internal data structure tccp defines separate defaults for each component, set from main */ + /* default, then selectively overwritten. */ + /* Compare j2k_read_cox(...) */ + /* We don't really know which was the default, and which were not */ + /* Let's pretend that [0] is the default and all others are not */ + if(notes) { + fprintf(xmlout, " \n"); + if(tcp == &j2k_default_tcp) + fprintf(xmlout, " \n"); + else + fprintf(xmlout, " \n"); + } + for (compno = 1; compno < numcomps; compno++) /* spec says components are zero-based */ + { + tccp = &tcp->tccps[compno]; + if(same_component_style(firstcomp_tccp, tccp)) + continue; + +/* Alignments: " < < < < < To help maintain xml pretty-printing */ + fprintf(xmlout, " \n"); /* Optional in main header, at most 1 per component */ + if(notes) + fprintf(xmlout, " \n"); + /* Overrides the main COD for the specific component */ + /* Not retained or of interest: Lcod */ + fprintf(xmlout, " 0x%02x\n", tccp->csty); /* 1 byte */ + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " %d\n", compno); /* 1 or 2 bytes */ + /* Unfortunately compo isn't retained in j2k_read_coc: compno = cio_read(j2k_img->numcomps <= 256 ? 1 : 2); /* Ccoc */ + /*if(j2k_img_numcomps <=256) + component is 1 byte + else + compno is 2 byte */ + + /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", tccp->numresolutions - 1); /* 1 byte, SPcox (D) */ + fprintf(xmlout, " %d\n", tccp->cblkw - 2); /* 1 byte, SPcox (E) */ + fprintf(xmlout, " %d\n", tccp->cblkh - 2); /* 1 byte, SPcox (F) */ + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " 0x%02x\n", tccp->cblksty); /* 1 byte, SPcox (G) */ + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " %d\n", tccp->qmfbid); /* 1 byte, SPcox (H) */ + if(notes) + fprintf(xmlout, " \n"); + if (tccp->csty & J2K_CP_CSTY_PRT) { + fprintf(xmlout, " \n"); /* 1 byte, SPcox (I_i) */ + if(notes) + fprintf(xmlout, " \n"); + for (i = 0; i < tccp->numresolutions-1; i++) { /* subtract 1 to get # of decomposition levels */ + fprintf(xmlout, " \n", i); + if(raw) + fprintf(xmlout," 0x%02x\n", (tccp->prch[i] << 4) | tccp->prcw[i]); /* packed into 1 byte, SPcox (G) */ + if(derived) { + fprintf(xmlout," %d\n", tccp->prcw[i]); + fprintf(xmlout," %d\n", tccp->prch[i]); + } + fprintf(xmlout, " \n", i); + } + fprintf(xmlout, " \n"); /* 1 byte, SPcox (I_i) */ + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } +} + +/* ------------- */ + +BOOL same_component_style(j2k_tccp_t *tccp1, j2k_tccp_t *tccp2) +{ + int i; + + if(tccp1->numresolutions != tccp2->numresolutions) + return FALSE; + if(tccp1->cblkw != tccp2->cblkw) + return FALSE; + if(tccp1->cblkh != tccp2->cblkh) + return FALSE; + if(tccp1->cblksty != tccp2->cblksty) + return FALSE; + if(tccp1->csty != tccp2->csty) + return FALSE; + + if (tccp1->csty & J2K_CP_CSTY_PRT) { + for (i = 0; i < tccp1->numresolutions; i++) { + if(tccp1->prcw[i] != tccp2->prcw[i] || tccp1->prch[i] != tccp2->prch[i]) + return FALSE; + } + } + return TRUE; +} + +/* ------------- */ + +void xml_out_frame_qcd(FILE* xmlout, j2k_tcp_t *tcp) +{ + /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */ + j2k_tccp_t *tccp; + int bandno, numbands; + + /* Compare j2k_read_qcx */ + fprintf(xmlout, " \n"); /* Required in main header, single occurrence */ + tccp = &(tcp->tccps[0]); + /* Not retained or of interest: Lqcd */ + fprintf(xmlout, " \n"); /* 1 byte */ + if(notes) + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " 0x%02x\n", (tccp->numgbits) << 5 | tccp->qntsty); + if(derived) + fprintf(xmlout, " %d\n", tccp->qntsty); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + if(derived) + fprintf(xmlout, " %d\n", tccp->numgbits); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + + /* Problem: numbands in some cases is calculated from len, which is not retained or available here at this time */ + /* So we'll just dump all internal values */ + /* We could calculate it, but I'm having trouble believing the length equations in the standard */ + + fprintf(xmlout, " \n"); + switch(tccp->qntsty) { + case J2K_CCP_QNTSTY_NOQNT: /* no quantization */ + /* This is what standard says, but I don't believe it: len = 4 + (3*decomp); */ + numbands = J2K_MAXBANDS; /* should be: numbands = len - 1; */ + /* Better: IMAGINE numbands = tccp->stepsize_numbands; */ + /* Instead look for first zero exponent, quit there. Adequate? */ + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + for (bandno = 0; bandno < numbands; bandno++) { + if(tccp->stepsizes[bandno].expn == 0) + break; /* Remove when we have real numbands */ + fprintf(xmlout, " \n", bandno); + if(raw) + fprintf(xmlout," 0x%02x\n", tccp->stepsizes[bandno].expn << 3); + if(derived) + fprintf(xmlout," %d\n", tccp->stepsizes[bandno].expn); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); + break; + case J2K_CCP_QNTSTY_SIQNT: /* scalar quantization derived */ + /* This is what standard says. Should I believe it:: len = 5; + /* numbands = 1; */ + fprintf(xmlout, " \n"); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + + for (bandno = 1; bandno < J2K_MAXBANDS; bandno++) { + if(tccp->stepsizes[bandno].expn == 0) + break; + + fprintf(xmlout, " %d\n", bandno, tccp->stepsizes[bandno].expn); + } + + fprintf(xmlout, " \n"); + break; + + default: /* J2K_CCP_QNTSTY_SEQNT */ /* scalar quantization expounded */ + /* This is what standard says, but should I believe it: len = 5 + 6*decomp; */ + numbands = J2K_MAXBANDS; /* should be: (len - 1) / 2;*/ + /* Better: IMAGINE numbands = tccp->stepsize_numbands; */ + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + for (bandno = 0; bandno < numbands; bandno++) { + if(tccp->stepsizes[bandno].expn == 0 && tccp->stepsizes[bandno].mant == 0) + break; /* Remove when we have real numbands */ + + fprintf(xmlout, " \n", bandno); + if(raw) + fprintf(xmlout," 0x%02x\n", (tccp->stepsizes[bandno].expn << 11) | tccp->stepsizes[bandno].mant); + if(derived) { + fprintf(xmlout," %d\n", tccp->stepsizes[bandno].expn); + fprintf(xmlout," %d\n", tccp->stepsizes[bandno].mant); + } + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); + break; + } /* switch */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + +/* Alignments: " < < < < < To help maintain xml pretty-printing */ +} + +/* ------------- */ + +void xml_out_frame_qcc(FILE* xmlout, j2k_tcp_t *tcp, int numcomps) +{ +/* Uses global j2k_default_tcp */ + /* This code will compile only if declaration of j2k_default_tcp is changed from static (to implicit extern) in j2k.c */ + j2k_tccp_t *tccp, *firstcomp_tccp; + int bandno, numbands; + int compno; + + firstcomp_tccp = &(tcp->tccps[0]); + /* Internal data structure tccp defines separate defaults for each component, set from main */ + /* default, then selectively overwritten. */ + /* Compare j2k_read_qcx(...) */ + /* We don't really know which was the default, and which were not */ + /* Let's pretend that [0] is the default and all others are not */ + if(notes) { + fprintf(xmlout, " \n"); + if(tcp == &j2k_default_tcp) + fprintf(xmlout, " \n"); + else + fprintf(xmlout, " \n"); + } + for (compno = 1; compno < numcomps; compno++) /* spec says components are zero-based */ + { + tccp = &(tcp->tccps[compno]); + if(same_component_quantization(firstcomp_tccp, tccp)) + continue; + + /* Compare j2k_read_qcx */ + fprintf(xmlout, " \n", compno); /* Required in main header, single occurrence */ + tccp = &j2k_default_tcp.tccps[0]; + /* Not retained or perhaps of interest: Lqcd It maybe can be calculated. */ + fprintf(xmlout, " \n"); /* 1 byte */ + if(notes) + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout, " 0x%02x\n", (tccp->numgbits) << 5 | tccp->qntsty); + if(derived) + fprintf(xmlout, " %d\n", tccp->qntsty); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + if(derived) + fprintf(xmlout, " %d\n", tccp->numgbits); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + + /* Problem: numbands in some cases is calculated from len, which is not retained or available here at this time */ + /* So we'll just dump all internal values */ + fprintf(xmlout, " \n"); + switch(tccp->qntsty) { + case J2K_CCP_QNTSTY_NOQNT: + numbands = J2K_MAXBANDS; /* should be: numbands = len - 1; */ + /* Better: IMAGINE numbands = tccp->stepsize_numbands; */ + + /* Instead look for first zero exponent, quit there. Adequate? */ + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + for (bandno = 0; bandno < numbands; bandno++) { + if(tccp->stepsizes[bandno].expn == 0) + break; /* Remove this once we have real numbands */ + fprintf(xmlout, " \n", bandno); + if(raw) + fprintf(xmlout," 0x%02x\n", tccp->stepsizes[bandno].expn << 3); + if(derived) + fprintf(xmlout," %d\n", tccp->stepsizes[bandno].expn); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); + break; + case J2K_CCP_QNTSTY_SIQNT: + /* numbands = 1; */ + fprintf(xmlout, " \n"); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + + for (bandno = 1; bandno < J2K_MAXBANDS; bandno++) { + if(tccp->stepsizes[bandno].expn == 0) + break; + + fprintf(xmlout, " %d\n", bandno, tccp->stepsizes[bandno].expn); + } + fprintf(xmlout, " \n"); + break; + + default: /* J2K_CCP_QNTSTY_SEQNT */ + numbands = J2K_MAXBANDS; /* should be: (len - 1) / 2;*/ + /* Better: IMAGINE numbands = tccp->stepsize_numbands; */ + fprintf(xmlout, " \n"); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + for (bandno = 0; bandno < numbands; bandno++) { + if(tccp->stepsizes[bandno].expn == 0 && tccp->stepsizes[bandno].mant == 0) + break; /* Remove this once we have real numbands count */ + fprintf(xmlout, " \n", bandno); + if(raw) + fprintf(xmlout," 0x%02x\n", (tccp->stepsizes[bandno].expn << 11) | tccp->stepsizes[bandno].mant); + if(derived) { + fprintf(xmlout," %d\n", tccp->stepsizes[bandno].expn); + fprintf(xmlout," %d\n", tccp->stepsizes[bandno].mant); + } + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " \n"); + break; + } /* switch */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } +/* Alignments: " < < < < < To help maintain xml pretty-printing */ +} + +/* ------------- */ + +BOOL same_component_quantization(j2k_tccp_t *tccp1, j2k_tccp_t *tccp2) +{ + int bandno, numbands; + + if(tccp1->qntsty != tccp2->qntsty) + return FALSE; + if(tccp1->numgbits != tccp2->numgbits) + return FALSE; + + switch(tccp1->qntsty) { + case J2K_CCP_QNTSTY_NOQNT: + numbands = J2K_MAXBANDS; /* should be: numbands = len - 1; */ + /* Instead look for first zero exponent, quit there. Adequate? */ + for (bandno = 0; bandno < numbands; bandno++) { + if(tccp1->stepsizes[bandno].expn == 0) + break; + if(tccp1->stepsizes[bandno].expn != tccp2->stepsizes[bandno].expn) + return FALSE; + } + break; + case J2K_CCP_QNTSTY_SIQNT: + /* numbands = 1; */ + if(tccp1->stepsizes[0].expn != tccp2->stepsizes[0].expn || tccp1->stepsizes[0].mant != tccp2->stepsizes[0].mant) + return FALSE; + /* Don't need to check remainder, since they are calculated from [0] */ + break; + + default: /* J2K_CCP_QNTSTY_SEQNT */ + numbands = J2K_MAXBANDS; /* should be: (len - 1) / 2;*/ + /* This comparison may cause us problems with trailing junk values. */ + for (bandno = 0; bandno < numbands; bandno++) { + if(tccp1->stepsizes[bandno].expn != tccp2->stepsizes[bandno].expn || tccp1->stepsizes[bandno].mant != tccp2->stepsizes[bandno].mant); + return FALSE; + } + break; + } /* switch */ + return TRUE; +} + +/* ------------- */ + +void xml_out_frame_rgn(FILE* xmlout, j2k_tcp_t *tcp, int numcomps) +{ + int compno, SPrgn; + /* Don't know if MJ2 files can have regions of interest. Assume yes. */ + for(compno = 0; compno < numcomps; compno++) { + SPrgn = tcp->tccps[compno].roishift; /* 1 byte; SPrgn */ + if(SPrgn == 0) + continue; /* Yet another kludge */ + + fprintf(xmlout, " \n"); /* Optional in main header, at most 1 per component */ + if(notes) + fprintf(xmlout, " \n"); + /* Not retained or of interest: Lrgd */ + fprintf(xmlout, " 0\n"); /* 1 byte */ + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", compno); /* 1 or 2 bytes */ + fprintf(xmlout, " %d\n", SPrgn); /* 1 byte */ + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " POC != 1) + return; /* Not present */ + + fprintf(xmlout, " \n"); /* Optional in main header, at most 1 per component */ + /* j2k_read_poc seems to allow accumulation of default pocs from multiple POC segments, but does + the spec really allow that? */ + /* 2 bytes, not retained; Lpoc */ + /* I probably didn't get this dump precisely right. */ + for (i = 0; i < tcp->numpocs; i++) { + poc = &tcp->pocs[i]; + fprintf(xmlout, " \n", i+1); + fprintf(xmlout, " %d\n", poc->resno0); /* 1 byte, RSpoc_i */ + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " %d\n", poc->compno0);/* j2k_img->numcomps <= 256 ? 1 byte : 2 bytes; CSpoc_i */ + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " %d\n", poc->layno1); /* int_min(cio_read(2), tcp->numlayers); /* 2 bytes; LYEpoc_i */ + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " %d\n", poc->resno1); /*int_min(cio_read(1), tccp->numresolutions); /* REpoc_i */ + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " %d\n", poc->compno1); /* int_min(cio_read(j2k_img->numcomps <= 256 ? 1 : 2), j2k_img->numcomps); /* CEpoc_i */ + if(notes) + fprintf(xmlout," \n"); + fprintf(xmlout, " %d\n", poc->prg); /* 1 byte Ppoc_i */ + if(notes) { + fprintf(xmlout," \n"); + fprintf(xmlout," \n"); + fprintf(xmlout," \n"); + } + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " ppm != 1) + return; /* Not present */ + + fprintf(xmlout, " \n"); /* Optional in main header, but if not, must be in PPT or codestream */ + /* 2 bytes Lppm not saved */ + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + + /* 1 byte, not retained ; Zppm is sequence # of this PPM header */ + /* 4 bytes, possibly overwritten multiple times in j2k_cp->ppm_previous: Nppm */ + /* Use j symbol for index instead of i, to make comparable with j2k_read_ppm */ + /* Not real clear whether to use ppm->store or ppm_len as upper bound */ + fprintf(xmlout, " \n"); + xml_out_dump_hex(xmlout, cp->ppm_data, cp->ppm_len); + /* Dump packet headers 1 byte at a time: lppm[i][j] */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); /* Optional in main header, but if not, must be in PPT or codestream */ +} + +/* ------------- */ + +void xml_out_frame_ppt(FILE *xmlout, j2k_tcp_t *tcp) { /* opt in tilepart header */ +/* Compare j2k_read_ppt() */ + int j; + + if(tcp->ppt != 1) + return; /* Not present */ + + fprintf(xmlout, " \n"); /* Optional in main header, but if not, must be in PPT or codestream */ + /* 2 bytes Lppm not saved */ + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + + /* 1 byte, not retained ; Zppt is sequence # of this PPT header */ + /* 4 bytes, possibly overwritten multiple times in j2k_cp->ppt_previous: Nppt */ + /* Use j symbol for index instead of i, to make comparable with j2k_read_ppt */ + /* Not real clear whether to use ppt->store or ppt_len as upper bound */ + fprintf(xmlout, " \n"); + xml_out_dump_hex(xmlout, tcp->ppt_data, tcp->ppt_len); + /* Dump packet headers 1 byte at a time: lppt[i][j] */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); /* Optional in tile-part header, but if not, must be in PPM or codestream */ +} +#endif SUPPRESS_FOR_NOW + +/* ------------- */ + +void xml_out_frame_tlm(FILE* xmlout) { /* opt, main header only. May be multiple. */ +/* Compare j2k_read_tlm()... which doesn't retain anything! */ +/* Plan: Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */ +} + +/* ------------- */ + +void xml_out_frame_plm(FILE* xmlout) { /* opt in main; can be used in conjunction with PLT */ +/* NO-OP. PLM NOT SAVED IN DATA STRUCTURE */ + /* Compare j2k_read_plm()... which doesn't retain anything! */ +/* Plan: Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */ +} + +/* ------------- */ + +void xml_out_frame_plt(FILE* xmlout, j2k_tcp_t *tcp) { /* opt in main; can be used in conjunction with PLT */ +/* NO-OP. PLT NOT SAVED IN DATA STRUCTURE */ + /* Compare j2k_read_plt()... which doesn't retain anything! */ +} + +/* ------------- */ + +void xml_out_frame_crg(FILE* xmlout) { /* NO-OP. CRG NOT SAVED IN DATA STRUCTURE */ /* opt in main; */ +/* Compare j2k_read_crg()... which doesn't retain anything! */ +/* Plan: Since this is only called from main header, not tilepart, use global j2k_default_tcp rather than parameter */ +#ifdef NOTYET + THIS PSEUDOCODE IMAGINES THESE EXIST: j2k_default_tcp->crg, j2k_default_tcp->crg_i, j2k_default_tcp->crg_xcrg*, j2k_default_tcp->crg_ycrg* + (POSSIBLY DON'T NEED crg_i, CAN GET NUMBER OR COMPONENTS FROM ELSEWHERE) + if(j2k_default_tcp->crg != 1 || j2k_default_tcp->crg_i == 0) + return; /* Not present */ + + fprintf(xmlout, " \n", j2k_default_tcp->crg_i); + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + /* This isn't the most compact form of table, but is OK when number of components is small, as is likely. */ + for (i = 0; i < j2k_default_tcp->crg_i; i++) { + fprintf(xmlout, " \n", i+1); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout," %d\n", j2k_default_tcp->crg_xcrg[i]); + if(derived) { + /* Calculate n * 100%/65536; 4 digits after decimal point is sufficiently accurate */ + fprintf(xmlout," %.4f\n", ((double)j2k_default_tcp->crg_xcrg[i])/655.36); + /* We could do another calculation that include XRsiz[i]; maybe later. */ + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + if(raw) + fprintf(xmlout," %d\n", j2k_default_tcp->crg_ycrg[i]); + if(derived) { + fprintf(xmlout," %f\n", ((double)j2k_default_tcp->crg_ycrg[i])/655.36); + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + + fprintf(xmlout, " \n"); + +#endif +} + +/* ------------- */ + +/* Regrettably from a metadata point of view, j2k_read_com() skips over any comments in main header or tile-part-header */ +void xml_out_frame_com(FILE* xmlout, j2k_tcp_t *tcp) { /* NO-OP. COM NOT SAVED IN DATA STRUCTURE */ /* opt in main; */ +/* Compare j2k_read_com()... which doesn't retain anything! */ +#ifdef NOTYET + THIS PSEUDOCODE IMAGINES THESE EXIST: tcp->com, tcp->com_len, tcp->com_data array + if(tcp->com != 1) + return; /* Not present */ + + fprintf(xmlout, " \n"); /* Optional in main or tile-part header */ + xml_out_dump_hex_and_ascii(tcp->com_data, tcp->com_len); + fprintf(xmlout, " \n"); +#endif +} + +void xml_out_dump_hex(FILE* xmlout, char *data, int data_len) { + int i; + + /* This is called when raw is true, or there is no appropriate derived form */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " "); /* Inadequate for pretty printing */ + for (i = 0; i < data_len; i++) { /* Dump packet headers */ + fprintf(xmlout, "%02x", data[i]); + } + fprintf(xmlout, " \n"); +} + +/* Define this as an even number: */ +#define BYTES_PER_DUMP_LINE 40 +/* Current total width for Hex and ASCII is : 11 spaces lead + (3 * BPDL) + 2 spaces + BPDL */ +void xml_out_dump_hex_and_ascii(FILE* xmlout, char *data, int data_len) { + int i,j; + + if(raw) + xml_out_dump_hex(xmlout, data, data_len); + + if(derived) { + fprintf(xmlout, " \n"); + for (i = 0; i < data_len; ) { + fprintf(xmlout," "); /* Additional leading space added in loop */ + /* First column: hex */ + for (j = 0; j < BYTES_PER_DUMP_LINE; j++) /* Dump bytes */ + fprintf(xmlout," %02x", data[i+j]); + /* Space between columns... */ fprintf(xmlout, " "); + /* Second column: ASCII */ + for (j = 0; j < BYTES_PER_DUMP_LINE; j++, i++) { + if(isprint((int)data[i]) && i < data_len) + fprintf(xmlout,"%c", data[i]); + else + fprintf(xmlout," "); + } + /* If we also wanted to output UCS-2 Unicode as a third column, then entire document + must use fwprintf. Forget about it for now. As it stands, if data is UCS-2 format but still + the ASCII set, then we'll be able to read every other byte as ASCII in column 2. If + data is UTF-8 format but still ASCII, then we'll be able to read every byte as ASCII + in column 2. */ + } + fprintf(xmlout, " \n"); + } +} + + +/* ------------- */ + +void xml_out_frame_jp2h(FILE* xmlout, jp2_struct_t *jp2_struct) { /* JP2 Header */ +/* Compare jp2_read_jp2h(jp2_struct_t * jp2_struct) */ + int i; + + fprintf(xmlout, " \n"); + +/* Compare jp2_read_ihdr(jp2_struct)) */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", jp2_struct->h); /* 4 bytes */ + fprintf(xmlout, " %d\n", jp2_struct->w); /* 4 bytes */ + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", jp2_struct->numcomps); /* 2 bytes */ + if(notes) + fprintf(xmlout, " \n"); /* 2 bytes */ + fprintf(xmlout, " \n"); /* 1 byte */ + if(jp2_struct->bpc == 255) { + fprintf(xmlout, " 0x%02x\n", jp2_struct->bpc); /* 1 byte */ + if(notes) + fprintf(xmlout, " \n"); + } else { /* Not 0xff */ + if(raw) { + fprintf(xmlout, " 0x%02x\n", jp2_struct->bpc); /* 1 byte */ + if(notes) + fprintf(xmlout," \n"); + } + if(derived) { + fprintf(xmlout, " %d\n", jp2_struct->bpc & 0x7f); + fprintf(xmlout, " %d\n", jp2_struct->bpc >> 7); + } + } + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", jp2_struct->C); /* 1 byte */ + if(notes) + fprintf(xmlout, " \n"); /* 2 bytes */ + fprintf(xmlout, " %d\n", jp2_struct->UnkC); /* 1 byte */ + if(notes) + fprintf(xmlout, " \n"); /* 1 byte */ + fprintf(xmlout, " %d\n", jp2_struct->IPR); /* 1 byte */ + if(notes) + fprintf(xmlout, " \n"); /* 2 bytes */ + fprintf(xmlout, " \n"); + + if (jp2_struct->bpc == 255) + { + fprintf(xmlout, " \n"); + if(notes) + fprintf(xmlout, " \n"); + /* Bits per pixel varies with components */ + /* Compare jp2_read_bpcc(jp2_struct) */ + for (i = 0; i < (int)jp2_struct->numcomps; i++) { + if(raw) + fprintf(xmlout," 0x%02x\n", jp2_struct->comps[i].bpcc); /* 1 byte */ + if(derived) { + fprintf(xmlout," %d\n", (jp2_struct->comps[i].bpcc & 0x7f)+1); + fprintf(xmlout," %d\n", jp2_struct->comps[i].bpcc >> 7); + } + } + fprintf(xmlout, " \n"); + } + + /* Compare jp2_read_colr(jp2_struct) */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", jp2_struct->meth); /* 1 byte */ + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + fprintf(xmlout, " %d\n", jp2_struct->precedence); /* 1 byte */ + if(notes) + fprintf(xmlout, " \n"); + fprintf(xmlout, " %d\n", jp2_struct->approx); /* 1 byte */ + if(notes) + fprintf(xmlout, " \n"); + + if (jp2_struct->meth == 1) { + fprintf(xmlout, " %d\n", jp2_struct->enumcs); /* 4 bytes */ + if(notes) { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } + } + else + if(notes) + fprintf(xmlout, " \n"); + /* only 1 byte is read and nothing stored */ + fprintf(xmlout, " \n"); + + /* TO DO? No OpenJPEG support. + Palette 'pclr' + ComponentMapping 'cmap' + ChannelDefinition 'cdef' + Resolution 'res' + */ + fprintf(xmlout, " \n"); +} +/* ------------- */ + +#ifdef NOTYET +IMAGE these use cp structure, extended... but we could use a new data structure instead +void xml_out_frame_jp2i(FILE* xmlout, j2k_cp_t *cp) { + /* IntellectualProperty 'jp2i' (no restrictions on location) */ + int i; + IMAGE cp->jp2i, cp->jp2i_count, cp->jp2i_data (array of chars), cp->cp2i_len (array of ints) + if(cp->jp2i != 1) + return; /* Not present */ + + for(i = 0; i < cp->jp2i_count; i++) + { + fprintf(xmlout, " \n"); + /* I think this can be anything, including binary, so do a dump */ + /* Is it better to indent or not indent this content? Indent is better for reading, but + worse for cut/paste. */ + xml_out_dump_hex_and_ascii(xmlout, cp->jp2i_data[i], cp->jp2i_len[i]); + fprintf(xmlout, " \n"); + } +} + +void xml_out_frame_xml(FILE* xmlout, j2k_cp_t *cp) { + /* XML 'xml\040' (0x786d6c20). Can appear multiply, before or after jp2c codestreams */ + IMAGE cp->xml, cp->xml_count, cp->xml_data (array of chars) + MAYBE WE DON'T NEED cp->xml_len (array of ints) IF WE ASSUME xml_data IS NULL-TERMINATED. + ASSUME ASSUME EACH LINE IS ENDED BY \n. + int i; + if(cp->xml != 1) + return; /* Not present */ + + for(i = 0; i < cp->xml_count; i++) + { + fprintf(xmlout, " \n", i+1); + /* Is it better to indent or not indent this content? Indent is better for reading, but + worse for cut/paste. Being lazy, didn't indent here. */ + fprintf(xmlout,cp->xml_data[i]); /* May be multiple lines */ /* Could check if this is well-formed */ + fprintf(xmlout, " \n"); + } +} + +void xml_out_frame_uuid(FILE* xmlout, j2k_cp_t *cp) { + /* UUID 'uuid' (top level only) */ + /* Part I 1.7.2 says: may appear multiply in JP2 file, anywhere except before File Type box */ + /* Part III 5.2.1 says: Private extensions shall be achieved through the 'uuid' type. */ + /* A UUID is a 16-byte value. There is a conventional string representation for it: + "0x12345678-9ABC-DEF0-1234-567890ABCDEF". Let's assume that is what is stored in uuid_value */ + + /* Part III 6.1 Any other MJ2 box type could be alternatively written as a 'uuid' box, with value given + as : 0xXXXXXXXX-0011-0010-8000-00AA00389B71, where the Xs are the boxtype in hex. However, + such a file is "not compliant; systems may choose to read [such] objects ... as equivalent to the box of + the same type, or not." Here, we choose not to. */ + int i; + IMAGE cp->uuid, cp->uuid_count, cp->uuid_value (array of uuids... let's say fixed-length strings) cp->uuid_data (array of char buffers), cp->uuid_len (array of ints) + if(cp->juuid != 1) + return; /* Not present */ + + for(i = 0; i < cp->uuid_count; i++) + { + fprintf(xmlout, " + fprintf(xmlout, " %s\n", cp->uuid_value[i]); + fprintf(xmlout, " \n"); + /* I think this can be anything, including binary, so do a dump */ + /* Is it better to indent or not indent this content? Indent is better for reading, but + worse for cut/paste. */ + xml_out_dump_hex_and_ascii(xmlout, cp->uuid_data[i], cp->uuid_len[i]); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } +} + +void xml_out_frame_uinf(FILE* xmlout, j2k_cp_t *cp) { + /* UUIDInfo 'uinf', includes UUIDList 'ulst' and URL 'url\40' */ + /* Part I 1.7.3 says: may appear multiply in JP2 file, anywhere at the top level except before File Type box */ + /* So there may be multiple ulst's, and each can have multiple UUIDs listed (with a single URL) */ + /* This is not quite as vendor-specific as UUIDs, or at least is meant to be generally readable */ + /* Assume UUIDs stored in canonical string format */ + int i, j; + IMAGE cp->uinf, cp->uinf_count, cp->uinf_ulst_nu (array of ints) + cp->uinf_uuid (2 dimensional array of uuids... let's say fixed-length strings), + cp->uinf_url (array of char buffers) + + if(cp->uinf != 1) + return; /* Not present */ + + for(i = 0; i < cp->uuid_count; i++) + { + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n",cp->cp->uinf_ulst_nu[i]); + for(j = 0; j < cp->uinf_ulst_nu[i]; j++) + fprintf(xmlout, " %s\n", cp->uuif_uuid[i][j], j+1); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + /* Could add VERS and FLAG here */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " %s",cp->uinf_url[i]); /* Probably single line, so indent works */ /* In theory, could check if this is well-formed, or good live link */ + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + fprintf(xmlout, " \n"); + } +} + +IMAGE these use cp structure, extended... but we could use a new data structure instead +void xml_out_frame_unknown_type(FILE* xmlout, j2k_cp_t *cp) { + /* Part III 5.2.1 says "Type fields not defined here are reserved. Private extensions + shall be acieved through the 'uuid' type." [This implies an unknown + type would be an error, but then...] "Boxes not explicitly defined in this standard, + or otherwise unrecognized by a reader, may be ignored." + Also, it says "the following types are not and will not be used, or used only in + their existing sense, in future versions of this specification, to avoid conflict + with existing content using earlier pre-standard versions of this format: + clip, crgn, matt, kmat, pnot, ctab, load, imap; + track reference types tmcd, chap, sync,scpt, ssrc" + [But good luck figuring out the mapping.] + Part III Amend. 2 4.1 is stronger: "All these specifications [of this family, e.g., + JP2 Part I, ISO Base format (Part 12) leading to MP4, Quicktime, and possibly including + MJ2] require that readers ignore objects that are unrecognizable to them". + */ + int i; + IMAGE cp->unknown_type, cp->unknown_type_count, cp->unknown_type_boxtype (array of buf[5]s), cp->unknown_type_data (array of chars), cp->unknown_type_len (array of ints) + if(cp->unknown_type != 1) + return; /* Not present */ + + for(i = 0; i < cp->unknown_type_count; i++) + { + fprintf(xmlout, " \n", cp->unknown_type_boxtype[i]); + /* Can be anything, including binary, so do a dump */ + /* Is it better to indent or not indent this content? Indent is better for reading, but + worse for cut/paste. */ + xml_out_dump_hex_and_ascii(xmlout, cp->unknown_type_data[i], cp->unknown_type_len[i]); + fprintf(xmlout, " \n"); + } +} + +#endif \ No newline at end of file diff --git a/mj2/meta_out.h b/mj2/meta_out.h new file mode 100644 index 00000000..bfe9d190 --- /dev/null +++ b/mj2/meta_out.h @@ -0,0 +1,13 @@ +/* meta_out.h */ +/* Dump MJ2, JP2 metadata (partial so far) to xml file */ +/* Callable from mj2_to_metadata */ +/* Contributed to Open JPEG by Glenn Pearson, U.S. National Library of Medicine */ + +#define BOOL int +#define FALSE 0 +#define TRUE 1 + +void xml_write_init(BOOL n, BOOL t, BOOL r, BOOL d); + +int xml_write_struct(FILE *file, FILE *xmlout, mj2_movie_t * movie, unsigned int sampleframe, char* stringDTD); + diff --git a/mj2/mj2_to_metadata.c b/mj2/mj2_to_metadata.c new file mode 100644 index 00000000..48304167 --- /dev/null +++ b/mj2/mj2_to_metadata.c @@ -0,0 +1,282 @@ +/* mj2_to_metadata.c */ +/* Dump MJ2, JP2 metadata (partial so far) to xml file */ +/* Contributed to Open JPEG by Glenn Pearson, contract software developer, U.S. National Library of Medicine. + +The base code in this file was developed by the author as part of a video archiving +project for the U.S. National Library of Medicine, Bethesda, MD. +It is the policy of NLM (and U.S. government) to not assert copyright. + +A non-exclusive copy of this code has been contributed to the Open JPEG project. +Except for copyright, inclusion of the code within Open JPEG for distribution and use +can be bound by the Open JPEG open-source license and disclaimer, expressed elsewhere. +*/ +#include +#include +#include + +#include "mj2.h" +#include + +//MEMORY LEAK +#ifdef _DEBUG +#define _CRTDBG_MAP_ALLOC +#include // Must be included first +#include +#endif +//MEM + +#include "mj2_to_metadata.h" +#include +#ifndef DONT_HAVE_GETOPT +#include +#else +#include "compat/getopt.h" +#endif + +/* ------------- */ + +void help_display() +{ + /* "1234567890123456789012345678901234567890123456789012345678901234567890123456789" */ + fprintf(stdout," Help for the 'mj2_to_metadata' Program\n"); + fprintf(stdout," ======================================\n"); + fprintf(stdout,"The -h option displays this information on screen.\n\n"); + + fprintf(stdout,"mj2_to_metadata generates an XML file from a Motion JPEG 2000 file.\n"); + fprintf(stdout,"The generated XML shows the structural, but not (yet) curatorial,\n"); + fprintf(stdout,"metadata from the movie header and from the JPEG 2000 image and tile\n"); + fprintf(stdout,"headers of a sample frame. Excluded: low-level packed-bits image data.\n\n"); + + fprintf(stdout,"By Default\n"); + fprintf(stdout,"----------\n"); + fprintf(stdout,"The metadata includes the jp2 image and tile headers of the first frame.\n"); + fprintf(stdout,"\n"); + fprintf(stdout,"Metadata values are shown in 'raw' form (e.g., hexidecimal) as stored in the\n"); + fprintf(stdout,"file, and, if apt, in a 'derived' form that is more quickly grasped.\n"); + fprintf(stdout,"\n"); + fprintf(stdout,"Notes explaining the XML are embedded as terse comments. These include\n"); + fprintf(stdout," meaning of non-obvious tag abbreviations;\n"); + fprintf(stdout," range and precision of valid values;\n"); + fprintf(stdout," interpretations of values, such as enumerations; and\n"); + fprintf(stdout," current implementation limitations.\n"); + fprintf(stdout,"\n"); + fprintf(stdout,"The sample-size and chunk-offset tables, each with 1 row per frame, are not reported.\n"); + fprintf(stdout,"\n"); + fprintf(stdout,"The file is self-contained and no verification (e.g., against a DTD) is requested.\n"); + fprintf(stdout,"\n"); + fprintf(stdout,"Required Parameters (except with -h)\n"); + fprintf(stdout,"------------------------------------\n"); + fprintf(stdout,"[Caution: file strings that contain spaces should be wrapped with quotes.]\n"); + fprintf(stdout,"-i input.mj2 : where 'input' is any source file name or path.\n"); + fprintf(stdout," MJ2 files created with 'frames_to_mj2' are supported so far.\n"); + fprintf(stdout," These are silent, single-track, 'MJ2 Simple Profile' videos.\n"); + fprintf(stdout,"-o output.xml : where 'output' is any destination file name or path.\n"); + fprintf(stdout,"\n"); + fprintf(stdout,"Optional Parameters\n"); + fprintf(stdout,"-------------------\n"); + fprintf(stdout,"-h : Display this help information.\n"); + fprintf(stdout,"-n : Suppress all mj2_to_metadata notes.\n"); + fprintf(stdout,"-t : Include sample-size and chunk-offset tables.\n"); + fprintf(stdout,"-f n : where n > 0. Include jp2 header info for frame n [default=1].\n"); + fprintf(stdout,"-f 0 : No jp2 header info.\n"); + fprintf(stdout,"-r : Suppress all 'raw' data for which a 'derived' form exists.\n"); + fprintf(stdout,"-d : Suppress all 'derived' data.\n"); + fprintf(stdout," (If both -r and -d given, -r will be ignored.)\n"); + fprintf(stdout,"-v string : Verify against the DTD file located by the string.\n"); + fprintf(stdout," Prepend quoted 'string' with either SYSTEM or PUBLIC keyword.\n"); + fprintf(stdout," Thus, for the distributed DTD placed in the same directory as\n"); + fprintf(stdout," the output file: -v \"SYSTEM mj2_to_metadata.dtd\"\n"); + fprintf(stdout," \"PUBLIC\" is used with an access protocol (e.g., http:) + URL.\n"); + /* More to come */ + fprintf(stdout,"\n"); + /* "1234567890123456789012345678901234567890123456789012345678901234567890123456789" */ +} + +/* ------------- */ + +int main(int argc, char *argv[]) { + + FILE *file, *xmlout; +/* char xmloutname[50]; */ + mj2_movie_t movie; + + char* infile = 0; + char* outfile = 0; + char* s, S1, S2, S3; + int len; + unsigned int sampleframe = 1; /* First frame */ + char* stringDTD = NULL; + BOOL notes = TRUE; + BOOL sampletables = FALSE; + BOOL raw = TRUE; + BOOL derived = TRUE; + +#ifndef NO_PACKETS_DECODING + fprintf(stdout,"NO_PACKETS_DECODING should be defined in preprocessing. Exiting...\n"); + return 1; +#endif + + while (TRUE) { + /* ':' after letter means it takes an argument */ + int c = getopt(argc, argv, "i:o:f:v:hntrd"); + /* FUTURE: Reserve 'p' for pruning file (which will probably make -t redundant) */ + if (c == -1) + break; + switch (c) { + case 'i': /* IN file */ + infile = optarg; + s = optarg; + while (*s) { s++; } /* Run to filename end */ + s--; + S3 = *s; + s--; + S2 = *s; + s--; + S1 = *s; + + if ((S1 == 'm' && S2 == 'j' && S3 == '2') + || (S1 == 'M' && S2 == 'J' && S3 == '2')) { + break; + } + fprintf(stderr, "Input file name must have .mj2 extension, not .%c%c%c.\n", S1, S2, S3); + return 1; + + /* ----------------------------------------------------- */ + case 'o': /* OUT file */ + outfile = optarg; + while (*outfile) { outfile++; } /* Run to filename end */ + outfile--; + S3 = *outfile; + outfile--; + S2 = *outfile; + outfile--; + S1 = *outfile; + + outfile = optarg; + + if ((S1 == 'x' && S2 == 'm' && S3 == 'l') + || (S1 == 'X' && S2 == 'M' && S3 == 'L')) + break; + + fprintf(stderr, + "Output file name must have .xml extension, not .%c%c%c\n", S1, S2, S3); + return 1; + + /* ----------------------------------------------------- */ + case 'f': /* Choose sample frame. 0 = none */ + sscanf(optarg, "%u", &sampleframe); + break; + + /* ----------------------------------------------------- */ + case 'v': /* Verification by DTD. */ + stringDTD = optarg; + /* We will not insist upon last 3 chars being "dtd", since non-file + access protocol may be used. */ + if(strchr(stringDTD,'"') != NULL) { + fprintf(stderr, "-D's string must not contain any embedded double-quote characters.\n"); + return 1; + } + + if (strncmp(stringDTD,"PUBLIC ",7) == 0 || strncmp(stringDTD,"SYSTEM ",7) == 0) + break; + + fprintf(stderr, "-D's string must start with \"PUBLIC \" or \"SYSTEM \"\n"); + return 1; + + /* ----------------------------------------------------- */ + case 'n': /* Suppress comments */ + notes = FALSE; + break; + + /* ----------------------------------------------------- */ + case 't': /* Show sample size and chunk offset tables */ + sampletables = TRUE; + break; + + /* ----------------------------------------------------- */ + case 'h': /* Display an help description */ + help_display(); + return 0; + + /* ----------------------------------------------------- */ + case 'r': /* Suppress raw data */ + raw = FALSE; + break; + + /* ----------------------------------------------------- */ + case 'd': /* Suppress derived data */ + derived = FALSE; + break; + + /* ----------------------------------------------------- */ + default: + return 1; + } /* switch */ + } /* while */ + + if(!raw && !derived) + raw = TRUE; /* At least one of 'raw' and 'derived' must be true */ + + /* Error messages */ + /* -------------- */ + if (!infile || !outfile) { + fprintf(stderr,"Correct usage: mj2_to_metadata -i mj2-file -o xml-file (plus options)\n"); + return 1; + } + +/* was: + if (argc != 3) { + printf("Bad syntax: Usage: MJ2_to_metadata inputfile.mj2 outputfile.xml\n"); + printf("Example: MJ2_to_metadata foreman.mj2 foreman.xml\n"); + return 1; + } +*/ + len = strlen(infile); + if(infile[0] == ' ') + { + infile++; /* There may be a leading blank if user put space after -i */ + } + + file = fopen(infile, "rb"); /* was: argv[1] */ + + if (!file) { + fprintf(stderr, "Failed to open %s for reading.\n", infile); /* was: argv[1] */ + return 1; + } + + len = strlen(outfile); + if(outfile[0] == ' ') + { + outfile++; /* There may be a leading blank if user put space after -o */ + } + + // Checking output file + xmlout = fopen(outfile, "w"); /* was: argv[2] */ + if (!xmlout) { + fprintf(stderr, "Failed to open %s for writing.\n", outfile); /* was: argv[2] */ + return 1; + } + // Leave it open + + if (mj2_read_struct(file, &movie)) // Creating the movie structure + { + fclose(xmlout); + return 1; + } + + xml_write_init(notes, sampletables, raw, derived); + xml_write_struct(file, xmlout, &movie, sampleframe, stringDTD); + fclose(xmlout); + + mj2_memory_free(&movie); + + //MEMORY LEAK + #ifdef _DEBUG + _CrtDumpMemoryLeaks(); + #endif + //MEM + + return 0; +} + + diff --git a/mj2/mj2_to_metadata.dsp b/mj2/mj2_to_metadata.dsp new file mode 100644 index 00000000..1151b73a --- /dev/null +++ b/mj2/mj2_to_metadata.dsp @@ -0,0 +1,276 @@ +# Microsoft Developer Studio Project File - Name="mj2_to_metadata" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=mj2_to_metadata - 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 "mj2_to_metadata.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 "mj2_to_metadata.mak" CFG="mj2_to_metadata - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mj2_to_metadata - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "mj2_to_metadata - 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)" == "mj2_to_metadata - 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 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /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)" == "mj2_to_metadata - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "mj2_to_metadata___Win32_Debug0" +# PROP BASE Intermediate_Dir "mj2_to_metadata___Win32_Debug0" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "mj2_to_metadata___Win32_Debug0" +# PROP Intermediate_Dir "mj2_to_metadata___Win32_Debug0" +# 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 /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /D "NO_PACKETS_DECODING" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /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 "mj2_to_metadata - Win32 Release" +# Name "mj2_to_metadata - Win32 Debug" +# Begin Group "MJ2" + +# PROP Default_Filter "" +# Begin Group "MJ2 Header Files" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\compat\getopt.h +# End Source File +# Begin Source File + +SOURCE=.\meta_out.h +# End Source File +# Begin Source File + +SOURCE=.\mj2.h +# End Source File +# Begin Source File + +SOURCE=.\mj2_convert.h +# End Source File +# End Group +# Begin Group "MJ2 Source Files" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\compat\getopt.c +# End Source File +# Begin Source File + +SOURCE=.\meta_out.c +# End Source File +# Begin Source File + +SOURCE=.\mj2.c +# End Source File +# Begin Source File + +SOURCE=.\mj2_convert.c +# End Source File +# Begin Source File + +SOURCE=.\mj2_to_metadata.c +# End Source File +# End Group +# End Group +# Begin Group "OpenJPEG" + +# PROP Default_Filter "" +# Begin Group "OpenJPEG Header Files" + +# PROP Default_Filter ".h" +# Begin Source File + +SOURCE=..\libopenjpeg\bio.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\cio.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\dwt.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\fix.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\int.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\j2k.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\jp2.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\jpt.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\mct.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\mqc.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\openjpeg.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\pi.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\raw.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\t1.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\t2.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\tcd.h +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\tgt.h +# End Source File +# End Group +# Begin Group "OpenJPEG Source Files" + +# PROP Default_Filter ".c" +# Begin Source File + +SOURCE=..\libopenjpeg\bio.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\cio.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\dwt.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\fix.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\int.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\j2k.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\jp2.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\jpt.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\mct.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\mqc.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\pi.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\raw.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\t1.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\t2.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\tcd.c +# End Source File +# Begin Source File + +SOURCE=..\libopenjpeg\tgt.c +# End Source File +# End Group +# End Group +# End Target +# End Project diff --git a/mj2/mj2_to_metadata.h b/mj2/mj2_to_metadata.h new file mode 100644 index 00000000..f4c34919 --- /dev/null +++ b/mj2/mj2_to_metadata.h @@ -0,0 +1,9 @@ +/* mj2_to_metadata.h */ +/* Dump MJ2, JP2 metadata (partial so far) to xml file */ +/* Contributed to Open JPEG by Glenn Pearson, U.S. National Library of Medicine */ + +#define BOOL int +#define FALSE 0 +#define TRUE 1 + +#include "meta_out.h" diff --git a/mj2/mj2_to_metadata_Notes.doc b/mj2/mj2_to_metadata_Notes.doc new file mode 100644 index 0000000000000000000000000000000000000000..39dd21fb570e6b042ad9536fb33cf0fa5347f38f GIT binary patch literal 33792 zcmeI53z(c$dB@M}C7VDdSwgZT0ptUNZeX(sixiAp5^^z#xe39b<;gNT^X<+gGxH5| z+09zpP80+cg%Td6l}Ew0Ua3UzDL&E))>^6-NLxf|eNt!@qauczqDHpA|M|Xec6N4W z$;G>Kmj9gZ+}?A}`@ZKr=lw2W@59GEe*0(UKVfRZg{IlOG&0RhsmhOV{kkySZp;N- zEAOR|kr8E|54dcE-yse>^|xO%t;?ph7;|9OeG;NENS1)$Uz%^s4AZy0Z~N1$pI&Wq z$NWrd=`fw$#$4a!>RpEwuCo_CQZIty>gzDCHlD4FAgm7BzAx%$ zOcXDm=q}0?hxI>yg5THw2JMbCel2vGp!+&vg+qxoj;H1ta|sPEJkgl9k?y7a91*Aq zAwT|dMomGGtQ~h)FN{UEI)wDXIBXx*3DZT|b&wf3&M&Er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