// Code generated by kaitai-struct-compiler from a .ksy source file. DO NOT EDIT.

import (
	"github.com/kaitai-io/kaitai_struct_go_runtime/kaitai"
	"bytes"
)


/**
 * @see <a href="https://developers.google.com/speed/webp/docs/riff_container">Source</a>
 */

type Webp_ChunkNames int
const (
	Webp_ChunkNames__XmpVar Webp_ChunkNames = 5262680
	Webp_ChunkNames__Vp8 Webp_ChunkNames = 540561494
	Webp_ChunkNames__Xmp Webp_ChunkNames = 542133592
	Webp_ChunkNames__Exif Webp_ChunkNames = 1179211845
	Webp_ChunkNames__Anmf Webp_ChunkNames = 1179471425
	Webp_ChunkNames__Alph Webp_ChunkNames = 1213221953
	Webp_ChunkNames__Vp8l Webp_ChunkNames = 1278758998
	Webp_ChunkNames__Frgm Webp_ChunkNames = 1296519750
	Webp_ChunkNames__Anim Webp_ChunkNames = 1296649793
	Webp_ChunkNames__Iccp Webp_ChunkNames = 1346585417
	Webp_ChunkNames__Vp8x Webp_ChunkNames = 1480085590
)
var values_Webp_ChunkNames = map[Webp_ChunkNames]struct{}{5262680: {}, 540561494: {}, 542133592: {}, 1179211845: {}, 1179471425: {}, 1213221953: {}, 1278758998: {}, 1296519750: {}, 1296649793: {}, 1346585417: {}, 1480085590: {}}
func (v Webp_ChunkNames) isDefined() bool {
	_, ok := values_Webp_ChunkNames[v]
	return ok
}

type Webp_CompressionMethod int
const (
	Webp_CompressionMethod__None Webp_CompressionMethod = 0
	Webp_CompressionMethod__WebpLossless Webp_CompressionMethod = 1
)
var values_Webp_CompressionMethod = map[Webp_CompressionMethod]struct{}{0: {}, 1: {}}
func (v Webp_CompressionMethod) isDefined() bool {
	_, ok := values_Webp_CompressionMethod[v]
	return ok
}

type Webp_FilteringMethod int
const (
	Webp_FilteringMethod__None Webp_FilteringMethod = 0
	Webp_FilteringMethod__Horizontal Webp_FilteringMethod = 1
	Webp_FilteringMethod__Vertical Webp_FilteringMethod = 2
	Webp_FilteringMethod__Gradient Webp_FilteringMethod = 3
)
var values_Webp_FilteringMethod = map[Webp_FilteringMethod]struct{}{0: {}, 1: {}, 2: {}, 3: {}}
func (v Webp_FilteringMethod) isDefined() bool {
	_, ok := values_Webp_FilteringMethod[v]
	return ok
}

type Webp_Preprocessing int
const (
	Webp_Preprocessing__None Webp_Preprocessing = 0
	Webp_Preprocessing__LevelReduction Webp_Preprocessing = 1
)
var values_Webp_Preprocessing = map[Webp_Preprocessing]struct{}{0: {}, 1: {}}
func (v Webp_Preprocessing) isDefined() bool {
	_, ok := values_Webp_Preprocessing[v]
	return ok
}
type Webp struct {
	Magic []byte
	LenData uint32
	Webp []byte
	Payload *Webp_Chunks
	_io *kaitai.Stream
	_root *Webp
	_parent kaitai.Struct
	_raw_Payload []byte
}
func NewWebp() *Webp {
	return &Webp{
	}
}

