FFmpeg源码:skip_bits、skip_bits1、show_bits函数分析

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

GetBitContext结构体和其相关的函数分析:

FFmpeg中位操作相关的源码:GetBitContext结构体,init_get_bits函数、get_bits1函数和get_bits函数分析

FFmpeg源码:skip_bits、skip_bits1、show_bits函数分析

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

一、skip_bits函数

skip_bits函数定义在FFmpeg源码(本文演示用的FFmpeg源码版本为7.0.1)的头文件libavcodec/get_bits.h中:

cpp 复制代码
static inline void skip_bits(GetBitContext *s, int n)
{
    OPEN_READER(re, s);
    LAST_SKIP_BITS(re, s, n);
    CLOSE_READER(re, s);
}

该函数在已使用init_get_bits函数进行初始化后,才能被调用。其作用是跳过s->buffer指向的缓冲区中的从第s->index位开始的音视频码流二进制数据,总共跳过n位(bit)。执行完skip_bits函数后,s->index的值会加n。

形参s:既是输入型参数也是输出型参数。指向已经被初始化的GetBitContext类型的变量。

形参n:输入型参数。需要跳过的位数。

返回值:无

二、skip_bits1函数

skip_bits1函数定义在FFmpeg源码的头文件libavcodec/get_bits.h中:

cpp 复制代码
static inline void skip_bits1(GetBitContext *s)
{
    skip_bits(s, 1);
}

该函数在已使用init_get_bits函数进行初始化后,才能被调用。其作用是跳过s->buffer指向的缓冲区中的第s->index位音视频码流二进制数据,总共跳过1位(bit)。执行完skip_bits1函数后,s->index的值会加1。

形参s:既是输入型参数也是输出型参数。指向已经被初始化的GetBitContext类型的变量。

返回值:无

三、show_bits函数

show_bits函数定义在FFmpeg源码的头文件libavcodec/get_bits.h中:

cpp 复制代码
/**
 * Show 1-25 bits.
 */
static inline unsigned int show_bits(GetBitContext *s, int n)
{
    register unsigned int tmp;
    OPEN_READER_NOSIZE(re, s);
    av_assert2(n>0 && n<=25);
    UPDATE_CACHE(re, s);
    tmp = SHOW_UBITS(re, s, n);
    return tmp;
}

该函数在已使用init_get_bits函数进行初始化后,才能被调用。其作用是展示s->buffer指向的缓冲区中的从第s->index位开始的音视频码流二进制数据,总共展示n位(bit)。执行show_bits函数后,s->index的值不会增加。

形参s:输入型参数。指向已经被初始化的GetBitContext类型的变量。

形参n:输入型参数。总共需要展示的位数。

返回值:被展示的n位(bit)的数据的值。

相关推荐
l1t1 天前
使用ffmpeg把英语四级听力MP3文件转成wav供模型识别
ffmpeg·语音识别
liulilittle3 天前
Windows 11 上搭建 YouTube 视频下载工具:yt-dlp + FFmpeg
windows·ffmpeg·音视频
指尖在键盘上舞动3 天前
Cannot find matching video player interface for ‘ffpyplayer‘.解决方案
linux·ubuntu·ffmpeg·psychopy·ffpyplayer
glumes4 天前
音视频教程-第二节
ffmpeg
softbangong4 天前
899-批量视频处理工具
ffmpeg·格式转换·批量处理·音频提取·视频处理工具·视频截取
智能工业品检测-奇妙智能5 天前
SpringBoot整合FFmpeg的方法
人工智能·ffmpeg·springboot·deepseek·openclaw
斌蔚司李5 天前
Windows 上安装 FFmpeg
windows·ffmpeg
binderIPC5 天前
Android项目中FFmpeg的.so包使用详情
android·ffmpeg
java_nn5 天前
使用ffmpeg直播推流
ffmpeg
智能工业品检测-奇妙智能5 天前
快速直播:Node.js + FFmpeg + flv.js 全栈实战
javascript·ffmpeg·node.js