xvid

package module
v0.0.0-...-4966bb3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2019 License: MIT Imports: 8 Imported by: 0

README

go-xvid GoDoc stability-experimental

Go bindings for Xvid (libxvidcore) 1.3.X

Run with environment variable GODEBUG=cgocheck=0.

Usage

The API is well-documented in its GoDoc

A decoder and encoder as well as convert example are available in examples/ (must be run from the repo main directory, with GODEBUG=cgocheck=0).

You can also check the library source code and the Xvid source code (please open an issue if the library lacks documentation for your use case).

Status

Some tests run locally, not used in production environments yet.

The API could be slightly changed in backwards-incompatible ways for now.

  • Nearly all of xvidcore
  • Frame slice rendering

License

Disclaimer: IANAL/TINLA

TL;DR go-xvid is MIT-licensed, but if you build and redistribute the binaries of a program that uses xvid through go-xvid you must redistribute it as GPLv2.

The go-xvid source code files themselves do not copy or use any significant part of libxvidcore. By themselves the source code files are MIT-licensed as stated in the LICENSE file and solely belong to the copyright owners listed in the LICENSE files.

A piece of software that uses (statically links to) the go-xvid bindings will probably link (dynamically) to libxvidcore. If that is the case, and the program is to be redistributed, then per the GPLv2 license, that piece of software must be redistributed under the GPLv2 license (which includes distributing the source code of the program). (Actually under a license that is compatible with GPLv2, but there are almost none.)

Note that if you build a program that links against libxvidcore but you do not redistribute it (typically you use it as part of a server backend), you can use libxvidcore and go-xvid, even for commercial use, without sharing the source code of your program.

Documentation

Overview

go-xvid are Go bindings to xvidcore from Xvid 1.3.X (which uses the MPEG-4 Part 2, MPEG-4 Visual, ISO/IEC 14496-2 video codec standard). This library can encode a sequence of images to an encoded Xvid stream, decode images from an encoded Xvid stream, and convert images between different color spaces.

Xvid and containers

go-xvid only handles raw Xvid streams. Nearly all video files commonly found are stored in a media container, that encapsulate, but are not, raw Xvid video streams. go-xvid cannot decode or encode container data, and the raw video streams must be encapsulated or decapsulated.

Documentation

go-xvid tries to not abbreviate names and identifiers so that all the names used can easily be searched on the Internet when they are not known. This means that this documentation will not redefine or explain common codec concepts like macroblocks, quantizers, rate-control, and such. Most of the complex configuration structures can be initialized to sane default values in case the user is not familiar with advanced encoding concepts.

Initialization

Before any other function in the package can be called, Init or InitWithFlags must be called once to initialize all internal Xvid state. There is no Close method corresponding to the Init call.

As an exception, GetGlobalInfo, which returns general information about the runtime Xvid build, can be called at any time before and after Init.

Errors

go-xvid defines a specific error type, Error, which is used to represent internal xvidcore errors.

Images

Images in go-xvid is stored in the Image structure, which stores both an image color space and its data as an array of planes, which are themselves arrays of data. Each plane has a specific stride. The classic RGBA color space has only one plane and data array but some color spaces can have up to three. See Image for more information.

Images can be converted from one color space to another with the Convert function.

Decoding

go-xvid can decode a sequence of images from a raw encoded Xvid stream. Decoder is the struct used to decode from a stream. A Decoder is created with NewDecoder, which takes a DecoderInit configuration struct to initialize it.

Once created, Decoder.Decode can be called in a loop to decode a single frame at a time until the entire stream has been processed. Each decoded frame contains extra statistics returned by Decoder.Decode.

When the Decoder is no longer needed, it must be closed with Decoder.Close to free any internal data.

Encoding

go-xvid can encode a sequence of images to a raw encoded Xvid stream. Encoder is the struct used to encode from a stream. An Encoder is created with NewEncoder, which takes an EncoderInit configuration struct to initialize it, which itself should be initialized with NewEncoderInit to sane default values.

Once created, Encoder.Encode can be called in a loop to encode a single image at a time until all the images have been processed. Each encoded frame contains extra statistics returned by Encoder.Encode.

When the Encoder is no longer needed, it must be closed with Encoder.Close to free any internal data.

Plugins

Plugins are used to read and write internal frame data when encoding. Some standard plugins are defined in the library but custom ones can be created by implementing the Plugin interface.

In Xvid, rate-control is achieved by using plugins (for both 1-pass rate-control and 2-pass rate-control). You will probably need to use one of these rate-control plugins when encoding (otherwise the smallest quantizer is always used).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BufferSize

func BufferSize(width int, height int) int

BufferSize returns the minimal output buffer size for encoding a frame. The Output buffer of an EncoderFrame will automatically be reallocated to this size if it is smaller.

func Convert

func Convert(input Image, output *Image, width int, height int, interlacing bool) error

Converts converts an Image from a color space (has to be ColorSpacePlanar or ColorSpaceYV12) to any other but ColorSpaceInternal. Init (or InitWithFlags) must be called once before calling this function. An error can be returned because of invalid input or output images, or due to an internal Xvid error.

func Init

func Init() error

Init initializes Xvid and must be called once before calling any other method, except GetGlobalInfo. Alternatively InitWithFlags can be used to specify custom CPU and debug flags. Init uses all the available CPU features and doesn't enable any debug. If an error is returned, initialization failed and no further Xvid functions are expected to work. There is no global Close() function corresponding to Init.

func InitWithFlags

func InitWithFlags(cpuFlags CPUFlag, debugFlags DebugFlag) error

InitWithFlags initializes Xvid and must be called once before calling any other method, except GetGlobalInfo. Alternatively Init can be used to initialize with all available CPU features and no debug. If an error is returned, initialization failed and no further Xvid functions are expected to work. There is no global Close() function corresponding to InitWithFlags.

Types

type BFrameQuantizer

type BFrameQuantizer struct {
	// ratio in percent (see formula); default is 150
	Ratio int
	// offset in 0.01 units (see formula); default is 100
	Offset int
}

BFrameQuantizer stores parameters for choosing B-frames quantizers. The actual formula used is:

quantizer = (average(pastReferenceQuantizer, futureReferenceQuantizer) * Ratio + Offset) / 100

type CPUFlag

type CPUFlag uint

CPUFlag is a flag (or a bitwise-or union of flags) for CPU-specific features.

const (
	CPU_ASM      CPUFlag = C.XVID_CPU_ASM
	CPU_MMX      CPUFlag = C.XVID_CPU_MMX
	CPU_MMXEXT   CPUFlag = C.XVID_CPU_MMXEXT
	CPU_SSE      CPUFlag = C.XVID_CPU_SSE
	CPU_SSE2     CPUFlag = C.XVID_CPU_SSE2
	CPU_SSE3     CPUFlag = C.XVID_CPU_SSE3
	CPU_SSE41    CPUFlag = C.XVID_CPU_SSE41
	CPU_3DNOW    CPUFlag = C.XVID_CPU_3DNOW
	CPU_3DNOWEXT CPUFlag = C.XVID_CPU_3DNOWEXT
	CPU_TSC      CPUFlag = C.XVID_CPU_TSC
)

type ColorSpace

type ColorSpace struct {

	// number of image planes for colorspace
	Planes int
	// number of strides for colorspace
	Strides int
	// bits per pixel average (over all planes)
	BitsPerPixel int
	// bits per pixel for each plane
	BitsPerPixelPlanes []int
	// contains filtered or unexported fields
}

ColorSpace is the color space of an Image. See https://fourcc.org/yuv.php for details about each color space.

var (
	// YUV 4:2:0 planar, like ColorSpaceI420 but with 3 buffers,
	// planes[0] is Y, planes[1] is U, planes[2] is V;
	// stride[0] is Y stride, stride[1] is U/V stride
	ColorSpacePlanar ColorSpace = ColorSpace{
		Planes:             3,
		Strides:            2,
		BitsPerPixel:       12,
		BitsPerPixelPlanes: []int{8, 2, 2},
		// contains filtered or unexported fields
	}
	// YUV 4:2:0 planar, packed as YUV, FourCC I420
	// stride[0] is Y stride, U and V stride are stride[0]/2
	ColorSpaceI420 ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       12,
		BitsPerPixelPlanes: []int{12},
		// contains filtered or unexported fields
	}
	// YUV 4:2:0 planar, packed as YVU, FourCC YV12
	// stride[0] is Y stride, U and V stride are stride[0]/2
	ColorSpaceYV12 ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       12,
		BitsPerPixelPlanes: []int{12},
		// contains filtered or unexported fields
	}
	// YUV 4:2:2 packed, FourCC YUY2
	ColorSpaceYUY2 ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       16,
		BitsPerPixelPlanes: []int{16},
		// contains filtered or unexported fields
	}
	// YUV 4:2:2 packed, FourCC UYVY
	ColorSpaceUYVY ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       16,
		BitsPerPixelPlanes: []int{16},
		// contains filtered or unexported fields
	}
	// YUV 4:2:2 packed, FourCC YVYU
	ColorSpaceYVYU ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       16,
		BitsPerPixelPlanes: []int{16},
		// contains filtered or unexported fields
	}
	// 24-bit RGB packed
	ColorSpaceRGB ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       24,
		BitsPerPixelPlanes: []int{24},
		// contains filtered or unexported fields
	}
	// 32-bit BGRA packed
	ColorSpaceBGRA ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       32,
		BitsPerPixelPlanes: []int{32},
		// contains filtered or unexported fields
	}
	// 32-bit ABGR packed
	ColorSpaceABGR ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       32,
		BitsPerPixelPlanes: []int{32},
		// contains filtered or unexported fields
	}
	// 32-bit RGBA packed
	ColorSpaceRGBA ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       32,
		BitsPerPixelPlanes: []int{32},
		// contains filtered or unexported fields
	}
	// 32-bit ARGB packed
	ColorSpaceARGB ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       32,
		BitsPerPixelPlanes: []int{32},
		// contains filtered or unexported fields
	}
	// 24-bit BGR packed
	ColorSpaceBGR ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       24,
		BitsPerPixelPlanes: []int{24},
		// contains filtered or unexported fields
	}
	// 16-bit RGB555 packed
	ColorSpaceRGB555 ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       16,
		BitsPerPixelPlanes: []int{16},
		// contains filtered or unexported fields
	}
	// 16-bit RGB565 packed
	ColorSpaceRGB565 ColorSpace = ColorSpace{
		Planes:             1,
		Strides:            1,
		BitsPerPixel:       16,
		BitsPerPixelPlanes: []int{16},
		// contains filtered or unexported fields
	}
	// only for decoding: YUV 4:2:0 planar, but uses internal decoder buffers and strides rather than copying to a buffer; invalid after any call to a Decoder method
	ColorSpaceInternal ColorSpace = ColorSpace{
		Planes:             3,
		Strides:            2,
		BitsPerPixel:       12,
		BitsPerPixelPlanes: []int{8, 2, 2},
		// contains filtered or unexported fields
	}
	// only for decoding: don't output anything
	ColorSpaceNoOutput ColorSpace = ColorSpace{BitsPerPixelPlanes: []int{}, /* contains filtered or unexported fields */}
)

type DebugFlag

type DebugFlag uint

DebugFlag is a flag (or a bitwise-or union of flags) for printing of specific types of debug messages to standard error.

const (
	DebugError         DebugFlag = C.XVID_DEBUG_ERROR
	DebugStartCode     DebugFlag = C.XVID_DEBUG_STARTCODE
	DebugHeader        DebugFlag = C.XVID_DEBUG_HEADER
	DebugTimecode      DebugFlag = C.XVID_DEBUG_TIMECODE
	DebugMacroBlocks   DebugFlag = C.XVID_DEBUG_MB
	DebugCoefficients  DebugFlag = C.XVID_DEBUG_COEFF
	DebugMotionVectors DebugFlag = C.XVID_DEBUG_MV
	DebugRateControl   DebugFlag = C.XVID_DEBUG_RC
)
var DebugDebug DebugFlag = DebugFlag(C.DEBUG_DEBUG)

type Decoder

type Decoder struct {
	// current frame width in pixels
	Width int
	// current frame height in pixels
	Height int
	// contains filtered or unexported fields
}

Decoder is an initialized Xvid decoder. To create a Decoder, use NewDecoder. A Decoder must be closed after use, by calling its Close method. To decode a frame, use the Decode method.

func NewDecoder

func NewDecoder(init DecoderInit) (*Decoder, error)