func (this Webp) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp) Read(io *kaitai.Stream, parent kaitai.Struct, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp1, err := this._io.ReadBytes(int(4))
	if err != nil {
		return err
	}
	tmp1 = tmp1
	this.Magic = tmp1
	if !(bytes.Equal(this.Magic, []uint8{82, 73, 70, 70})) {
		return kaitai.NewValidationNotEqualError([]uint8{82, 73, 70, 70}, this.Magic, this._io, "/seq/0")
	}
	tmp2, err := this._io.ReadU4le()
	if err != nil {
		return err
	}
	this.LenData = uint32(tmp2)
	tmp3, err := this._io.ReadBytes(int(4))
	if err != nil {
		return err
	}
	tmp3 = tmp3
	this.Webp = tmp3
	if !(bytes.Equal(this.Webp, []uint8{87, 69, 66, 80})) {
		return kaitai.NewValidationNotEqualError([]uint8{87, 69, 66, 80}, this.Webp, this._io, "/seq/2")
	}
	tmp4, err := this._io.ReadBytes(int(this.LenData - 4))
	if err != nil {
		return err
	}
	tmp4 = tmp4
	this._raw_Payload = tmp4
	_io__raw_Payload := kaitai.NewStream(bytes.NewReader(this._raw_Payload))
	tmp5 := NewWebp_Chunks()
	err = tmp5.Read(_io__raw_Payload, this, this._root)
	if err != nil {
		return err
	}
	this.Payload = tmp5
	return err
}
type Webp_Alph struct {
	Reserved uint64
	Preprocessing Webp_Preprocessing
	Filtering Webp_FilteringMethod
	Compression Webp_CompressionMethod
	Data []byte
	_io *kaitai.Stream
	_root *Webp
	_parent *Webp_Chunk
}
func NewWebp_Alph() *Webp_Alph {
	return &Webp_Alph{
	}
}

func (this Webp_Alph) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp_Alph) Read(io *kaitai.Stream, parent *Webp_Chunk, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp6, err := this._io.ReadBitsIntBe(2)
	if err != nil {
		return err
	}
	this.Reserved = tmp6
	if !(this.Reserved == 0) {
		return kaitai.NewValidationNotEqualError(0, this.Reserved, this._io, "/types/alph/seq/0")
	}
	tmp7, err := this._io.ReadBitsIntBe(2)
	if err != nil {
		return err
	}
	this.Preprocessing = Webp_Preprocessing(tmp7)
	if !this.Preprocessing.isDefined() {
		return kaitai.NewValidationNotInEnumError(this.Preprocessing, this._io, "/types/alph/seq/1")
	}
	tmp8, err := this._io.ReadBitsIntBe(2)
	if err != nil {
		return err
	}
	this.Filtering = Webp_FilteringMethod(tmp8)
	tmp9, err := this._io.ReadBitsIntBe(2)
	if err != nil {
		return err
	}
	this.Compression = Webp_CompressionMethod(tmp9)
	if !this.Compression.isDefined() {
		return kaitai.NewValidationNotInEnumError(this.Compression, this._io, "/types/alph/seq/3")
	}
	this._io.AlignToByte()
	tmp10, err := this._io.ReadBytesFull()
	if err != nil {
		return err
	}
	tmp10 = tmp10
	this.Data = tmp10
	return err
}

/**
 * @see <a href="https://developers.google.com/speed/webp/docs/riff_container#animation">Source</a>
 */
type Webp_Anim struct {
	BackgroundColor *Webp_Anim_BgColor
	LoopCount uint16
	_io *kaitai.Stream
	_root *Webp
	_parent *Webp_Chunk
}
func NewWebp_Anim() *Webp_Anim {
	return &Webp_Anim{
	}
}

func (this Webp_Anim) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp_Anim) Read(io *kaitai.Stream, parent *Webp_Chunk, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp11 := NewWebp_Anim_BgColor()
	err = tmp11.Read(this._io, this, this._root)
	if err != nil {
		return err
	}
	this.BackgroundColor = tmp11
	tmp12, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.LoopCount = uint16(tmp12)
	return err
}
type Webp_Anim_BgColor struct {
	Blue uint8
	Green uint8
	Red uint8
	Alpha uint8
	_io *kaitai.Stream
	_root *Webp
	_parent *Webp_Anim
}
func NewWebp_Anim_BgColor() *Webp_Anim_BgColor {
	return &Webp_Anim_BgColor{
	}
}

