x265-1.8版本-encoder/dpb.h注释

本文介绍x265项目中DPB模块的作用及其实现细节,包括关键帧处理、参考帧列表维护等功能,并探讨了其在提高视频压缩效率方面的作用。
部署运行你感兴趣的模型镜像

注:问号以及未注释部分 会在x265-1.9版本内更新

/*****************************************************************************
 * Copyright (C) 2013 x265 project
 *
 * Authors: Steve Borho <steve@borho.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
 *
 * This program is also available under a commercial proprietary license.
 * For more information, contact us at license @ x265.com.
 *****************************************************************************/

#ifndef X265_DPB_H
#define X265_DPB_H

#include "piclist.h"

namespace X265_NS {
// private namespace for x265

class Frame;
class FrameData;
class Slice;

class DPB//DPB 是:Decoding Picture Buffer
{
public:

    int                m_lastIDR;//在openGOP关闭下 最近的一个关键帧位置
    int                m_pocCRA; //在openGOP打开下 最近的一个关键帧位置
    int                m_maxRefL0;//L0最大帧数(只有前向帧)即配置的参考帧最大数目
    int                m_maxRefL1;//L1最大帧数(只有后向帧) 如果B帧可参考为2 其它为1
    int                m_bOpenGOP;//打开表示,除第一帧为 X265_TYPE_IDR外,其它I帧为 X265_TYPE_I,打开可以提高压缩率,但是要保留前一个I帧,目的是可以获取当前I帧(IDR无须参考任何帧,I帧可能参考其它I帧)
                                  //关闭表示,全部I帧都为IDR帧  默认为打开,但是打开不适用随机访问
                                  //打开即其关键帧为CAR 关闭为IDR
    bool               m_bRefreshPending;//表示有CRA前置帧,遇到CRA帧 设置为true 新帧在CRA后之后 置为false  始化为false  
    bool               m_bTemporalSublayer;//是否应用时域子层
    PicList            m_picList;//存储当前还需要参考的帧(可能未编码) 编码顺序倒序排序 第一帧是离当前编码最近的帧
    PicList            m_freeList;//???更新在PicList的解释
    FrameData*         m_picSymFreeList;

    DPB(x265_param *param)
    {
        m_lastIDR = 0;
        m_pocCRA = 0;
        m_bRefreshPending = false;
        m_picSymFreeList = NULL;
        m_maxRefL0 = param->maxNumReferences;
        m_maxRefL1 = param->bBPyramid ? 2 : 1;
        m_bOpenGOP = param->bOpenGOP;
        m_bTemporalSublayer = !!param->bEnableTemporalSubLayers;
    }

    ~DPB();
    /** 函数功能       : 设置NAL单元类型,将待编码帧加入DPB列表,获取slice参考帧列表等slice参量,将该帧的参考帧的被参考次数加一
    /*  调用范围       : 只在Encoder::encode函数中被调用
    * \参数 newFrame   : 待编码帧
    *   返回值         : null
    **/
    void prepareEncode(Frame*);

    void recycleUnreferenced();

protected:
    /** 函数功能           : slice中rps获取参考帧列表
    /*  调用范围           : 只在DPB::prepareEncode函数中被调用
    * \参数 curPoc         : 当前帧的POC
    * \参数 isRAP          : 是否关键帧
    * \参数 rps            : slice中的rps &slice->m_rps
    * \参数 maxDecPicBuffer: 解码需要的最大buffer大小
    *   返回值             : null
    **/
    void computeRPS(int curPoc, bool isRAP, RPS * rps, unsigned int maxDecPicBuffer);
    /** 函数功能           : 将DPB m_picList列表中在不属于当前帧的参考帧列表的参考状态置为false
    /*  调用范围           : 只在DPB::prepareEncode函数中被调用
    * \参数 rps            : slice中的rps &slice->m_rps
    * \参数 curPoc         : 当前帧的POC
    *   返回值             : null
    **/
    void applyReferencePictureSet(RPS *rps, int curPoc);
    /** 函数功能       : 遇到关键帧,设置关键帧前的被参考状态(一般置为false)
    /*  调用范围       : 只在DPB::prepareEncode函数中被调用
    * \参数 pocCurr    : 当前帧的POC
    * \参数 nalUnitType: 帧类型
    *   返回值         : null
    **/
    void decodingRefreshMarking(int pocCurr, NalUnitType nalUnitType);
    /** 函数功能       : 返回前置图像NAL类型,后置图像NAL类型,关键帧NAL类型(并不是最终类型)
    /*  调用范围       : 只在DPB::prepareEncode函数中被调用
    * \参数 curPOC     : 当前poc
    * \参数 bIsKeyFrame: 是否为IDR帧
    *   返回值         : 返回前置图像NAL类型,后置图像NAL类型,关键帧NAL类型
    **/
    NalUnitType getNalUnitType(int curPoc, bool bIsKeyFrame);
};
}

