Skip to content

Instantly share code, notes, and snippets.

@pabloko
pabloko / usbhid.cpp
Created April 28, 2021 16:22
Lua 5.1 / luajit - Usb HID library (hidapi) [win/mac/linux]
//using hidapi library: https://github.com/signal11/hidapi/ by Alan Ott
#include <stdio.h>
#include <malloc.h>
#include "hidapi.h"
#pragma comment(lib, "setupapi.lib")
#pragma comment(lib, "hidapi.lib")
#include <Windows.h>
#include <lua.hpp>
#pragma comment(lib, "lua5.1.lib")
unsigned char buffer[0xFFF] = { 0 };
@pabloko
pabloko / 0000-ffmpeg 4.4 with NDI support (updated SDK, fixed timestamps errors).md
Last active February 2, 2024 18:11
ffmpeg 4.4 with NDI support (updated SDK, fixed timestamps errors)

update: https://framagit.org/tytan652/ffmpeg-ndi-patch use this patch. this gist is outdated

ffmpeg 4.4 with NDI

This patch adds libndi_newtek to last ffmpeg version, and fix timecode related issues that produces wrong PTS/DTS timestamps that seems to happen with newer NDI SDKs.

changes

  • Updated libndi methods by newer versions (v2/v3)
@pabloko
pabloko / ArtNet.cs
Last active September 1, 2021 01:15
[C#] Very simple Art-Net DMX sender-only class
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace ArtNetDmx
{
class ArtNet
{
//Udp socket object to make requests
@pabloko
pabloko / wicimagedecoder.hpp
Created February 22, 2022 08:39
Image Decoder based on WIC
/*
* Image decoder based on WIC
* ------------------------------------------------
* Provides synchronous loading of images and copy
* frames in ARGB format.
*
* Example of loading images:
* ImageDecoder::Init();
* ImageDecoder* img = ImageDecoder::FromFile("C:\\path\\to\\image.png");
* ImageDecoder* img = ImageDecoder::FromURL("http://example.com/img.jpg");
@pabloko
pabloko / 1.Query information from NT Handles of shared D3D11 Textures.md
Last active May 11, 2023 11:28
Query information from NT Handles of shared D3D11 Textures

Query information from NT Handles of shared D3D11 Textures

tl;dr: you can't. Only D3D12 and Vulkan resources expose API to query it's physical size

Looking into using the gl extension EXT_external_objects_win32 stumbled upon this <size> parameter in glImportMemoryWin32HandleEXT when using a D3D11 resources

tl;dr: Use 0 as size when using HANDLE_TYPE_D3D11_IMAGE_EXT / HANDLE_TYPE_D3D11_IMAGE_KMT_EXT

the driver implmentation will figure out the internal size of the resource. This size would be alignedWidth * alignedHeight * Bpp where alignment varies depending of the graphics card vendor, model and driver version.

To give some context, here are some values from my NV card with updated drivers