Win32 API 日本語リファレンス
ホームMedia.DirectShow › VIDEOINFO

VIDEOINFO

構造体
サイズx64: 1128 バイト / x86: 1128 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
rcSourceRECT16+0+0使用する入力ビデオの範囲です。
rcTargetRECT16+16+16ビデオを表示する位置です。
dwBitRateDWORD4+32+32おおよそのデータレート (ビット/秒) です。
dwBitErrorRateDWORD4+36+36このストリームのビットエラーレートです。
AvgTimePerFrameLONGLONG8+40+401 フレームあたりの平均時間として希望する値を、100 ナノ秒単位で指定します。詳細については、VIDEOINFOHEADER 構造体の「解説」セクションを参照してください。
bmiHeaderBITMAPINFOHEADER40+48+48デバイス非依存ビットマップの色情報と寸法情報を含む BITMAPINFOHEADER 構造体です。
Anonymous_Anonymous_e__Union1036+88+88カラーテーブルやビットマスク等を含む無名共用体。

共用体: _Anonymous_e__Union x64 1036B / x86 1036B

フィールドサイズx64x86説明
bmiColorsRGBQUAD1024+0+0ビデオのカラーパレットを指定する Win32 RGBQUAD 構造体の配列です。各構造体は、赤・緑・青の強度の組み合わせである 1 つの色を表します。
dwBitMasksDWORD12+0+0トゥルーカラーのビットマスクを指定する DWORD 値の配列です。
TrueColorInfoTRUECOLORINFO1036+0+0カラーパレットとカラービットマスクの配列の両方を含む TRUECOLORINFO 構造体です。

公式ドキュメント

[このページに関連する機能である DirectShow はレガシー機能です。この機能は MediaPlayerIMFMediaEngine、および Audio/Video Capture in Media Foundation に置き換えられました。これらの機能は Windows 10 および Windows 11 向けに最適化されています。Microsoft は、新しいコードでは可能な限り DirectShow ではなく MediaPlayerIMFMediaEngineAudio/Video Capture in Media Foundation を使用することを強く推奨します。また、レガシー API を使用している既存のコードについても、可能であれば新しい API を使用するように書き直すことを推奨します。]

VIDEOINFO 構造体は VIDEOINFOHEADER 構造体と同等ですが、3 つのカラーマスクと 256 色のカラーテーブルを保持できるだけのメモリを備えています。

ビデオフィルターを作成する場合、この構造体を使用すると、フォーマットブロックが常に最大サイズの VIDEOINFOHEADER 構造体を格納できるだけのメモリを持つことを保証できます。

解説(Remarks)

標準の RGB フォーマットの格納にのみ使用することが確実である場合を除き、この構造体を使用しないでください。標準の RGB 以外のものを格納すると、bmiHeader 構造体のサイズが可変であることがほぼ確実に問題を引き起こすため、代わりに VIDEOINFOHEADER 構造体を使用してください。どうしても VIDEOINFO 構造体を使用する必要がある場合は、TrueColorInfodwBitMasksbmiColors の各メンバーに直接アクセスしないでください。代わりに、TRUECOLORCOLORSBITMASKS の各マクロを使用して色情報へのポインターを取得してください。これらのメンバーのうちどれが有効であるかは、BITMAPINFOHEADER 構造体の内容によって決まります。

最初の 5 つのデータメンバーは VIDEOINFOHEADER 構造体と同等です。これらが個別に展開されているのは、単に VIDEOINFO 構造体へのポインターを扱う際に必要となる参照解決の回数を減らすためです。

rcSource メンバーと rcTarget メンバーの使用方法については、Source and Target Rectangles in Video Renderers を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// RECT  (x64 16 / x86 16 バイト)
typedef struct RECT {
    INT left;
    INT top;
    INT right;
    INT bottom;
} RECT;

// BITMAPINFOHEADER  (x64 40 / x86 40 バイト)
typedef struct BITMAPINFOHEADER {
    DWORD biSize;
    INT biWidth;
    INT biHeight;
    WORD biPlanes;
    WORD biBitCount;
    DWORD biCompression;
    DWORD biSizeImage;
    INT biXPelsPerMeter;
    INT biYPelsPerMeter;
    DWORD biClrUsed;
    DWORD biClrImportant;
} BITMAPINFOHEADER;

