This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned char* rgb_to_monochrome(unsigned char *rgbImg, int width, int height, int colorspace, int weighted) { //RGB(A) -> Mono | |
unsigned char *monoImg = malloc(width * height); | |
int m = 0, n = 0; | |
register r = width * height; | |
//weighted averaging better matches human perception. Human eyes perceive green more strongly than red, and red more strongly than blue | |
//the standard weights are about .3R + .6G + .1B | |
//the weights here are adusted to make them faster to compute. The difference is minimal | |
if(colorspace == 3) { //RGB | |
if(weighted) //weighted averaging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <unistd.h> | |
#include <pthread.h> | |
#include <netinet/in.h> | |
#include <sys/socket.h> | |
#include <signal.h> | |
#define THREADS 4 | |
#define QUEUE_DEPTH 32 //power of 2 | |
#define BUFFER_SIZE 2048 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//convert an integer IPv4 address to a string OR a string to an integer IPv4 address | |
//STR to IP | |
static unsigned int str_to_ip(char *str) { | |
//assumes str is properly formatted IPv4 address | |
register unsigned int ip, octet; | |
register char *tail = str; | |
while(*tail++) | |
; //work backwards to track decimal position |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const unsigned char digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
//if you trust your input only has valid characters (defined above), you can cut this in half (123 instead of 256) | |
//probably not recommended, just in case, as invalid characters could cause a seg fault | |
unsigned char digitsDecode[256] = {0}; | |
for(int i = 0; i < 64; i++) | |
digitsDecode[digits[i]] = i; | |
int base64_encode(register unsigned char *buff, unsigned char* str, int len) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Generate .BIF media preview thumbnails | |
#REQUIRES: ffmpeg, mediainfo, and roku's biftool | |
if [ -z "$1" ]; then echo -e "\nGenerate .BIF media preview thumbnails\nFiles are stored in source folder\n\nUsage: ${0##*/} [video files/directories...] <Absolute or Relative paths. Recursive>\n";exit 1;fi | |
tmpdir="/tmp/bifgen" | |
[ -d "$tmpdir" ] && rm -f "$tmpdir"/* || mkdir -p "$tmpdir" | |
IFS=$'\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Creates an animated thumbnail of a video clip | |
#This script uses scene cuts instead of fixed time intervals, and does not work well for videos with few/infrequent scene cuts | |
if [ -z "$1" ];then echo "Usage: <Video Files...> [outputs to same dir as input]" &>2;exit 1;fi | |
numOfScenes=8 #max number of scenes | |
sceneLength=1.5 #length of each scene in seconds | |
sceneDelay=1.7 #time (seconds) after a frame cut to start scene (to avoid transition effects) | |
for i;do |