Blog 2022/2/24
<- previous | index | next ->
- 1957
- Fortran
<html> | |
<head> | |
<script is:inline defer src="https://cdn.jsdelivr.net/npm/img-comparison-slider@8/dist/index.js"></script> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/img-comparison-slider@8/dist/styles.css" /> | |
<script is:inline src="/assets/code/ImageManipulator.js"></script> | |
<style> |
Blog 2022/2/24
<- previous | index | next ->
#if 0 // self-compiling code: chmod +x this file and run it like a script | |
BINARY=vaapi_egl_interop_example | |
gcc -std=c99 -Wall -Wextra -pedantic -Werror -g -fsanitize=address -o $BINARY $0 \ | |
`pkg-config libavcodec libavformat libavutil libva gl egl libdrm --cflags --libs` \ | |
-lX11 -lva-x11 -lva-drm || exit 1 | |
test "$1" = "--compile-only" && exit 0 | |
exec env ASAN_OPTIONS=fast_unwind_on_malloc=0 ./$BINARY $* | |
#endif /* | |
Minimal example application for hardware video decoding on Linux and display |
#!/home/dixyes/awsl/pl/luajit | |
--[[ | |
gist: https://gist.github.com/dixyes/cd945d8a195889de32cb524254d90d33 | |
First to say : ffi niubi! | |
This file is ncursesw command line ui written in lua, using luajit and some C things. | |
Note: pits here: | |
1. variables created by ffi.new("sometype") may be gced at anytime (maybe use ffi.typeof() to create type can resolve this.); | |
workaround: use ffi.C.malloc instead | |
2. struct index may be not reliable: for example a structure struct sStruct{u32 lFirst; u64 llSecond;}; when use instSStruct[0].llSecond, it will use area from llSecond's half to out of bound 4 bytes as llSecond. |
#pragma once | |
#define DYN_ARR_OF(type) struct { \ | |
type *data; \ | |
type *endptr; \ | |
uint32_t capacity; \ | |
} | |
#if !defined(__cplusplus) | |
#define decltype(x) void* |
WAYLAND_PROTOCOLS=/usr/share/wayland-protocols | |
# wayland-scanner is a tool which generates C headers and rigging for Wayland | |
# protocols, which are specified in XML. wlroots requires you to rig these up | |
# to your build system yourself and provide them in the include path. | |
xdg-shell-protocol.h: | |
wayland-scanner server-header \ | |
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ | |
xdg-shell-protocol.c: xdg-shell-protocol.h |
#include <stdio.h> | |
#define STB_IMAGE_WRITE_IMPLEMENTATION | |
#include "stb_image_write.h" | |
#include <ft2build.h> | |
#include FT_FREETYPE_H | |
#define NUM_GLYPHS 128 | |
struct glyph_info { | |
int x0, y0, x1, y1; // coords of glyph in the texture atlas |
# GIT heart FZF | |
# ------------- | |
is_in_git_repo() { | |
git rev-parse HEAD > /dev/null 2>&1 | |
} | |
fzf-down() { | |
fzf --height 50% --min-height 20 --border --bind ctrl-/:toggle-preview "$@" | |
} |
//This program is demo for using pthreads with libev. | |
//Try using Timeout values as large as 1.0 and as small as 0.000001 | |
//and notice the difference in the output | |
//(c) 2009 debuguo | |
//(c) 2013 enthusiasticgeek for stack overflow | |
//Free to distribute and improve the code. Leave credits intact | |
#include <ev.h> | |
#include <stdio.h> // for puts |
#include "H264_Decoder.h" | |
H264_Decoder::H264_Decoder(h264_decoder_callback frameCallback, void* user) | |
:codec(NULL) | |
,codec_context(NULL) | |
,parser(NULL) | |
,fp(NULL) | |
,frame(0) | |
,cb_frame(frameCallback) | |
,cb_user(user) |