H264分析源码学习之结构体篇——h264_stream_t结构体
2017-02-02 16:33
561 查看
最近学习H264的编解码,因此先学习了解H264的结构。我是通过h264分析开源库的源码进行学习的。首先先从数据结构体入手,通过了解重要的数据结构体来认识H264!
首先,我们需要初略的知道,H264数据流就是由一个一个独立的NALU单元构成:
再深入一点,每一个NALU由NALU header 和 NALU payload 两个部分组成(头信息主要说明此单元负载的数据类型,占一个字节)
再深入一点,NALU单元之间需要一个标志来区分开。因此,在一个NALU单元开始前都会有一个开始码(0x000001)
其实,H264流就这么简单!
首先,我们需要初略的知道,H264数据流就是由一个一个独立的NALU单元构成:
... | NALU | NALU | NALU | ... |
... | NALU header | NALU payload | NALU header | NALU payload | ... |
... | Start Code | NALU Header | NALU payload | Start Code | NALU Header | NALU payload | ... |
/** H264 stream Contains data structures for all NAL types that can be handled by this library. When reading, data is read into those, and when writing it is written from those. The reason why they are all contained in one place is that some of them depend on others, we need to have all of them available to read or write correctly. */ /* h264流的结构体: 包含所有NAL类型的数据结构,可以被这个库处理 当读取时,将数据读入这些数据结构体中,当写入时,从这数据结构体中写入 这个结构体在h264_new()函数中申请内存空间,在h264_free()函数中释放 */ typedef struct { nal_t* nal; //NALU单元数据结构(句法元素包括:NALU header的信息,指向NALU payload的指针) sps_t* sps; //sequence parameter sets序列参数集 pps_t* pps; //picture parameter sets图片参数集 aud_t* aud; sei_t* sei; //This is a TEMP pointer at whats in h->seis... int num_seis; slice_header_t* sh; slice_data_rbsp_t* slice_data; sps_t* sps_table[32]; pps_t* pps_table[256]; sei_t** seis; videoinfo_t* info; } h264_stream_t; /** Create a new H264 stream object. Allocates all structures contained within it. @return the stream object */ h264_stream_t* h264_new() { h264_stream_t* h = (h264_stream_t*)calloc(1, sizeof(h264_stream_t)); h->nal = (nal_t*)calloc(1, sizeof(nal_t)); // initialize tables for ( int i = 0; i < 32; i++ ) { h->sps_table[i] = (sps_t*)calloc(1, sizeof(sps_t)); } for ( int i = 0; i < 256; i++ ) { h->pps_table[i] = (pps_t*)calloc(1, sizeof(pps_t)); } h->sps = h->sps_table[0]; h->pps = h->pps_table[0]; h->aud = (aud_t*)calloc(1, sizeof(aud_t)); h->num_seis = 0; h->seis = NULL; h->sei = NULL; //This is a TEMP pointer at whats in h->seis... h->sh = (slice_header_t*)calloc(1, sizeof(slice_header_t)); h->info = (videoinfo_t*)calloc(1, sizeof(videoinfo_t)); h->info->type = 0; return h; }
相关文章推荐
- H264分析源码学习之结构体篇——h264_stream_t结构体
- H264分析源码学习之结构体篇——nal_t结构体
- WEBX2.0学习源码分析(一)初识webx2.0 基本目录结构
- GoAhead 2.1.8嵌入式webserver源码分析学习(二)---源码文件结构分析
- DEDE源码分析与学习之二: member文件结构说明
- cocos2D-X源码分析之从cocos2D-X学习OpenGL----cocos2D-X渲染结构
- Dalvik虚拟机学习1——Dalvik虚拟机源码结构分析
- AndroidPN的学习研究(二)源码结构分析
- 源码分析redis的有序集合,学习skiplist跳跃表数据结构
- 分析.NET基础库源码,学习Stream类及相关类
- cocos2D-X源码分析之从cocos2D-X学习OpenGL(1)----cocos2D-X渲染结构
- 数据结构与算法学习(二)链式存储结构LinkedList源码分析
- ffmpeg学习七:avformat_find_stream_info函数源码分析
- JDK源码学习之HashMap (一) : 底层存储结构分析
- java8学习之Stream源码分析
- 数据结构与算法学习(一)顺序存储结构ArrayList源码分析
- cocos2D-X源码分析之从cocos2D-X学习OpenGL(1)----cocos2D-X渲染结构
- cocos2D-X源码分析之从cocos2D-X学习OpenGL(1)----cocos2D-X渲染结构
- cocos2D-X源码分析之从cocos2D-X学习OpenGL(1)----cocos2D-X渲染结构
- ExtJs源码分析与学习—ExtJs源码结构