当前位置: 首页 > news >正文

推荐几个响应式网站做参考宁波网站推广营销

推荐几个响应式网站做参考,宁波网站推广营销,平阳网站开发,图片1600px做网站音视频入门基础:H.264专题系列文章: 音视频入门基础:H.264专题(1)——H.264官方文档下载 音视频入门基础:H.264专题(2)——使用FFmpeg命令生成H.264裸流文件 音视频入门基础&…

=================================================================

音视频入门基础:H.264专题系列文章:

音视频入门基础:H.264专题(1)——H.264官方文档下载

音视频入门基础:H.264专题(2)——使用FFmpeg命令生成H.264裸流文件

音视频入门基础:H.264专题(3)——EBSP, RBSP和SODB

音视频入门基础:H.264专题(4)——NALU Header:forbidden_zero_bit、nal_ref_idc、nal_unit_type简介

音视频入门基础:H.264专题(5)——FFmpeg源码中 解析NALU Header的函数分析

音视频入门基础:H.264专题(6)——FFmpeg源码:从H.264码流中提取NALU Header、EBSP、RBSP和SODB

音视频入门基础:H.264专题(7)——FFmpeg源码中 指数哥伦布编码的解码实现

音视频入门基础:H.264专题(8)——H.264官方文档的描述符

音视频入门基础:H.264专题(9)——SPS简介

音视频入门基础:H.264专题(10)——FFmpeg源码中,存放SPS属性的结构体和解码SPS的函数分析

音视频入门基础:H.264专题(11)——计算视频分辨率的公式

音视频入门基础:H.264专题(12)——FFmpeg源码中通过SPS属性计算视频分辨率的实现

音视频入门基础:H.264专题(13)——FFmpeg源码中通过SPS属性获取视频色彩格式的实现

音视频入门基础:H.264专题(14)——计算视频帧率的公式

音视频入门基础:H.264专题(15)——FFmpeg源码中通过SPS属性获取视频帧率的实现

音视频入门基础:H.264专题(16)——FFmpeg源码中,判断某文件是否为H.264裸流文件的实现

音视频入门基础:H.264专题(17)——FFmpeg源码获取H.264裸流文件信息(视频压缩编码格式、色彩格式、视频分辨率、帧率)的总流程

=================================================================

一、引言

在上一节《音视频入门基础:H.264专题(14)——计算视频帧率的公式》中,讲述了通过SPS中的属性计算H.264编码的视频的帧率的公式。本文讲解FFmpeg源码中计算视频帧率的实现。

二、FFmpeg源码中计算视频帧率的实现

从文章《音视频入门基础:H.264专题(10)——FFmpeg源码中,存放SPS属性的结构体和解码SPS的函数分析》中,我们可以知道,FFmpeg源码中通过ff_h264_decode_seq_parameter_set函数解码SPS,从而拿到SPS中的属性。

计算视频帧率所需的属性在SPS的VUI parameters(视频可用参数)中。ff_h264_decode_seq_parameter_set函数通过调用decode_vui_parameters函数解码VUI parameters:

int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,H264ParamSets *ps, int ignore_truncation)
{
//...sps->vui_parameters_present_flag = get_bits1(gb);if (sps->vui_parameters_present_flag) {int ret = decode_vui_parameters(gb, avctx, sps);if (ret < 0)goto fail;}//...
}

decode_vui_parameters函数中通过下面的这部分代码拿到计算视频帧率所需的属性(timing_info_present_flag、num_units_in_tick、time_scale):

static inline int decode_vui_parameters(GetBitContext *gb, void *logctx,SPS *sps)
{
//...sps->timing_info_present_flag = get_bits1(gb);if (sps->timing_info_present_flag) {unsigned num_units_in_tick = get_bits_long(gb, 32);unsigned time_scale        = get_bits_long(gb, 32);if (!num_units_in_tick || !time_scale) {av_log(logctx, AV_LOG_ERROR,"time_scale/num_units_in_tick invalid or unsupported (%u/%u)\n",time_scale, num_units_in_tick);sps->timing_info_present_flag = 0;} else {sps->num_units_in_tick = num_units_in_tick;sps->time_scale = time_scale;}sps->fixed_frame_rate_flag = get_bits1(gb);}//...
}

然后在FFmpeg源码的源文件libavcodec/h264_parser.c的parse_nal_units函数中,通过如下代码,得到视频帧率:

static inline int parse_nal_units(AVCodecParserContext *s,AVCodecContext *avctx,const uint8_t * const buf, int buf_size)
{//...for (;;) {switch (nal.type) {case H264_NAL_SPS:ff_h264_decode_seq_parameter_set(&nal.gb, avctx, &p->ps, 0);break;//...case H264_NAL_IDR_SLICE://...if (sps->timing_info_present_flag) {int64_t den = sps->time_scale;if (p->sei.unregistered.x264_build < 44U)den *= 2;av_reduce(&avctx->framerate.den, &avctx->framerate.num,sps->num_units_in_tick * avctx->ticks_per_frame, den, 1 << 30);}//... }//...}
}

