Skip to content

JP2K Quantization unpacking and QCD data checks #109

@ChrisRalph

Description

@ChrisRalph

Hi all,

We are seeing that the GuardBit value determined with j2c-test is incorrect. Proposing the following changes to unpack the correct bytes for determining GuardBits:

JP2K.h around lines 164 to 200

      const int SqcdOFST = 0;
      const int SPqcdOFST = 1;

      enum QuantizationType_t
      {
	QT_NONE,
	QT_DERIVED,
	QT_EXP
      };

      const char* GetQuantizationTypeString(const QuantizationType_t m);

      // Quantization default
      class QCD
        {
	  const byte_t* m_MarkerSqcd;
	  const byte_t* m_MarkerData;
	  ui32_t m_DataSize;

	  KM_NO_COPY_CONSTRUCT(QCD);
	  QCD();

	public:
	  QCD(const Marker& M)
	    {
	      assert(M.m_Type == MRK_QCD);
              m_MarkerSqcd = M.m_Data;
	      m_MarkerData = M.m_Data + SPqcdOFST;
	      m_DataSize = M.m_DataSize - SPqcdOFST;
	    }

	  ~QCD() {}
	  inline QuantizationType_t QuantizationType() const { return static_cast<QuantizationType_t>(*(m_MarkerSqcd) & 0x03); }
	  inline ui8_t  GuardBits() const { return (*(m_MarkerSqcd) & 0xe0) >> 5; }
	  void Dump(FILE* stream = 0) const;
	};

Additionally, does anyone know if there is a specific requirement for the QCD Data to match between frames aswell as GuardBits matching, as per the pedantic checks? Different JP2K Encoders potentially use different values here and the pedantic checks prevent these from wrapping frames which have differing values in a single MXF.

Proposing the following changes to highlight a difference of QCD Data (with matching GuardBits), but not to fail the pedantic checks:

JP2K_Sequence_Parser.cpp line ~209 to 226:

//
bool
operator==(const ASDCP::JP2K::QuantizationDefault_t& lhs, const ASDCP::JP2K::QuantizationDefault_t& rhs)
{
  if ( lhs.Sqcd != rhs.Sqcd ) return false;
  if ( lhs.SPqcdLength != rhs.SPqcdLength ) return false;
  
  for ( ui32_t i = 0; i < JP2K::MaxDefaults; i++ )
    {
      if ( lhs.SPqcd[i] != rhs.SPqcd[i]  ){
        printf("SPqcd Component mismatch.\n");
        // TODO: Bypassing this check until we know if it is appropriate
        // return false;
      }
    }

  return true;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions