---
title: DVPP媒体数据处理视频解码问题案例（2）-官方技术文章-昇腾社区
description: DVPP（Digital Vision Pre-Processing）是昇腾AI处理器内置的图像处理单元，通过AscendCL媒体数据处理接口提供强大的媒体处理硬加速能力，主要功能包括图像编解码、视频编解码、图像抠图缩放等。
keywords: DVPP,媒体数据处理,视频解码问题,案例,官方技术文章,昇腾社区,视频解码丢帧,丢包
url: https://www.hiascend.com/developer/techArticles/20231215-1?envFlag=1
section: (其他)
---

# DVPP媒体数据处理视频解码问题案例（2）-官方技术文章-昇腾社区

URL: https://www.hiascend.com/developer/techArticles/20231215-1?envFlag=1
描述: DVPP（Digital Vision Pre-Processing）是昇腾AI处理器内置的图像处理单元，通过AscendCL媒体数据处理接口提供强大的媒体处理硬加速能力，主要功能包括图像编解码、视频编解码、图像抠图缩放等。
关键词: DVPP,媒体数据处理,视频解码问题,案例,官方技术文章,昇腾社区,视频解码丢帧,丢包

官方技术文章 [了解详情](https://www.hiascend.com/zh/developer/techArticles)

DVPP媒体数据处理视频解码问题案例（2）

DVPP媒体数据处理视频解码问题案例（2）

故障案例

发表于: 2023/12/15

往期分享过几个DVPP视频解码问题的典型案例，看的人多，说明在这一块，大家还是有些疑问的，所以本期继续分享其它DVPP视频解码问题的典型案例，并给出原因分析及解决方法：

1.	视频解码丢帧/丢包，导致出现重影或不连续现象2.	视频解码不触发回调函数，导致获取不到解码结果3.	复用输出图片描述类型，VDEC视频解码报错，提示有不支持的图片格式

# 01 视频解码丢帧/丢包，导致出现重影或不连续现象

## 问题现象&可能原因

视频解码丢帧，出现重影或不连续现象。查看Device侧日志，发现日志中存在以下几个报错中的一个或多个，不同版本日志信息可能有所不同。•	H264码流缺少IDR帧，日志报错示例（1）

```
[HiDvpp][A618] [Vfmw]:ppssps_check [Line]:6803 pps with this pic_parameter_set_id = %d haven't decode
[HiDvpp][A618] [Vfmw]:process_slice_header_first_part [Line]:7401 PPS or SPS of this slice not valid
[HiDvpp][A618] [Vfmw]:h264_dec_slice [Line]:7915 sliceheader dec err

```

或

```
[ERROR] DVPP:2020-12-31-23:51:51.339.518 [VDEC][PPSSPSCheckTmpId:7065][T3]  PPSSPSCheckTmpId: pps with this pic_parameter_set_id = 0 haven't decode
[ERROR] DVPP:2020-12-31-23:51:51.339.616 [VDEC][ProcessSliceHeaderFirstPart:7627][T3]  PPS or SPS of this slice not valid
[ERROR] DVPP:2020-12-31-23:51:51.339.678 [VDEC][InquiresSlceProperty:10582][T3]  sliceheader dec err

```

•	H264码流缺少I帧，日志报错示例（2）

```
[HiDvpp][A618] [Vfmw]:h264_dec_slice [Line]:7983 init pic err, find next recover point or next valid sps, pps, or exit
[HiDvpp][A618] [Vfmw]:h264_dec_slice [Line]:3716 dec list error, ret=-1
[HiDvpp][A618] [Vfmw]:receive_packet [Line]:10676 nal_release_err

```

或

```
[ERROR] DVPP:2020-12-31-20:51:51.318.218 [VDEC][InitPic:6039][T3]  line 6039: frame gap(=48) > dpb size(=2)
[ERROR] DVPP:2020-12-31-20:51:51.318.266 [VDEC][H264_DecSlice:8238][T3]  init pic err, find next recover point or next valid sps, pps, or exit
[ERROR] DVPP:2020-12-31-20:51:51.318.336 [VDEC][H264_DecOneNal:10077][T3]  DecList error, ret=-1
[ERROR] DVPP:2020-12-31-20:51:51.318.392 [VDEC][ReceivePacket:10400][T3]  nal_release-err

```

•	H264码流缺少P帧，日志报错示例（3）

```
[HiDvpp][A618] [Vfmw]:init_list_x [Line]:4829 for P slice size of list equal 0.ctx->dpb.ref_frames_in_buffer:0.
[HiDvpp][A618] [Vfmw]:dec_list [Line]:5068 init list error.
[HiDvpp][A618] [Vfmw]:h264_dec_list [Line]:4829 dec_list error, ret=-1
[HiDvpp][A618] [Vfmw]:h264_dec_one_nal [Line]:10298 slice_check failed, clear current slice.

```

或

```
[ERROR] DVPP:2020-12-31-20:30:22.188.008 [VDEC][InitListX:4513][T3]  for P slice size of list equal 0.
[ERROR] DVPP:2020-12-31-20:30:22.188.056 [VDEC][DecList:4832][T3] line: 4832 InitListX failed
[ERROR] DVPP:2020-12-31-20:30:22.188.128 [VDEC][H264_DecSlice:8260][T3] DecList error, ret=-1
[ERROR] DVPP:2020-12-31-20:30:22.188.199 [VDEC][H264_DecOneNal:10077][T3] Decoder Slice failed

```

•	H264码流缺少B帧，日志报错示例（4）

```
[HiDvpp][A618] [Vfmw]:init_list_x [Line]:4865 for B slice size of two list all equal 0.
[HiDvpp][A618] [Vfmw]:dec_list [Line]:5068 init list error.
[HiDvpp][A618] [Vfmw]:h264_dec_list [Line]:4829 dec_list error, ret=-1

```

或

```
[ERROR] DVPP:2020-12-31-10:20:28.528.090 [VDEC][InitListX:4653][T3] for B slice size of two list all equal 0.
[ERROR] DVPP:2020-12-31-10:20:28.528.168 [VDEC][DecList:4830][T3] line: 4832 InitListX failed
[ERROR] DVPP:2020-12-31-10:20:28.528.266 [VDEC][H264_DecSlice:8257][T3] DecList error, ret=-1

```

•	H265码流缺少IDR帧，日志报错示例（5）

```
[HiDvpp][A618] [Vfmw]:hevc_vps_sps_pps_check [Line]:7300 pps with this pic_parameter_set_id = 0 haven't be decoded
[HiDvpp][A618] [Vfmw]:hevc_dec_slice_segment_header [Line]:3857 hevc_vps_sps_pps_check != HEVC_DEC_NORMAL
[HiDvpp][A618] [Vfmw]:hevc_inquire_slice_property [Line]:9004 hevc_dec_slice_segment_header dec err
[HiDvpp][A618] [Vfmw]:hevc_dec_decode_packet[Line]:9004 hevc_inquire_slice_property error.

```

或

```
[ERROR] DVPP:2020-12-31-10:30:22.130.500 [VDEC][HEVC_VpsSpsPpsCheck:8084][T10] pps with this pic_parameter_set_id = 0 haven't be decoded
[ERROR] DVPP:2020-12-31-10:30:22.130.598 [VDEC][HEVC_DecSliceSegmentHeader:2793][T10] HEVC_VpsSpsPpsCheck != HEVC_DEC_NORMAL
[ERROR] DVPP:2020-12-31-10:30:22.130.686 [VDEC][HEVC_InquireSliceProperty:10169][T10] HEVC_DecSliceSegmentHeader dec err
[ERROR] DVPP:2020-12-31-10:30:22.130.789 [VDEC][HEVCDEC_DecodePacket:753][T10] HEVC_InquireSliceProperty error.

```

•	H265码流缺少I帧或者P帧，日志报错示例（6）

```
[HiDvpp][A618] [Vfmw]:hevc_ref_pic_process [Line]:3474 ref frame(poc 15) lost.
[HiDvpp][A618] [Vfmw]:hevc_create_lost_picture [Line]:5839 DPB no suited fs for lost pic.
[HiDvpp][A618] [Vfmw]:hevc_create_lost_picture [Line]:5847 take poc(17) to create lost poc(15).

```

或

```
[ERROR] DVPP:2020-12-31-11:22:28.800.158 [VDEC][HEVC_RefPicProcess:2480][T10] Ref frame(poc 15) lost.
[ERROR] DVPP:2020-12-31-11:22:28.800.236 [VDEC][HEVC_CreateLostPicture:6392][T10] DPB no suited fs for lost pic.
[ERROR] DVPP:2020-12-31-11:22:28.800.352 [VDEC][HEVC_RefPicProcess:2480][T10] Ref frame(poc 18) lost.
[ERROR] DVPP:2020-12-31-11:22:28.800.426 [VDEC][HEVC_CreateLostPicture:6392] [T10] DPB no suited fs for lost pic.
[ERROR] DVPP:2020-12-31-11:22:28.800.522 [VDEC][HEVC_RefPicProcess:2480] [T10] Ref frame(poc 18) lost.

```

•	H265码流缺少I帧或者B帧，日志报错示例（7）

```
[ERROR] DVPP:2020-12-31-11:56:35.038.109 [VDEC][HEVC_RefPicProcess:2480] [T56] Ref frame(poc 15) lost.
[ERROR] DVPP:2020-12-31-11:56:35.038.283 [VDEC][HEVC_CreateLostPicture:6392] [T56] Take poc(17) to create lost poc(15).
[ERROR] DVPP:2020-12-31-11:56:35.038.502 [VDEC][FSP_SetRef:934] [T56] check condition: pstLogicFs->IsDummyFs == 0 fail
[ERROR] DVPP:2020-12-31-11:56:35.038.801 [VDEC][FSP_SetRef:934] [T56] check condition: pstLogicFs->IsDummyFs == 0 fail
[ERROR] DVPP:2020-12-31-11:56:35.039.128 [VDEC][FSP_SetRef:934] [T56] check condition: pstLogicFs->IsDummyFs == 0 fail

```

## 处理步骤

1.	检查输入的源码流是否有问题。使用第三方工具（如：eseye u）对输入码流进行检查，查看码流是否异常。

2.	若查看的源码流结果为正常，则可能码流在传输给设备侧VDEC视频解码的过程中遭到破坏，需要在调用码流接口之前，通过fwrite函数将输送给VDEC的码流保存下来。o	使用第三方工具对保存的码流进行检查，如果码流异常，用户需自行排查将码流送进去之前是否有送流问题。o	通过对应版本的sample，解码这段保留下来的码流，验证码流是否正常或VDEC是否支持该格式。如果sample 解码正常，那就是开发代码有问题，可以参考VDEC示例代码，找到对应的视频解码的代码参考优化。

# 02 视频解码不触发回调函数，导致获取不到解码结果

## 现象描述

用户输入码流给VDEC解码，某些帧或所有帧都没有触发回调函数，用户收不到解码结果。

## 可能原因

码流中某些帧是坏帧，导致语法解析不出这些帧的含义，或者解码这些帧失败，从而不调用回调函数。

## 处理步骤

针对分析的可能原因，请参考以下步骤进行处理：1.	查看日志中是否有视频解码丢帧/丢包中的日志报错信息，若有，则是因为异常帧解码失败导致没有回调。2.	若没有视频解码丢帧/丢包中的日志报错信息，则设置环境变量（export ASCEND_MODULE_LOG_LEVEL=DVPP=1）将DVPP模块的日志级别设置为info，或设置环境变量（export ASCEND_GLOBAL_LOG_LEVEL=1）将全局日志级别设置为info，查看下述三条日志打印的总次数是否和输入的帧数相等。o	（1）"The queue is empty, so call the non-intelligent pointer callback interface."o	（2）"The queue is not empty, so call the smart pointer callback interface."o	（3）"The queue is not empty, but hiai_data_sp is nullptr."生成上述3种日志信息的场景如下：o	未使用hiai_data_sp，成功解码返回，打印（1）日志，然后调用用户注册的回调函数。o	每一帧对应设置一个hiai_data_sp，成功解码返回，打印（2）日志，然后调用用户注册的回调函数。o	N帧对应设置一个hiai_data_sp，第1帧成功解码返回，打印（2）日志，然后调用用户注册的回调函数；其他N-1帧，成功解码后打印（3）日志信息，并调用用户注册的回调函数。不论上述场景中哪一种，均会调用用户注册的回调函数，即只要调用一次用户回调函数就说明解码返回一帧。所以上述三条日志出现的次数总和与用户输入总帧数相等，则说明无解码丢帧，用户需排查自身接收解码结果的统计是否有误。

# 03 复用输出图片描述类型，VDEC视频解码报错，提示有不支持的图片格式

## 现象描述

循环调用aclvdecSendFrame接口解码视频中的每一帧码流时，在遇到异常帧之后，解码下一帧就会报错，退出应用进程。分别查看Host侧日志、Device侧日志，发现Device日志中提示the out format 0 is not supported，日志片段如下：•	Device侧日志：

```
[ERROR] KERNEL(2234,sklogd):2023-06-13-19:21:22.987.969 [klogd.c:246][652145.056916] [HiDvpp][A618] [Vdec]:vdec_check_resize_param [Line]:6768 pid 23973 usr chn 0 device 0 chn 0 the out format 0 is not supported. 
```

•	Host侧日志：

```
[ERROR] RUNTIME(17174,AIMCDemo):2023-06-13-19:21:23.664.211 [api_c.cc:721]17184 rtStreamSynchronize:[DVPP][DEFAULT]ErrCode=507018, desc=[aicpu exception], InnerCode=0x715002a
[ERROR] RUNTIME(17174,AIMCDemo):2023-06-13-19:21:23.664.215 [error_message_manage.cc:49]17184 FuncErrorReason:[DVPP][DEFAULT]report error module_type=3, module_name=EE8888
[ERROR] RUNTIME(17174,AIMCDemo):2023-06-13-19:21:23.664.221 [error_message_manage.cc:49]17184 FuncErrorReason:[DVPP][DEFAULT]rtStreamSynchronize execute failed, reason=[aicpu exception]
[INFO] GE(17174,AIMCDemo):2023-06-13-19:21:23.664.227 [error_manager.cc:252]17184 ReportInterErrMessage:report error_message, error_code:EE8888, work_stream_id:1717417184
[ERROR] ASCENDCL(17174,AIMCDemo):2023-06-13-19:21:23.664.234 [video_processor_v200.cpp:1089]17184 aclvdecSendFrame: [DVPP][DEFAULT][Sync][Stream]vdec fail to synchronize sendFrameStream, runtime errorCode = 507018, channelId = 0.

```

## 可能原因

检查应用代码，发现循环解码视频中的每一帧码流时，复用aclvdecSendFrame接口的输出图片描述类型acldvppPicDesc，但在下一次解码前没有重新设置输出图片format、width、height、widthStride、heightStride，这时，如果前一帧解码失败，acldvppPicDesc的参数format、width、height、widthStride、heightStride变成默认值0，width、height、widthStride、heightStride为0时，vdec会以实际图片宽高解码输出，但format为0，表示YUV400格式，vdec不支持解码输出该格式，会导致下一帧参数不合法解失败。

## 处理步骤

优化应用代码逻辑，复用输出图片描述类型acldvppPicDesc时，在下一次解码前需重新设置输出图片format、width、height、widthStride、heightStride。正例代码片段：

```
aclError ret;
int restLen = 10;
uint32_t inBufferSize = 0;
void *g_picOutBufferDev;
void *inBufferDev = nullptr;
acldvppPicDesc *picOutputDesc;
size_t dataSize = (INPUT_WIDTH * INPUT_HEIGHT * 3) / 2;
// 申请一个picOutputDesc,每帧复用
picOutputDesc = acldvppCreatePicDesc();
// read file to device memory
 ReadFileToDeviceMem(filePath.c_str(), inBufferDev, inBufferSize);
 while (restLen > 0) {
        // 等待前一个使用picOutputDesc解码帧结束，重新复用picOutputDesc,并针对这一帧重新设置Format、width、height、widthStride、heightStride参数值
        ret = acldvppSetPicDescFormat(picOutputDesc, static_cast<acldvppPixelFormat>(1)); // 1：YUV420 semi-planner（nv12）
        ret = acldvppSetPicDescWidth(picOutputDesc, 1920);
        ret = acldvppSetPicDescHeight(picOutputDesc, 1080);
        ret = acldvppSetPicDescWidthStride(picOutputDesc, 1920);
        ret = acldvppSetPicDescHeightStride(picOutputDesc, 1080);
        ret = acldvppMalloc(&g_picOutBufferDev, dataSize);
        ret = acldvppSetPicDescData(picOutputDesc, g_picOutBufferDev);
        ret = acldvppSetPicDescSize(picOutputDesc, dataSize);
        ret = aclvdecSendFrame(vdecChannelDesc, streamInputDesc, picOutputDesc, nullptr, nullptr);
        restLen = restLen - 1;
}

```

反例代码片段：

```
aclError ret;
int restLen = 10;
uint32_t inBufferSize = 0;
void *g_picOutBufferDev;
void *inBufferDev = nullptr;
acldvppPicDesc *picOutputDesc;
size_t dataSize = (INPUT_WIDTH * INPUT_HEIGHT * 3) / 2;
// 申请一个picOutputDesc，每帧复用，且对Format、width、height、widthStride、heightStride参数值只设置了一次
picOutputDesc = acldvppCreatePicDesc();
ret = acldvppSetPicDescFormat(picOutputDesc, static_cast<acldvppPixelFormat>(1)); // 1：YUV420 semi-planner（nv12）
ret = acldvppSetPicDescWidth(picOutputDesc, 1920);
ret = acldvppSetPicDescHeight(picOutputDesc, 1080);
ret = acldvppSetPicDescWidthStride(picOutputDesc, 1920);
ret = acldvppSetPicDescHeightStride(picOutputDesc, 1080);
// read file to device memory
ReadFileToDeviceMem(filePath.c_str(), inBufferDev, inBufferSize);
while (restLen > 0) {
        // 等待前一个使用picOutputDesc解码帧结束，重新复用picOutputDesc,但没有重新设置Format、width、height、widthStride、heightStride参数值
	// 如果前一帧解码失败，picOutputDesc_的参数Format、width、height、widthStride、heightStride变成默认值0，
	// width、height、widthStride、heightStride为0时，vdec会以实际图片宽高解码输出，但Format为0，表示YUV400格式，vdec不支持解码输出该格式，会导致本帧参数不合法解码失败
        ret = acldvppMalloc(&g_picOutBufferDev, dataSize);
        ret = acldvppSetPicDescData(picOutputDesc, g_picOutBufferDev);
        ret = acldvppSetPicDescSize(picOutputDesc, dataSize);
        ret = aclvdecSendFrame(vdecChannelDesc, streamInputDesc, picOutputDesc, nullptr, nullptr);
        restLen = restLen - 1;
    }

```

# 04 更多介绍

[1]昇腾文档中心：https://www.hiascend.com/zh/document [了解详情](https://www.hiascend.com/zh/document)[2]昇腾社区在线课程：https://www.hiascend.com/zh/edu/courses [了解详情](https://www.hiascend.com/zh/edu/courses)[3]昇腾论坛：https://www.hiascend.com/forum [了解详情](https://www.hiascend.com/forum)

本页内容
