我目前正在研究使用 C++ (C++17) 可变参数模板来生成高效、实时的电路仿真。
我的目标是利用可变参数模板来定义可以在编译时遍历的树。为了定义这样的树,我使用了以下三个结构:
template <auto Tag> struct Leaf
{
static constexpr auto tag = Tag;
};
template <typename ... Children> struct Branch
{
static constexpr auto child_count = sizeof ... (Children);
template <typename Lambda> constexpr void for_each_child(Lambda && lambda)
{
// TODO: Execute 'lambda' on each child.
}
std::tuple<Children ...> m_children {};
};
template <typename Root> struct Tree
{
template <auto Tag> constexpr auto & get_leaf()
{
// TODO: Traverse the tree and find the leaf with tag …Run Code Online (Sandbox Code Playgroud) 基于这个堆栈溢出问题以及WWDC 2014的Apple 对视频编码和解码的直接访问,我制作了一个小型Xcode项目,演示了如何使用AVFoundation解码和显示H.264流。该项目可在github 此处获得。
我已将一系列1000个NALU转储到文件中,并将它们包含在项目中(nalu_000.bin ... nalu_999.bin)。
下面包括代码的有趣部分,该部分分析NALU并将其流式传输到AVSampleBufferDisplayLayer:
@import AVKit;
typedef enum {
NALUTypeSliceNoneIDR = 1,
NALUTypeSliceIDR = 5,
NALUTypeSPS = 7,
NALUTypePPS = 8
} NALUType;
@interface ViewController ()
@property (nonatomic, strong, readonly) VideoView * videoView;
@property (nonatomic, strong) NSData * spsData;
@property (nonatomic, strong) NSData * ppsData;
@property (nonatomic) CMVideoFormatDescriptionRef videoFormatDescr;
@property (nonatomic) BOOL videoFormatDescriptionAvailable;
@end
@implementation ViewController
- (VideoView *)videoView { …Run Code Online (Sandbox Code Playgroud)