Skip to content

Instantly share code, notes, and snippets.

View depthlove's full-sized avatar

depthlove depthlove

View GitHub Profile
@depthlove
depthlove / openh264-android-build.sh
Created February 17, 2022 15:58 — forked from KivApple/openh264-android-build.sh
Script to build OpenH264 library for Android NDK under Linux (requires Android NDK, curl, unzip)
#!/bin/sh
export NDK=~/Apps/AndroidSDK/ndk-bundle # Change me
export JNILIBS_DIR=../../app/src/main/jniLibs # Change me
export INCLUDE_DIR=../../app/src/main/cpp/libopenh264 # Change me
export DOWNLOAD_URL=https://github.com/cisco/openh264/archive/master.zip
mkdir -p tmp
ln -sf $NDK/prebuilt/linux-x86_64/bin/yasm tmp/nasm
export PATH=$(pwd)/tmp:$PATH
@depthlove
depthlove / headphones-detect.c
Created October 11, 2019 12:54 — forked from kyleneideck/headphones-detect.c
Runs a command when headphones are plugged in to or unplugged from the built-in audio device.
//
// headphones-detect.c
// Kyle Neideck, [email protected]
//
// Compile with:
// clang -framework CoreAudio -framework CoreFoundation -o headphones-detect headphones-detect.c
//
// Runs a command when headphones are plugged in to or unplugged from the
// built-in audio device.
//
@depthlove
depthlove / NSString+Random.h
Created June 22, 2018 05:29 — forked from mdippery/NSString+Random.h
Generate random strings in Objective-C
/*
* Copyright (C) 2011 Michael Dippery <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@depthlove
depthlove / makeAnimatedGif.m
Created June 5, 2018 10:37 — forked from mayoff/makeAnimatedGif.m
Example of creating an animated GIF on iOS, with no 3rd-party code required. This should also be easy to port to OS X.
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
static UIImage *frameImage(CGSize size, CGFloat radians) {
UIGraphicsBeginImageContextWithOptions(size, YES, 1); {
[[UIColor whiteColor] setFill];
UIRectFill(CGRectInfinite);
CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(gc, size.width / 2, size.height / 2);
@depthlove
depthlove / UIImage+Scale.m
Created December 19, 2017 05:22 — forked from tomasbasham/UIImage+Scale.m
Scale a UIImage to any given rect keeping the aspect ratio
@implementation UIImage (scale)
/**
* Scales an image to fit within a bounds with a size governed by
* the passed size. Also keeps the aspect ratio.
*
* Switch MIN to MAX for aspect fill instead of fit.
*
* @param newSize the size of the bounds the image must fit within.
* @return a new scaled image.
@depthlove
depthlove / GPUImageMovie.h
Created October 11, 2017 17:31 — forked from pgodino/GPUImageMovie.h
Play audio with movie
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import "GPUImageOpenGLESContext.h"
#import "GPUImageOutput.h"
#import "TPCircularBuffer.h"
#ifndef max
#define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
#endif
@depthlove
depthlove / GPUImageFiveInputFilter.h
Created October 11, 2017 17:28 — forked from georgmay/GPUImageFiveInputFilter.h
GPUImageFilter with custom shader up for five textures. Never thought I'd gonna make something like this.
#import <GPUImage/GPUImage.h>
#import "GPUImageFourInputFilter.h"
@interface GPUImageFiveInputFilter : GPUImageFourInputFilter
{
GPUImageFramebuffer *fifthInputFramebuffer;
GLint filterFifthTextureCoordinateAttribute;
GLint filterInputTextureUniform5;
GPUImageRotationMode inputRotation5;
@depthlove
depthlove / gist:3d84efa4212214305f7652b57371470a
Created October 11, 2017 17:27 — forked from DarcyRayner/gist:5112945
GPUImageMovie with audio playback
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import "GPUImageOpenGLESContext.h"
#import "GPUImageOutput.h"
/** Protocol for getting Movie played callback.
*/
@protocol GPUImageMovieDelegate <NSObject>
- (void)didCompletePlayingMovie;
#import <AVFoundation/AVFoundation.h>
#import "GPUImageLayer.h"
#import "GPUImageOutput.h"
#import "GPUImageFilter.h"
@interface GPUImageLayer() {
GPUImageFramebuffer *inputFramebufferForDisplay;
GLProgram *displayProgram;
GLint displayPositionAttribute, displayTextureCoordinateAttribute;
@depthlove
depthlove / ColorDetect.m
Created October 11, 2017 17:21 — forked from nhisyam/ColorDetect.m
Code snippets to show color detection problem using GPUImage
#import "ColorDetectVC.h"
@interface ColorDetectVC ()
{
GPUImageVideoCamera *videoCamera;
GPUImageFilter *rotationFilter;
GPUImageView *filteredVideoView;
GPUImageRawData *positionRawData;
}
@end