func (this Webp_Anim_BgColor) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp_Anim_BgColor) Read(io *kaitai.Stream, parent *Webp_Anim, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp13, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.Blue = tmp13
	tmp14, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.Green = tmp14
	tmp15, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.Red = tmp15
	tmp16, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.Alpha = tmp16
	return err
}
type Webp_Anmf struct {
	FrameXDiv2 uint64
	FrameYDiv2 uint64
	FrameWidthMinus1 uint64
	FrameHeightMinus1 uint64
	Duration uint64
	Reserved uint64
	BlendingMethod bool
	DisposalMethod bool
	Data []byte
	_io *kaitai.Stream
	_root *Webp
	_parent *Webp_Chunk
	_f_frameHeight bool
	frameHeight int
	_f_frameWidth bool
	frameWidth int
	_f_frameX bool
	frameX int
	_f_frameY bool
	frameY int
}
func NewWebp_Anmf() *Webp_Anmf {
	return &Webp_Anmf{
	}
}

func (this Webp_Anmf) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp_Anmf) Read(io *kaitai.Stream, parent *Webp_Chunk, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp17, err := this._io.ReadBitsIntLe(24)
	if err != nil {
		return err
	}
	this.FrameXDiv2 = tmp17
	tmp18, err := this._io.ReadBitsIntLe(24)
	if err != nil {
		return err
	}
	this.FrameYDiv2 = tmp18
	tmp19, err := this._io.ReadBitsIntLe(24)
	if err != nil {
		return err
	}
	this.FrameWidthMinus1 = tmp19
	tmp20, err := this._io.ReadBitsIntLe(24)
	if err != nil {
		return err
	}
	this.FrameHeightMinus1 = tmp20
	tmp21, err := this._io.ReadBitsIntLe(24)
	if err != nil {
		return err
	}
	this.Duration = tmp21
	tmp22, err := this._io.ReadBitsIntBe(6)
	if err != nil {
		return err
	}
	this.Reserved = tmp22
	if !(this.Reserved == 0) {
		return kaitai.NewValidationNotEqualError(0, this.Reserved, this._io, "/types/anmf/seq/5")
	}
	tmp23, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.BlendingMethod = tmp23 != 0
	tmp24, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.DisposalMethod = tmp24 != 0
	this._io.AlignToByte()
	tmp25, err := this._io.ReadBytesFull()
	if err != nil {
		return err
	}
	tmp25 = tmp25
	this.Data = tmp25
	return err
}
func (this *Webp_Anmf) FrameHeight() (v int, err error) {
	if (this._f_frameHeight) {
		return this.frameHeight, nil
	}
	this._f_frameHeight = true
	this.frameHeight = int(this.FrameHeightMinus1 + 1)
	return this.frameHeight, nil
}
func (this *Webp_Anmf) FrameWidth() (v int, err error) {
	if (this._f_frameWidth) {
		return this.frameWidth, nil
	}
	this._f_frameWidth = true
	this.frameWidth = int(this.FrameWidthMinus1 + 1)
	return this.frameWidth, nil
}
func (this *Webp_Anmf) FrameX() (v int, err error) {
	if (this._f_frameX) {
		return this.frameX, nil
	}
	this._f_frameX = true
	this.frameX = int(this.FrameXDiv2 * 2)
	return this.frameX, nil
}
func (this *Webp_Anmf) FrameY() (v int, err error) {
	if (this._f_frameY) {
		return this.frameY, nil
	}
	this._f_frameY = true
	this.frameY = int(this.FrameYDiv2 * 2)
	return this.frameY, nil
}
type Webp_Chunk struct {
	Name Webp_ChunkNames
	LenData uint32
	Data interface{}
	Padding []byte
	_io *kaitai.Stream
	_root *Webp
	_parent *Webp_Chunks
	_raw_Data []byte
}
func NewWebp_Chunk() *Webp_Chunk {
	return &Webp_Chunk{
	}
}