NewDecoder creates a new Decoder based on a DecoderInit configuration. Init (or InitWithFlags) must be called once before calling this function. Once created and finished using, a Decoder must be freed by calling Decoder.Close(). The Decoder is non-nil if and only if the returned error is nil. An internal error can be returned by Xvid, in which case the Decoder won't be created.

func (*Decoder) Close

func (d *Decoder) Close()

Close closes any internal resources specific to the Decoder. It must be called exactly once per Decoder and no other methods of the Decoder must be called after Close.

func (*Decoder) Decode

func (d *Decoder) Decode(frame DecoderFrame) (int, DecoderStats, error)

Decode decodes a single non-empty frame (either metadata (VOL) or an actual frame) from the encoded Xvid stream.

Decode returns an int, which is the length in bytes of the frame that was read. Decode might buffer up data from its Reader so the returned value might be less than the actual data read.

Decode returns a DecoderStats, which stores information about the decoded frame, which can be either a VOL (metadata), or an actual frame. If Decoder returns a non-nil error, DecoderStats in invalid.

Decode returns an error, which if it is not nil can be either io.EOF or another error. If it is io.EOF, this is an expected value which means that the entire stream has been decoded. Otherwise, it is an unexpected value, which can be due to invalid images, reader i/o errors, or internal Xvid errors.

In any case, the Decoder should not be used after any error and Decode will always return the same error after an error occurs. The Decoder must still be closed with Close.

type DecoderFlag

type DecoderFlag uint

DecoderFlag is a flag (or a bitwise-or union of flags) for decoding a frame, set in each frame.

const (
	// lowdelay mode
	DecoderLowDelay DecoderFlag = C.XVID_LOWDELAY
	// indicate break/discontinuity in streaming
	DecoderDiscontinuity DecoderFlag = C.XVID_DISCONTINUITY
	// perform luma deblocking
	DecoderDeblockLuma DecoderFlag = C.XVID_DEBLOCKY
	// perform chroma deblocking
	DecoderDeblockChroma DecoderFlag = C.XVID_DEBLOCKUV
	// perform luma deringing, requires deblocking to work
	DecoderDeringLuma DecoderFlag = C.XVID_DERINGY
	// perform chroma deringing, requires deblocking to work
	DecoderDeringChroma DecoderFlag = C.XVID_DERINGUV
	// adds film grain
	DecoderFilmGrain DecoderFlag = C.XVID_FILMEFFECT
)

type DecoderFrame

type DecoderFrame struct {
	// output image to store the decoded data to
	Output *Image
	// optional decoder flags to use for decoding the frame
	DecodeFlags DecoderFlag
	// optional brightness offset, 0 meaning no offset
	Brightness int
}

DecoderFrame is information used when decoding a frame in Decoder.Decode.

type DecoderInit

type DecoderInit struct {
	// Reader from which to read encoded frame data.
	// the Reader will not be closed automatically, it has to be caller-closed after the Decoder is finished.
	Input io.Reader
	// optional initial frame width in pixels (can be automatically detected by the Decoder)
	Width int
	// optional initial frame height in pixels (can be automatically detected by the Decoder)
	Height int
	// optional FourCC code of the raw Xvid stream
	FourCC int
	// optional number of threads to use for decoding, 0 meaning single-threaded
	NumThreads int
}

DecoderInit is information used to create a Decoder in NewDecoder. Its Input field must be set to the Reader from which to read an encoded raw Xvid stream data from.

type DecoderStats

type DecoderStats struct {
	// type of the decoded frame
	FrameType FrameType
	// non-nil if the frame type is FrameTypeVOL
	StatsVOL *DecoderStatsVOL
	// non-nil if the frame type is not FrameTypeVOL
	StatsFrame *DecoderStatsFrame
}

DecoderStats is information about a decoded frame, returned by Decoder.Decode. If the frame is a metadata pseudo-frame (VOL), StatsVOL is not nil, otherwise StatsFrame is not nil.

type DecoderStatsFrame

type DecoderStatsFrame struct {
	// valid only for interlaced frames (see DecoderStatsVOL.Interlacing), whether the interlacing is upper field first
	UpperFieldFirst bool
	// macroblock quantizers table (one quantizer per macroblock), can be nil
	Quantizers []int32
	// quantizers table stride (equal to the count of macroblocks in a line)
	QuantizersStride int
}

DecoderStatsFrame is information specific to an actual non-metadata non-empty frame, returned by Decoder.Decode in DecoderStats.

type DecoderStatsVOL

type DecoderStatsVOL struct {
	// whether the frame is interlaced
	Interlacing bool
	// frame width in pixels
	Width int
	// frame height in pixels
	Height int
	// frame pixel aspect ratio
	PixelAspectRatio PixelAspectRatio
}

DecoderStatsVOL is information specific to a metadata pseudo-frame, returned by Decoder.Decode in DecoderStats.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder is an initialized Xvid encoder. To create a Encoder, use NewEncoder. An Encoder must be closed after use, by calling its Close method. To encode a frame, use the Encode method.

func NewEncoder

func NewEncoder(init *EncoderInit) (*Encoder, error)

NewEncoder creates a new Encoder based on a EncoderInit configuration. Init (or InitWithFlags) must be called once before calling this function. Once created and finished using, an Encoder must be freed by calling Encoder.Close(). The Encoder is non-nil if and only if the returned error is nil. An internal error can be returned by Xvid, in which case the Encoder won't be created.

func (*Encoder) Close

func (e *Encoder) Close()

Close closes any internal resources specific to the Encoder. It must be called exactly once per Encoder and no other methods of the Encoder must be called after Close.

func (*Encoder) Encode

func (e *Encoder) Encode(frame EncoderFrame) (int, *EncoderStats, error)

Encode encodes a single Image to an encoded Xvid stream.

Encode returns an int, which is the length in bytes of the frame that was written. The Encoder might write data and return a non-zero int even if no frame was written (even if EncoderStats is nil).

Encode returns an EncoderStats, which stores information about the encoded frame, which can be either a VOL (metadata), an actual frame, or nil. nil means that no frame was encoded, even though some data may be written (and int could be > 0) as Xvid can sometimes buffer frame data internally or write part of a frame to the stream.

Encode returns an error, which if not nil can be due to invalid images, or internal Xvid errors.

In most cases, the Encode should not be used after an error occurs. The Encode must still be closed with Close.

type EncoderFlag

type EncoderFlag uint

EncoderFlag is a flag (or a bitwise-or union of flags) for encoding frames, set in Encoder.Init.

