Skip to content

Instantly share code, notes, and snippets.

@dwbuiten
dwbuiten / fall.go
Created June 24, 2014 16:12
switch idiom
switch mystr {
case "a", "b", "c", "d", "e":
default:
dostuff()
}
// versus
if myster != "a" && mystr != "=" && mystr != "c" && mystr != "d" && mystr != "e" {
dostuff()
@dwbuiten
dwbuiten / gist:5490198
Last active December 16, 2015 20:09
Static Linking Order for C99-to-C89 Clang Libs
lib\libclang.lib lib\clangARCMigrate.lib lib\clangRewriteCore.lib lib\clangFrontend.lib lib\clangDriver.lib lib\clangSerialization.lib lib\clangParse.lib lib\clangSema.lib lib\clangEdit.lib lib\clangAnalysis.lib lib\clangAST.lib lib\clangLex.lib lib\clangBasic.lib lib\LLVMMC.lib lib\LLVMMCParser.lib lib\LLVMObject.lib lib\LLVMSupport.lib ;ib\LLVMBitstreamReader.lib lib\LLVMBitstreamWriter.lib lib\shell32.lib lib\Advapi32.lib
@dwbuiten
dwbuiten / gist:5490255
Last active December 16, 2015 20:09
Hacky script for compiling dynamic MediaInfo
#!/bin/sh -e
# Replace with whatever versions you need
ZEN_VERSION=0.4.29
LIB_VERSION=0.7.63
MED_VERSION=0.7.63
PREFIX=/usr/local
wget http://mediaarea.net/download/source/libzen/${ZEN_VERSION}/libzen_${ZEN_VERSION}.tar.bz2
wget http://mediaarea.net/download/source/libmediainfo/${LIB_VERSION}/libmediainfo_${LIB_VERSION}.tar.bz2
@dwbuiten
dwbuiten / d2vscan.pl
Created May 22, 2013 21:02
Hacky script to generate a d2v file. Lacks many basic features.
#!/usr/bin/env perl
use strict;
use warnings;
use bigint;
use File::Spec;
use JSON::XS;
my $filename = $ARGV[0];
my $data = `ffprobe -show_streams -show_format -show_frames -of json $filename`;
@dwbuiten
dwbuiten / cref.go
Created January 30, 2016 20:46
A Little CGO Abomination
// Package cref implements a way to hose your Go garbage collection.
package cref
import (
"fmt"
"unsafe"
)
/*
#include <pthread.h>
@dwbuiten
dwbuiten / ts_extract.c
Created September 17, 2014 14:47
L-SMASH ts extraction
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <lsmash.h>
typedef struct ts {
uint64_t dts;
draw.c:30: error: CHECKERS_DEAD_CODE
Node not visited: 20
28. static inline char get_char(char c)
29. {
30. > if (c > 31 && c < 127)
31. return c;
32. else
33.
Original code here: https://github.com/dwbuiten/bxd/blob/master/draw.c#L28-34
draw.c:30: error: CHECKERS_DEAD_CODE
Node not visited: 20
28. static inline char get_char(char c)
29. {
30. > if (c > 31 && c < 127)
31. return c;
32. else
33.
Original code is here: https://github.com/dwbuiten/bxd/blob/master/draw.c#L28-34
// This is pseudocode / example to explain what kind of implementation I mean.
// I have not checked it for off-by-one errors, 100% accurate C compliance, etc.
// It's just to show what I mean, implementation wise.
#define SOME_DEFAULT_SIZE 20
char *vlc_uri_compose(const vlc_url_t *uri)
{
char *buf, *enc;
size_t len = SOME_DEFAULT_SIZE;
daemon404@bbvm:~/dev/f/ffmpeg/tests/data/fate$ grep Seg *.err
h264-conformance-caba1_sva_b.err:Segmentation fault
h264-conformance-cabac_mot_fld0_full.err:Segmentation fault
h264-conformance-cama1_toshiba_b.err:Segmentation fault
h264-conformance-capcm1_sand_e.err:Segmentation fault
h264-conformance-capcmnl1_sand_e.err:Segmentation fault
h264-conformance-cvbs3_sony_c.err:Segmentation fault
h264-conformance-frext-hpcv_brcm_a.err:Segmentation fault
h264-conformance-frext-hpcvfl_bcrm_a.err:Segmentation fault
h264-conformance-nrf_mw_e.err:Segmentation fault