func (this Webp_Chunk) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp_Chunk) Read(io *kaitai.Stream, parent *Webp_Chunks, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp26, err := this._io.ReadU4le()
	if err != nil {
		return err
	}
	this.Name = Webp_ChunkNames(tmp26)
	if !this.Name.isDefined() {
		return kaitai.NewValidationNotInEnumError(this.Name, this._io, "/types/chunk/seq/0")
	}
	tmp27, err := this._io.ReadU4le()
	if err != nil {
		return err
	}
	this.LenData = uint32(tmp27)
	switch (this.Name) {
	case Webp_ChunkNames__Alph:
		tmp28, err := this._io.ReadBytes(int(this.LenData))
		if err != nil {
			return err
		}
		tmp28 = tmp28
		this._raw_Data = tmp28
		_io__raw_Data := kaitai.NewStream(bytes.NewReader(this._raw_Data))
		tmp29 := NewWebp_Alph()
		err = tmp29.Read(_io__raw_Data, this, this._root)
		if err != nil {
			return err
		}
		this.Data = tmp29
	case Webp_ChunkNames__Anim:
		tmp30, err := this._io.ReadBytes(int(this.LenData))
		if err != nil {
			return err
		}
		tmp30 = tmp30
		this._raw_Data = tmp30
		_io__raw_Data := kaitai.NewStream(bytes.NewReader(this._raw_Data))
		tmp31 := NewWebp_Anim()
		err = tmp31.Read(_io__raw_Data, this, this._root)
		if err != nil {
			return err
		}
		this.Data = tmp31
	case Webp_ChunkNames__Anmf:
		tmp32, err := this._io.ReadBytes(int(this.LenData))
		if err != nil {
			return err
		}
		tmp32 = tmp32
		this._raw_Data = tmp32
		_io__raw_Data := kaitai.NewStream(bytes.NewReader(this._raw_Data))
		tmp33 := NewWebp_Anmf()
		err = tmp33.Read(_io__raw_Data, this, this._root)
		if err != nil {
			return err
		}
		this.Data = tmp33
	case Webp_ChunkNames__Vp8:
		tmp34, err := this._io.ReadBytes(int(this.LenData))
		if err != nil {
			return err
		}
		tmp34 = tmp34
		this._raw_Data = tmp34
		_io__raw_Data := kaitai.NewStream(bytes.NewReader(this._raw_Data))
		tmp35 := NewWebp_Vp8()
		err = tmp35.Read(_io__raw_Data, this, this._root)
		if err != nil {
			return err
		}
		this.Data = tmp35
	case Webp_ChunkNames__Vp8l:
		tmp36, err := this._io.ReadBytes(int(this.LenData))
		if err != nil {
			return err
		}
		tmp36 = tmp36
		this._raw_Data = tmp36
		_io__raw_Data := kaitai.NewStream(bytes.NewReader(this._raw_Data))
		tmp37 := NewWebp_Vp8l()
		err = tmp37.Read(_io__raw_Data, this, this._root)
		if err != nil {
			return err
		}
		this.Data = tmp37
	case Webp_ChunkNames__Vp8x:
		tmp38, err := this._io.ReadBytes(int(this.LenData))
		if err != nil {
			return err
		}
		tmp38 = tmp38
		this._raw_Data = tmp38
		_io__raw_Data := kaitai.NewStream(bytes.NewReader(this._raw_Data))
		tmp39 := NewWebp_Vp8x()
		err = tmp39.Read(_io__raw_Data, this, this._root)
		if err != nil {
			return err
		}
		this.Data = tmp39
	case Webp_ChunkNames__Xmp:
		tmp40, err := this._io.ReadBytes(int(this.LenData))
		if err != nil {
			return err
		}
		tmp40 = tmp40
		this._raw_Data = tmp40
		_io__raw_Data := kaitai.NewStream(bytes.NewReader(this._raw_Data))
		tmp41 := NewWebp_Xmp()
		err = tmp41.Read(_io__raw_Data, this, this._root)
		if err != nil {
			return err
		}
		this.Data = tmp41
	case Webp_ChunkNames__XmpVar:
		tmp42, err := this._io.ReadBytes(int(this.LenData))
		if err != nil {
			return err
		}
		tmp42 = tmp42
		this._raw_Data = tmp42
		_io__raw_Data := kaitai.NewStream(bytes.NewReader(this._raw_Data))
		tmp43 := NewWebp_Xmp()
		err = tmp43.Read(_io__raw_Data, this, this._root)
		if err != nil {
			return err
		}
		this.Data = tmp43
	default:
		tmp44, err := this._io.ReadBytes(int(this.LenData))
		if err != nil {
			return err
		}
		tmp44 = tmp44
		this._raw_Data = tmp44
	}
	tmp45 := this.LenData % 2
	if tmp45 < 0 {
		tmp45 += 2
	}
	if (tmp45 != 0) {
		tmp46, err := this._io.ReadBytes(int(1))
		if err != nil {
			return err
		}
		tmp46 = tmp46
		this.Padding = tmp46
		if !(bytes.Equal(this.Padding, []uint8{0})) {
			return kaitai.NewValidationNotEqualError([]uint8{0}, this.Padding, this._io, "/types/chunk/seq/3")
		}
	}
	return err
}
type Webp_Chunks struct {
	Chunks []*Webp_Chunk
	_io *kaitai.Stream
	_root *Webp
	_parent *Webp
}
func NewWebp_Chunks() *Webp_Chunks {
	return &Webp_Chunks{
	}
}

