undo, j2c-test
authorjhurst <jhurst@cinecert.com>
Tue, 5 Jan 2010 04:12:15 +0000 (04:12 +0000)
committerjhurst <>
Tue, 5 Jan 2010 04:12:15 +0000 (04:12 +0000)
README
configure.ac
src/JP2K.cpp
src/MDD.cpp
src/MXF.cpp
src/Makefile.am
src/asdcp-test.cpp
src/j2c-test.cpp
src/jp2k-tst.sh

diff --git a/README b/README
index 04af90cd52b52d33fc984240418539a49462023d..da0269612ab8b27cd963524f78050228d2d14c70 100755 (executable)
--- a/README
+++ b/README
@@ -112,6 +112,14 @@ utilities all respond to -h.
 
 Change History
 
+2010.01.05 -  bug fixes, enhancements, v1.5.32
+ o Re-fixed swapped Interop and SMPTE OP Atom UL values. The swap
+   introduced in v1.5.31 was done in error.
+ o Added -z,-Z options to asdcp-test (j2c parameter checking)
+ o Reformed jp2k-test as j2c-test, added help and list processing,
+   added to standard install target.
+
+
 2009.12.31 -  bug fixes, enhancements, v1.5.31
  o Fixed swapped Interop and SMPTE OP Atom UL values.
  o Added get_BER_length_for_value() subroutine.
index 21e94d5fef1d8533def4345dc432857149cfdc21..e03e0132190ac815ab9ba0bdf45ebf7667ebddf6 100644 (file)
@@ -37,7 +37,7 @@ AC_PREREQ([2.59])
 # For example, if asdcplib version 1.0.0 were modified to accomodate changes
 # in file format, and if no changes were made to AS_DCP.h, the new version would be
 # 1.0.1. If changes were also required in AS_DCP.h, the new version would be 1.1.1.
-AC_INIT([asdcplib], [1.5.31], [asdcplib@cinecert.com])
+AC_INIT([asdcplib], [1.5.32], [asdcplib@cinecert.com])
 
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_SRCDIR([src/KM_error.h])
index b8c5b5928a060ce60b62d05bf59de3f7e19a6fed..6858253f1e3768f3947ce820b34a6641dc7d5605 100755 (executable)
@@ -162,6 +162,7 @@ ASDCP::JP2K::Accessor::COM::Dump(FILE* stream)
     }
   else
     {
+      fprintf(stream, "COM:\n");
       Kumu::hexdump(CommentData(), CommentSize(), stream);
     }
 }
index f4ed6d9627e9908577f11678a14a8f023a2c5cd2..08c5c5f9930476318e7eb9ac3f12add67fadece3 100644 (file)
@@ -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
index c4a9693d0348be623f7b3618b25974ac4061e8e5..9c53a9008563f4c0f54770f25a9171aabf6383cb 100755 (executable)
@@ -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
     {
index 0b49e74865f90f3c500ed6493d55979391c81cf0..a4a413407825006a5edfdce878143882c3da1a2f 100644 (file)
@@ -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
index 0266b7bc7c0b90c3f68c832f6e0b9799e1bb8412..04498c667ed5faa5638f88dc7a04de07ff85d99e 100755 (executable)
@@ -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) )
index 09452f173f45478b43ff7fcd1963ec0bc59c960c..968ed98f232e2a794a436a74f118567723720515 100755 (executable)
@@ -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
 //
index 38df36761227e5d5fa9e95b493a43c334a2f972f..3cb4e045db729df620136dc8a6e196ab4ed6accd 100755 (executable)
@@ -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