const (
	// packed B-frames; strongly discouraged
	EncoderPacked EncoderFlag = C.XVID_GLOBAL_PACKED
	// closed GOP
	EncoderClosedGOP EncoderFlag = C.XVID_GLOBAL_CLOSED_GOP
	// require plugins to use the original image for PSNR calculation
	EncoderEnableExtraStats EncoderFlag = C.XVID_GLOBAL_EXTRASTATS_ENABLE
	// write DivX5 userdata string, implied by EncoderPacked
	EncoderWriteDivX5UserData EncoderFlag = C.XVID_GLOBAL_DIVX5_USERDATA
)

type EncoderFrame

type EncoderFrame struct {
	// input image to encode
	Input *Image
	// buffer to store the encoded frame data into, if pointing to a nil or too small slice, will realloc it to the minimum buffer size as returned by BufferSize
	Output *[]byte

	// optional flags for the next group of pictures; the encoder will not react to any changes until the next VOL (keyframe)
	VOLFlags VOLFlag
	// optional 8x8 row-major quantizer matrix for intraframe encoding
	QuantizerIntraMatrix []uint8
	// optional 8x8 row-major quantizer matrix for interframe encoding
	QuantizerInterMatrix []uint8
	// optional pixel aspect ratio, defaults to square pixel
	PixelAspectRatio PixelAspectRatio

	// optional; sets the frame rate by changing the Denominator of the frame rate fraction defined in Init; default means unchanged frame rate
	FrameRateDenominator int
	// optional encoding flags for this frame
	VOPFlags VOPFlag
	// optional motion estimation flags for this frame
	MotionFlags MotionFlag

	// optional forced type for this frame, defaults to FrameTypeAuto
	Type FrameType
	// optional quantizer for this frame, 0 defaults to automatic rate-controlled quantizer, recommended range is 2-31
	Quantizer int
	// optional adjustment for choosing between encoding a P-frame or a B-frame; > 0 means more B-frames, <0 means less B-frames
	BFrameThreshold int
}

EncoderFrame is information used when encoding a frame in Encoder.Encode. Its only required fields are the Input Image and its Output buffer.

type EncoderInit

type EncoderInit struct {
	// frame width in pixels
	Width int
	// frame height in pixels
	Height int

	// optional encoder profile; default is EncoderAuto for automatic profile selection
	Profile EncoderProfile
	// optional encoder bitrate zones, that enforce a specific parameter for a range of frames; must be sorted in increasing frame start order
	Zones []EncoderZone
	// optional encoder plugins
	Plugins []Plugin
	// optional number of threads to use for encoding, 0 means single-threaded; default is GetGlobalInfo().NumThreads-1
	NumThreads int
	// optional maximum sequential B-frames, 0 means disabling B-frames; default is 2
	MaxBFrames int
	// optional global encoder flags; default is no flags
	Flags EncoderFlag

	// framerate; Numerator=0 means variable framerate; only the Denominator can be changed after initialization
	FrameRate Fraction

	// optional maximum interval between key frames; default is 300
	MaxKeyFrameInterval int
	// optional frame dropping ratio in percent between 0 (drop none) to 100 (drop all); default is 0
	FrameDropRatio int

	// optional B-frames quantizer multipier/offset; used to decide B-frames quantizer when automatic quantizer is used
	BFrameQuantizer BFrameQuantizer

	// optional quantizer range for I frames
	QuantizerI QuantizerRange
	// optional quantizer range for P frames
	QuantizerP QuantizerRange
	// optional quantizer range for B frames
	QuantizerB QuantizerRange

	// optional starting frame number, relative to the zones start frames; default is 0
	StartFrameNumber int
	// optional number of slices to encode for each frame; default is 0, meaning 1 slice
	NumSlices int
}

EncoderInit is information used to create an Encoder in NewEncoder. To initialize an EncoderInit with default values, use NewEncoderInit.

func NewEncoderInit

func NewEncoderInit(width int, height int, frameRate Fraction, plugins []Plugin) *EncoderInit

NewEncoderInit returns an EncoderInit initialized with the default encoding parameters.

In Xvid rate-control is done with plugins: either 1-pass with PluginRC1Pass, or 2-pass with PluginRC2Pass1 (on the first pass) and PluginRC2Pass2 (on the second pass).

type EncoderProfile

type EncoderProfile uint

EncoderProfile is a profile (and level) used for encoding; should be set to EncoderProfileAuto to detect automatically.

const (
	// automatically choose profile
	EncoderProfileAuto EncoderProfile = 0
	// simple profile, level L0
	EncoderProfileS_L0 EncoderProfile = C.XVID_PROFILE_S_L0
	// simple profile, level L1
	EncoderProfileS_L1 EncoderProfile = C.XVID_PROFILE_S_L1
	// simple profile, level L2
	EncoderProfileS_L2 EncoderProfile = C.XVID_PROFILE_S_L2
	// simple profile, level L3
	EncoderProfileS_L3 EncoderProfile = C.XVID_PROFILE_S_L3
	// simple profile, level L4a
	EncoderProfileS_L4A EncoderProfile = C.XVID_PROFILE_S_L4a
	// simple profile, level L5
	EncoderProfileS_L5 EncoderProfile = C.XVID_PROFILE_S_L5
	// simple profile, level L6
	EncoderProfileS_L6 EncoderProfile = C.XVID_PROFILE_S_L6
	// advanced real-time simple profile, level L1
	EncoderProfileARTS_L1 EncoderProfile = C.XVID_PROFILE_ARTS_L1
	// advanced real-time simple profile, level L2
	EncoderProfileARTS_L2 EncoderProfile = C.XVID_PROFILE_ARTS_L2
	// advanced real-time simple profile, level L3
	EncoderProfileARTS_L3 EncoderProfile = C.XVID_PROFILE_ARTS_L3
	// advanced real-time simple profile, level L4
	EncoderProfileARTS_L4 EncoderProfile = C.XVID_PROFILE_ARTS_L4
	// advanced simple profile, level L0
	EncoderProfileAS_L0 EncoderProfile = C.XVID_PROFILE_AS_L0
	// advanced simple profile, level L1
	EncoderProfileAS_L1 EncoderProfile = C.XVID_PROFILE_AS_L1
	// advanced simple profile, level L2
	EncoderProfileAS_L2 EncoderProfile = C.XVID_PROFILE_AS_L2
	// advanced simple profile, level L3
	EncoderProfileAS_L3 EncoderProfile = C.XVID_PROFILE_AS_L3
	// advanced simple profile, level L4
	EncoderProfileAS_L4 EncoderProfile = C.XVID_PROFILE_AS_L4
)