func (this Webp_Chunks) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp_Chunks) Read(io *kaitai.Stream, parent *Webp, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	for i := 0;; i++ {
		tmp47, err := this._io.EOF()
		if err != nil {
			return err
		}
		if tmp47 {
			break
		}
		tmp48 := NewWebp_Chunk()
		err = tmp48.Read(this._io, this, this._root)
		if err != nil {
			return err
		}
		this.Chunks = append(this.Chunks, tmp48)
	}
	return err
}

/**
 * @see <a href="https://www.rfc-editor.org/rfc/rfc6386#section-9.1">Source</a>
 */
type Webp_Vp8 struct {
	FrameType bool
	Version uint64
	ShowFrame bool
	LenFirstPartition uint64
	StartCode []byte
	Width uint64
	HorizontalScale uint64
	Height uint64
	VerticalScale uint64
	Data []byte
	_io *kaitai.Stream
	_root *Webp
	_parent *Webp_Chunk
}
func NewWebp_Vp8() *Webp_Vp8 {
	return &Webp_Vp8{
	}
}

func (this Webp_Vp8) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp_Vp8) Read(io *kaitai.Stream, parent *Webp_Chunk, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp49, err := this._io.ReadBitsIntLe(1)
	if err != nil {
		return err
	}
	this.FrameType = tmp49 != 0
	if !(this.FrameType == false) {
		return kaitai.NewValidationNotEqualError(false, this.FrameType, this._io, "/types/vp8/seq/0")
	}
	tmp50, err := this._io.ReadBitsIntLe(3)
	if err != nil {
		return err
	}
	this.Version = tmp50
	if !(this.Version <= 3) {
		return kaitai.NewValidationGreaterThanError(3, this.Version, this._io, "/types/vp8/seq/1")
	}
	tmp51, err := this._io.ReadBitsIntLe(1)
	if err != nil {
		return err
	}
	this.ShowFrame = tmp51 != 0
	tmp52, err := this._io.ReadBitsIntLe(19)
	if err != nil {
		return err
	}
	this.LenFirstPartition = tmp52
	this._io.AlignToByte()
	tmp53, err := this._io.ReadBytes(int(3))
	if err != nil {
		return err
	}
	tmp53 = tmp53
	this.StartCode = tmp53
	if !(bytes.Equal(this.StartCode, []uint8{157, 1, 42})) {
		return kaitai.NewValidationNotEqualError([]uint8{157, 1, 42}, this.StartCode, this._io, "/types/vp8/seq/4")
	}
	tmp54, err := this._io.ReadBitsIntLe(14)
	if err != nil {
		return err
	}
	this.Width = tmp54
	tmp55, err := this._io.ReadBitsIntLe(2)
	if err != nil {
		return err
	}
	this.HorizontalScale = tmp55
	tmp56, err := this._io.ReadBitsIntLe(14)
	if err != nil {
		return err
	}
	this.Height = tmp56
	tmp57, err := this._io.ReadBitsIntLe(2)
	if err != nil {
		return err
	}
	this.VerticalScale = tmp57
	this._io.AlignToByte()
	tmp58, err := this._io.ReadBytesFull()
	if err != nil {
		return err
	}
	tmp58 = tmp58
	this.Data = tmp58
	return err
}

