-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathFFTConvertUtil.h
More file actions
70 lines (55 loc) · 1.98 KB
/
FFTConvertUtil.h
File metadata and controls
70 lines (55 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// FFTConvertUtil.h
// FFmpegTutorial
//
// Created by Matt Reach on 2020/6/3.
//
// AVFrame 转换工具类
#import <Foundation/Foundation.h>
#import <CoreMedia/CMSampleBuffer.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CoreImage/CoreImage.h>
#if TARGET_OS_IOS
#import <UIKit/UIImage.h>
#else
#import <AppKit/NSImage.h>
#import <AppKit/NSOpenGL.h>
#endif
typedef struct AVFrame AVFrame;
NS_ASSUME_NONNULL_BEGIN
@interface FFTConvertUtil : NSObject
/**
AVFrame to CGImage,pixel fmt support [RGB555BE/RGB555LE/RGB24/ARGB/0RGB/RGBA/RGB0]
*/
+ (CGImageRef _Nullable)createImageFromRGBFrame:(AVFrame*)frame;
/**
AVFrame to CIImage,pixel fmt support [ARGB/0RGB/RGBA/RGB0/ABGR/0BGR/BGRA/BGR0]
注:ABGR/0BGR form iOS 9 supported.
*/
+ (CIImage* )ciImageFromRGB32orBGR32Frame:(AVFrame*)frame;
+ (int)cvpixelFormatTypeWithAVFrame:(AVFrame *)frame;
/// create CVPixelBufferPool
+ (CVPixelBufferPoolRef _Nullable)createPixelBufferPoolWithAVFrame:(AVFrame *)frame;
/**
AVFrame to CVPixelBuffer,pixel fmt support [RGB24/ARGB/0RGB/BGRA/BGR0/NV12/NV21]
注:内部会将 NV21 软排为 NV12.
*/
+ (CVPixelBufferRef _Nullable)pixelBufferFromAVFrame:(AVFrame*)frame opt:(CVPixelBufferPoolRef _Nullable)poolRef;
+ (CMSampleBufferRef)createSampleBufferRefFromCVPixelBufferRef:(CVPixelBufferRef)pixelBuffer;
#if TARGET_OS_IOS
///截取原视频画面
+ (UIImage *)snapshot:(GLint)renderbuffer scale:(CGFloat)scale;
#else
///截取当前屏幕显示的画面
+ (NSImage *)snapshot:(NSOpenGLContext *)openGLContext size:(CGSize)size;
///截取原视频画面
+ (NSImage *)snapshotFBO:(GLint)renderbuffer size:(CGSize)size;
#endif
//黑白电视机雪花屏
+ (CVPixelBufferRef)snowPixelBuffer:(int)w h:(int)h opt:(CVPixelBufferPoolRef)poolRef;
//黑白色阶图
+ (CVPixelBufferRef)grayColorBarPixelBuffer:(int)w h:(int)h barNum:(int)barNum opt:(CVPixelBufferPoolRef)poolRef;
//三个小球
+ (CVPixelBufferRef)ball3PixelBuffer:(int)w h:(int)h opt:(CVPixelBufferPoolRef)poolRef;
@end
NS_ASSUME_NONNULL_END