首页 > 其他分享 >av_packet_rescale_ts

av_packet_rescale_ts

时间:2024-03-01 14:44:06浏览次数:17  
标签:src pkt rescale dst ts packet av tb

/**
 * Convert valid timing fields (timestamps / durations) in a packet from one
 * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be
 * ignored.
 *
 * @param pkt packet on which the conversion will be performed
 * @param src_tb source timebase, in which the timing fields in pkt are
 *               expressed
 * @param dst_tb destination timebase, to which the timing fields will be
 *               converted
 */
void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
{
    if (pkt->pts != AV_NOPTS_VALUE)
        pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
    if (pkt->dts != AV_NOPTS_VALUE)
        pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
    if (pkt->duration > 0)
        pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
}

av_packet_rescale_ts用于调整AVPacket结构体中时间戳(timestamp)的单位。AVPacket结构体通常用于存储音频或视频流中的数据包。

参数说明:

  • pkt:指向AVPacket结构体的指针。
  • src_tb:源时间基准。这是一个AVRational结构体,用于表示原始时间戳的单位。
  • dst_tb:目标时间基准。这是一个AVRational结构体,用于表示调整后时间戳的单位。

函数实现原理:
首先,函数会检查AVPacket结构体中的pts(显示时间戳)、dts(解码时间戳)和duration(持续时间)是否为AV_NOPTS_VALUE,如果不是,则对这些时间戳进行调整。
av_rescale_q是一个用于调整时间戳的函数,它接受三个参数:a(原始时间戳)、b(原始时间基准)和c(目标时间基准)。函数会将ab转换为c

注意事项:

  • 在使用这个函数之前,请确保已经正确设置了AVPacket结构体中的时间戳。
  • 注意检查src_tbdst_tb的值是否合法,否则可能导致转换结果不正确。

标签:src,pkt,rescale,dst,ts,packet,av,tb
From: https://www.cnblogs.com/faithlocus/p/18047037

相关文章

  • SiteServer CMS远程模板下载getshell漏洞导致的黑SEO利用分析溯源
    前言某日中午,涉及一代理商客户网站发现异常SQ内容,要求进行溯源分析并找出根本原因。0x01初步分析通过提供的链接(www.xxx.com.cn/2023j19tPLKn2/55151),确认涉及黑帽SEO活动,通过百度搜索进一步验证也证实了这一点。0x02日志分析黑客常常在植入菠菜或非法广告的网站中设置后......
  • Go 100 mistakes - #86: Sleeping in unit tests
      ......
  • Go 100 mistakes - #82: Not categorizing tests
         ......
  • ssts-hospital-web-master项目实战记录三十:项目迁移-Hook实现(useSystemService)
    记录时间:2024-02-29一、useSystemService模块实现service/system-service/useTerminalService.tsimporthydatefrom'@/utils/date-format'import{LogInfo}from'@/framework/utils/log-local'import{Device}from'@/types/device'impor......
  • Codeforces 1455E Four Points
    首先确定每个点最后走到的是哪一个点。这部分可以枚举全排列。假设左上角的点为\((x_0,y_0)\),右上角的点为\((x_1,y_1)\),左下角的点为\((x_2,y_2)\),右下角的点为\((x_3,y_3)\)。令最终的点为\((x'_0,y'_0)\),以此类推。那么最终的答案就是\(\sum\limits_{i=0}^3|......
  • 浅析TSN网络之车载以太网协议测试
    TSN是一项从视频音频数据领域延伸至工业领域、汽车领域的技术。TSN最初来源于音视频领域的应用需求,当时该技术被称为AVB,由于针对音视频网络需要较高的带宽和最大限度的实时,借助AVB能较好的传输高质量音视频。2012年,AVB任务组在其章程中扩大了时间确定性以太网的应用需求和适用范......
  • TSINGSEE青犀AI智能分析网关V4区域入侵检测算法及应用介绍
    区域入侵检测算法主要应用于需要高度安全防护的场所,如:电力、水利、石油等国家基础设施场所;政府机关、军事基地等重要设施;监狱、看守所等监管场所;大型企业、工厂等生产区域;校园、住宅小区、楼宇等。这些场所通常具有明确的周界警戒区域,需要对非法入侵行为进行实时监测和预警。TSI......
  • racial traits in wow classic
    humanDiplomacy—Gaina10%bonustoanyfactionpointgains.MaceSpecialization—Increasesyourskillwithone-handandtwo-handMacesby5.Perception—Thisincreasesstealthdetectionfor20seconds,withacooldownof3minutes.SwordSpecializati......
  • ssts-hospital-web-master项目实战记录三十:项目迁移-Hook实现(useDeviceStore)
    记录时间:2024-02-28一、useDeviceStore模块实现types/device.ts//定义DeviceInfo的类型interfaceDeviceInfo{ Id:string TypeId:number TypeName:string DeviceId:number OrderNo:number DeviceName:string DeviceCode:string ParentI......
  • 11 .Codeforces Round 891 (Div. 3)E. Power of Points(推公式+前缀和优化)
    E.PowerofPoints题解参考#include<bits/stdc++.h>#defineintlonglong#definerep(i,a,b)for(inti=(a);i<=(b);++i)#definefep(i,a,b)for(inti=(a);i>=(b);--i)#define_for(i,a,b)for(inti=(a);i<(b);++i)#definepii......