/**
 * @see <a href="https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification">Source</a>
 */
type Webp_Vp8l struct {
	Signature uint8
	ImageWidthMinus1 uint64
	ImageHeightMinus1 uint64
	AlphaIsUsed bool
	VersionNumber uint64
	Data []byte
	_io *kaitai.Stream
	_root *Webp
	_parent *Webp_Chunk
	_f_imageHeight bool
	imageHeight int
	_f_imageWidth bool
	imageWidth int
}
func NewWebp_Vp8l() *Webp_Vp8l {
	return &Webp_Vp8l{
	}
}

func (this Webp_Vp8l) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp_Vp8l) Read(io *kaitai.Stream, parent *Webp_Chunk, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp59, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.Signature = tmp59
	if !(this.Signature == 47) {
		return kaitai.NewValidationNotEqualError(47, this.Signature, this._io, "/types/vp8l/seq/0")
	}
	tmp60, err := this._io.ReadBitsIntLe(14)
	if err != nil {
		return err
	}
	this.ImageWidthMinus1 = tmp60
	tmp61, err := this._io.ReadBitsIntLe(14)
	if err != nil {
		return err
	}
	this.ImageHeightMinus1 = tmp61
	tmp62, err := this._io.ReadBitsIntLe(1)
	if err != nil {
		return err
	}
	this.AlphaIsUsed = tmp62 != 0
	tmp63, err := this._io.ReadBitsIntLe(3)
	if err != nil {
		return err
	}
	this.VersionNumber = tmp63
	if !(this.VersionNumber == 0) {
		return kaitai.NewValidationNotEqualError(0, this.VersionNumber, this._io, "/types/vp8l/seq/4")
	}
	this._io.AlignToByte()
	tmp64, err := this._io.ReadBytesFull()
	if err != nil {
		return err
	}
	tmp64 = tmp64
	this.Data = tmp64
	return err
}
func (this *Webp_Vp8l) ImageHeight() (v int, err error) {
	if (this._f_imageHeight) {
		return this.imageHeight, nil
	}
	this._f_imageHeight = true
	this.imageHeight = int(this.ImageHeightMinus1 + 1)
	return this.imageHeight, nil
}
func (this *Webp_Vp8l) ImageWidth() (v int, err error) {
	if (this._f_imageWidth) {
		return this.imageWidth, nil
	}
	this._f_imageWidth = true
	this.imageWidth = int(this.ImageWidthMinus1 + 1)
	return this.imageWidth, nil
}

/**
 * A hint only - it should not impact decoding. It should be `false` when
 * all alpha values are 255 in the picture, and `true` otherwise.
 */
