Skip to content

Instantly share code, notes, and snippets.

// 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;

Things to Look for When Evaluating Encoders

"Our encoder mixes DCT synergies and gamma radiation to provide excellent quality that abides by industry standard salsa dancing techniques, using adaptive streaming techniques." — Vendor.

First Steps

  1. First, verify they actually have a product to sell that actually exists and can be tested in-house.

    Warning signs: incredibly vague descriptions of the product, lots of "patent pending" claims with no real patents to be found, and insistence that they can do the testing for you and provide metrics instead of letting you test it yourself.

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
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
@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>

Problems & Solutions for Interaction Between C and Go

At Vimeo, on the transcoding team, we work a lot with Go, and a lot with C, for various tasks such as media ingest. This means we use CGO quite extensively, and consequently, have run into bits that are perhaps not very well documented, if at all. Below is my effort to document some of the problems we've run into, and how we fixed or worked around them.

Many of these are obviously wrong in retrospect, but hindsight is 20/20, and these problems do exist in many codebases currently.

Some are definitely ugly, and I much welcome better solutions! Tweet me at @daemon404 if you have any, or have your own CGO story/tips, please! I'd love to learn of them.

Table of Contents

@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;
@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()
/*
* posix_memalign wrapper with random failurres
*
* Copyright (c) 2013, Derek Buitenhuis
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@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`;