ホーム › Media.MediaFoundation › MFInitVideoFormat_RGB
MFInitVideoFormat_RGB
関数幅高さとD3D形式からRGBのMFVIDEOFORMATを初期化する。
シグネチャ
// MFPlat.dll
#include <windows.h>
HRESULT MFInitVideoFormat_RGB(
MFVIDEOFORMAT* pVideoFormat,
DWORD dwWidth,
DWORD dwHeight,
DWORD D3Dfmt
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pVideoFormat | MFVIDEOFORMAT* | in | MFVIDEOFORMAT 構造体へのポインター。この関数は、構造体のメンバーに形式情報を設定します。 |
| dwWidth | DWORD | in | ビデオの幅 (ピクセル単位)。 |
| dwHeight | DWORD | in | ビデオの高さ (ピクセル単位)。 |
| D3Dfmt | DWORD | in | RGB 形式を指定する D3DFORMAT 値。 |
戻り値の型: HRESULT
公式ドキュメント
非圧縮 RGB ビデオ形式用に MFVIDEOFORMAT 構造体を初期化します。
戻り値
この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。
解説(Remarks)
この関数は、指定された RGB 形式に対して妥当な既定値を設定します。
開発者には、MFVIDEOFORMAT 構造体を使用するのではなく、メディアタイプ属性を使用することが推奨されます。Media Type Attributes を参照してください。
一般に、この関数の呼び出しは避けるべきです。形式の詳細をすべて把握している場合は、この関数を使わずに MFVIDEOFORMAT 構造体に値を設定できます。形式の詳細をすべて把握していない場合は、MFVIDEOFORMAT 構造体を使用するよりも属性を使用する方が望ましいです。
Note Windows 7 より前では、この関数は evr.dll からエクスポートされていました。Windows 7 以降では、この関数は mfplat.dll からエクスポートされ、evr.dll は mfplat.dll を呼び出すスタブ関数をエクスポートします。詳細については、Library Changes in Windows 7 を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// MFPlat.dll
#include <windows.h>
HRESULT MFInitVideoFormat_RGB(
MFVIDEOFORMAT* pVideoFormat,
DWORD dwWidth,
DWORD dwHeight,
DWORD D3Dfmt
);[DllImport("MFPlat.dll", ExactSpelling = true)]
static extern int MFInitVideoFormat_RGB(
IntPtr pVideoFormat, // MFVIDEOFORMAT*
uint dwWidth, // DWORD
uint dwHeight, // DWORD
uint D3Dfmt // DWORD
);<DllImport("MFPlat.dll", ExactSpelling:=True)>
Public Shared Function MFInitVideoFormat_RGB(
pVideoFormat As IntPtr, ' MFVIDEOFORMAT*
dwWidth As UInteger, ' DWORD
dwHeight As UInteger, ' DWORD
D3Dfmt As UInteger ' DWORD
) As Integer
End Function' pVideoFormat : MFVIDEOFORMAT*
' dwWidth : DWORD
' dwHeight : DWORD
' D3Dfmt : DWORD
Declare PtrSafe Function MFInitVideoFormat_RGB Lib "mfplat" ( _
ByVal pVideoFormat As LongPtr, _
ByVal dwWidth As Long, _
ByVal dwHeight As Long, _
ByVal D3Dfmt As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MFInitVideoFormat_RGB = ctypes.windll.mfplat.MFInitVideoFormat_RGB
MFInitVideoFormat_RGB.restype = ctypes.c_int
MFInitVideoFormat_RGB.argtypes = [
ctypes.c_void_p, # pVideoFormat : MFVIDEOFORMAT*
wintypes.DWORD, # dwWidth : DWORD
wintypes.DWORD, # dwHeight : DWORD
wintypes.DWORD, # D3Dfmt : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MFPlat.dll')
MFInitVideoFormat_RGB = Fiddle::Function.new(
lib['MFInitVideoFormat_RGB'],
[
Fiddle::TYPE_VOIDP, # pVideoFormat : MFVIDEOFORMAT*
-Fiddle::TYPE_INT, # dwWidth : DWORD
-Fiddle::TYPE_INT, # dwHeight : DWORD
-Fiddle::TYPE_INT, # D3Dfmt : DWORD
],
Fiddle::TYPE_INT)#[link(name = "mfplat")]
extern "system" {
fn MFInitVideoFormat_RGB(
pVideoFormat: *mut MFVIDEOFORMAT, // MFVIDEOFORMAT*
dwWidth: u32, // DWORD
dwHeight: u32, // DWORD
D3Dfmt: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MFPlat.dll")]
public static extern int MFInitVideoFormat_RGB(IntPtr pVideoFormat, uint dwWidth, uint dwHeight, uint D3Dfmt);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MFPlat_MFInitVideoFormat_RGB' -Namespace Win32 -PassThru
# $api::MFInitVideoFormat_RGB(pVideoFormat, dwWidth, dwHeight, D3Dfmt)#uselib "MFPlat.dll"
#func global MFInitVideoFormat_RGB "MFInitVideoFormat_RGB" sptr, sptr, sptr, sptr
; MFInitVideoFormat_RGB varptr(pVideoFormat), dwWidth, dwHeight, D3Dfmt ; 戻り値は stat
; pVideoFormat : MFVIDEOFORMAT* -> "sptr"
; dwWidth : DWORD -> "sptr"
; dwHeight : DWORD -> "sptr"
; D3Dfmt : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MFPlat.dll" #cfunc global MFInitVideoFormat_RGB "MFInitVideoFormat_RGB" var, int, int, int ; res = MFInitVideoFormat_RGB(pVideoFormat, dwWidth, dwHeight, D3Dfmt) ; pVideoFormat : MFVIDEOFORMAT* -> "var" ; dwWidth : DWORD -> "int" ; dwHeight : DWORD -> "int" ; D3Dfmt : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MFPlat.dll" #cfunc global MFInitVideoFormat_RGB "MFInitVideoFormat_RGB" sptr, int, int, int ; res = MFInitVideoFormat_RGB(varptr(pVideoFormat), dwWidth, dwHeight, D3Dfmt) ; pVideoFormat : MFVIDEOFORMAT* -> "sptr" ; dwWidth : DWORD -> "int" ; dwHeight : DWORD -> "int" ; D3Dfmt : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT MFInitVideoFormat_RGB(MFVIDEOFORMAT* pVideoFormat, DWORD dwWidth, DWORD dwHeight, DWORD D3Dfmt) #uselib "MFPlat.dll" #cfunc global MFInitVideoFormat_RGB "MFInitVideoFormat_RGB" var, int, int, int ; res = MFInitVideoFormat_RGB(pVideoFormat, dwWidth, dwHeight, D3Dfmt) ; pVideoFormat : MFVIDEOFORMAT* -> "var" ; dwWidth : DWORD -> "int" ; dwHeight : DWORD -> "int" ; D3Dfmt : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT MFInitVideoFormat_RGB(MFVIDEOFORMAT* pVideoFormat, DWORD dwWidth, DWORD dwHeight, DWORD D3Dfmt) #uselib "MFPlat.dll" #cfunc global MFInitVideoFormat_RGB "MFInitVideoFormat_RGB" intptr, int, int, int ; res = MFInitVideoFormat_RGB(varptr(pVideoFormat), dwWidth, dwHeight, D3Dfmt) ; pVideoFormat : MFVIDEOFORMAT* -> "intptr" ; dwWidth : DWORD -> "int" ; dwHeight : DWORD -> "int" ; D3Dfmt : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mfplat = windows.NewLazySystemDLL("MFPlat.dll")
procMFInitVideoFormat_RGB = mfplat.NewProc("MFInitVideoFormat_RGB")
)
// pVideoFormat (MFVIDEOFORMAT*), dwWidth (DWORD), dwHeight (DWORD), D3Dfmt (DWORD)
r1, _, err := procMFInitVideoFormat_RGB.Call(
uintptr(pVideoFormat),
uintptr(dwWidth),
uintptr(dwHeight),
uintptr(D3Dfmt),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MFInitVideoFormat_RGB(
pVideoFormat: Pointer; // MFVIDEOFORMAT*
dwWidth: DWORD; // DWORD
dwHeight: DWORD; // DWORD
D3Dfmt: DWORD // DWORD
): Integer; stdcall;
external 'MFPlat.dll' name 'MFInitVideoFormat_RGB';result := DllCall("MFPlat\MFInitVideoFormat_RGB"
, "Ptr", pVideoFormat ; MFVIDEOFORMAT*
, "UInt", dwWidth ; DWORD
, "UInt", dwHeight ; DWORD
, "UInt", D3Dfmt ; DWORD
, "Int") ; return: HRESULT●MFInitVideoFormat_RGB(pVideoFormat, dwWidth, dwHeight, D3Dfmt) = DLL("MFPlat.dll", "int MFInitVideoFormat_RGB(void*, dword, dword, dword)")
# 呼び出し: MFInitVideoFormat_RGB(pVideoFormat, dwWidth, dwHeight, D3Dfmt)
# pVideoFormat : MFVIDEOFORMAT* -> "void*"
# dwWidth : DWORD -> "dword"
# dwHeight : DWORD -> "dword"
# D3Dfmt : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mfplat" fn MFInitVideoFormat_RGB(
pVideoFormat: [*c]MFVIDEOFORMAT, // MFVIDEOFORMAT*
dwWidth: u32, // DWORD
dwHeight: u32, // DWORD
D3Dfmt: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc MFInitVideoFormat_RGB(
pVideoFormat: ptr MFVIDEOFORMAT, # MFVIDEOFORMAT*
dwWidth: uint32, # DWORD
dwHeight: uint32, # DWORD
D3Dfmt: uint32 # DWORD
): int32 {.importc: "MFInitVideoFormat_RGB", stdcall, dynlib: "MFPlat.dll".}pragma(lib, "mfplat");
extern(Windows)
int MFInitVideoFormat_RGB(
MFVIDEOFORMAT* pVideoFormat, // MFVIDEOFORMAT*
uint dwWidth, // DWORD
uint dwHeight, // DWORD
uint D3Dfmt // DWORD
);ccall((:MFInitVideoFormat_RGB, "MFPlat.dll"), stdcall, Int32,
(Ptr{MFVIDEOFORMAT}, UInt32, UInt32, UInt32),
pVideoFormat, dwWidth, dwHeight, D3Dfmt)
# pVideoFormat : MFVIDEOFORMAT* -> Ptr{MFVIDEOFORMAT}
# dwWidth : DWORD -> UInt32
# dwHeight : DWORD -> UInt32
# D3Dfmt : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MFInitVideoFormat_RGB(
void* pVideoFormat,
uint32_t dwWidth,
uint32_t dwHeight,
uint32_t D3Dfmt);
]]
local mfplat = ffi.load("mfplat")
-- mfplat.MFInitVideoFormat_RGB(pVideoFormat, dwWidth, dwHeight, D3Dfmt)
-- pVideoFormat : MFVIDEOFORMAT*
-- dwWidth : DWORD
-- dwHeight : DWORD
-- D3Dfmt : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MFPlat.dll');
const MFInitVideoFormat_RGB = lib.func('__stdcall', 'MFInitVideoFormat_RGB', 'int32_t', ['void *', 'uint32_t', 'uint32_t', 'uint32_t']);
// MFInitVideoFormat_RGB(pVideoFormat, dwWidth, dwHeight, D3Dfmt)
// pVideoFormat : MFVIDEOFORMAT* -> 'void *'
// dwWidth : DWORD -> 'uint32_t'
// dwHeight : DWORD -> 'uint32_t'
// D3Dfmt : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MFPlat.dll", {
MFInitVideoFormat_RGB: { parameters: ["pointer", "u32", "u32", "u32"], result: "i32" },
});
// lib.symbols.MFInitVideoFormat_RGB(pVideoFormat, dwWidth, dwHeight, D3Dfmt)
// pVideoFormat : MFVIDEOFORMAT* -> "pointer"
// dwWidth : DWORD -> "u32"
// dwHeight : DWORD -> "u32"
// D3Dfmt : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MFInitVideoFormat_RGB(
void* pVideoFormat,
uint32_t dwWidth,
uint32_t dwHeight,
uint32_t D3Dfmt);
C, "MFPlat.dll");
// $ffi->MFInitVideoFormat_RGB(pVideoFormat, dwWidth, dwHeight, D3Dfmt);
// pVideoFormat : MFVIDEOFORMAT*
// dwWidth : DWORD
// dwHeight : DWORD
// D3Dfmt : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Mfplat extends StdCallLibrary {
Mfplat INSTANCE = Native.load("mfplat", Mfplat.class);
int MFInitVideoFormat_RGB(
Pointer pVideoFormat, // MFVIDEOFORMAT*
int dwWidth, // DWORD
int dwHeight, // DWORD
int D3Dfmt // DWORD
);
}@[Link("mfplat")]
lib LibMFPlat
fun MFInitVideoFormat_RGB = MFInitVideoFormat_RGB(
pVideoFormat : MFVIDEOFORMAT*, # MFVIDEOFORMAT*
dwWidth : UInt32, # DWORD
dwHeight : UInt32, # DWORD
D3Dfmt : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MFInitVideoFormat_RGBNative = Int32 Function(Pointer<Void>, Uint32, Uint32, Uint32);
typedef MFInitVideoFormat_RGBDart = int Function(Pointer<Void>, int, int, int);
final MFInitVideoFormat_RGB = DynamicLibrary.open('MFPlat.dll')
.lookupFunction<MFInitVideoFormat_RGBNative, MFInitVideoFormat_RGBDart>('MFInitVideoFormat_RGB');
// pVideoFormat : MFVIDEOFORMAT* -> Pointer<Void>
// dwWidth : DWORD -> Uint32
// dwHeight : DWORD -> Uint32
// D3Dfmt : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MFInitVideoFormat_RGB(
pVideoFormat: Pointer; // MFVIDEOFORMAT*
dwWidth: DWORD; // DWORD
dwHeight: DWORD; // DWORD
D3Dfmt: DWORD // DWORD
): Integer; stdcall;
external 'MFPlat.dll' name 'MFInitVideoFormat_RGB';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MFInitVideoFormat_RGB"
c_MFInitVideoFormat_RGB :: Ptr () -> Word32 -> Word32 -> Word32 -> IO Int32
-- pVideoFormat : MFVIDEOFORMAT* -> Ptr ()
-- dwWidth : DWORD -> Word32
-- dwHeight : DWORD -> Word32
-- D3Dfmt : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mfinitvideoformat_rgb =
foreign "MFInitVideoFormat_RGB"
((ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> returning int32_t)
(* pVideoFormat : MFVIDEOFORMAT* -> (ptr void) *)
(* dwWidth : DWORD -> uint32_t *)
(* dwHeight : DWORD -> uint32_t *)
(* D3Dfmt : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mfplat (t "MFPlat.dll"))
(cffi:use-foreign-library mfplat)
(cffi:defcfun ("MFInitVideoFormat_RGB" mfinit-video-format-rgb :convention :stdcall) :int32
(p-video-format :pointer) ; MFVIDEOFORMAT*
(dw-width :uint32) ; DWORD
(dw-height :uint32) ; DWORD
(d3-dfmt :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MFInitVideoFormat_RGB = Win32::API::More->new('MFPlat',
'int MFInitVideoFormat_RGB(LPVOID pVideoFormat, DWORD dwWidth, DWORD dwHeight, DWORD D3Dfmt)');
# my $ret = $MFInitVideoFormat_RGB->Call($pVideoFormat, $dwWidth, $dwHeight, $D3Dfmt);
# pVideoFormat : MFVIDEOFORMAT* -> LPVOID
# dwWidth : DWORD -> DWORD
# dwHeight : DWORD -> DWORD
# D3Dfmt : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型