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

Mpeg2TableSampleHdr

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

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

フィールド

フィールドサイズx64x86説明
SectionCountBYTE1+0+0サンプルに含まれるセクション数。
ReservedBYTE3+1+1予約フィールド。将来の拡張用で通常は0。
SectionOffsetsINT4+4+4各セクションの開始オフセット配列。可変長の先頭要素。

各言語での定義

#include <windows.h>

// Mpeg2TableSampleHdr  (x64 8 / x86 8 バイト)
#pragma pack(push, 1)
typedef struct Mpeg2TableSampleHdr {
    BYTE SectionCount;
    BYTE Reserved[3];
    INT SectionOffsets[1];
} Mpeg2TableSampleHdr;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct Mpeg2TableSampleHdr
{
    public byte SectionCount;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] Reserved;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public int[] SectionOffsets;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure Mpeg2TableSampleHdr
    Public SectionCount As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public Reserved() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public SectionOffsets() As Integer
End Structure
import ctypes
from ctypes import wintypes

class Mpeg2TableSampleHdr(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("SectionCount", ctypes.c_ubyte),
        ("Reserved", ctypes.c_ubyte * 3),
        ("SectionOffsets", ctypes.c_int * 1),
    ]
#[repr(C, packed(1))]
pub struct Mpeg2TableSampleHdr {
    pub SectionCount: u8,
    pub Reserved: [u8; 3],
    pub SectionOffsets: [i32; 1],
}
import "golang.org/x/sys/windows"

type Mpeg2TableSampleHdr struct {
	SectionCount byte
	Reserved [3]byte
	SectionOffsets [1]int32
}
type
  Mpeg2TableSampleHdr = packed record
    SectionCount: Byte;
    Reserved: array[0..2] of Byte;
    SectionOffsets: array[0..0] of Integer;
  end;
const Mpeg2TableSampleHdr = extern struct {
    SectionCount: u8,
    Reserved: [3]u8,
    SectionOffsets: [1]i32,
};
type
  Mpeg2TableSampleHdr {.packed.} = object
    SectionCount: uint8
    Reserved: array[3, uint8]
    SectionOffsets: array[1, int32]
align(1)
struct Mpeg2TableSampleHdr
{
    ubyte SectionCount;
    ubyte[3] Reserved;
    int[1] SectionOffsets;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; Mpeg2TableSampleHdr サイズ: 8 バイト(x64)
dim st, 2    ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; SectionCount : BYTE (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; Reserved : BYTE (+1, 3byte)  varptr(st)+1 を基点に操作(3byte:入れ子/配列)
; SectionOffsets : INT (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global Mpeg2TableSampleHdr, pack=1
    #field byte SectionCount
    #field byte Reserved 3
    #field int SectionOffsets 1
#endstruct

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