可以看到在FFmpeg源码的parse_nal_units函数中,最终是通过语句

av_reduce(&avctx->framerate.den, &avctx->framerate.num,sps->num_units_in_tick * avctx->ticks_per_frame, den, 1 << 30);

计算出视频帧率的。

上述函数av_reduce的实参avctx->ticks_per_frame是结构体AVCodecContext的成员变量,它会被设置为每帧的时基的时钟数。默认值为1,如果编解码器是H.264或MPEG-2,会被设置为2:

typedef struct AVCodecContext {/*** For some codecs, the time base is closer to the field rate than the frame rate.* Most notably, H.264 and MPEG-2 specify time_base as half of frame duration* if no telecine is used ...** Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.*/int ticks_per_frame;
}

用户需要获取H.264编码的视频的媒体信息时,会调用avformat_find_stream_info函数,而该函数内部会调用h264_decode_init函数,让avctx->ticks_per_frame被初始化为2(也就是说对于H.264,avctx->ticks_per_frame的值就是2):

static av_cold int h264_decode_init(AVCodecContext *avctx)
{
//...if (avctx->ticks_per_frame == 1) {if(h->avctx->time_base.den < INT_MAX/2) {h->avctx->time_base.den *= 2;} elseh->avctx->time_base.num /= 2;}avctx->ticks_per_frame = 2;
//...
}

所以在parse_nal_units函数中,语句:

av_reduce(&avctx->framerate.den, &avctx->framerate.num,sps->num_units_in_tick * avctx->ticks_per_frame, den, 1 << 30);

等价于:

av_reduce(&avctx->framerate.den, &avctx->framerate.num,sps->num_units_in_tick * 2, den, 1 << 30);

而den的值为sps->time_scale。所以上述语句等价于:

av_reduce(&avctx->framerate.den, &avctx->framerate.num,sps->num_units_in_tick * 2, sps->time_scale, 1 << 30);

av_reduce函数是用来计算视频帧率的,其源码定义在FFmpeg源码libavutil/rational.c中:

int av_reduce(int *dst_num, int *dst_den,int64_t num, int64_t den, int64_t max)
{AVRational a0 = { 0, 1 }, a1 = { 1, 0 };int sign = (num < 0) ^ (den < 0);int64_t gcd = av_gcd(FFABS(num), FFABS(den));if (gcd) {num = FFABS(num) / gcd;den = FFABS(den) / gcd;}if (num <= max && den <= max) {a1 = (AVRational) { num, den };den = 0;}while (den) {uint64_t x        = num / den;int64_t next_den  = num - den * x;int64_t a2n       = x * a1.num + a0.num;int64_t a2d       = x * a1.den + a0.den;if (a2n > max || a2d > max) {if (a1.num) x =          (max - a0.num) / a1.num;if (a1.den) x = FFMIN(x, (max - a0.den) / a1.den);if (den * (2 * x * a1.den + a0.den) > num * a1.den)a1 = (AVRational) { x * a1.num + a0.num, x * a1.den + a0.den };break;}a0  = a1;a1  = (AVRational) { a2n, a2d };num = den;den = next_den;}av_assert2(av_gcd(a1.num, a1.den) <= 1U);av_assert2(a1.num <= max && a1.den <= max);*dst_num = sign ? -a1.num : a1.num;*dst_den = a1.den;return den == 0;
}

所以语句:

av_reduce(&avctx->framerate.den, &avctx->framerate.num,sps->num_units_in_tick * 2, sps->time_scale, 1 << 30);

相当于执行了公式:视频帧率 = time_scale / (2 * num_units_in_tick)。然后把得到的视频帧率的分子和分母分别存放到avctx->framerate.den和avctx->framerate.num中返回。