type EncoderStats

type EncoderStats struct {
	// frame type of the encoded frame
	FrameType FrameType
	// whether this frame was encoded as an I frame
	KeyFrame bool
	// quantizer used for the frame
	Quantizer int
	// actual VOL flags used for the frame
	VOLFlags VOLFlag
	// actual VOP flags used for the frame
	VOPFlags VOPFlag
	// length of frame in bytes
	Length int
	// length of frame header in bytes
	HeaderLength int
	// number of blocks coded as intra
	IntraBlocks int
	// number of blocks coded as inter
	InterBlocks int
	// number of blocks not coded
	UncodedBlocks int

	// only present if VOLExtraStats is set; Y plane SSE
	SSEY int
	// only present if VOLExtraStats is set; U plane SSE
	SSEU int
	// only present if VOLExtraStats is set; V plane SSE
	SSEV int
}

EncoderStats is information about an encoded frame, returned by Encoder.Encode.

type EncoderZone

type EncoderZone struct {
	// start frame (inclusive) of the zone
	Frame int
	// zone type
	Mode ZoneType
	// value, meaning depends on the ZoneType used
	Value Fraction
}

EncoderZone is a bitrate enforcement zone used for encoding, which applies during a range of frames, starting on its Frame (inclusive) and ending on the next EncoderZone frame (exclusive).

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is an internal Xvid error, which can be returned by most go-xvid functions.

func (*Error) Error

func (e *Error) Error() string

type Fraction

type Fraction struct {
	Numerator int
	// must not be 0
	Denominator int
}

Fraction is an exact integer fraction to represent a decimal number without precision loss.

func (Fraction) Float

func (f Fraction) Float() float32

Float returns the actual value of a fraction, which is Numerator / Denominator

type FrameType

type FrameType int

FrameType is the type of a frame that was decoded [D], that was encoded (in EncodeStats) [E], or to be encoded [S]. Each fields description has a set of letters to show when the field is used.

const (
	// [D] VOL (metadata) was decoded
	FrameTypeVOL FrameType = C.XVID_TYPE_VOL
	// [S] automatically determine coding type
	FrameTypeAuto FrameType = C.XVID_TYPE_AUTO
	// [D,E,S] intra frame
	FrameTypeI FrameType = C.XVID_TYPE_IVOP
	// [D,E,S] predicted frame
	FrameTypeP FrameType = C.XVID_TYPE_PVOP
	// [D,E,S] bidirectionally encoded
	FrameTypeB FrameType = C.XVID_TYPE_BVOP
	// [D,E,S] predicted+sprite frame
	FrameTypeS FrameType = C.XVID_TYPE_SVOP
)

type GlobalInfo

type GlobalInfo struct {
	// runtime version of xvidcore
	Version Version
	// runtime build string of xvidcore
	Build string
	// supported cpu features found
	CPUFlags CPUFlag
	// count of system threads found
	NumThreads int
}

GlobalInfo stores global information about Xvid, obtained from GetGlobalInfo.

func GetGlobalInfo

func GetGlobalInfo() (*GlobalInfo, error)

GetGlobalInfo returns global information about Xvid, can be called before any Init method. If an error is returned, no further Xvid functions are expected to work.

type Image

type Image struct {
	// image color space, determines the number of planes
	Colorspace ColorSpace
	// whether to flip the image vertically, during converting (only set on the output image), decoding, or encoding
	VerticalFlip bool
	// image planes, each plane contains image data
	Planes [][]byte
	// planes strides (bytes per row)
	Strides []int
}

Image represents an input or output image data and its color space.

The data is stored in multiple buffers, one per image plane; each plane has a specific stride (data size in bytes per line).

When used as input, ColorSpace must be set to the actual color space of the image data; Planes and Strides must contain at least as many planes as the ColorSpace.Planes count, and each plane must contain enough image data (corresponding to the image bounds, color space, and stride). Strides can be set to 0 to assume compact data.

When used as output, ColorSpace must be set to the desired color space of the image data; xvid will automatically convert the data from its internal color space to the target one. Planes can be nil, in which case it will be created to contain the output data; if it is not nil it must contain at least as many planes as the ColorSpace.Planes count. Each plane can be nil, in which case it will be created to contain the output data; if it is not nil it must contain enough image data (corresponding to the image bounds, color space, and stride). Strides can be nil, in which case it will be created and filled with zeroes. Each stride can be 0, in which case the value will be replaced with the actual data size per line, to have compact data.

When used as output with the special ColorSpaceInternal color space, the strides will be ignored and replaced with the actual internal encoder buffer strides; and the planes buffers will be ignored and replaced with the internal encoder buffers. The data is valid until the next call to any of the Encoder methods.

type MaskingMethod

type MaskingMethod uint

MaskingMethod is a method used for lumi-masking (adaptive quantization).

const (
	// luminance masking
	MaskingLuminance MaskingMethod = 0
	// variance masking
	MaskingVariance MaskingMethod = 1
)

type MotionFlag

type MotionFlag uint

MotionFlag is a flag (or a bitwise-or union of flags) of motion estimation flags for encoding a single frame, set in Encoder.Encode.

