diff options
| author | jhurst <jhurst@cinecert.com> | 2010-01-05 04:12:15 +0000 |
|---|---|---|
| committer | jhurst <> | 2010-01-05 04:12:15 +0000 |
| commit | 5975dff0adbe4feb120fe18e5bee6641f40d2559 (patch) | |
| tree | 735e8f1b28f37148baf7a704ad0c1539bdab381c /src | |
| parent | d2bb60a0011f1d5ea555b74153c16b283f14e397 (diff) | |
undo, j2c-test
Diffstat (limited to 'src')
| -rwxr-xr-x | src/JP2K.cpp | 1 | ||||
| -rw-r--r-- | src/MDD.cpp | 6 | ||||
| -rwxr-xr-x | src/MXF.cpp | 4 | ||||
| -rw-r--r-- | src/Makefile.am | 8 | ||||
| -rwxr-xr-x | src/asdcp-test.cpp | 20 | ||||
| -rwxr-xr-x | src/j2c-test.cpp | 217 | ||||
| -rwxr-xr-x | src/jp2k-tst.sh | 2 |
7 files changed, 196 insertions, 62 deletions
diff --git a/src/JP2K.cpp b/src/JP2K.cpp index b8c5b59..6858253 100755 --- a/src/JP2K.cpp +++ b/src/JP2K.cpp @@ -162,6 +162,7 @@ ASDCP::JP2K::Accessor::COM::Dump(FILE* stream) } else { + fprintf(stream, "COM:\n"); Kumu::hexdump(CommentData(), CommentSize(), stream); } } diff --git a/src/MDD.cpp b/src/MDD.cpp index f4ed6d9..08c5c5f 100644 --- a/src/MDD.cpp +++ b/src/MDD.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2006-2009, John Hurst +Copyright (c) 2006-2010, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -38,10 +38,10 @@ static const ASDCP::MDDEntry s_MDD_Table[] = { { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, {0}, false, "MICAlgorithm_NONE" }, - { { 0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x02, // 1 + { { 0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x01, // 1 0x0d, 0x01, 0x02, 0x01, 0x10, 0x00, 0x00, 0x00 }, {0}, false, "MXFInterop_OPAtom" }, - { { 0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x01, // 2 + { { 0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x02, // 2 0x0d, 0x01, 0x02, 0x01, 0x10, 0x00, 0x00, 0x00 }, {0}, false, "OPAtom" }, { { 0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x01, // 3 diff --git a/src/MXF.cpp b/src/MXF.cpp index c4a9693..9c53a90 100755 --- a/src/MXF.cpp +++ b/src/MXF.cpp @@ -720,8 +720,8 @@ ASDCP::MXF::OPAtomHeader::InitFromFile(const Kumu::FileReader& Reader) } else if ( OperationalPattern == InteropOPAtomUL ) // Interop { - // if ( m_Dict == &DefaultCompositeDict() ) - // m_Dict = &DefaultInteropDict(); + if ( m_Dict == &DefaultCompositeDict() ) + m_Dict = &DefaultInteropDict(); } else { diff --git a/src/Makefile.am b/src/Makefile.am index 0b49e74..a4a4134 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -112,7 +112,7 @@ asdcp_la_LIBADD = libpyasdcp.la endif # list of programs to be built and installed -bin_PROGRAMS = asdcp-test blackwave klvwalk kmfilegen kmrandgen \ +bin_PROGRAMS = asdcp-test j2c-test blackwave klvwalk kmfilegen kmrandgen \ kmuuidgen wavesplit # sources for a program @@ -132,9 +132,11 @@ klvwalk_SOURCES = klvwalk.cpp klvwalk_LDADD = libasdcp.la wavesplit_SOURCES = wavesplit.cpp wavesplit_LDADD = libasdcp.la +j2c_test_SOURCES = j2c-test.cpp +j2c_test_LDADD = libasdcp.la # list of programs that need to be compiled for use in test suite -check_PROGRAMS = asdcp-mem-test path-test jp2k-test S429-5-cgi \ +check_PROGRAMS = asdcp-mem-test path-test S429-5-cgi \ fips-186-rng-test asdcp-version if DEV_HEADERS check_PROGRAMS += tt-xform @@ -146,8 +148,6 @@ asdcp_mem_test_SOURCES = asdcp-mem-test.cpp asdcp_mem_test_LDADD = libasdcp.la path_test_SOURCES = path-test.cpp path_test_LDADD = libkumu.la -jp2k_test_SOURCES = jp2k-test.cpp -jp2k_test_LDADD = libasdcp.la S429_5_cgi_SOURCES = S429-5-cgi.cpp S429_5_cgi_LDADD = libasdcp.la fips_186_rng_test_SOURCES = fips-186-rng-test.cpp diff --git a/src/asdcp-test.cpp b/src/asdcp-test.cpp index 0266b7b..04498c6 100755 --- a/src/asdcp-test.cpp +++ b/src/asdcp-test.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, John Hurst +Copyright (c) 2003-2010, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -103,7 +103,7 @@ banner(FILE* stream = stdout) { fprintf(stream, "\n\ %s (asdcplib %s)\n\n\ -Copyright (c) 2003-2009 John Hurst\n\n\ +Copyright (c) 2003-2010 John Hurst\n\n\ asdcplib may be copied only under the terms of the license found at\n\ the top of every file in the asdcplib distribution kit.\n\n\ Specify the -h (help) option for further information about %s\n\n", @@ -118,7 +118,7 @@ usage(FILE* stream = stdout) USAGE: %s -c <output-file> [-3] [-a <uuid>] [-b <buffer-size>]\n\ [-d <duration>] [-e|-E] [-f <start-frame>] [-j <key-id-string>]\n\ [-k <key-string>] [-l <label>] [-L] [-M] [-p <frame-rate>] [-R]\n\ - [-s <num>] [-v] [-W] <input-file> [<input-file-2> ...]\n\ + [-s <num>] [-v] [-W] [-z|-Z] <input-file> [<input-file-2> ...]\n\ \n\ %s [-h|-help] [-V]\n\ \n\ @@ -186,6 +186,8 @@ Read/Write Options:\n\ -W - Read input file only, do not write source file\n\ -w <width> - Width of numeric element in a series of frame file names\n\ (use with -x, default 6).\n\ + -z - Fail if j2c inputs have unequal parameters (default)\n\ + -Z - Ignore unequal parameters in j2c inputs\n\ \n"); fprintf(stream, "\ @@ -268,6 +270,7 @@ public: bool duration_flag; // true if duration argument given bool do_repeat; // if true and -c -d, repeat first input frame bool use_smpte_labels; // if true, SMPTE UL values will be written instead of MXF Interop values + bool j2c_pedantic; // passed to JP2K::SequenceParser::OpenRead ui32_t picture_rate; // fps of picture when wrapping PCM ui32_t fb_size; // size of picture frame buffer ui32_t file_count; // number of elements in filenames[] @@ -302,7 +305,7 @@ public: verbose_flag(false), fb_dump_size(0), showindex_flag(false), showheader_flag(false), no_write_flag(false), version_flag(false), help_flag(false), stereo_image_flag(false), number_width(6), start_frame(0), - duration(0xffffffff), duration_flag(false), do_repeat(false), use_smpte_labels(false), + duration(0xffffffff), duration_flag(false), do_repeat(false), use_smpte_labels(false), j2c_pedantic(true), picture_rate(24), fb_size(FRAME_BUFFER_SIZE), file_count(0), file_root(0), out_file(0), channel_fmt(PCM::CF_NONE) { @@ -447,6 +450,9 @@ public: file_root = argv[i]; break; + case 'Z': j2c_pedantic = false; break; + case 'z': j2c_pedantic = true; break; + default: fprintf(stderr, "Unrecognized option: %s\n", argv[i]); return; @@ -772,10 +778,10 @@ write_JP2K_S_file(CommandOptions& Options) } // set up essence parser - Result_t result = ParserLeft.OpenRead(Options.filenames[0]); + Result_t result = ParserLeft.OpenRead(Options.filenames[0], Options.j2c_pedantic); if ( ASDCP_SUCCESS(result) ) - result = ParserRight.OpenRead(Options.filenames[1]); + result = ParserRight.OpenRead(Options.filenames[1], Options.j2c_pedantic); // set up MXF writer if ( ASDCP_SUCCESS(result) ) @@ -996,7 +1002,7 @@ write_JP2K_file(CommandOptions& Options) Kumu::FortunaRNG RNG; // set up essence parser - Result_t result = Parser.OpenRead(Options.filenames[0]); + Result_t result = Parser.OpenRead(Options.filenames[0], Options.j2c_pedantic); // set up MXF writer if ( ASDCP_SUCCESS(result) ) diff --git a/src/j2c-test.cpp b/src/j2c-test.cpp index 09452f1..968ed98 100755 --- a/src/j2c-test.cpp +++ b/src/j2c-test.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2009, John Hurst +Copyright (c) 2005-2010, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/*! \file jp2k-test.cpp +/*! \file j2c-test.cpp \version $Id$ \brief JP2K parser test */ @@ -38,70 +38,197 @@ using namespace Kumu; using namespace ASDCP; using namespace ASDCP::JP2K; + + +//------------------------------------------------------------------------------------------ +// +// command line option parser class + +static const char* PROGRAM_NAME = "j2c-test"; // program name for messages + +// Macros used to test command option data state. + +// Increment the iterator, test for an additional non-option command line argument. +// Causes the caller to return if there are no remaining arguments or if the next +// argument begins with '-'. +#define TEST_EXTRA_ARG(i,c) if ( ++i >= argc || argv[(i)][0] == '-' ) \ + { \ + fprintf(stderr, "Argument not found for option %c.\n", (c)); \ + return; \ + } +// +void +banner(FILE* stream = stderr) +{ + fprintf(stream, "\n\ +%s (asdcplib %s)\n\n\ +Copyright (c) 2005-2010 John Hurst\n\n\ +%s is part of asdcplib.\n\ +asdcplib may be copied only under the terms of the license found at\n\ +the top of every file in the asdcplib distribution kit.\n\n\ +Specify the -h (help) option for further information about %s\n\n", + PROGRAM_NAME, ASDCP::Version(), PROGRAM_NAME, PROGRAM_NAME); +} + +// +void +usage(FILE* stream = stderr) +{ + fprintf(stream, "\ +USAGE: %s [-h|-help] [-V]\n\ +\n\ + %s [-r] [-v] <filename> [...]\n\ +\n\ + -V - Show version\n\ + -h - Show help\n\ + -r - Show raw data\n\ + -v - Print extra detail\n\ +\n\ + NOTES: o There is no option grouping, all options must be distinct arguments.\n\ + o All option arguments must be separated from the option by whitespace.\n\ +\n", PROGRAM_NAME, PROGRAM_NAME); +} + +// +// +class CommandOptions +{ + CommandOptions(); + +public: + bool error_flag; // true if the given options are in error or not complete + bool version_flag; // true if the version display option was selected + bool verbose_flag; // true if the verbose option was selected + bool detail_flag; // true if the version display option was selected + bool help_flag; // true if the help display option was selected + std::list<std::string> filename_list; + + CommandOptions(int argc, const char** argv) : + error_flag(true), version_flag(false), verbose_flag(false), + detail_flag(false), help_flag(false) + { + for ( int i = 1; i < argc; i++ ) + { + if ( argv[i][0] == '-' && isalpha(argv[i][1]) && argv[i][2] == 0 ) + { + switch ( argv[i][1] ) + { + case 'V': version_flag = true; break; + case 'h': help_flag = true; break; + case 'r': detail_flag = true; break; + case 'v': verbose_flag = true; break; + + default: + fprintf(stderr, "Unrecognized option: %c\n", argv[i][1]); + return; + } + } + else + { + filename_list.push_back(argv[i]); + } + } + + if ( filename_list.empty() ) + { + fputs("Input j2c filename(s) required.\n", stderr); + return; + } + + error_flag = false; + } +}; + + + + // int main(int argc, const char** argv) { - ASDCP::JP2K::FrameBuffer FB; - Marker MyMarker; + CommandOptions Options(argc, argv); - if ( argc < 2 ) - return 1; + if ( Options.version_flag ) + banner(); - FB.Capacity(1024*1024*2); - CodestreamParser Parser; + if ( Options.help_flag ) + usage(); - Result_t result = Parser.OpenReadFrame(argv[1], FB); + if ( Options.version_flag || Options.help_flag ) + return 0; - if ( result != RESULT_OK ) + if ( Options.error_flag ) { - fputs("Program stopped on error.\n", stderr); - - if ( result != RESULT_FAIL ) - { - fputs(result.Label(), stderr); - fputc('\n', stderr); - } - - return 1; + fprintf(stderr, "There was a problem. Type %s -h for help.\n", PROGRAM_NAME); + return 3; } - const byte_t* p = FB.RoData(); - const byte_t* end_p = p + FB.Size(); - - hexdump(p, 256, stderr); + ASDCP::JP2K::FrameBuffer FB; + Marker MyMarker; + CodestreamParser Parser; + std::list<std::string>::iterator i; - while ( p < end_p && ASDCP_SUCCESS(GetNextMarker(&p, MyMarker)) ) + Result_t result = FB.Capacity(1024*1024*4); + + for ( i = Options.filename_list.begin(); ASDCP_SUCCESS(result) && i != Options.filename_list.end(); i++ ) { - MyMarker.Dump(); + result = Parser.OpenReadFrame(argv[1], FB); - switch ( MyMarker.m_Type ) + if ( ASDCP_SUCCESS(result) ) { - case MRK_SOD: - p = end_p; - break; + const byte_t* p = FB.RoData(); + const byte_t* end_p = p + FB.Size(); + + while ( p < end_p && ASDCP_SUCCESS(GetNextMarker(&p, MyMarker)) ) + { + if ( Options.verbose_flag ) + { + MyMarker.Dump(stdout); + + if ( Options.detail_flag ) + hexdump(MyMarker.m_Data - 2, MyMarker.m_DataSize + 2, stdout); + } + + switch ( MyMarker.m_Type ) + { + case MRK_SOD: + p = end_p; + break; + + case MRK_SIZ: + { + Accessor::SIZ SIZ_(MyMarker); + SIZ_.Dump(stdout); + } + break; + + case MRK_COM: + { + Accessor::COM COM_(MyMarker); + COM_.Dump(stdout); + } + break; + } + } + } + } - case MRK_SIZ: - { - Accessor::SIZ SIZ_(MyMarker); - hexdump(MyMarker.m_Data - 2, MyMarker.m_DataSize + 2, stderr); - SIZ_.Dump(); - } - break; + if ( ASDCP_FAILURE(result) ) + { + fputs("Program stopped on error.\n", stderr); - case MRK_COM: - { - Accessor::COM COM_(MyMarker); - COM_.Dump(); - } - break; + if ( result != RESULT_FAIL ) + { + fputs(result, stderr); + fputc('\n', stderr); } + + return 1; } - + return 0; } - // -// end jp2k-test.cpp +// end j2c-test.cpp // diff --git a/src/jp2k-tst.sh b/src/jp2k-tst.sh index 38df367..3cb4e04 100755 --- a/src/jp2k-tst.sh +++ b/src/jp2k-tst.sh @@ -48,7 +48,7 @@ for file in `ls ${TEST_FILES}/${TEST_FILE_PREFIX}`; do \ done -#${BUILD_DIR}/jp2k-test${EXEEXT} ${TEST_FILES}/${TEST_FILE_PREFIX}/MM_2k_XYZ_000000.j2c +#${BUILD_DIR}/j2c-test${EXEEXT} ${TEST_FILES}/${TEST_FILE_PREFIX}/MM_2k_XYZ_000000.j2c #if [ $? -ne 0 ]; then # exit 1 #fi |
