From 7bcb9e7e949ba014f1811890149cc44f20f8202a Mon Sep 17 00:00:00 2001 From: Malanchi Date: Thu, 16 Jan 2025 17:22:41 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c | 10 ++++++++++ VisionSDK/Ascendffmpeg/libavcodec/avcodec.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c b/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c index 7f091358a..0ccbbd16a 100644 --- a/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c +++ b/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c @@ -589,6 +589,16 @@ static int hi_mpi_encode(ASCENDEncContext_t *ctx, const AVFrame *frame) { av_log(ctx, AV_LOG_DEBUG, "Send frame size: %ux%u, pts:%ld, frame type:%d.\n", frame->width, frame->height, frame->pts, frame->pict_type); + + AscendEncPrivateData_t* priv_data = frame->opaque; + if (priv_data && priv_data->next_frame_is_I_frame) { + ret = hi_mpi_venc_request_idr(ctx->channel_id, HI_TRUE); + if (ret) { + av_log(ctx, AV_LOG_ERROR, "Set I-frame failed. ret is %d.\n", ret); + return ret; + } + priv_data->next_frame_is_I_frame = false; + } hi_venc_start_param recvParam; recvParam.recv_pic_num = -1; diff --git a/VisionSDK/Ascendffmpeg/libavcodec/avcodec.h b/VisionSDK/Ascendffmpeg/libavcodec/avcodec.h index 8a71c0423..ac310cba5 100644 --- a/VisionSDK/Ascendffmpeg/libavcodec/avcodec.h +++ b/VisionSDK/Ascendffmpeg/libavcodec/avcodec.h @@ -28,6 +28,7 @@ */ #include +#include #include "libavutil/samplefmt.h" #include "libavutil/attributes.h" #include "libavutil/avutil.h" @@ -4181,4 +4182,8 @@ AVCPBProperties *av_cpb_properties_alloc(size_t *size); * @} */ +typedef struct AscendEncPrivateData { + bool next_frame_is_I_frame; +} AscendEncPrivateData_t; + #endif /* AVCODEC_AVCODEC_H */ -- Gitee From 001cc199b378a3a9714a16325ddd2cc833adaf27 Mon Sep 17 00:00:00 2001 From: Malanchi Date: Mon, 20 Jan 2025 10:28:03 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ascendffmpeg/libavcodec/ascend_enc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c b/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c index 0ccbbd16a..2f747bd61 100644 --- a/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c +++ b/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c @@ -590,16 +590,6 @@ static int hi_mpi_encode(ASCENDEncContext_t *ctx, const AVFrame *frame) av_log(ctx, AV_LOG_DEBUG, "Send frame size: %ux%u, pts:%ld, frame type:%d.\n", frame->width, frame->height, frame->pts, frame->pict_type); - AscendEncPrivateData_t* priv_data = frame->opaque; - if (priv_data && priv_data->next_frame_is_I_frame) { - ret = hi_mpi_venc_request_idr(ctx->channel_id, HI_TRUE); - if (ret) { - av_log(ctx, AV_LOG_ERROR, "Set I-frame failed. ret is %d.\n", ret); - return ret; - } - priv_data->next_frame_is_I_frame = false; - } - hi_venc_start_param recvParam; recvParam.recv_pic_num = -1; int ret = hi_mpi_venc_start_chn(ctx->channel_id, &recvParam); @@ -756,6 +746,15 @@ static int ff_himpi_enc_receive_packet(AVCodecContext *avctx, AVPacket *avpkt) continue; } + AscendEncPrivateData_t* priv_data = frame->opaque; + if (priv_data && priv_data->next_frame_is_I_frame) { + ret = hi_mpi_venc_request_idr(ctx->channel_id, HI_TRUE); + if (ret) { + av_log(ctx, AV_LOG_ERROR, "Set I-frame failed. ret is %d.\n", ret); + return ret; + } + } + send_ret = hi_mpi_encode(ctx, &frame); av_frame_unref(&frame); if (send_ret < 0 && send_ret != AVERROR_EOF) { -- Gitee From 46ea146460e9ae08bcd90bf13f917660fa8c7b36 Mon Sep 17 00:00:00 2001 From: Malanchi Date: Mon, 20 Jan 2025 11:00:28 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c b/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c index 2f747bd61..a85da9060 100644 --- a/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c +++ b/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c @@ -746,7 +746,7 @@ static int ff_himpi_enc_receive_packet(AVCodecContext *avctx, AVPacket *avpkt) continue; } - AscendEncPrivateData_t* priv_data = frame->opaque; + AscendEncPrivateData_t* priv_data = frame.opaque; if (priv_data && priv_data->next_frame_is_I_frame) { ret = hi_mpi_venc_request_idr(ctx->channel_id, HI_TRUE); if (ret) { -- Gitee From 2919f69b4fb8ff1c3020c028ea3a22c197604266 Mon Sep 17 00:00:00 2001 From: Malanchi Date: Tue, 21 Jan 2025 15:10:52 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VisionSDK/Ascendffmpeg/README_DEV.md | 154 ++++++++++++++++ VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md | 81 +++++++++ .../Ascendffmpeg/doc/dec_mjpeg_ascend.md | 63 +++++++ VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md | 171 ++++++++++++++++++ .../Ascendffmpeg/libavcodec/ascend_enc.c | 4 +- VisionSDK/Ascendffmpeg/libavcodec/avcodec.h | 3 +- 6 files changed, 473 insertions(+), 3 deletions(-) create mode 100644 VisionSDK/Ascendffmpeg/README_DEV.md create mode 100644 VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md create mode 100644 VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md create mode 100644 VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md diff --git a/VisionSDK/Ascendffmpeg/README_DEV.md b/VisionSDK/Ascendffmpeg/README_DEV.md new file mode 100644 index 000000000..efc5eef7e --- /dev/null +++ b/VisionSDK/Ascendffmpeg/README_DEV.md @@ -0,0 +1,154 @@ +## 1 介绍 + +### 1.1 简介 + +mxVison ascend 硬件平台内置了视频相关的硬件加速编解码器,为了提升用户的易用性,Vision SDK提供了 Ffmepg-Ascend 解决方案。 + +支持的功能: + +|功能|mpeg4|h264/h265| mjpeg |多路 | +|:----:|:----:|:----:|:-----:|:-------:| +|硬件解码|√|√| √ | √ | +|硬件编码|√|√| | √ | +|硬件转码|√|√| √ | √ | +|硬件缩放|√|√| | √ | + +注意:mjpeg视频流的转码相关功能只在Atlas A500 A2上适用。 + +### 1.2 支持的产品 + +本项目支持昇腾Atlas 300I pro、 Atlas 300V pro、 Atlas A500 A2。 + +### 1.3 支持的版本 +本样例配套的CANN版本、Driver/Firmware版本如下所示: + +| CANN版本 | Driver/Firmware版本 | +| ------------------ | -------------- | +| 8.0.RC3 | 24.1.RC3 | + + +## 2 设置环境变量 +* `ASCEND_HOME` Ascend 安装的路径,一般为 `/usr/local/Ascend` +* 执行命令 + ```bash + export ASCEND_HOME=/usr/local/Ascend + . /usr/local/Ascend/ascend-toolkit/set_env.sh #toolkit默认安装路径,根据实际安装路径修改 + ``` + + +## 3 编译 + +**步骤1:** 在项目目录`Ascendffmpeg/`下添加可执行权限: +```bash +chmod +x ./configure +chmod +x ./ffbuild/*.sh +``` + +**步骤2:** 在项目目录`Ascendffmpeg/`下执行编译: + +编译选项说明: +* `prefix` - FFmpeg 及相关组件安装目录 +* `enable-shared` - FFmpeg 允许生成 so 文件 +* `extra-cflags` - 添加第三方头文件 +* `extra-ldflags` - 指定第三方库位置 +* `extra-libs` - 添加第三方 so 文件 +* `enable-ascend` - 允许使用 ascend 进行硬件加速 + +执行编译命令: + ```bash + ./configure \ + --prefix=./ascend \ + --enable-shared \ + --extra-cflags="-I${ASCEND_HOME}/ascend-toolkit/latest/acllib/include" \ + --extra-ldflags="-L${ASCEND_HOME}/ascend-toolkit/latest/acllib/lib64" \ + --extra-libs="-lacl_dvpp_mpi -lascendcl" \ + --enable-ascend \ + && make -j && make install + ``` + +**步骤3:** 添加环境变量 + +通过指令`find / -name libavdevice.so`查找到文件所在路径,形如`/PATH/TO/mindxsdk-referenceapps/VisionSDK/Ascendffmpeg/ascend/lib/libavdevice.so`,则执行: +```bash +export LD_LIBRARY_PATH=/PATH/TO/mindxsdk-referenceapps/VisionSDK/Ascendffmpeg/ascend/lib:$LD_LIBRARY_PATH +``` + + + +## 4 特性介绍 + +Ascendffmpeg在ffmpeg开源软件基础上,结合昇腾NPU设备硬件加速,扩充了视频编解码能力。 + +### 4.1 解码 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
解码器介绍McoreLegacy
h264_ascendlink
h265_ascendlink
mjpeg_ascendlink
+ + +### 4.2 编码 + + + + + + + + + + + + + + + + + + + + + + + + + + +
编码器介绍McoreLegacyReleased
h264_ascendlink
h265_ascendlink
+ + +## 5 常见问题 +### 5.1 文件编译不通过 + +问题描述: 文件编译不通过 + +解决方案: 可能是文件格式被改变或者破坏,建议通过以下两种方式直接获取代码,而非文件传输: +- 在环境上通过git clone直接下载该代码仓。 +- 直接从代码仓网页gitee下载zip包,并在环境上通过`unzip`解压。 + diff --git a/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md b/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md new file mode 100644 index 000000000..c8f9c95f7 --- /dev/null +++ b/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md @@ -0,0 +1,81 @@ +## h26x_ascend解码器 + +### 1 简介 + +Ffmepg-Ascend 中内置了h264_ascend和h265_ascend解码器,利用昇腾NPU设备分别处理h264视频流和h265视频流的解码。 + +### 2 头文件导入 + +```commandline +#include "libavcodec/ascend_dec.h" +``` + +### 3 特性支持 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
特性参数名类型说明h264_ascendh265_ascend
指定运行设备device_idint 取值范围取决于芯片个数,默认为 0。 `npu-smi info` 命令可以查看芯片个数
指定运行通道号channel_idint 取值范围取决于芯片实际情况,超出时会报错(对于昇腾Atlas 300I pro、 Atlas 300V pro,该参数的取值范围:[0, 256),JPEGD功能和VDEC功能共用通道,且通道总数最多256。对于Atlas 500 A2推理产品,该参数的取值范围:[0, 128),JPEGD功能和VDEC功能共用通道,且通道总数最多128)。 若是指定的通道已被占用, 则自动寻找并申请新的通道。
缩放resize_strchar* 输入格式为: {width}x{height}, 宽高:[128x128-4096x4096]
+ +### 4 解码器使用 + +开发态使用解码器代码样例请参考:Ascendffmepg/doc/examples/hw_decode.c + +**特别的**: + +解码器默认在“0”号设备上用编号“0”通道进行解码操作,且默认不指定缩放尺寸。 + +如用户对执行设备,执行通道以及是否缩放有自定义诉求,可以利用“ascend_dec.h”文件中的ASCENDContext_t结构体实现,如下代码所示: + +```commandline + +ASCENDContext_t* privData = (ASCENDContext_t*)av_malloc(sizeof(ASCENDContext_t)); +privData->device_id = 1; // 用户可自定义修改 +privData->channel_id = 1; // 用户可自定义修改 +privData->resize_str = "1920x1080"; // 用户可自定义修改 + +AVCodec *decoder; // 假设已经完成对decoder的初始化 + +AVCodecContext* decoder_ctx = avcodec_alloc_context3(decoder); + +decoder_ctx->priv_data = privData; // 将自定义数据传入解码器上下文 + +/* 执行解码以及相关资源释放 */ +··· +``` diff --git a/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md b/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md new file mode 100644 index 000000000..55f64f2ef --- /dev/null +++ b/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md @@ -0,0 +1,63 @@ +## mjpeg_ascend解码器 + +### 1 简介 + +Ffmepg-Ascend 中内置了mjpeg_ascend解码器,利用昇腾NPU设备处理mjpeg视频流的解码。当前该解码器仅支持在Atlas A500 A2上使用。 + +### 2 头文件导入 + +```commandline +#include "libavcodec/ascend_mjpeg_dec.h" +``` + +### 3 特性支持 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
特性参数名类型说明mjpeg_ascend
指定运行设备device_idint 取值范围取决于芯片个数,默认为 0。 `npu-smi info` 命令可以查看芯片个数
指定运行通道号channel_idint 取值范围取决于芯片实际情况,超出时会报错(对于昇腾Atlas 300I pro、 Atlas 300V pro,该参数的取值范围:[0, 256),JPEGD功能和VDEC功能共用通道,且通道总数最多256。对于Atlas 500 A2推理产品,该参数的取值范围:[0, 128),JPEGD功能和VDEC功能共用通道,且通道总数最多128)。 若是指定的通道已被占用, 则自动寻找并申请新的通道。
+ +### 4 解码器使用 + +开发态使用解码器代码样例请参考:Ascendffmepg/doc/examples/hw_decode.c + +如用户对执行设备,执行通道有自定义诉求,可以利用“ascend_mjpeg_dec.h”文件中的AscendMJpegDecodeContext结构体实现,如下代码所示: + +```commandline + +AscendMJpegDecodeContext* privData = (AscendMJpegDecodeContext*)av_malloc(sizeof(AscendMJpegDecodeContext)); +privData->device_id = 1; // 用户可自定义修改 +privData->channel_id = 1; // 用户可自定义修改 + +AVCodec *decoder; // 假设已经完成对decoder的初始化 + +AVCodecContext* decoder_ctx = avcodec_alloc_context3(decoder); + +decoder_ctx->priv_data = privData; // 将自定义数据传入解码器上下文 + +/* 执行解码以及相关资源释放 */ +··· +``` diff --git a/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md b/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md new file mode 100644 index 000000000..afb67d910 --- /dev/null +++ b/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md @@ -0,0 +1,171 @@ +## h26x_ascend编码器 + +### 1 简介 + +Ffmepg-Ascend 中内置了h264_ascend和h265_ascend编码器,利用昇腾NPU设备分别处理h264视频流和h265视频流的编码。 + +### 2 头文件导入 + +```commandline +#include "libavcodec/ascend_enc.h" +``` + +### 3 特性支持 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
特性参数名类型说明h264_ascendh265_ascend
指定运行设备device_idint 取值范围取决于芯片个数,默认为 0。 `npu-smi info` 命令可以查看芯片个数
指定运行通道号channel_idint 取值范围取决于芯片实际情况,超出时会报错(对于昇腾Atlas 300I pro、 Atlas 300V pro,该参数的取值范围:[0, 256),JPEGD功能和VDEC功能共用通道,且通道总数最多256。对于Atlas 500 A2推理产品,该参数的取值范围:[0, 128),JPEGD功能和VDEC功能共用通道,且通道总数最多128)。 若是指定的通道已被占用, 则自动寻找并申请新的通道。
指定视频编码的画质级别profileint 0: baseline, 1: main, 2: high, 默认为 1。 H265 编码器只支持 main
指定视频编码器的速率控制模式 rc_modeint 0: CBR, 1: VBR, 默认为 0
指定关键帧间隔gopint[1, 65536], 默认为 30
指定帧率frame_rateint [1, 240], 默认为25
限制码流的最大比特率max_bit_rateint [2, 614400], 默认为 20000
指定视频场景movement_sceneint 0:静态场景(监控视频等), 1:动态场景(直播,游戏等), 默认为 1
强制编码下一帧为I帧\\ 该特性需要修改AVFrame中的opaque参数,详情见4.2
+ +### 4 编码器使用 + +开发态使用解码器代码样例请参考:Ascendffmepg/doc/examples/encode_video.c + +#### 4.1 常规特性使用 + +如用户对执行设备,执行通道以及其他常规特性有自定义诉求,可以利用“ascend_enc.h”文件中的ASCENDEncContext_t结构体实现,如下代码所示: + +```commandline + +ASCENDEncContext_t* privData = (ASCENDEncContext_t*)av_malloc(sizeof(ASCENDEncContext_t)); +privData->device_id = 1; // 用户可自定义修改 +privData->channel_id = 1; // 用户可自定义修改 +privData->profile = 0; // 用户可自定义修改 +privData->rc_mode = 0; // 用户可自定义修改 +privData->gop = 25; // 用户可自定义修改 +privData->frame_rate = 25; // 用户可自定义修改 +privData->movement_scene = 0; // 用户可自定义修改 + +AVCodec *encoder; // 假设已经完成对encoder的初始化 + +AVCodecContext* encoder_ctx = avcodec_alloc_context3(encoder); + +decoder_ctx->priv_data = privData; // 将自定义数据传入编码器上下文 + +/* 执行编码以及相关资源释放 */ +··· +``` + +#### 4.2 强制编码下一帧为I帧 + +该特性通过AVFrame结构体中的opaque指针传递给编码器,如下代码所示: + +```commandline +// 通过AscendEncPrivateData_t来承载是否编码下一帧为I的语义。AscendEncPrivateData_t结构体定义在“liavcodec/avcodec.h”文件中。 +AscendEncPrivateData_t privData = (AscendEncPrivateData_t*)av_malloc(sizeof(AscendEncPrivateData_t)); +privData->next_is_I_frame = true; // 该参数为true时,代表下一帧将会强制编码为I帧 +privData->is_instant = true; // 该参数为true时,立即编出I帧,不受帧率控制约束;该参数为false时,则在帧率控制的下一帧编出I帧。 + // 当前底层支持场景为目标帧率与原帧率一致,故该参数目前无论设置为true或者false,都是每调用一次接口即可编出一个I帧,调用频繁会影响码流帧率和码率的稳定。 + +AVCodecContext* enc_ctx; // 假设已完成编码器上下文的初始化 +AVFrame *frame; // 假设已完成AVFrame的初始化 + +frame->opaque = privData; // 将是否将下一帧编码为I帧的信息赋值给frame + +avcodec_send_frame(enc_ctx, frame); // 调用编码器进行编码 + +/* 获取编码结果以及释放资源 */ +··· +``` diff --git a/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c b/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c index a85da9060..9bb32bce3 100644 --- a/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c +++ b/VisionSDK/Ascendffmpeg/libavcodec/ascend_enc.c @@ -747,8 +747,8 @@ static int ff_himpi_enc_receive_packet(AVCodecContext *avctx, AVPacket *avpkt) } AscendEncPrivateData_t* priv_data = frame.opaque; - if (priv_data && priv_data->next_frame_is_I_frame) { - ret = hi_mpi_venc_request_idr(ctx->channel_id, HI_TRUE); + if (priv_data && priv_data->next_is_I_frame) { + ret = hi_mpi_venc_request_idr(ctx->channel_id, priv_data->is_instant); if (ret) { av_log(ctx, AV_LOG_ERROR, "Set I-frame failed. ret is %d.\n", ret); return ret; diff --git a/VisionSDK/Ascendffmpeg/libavcodec/avcodec.h b/VisionSDK/Ascendffmpeg/libavcodec/avcodec.h index ac310cba5..0cd9750a7 100644 --- a/VisionSDK/Ascendffmpeg/libavcodec/avcodec.h +++ b/VisionSDK/Ascendffmpeg/libavcodec/avcodec.h @@ -4183,7 +4183,8 @@ AVCPBProperties *av_cpb_properties_alloc(size_t *size); */ typedef struct AscendEncPrivateData { - bool next_frame_is_I_frame; + bool next_is_I_frame; + bool is_instant; } AscendEncPrivateData_t; #endif /* AVCODEC_AVCODEC_H */ -- Gitee From 201f452a6601268e27a5d5c4ed2045e6092838e4 Mon Sep 17 00:00:00 2001 From: Malanchi Date: Tue, 21 Jan 2025 15:13:14 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VisionSDK/Ascendffmpeg/README_DEV.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/VisionSDK/Ascendffmpeg/README_DEV.md b/VisionSDK/Ascendffmpeg/README_DEV.md index efc5eef7e..01fc8c8c6 100644 --- a/VisionSDK/Ascendffmpeg/README_DEV.md +++ b/VisionSDK/Ascendffmpeg/README_DEV.md @@ -91,21 +91,21 @@ Ascendffmpeg在ffmpeg开源软件基础上,结合昇腾NPU设备硬件加速 h264_ascend - link + link ✅ ✅ h265_ascend - link + link ✅ ✅ mjpeg_ascend - link + link ✅ ✅ @@ -126,7 +126,7 @@ Ascendffmpeg在ffmpeg开源软件基础上,结合昇腾NPU设备硬件加速 h264_ascend - link + link ✅ ✅ ✅ @@ -134,7 +134,7 @@ Ascendffmpeg在ffmpeg开源软件基础上,结合昇腾NPU设备硬件加速 h265_ascend - link + link ✅ ✅ ✅ -- Gitee From 63eea8c8458c2ff660077b3097aab6fc5ddc97a7 Mon Sep 17 00:00:00 2001 From: Malanchi Date: Tue, 21 Jan 2025 15:14:05 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VisionSDK/Ascendffmpeg/README_DEV.md | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/VisionSDK/Ascendffmpeg/README_DEV.md b/VisionSDK/Ascendffmpeg/README_DEV.md index 01fc8c8c6..f1bdbff11 100644 --- a/VisionSDK/Ascendffmpeg/README_DEV.md +++ b/VisionSDK/Ascendffmpeg/README_DEV.md @@ -85,29 +85,22 @@ Ascendffmpeg在ffmpeg开源软件基础上,结合昇腾NPU设备硬件加速 解码器 介绍 - Mcore - Legacy h264_ascend link - ✅ - ✅ h265_ascend link - ✅ - ✅ mjpeg_ascend link - ✅ - ✅ + @@ -119,25 +112,18 @@ Ascendffmpeg在ffmpeg开源软件基础上,结合昇腾NPU设备硬件加速 编码器 介绍 - Mcore - Legacy - Released + h264_ascend link - ✅ - ✅ - ✅ + h265_ascend link - ✅ - ✅ - ✅ -- Gitee From 11183363a91c6f34b198f40f24bccd0bc047e026 Mon Sep 17 00:00:00 2001 From: Malanchi Date: Tue, 21 Jan 2025 15:28:27 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md | 2 +- VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md | 2 +- VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md b/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md index c8f9c95f7..2414015a5 100644 --- a/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md +++ b/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md @@ -4,7 +4,7 @@ Ffmepg-Ascend 中内置了h264_ascend和h265_ascend解码器,利用昇腾NPU设备分别处理h264视频流和h265视频流的解码。 -### 2 头文件导入 +### 2 头文件 ```commandline #include "libavcodec/ascend_dec.h" diff --git a/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md b/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md index 55f64f2ef..6a6c395f1 100644 --- a/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md +++ b/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md @@ -4,7 +4,7 @@ Ffmepg-Ascend 中内置了mjpeg_ascend解码器,利用昇腾NPU设备处理mjpeg视频流的解码。当前该解码器仅支持在Atlas A500 A2上使用。 -### 2 头文件导入 +### 2 头文件 ```commandline #include "libavcodec/ascend_mjpeg_dec.h" diff --git a/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md b/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md index afb67d910..f054d69ce 100644 --- a/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md +++ b/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md @@ -4,7 +4,7 @@ Ffmepg-Ascend 中内置了h264_ascend和h265_ascend编码器,利用昇腾NPU设备分别处理h264视频流和h265视频流的编码。 -### 2 头文件导入 +### 2 头文件 ```commandline #include "libavcodec/ascend_enc.h" -- Gitee From 08c703b23765274839334bc3ed04922bcfd6c8c8 Mon Sep 17 00:00:00 2001 From: Malanchi Date: Tue, 21 Jan 2025 16:17:04 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VisionSDK/Ascendffmpeg/README_DEV.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VisionSDK/Ascendffmpeg/README_DEV.md b/VisionSDK/Ascendffmpeg/README_DEV.md index f1bdbff11..bda0525ef 100644 --- a/VisionSDK/Ascendffmpeg/README_DEV.md +++ b/VisionSDK/Ascendffmpeg/README_DEV.md @@ -2,7 +2,7 @@ ### 1.1 简介 -mxVison ascend 硬件平台内置了视频相关的硬件加速编解码器,为了提升用户的易用性,Vision SDK提供了 Ffmepg-Ascend 解决方案。 +Vison ascend 硬件平台内置了视频相关的硬件加速编解码器,为了提升用户的易用性,Vision SDK提供了 Ffmepg-Ascend 解决方案。 支持的功能: @@ -68,9 +68,9 @@ chmod +x ./ffbuild/*.sh **步骤3:** 添加环境变量 -通过指令`find / -name libavdevice.so`查找到文件所在路径,形如`/PATH/TO/mindxsdk-referenceapps/VisionSDK/Ascendffmpeg/ascend/lib/libavdevice.so`,则执行: +通过指令`find / -name libavdevice.so`查找到文件所在路径,形如`/PATH/TO/mindsdk-referenceapps/VisionSDK/Ascendffmpeg/ascend/lib/libavdevice.so`,则执行: ```bash -export LD_LIBRARY_PATH=/PATH/TO/mindxsdk-referenceapps/VisionSDK/Ascendffmpeg/ascend/lib:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=/PATH/TO/mindsdk-referenceapps/VisionSDK/Ascendffmpeg/ascend/lib:$LD_LIBRARY_PATH ``` -- Gitee From b51bf16213bd6f8fc1575022815a55b66bc2428a Mon Sep 17 00:00:00 2001 From: Malanchi Date: Tue, 21 Jan 2025 16:54:21 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md | 2 +- VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md | 3 ++- VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md b/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md index 2414015a5..e5e535660 100644 --- a/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md +++ b/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md @@ -55,7 +55,7 @@ Ffmepg-Ascend 中内置了h264_ascend和h265_ascend解码器,利用昇腾NPU ### 4 解码器使用 -开发态使用解码器代码样例请参考:Ascendffmepg/doc/examples/hw_decode.c +开发态使用解码器代码样例请参考:hw_decode.c **特别的**: diff --git a/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md b/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md index 6a6c395f1..822e482e3 100644 --- a/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md +++ b/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md @@ -42,7 +42,8 @@ Ffmepg-Ascend 中内置了mjpeg_ascend解码器,利用昇腾NPU设备处理mjp ### 4 解码器使用 -开发态使用解码器代码样例请参考:Ascendffmepg/doc/examples/hw_decode.c +开发态使用解码器代码样例请参考:hw_decode.c + 如用户对执行设备,执行通道有自定义诉求,可以利用“ascend_mjpeg_dec.h”文件中的AscendMJpegDecodeContext结构体实现,如下代码所示: diff --git a/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md b/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md index f054d69ce..f6d49e9ac 100644 --- a/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md +++ b/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md @@ -121,7 +121,9 @@ Ffmepg-Ascend 中内置了h264_ascend和h265_ascend编码器,利用昇腾NPU ### 4 编码器使用 -开发态使用解码器代码样例请参考:Ascendffmepg/doc/examples/encode_video.c +开发态使用编码器代码样例请参考:encode_video.c + + #### 4.1 常规特性使用 -- Gitee From dccf1dbbe77c3ce4926c4bbb42d68db8eb139ec9 Mon Sep 17 00:00:00 2001 From: Malanchi Date: Tue, 21 Jan 2025 16:55:46 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md | 2 +- VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md | 2 +- VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md b/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md index e5e535660..b17569818 100644 --- a/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md +++ b/VisionSDK/Ascendffmpeg/doc/dec_h26x_ascend.md @@ -55,7 +55,7 @@ Ffmepg-Ascend 中内置了h264_ascend和h265_ascend解码器,利用昇腾NPU ### 4 解码器使用 -开发态使用解码器代码样例请参考:hw_decode.c +开发态使用解码器代码样例请参考:hw_decode.c **特别的**: diff --git a/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md b/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md index 822e482e3..77ff989d0 100644 --- a/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md +++ b/VisionSDK/Ascendffmpeg/doc/dec_mjpeg_ascend.md @@ -42,7 +42,7 @@ Ffmepg-Ascend 中内置了mjpeg_ascend解码器,利用昇腾NPU设备处理mjp ### 4 解码器使用 -开发态使用解码器代码样例请参考:hw_decode.c +开发态使用解码器代码样例请参考:hw_decode.c 如用户对执行设备,执行通道有自定义诉求,可以利用“ascend_mjpeg_dec.h”文件中的AscendMJpegDecodeContext结构体实现,如下代码所示: diff --git a/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md b/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md index f6d49e9ac..6dcf676c7 100644 --- a/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md +++ b/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md @@ -121,7 +121,7 @@ Ffmepg-Ascend 中内置了h264_ascend和h265_ascend编码器,利用昇腾NPU ### 4 编码器使用 -开发态使用编码器代码样例请参考:encode_video.c +开发态使用编码器代码样例请参考:encode_video.c -- Gitee From 7478a54dde28cc198fdc6614854928ebe4e1c068 Mon Sep 17 00:00:00 2001 From: Malanchi Date: Wed, 22 Jan 2025 11:16:54 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E5=B8=A7=E4=B8=BAI=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md b/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md index 6dcf676c7..eca992060 100644 --- a/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md +++ b/VisionSDK/Ascendffmpeg/doc/enc_h26x_ascend.md @@ -168,6 +168,10 @@ frame->opaque = privData; // 将是否将下一帧编码为I帧的信息赋值 avcodec_send_frame(enc_ctx, frame); // 调用编码器进行编码 -/* 获取编码结果以及释放资源 */ +/* 获取编码结果 */ +··· +frame->opaque = NULL; // 当编码I帧结束,需要对该参数进行复位,否则后续视频帧都会编码为I帧 + +/* 释放资源 */ ··· ``` -- Gitee