ホーム › Media.MediaFoundation › MFConvertToFP16Array
MFConvertToFP16Array
関数単精度浮動小数点配列を半精度浮動小数点配列へ変換する。
シグネチャ
// MFPlat.dll
#include <windows.h>
HRESULT MFConvertToFP16Array(
WORD* pDest,
const FLOAT* pSrc,
DWORD dwCount
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pDest | WORD* | out |
| pSrc | FLOAT* | in |
| dwCount | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// MFPlat.dll
#include <windows.h>
HRESULT MFConvertToFP16Array(
WORD* pDest,
const FLOAT* pSrc,
DWORD dwCount
);[DllImport("MFPlat.dll", ExactSpelling = true)]
static extern int MFConvertToFP16Array(
out ushort pDest, // WORD* out
ref float pSrc, // FLOAT*
uint dwCount // DWORD
);<DllImport("MFPlat.dll", ExactSpelling:=True)>
Public Shared Function MFConvertToFP16Array(
<Out> ByRef pDest As UShort, ' WORD* out
ByRef pSrc As Single, ' FLOAT*
dwCount As UInteger ' DWORD
) As Integer
End Function' pDest : WORD* out
' pSrc : FLOAT*
' dwCount : DWORD
Declare PtrSafe Function MFConvertToFP16Array Lib "mfplat" ( _
ByRef pDest As Integer, _
ByRef pSrc As Single, _
ByVal dwCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MFConvertToFP16Array = ctypes.windll.mfplat.MFConvertToFP16Array
MFConvertToFP16Array.restype = ctypes.c_int
MFConvertToFP16Array.argtypes = [
ctypes.POINTER(ctypes.c_ushort), # pDest : WORD* out
ctypes.POINTER(ctypes.c_float), # pSrc : FLOAT*
wintypes.DWORD, # dwCount : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MFPlat.dll')
MFConvertToFP16Array = Fiddle::Function.new(
lib['MFConvertToFP16Array'],
[
Fiddle::TYPE_VOIDP, # pDest : WORD* out
Fiddle::TYPE_VOIDP, # pSrc : FLOAT*
-Fiddle::TYPE_INT, # dwCount : DWORD
],
Fiddle::TYPE_INT)#[link(name = "mfplat")]
extern "system" {
fn MFConvertToFP16Array(
pDest: *mut u16, // WORD* out
pSrc: *const f32, // FLOAT*
dwCount: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MFPlat.dll")]
public static extern int MFConvertToFP16Array(out ushort pDest, ref float pSrc, uint dwCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MFPlat_MFConvertToFP16Array' -Namespace Win32 -PassThru
# $api::MFConvertToFP16Array(pDest, pSrc, dwCount)#uselib "MFPlat.dll"
#func global MFConvertToFP16Array "MFConvertToFP16Array" sptr, sptr, sptr
; MFConvertToFP16Array varptr(pDest), varptr(pSrc), dwCount ; 戻り値は stat
; pDest : WORD* out -> "sptr"
; pSrc : FLOAT* -> "sptr"
; dwCount : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MFPlat.dll" #cfunc global MFConvertToFP16Array "MFConvertToFP16Array" var, var, int ; res = MFConvertToFP16Array(pDest, pSrc, dwCount) ; pDest : WORD* out -> "var" ; pSrc : FLOAT* -> "var" ; dwCount : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MFPlat.dll" #cfunc global MFConvertToFP16Array "MFConvertToFP16Array" sptr, sptr, int ; res = MFConvertToFP16Array(varptr(pDest), varptr(pSrc), dwCount) ; pDest : WORD* out -> "sptr" ; pSrc : FLOAT* -> "sptr" ; dwCount : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT MFConvertToFP16Array(WORD* pDest, FLOAT* pSrc, DWORD dwCount) #uselib "MFPlat.dll" #cfunc global MFConvertToFP16Array "MFConvertToFP16Array" var, var, int ; res = MFConvertToFP16Array(pDest, pSrc, dwCount) ; pDest : WORD* out -> "var" ; pSrc : FLOAT* -> "var" ; dwCount : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT MFConvertToFP16Array(WORD* pDest, FLOAT* pSrc, DWORD dwCount) #uselib "MFPlat.dll" #cfunc global MFConvertToFP16Array "MFConvertToFP16Array" intptr, intptr, int ; res = MFConvertToFP16Array(varptr(pDest), varptr(pSrc), dwCount) ; pDest : WORD* out -> "intptr" ; pSrc : FLOAT* -> "intptr" ; dwCount : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mfplat = windows.NewLazySystemDLL("MFPlat.dll")
procMFConvertToFP16Array = mfplat.NewProc("MFConvertToFP16Array")
)
// pDest (WORD* out), pSrc (FLOAT*), dwCount (DWORD)
r1, _, err := procMFConvertToFP16Array.Call(
uintptr(pDest),
uintptr(pSrc),
uintptr(dwCount),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MFConvertToFP16Array(
pDest: Pointer; // WORD* out
pSrc: Pointer; // FLOAT*
dwCount: DWORD // DWORD
): Integer; stdcall;
external 'MFPlat.dll' name 'MFConvertToFP16Array';result := DllCall("MFPlat\MFConvertToFP16Array"
, "Ptr", pDest ; WORD* out
, "Ptr", pSrc ; FLOAT*
, "UInt", dwCount ; DWORD
, "Int") ; return: HRESULT●MFConvertToFP16Array(pDest, pSrc, dwCount) = DLL("MFPlat.dll", "int MFConvertToFP16Array(void*, void*, dword)")
# 呼び出し: MFConvertToFP16Array(pDest, pSrc, dwCount)
# pDest : WORD* out -> "void*"
# pSrc : FLOAT* -> "void*"
# dwCount : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。