#endif // X265_DPB_H


 

您可能感兴趣的与本文相关的镜像

Seed-Coder-8B-Base

Seed-Coder-8B-Base

文本生成
Seed-Coder

Seed-Coder是一个功能强大、透明、参数高效的 8B 级开源代码模型系列,包括基础变体、指导变体和推理变体,由字节团队开源

LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf LDF Modes: Finder ~ chain, Compatibility ~ soft Found 37 compatible libraries Scanning dependencies... Dependency Graph |-- ESP32Encoder @ 0.11.8 Building in release mode Compiling .pio/build/esp32-c3-devkitm-1/src/main.cpp.o Linking .pio/build/esp32-c3-devkitm-1/firmware.elf /Users/gengwenhao/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: .pio/build/esp32-c3-devkitm-1/src/main.cpp.o: in function `setup()': /Users/gengwenhao/Documents/PlatformIO/Projects/9KEY_ENCODER/src/main.cpp:22: undefined reference to `ESP32Encoder::attachHalfQuad(int, int)' /Users/gengwenhao/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /Users/gengwenhao/Documents/PlatformIO/Projects/9KEY_ENCODER/src/main.cpp:25: undefined reference to `ESP32Encoder::clearCount()' /Users/gengwenhao/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /Users/gengwenhao/Documents/PlatformIO/Projects/9KEY_ENCODER/src/main.cpp:31: undefined reference to `ESP32Encoder::getCount()' /Users/gengwenhao/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: .pio/build/esp32-c3-devkitm-1/src/main.cpp.o: in function `_GLOBAL__sub_I_encoder': /Users/gengwenhao/Documents/PlatformIO/Projects/9KEY_ENCODER/src/main.cpp:70: undefined reference to `ESP32Encoder::ESP32Encoder(bool, void (*)(void*), void*)' collect2: error: ld returned 1 exit status *** [.pio/build/esp32-c3-devkitm-1/firmware.elf] Error 1 =================================================== [FAILED] Took 1.36 seconds ===
最新发布
08-04
<think>我们正在解决ESP32Encoder库在PlatformIO中出现的未定义引用错误。这种错误通常发生在链接阶段,表明编译器找到了函数声明,但没有找到其实现。以下是一些常见原因及解决方法: ### 1. **检查库的安装** - 确保已正确安装ESP32Encoder库。在PlatformIO中,可以通过`platformio.ini`文件添加依赖。 - 在`platformio.ini`中添加: ``` lib_deps = madhephaestus/ESP32Encoder @ ^0.12.0 ``` ### 2. **检查库的兼容性** - 确保所安装的库版本支持ESP32-C3。由于ESP32-C3是RISC-V架构,某些库可能不支持。ESP32Encoder库从0.12.0版本开始支持ESP32-C3[^1]。 ### 3. **检查头文件包含** - 在代码中正确包含头文件: ```cpp #include <ESP32Encoder.h> ``` ### 4. **链接器错误的具体分析** - 错误信息类似`undefined reference to 'ESP32Encoder::ESP32Encoder()'`,这通常意味着链接器找不到库的实现。可能的原因: - 库未正确安装:检查`.pio/libdeps`目录下是否存在`ESP32Encoder`文件夹。 - 构建系统未链接库:确保PlatformIO能够自动链接已安装的库。 ### 5. **清理并重新构建** - 在PlatformIO中,执行清理并重新构建: ``` pio run --target clean pio run ``` ### 6. **检查硬件支持** - 确保在`platformio.ini`中正确设置了板子型号: ``` board = esp32-c3-devkitm-1 platform = espressif32 ``` ### 7. **更新PlatformIO和平台** - 更新PlatformIO核心和Espressif32平台: ``` pio upgrade pio platform update espressif32 ``` ### 8. **使用正确的命名空间** - 根据库的文档,使用正确的类名。例如: ```cpp ESP32Encoder encoder; ``` ### 9. **检查库的依赖** - 某些库可能依赖其他库。ESP32Encoder依赖于`driver`库,但PlatformIO通常会自动处理。 ### 10. **查看库的示例** - 参考官方示例代码,确保使用方式正确。 ### 示例代码 ```cpp #include <Arduino.h> #include <ESP32Encoder.h> ESP32Encoder encoder; void setup() { encoder.attachSingleEdge(0, 1); // 根据实际引脚调整 } void loop() { Serial.println(encoder.getCount()); delay(100); } ``` ### 如果问题仍然存在 - 查看库的源代码,确认函数实现是否存在。 - 在GitHub上搜索类似问题。 §§相关问题§§ 1. 如何为ESP32-C3在PlatformIO中添加第三方库? 2. 如何更新PlatformIO的核心和平台? 3. ESP32Encoder库在ESP32-C3上使用时需要注意什么?</think>### ESP32Encoder库在PlatformIO中的链接错误解决方案 您在ESP32-C3-DevKitM-1开发板上使用ESP32Encoder库时遇到的`undefined reference`错误,通常是由于链接器找不到库函数的实现代码导致的。以下是系统化的解决步骤: #### 1. **检查库安装与依赖** - 在`platformio.ini`中添加库依赖(使用最新兼容版本): ```ini lib_deps = madhephaestus/ESP32Encoder @ ^0.12.0 ``` - 执行清理重建: ```bash pio run --target clean && pio run ``` - **注意**:ESP32-C3需要库版本≥0.12.0才能支持RISC-V架构[^1] #### 2. **验证硬件配置** - 确保`platformio.ini`正确定义开发板: ```ini [env:esp32-c3] platform = espressif32 board = esp32-c3-devkitm-1 framework = arduino ``` #### 3. **检查代码包含关系** - 在`.cpp`文件中正确包含头文件: ```cpp #include <ESP32Encoder.h> // 注意不是"ESP32Encoder.h" ``` - 全局初始化编码器对象(避免局部声明): ```cpp ESP32Encoder encoder; // 全局对象声明 void setup() { encoder.attachSingleEdge(0, 1); // GPIO0和GPIO1 } ``` #### 4. **解决架构兼容性问题** - 如果是旧版库导致的RISC-V兼容问题: 1. 打开`.pio/libdeps/esp32-c3/ESP32Encoder/src/ESP32Encoder.h` 2. 确保存在以下宏定义: ```cpp #if CONFIG_IDF_TARGET_ESP32C3 #define _ENCODER_USE_RMT #endif ``` #### 5. **更新开发环境** - 升级PlatformIO核心: ```bash pio upgrade ``` - 更新ESP32平台: ```bash pio platform update espressif32 ``` #### 6. **验证最小可运行示例** ```cpp #include <Arduino.h> #include <ESP32Encoder.h> ESP32Encoder encoder; void setup() { Serial.begin(115200); ESP32Encoder::useInternalWeakPullResistors = UP; // 启用内部上拉 encoder.attachSingleEdge(0, 1); // 使用单边沿计数模式 } void loop() { Serial.printf("Count: %d\n", encoder.getCount()); delay(100); } ``` > **常见错误模式**: > `undefined reference to ESP32Encoder::attachSingleEdge(...)` > ➜ 通常表示库未正确链接,检查`.pio/libdeps`目录是否存在库文件
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值