Skip to content

Instantly share code, notes, and snippets.

View cyndibaby905's full-sized avatar

Fred Chen cyndibaby905

  • ByteDance
  • Beijing, China
View GitHub Profile
- (UIImage *)alteredImageFromSampleBuffer:(CMSampleBufferRef)sampleBuffer
{
// Get a reference to the buffer, lock the address, and get a pointer to its data. Easy peasy.
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer, 0);
void *sourceData = CVPixelBufferGetBaseAddress(imageBuffer);
// Set a bunch of variables we need. The "radius" for the blur kernel needs to be positive and odd. The permute map maps the BGRA channels of the buffer to the ARGB that vImage needs.
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
size_t width = CVPixelBufferGetWidth(imageBuffer);
@cyndibaby905
cyndibaby905 / build_ffmpeg_android
Created August 5, 2014 07:14
Build ffmpeg on OS X 10.9
此处主要参考 http://harryhsu.logdown.com/posts/198416-build-ffmpeg-on-mac-os-109
根据我的编译过程做了适当修改
1. Download NDK
https://developer.android.com/tools/sdk/ndk/index.html
我下载的版本是android-ndk-r10,不同的版本在下面的build脚中本需要修改的地方大致相同.
2. Download ffmpeg source code
下载 ffmpeg(http://www.ffmpeg.org/download.html)
推荐 git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
@cyndibaby905
cyndibaby905 / CHAlertViewController.m
Created November 7, 2014 08:58
Just a demo to show how to use runtime functions to implement UIAlertController in iOS 7 or before.
//
// AppDelegate.m
// RuntimeDemo
//
// Created by hangchen on 11/7/14.
// Copyright (c) 2014 hangchen. All rights reserved.
//
#import "AppDelegate.h"
#import <objc/runtime.h>
@cyndibaby905
cyndibaby905 / SmartPointer.h
Last active November 27, 2015 07:48
A standard smart pointer
//
// SmartPointer.h
// MemoryDemo
//
// Created by HangChen on 5/5/15.
// Copyright (c) 2015 HangChen. All rights reserved.
//
#ifndef __MemoryDemo__SmartPointer__
#define __MemoryDemo__SmartPointer__
@cyndibaby905
cyndibaby905 / XCDUUID.m
Created January 27, 2016 08:13 — forked from OliverLetterer/XCDUUID.m
With this gist, I, as a total assembly noob, am trying to understand the XCDUUID runtime hack (https://github.com/0xced/NSUUID/blob/1.0.1/NSUUID.m#L167-L221) to be able to use NSUUID on iOS < 6.0.
@implementation XCDUUID
+ (void) load
{
// query runtime if NSUUID class already exists, if so => done
if (objc_getClass("NSUUID"))
{
return;
}