const (

	// use advdiamonds instead of diamonds as search pattern
	MotionAdvancedDiamond16 MotionFlag = C.XVID_ME_ADVANCEDDIAMOND16
	// use advdiamond for MotionExtendSearch8
	MotionAdvancedDiamond8 MotionFlag = C.XVID_ME_ADVANCEDDIAMOND8
	// use squares instead of diamonds as search pattern
	MotionUseSquares16 MotionFlag = C.XVID_ME_USESQUARES16
	// use square for MotionExtendSearch8
	MotionUseSquares8 MotionFlag = C.XVID_ME_USESQUARES8

	MotionHalfPixelRefine16    MotionFlag = C.XVID_ME_HALFPELREFINE16
	MotionHalfPixelRefine8     MotionFlag = C.XVID_ME_HALFPELREFINE8
	MotionQuarterPixelRefine16 MotionFlag = C.XVID_ME_QUARTERPELREFINE16
	MotionQuarterPixelRefine8  MotionFlag = C.XVID_ME_QUARTERPELREFINE8
	MotionGMERefine            MotionFlag = C.XVID_ME_GME_REFINE
	// extend PMV by more searches
	MotionExtendSearch16 MotionFlag = C.XVID_ME_EXTSEARCH16
	// use diamond/square for extended 8x8 search
	MotionExtendSearch8 MotionFlag = C.XVID_ME_EXTSEARCH8
	// also use chroma for P_VOP/S_VOP ME
	MotionChromaPFrame MotionFlag = C.XVID_ME_CHROMA_PVOP
	// also use chroma for B_VOP ME
	MotionChromaBFrame MotionFlag = C.XVID_ME_CHROMA_BVOP
	// use low-complexity refinement functions
	MotionFastRefine16 MotionFlag = C.XVID_ME_FASTREFINE16
	// low-complexity 8x8 sub-block refinement
	MotionFastRefine8 MotionFlag = C.XVID_ME_FASTREFINE8

	// only valid with VOPModeDecisionRD, perform RD-based halfpel refinement
	MotionHalfPixelRefine16RD MotionFlag = C.XVID_ME_HALFPELREFINE16_RD
	// only valid with VOPModeDecisionRD, perform RD-based halfpel refinement for 8x8 mode
	MotionHalfPixelRefine8RD MotionFlag = C.XVID_ME_HALFPELREFINE8_RD
	// only valid with VOPModeDecisionRD, perform RD-based qpel refinement
	MotionQuarterPixelRefine16RD MotionFlag = C.XVID_ME_QUARTERPELREFINE16_RD
	// only valid with VOPModeDecisionRD, perform RD-based qpel refinement for 8x8 mode
	MotionQuarterPixelRefine8RD MotionFlag = C.XVID_ME_QUARTERPELREFINE8_RD
	// only valid with VOPModeDecisionRD, perform RD-based search using square pattern enable XVID_ME_EXTSEARCH8 to do this in 8x8 search as well
	MotionExtendSearchRD MotionFlag = C.XVID_ME_EXTSEARCH_RD
	// only valid with VOPModeDecisionRD, always check vector equal to prediction
	MotionCheckPredictionRD MotionFlag = C.XVID_ME_CHECKPREDICTION_RD

	// speed-up ME by detecting stationary scenes
	MotionDetectStaticMotion MotionFlag = C.XVID_ME_DETECT_STATIC_MOTION
	// speed-up by skipping b-frame delta search
	MotionSkipDeltaSearch MotionFlag = C.XVID_ME_SKIP_DELTASEARCH
	// speed-up by partly skipping interpolate mode
	MotionFastModeInterpolate MotionFlag = C.XVID_ME_FAST_MODEINTERPOLATE
	// speed-up by early exiting b-search
	MotionBFrameEarlyStop MotionFlag = C.XVID_ME_BFRAME_EARLYSTOP
)

type PixelAspectRatio

type PixelAspectRatio struct {
	// pixel width ratio
	Width int
	// pixel height ratio
	Height int
	// contains filtered or unexported fields
}

PixelAspectRatio is a frame pixel aspect ratio (PAR), given as an integer fraction of a pixel width and height. There are both standard frame pixel aspect ratios, defined in go-xvid, and user-defined pixel aspect ratios, which can be unexact due to precision loss (clamped to [1, 255]).

var (
	// square pixel
	PixelAspectRatio11VGA PixelAspectRatio = PixelAspectRatio{1, 1, C.XVID_PAR_11_VGA}
	// 12:11 pixel (seldom used in 4:3 pal 625-line)
	PixelAspectRatio43PAL PixelAspectRatio = PixelAspectRatio{12, 11, C.XVID_PAR_43_PAL}
	// 10:11 pixel (seldom used in 4:3 pal 525-line)
	PixelAspectRatio43NTSC PixelAspectRatio = PixelAspectRatio{10, 11, C.XVID_PAR_43_NTSC}
	// 16:11 pixel (seldom used in 16:9 pal 625-line)
	PixelAspectRatio169PAL PixelAspectRatio = PixelAspectRatio{16, 11, C.XVID_PAR_169_PAL}
	// 40:33 pixel (seldom used in 16:9 ntsc 525-line)
	PixelAspectRatio169NTSC PixelAspectRatio = PixelAspectRatio{40, 33, C.XVID_PAR_169_NTSC}
)

type Plugin

type Plugin interface {
	// called during Encoder.Init
	// return the information the plugins needs
	Info() PluginFlag
	// called during Encoder.Init to init the plugin (any startup setup should be done here)
	// return false to disable the plugin for an Encoder
	Init(create PluginInit) bool
	// called during Encoder.Close to close any open plugin resources
	Close(close PluginClose)

	// called during Encoder.Encode, before starting to encode a frame
	Before(data *PluginData)
	// called during Encoder.Encode, while encoding a frame
	Frame(data *PluginData)
	// called during Encoder.Encode, after encoding a frame
	After(data *PluginData)
}

Plugin is an Xvid plugin that is used during the encoding process as a callback for both read and write operations to some internal frame encoding data. Plugins are used in the Encoder methods.

Some default plugins are provided, which include 1-pass and 2-pass rate control.

Custom plugins can also be created by implementing the Plugin interface.

func PluginAdaptiveQuantization

func PluginAdaptiveQuantization(method MaskingMethod) Plugin

PluginAdaptiveQuantization returns an instance of the adaptive quantization plugin (also-called lumi-masking).

func PluginDump

func PluginDump() Plugin

PluginDump returns an instance of a plugin that writes original and encoded image data to files in YUV in PGM format in the working directory.

func PluginPSNR

func PluginPSNR() Plugin

PluginPSNR returns an instance of a plugin that writes PSNR values to the standard output.

func PluginPSNRHVSM

func PluginPSNRHVSM() Plugin

PluginPSNRHVSM returns an instance of a plugin that writes PSNRHVSM values to the standard output.

func PluginRC1Pass

func PluginRC1Pass(init PluginRC1PassInit) Plugin

PluginRC1Pass returns an instance of the 1-pass rate-control plugin, to be used in NewEncoder. This plugin will choose specific quantizers to try to match the bitrate parameters.

func PluginRC2Pass1

func PluginRC2Pass1(filename string) Plugin

