Implemented J2K desc to/from MD
[asdcplib.git] / src / asdcp-info.cpp
index df69d2b83c711b195210a5f65239b348a451bb93..b8876fed903326fb417d3fb478a8f121eddd935b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2003-2012, John Hurst
+Copyright (c) 2003-2014, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <KM_fileio.h>
 #include <AS_DCP.h>
+#include <AS_02.h>
 #include <MXF.h>
 #include <Metadata.h>
 
@@ -75,7 +76,7 @@ banner(FILE* stream = stdout)
 {
   fprintf(stream, "\n\
 %s (asdcplib %s)\n\n\
-Copyright (c) 2003-2012 John Hurst\n\n\
+Copyright (c) 2003-2015 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",
@@ -163,7 +164,7 @@ public:
 
              case 't':
                TEST_EXTRA_ARG(i, 't');
-               max_bitrate = abs(atoi(argv[i]));
+               max_bitrate = Kumu::xabs(strtol(argv[i], 0, 10));
                max_bitrate_flag = true;
                break;
 
@@ -477,7 +478,7 @@ public:
          {
            if ( last_stream_offset != 0 )
              {
-               ui64_t this_frame_size = entry.StreamOffset - last_stream_offset;
+               ui64_t this_frame_size = entry.StreamOffset - last_stream_offset - 20; // do not count the bytes that represent the KLV wrapping 
                total_frame_bytes += this_frame_size;
 
                if ( this_frame_size > largest_frame )
@@ -488,14 +489,17 @@ public:
          }
       }
 
-    // scale bytes to megabits
-    static const double mega_const = 1.0 / ( 1000000 / 8.0 );
+    if ( KM_SUCCESS(result) )
+      {
+       // scale bytes to megabits
+       static const double mega_const = 1.0 / ( 1000000 / 8.0 );
 
-    // we did not accumulate the first or last frame, so duration -= 2
-    double avg_bytes_frame = total_frame_bytes / ( m_Desc.ContainerDuration - 2 );
+       // we did not accumulate the first or last frame, so duration -= 2
+       double avg_bytes_frame = total_frame_bytes / ( m_Desc.ContainerDuration - 2 );
 
-    m_MaxBitrate = largest_frame * mega_const * m_Desc.EditRate.Quotient();
-    m_AvgBitrate = avg_bytes_frame * mega_const * m_Desc.EditRate.Quotient();
+       m_MaxBitrate = largest_frame * mega_const * m_Desc.EditRate.Quotient();
+       m_AvgBitrate = avg_bytes_frame * mega_const * m_Desc.EditRate.Quotient();
+      }
   }
 
   //
@@ -627,6 +631,13 @@ show_file_info(CommandOptions& Options)
       FileInfoWrapper<ASDCP::ATMOS::MXFReader, MyAtmosDescriptor> wrapper;
       result = wrapper.file_info(Options, "Dolby ATMOS");
     }
+  else if ( EssenceType == ESS_AS02_PCM_24b_48k
+           || EssenceType == ESS_AS02_PCM_24b_96k
+           || EssenceType == ESS_AS02_JPEG_2000
+           || EssenceType == ESS_AS02_TIMED_TEXT )
+    {
+      fprintf(stderr, "File is AS-02. Inspection in not supported by this command.\n");
+    }
   else
     {
       fprintf(stderr, "File is not AS-DCP: %s\n", Options.filenames.front().c_str());