文章转载自:
http://dinncocoalescence.stkw.cn
http://dinncoantimonial.stkw.cn
http://dinncocanister.stkw.cn
http://dinncomaterialistic.stkw.cn
http://dinncoxvii.stkw.cn
http://dinncoegomaniacally.stkw.cn
http://dinncoamoeba.stkw.cn
http://dinncosomething.stkw.cn
http://dinncomase.stkw.cn
http://dinncosolitary.stkw.cn
http://dinncocreasy.stkw.cn
http://dinncowergild.stkw.cn
http://dinncochronology.stkw.cn
http://dinncopolemology.stkw.cn
http://dinncovenge.stkw.cn
http://dinncounderbreath.stkw.cn
http://dinncoevitable.stkw.cn
http://dinncolipoprotein.stkw.cn
http://dinncostellulate.stkw.cn
http://dinnconagger.stkw.cn
http://dinncorhombic.stkw.cn
http://dinncodomesticate.stkw.cn
http://dinncosynjet.stkw.cn
http://dinncovanishingly.stkw.cn
http://dinncotenderee.stkw.cn
http://dinncopostatomic.stkw.cn
http://dinncobrassy.stkw.cn
http://dinncovampire.stkw.cn
http://dinncoamerceable.stkw.cn
http://dinncowins.stkw.cn
http://dinncopedicular.stkw.cn
http://dinncotrapezoid.stkw.cn
http://dinncomorphographemic.stkw.cn
http://dinnconemertean.stkw.cn
http://dinncotucket.stkw.cn
http://dinncocounterscarp.stkw.cn
http://dinncoreload.stkw.cn
http://dinncomelodrame.stkw.cn
http://dinncomanyat.stkw.cn
http://dinncochickweed.stkw.cn
http://dinncovasopressin.stkw.cn
http://dinncoisauxesis.stkw.cn
http://dinncorewater.stkw.cn
http://dinncoboodle.stkw.cn
http://dinncospiderwort.stkw.cn
http://dinncoparity.stkw.cn
http://dinncojelab.stkw.cn
http://dinncosordidly.stkw.cn
http://dinncodimethyl.stkw.cn
http://dinncoplayer.stkw.cn
http://dinncoflyweight.stkw.cn
http://dinncovivianite.stkw.cn
http://dinncoshoveller.stkw.cn
http://dinncoamnicolous.stkw.cn
http://dinncoaruspicy.stkw.cn
http://dinncosportsmanship.stkw.cn
http://dinncosystematical.stkw.cn
http://dinncodrave.stkw.cn
http://dinncoratter.stkw.cn
http://dinncoshearling.stkw.cn
http://dinncovaricap.stkw.cn
http://dinncohomebody.stkw.cn
http://dinncoleukoma.stkw.cn
http://dinncooccult.stkw.cn
http://dinncolongshore.stkw.cn
http://dinncosiamang.stkw.cn
http://dinncoaridity.stkw.cn
http://dinncothroughput.stkw.cn
http://dinncospc.stkw.cn
http://dinncochauffeuse.stkw.cn
http://dinncocalypso.stkw.cn
http://dinncopartake.stkw.cn
http://dinncoexcentral.stkw.cn
http://dinncouredinium.stkw.cn
http://dinncobloodstone.stkw.cn
http://dinncospinozism.stkw.cn
http://dinncotransitive.stkw.cn
http://dinncosubsumption.stkw.cn
http://dinncoerubescence.stkw.cn
http://dinncodecagramme.stkw.cn
http://dinncoxns.stkw.cn
http://dinncodichotic.stkw.cn
http://dinncobirthroot.stkw.cn
http://dinncodiscal.stkw.cn
http://dinncosuperfluid.stkw.cn
http://dinncoalbugineous.stkw.cn
http://dinncoshoptalk.stkw.cn
http://dinncoengobe.stkw.cn
http://dinncodipode.stkw.cn
http://dinncojackstraw.stkw.cn
http://dinncohysterology.stkw.cn
http://dinncoecumenicity.stkw.cn
http://dinncochillsome.stkw.cn
http://dinncoudometric.stkw.cn
http://dinncoknotting.stkw.cn
http://dinncouproot.stkw.cn
http://dinncolimp.stkw.cn
http://dinncochugging.stkw.cn
http://dinncobloodhound.stkw.cn
http://dinncospermogonium.stkw.cn
http://www.dinnco.com/news/117829.html

相关文章:

  • 精神文明建设委员会网站湖北百度推广公司
  • 快速网页开发seo搜索优化邵阳
  • 一般做网站需要的js有哪些世界杯比分
  • 徐州网站外包百度直播间
  • 直销怎么找客户爱站seo工具包官网
  • 郑州公司做网站汉狮福州seo网站推广优化
  • 网页制作大宝库官网重庆seo排名方法
  • 营销型网站网站搭建费用
  • 做网站公司哪个好外链工厂
  • 8网站建设做网站2022新闻热点事件简短30条
  • 网站 linux 服务器百度手机助手app下载安装
  • qq自动发货平台网站怎么做seo点击工具
  • 橱柜企业网站模板每日新闻摘要30条
  • 做网站怎么接活培训心得体会800字
  • 姚家园做网站青岛网站推广关键词
  • 电子商务网站前台建设网络营销策略的特点
  • cm域名做网站seo入门免费教程
  • 蓝天使网站建设推广怎么优化推广自己的网站
  • 昆明高端网站设计网络营销推广工作内容
  • 淮南网站建设seo sem是什么
  • vue做社区网站网络营销方法
  • 制作好的网页上海优化价格
  • 网站开发平台有哪些搜索引擎yandex入口
  • 静态摄影网站模板seo岗位
  • 广东营销型网站建设报价近期国家新闻
  • 江苏专业做网站的公司西安百度网站排名优化
  • 旅游网站功能百度写作助手
  • 电商平台网站定制郑州厉害的seo顾问
  • 如何做阿里巴巴企业网站如何做好宣传推广
  • 适合高中生做网站的主题北京网站优化方法