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

AVITIMECODEINDEX

構造体
サイズx64: 16384 バイト / x86: 16384 バイトパッキング2

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

フィールド

フィールドサイズx64x86説明
fccDWORD4+0+0チャンクを識別するFourCCコード。
cbDWORD4+4+4インデックスデータのバイト数。
wLongsPerEntryWORD2+8+81エントリあたりのDWORD(4バイト)数。
bIndexSubTypeBYTE1+10+10インデックスのサブタイプを示す値。
bIndexTypeBYTE1+11+11インデックスの種類を示す値(タイムコードインデックス)。
nEntriesInUseDWORD4+12+12使用中のエントリ数。
dwChunkIdDWORD4+16+16このインデックスが指すチャンクのID(FourCC)。
dwReservedDWORD12+20+20予約フィールド配列。将来の拡張用で通常は0。
aIndexTIMECODEDATA16352+32+32タイムコードデータ配列(TIMECODEDATA)。可変長の先頭要素。

各言語での定義

#include <windows.h>

// TIMECODE  (x64 8 / x86 8 バイト)
typedef struct TIMECODE {
    _Anonymous_e__Struct Anonymous;
    ULONGLONG qw;
} TIMECODE;

// TIMECODEDATA  (x64 16 / x86 16 バイト)
#pragma pack(push, 2)
typedef struct TIMECODEDATA {
    TIMECODE time;
    DWORD dwSMPTEflags;
    DWORD dwUser;
} TIMECODEDATA;
#pragma pack(pop)

// AVITIMECODEINDEX  (x64 16384 / x86 16384 バイト)
#pragma pack(push, 2)
typedef struct AVITIMECODEINDEX {
    DWORD fcc;
    DWORD cb;
    WORD wLongsPerEntry;
    BYTE bIndexSubType;
    BYTE bIndexType;
    DWORD nEntriesInUse;
    DWORD dwChunkId;
    DWORD dwReserved[3];
    TIMECODEDATA aIndex[1022];
} AVITIMECODEINDEX;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TIMECODE
{
    public _Anonymous_e__Struct Anonymous;
    public ulong qw;
}

[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]
public struct TIMECODEDATA
{
    public TIMECODE time;
    public uint dwSMPTEflags;
    public uint dwUser;
}

[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]
public struct AVITIMECODEINDEX
{
    public uint fcc;
    public uint cb;
    public ushort wLongsPerEntry;
    public byte bIndexSubType;
    public byte bIndexType;
    public uint nEntriesInUse;
    public uint dwChunkId;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] dwReserved;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1022)] public TIMECODEDATA[] aIndex;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TIMECODE
    Public Anonymous As _Anonymous_e__Struct
    Public qw As ULong
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=2, CharSet:=CharSet.Unicode)>
Public Structure TIMECODEDATA
    Public time As TIMECODE
    Public dwSMPTEflags As UInteger
    Public dwUser As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=2, CharSet:=CharSet.Unicode)>
Public Structure AVITIMECODEINDEX
    Public fcc As UInteger
    Public cb As UInteger
    Public wLongsPerEntry As UShort
    Public bIndexSubType As Byte
    Public bIndexType As Byte
    Public nEntriesInUse As UInteger
    Public dwChunkId As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public dwReserved() As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1022)> Public aIndex() As TIMECODEDATA
End Structure
import ctypes
from ctypes import wintypes

class TIMECODE(ctypes.Structure):
    _fields_ = [
        ("Anonymous", _Anonymous_e__Struct),
        ("qw", ctypes.c_ulonglong),
    ]

class TIMECODEDATA(ctypes.Structure):
    _pack_ = 2
    _fields_ = [
        ("time", TIMECODE),
        ("dwSMPTEflags", wintypes.DWORD),
        ("dwUser", wintypes.DWORD),
    ]

class AVITIMECODEINDEX(ctypes.Structure):
    _pack_ = 2
    _fields_ = [
        ("fcc", wintypes.DWORD),
        ("cb", wintypes.DWORD),
        ("wLongsPerEntry", ctypes.c_ushort),
        ("bIndexSubType", ctypes.c_ubyte),
        ("bIndexType", ctypes.c_ubyte),
        ("nEntriesInUse", wintypes.DWORD),
        ("dwChunkId", wintypes.DWORD),
        ("dwReserved", wintypes.DWORD * 3),
        ("aIndex", TIMECODEDATA * 1022),
    ]
#[repr(C)]
pub struct TIMECODE {
    pub Anonymous: _Anonymous_e__Struct,
    pub qw: u64,
}

#[repr(C, packed(2))]
pub struct TIMECODEDATA {
    pub time: TIMECODE,
    pub dwSMPTEflags: u32,
    pub dwUser: u32,
}

