Filter SDK/Cplusplus API/VideoInfo
The VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). The GetVideoInfo method in IClip returns this structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).
Properies and constants
// General properties:
int width, height; // width=0 means no video unsigned fps_numerator, fps_denominator; int num_frames; // max. num_frames = 2,147,483,647 (signed int32) int audio_samples_per_second; // audio_samples_per_second=0 means no audio int sample_type; // samples types are defined in avisynth.h __int64 num_audio_samples; int nchannels;
// Colorspace properties and constants:
int pixel_type; enum { CS_BGR = 1<<28, CS_YUV = 1<<29, CS_INTERLEAVED = 1<<30, CS_PLANAR = 1<<31, // added in v5 CS_Shift_Sub_Width = 0, CS_Shift_Sub_Height = 8, CS_Shift_Sample_Bits = 16, CS_Sub_Width_Mask = 7 << CS_Shift_Sub_Width, CS_Sub_Width_1 = 3 << CS_Shift_Sub_Width, // YV24 CS_Sub_Width_2 = 0 << CS_Shift_Sub_Width, // YV12, I420, YV16 CS_Sub_Width_4 = 1 << CS_Shift_Sub_Width, // YUV9, YV411 CS_VPlaneFirst = 1 << 3, // YV12, YV16, YV24, YV411, YUV9 CS_UPlaneFirst = 1 << 4, // I420 CS_Sub_Height_Mask = 7 << CS_Shift_Sub_Height, CS_Sub_Height_1 = 3 << CS_Shift_Sub_Height, // YV16, YV24, YV411 CS_Sub_Height_2 = 0 << CS_Shift_Sub_Height, // YV12, I420 CS_Sub_Height_4 = 1 << CS_Shift_Sub_Height, // YUV9 CS_Sample_Bits_Mask = 7 << CS_Shift_Sample_Bits, CS_Sample_Bits_8 = 0 << CS_Shift_Sample_Bits, CS_Sample_Bits_16 = 1 << CS_Shift_Sample_Bits, CS_Sample_Bits_32 = 2 << CS_Shift_Sample_Bits, CS_PLANAR_MASK = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_BGR | CS_Sample_Bits_Mask | CS_Sub_Height_Mask | CS_Sub_Width_Mask, CS_PLANAR_FILTER = ~( CS_VPlaneFirst | CS_UPlaneFirst ), };
// Colorformat constants:
enum { CS_UNKNOWN = 0, CS_BGR24 = 1<<0 | CS_BGR | CS_INTERLEAVED, CS_BGR32 = 1<<1 | CS_BGR | CS_INTERLEAVED, CS_YUY2 = 1<<2 | CS_YUV | CS_INTERLEAVED, CS_YV12 = 1<<3 | CS_YUV | CS_PLANAR, // y-v-u, 4:2:0 planar // only in v3 CS_I420 = 1<<4 | CS_YUV | CS_PLANAR, // y-u-v, 4:2:0 planar // only in v3 CS_IYUV = 1<<4 | CS_YUV | CS_PLANAR, // same as above // only in v3 // added in v5 CS_RAW32 = 1<<5 | CS_INTERLEAVED, CS_YV24 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_1, // YUV 4:4:4 planar CS_YV16 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_2, // YUV 4:2:2 planar CS_YV12 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // y-v-u, 4:2:0 planar CS_I420 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_UPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // y-u-v, 4:2:0 planar CS_IYUV = CS_I420, CS_YUV9 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_4 | CS_Sub_Width_4, // YUV 4:1:0 planar CS_YV411 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_4, // YUV 4:1:1 planar CS_Y8 = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_Sample_Bits_8, // Y 4:0:0 planar };
// Image_type properties and constants:
int image_type; enum { IT_BFF = 1<<0, IT_TFF = 1<<1, IT_FIELDBASED = 1<<2 };
// Chroma placement constants (bits 20 -> 23):
enum { // added in v5 CS_UNKNOWN_CHROMA_PLACEMENT = 0 << 20, CS_MPEG1_CHROMA_PLACEMENT = 1 << 20, CS_MPEG2_CHROMA_PLACEMENT = 2 << 20, CS_YUY2_CHROMA_PLACEMENT = 3 << 20, CS_TOPLEFT_CHROMA_PLACEMENT = 4 << 20 };
Functions [need to add examples]
HasVideo / HasAudio
bool HasVideo() const;
This will return true if there is any video in the given clip.
bool HasAudio() const;
This will return true if there is any audio in the given clip.
IsRGB / IsRGB24 / IsRGB32
bool IsRGB() const; bool IsRGB24() const; bool IsRGB32() const;
All of them will return true if the colorspace is RGB (in any way). The last two return true if the clip has the specific RGB colorspace (RGB24 and RGB32).
IsYUV / IsYUY2 / IsYV24 / IsYV16 / IsYV12 / IsYV411 / IsY8
bool IsYUV() const; bool IsYUY2() const; bool IsYV24() const; // v5 bool IsYV16() const; // v5 bool IsYV12() const; bool IsYV411() const; // v5 bool IsY8() const; // v5
All of them will return true if the colorspace is YUV (in any way). The last six return true if the clip has the specific YUV colorspace (YUY2, YV24, YV16, YV12, YV411 and Y8).
IsColorSpace / IsSameColorspace / IsPlanar
bool IsColorSpace(int c_space) const;
This will return true if the colorspace (VideoInfo.pixel_type) is the same as the given c_space (or more general it checks for a Colorspace property).
bool IsSameColorspace(const VideoInfo& vi) const;
This function will compare two VideoInfos, and check if the colorspace is the same. Note: It does not check imagesize or similar properties.
bool IsPlanar() const;
This will return true if the video is planar. See the Planar image format.
Is / IsFieldBased / IsParityKnown / IsBFF / IsTFF
bool Is(int property) const;
From v6 this will return true if the image type (VideoInfo.image_type) is the same as the given property (being IT_BFF, IT_TFF or IT_FIELDBASED).
bool IsFieldBased() const;
This will return true if the video is field-based. Thus if has been through a SeparateFields or AssumeFieldBased. Otherwise it will return false.
bool IsParityKnown() const;
This will return true if the video parity is known (thus if it is TFF or BFF).
bool IsBFF() const; bool IsTFF() const;
This will return true if the video is bottom-field-first or top-field-first respectively.
BytesFromPixels
int BytesFromPixels(int pixels) const;
For interleaved formats it will return the number of bytes from the specified number of pixels. For planar formats it will do the same except it operates on the first plane.
RowSize / BMPSize
int RowSize(int plane=0) const;
For interleaved formats it will return the width of the frame in bytes. For planar formats it will return the width of the specified plane in bytes.
examples:
640x480 RGB24: RowSize() = 3*640 = 1920
640x480 YV12: RowSize() = 640
640x480 YV12: RowSize(1) = 320
int BMPSize() const;
For interleaved formats it will return the size of the frame in bytes where the width is rounded up to a multiple of 4 bytes. For planar formats it will do the same but only for the first plane. So, it's the number of bytes of a frame as it was a BMP frame.
examples:
640x480 RGB24: BMPSize() = 480 * 3*640 = 921600
643x480 RGB24: BMPSize() = 480 * 3*644 = 927360
640x480 YV24: BMPSize() = 480 * 640 = 307200
643x480 YV24: BMPSize() = 480 * 644 = 309120
Since v5 the behavior for planar formats is the same as for interleaved formats.
GetPlaneWidthSubsampling / GetPlaneHeightSubsampling
int GetPlaneWidthSubsampling(int plane) const; // v5
This will return the subsampling of the width in bitshifts.
examples:
YV24: GetPlaneWidthSubsampling(PLANAR_U) = 0 // since there is no horizontal subsampling on a chroma plane
YV16: GetPlaneWidthSubsampling(PLANAR_U) = 0 // since there is no horizontal subsampling on a chroma plane
int GetPlaneHeightSubsampling(int plane) const; // v5
This will return the subsampling of the height in bitshifts.
examples:
YV24: GetPlaneHeightSubsampling(PLANAR_U) = 0 // since there is no vertical subsampling on a chroma plane
YV16: GetPlaneHeightSubsampling(PLANAR_U) = 1 // since vertically there are two times less samples on a chroma plane compared to a plane which is not subsampled
color format | GetPlaneWidthSubsampling(PLANAR_U) | GetPlaneHeightSubsampling(PLANAR_U) |
YV24 | 0 | 0 |
YV16 | 1 | 0 |
YV12 | 1 | 1 |
YV411 | 2 | 1 |
Y8 | 0 ? | 0 ? |
AudioSamplesFromFrames / FramesFromAudioSamples / AudioSamplesFromBytes / BytesFromAudioSamples
__int64 AudioSamplesFromFrames(int frames) const;
This returns the number of audiosamples from the first frames frames.
int FramesFromAudioSamples(__int64 samples) const;
This returns the number of frames from the first samples audiosamples.
__int64 AudioSamplesFromBytes(__int64 bytes) const;
This returns the number of audiosamples from the specified number of bytes.
__int64 BytesFromAudioSamples(__int64 samples) const;
This returns the number of bytes from the first samples audiosamples.
AudioChannels / SampleType
int AudioChannels() const;
This will return the number of audio channels.
int SampleType() const;
This will return the sample type. See constants for the available sample types.
SamplesPerSecond / BytesPerAudioSample
int SamplesPerSecond() const;
This will return the number of bytes per second.
int BytesPerAudioSample() const;
This will return the number of bytes per sample.
IsSampleType
bool IsSampleType(int testtype) const;
This will true if the sampletype (VideoInfo.sample_type) is the same as testtype.
SetFieldBased / Set / Clear
void SetFieldBased(bool isfieldbased);
This will set the field-based property to true (respectively false) if IsFieldBased()=true (respectively false).
void Set(int property); void Clear(int property);
This sets respectively clears an image_type property like: IT_BFF, IT_TFF or IT_FIELDBASED. See field.h for examples.
BitsPerPixel / BytesPerChannelSample
int BitsPerPixel() const;
This will return the number of bits per pixel. This can be:
pixel_type | nr of bits |
---|---|
CS_BGR32 | 32 |
CS_BGR24, CS_YV24 | 24 |
CS_YUY2, CS_YV16 | 16 |
CS_YV12, CS_I420 | 12 |
CS_Y8 | 8 |
CS_YV411 | 6 |
int BytesPerChannelSample() const;
This will return the number of bytes per channel-sample. This can be:
sample | nr of bytes |
---|---|
SAMPLE_INT8 | sizeof(signed char) |
SAMPLE_INT16 | sizeof(signed short) |
SAMPLE_INT24 | 3 |
SAMPLE_INT32 | sizeof(signed int) |
SAMPLE_FLOAT | sizeof(SFLOAT) |
SetFPS / MulDivFPS
void SetFPS(unsigned numerator, unsigned denominator);
This will set the framerate.
void MulDivFPS(unsigned multiplier, unsigned divisor);
This will multiply the denominator by multiplier and scale the numerator and modified denominator.