flv+h264 configuration tag mux和demux
2017-04-14 00:00
1131 查看
flv+h264 configuration tag mux
函数ff_isom_write_avcc()
int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len) { if (len > 6) { /* check for H.264 start code */ if (AV_RB32(data) == 0x00000001 || AV_RB24(data) == 0x000001) { uint8_t *buf=NULL, *end, *start; uint32_t sps_size=0, pps_size=0; uint8_t *sps=0, *pps=0; int ret = ff_avc_parse_nal_units_buf(data, &buf, &len); if (ret < 0) return ret; start = buf; end = buf + len; /* look for sps and pps */ while (end - buf > 4) { uint32_t size; uint8_t nal_type; size = FFMIN(AV_RB32(buf), end - buf - 4); buf += 4; nal_type = buf[0] & 0x1f; if (nal_type == 7) { /* SPS */ sps = buf; sps_size = size; } else if (nal_type == 8) { /* PPS */ pps = buf; pps_size = size; } buf += size; } if (!sps || !pps || sps_size < 4 || sps_size > UINT16_MAX || pps_size > UINT16_MAX) return AVERROR_INVALIDDATA; avio_w8(pb, 1); /* version */ avio_w8(pb, sps[1]); /* profile */ avio_w8(pb, sps[2]); /* profile compat */ avio_w8(pb, sps[3]); /* level */ avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */ avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */ avio_wb16(pb, sps_size); avio_write(pb, sps, sps_size); avio_w8(pb, 1); /* number of pps */ avio_wb16(pb, pps_size); avio_write(pb, pps, pps_size); av_free(start); } else { avio_write(pb, data, len); } } return 0; }
参见标准:
ISO/IEC 14496-15:2010
Information technology -- Coding of audio-visual objects -- Part 15: Advanced Video Coding (AVC) file format
flv+h264 HEVCDecoderConfigurationRecord tag demux
函数ff_h264_decode_extradata
int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps, int *is_avc, int *nal_length_size, int err_recognition, void *logctx) { int ret; if (!data || size <= 0) return -1; if (data[0] == 1) { int i, cnt, nalsize; const uint8_t *p = data; *is_avc = 1; if (size < 7) { av_log(logctx, AV_LOG_ERROR, "avcC %d too short\n", size); return AVERROR_INVALIDDATA; } // Decode sps from avcC cnt = *(p + 5) & 0x1f; // Number of sps p += 6; for (i = 0; i < cnt; i++) { nalsize = AV_RB16(p) + 2; if (nalsize > size - (p - data)) return AVERROR_INVALIDDATA; ret = decode_extradata_ps_mp4(p, nalsize, ps, err_recognition, logctx); if (ret < 0) { av_log(logctx, AV_LOG_ERROR, "Decoding sps %d from avcC failed\n", i); return ret; } p += nalsize; } // Decode pps from avcC cnt = *(p++); // Number of pps for (i = 0; i < cnt; i++) { nalsize = AV_RB16(p) + 2; if (nalsize > size - (p - data)) return AVERROR_INVALIDDATA; ret = decode_extradata_ps_mp4(p, nalsize, ps, err_recognition, logctx); if (ret < 0) { av_log(logctx, AV_LOG_ERROR, "Decoding pps %d from avcC failed\n", i); return ret; } p += nalsize; } // Store right nal length size that will be used to parse all other nals *nal_length_size = (data[4] & 0x03) + 1; } else { *is_avc = 0; ret = decode_extradata_ps(data, size, ps, 0, logctx); if (ret < 0) return ret; } return size; }
相关文章推荐
- MP4+h.265 configuration tag mux和demux
- 【DSP开发】【VS开发】MUX和DEMUX的含义
- Router_Switchboard Configuration<15>
- Ubuntu下安装MySQL出错(dpkg: dependency problems prevent configuration of mysql-community-server)
- tag
- Tomcat启动异常:Could not publish server configuration for Tomcat v7.0 Server at localhost.
- 异常:According to TLD tag beanwrite must be empty but is not
- Visual Studio 2015 WPF增强:调试查看UI布局,Xaml修改tag更智能
- Unit Testing of Spring MVC Controllers: Configuration
- Spring Test @TransactionConfiguration
- No configuration found for the specified action:
- onConfigurationChanged方法介绍及问题解决
- Strange 404 and Eclipse Web Modules configuration
- 接入环信sdk后打包出现Error:Error: Unexpected cast to Button: layout tag was TextView [WrongViewCast]
- Struts2零配置之Configuration by Convention(一)
- Android Studio,Error:Configuration with name 'default' not found.
- JSP 分页框架 Pager Tag Library使用
- The builder launch configuration could not be found.项目启动报错
- configuration system fail to initialize解决办法
- activiti学习笔记4--mail server configuration--20170328