type Webp_Vp8x struct {
	Reserved1 uint64
	IccProfile bool
	Alpha bool
	Exif bool
	Xmp bool
	Animation bool
	Reserved2 bool
	Reserved3 uint64
	CanvasWidthMinus1 uint64
	CanvasHeightMinus1 uint64
	_io *kaitai.Stream
	_root *Webp
	_parent *Webp_Chunk
	_f_canvasHeight bool
	canvasHeight int
	_f_canvasWidth bool
	canvasWidth int
}
func NewWebp_Vp8x() *Webp_Vp8x {
	return &Webp_Vp8x{
	}
}

func (this Webp_Vp8x) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp_Vp8x) Read(io *kaitai.Stream, parent *Webp_Chunk, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp65, err := this._io.ReadBitsIntBe(2)
	if err != nil {
		return err
	}
	this.Reserved1 = tmp65
	if !(this.Reserved1 == 0) {
		return kaitai.NewValidationNotEqualError(0, this.Reserved1, this._io, "/types/vp8x/seq/0")
	}
	tmp66, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.IccProfile = tmp66 != 0
	tmp67, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.Alpha = tmp67 != 0
	tmp68, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.Exif = tmp68 != 0
	tmp69, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.Xmp = tmp69 != 0
	tmp70, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.Animation = tmp70 != 0
	tmp71, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.Reserved2 = tmp71 != 0
	if !(this.Reserved2 == false) {
		return kaitai.NewValidationNotEqualError(false, this.Reserved2, this._io, "/types/vp8x/seq/6")
	}
	tmp72, err := this._io.ReadBitsIntBe(24)
	if err != nil {
		return err
	}
	this.Reserved3 = tmp72
	if !(this.Reserved3 == 0) {
		return kaitai.NewValidationNotEqualError(0, this.Reserved3, this._io, "/types/vp8x/seq/7")
	}
	tmp73, err := this._io.ReadBitsIntLe(24)
	if err != nil {
		return err
	}
	this.CanvasWidthMinus1 = tmp73
	tmp74, err := this._io.ReadBitsIntLe(24)
	if err != nil {
		return err
	}
	this.CanvasHeightMinus1 = tmp74
	tmp75, err := this.CanvasWidth()
	if err != nil {
		return err
	}
	tmp76, err := this.CanvasWidth()
	if err != nil {
		return err
	}
	if !(this.CanvasHeightMinus1 <= uint32(4294967295) / tmp75 - 1) {
		return kaitai.NewValidationGreaterThanError(uint32(4294967295) / tmp76 - 1, this.CanvasHeightMinus1, this._io, "/types/vp8x/seq/9")
	}
	return err
}
func (this *Webp_Vp8x) CanvasHeight() (v int, err error) {
	if (this._f_canvasHeight) {
		return this.canvasHeight, nil
	}
	this._f_canvasHeight = true
	this.canvasHeight = int(this.CanvasHeightMinus1 + 1)
	return this.canvasHeight, nil
}
func (this *Webp_Vp8x) CanvasWidth() (v int, err error) {
	if (this._f_canvasWidth) {
		return this.canvasWidth, nil
	}
	this._f_canvasWidth = true
	this.canvasWidth = int(this.CanvasWidthMinus1 + 1)
	return this.canvasWidth, nil
}
type Webp_Xmp struct {
	Data string
	_io *kaitai.Stream
	_root *Webp
	_parent *Webp_Chunk
}
func NewWebp_Xmp() *Webp_Xmp {
	return &Webp_Xmp{
	}
}

func (this Webp_Xmp) IO_() *kaitai.Stream {
	return this._io
}

func (this *Webp_Xmp) Read(io *kaitai.Stream, parent *Webp_Chunk, root *Webp) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp77, err := this._io.ReadBytesFull()
	if err != nil {
		return err
	}
	tmp77 = tmp77
	this.Data = string(tmp77)
	return err
}
