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

KS_DATAFORMAT_MPEGVIDEOINFO2

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

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

フィールド

フィールドサイズx64x86説明
DataFormatKSDATAFORMAT64+0+0基底となるKSDATAFORMATデータフォーマット記述子である。
MpegVideoInfoHeader2KS_MPEGVIDEOINFO2136+64+64MPEG映像フォーマットを記述するKS_MPEGVIDEOINFO2である。

各言語での定義

#include <windows.h>

// KSDATAFORMAT  (x64 64 / x86 64 バイト)
typedef struct KSDATAFORMAT {
    _Anonymous_e__Struct Anonymous;
    LONGLONG Alignment;
} KSDATAFORMAT;

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

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

// KS_VIDEOINFOHEADER2  (x64 112 / x86 112 バイト)
typedef struct KS_VIDEOINFOHEADER2 {
    RECT rcSource;
    RECT rcTarget;
    DWORD dwBitRate;
    DWORD dwBitErrorRate;
    LONGLONG AvgTimePerFrame;
    DWORD dwInterlaceFlags;
    DWORD dwCopyProtectFlags;
    DWORD dwPictAspectRatioX;
    DWORD dwPictAspectRatioY;
    _Anonymous_e__Union Anonymous;
    DWORD dwReserved2;
    KS_BITMAPINFOHEADER bmiHeader;
} KS_VIDEOINFOHEADER2;

// KS_MPEGVIDEOINFO2  (x64 136 / x86 136 バイト)
typedef struct KS_MPEGVIDEOINFO2 {
    KS_VIDEOINFOHEADER2 hdr;
    DWORD dwStartTimeCode;
    DWORD cbSequenceHeader;
    DWORD dwProfile;
    DWORD dwLevel;
    DWORD dwFlags;
    DWORD bSequenceHeader[1];
} KS_MPEGVIDEOINFO2;

// KS_DATAFORMAT_MPEGVIDEOINFO2  (x64 200 / x86 200 バイト)
typedef struct KS_DATAFORMAT_MPEGVIDEOINFO2 {
    KSDATAFORMAT DataFormat;
    KS_MPEGVIDEOINFO2 MpegVideoInfoHeader2;
} KS_DATAFORMAT_MPEGVIDEOINFO2;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KSDATAFORMAT
{
    public _Anonymous_e__Struct Anonymous;
    public long Alignment;
}

[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 KS_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 KS_VIDEOINFOHEADER2
{
    public RECT rcSource;
    public RECT rcTarget;
    public uint dwBitRate;
    public uint dwBitErrorRate;
    public long AvgTimePerFrame;
    public uint dwInterlaceFlags;
    public uint dwCopyProtectFlags;
    public uint dwPictAspectRatioX;
    public uint dwPictAspectRatioY;
    public _Anonymous_e__Union Anonymous;
    public uint dwReserved2;
    public KS_BITMAPINFOHEADER bmiHeader;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KS_MPEGVIDEOINFO2
{
    public KS_VIDEOINFOHEADER2 hdr;
    public uint dwStartTimeCode;
    public uint cbSequenceHeader;
    public uint dwProfile;
    public uint dwLevel;
    public uint dwFlags;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public uint[] bSequenceHeader;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct KS_DATAFORMAT_MPEGVIDEOINFO2
{
    public KSDATAFORMAT DataFormat;
    public KS_MPEGVIDEOINFO2 MpegVideoInfoHeader2;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KSDATAFORMAT
    Public Anonymous As _Anonymous_e__Struct
    Public Alignment As Long
End Structure

<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 KS_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 KS_VIDEOINFOHEADER2
    Public rcSource As RECT
    Public rcTarget As RECT
    Public dwBitRate As UInteger
    Public dwBitErrorRate As UInteger
    Public AvgTimePerFrame As Long
    Public dwInterlaceFlags As UInteger
    Public dwCopyProtectFlags As UInteger
    Public dwPictAspectRatioX As UInteger
    Public dwPictAspectRatioY As UInteger
    Public Anonymous As _Anonymous_e__Union
    Public dwReserved2 As UInteger
    Public bmiHeader As KS_BITMAPINFOHEADER
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KS_MPEGVIDEOINFO2
    Public hdr As KS_VIDEOINFOHEADER2
    Public dwStartTimeCode As UInteger
    Public cbSequenceHeader As UInteger
    Public dwProfile As UInteger
    Public dwLevel As UInteger
    Public dwFlags As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public bSequenceHeader() As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure KS_DATAFORMAT_MPEGVIDEOINFO2
    Public DataFormat As KSDATAFORMAT
    Public MpegVideoInfoHeader2 As KS_MPEGVIDEOINFO2
End Structure
import ctypes
from ctypes import wintypes

class KSDATAFORMAT(ctypes.Structure):
    _fields_ = [
        ("Anonymous", _Anonymous_e__Struct),
        ("Alignment", ctypes.c_longlong),
    ]

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

class KS_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 KS_VIDEOINFOHEADER2(ctypes.Structure):
    _fields_ = [
        ("rcSource", RECT),
        ("rcTarget", RECT),
        ("dwBitRate", wintypes.DWORD),
        ("dwBitErrorRate", wintypes.DWORD),
        ("AvgTimePerFrame", ctypes.c_longlong),
        ("dwInterlaceFlags", wintypes.DWORD),
        ("dwCopyProtectFlags", wintypes.DWORD),
        ("dwPictAspectRatioX", wintypes.DWORD),
        ("dwPictAspectRatioY", wintypes.DWORD),
        ("Anonymous", _Anonymous_e__Union),
        ("dwReserved2", wintypes.DWORD),
        ("bmiHeader", KS_BITMAPINFOHEADER),
    ]

class KS_MPEGVIDEOINFO2(ctypes.Structure):
    _fields_ = [
        ("hdr", KS_VIDEOINFOHEADER2),
        ("dwStartTimeCode", wintypes.DWORD),
        ("cbSequenceHeader", wintypes.DWORD),
        ("dwProfile", wintypes.DWORD),
        ("dwLevel", wintypes.DWORD),
        ("dwFlags", wintypes.DWORD),
        ("bSequenceHeader", wintypes.DWORD * 1),
    ]

class KS_DATAFORMAT_MPEGVIDEOINFO2(ctypes.Structure):
    _fields_ = [
        ("DataFormat", KSDATAFORMAT),
        ("MpegVideoInfoHeader2", KS_MPEGVIDEOINFO2),
    ]
#[repr(C)]
pub struct KSDATAFORMAT {
    pub Anonymous: _Anonymous_e__Struct,
    pub Alignment: i64,
}

#[repr(C)]
pub struct RECT {
    pub left: i32,
    pub top: i32,
    pub right: i32,
    pub bottom: i32,
}

#[repr(C)]
pub struct KS_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 KS_VIDEOINFOHEADER2 {
    pub rcSource: RECT,
    pub rcTarget: RECT,
    pub dwBitRate: u32,
    pub dwBitErrorRate: u32,
    pub AvgTimePerFrame: i64,
    pub dwInterlaceFlags: u32,
    pub dwCopyProtectFlags: u32,
    pub dwPictAspectRatioX: u32,
    pub dwPictAspectRatioY: u32,
    pub Anonymous: _Anonymous_e__Union,
    pub dwReserved2: u32,
    pub bmiHeader: KS_BITMAPINFOHEADER,
}

#[repr(C)]
pub struct KS_MPEGVIDEOINFO2 {
    pub hdr: KS_VIDEOINFOHEADER2,
    pub dwStartTimeCode: u32,
    pub cbSequenceHeader: u32,
    pub dwProfile: u32,
    pub dwLevel: u32,
    pub dwFlags: u32,
    pub bSequenceHeader: [u32; 1],
}

#[repr(C)]
pub struct KS_DATAFORMAT_MPEGVIDEOINFO2 {
    pub DataFormat: KSDATAFORMAT,
    pub MpegVideoInfoHeader2: KS_MPEGVIDEOINFO2,
}
import "golang.org/x/sys/windows"

type KSDATAFORMAT struct {
	Anonymous _Anonymous_e__Struct
	Alignment int64
}

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

type KS_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 KS_VIDEOINFOHEADER2 struct {
	rcSource RECT
	rcTarget RECT
	dwBitRate uint32
	dwBitErrorRate uint32
	AvgTimePerFrame int64
	dwInterlaceFlags uint32
	dwCopyProtectFlags uint32
	dwPictAspectRatioX uint32
	dwPictAspectRatioY uint32
	Anonymous _Anonymous_e__Union
	dwReserved2 uint32
	bmiHeader KS_BITMAPINFOHEADER
}

type KS_MPEGVIDEOINFO2 struct {
	hdr KS_VIDEOINFOHEADER2
	dwStartTimeCode uint32
	cbSequenceHeader uint32
	dwProfile uint32
	dwLevel uint32
	dwFlags uint32
	bSequenceHeader [1]uint32
}

type KS_DATAFORMAT_MPEGVIDEOINFO2 struct {
	DataFormat KSDATAFORMAT
	MpegVideoInfoHeader2 KS_MPEGVIDEOINFO2
}
type
  KSDATAFORMAT = record
    Anonymous: _Anonymous_e__Struct;
    Alignment: Int64;
  end;

  RECT = record
    left: Integer;
    top: Integer;
    right: Integer;
    bottom: Integer;
  end;

  KS_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;

  KS_VIDEOINFOHEADER2 = record
    rcSource: RECT;
    rcTarget: RECT;
    dwBitRate: DWORD;
    dwBitErrorRate: DWORD;
    AvgTimePerFrame: Int64;
    dwInterlaceFlags: DWORD;
    dwCopyProtectFlags: DWORD;
    dwPictAspectRatioX: DWORD;
    dwPictAspectRatioY: DWORD;
    Anonymous: _Anonymous_e__Union;
    dwReserved2: DWORD;
    bmiHeader: KS_BITMAPINFOHEADER;
  end;

  KS_MPEGVIDEOINFO2 = record
    hdr: KS_VIDEOINFOHEADER2;
    dwStartTimeCode: DWORD;
    cbSequenceHeader: DWORD;
    dwProfile: DWORD;
    dwLevel: DWORD;
    dwFlags: DWORD;
    bSequenceHeader: array[0..0] of DWORD;
  end;

  KS_DATAFORMAT_MPEGVIDEOINFO2 = record
    DataFormat: KSDATAFORMAT;
    MpegVideoInfoHeader2: KS_MPEGVIDEOINFO2;
  end;
const KSDATAFORMAT = extern struct {
    Anonymous: _Anonymous_e__Struct,
    Alignment: i64,
};

const RECT = extern struct {
    left: i32,
    top: i32,
    right: i32,
    bottom: i32,
};

const KS_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 KS_VIDEOINFOHEADER2 = extern struct {
    rcSource: RECT,
    rcTarget: RECT,
    dwBitRate: u32,
    dwBitErrorRate: u32,
    AvgTimePerFrame: i64,
    dwInterlaceFlags: u32,
    dwCopyProtectFlags: u32,
    dwPictAspectRatioX: u32,
    dwPictAspectRatioY: u32,
    Anonymous: _Anonymous_e__Union,
    dwReserved2: u32,
    bmiHeader: KS_BITMAPINFOHEADER,
};

const KS_MPEGVIDEOINFO2 = extern struct {
    hdr: KS_VIDEOINFOHEADER2,
    dwStartTimeCode: u32,
    cbSequenceHeader: u32,
    dwProfile: u32,
    dwLevel: u32,
    dwFlags: u32,
    bSequenceHeader: [1]u32,
};

const KS_DATAFORMAT_MPEGVIDEOINFO2 = extern struct {
    DataFormat: KSDATAFORMAT,
    MpegVideoInfoHeader2: KS_MPEGVIDEOINFO2,
};
type
  KSDATAFORMAT {.bycopy.} = object
    Anonymous: _Anonymous_e__Struct
    Alignment: int64

  RECT {.bycopy.} = object
    left: int32
    top: int32
    right: int32
    bottom: int32

  KS_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

  KS_VIDEOINFOHEADER2 {.bycopy.} = object
    rcSource: RECT
    rcTarget: RECT
    dwBitRate: uint32
    dwBitErrorRate: uint32
    AvgTimePerFrame: int64
    dwInterlaceFlags: uint32
    dwCopyProtectFlags: uint32
    dwPictAspectRatioX: uint32
    dwPictAspectRatioY: uint32
    Anonymous: _Anonymous_e__Union
    dwReserved2: uint32
    bmiHeader: KS_BITMAPINFOHEADER

  KS_MPEGVIDEOINFO2 {.bycopy.} = object
    hdr: KS_VIDEOINFOHEADER2
    dwStartTimeCode: uint32
    cbSequenceHeader: uint32
    dwProfile: uint32
    dwLevel: uint32
    dwFlags: uint32
    bSequenceHeader: array[1, uint32]

  KS_DATAFORMAT_MPEGVIDEOINFO2 {.bycopy.} = object
    DataFormat: KSDATAFORMAT
    MpegVideoInfoHeader2: KS_MPEGVIDEOINFO2
struct KSDATAFORMAT
{
    _Anonymous_e__Struct Anonymous;
    long Alignment;
}

struct RECT
{
    int left;
    int top;
    int right;
    int bottom;
}

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

struct KS_VIDEOINFOHEADER2
{
    RECT rcSource;
    RECT rcTarget;
    uint dwBitRate;
    uint dwBitErrorRate;
    long AvgTimePerFrame;
    uint dwInterlaceFlags;
    uint dwCopyProtectFlags;
    uint dwPictAspectRatioX;
    uint dwPictAspectRatioY;
    _Anonymous_e__Union Anonymous;
    uint dwReserved2;
    KS_BITMAPINFOHEADER bmiHeader;
}

struct KS_MPEGVIDEOINFO2
{
    KS_VIDEOINFOHEADER2 hdr;
    uint dwStartTimeCode;
    uint cbSequenceHeader;
    uint dwProfile;
    uint dwLevel;
    uint dwFlags;
    uint[1] bSequenceHeader;
}

struct KS_DATAFORMAT_MPEGVIDEOINFO2
{
    KSDATAFORMAT DataFormat;
    KS_MPEGVIDEOINFO2 MpegVideoInfoHeader2;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; KS_DATAFORMAT_MPEGVIDEOINFO2 サイズ: 200 バイト(x64)
dim st, 50    ; 4byte整数×50(構造体サイズ 200 / 4 切り上げ)
; DataFormat : KSDATAFORMAT (+0, 64byte)  varptr(st)+0 を基点に操作(64byte:入れ子/配列)
; MpegVideoInfoHeader2 : KS_MPEGVIDEOINFO2 (+64, 136byte)  varptr(st)+64 を基点に操作(136byte:入れ子/配列)
; ※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 KS_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 KS_VIDEOINFOHEADER2
    #field RECT rcSource
    #field RECT rcTarget
    #field int dwBitRate
    #field int dwBitErrorRate
    #field int64 AvgTimePerFrame
    #field int dwInterlaceFlags
    #field int dwCopyProtectFlags
    #field int dwPictAspectRatioX
    #field int dwPictAspectRatioY
    #field byte Anonymous 4
    #field int dwReserved2
    #field KS_BITMAPINFOHEADER bmiHeader
#endstruct

#defstruct global KS_MPEGVIDEOINFO2
    #field KS_VIDEOINFOHEADER2 hdr
    #field int dwStartTimeCode
    #field int cbSequenceHeader
    #field int dwProfile
    #field int dwLevel
    #field int dwFlags
    #field int bSequenceHeader 1
#endstruct

#defstruct global KS_DATAFORMAT_MPEGVIDEOINFO2
    #field byte DataFormat 64
    #field KS_MPEGVIDEOINFO2 MpegVideoInfoHeader2
#endstruct

stdim st, KS_DATAFORMAT_MPEGVIDEOINFO2        ; NSTRUCT 変数を確保
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。