Sha256: db9cefcdf1d461ad9fcc7af73061f0753406667f65f4baa81a23822c043d2a11

Contents?: true

Size: 865 Bytes

Versions: 11

Compression:

Stored size: 865 Bytes

Contents

require 'parsers/iso_base_media_file_format/decoder'

class FormatParser::CR3Parser::Decoder < FormatParser::ISOBaseMediaFileFormat::Decoder
  include FormatParser::EXIFParser

  protected

  BOX_PARSERS = BOX_PARSERS.merge({
    'CMT1' => :cmt1
  })
  CANON_METADATA_CONTAINER_UUID = '85c0b687820f11e08111f4ce462b6a48'

  def cmt1(size)
    exif = exif_from_tiff_io(StringIO.new(read_bytes(size)))
    if exif
      fields = exif.to_hash
      fields[:rotated] = exif.rotated?
      fields[:orientation_sym] = exif.orientation_sym
      [fields, nil]
    else
      [nil, nil]
    end
  end

  def uuid(size)
    usertype = read_bytes(16).unpack('H*').first
    fields = { usertype: usertype }
    children = if usertype == CANON_METADATA_CONTAINER_UUID
      build_box_tree(size - 16)
    else
      skip_bytes(size - 16)
    end
    [fields, children]
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
format_parser-2.10.0 lib/parsers/cr3_parser/decoder.rb
format_parser-2.9.0 lib/parsers/cr3_parser/decoder.rb
format_parser-2.8.0 lib/parsers/cr3_parser/decoder.rb
format_parser-2.7.2 lib/parsers/cr3_parser/decoder.rb
format_parser-2.7.1 lib/parsers/cr3_parser/decoder.rb
format_parser-2.7.0 lib/parsers/cr3_parser/decoder.rb
format_parser-2.6.0 lib/parsers/cr3_parser/decoder.rb
format_parser-2.5.0 lib/parsers/cr3_parser/decoder.rb
format_parser-2.4.5 lib/parsers/cr3_parser/decoder.rb
format_parser-2.4.4 lib/parsers/cr3_parser/decoder.rb
format_parser-2.4.3 lib/parsers/cr3_parser/decoder.rb