// VIDEOINFO  (x64 1128 / x86 1128 バイト)
typedef struct VIDEOINFO {
    RECT rcSource;
    RECT rcTarget;
    DWORD dwBitRate;
    DWORD dwBitErrorRate;
    LONGLONG AvgTimePerFrame;
    BITMAPINFOHEADER bmiHeader;
    _Anonymous_e__Union Anonymous;
} VIDEOINFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RECT
{
    public int left;
    public int top;
    public int right;
    public int bottom;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BITMAPINFOHEADER
{
    public uint biSize;
    public int biWidth;
    public int biHeight;
    public ushort biPlanes;
    public ushort biBitCount;
    public uint biCompression;
    public uint biSizeImage;
    public int biXPelsPerMeter;
    public int biYPelsPerMeter;
    public uint biClrUsed;
    public uint biClrImportant;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct VIDEOINFO
{
    public RECT rcSource;
    public RECT rcTarget;
    public uint dwBitRate;
    public uint dwBitErrorRate;
    public long AvgTimePerFrame;
    public BITMAPINFOHEADER bmiHeader;
    public _Anonymous_e__Union Anonymous;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RECT
    Public left As Integer
    Public top As Integer
    Public right As Integer
    Public bottom As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BITMAPINFOHEADER
    Public biSize As UInteger
    Public biWidth As Integer
    Public biHeight As Integer
    Public biPlanes As UShort
    Public biBitCount As UShort
    Public biCompression As UInteger
    Public biSizeImage As UInteger
    Public biXPelsPerMeter As Integer
    Public biYPelsPerMeter As Integer
    Public biClrUsed As UInteger
    Public biClrImportant As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure VIDEOINFO
    Public rcSource As RECT
    Public rcTarget As RECT
    Public dwBitRate As UInteger
    Public dwBitErrorRate As UInteger
    Public AvgTimePerFrame As Long
    Public bmiHeader As BITMAPINFOHEADER
    Public Anonymous As _Anonymous_e__Union
End Structure
import ctypes
from ctypes import wintypes

class RECT(ctypes.Structure):
    _fields_ = [
        ("left", ctypes.c_int),
        ("top", ctypes.c_int),
        ("right", ctypes.c_int),
        ("bottom", ctypes.c_int),
    ]

class BITMAPINFOHEADER(ctypes.Structure):
    _fields_ = [
        ("biSize", wintypes.DWORD),
        ("biWidth", ctypes.c_int),
        ("biHeight", ctypes.c_int),
        ("biPlanes", ctypes.c_ushort),
        ("biBitCount", ctypes.c_ushort),
        ("biCompression", wintypes.DWORD),
        ("biSizeImage", wintypes.DWORD),
        ("biXPelsPerMeter", ctypes.c_int),
        ("biYPelsPerMeter", ctypes.c_int),
        ("biClrUsed", wintypes.DWORD),
        ("biClrImportant", wintypes.DWORD),
    ]

class VIDEOINFO(ctypes.Structure):
    _fields_ = [
        ("rcSource", RECT),
        ("rcTarget", RECT),
        ("dwBitRate", wintypes.DWORD),
        ("dwBitErrorRate", wintypes.DWORD),
        ("AvgTimePerFrame", ctypes.c_longlong),
        ("bmiHeader", BITMAPINFOHEADER),
        ("Anonymous", _Anonymous_e__Union),
    ]
#[repr(C)]
pub struct RECT {
    pub left: i32,
    pub top: i32,
    pub right: i32,
    pub bottom: i32,
}

#[repr(C)]
pub struct BITMAPINFOHEADER {
    pub biSize: u32,
    pub biWidth: i32,
    pub biHeight: i32,
    pub biPlanes: u16,
    pub biBitCount: u16,
    pub biCompression: u32,
    pub biSizeImage: u32,
    pub biXPelsPerMeter: i32,
    pub biYPelsPerMeter: i32,
    pub biClrUsed: u32,
    pub biClrImportant: u32,
}

#[repr(C)]
pub struct VIDEOINFO {
    pub rcSource: RECT,
    pub rcTarget: RECT,
    pub dwBitRate: u32,
    pub dwBitErrorRate: u32,
    pub AvgTimePerFrame: i64,
    pub bmiHeader: BITMAPINFOHEADER,
    pub Anonymous: _Anonymous_e__Union,
}
import "golang.org/x/sys/windows"

type RECT struct {
	left int32
	top int32
	right int32
	bottom int32
}

type BITMAPINFOHEADER struct {
	biSize uint32
	biWidth int32
	biHeight int32
	biPlanes uint16
	biBitCount uint16
	biCompression uint32
	biSizeImage uint32
	biXPelsPerMeter int32
	biYPelsPerMeter int32
	biClrUsed uint32
	biClrImportant uint32
}

type VIDEOINFO struct {
	rcSource RECT
	rcTarget RECT
	dwBitRate uint32
	dwBitErrorRate uint32
	AvgTimePerFrame int64
	bmiHeader BITMAPINFOHEADER
	Anonymous _Anonymous_e__Union
}
type
  RECT = record
    left: Integer;
    top: Integer;
    right: Integer;
    bottom: Integer;
  end;

  BITMAPINFOHEADER = record
    biSize: DWORD;
    biWidth: Integer;
    biHeight: Integer;
    biPlanes: Word;
    biBitCount: Word;
    biCompression: DWORD;
    biSizeImage: DWORD;
    biXPelsPerMeter: Integer;
    biYPelsPerMeter: Integer;
    biClrUsed: DWORD;
    biClrImportant: DWORD;
  end;

  VIDEOINFO = record
    rcSource: RECT;
    rcTarget: RECT;
    dwBitRate: DWORD;
    dwBitErrorRate: DWORD;
    AvgTimePerFrame: Int64;
    bmiHeader: BITMAPINFOHEADER;
    Anonymous: _Anonymous_e__Union;
  end;
const RECT = extern struct {
    left: i32,
    top: i32,
    right: i32,
    bottom: i32,
};

const BITMAPINFOHEADER = extern struct {
    biSize: u32,
    biWidth: i32,
    biHeight: i32,
    biPlanes: u16,
    biBitCount: u16,
    biCompression: u32,
    biSizeImage: u32,
    biXPelsPerMeter: i32,
    biYPelsPerMeter: i32,
    biClrUsed: u32,
    biClrImportant: u32,
};

const VIDEOINFO = extern struct {
    rcSource: RECT,
    rcTarget: RECT,
    dwBitRate: u32,
    dwBitErrorRate: u32,
    AvgTimePerFrame: i64,
    bmiHeader: BITMAPINFOHEADER,
    Anonymous: _Anonymous_e__Union,
};
type
  RECT {.bycopy.} = object
    left: int32
    top: int32
    right: int32
    bottom: int32

  BITMAPINFOHEADER {.bycopy.} = object
    biSize: uint32
    biWidth: int32
    biHeight: int32
    biPlanes: uint16
    biBitCount: uint16
    biCompression: uint32
    biSizeImage: uint32
    biXPelsPerMeter: int32
    biYPelsPerMeter: int32
    biClrUsed: uint32
    biClrImportant: uint32

  VIDEOINFO {.bycopy.} = object
    rcSource: RECT
    rcTarget: RECT
    dwBitRate: uint32
    dwBitErrorRate: uint32
    AvgTimePerFrame: int64
    bmiHeader: BITMAPINFOHEADER
    Anonymous: _Anonymous_e__Union
struct RECT
{
    int left;
    int top;
    int right;
    int bottom;
}

struct BITMAPINFOHEADER
{
    uint biSize;
    int biWidth;
    int biHeight;
    ushort biPlanes;
    ushort biBitCount;
    uint biCompression;
    uint biSizeImage;
    int biXPelsPerMeter;
    int biYPelsPerMeter;
    uint biClrUsed;
    uint biClrImportant;
}

struct VIDEOINFO
{
    RECT rcSource;
    RECT rcTarget;
    uint dwBitRate;
    uint dwBitErrorRate;
    long AvgTimePerFrame;
    BITMAPINFOHEADER bmiHeader;
    _Anonymous_e__Union Anonymous;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; VIDEOINFO サイズ: 1128 バイト(x64)
dim st, 282    ; 4byte整数×282(構造体サイズ 1128 / 4 切り上げ)
; rcSource : RECT (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; rcTarget : RECT (+16, 16byte)  varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; dwBitRate : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; dwBitErrorRate : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; AvgTimePerFrame : LONGLONG (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; bmiHeader : BITMAPINFOHEADER (+48, 40byte)  varptr(st)+48 を基点に操作(40byte:入れ子/配列)
; Anonymous : _Anonymous_e__Union (+88, 1036byte)  varptr(st)+88 を基点に操作(1036byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global RECT
    #field int left
    #field int top
    #field int right
    #field int bottom
#endstruct

#defstruct global BITMAPINFOHEADER
    #field int biSize
    #field int biWidth
    #field int biHeight
    #field short biPlanes
    #field short biBitCount
    #field int biCompression
    #field int biSizeImage
    #field int biXPelsPerMeter
    #field int biYPelsPerMeter
    #field int biClrUsed
    #field int biClrImportant
#endstruct

#defstruct global VIDEOINFO
    #field RECT rcSource
    #field RECT rcTarget
    #field int dwBitRate
    #field int dwBitErrorRate
    #field int64 AvgTimePerFrame
    #field BITMAPINFOHEADER bmiHeader
    #field byte Anonymous 1036
#endstruct

stdim st, VIDEOINFO        ; NSTRUCT 変数を確保
st->dwBitRate = 100
mes "dwBitRate=" + st->dwBitRate
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。