PluginRC2Pass1 returns an instance of the 2-pass rate-control plugin for the first pass. To do 2-pass rate-control in Xvid, encode the same images twice, in the first run using the PluginRC2Pass1 plugin, and in the second run using the PluginRC2Pass2 plugin.

PluginRC2Pass1 takes a filename which is used to store the rate-control information (the file will be overwritten). If the file writing fails, Xvid will not return errors, so you can check for the file existence yourself after the encoding ends.

func PluginRC2Pass2

func PluginRC2Pass2(init PluginRC2Pass2Init) Plugin

PluginRC2Pass2 returns an instance of the 2-pass rate-control plugin for the second pass. To do 2-pass rate-control in Xvid, encode the same images twice, in the first run using the PluginRC2Pass1 plugin, and in the second run using the PluginRC2Pass2 plugin.

func PluginSSIM

func PluginSSIM(init PluginSSIMInit) Plugin

PluginSSIM returns an instance of a plugin that writes SSIM values to the standard output or to a file.

type PluginClose

type PluginClose struct {
	// total count of encoded frames
	NumFrames int
}

PluginClose stores information for an encoding session, used for reading by plugins in their Close callback.

type PluginData

type PluginData struct {
	// [BR,FR,AR] current encoder zone, or nil if none
	Zone *EncoderZone
	// [BR,FR,AR] frame width in pixels
	Width int
	// [BR,FR,AR] frame height in pixels
	Height int
	// [BR,FR,AR] frame width in macro blocks
	WidthMacroBlocks int
	// [BR,FR,AR] frame height in macro blocks
	HeightMacroBlocks int
	// [BR,FR,AR] framerate; Numerator=0 means variable framerate
	FrameRate Fraction
	// [BR,FR,AR] quantizer range for I frames
	QuantizerI QuantizerRange
	// [BR,FR,AR] quantizer range for P frames
	QuantizerP QuantizerRange
	// [BR,FR,AR] quantizer range for B frames
	QuantizerB QuantizerRange
	// [BR,FR,AR] frame number
	FrameNum int
	// [BR,FR,AR] reference frame
	Reference Image
	// [BR,FR,AR] current frame
	Current Image
	// [AR] the original (uncompressed) copy of the current frame
	Original Image
	// [BR,FR,AR,BW] type of this frame
	Type FrameType
	// [BR,FR,AR,BW,FW] quantizer used for this frame
	Quantizer int
	// [AR,FW] diff quantizers for this frame, only present if PluginRequireDiffQuantizer was set during Info()
	DiffQuantizers []int
	// [FR,AR] diff quantizers stride (quantizers per row), only set if PluginRequireDiffQuantizer was set during Info()
	DiffQuantizersStride int
	// [BR,AR,BW] actual group of pictures flags
	VOLFlags VOLFlag
	// [BR,AR,BW] encoding flags for this frame
	VOPFlags VOPFlag
	// [BR,AR,BW] motion estimation flags for this frame
	MotionFlags MotionFlag
	// [FW] lambda table for this frame, only present if PluginRequireLambda was set during Info(); six floats for each macroblock
	Lambda []float32
	// [BR,FR,AR] B-frames quantizer multipier/offset; used to decide B-frames quantizer when automatic quantizer is used
	BFrameQuantizer BFrameQuantizer
	// [AR] frame statistics
	Stats EncoderStats
}

PluginData stores information about an encoder and a specific frame to encode. It is used in plugins Before, Frame, and After callbacks.

Depending on the callback ([B]efore, [F]rame, [A]fter), some fields can be [R]eadable or [W]ritable. To represent this, each field description starts with a list [<B(efore)/F(rame)/A(fter)><R(ead)/W(rite)>, ...]. For example [AR,FW] means: writable during Frame, readable during After.

type PluginFlag

type PluginFlag uint

PluginFlag is a flag (or a bitwise-or union of flags) of data a custom Plugin needs access to.

const (
	// plugin needs a copy of the original (uncompressed) image
	PluginRequireOriginal PluginFlag = C.XVID_REQORIGINAL
	// plugin needs psnr between the uncompressed and compressed image
	PluginRequirePSNR PluginFlag = C.XVID_REQPSNR
	// plugin needs the diff quantizer table
	PluginRequireDiffQuantizer PluginFlag = C.XVID_REQDQUANTS
	// plugin needs the lambda table
	PluginRequireLambda PluginFlag = C.XVID_REQLAMBDA
)

type PluginInit

type PluginInit struct {
	// encoder bitrate zones, that enforce a specific parameter for a range of frames; must be sorted in increasing frame start order
	Zones []EncoderZone
	// frame width in pixels
	Width int
	// frame height in pixels
	Height int
	// frame width in macro blocks
	WidthMacroBlocks int
	// frame height in macro blocks
	HeightMacroBlocks int
	// framerate; Numerator=0 means variable framerate
	FrameRate Fraction
}

PluginInit stores general information for an encoder, used for reading by plugins in their Init callback.

type PluginRC1PassInit

type PluginRC1PassInit struct {
	// target bitrate in bits per second
	Bitrate int
	// reaction delay factor; defaults to 16
	ReactionDelayFactor int
	// averaging period; defaults to 100
	AveragingPeriod int
	// smoothing buffer; defaults to 100
	SmoothingBuffer int
}

PluginRC1PassInit is a configuration for the PluginRC1Pass plugin (1-pass rate-control). To return a configuration initialized to default values, use NewPluginRC1PassInit.

func NewPluginRC1PassInit

func NewPluginRC1PassInit(bitrate int) PluginRC1PassInit

NewPluginRC1PassInit returns a PluginRC1PassInit initialized to default values.

type PluginRC2Pass2Init

