Beispiel #1
0
SequenceExtension::SequenceExtension( BitReader &hdr )
{
  init();
  hdr.reset();

  ahabassert( hdr.readbits( 32 ) == 0x000001b5 );
  ahabassert( hdr.readbits( 4 ) == 1 );

  escape_bit = hdr.readbits( 1 );
  profile = hdr.readbits( 3 );
  level = hdr.readbits( 4 );
  progressive_sequence = hdr.readbits( 1 );
  chroma_format = hdr.readbits( 2 );
  horizontal_size_extension = hdr.readbits( 2 );
  vertical_size_extension = hdr.readbits( 2 );
  bit_rate_extension = hdr.readbits( 12 );

  mpegassert( hdr.readbits( 1 ) == 1 );
  
  vbv_buffer_size_extension = hdr.readbits( 8 );
  low_delay = hdr.readbits( 1 );
  frame_rate_extension_n = hdr.readbits( 2 );
  frame_rate_extension_d = hdr.readbits( 5 );

  /* Check conformance limits */
  if ( escape_bit ) {
    throw ConformanceLimitExceeded();
  }

  /* Simple profile or Main profile */
  if ( (profile != 5) && (profile != 4) ) {
    throw ConformanceLimitExceeded();
  }

  /* 4:2:0 only */
  if ( chroma_format != 1 ) {
    throw ConformanceLimitExceeded();
  }
}
  bool init ( BitReader br )
  {
    br.reset();
    if ( br.getByte() != 0x64
        || br.getByte() != 0x58
        || br.getByte() != 0x20
        || br.getByte() != 0x25 )
    {
        return false;
    }

    // * dca.c dca_exss_parse_header

    br.skip(8); // user data
    _ssIndex = br.getInt(2);
    bool blownUp(br.getBool());
    _headerSize = br.getInt(blownUp ? 12 : 8);
    //hdLen = ((hdHdr[6] & 0xf) << 11) + (hdHdr[7] << 3) + ((hdHdr[8] >> 5) & 7) + 1;
    _hdSize = br.getInt(blownUp ? 20: 16) + 1;

    return true;
  }
Beispiel #3
0
PictureCodingExtension::PictureCodingExtension( BitReader &hdr )
{
  init();
  hdr.reset();

  ahabassert( hdr.readbits( 32 ) == 0x000001b5 );
  ahabassert( hdr.readbits( 4 ) == 8 );
  
  f_code_fh = hdr.readbits( 4 );
  f_code_fv = hdr.readbits( 4 );
  f_code_bh = hdr.readbits( 4 );
  f_code_bv = hdr.readbits( 4 );

  intra_dc_precision = hdr.readbits( 2 );
  picture_structure = hdr.readbits( 2 );

  top_field_first = hdr.readbits( 1 );
  frame_pred_frame_dct = hdr.readbits( 1 );
  concealment_motion_vectors = hdr.readbits( 1 );
  q_scale_type = hdr.readbits( 1 );
  intra_vlc_format = hdr.readbits( 1 );
  alternate_scan = hdr.readbits( 1 );
  repeat_first_field = hdr.readbits( 1 );
  chroma_420_type = hdr.readbits( 1 );
  progressive_frame = hdr.readbits( 1 );

  if ( picture_structure != 3 ) {
    fprintf( stderr, "Ahab does not support field pictures.\n" );
    throw ConformanceLimitExceeded();
  }

  mpegassert( ((f_code_fh >= 1) && (f_code_fh <= 9)) || (f_code_fh == 15) );
  mpegassert( ((f_code_fv >= 1) && (f_code_fv <= 9)) || (f_code_fv == 15) );
  mpegassert( ((f_code_bh >= 1) && (f_code_bh <= 9)) || (f_code_bh == 15) );
  mpegassert( ((f_code_bv >= 1) && (f_code_bv <= 9)) || (f_code_bv == 15) );
}
Beispiel #4
0
QuantMatrixExtension::QuantMatrixExtension( BitReader &hdr )
{
  init();
  hdr.reset();

  ahabassert( hdr.readbits( 32 ) == 0x000001b5 );
  ahabassert( hdr.readbits( 4 ) == 3 );

  load_intra_quantiser_matrix = hdr.readbits( 1 );
  for ( int i = 0; i < 64; i++ ) {
    intra_quantiser_matrix[ mpeg2_normal_scan[ i ] ] =
      load_intra_quantiser_matrix
      ? hdr.readbits( 8 )
      : default_intra_quantiser_matrix[ i ];
    mpegassert( intra_quantiser_matrix[ mpeg2_normal_scan[ i ] ] != 0 );
  }

  load_non_intra_quantiser_matrix = hdr.readbits( 1 );
  for ( int i = 0; i < 64; i++ ) {
    non_intra_quantiser_matrix[ mpeg2_normal_scan[ i ] ] =
      load_non_intra_quantiser_matrix ? hdr.readbits( 8 ) : 16;
    mpegassert( intra_quantiser_matrix[ mpeg2_normal_scan[ i ] ] != 0 );
  }
}
  bool init ( BitReader br )
  {
    br.reset();
    // 16 bit formats
    if ( br.getByte() == 0x7f
            && br.getByte() == 0xfe
            && br.getByte() == 0x80
            && br.getByte() == 0x01 )
    {
        _is14Bit = false;
    }
    else
    {
      // 14 bit formats
      br.reset();
      if (br.getByte() == 0x1f
        && br.getByte() == 0xff
        && br.getByte() == 0xe8
        && br.getByte() == 0x00
        && br.getByte() == 0x07
        && br.getByte(4) == 0xf)
      {
        _is14Bit = true;
/*
 * The original code was this, not sure I can parse the 14bit the same as the
 * 16 bit, but I can look at that later if there are problems
    sampleBlocks = ((be2uint16(hdr16[2]) << 4)  & 0x70)
            | ((be2uint16(hdr16[3]) >> 10) & 0x0f);
    ++sampleBlocks;
    amode = (be2uint16(hdr16[4]) >> 4)  & 0x3f;
    sfreq = (be2uint16(hdr16[4]) >> 0)  & 0x0f;
    lfe   = (be2uint16(hdr16[6]) >> 11) & 0x03;
*/
      }
      else
      {
        return false; // invalid frame data
      }
    }

    _isNormalFrame = br.getBool(); // 1
    _shortSamples = br.getInt(5); // 6
    _isCrcPresent = br.getBool(); // 7
    _sampleBlocks = br.getInt(7) + 1; // 14
    _frameSize = br.getInt(14) + 1; // 28
    _channelLayout = br.getInt(6);
    _sampleIndex = br.getInt(4);
    _bitRate = br.getInt(5);
    _downMix = br.getBool();
    _dynamicRange = br.getBool();
    _timeStamp = br.getBool();
    _auxiliaryData = br.getBool();
    _hdcd = br.getBool();
    _externalDescription = br.getInt(3);
    _externalCoding = br.getBool();
    _aspf = br.getBool();
    _lfe = br.getInt(2);
    _predictorHistory = br.getBool();

    if ( _isCrcPresent )
      _crc = br.getInt(16);

    _multirateInter = br.getBool();
    _version = br.getInt(4);
    _copyHistory = br.getInt(2);
    _sourcePcmResolution = br.getInt(3);
    _frontSum = br.getBool();
    _surroundSum = br.getBool();
    _dialogNormalization = br.getInt(4);
    return true;
  }