#[repr(C, packed(2))]
pub struct AVITIMECODEINDEX {
    pub fcc: u32,
    pub cb: u32,
    pub wLongsPerEntry: u16,
    pub bIndexSubType: u8,
    pub bIndexType: u8,
    pub nEntriesInUse: u32,
    pub dwChunkId: u32,
    pub dwReserved: [u32; 3],
    pub aIndex: [TIMECODEDATA; 1022],
}
import "golang.org/x/sys/windows"

type TIMECODE struct {
	Anonymous _Anonymous_e__Struct
	qw uint64
}

type TIMECODEDATA struct {
	time TIMECODE
	dwSMPTEflags uint32
	dwUser uint32
}

type AVITIMECODEINDEX struct {
	fcc uint32
	cb uint32
	wLongsPerEntry uint16
	bIndexSubType byte
	bIndexType byte
	nEntriesInUse uint32
	dwChunkId uint32
	dwReserved [3]uint32
	aIndex [1022]TIMECODEDATA
}
type
  TIMECODE = record
    Anonymous: _Anonymous_e__Struct;
    qw: UInt64;
  end;

  TIMECODEDATA = packed record
    time: TIMECODE;
    dwSMPTEflags: DWORD;
    dwUser: DWORD;
  end;

  AVITIMECODEINDEX = packed record
    fcc: DWORD;
    cb: DWORD;
    wLongsPerEntry: Word;
    bIndexSubType: Byte;
    bIndexType: Byte;
    nEntriesInUse: DWORD;
    dwChunkId: DWORD;
    dwReserved: array[0..2] of DWORD;
    aIndex: array[0..1021] of TIMECODEDATA;
  end;
const TIMECODE = extern struct {
    Anonymous: _Anonymous_e__Struct,
    qw: u64,
};

const TIMECODEDATA = extern struct {
    time: TIMECODE,
    dwSMPTEflags: u32,
    dwUser: u32,
};

const AVITIMECODEINDEX = extern struct {
    fcc: u32,
    cb: u32,
    wLongsPerEntry: u16,
    bIndexSubType: u8,
    bIndexType: u8,
    nEntriesInUse: u32,
    dwChunkId: u32,
    dwReserved: [3]u32,
    aIndex: [1022]TIMECODEDATA,
};
type
  TIMECODE {.bycopy.} = object
    Anonymous: _Anonymous_e__Struct
    qw: uint64

  TIMECODEDATA {.packed.} = object
    time: TIMECODE
    dwSMPTEflags: uint32
    dwUser: uint32

  AVITIMECODEINDEX {.packed.} = object
    fcc: uint32
    cb: uint32
    wLongsPerEntry: uint16
    bIndexSubType: uint8
    bIndexType: uint8
    nEntriesInUse: uint32
    dwChunkId: uint32
    dwReserved: array[3, uint32]
    aIndex: array[1022, TIMECODEDATA]
struct TIMECODE
{
    _Anonymous_e__Struct Anonymous;
    ulong qw;
}

align(2)
struct TIMECODEDATA
{
    TIMECODE time;
    uint dwSMPTEflags;
    uint dwUser;
}

align(2)
struct AVITIMECODEINDEX
{
    uint fcc;
    uint cb;
    ushort wLongsPerEntry;
    ubyte bIndexSubType;
    ubyte bIndexType;
    uint nEntriesInUse;
    uint dwChunkId;
    uint[3] dwReserved;
    TIMECODEDATA[1022] aIndex;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; AVITIMECODEINDEX サイズ: 16384 バイト(x64)
dim st, 4096    ; 4byte整数×4096(構造体サイズ 16384 / 4 切り上げ)
; fcc : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; cb : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; wLongsPerEntry : WORD (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; bIndexSubType : BYTE (+10, 1byte)  poke st,10,値  /  値 = peek(st,10)
; bIndexType : BYTE (+11, 1byte)  poke st,11,値  /  値 = peek(st,11)
; nEntriesInUse : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwChunkId : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; dwReserved : DWORD (+20, 12byte)  varptr(st)+20 を基点に操作(12byte:入れ子/配列)
; aIndex : TIMECODEDATA (+32, 16352byte)  varptr(st)+32 を基点に操作(16352byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global TIMECODEDATA, pack=2
    #field byte time 8
    #field int dwSMPTEflags
    #field int dwUser
#endstruct

#defstruct global AVITIMECODEINDEX, pack=2
    #field int fcc
    #field int cb
    #field short wLongsPerEntry
    #field byte bIndexSubType
    #field byte bIndexType
    #field int nEntriesInUse
    #field int dwChunkId
    #field int dwReserved 3
    #field TIMECODEDATA aIndex 1022
#endstruct

stdim st, AVITIMECODEINDEX        ; NSTRUCT 変数を確保
st->fcc = 100
mes "fcc=" + st->fcc