type PluginRC2Pass2Init struct {
	// target bitrate in bits per second; defaults to 700*1024
	Bitrate int
	// path to file to read rate-control info from, should be the same file as the first pass filename
	Filename string
	// I-frame boost percentage, range: [0..100]; defaults to 10
	IFrameBoost int
	// percentage of compression performed on the high part of the curve (above average); defaults to 0
	CurveCompressionHigh int
	// percentage of compression performed on the low  part of the curve (below average); defaults to 0
	CurveCompressionLow int
	// payback delay in number of frames; defaults to 5
	OverflowControlStrength int
	// percentage of allowed range for a frame that gets bigger because of overflow bonus; defaults to 5
	MaxOverflowImprovement int
	// percentage of allowed range for a frame that gets smaller because of overflow penalty; defaults to 5
	MaxOverflowDegradation int

	// maximum bitrate reduction applied to an I-frame under the kfthreshold distance limit; defaults to 20
	IFrameReduction int

	// if an iframe is closer to the next iframe than this distance, a quantity of bits
	// is substracted from its bit allocation. The reduction is computed as multiples of
	// kfreduction/kthreshold. It reaches kfreduction when the distance == kfthreshold,
	// 0 for 1<distance<kfthreshold
	// defaults to 1
	IFrameThreshold int

	// how many bytes the controller has to compensate per frame due to container format overhead; defaults to 0
	ContainerFrameOverhead int

	// Video Buffering Verifier buffer size in bits; 0 disables VBV check; defaults to 0
	VBVSize int
	// Video Buffering Verifier max processing bitrate in bits per second
	VBVMaxRate int
	// Video Buffering Verifier initial buffer occupancy in bits; defaults to 0
	VBVInitial int
}

PluginRC2Pass2Init is a configuration for the PluginRC2Pass2 plugin (2-pass rate-control, pass 2). To return a configuration initialized to default values, use NewPluginRC2Pass2Init.

func NewPluginRC2Pass2Init

func NewPluginRC2Pass2Init(bitrate int, filename string) PluginRC2Pass2Init

NewPluginRC2Pass2Init returns a PluginRC2Pass2Init initialized to default values. It takes a filename which is used to read the rate-control information from a previous first pass.

type PluginSSIMInit

type PluginSSIMInit struct {
	// whether to output stats to stdout
	PrintStats bool
	// output stats filename (file will be overwritten); or empty to not output to a file
	StatsFilename string

	// SSIM computation accuracy from 0 (gaussian weighted, very slow), 1 (unweighted, slow) to 4 (unweighted, very fast); default is 2
	Accuracy int
	// CPU flags to use for decoding, or nil to use the autodetected CPU features
	CpuFlags *CPUFlag
}

PluginSSIMInit is a configuration for the PluginSSIM plugin (write SSIM values). The SSIM values can be written to the standard output or to a file.

type QuantizerRange

type QuantizerRange struct {
	// minimum quantizer value, inclusive, 0 defaults to 2, must be between 1 and 31
	Min int
	// maximum quantizer value, inclusive, 0 defaults to 31, must be between 1 and 31
	Max int
}

QuantizerRange specifies the allowed range of a quantization parameter.

type VOLFlag

type VOLFlag uint

VOLFlag is a flag (or a bitwise-or union of flags) for encoding a group of frames, set in Encoder.Encode.

const (
	// enable MPEG type quantization
	VOLMPEGQuantization VOLFlag = C.XVID_VOL_MPEGQUANT
	// enable plane sse stats
	VOLExtraStats VOLFlag = C.XVID_VOL_EXTRASTATS
	// enable quarterpel: frames will encoded as quarterpel
	VOLQuarterPixel VOLFlag = C.XVID_VOL_QUARTERPEL
	// enable GMC (global motion compensation); frames will be checked for gmc suitability
	VOLGMC VOLFlag = C.XVID_VOL_GMC
	// enable interlaced encoding
	VOLInterlacing VOLFlag = C.XVID_VOL_INTERLACING
)

type VOPFlag

type VOPFlag uint

VOPFlag is a flag (or a bitwise-or union of flags) for encoding a single frame, set in Encoder.Encode.

const (
	// print debug messages in frames
	VOPDebug VOPFlag = C.XVID_VOP_DEBUG
	// use halfpel interpolation
	VOPHalfPixel VOPFlag = C.XVID_VOP_HALFPEL
	// use 4 motion vectors per MB
	VOPInter4Vectors VOPFlag = C.XVID_VOP_INTER4V
	// use trellis based R-D "optimal" quantization
	VOPTrellisQuantization VOPFlag = C.XVID_VOP_TRELLISQUANT
	// enable chroma optimization pre-filter
	VOPChromaOptimization VOPFlag = C.XVID_VOP_CHROMAOPT
	// use 'cartoon mode'
	VOPCartoon VOPFlag = C.XVID_VOP_CARTOON
	// enable greyscale only mode (even for  color input material chroma is ignored)
	VOPGreyscale VOPFlag = C.XVID_VOP_GREYSCALE
	// high quality ac prediction
	VOPHighQualityACPrediction VOPFlag = C.XVID_VOP_HQACPRED
	// enable DCT-ME and use it for mode decision
	VOPModeDecisionRD VOPFlag = C.XVID_VOP_MODEDECISION_RD
	// use simplified R-D mode decision
	VOPFastModeDecisionRD VOPFlag = C.XVID_VOP_FAST_MODEDECISION_RD
	// enable rate-distortion mode decision in b-frames
	VOPRateDistortionBFrames VOPFlag = C.XVID_VOP_RD_BVOP
	// use PSNR-HVS-M as metric for rate-distortion optimizations
	VOPRateDistortionPSNRHVSM VOPFlag = C.XVID_VOP_RD_PSNRHVSM
	// only valid with VOLInterlacing, set upper-field-first flag
	VOPUpperFieldFirst VOPFlag = C.XVID_VOP_TOPFIELDFIRST
	// only valid with VOLInterlacing, set alternate vertical scan flag
	VOPAlternateSscan VOPFlag = C.XVID_VOP_ALTERNATESCAN
)

type Version

type Version struct {
	// contains filtered or unexported fields
}

Version is a semver (semantic versioning) version.

func (Version) Major

func (v Version) Major() int

Major returns the major number part of the version: 1.2.3 returns 1.

func (Version) Minor

func (v Version) Minor() int

Minor returns the minor number part of the version: 1.2.3 returns 2.

func (Version) Patch

func (v Version) Patch() int

Minor returns the patch number part of the version: 1.2.3 returns 3.

func (Version) String

func (v Version) String() string

String returns a readable string respresentation of the version, e.g. 1.2.3.

type ZoneType

type ZoneType uint

ZoneType is a kind of bitrate Zone, which is applied on a range of frames while encoding.

const (
	// enforce a specific quantizer, value is the quantizer, recommended range is 2-31, must be >= 1
	ZoneModeQuantizer ZoneType = C.XVID_ZONE_QUANT
	// enforce a specific frame weight, value is the weight, default weight is 1, must be > 0
	ZoneModeWeight ZoneType = C.XVID_ZONE_WEIGHT
)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL