CN114339408A - Video decoding method - Google Patents
Video decoding method Download PDFInfo
- Publication number
- CN114339408A CN114339408A CN202111424627.6A CN202111424627A CN114339408A CN 114339408 A CN114339408 A CN 114339408A CN 202111424627 A CN202111424627 A CN 202111424627A CN 114339408 A CN114339408 A CN 114339408A
- Authority
- CN
- China
- Prior art keywords
- video
- decoding
- target
- hard
- video packet
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 30
- 238000012216 screening Methods 0.000 claims abstract description 9
- 230000006835 compression Effects 0.000 claims description 5
- 238000007906 compression Methods 0.000 claims description 5
- 238000005538 encapsulation Methods 0.000 claims description 4
- 230000002159 abnormal effect Effects 0.000 description 4
- 238000001914 filtration Methods 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000013500 data storage Methods 0.000 description 2
- 230000005856 abnormality Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000004806 packaging method and process Methods 0.000 description 1
- 238000012856 packing Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Landscapes
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
Description
技术领域technical field
本发明涉及多媒体播放技术领域,尤其涉及一种视频解码方法。The invention relates to the technical field of multimedia playback, in particular to a video decoding method.
背景技术Background technique
视频文件的完整播放过程,分为视频解封装,视频解码,视频画面显示三个步骤。The complete playback process of a video file is divided into three steps: video decapsulation, video decoding, and video picture display.
解码器分为软件解码器.硬件解码器和无线解码器,其中:Decoders are divided into software decoders, hardware decoders and wireless decoders, among which:
软件解码器:电脑里所说的解码器是软解码器,即通过软件方法解出音频视频数据。与之相对应的是DVD和vcd机,它们属于硬件解码器.通常的,电脑所要播放某种格式视频,即需要支持该视频编码的解码器,视频解码器就应运而生。RM/RMVB Real Media解码器MOV Quick Time解码器3GP/MP4解码器DVD/VOB解码器Divx解码器xvid解码器WMV解码器。Software decoder: The decoder mentioned in the computer is a soft decoder, that is, the audio and video data are decoded by software methods. Corresponding to it are DVD and vcd machines, which belong to hardware decoders. Usually, if a computer wants to play a certain format of video, it needs a decoder that supports the video encoding, and the video decoder comes into being. RM/RMVB Real Media Decoder MOV Quick Time Decoder 3GP/MP4 Decoder DVD/VOB Decoder Divx Decoder xvid Decoder WMV Decoder.
硬件解码器:解码器的存在是因为音频视频数据存储要先通过压缩,否则数据量太庞大,而压缩需要通过一定的编码,才能用最小的容量来存贮质量最高的音频视频数据。因此在需要对数据进行播放时要先通过解码器进行解码。可以解码的数字编码格式有AC-3、HDCD、DTS等。这些都是多声道音视频编码格式。如果要达到高保真的水平,有双声道的PCM数字编码的。所以在选择硬件解码器的时候应该注意是否支持这些格式的软件。Hardware decoder: The existence of the decoder is because the audio and video data storage must first be compressed, otherwise the amount of data is too large, and compression requires a certain encoding, in order to use the smallest capacity to store the highest quality audio and video data. Therefore, when the data needs to be played, it must be decoded by the decoder first. The digital encoding formats that can be decoded are AC-3, HDCD, DTS, etc. These are multi-channel audio and video encoding formats. If you want to achieve a high fidelity level, there are two-channel PCM digital encoding. Therefore, when choosing a hardware decoder, you should pay attention to whether the software supports these formats.
在现有的解码方案中,播放器播放H264视频文件时,时常出现部分H264视频文件播放花屏、黑屏、播放过程中无法正常SEEK播放等问题。这是由于播放器在播放过程中,仅仅对H264视频文件的封装格式做了检查,而忽略了编码格式。进而出现播放器传输给软解码器的数据格式错误、播放器传输的数据硬解码器不支持的等情况,导致软解码器或硬解码器的视频解码异常,从而使得H264视频播放显示异常的现象。In the existing decoding scheme, when the player plays H264 video files, some H264 video files are often played with a blurry screen, a black screen, and the SEEK cannot be played normally during playback. This is because the player only checks the encapsulation format of the H264 video file while ignoring the encoding format during playback. Then, the data format transmitted by the player to the soft decoder is wrong, and the data transmitted by the player is not supported by the hard decoder, etc., resulting in abnormal video decoding of the soft decoder or hard decoder, thus making the H264 video playback display abnormal phenomenon. .
发明内容SUMMARY OF THE INVENTION
本发明提供一种视频解码方法,解决了现有的视频解码方案缺少对音频视频数据编码格式的检查,导致视频播放显示异常技术问题。The present invention provides a video decoding method, which solves the technical problem that the existing video decoding scheme lacks the checking of the encoding format of audio and video data, resulting in abnormal video playback display.
为解决以上技术问题,本发明提供一种视频解码方法,包括步骤:In order to solve the above technical problems, the present invention provides a video decoding method, comprising the steps:
S1、获取视频码流进行解封装得到码流信息,并存储到视频包队列;S1, obtain the video code stream for decapsulation to obtain the code stream information, and store it in the video packet queue;
S2、根据预设筛选规则,从所述视频包队列中筛选出目标视频包数据;S2, according to the preset screening rule, screen out the target video packet data from the video packet queue;
S3、获取每一所述目标视频包数据的属性信息,并根据所述属性信息确定目标解码方式;S3, obtain attribute information of each described target video packet data, and determine target decoding mode according to described attribute information;
S4、当所述视频码流对应的所述目标解码方式为硬解码时,创建硬解码插件并进行视频解码。S4. When the target decoding mode corresponding to the video code stream is hard decoding, create a hard decoding plug-in and perform video decoding.
本基础方案在获取到解封装视频码流之后,进行数据储存得到视频包队列,随后根据预设筛选规则对视频包队列进行数据筛选,可在解码之前就过滤掉非法数据,减少解码异常的产生,提高解码效率;随后,根据目标视频包数据的属性信息确定其对应的目标解码方式,并在目标解码方式为硬解码时,创建硬解码插件并进行视频解码,通过预先识别视频码流中视频帧的属性信息,实现对其编码格式的检查,进而为其分配对应的解码方式,从而确保播放器传输给软解码器或者是硬解码器的数据格式是支持的,使得视频可正常播放。In this basic scheme, after obtaining the decapsulated video stream, data storage is performed to obtain a video packet queue, and then data filtering is performed on the video packet queue according to the preset filtering rules, which can filter out illegal data before decoding and reduce the occurrence of decoding abnormality. , to improve the decoding efficiency; then, determine the corresponding target decoding method according to the attribute information of the target video packet data, and when the target decoding method is hard decoding, create a hard decoding plug-in and perform video decoding. The attribute information of the frame can check its encoding format, and then assign the corresponding decoding method to it, so as to ensure that the data format transmitted by the player to the soft decoder or hard decoder is supported, so that the video can be played normally.
在进一步的实施方案中,所述步骤S1具体为:对在播放器的封装解析模块中获取到的视频码流进行解封装,获取对应的码流信息,并将所述码流信息保存到视频包队列中;In a further embodiment, the step S1 is specifically as follows: decapsulate the video code stream obtained in the encapsulation analysis module of the player, obtain the corresponding code stream information, and save the code stream information to the video packet queue;
所述视频包队列中的每一视频包均存储对应所述视频码流的pts、dts、视频压缩数据。Each video packet in the video packet queue stores pts, dts and video compression data corresponding to the video stream.
在进一步的实施方案中,所述步骤S2包括:In a further embodiment, the step S2 includes:
S21、依次序读取所述视频包队列中的每一视频包;S21, sequentially read each video packet in the video packet queue;
S22、判断所述视频包对应NALU头的数量是否大于第一预设阈值,若是则进入下一步,若否则判断为视频包数据非法并丢弃;S22, determine whether the number of the corresponding NALU headers of the video packet is greater than the first preset threshold, if so, enter the next step, if otherwise, determine that the video packet data is illegal and discarded;
S23、判断所述视频包对应NALU头的数据类型是否大于第二预设阈值,若是则进入下一步,若否则判断为视频包数据非法并丢弃;S23, determine whether the data type of the corresponding NALU header of the video packet is greater than the second preset threshold, if so, enter the next step, if otherwise, determine that the video packet data is illegal and discarded;
S24、判断所述视频包对应NALU头的数据类型是否为目标值,若是则标记为目标视频包数据,若否则判断为视频包数据非法并丢弃。S24. Determine whether the data type of the NALU header corresponding to the video packet is the target value, and if so, mark it as the target video packet data, and if otherwise, determine that the video packet data is illegal and discard it.
本方案根据视频码流的正常规格属性,设置对应于NALU头的数量、NALU头的数据类型的第一预设阈值、第二预设阈值,对视频包进行初步的筛选,可快速过滤掉非法数据,提高视频包数据的可读性,从而提高视频播放的流畅性。According to the normal specification attributes of the video stream, this solution sets the first preset threshold and the second preset threshold corresponding to the number of NALU headers and the data type of the NALU header, and performs preliminary screening of video packets, which can quickly filter out illegal data to improve the readability of video packet data, thereby improving the smoothness of video playback.
在进一步的实施方案中,所述步骤S3包括:In a further embodiment, the step S3 includes:
S31、读取所述目标视频包数据的序列参数集中的profile属性、level属性,判断profile属性、level属性是否均不大于第三预设阈值,若是则进入下一步,若否则确定其目标解码方式为软解码;S31. Read the profile attribute and the level attribute in the sequence parameter set of the target video packet data, determine whether the profile attribute and the level attribute are not greater than a third preset threshold, if so, go to the next step, if not, determine the target decoding method for soft decoding;
S32、从所述序列参数集中读取视频清晰度,并判断所述视频清晰度是否大于第四预设阈值,若是则确定其目标解码方式为硬解码,若否则确定其目标解码方式为软解码;S32. Read the video definition from the sequence parameter set, and determine whether the video definition is greater than a fourth preset threshold, if so, determine that the target decoding mode is hard decoding, if not, determine that the target decoding mode is soft decoding ;
所述第三预设阈值包括硬解码的profile属性最大值、level属性最大值;所述视频清晰度包括视频高度和视频宽度,所述第四预设阈值包括硬解码的视频高度最大值、视频宽度最大值。The third preset threshold includes the maximum hard-decoded profile attribute and the maximum level attribute; the video definition includes video height and video width, and the fourth preset threshold includes the hard-decoded maximum video height, video Maximum width.
本方案以硬解码的解码能力为限制,设置对应于视频包数据profile属性和level属性、视频清晰度的第三预设阈值、第四预设阈值,将符合硬解码需求的视频文件优先分配为硬解码,从而降低CPU占用率,提高解码效率。This scheme is limited by the decoding ability of hard decoding, sets the third preset threshold and the fourth preset threshold corresponding to the video packet data profile attribute and level attribute, video definition, and preferentially assigns the video files that meet the hard decoding requirements as Hard decoding, thereby reducing CPU usage and improving decoding efficiency.
在进一步的实施方案中,所述步骤S4包括:In a further embodiment, the step S4 includes:
S41、创建H264解码类型的硬解码插件:S41. Create a hard decoding plug-in of H264 decoding type:
S42、通过编码器/解码器组件启动H264解码类型的硬解码插件;S42. Start the hard decoding plug-in of the H264 decoding type through the encoder/decoder component;
S43、将所述目标视频包数据发送到VPU解码器进行硬件解码输出。S43. Send the target video packet data to the VPU decoder for hardware decoding output.
在进一步的实施方案中,所述步骤S41包括:In a further embodiment, the step S41 includes:
A1、在枚举类型列表里面增加H264解码类型;A1. Add H264 decoding type to the enumeration type list;
A2、复制H264解码类型的硬解码库头文件、硬解码库,并设置编译输出目录;A2. Copy the hard decoding library header file and hard decoding library of H264 decoding type, and set the compilation output directory;
A3、配置H264解码类型的CMA起始地址及相关参数;A3. Configure the CMA start address and related parameters of the H264 decoding type;
A4、编译步骤A1~A3,完成H264解码类型的硬解码插件的创建。A4. Compilation steps A1 to A3 complete the creation of a hard decoding plug-in of the H264 decoding type.
在进一步的实施方案中,所述步骤S42包括:In a further embodiment, the step S42 includes:
B1、配置编码器/解码器组件的MIME类型为H264解码类型;B1. Configure the MIME type of the encoder/decoder component as H264 decoding type;
B2、在编码器/解码器组件启动MIME类型的插件,进而启动对应的H264解码类型的硬解码插件。B2. Start the MIME type plug-in in the encoder/decoder component, and then start the corresponding H264 decoding type hard decoding plug-in.
在进一步的实施方案中,所述步骤S43包括:In a further embodiment, the step S43 includes:
C1、驱动FFmpeg读取所述视频码流,分离其对应的extradata信息、音频流、视频流;C1, drive FFmpeg to read described video stream, separate its corresponding extradata information, audio stream, video stream;
C2、根据播放要求设置extradata的地址、缓存大小;C2. Set the address and cache size of extradata according to the playback requirements;
C3、通过FFmpeg解析extradata,得到序列参数集、图像参数集并合并为一个内存缓冲器;C3. Parse the extradata through FFmpeg to obtain the sequence parameter set and the image parameter set and combine them into a memory buffer;
C4、启动VPU解码器读取所述内存缓冲器,进行解码配置并根据所述目标视频包数据进行硬件解码输出。C4. Start the VPU decoder to read the memory buffer, perform decoding configuration, and perform hardware decoding and output according to the target video packet data.
本方案通过对播放器进行设置,为视频码流创建H264解码类型的硬解码插件,进而启动VPU解码器进行硬件解码输出,能够充分的利用系统中的硬件资源,降低CPU的负荷,有效的提升了视频解码效率。By setting the player, this solution creates a H264 decoding type hard decoding plug-in for the video stream, and then starts the VPU decoder for hardware decoding output, which can fully utilize the hardware resources in the system, reduce the CPU load, and effectively improve the video decoding efficiency.
在进一步的实施方案中,本发明还包括:In further embodiments, the present invention also includes:
S5、当所述视频码流对应的所述目标解码方式为软解码时,采取FFmpeg软解码方式,按照H264的视频编码规范格式对所述目标视频包数据进行视频解码。S5. When the target decoding mode corresponding to the video code stream is soft decoding, adopt the FFmpeg soft decoding mode to perform video decoding on the target video packet data according to the H264 video coding standard format.
在进一步的实施方案中,在步骤S23之后还包括:判断所述视频包是否为关键帧,若是则将其数据结构中的关键帧标志位key_flag设置为1,否则将其关键帧标志位key_flag设置为0。In a further embodiment, after step S23, it also includes: judging whether the video packet is a key frame, if so, setting the key frame flag bit key_flag in its data structure to 1, otherwise, setting its key frame flag bit key_flag is 0.
本方案在视频数据筛选过程中,对关键帧进行标识,有利于视频解码时快速识别当前帧是否为关键帧,进而采用合适的解码方式,以提高解码效率。In this solution, in the process of video data screening, key frames are identified, which is beneficial to quickly identify whether the current frame is a key frame during video decoding, and then adopt an appropriate decoding method to improve decoding efficiency.
附图说明Description of drawings
图1是本发明实施例提供的一种视频解码方法的工作流程图。FIG. 1 is a working flowchart of a video decoding method provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面结合附图具体阐明本发明的实施方式,实施例的给出仅仅是为了说明目的,并不能理解为对本发明的限定,包括附图仅供参考和说明使用,不构成对本发明专利保护范围的限制,因为在不脱离本发明精神和范围基础上,可以对本发明进行许多改变。The embodiments of the present invention will be explained in detail below in conjunction with the accompanying drawings. The examples are given only for the purpose of illustration and should not be construed as a limitation of the present invention. The accompanying drawings are only used for reference and description, and do not constitute a limitation on the protection scope of the patent of the present invention. limitation, since many changes may be made in the present invention without departing from the spirit and scope of the invention.
本发明实施例提供的一种视频解码方法,如图1所示,在本实施例中,以H264视频文件为例进行说明,包括步骤S1~S5:A video decoding method provided by an embodiment of the present invention is shown in FIG. 1 . In this embodiment, an H264 video file is used as an example for description, including steps S1 to S5:
S1、获取视频码流进行解封装得到码流信息,并存储到视频包队列,具体为:对在播放器的封装解析模块中获取到的视频码流进行解封装,获取对应的码流信息,并将码流信息保存到视频包队列中;S1. Obtain the video code stream and decapsulate to obtain the code stream information, and store it in the video packet queue, specifically: decapsulate the video code stream obtained in the encapsulation analysis module of the player, and obtain the corresponding code stream information, And save the stream information to the video packet queue;
视频包队列(即Avpacket队列)中的每一视频包均存储对应视频码流的pts、dts、视频压缩数据。Each video packet in the video packet queue (ie, the Avpacket queue) stores the pts, dts, and video compression data of the corresponding video stream.
S2、根据预设筛选规则,从视频包队列中筛选出目标视频包数据,包括步骤S21~S24:S2. According to preset screening rules, screen out target video packet data from the video packet queue, including steps S21-S24:
S21、依次序读取视频包队列中的每一视频包的视频压缩数据;S21, sequentially read the video compression data of each video packet in the video packet queue;
S22、判断视频包对应NALU头的数量是否大于第一预设阈值,若是则进入下一步,若否则判断为视频包数据非法并丢弃;S22, determine whether the number of NALU headers corresponding to the video packet is greater than the first preset threshold, if so, enter the next step, if otherwise, determine that the video packet data is illegal and discarded;
在本实施例中,第一预设阈值为0,NALU(Network Abstract Layer Unit)全称为网络抽象层单元,是H264码流的基本单元。一帧H264的码流(annex-b打包方式)由一系列的NALU组成,NALU由NALU头和NALU主体构成。In this embodiment, the first preset threshold is 0, the full name of NALU (Network Abstract Layer Unit) is the network abstraction layer unit, which is the basic unit of the H264 code stream. A frame of H264 code stream (annex-b packing method) is composed of a series of NALUs, and NALUs are composed of NALU header and NALU body.
一帧H264的码流(例如以annex-b打包方式的码流)由一系列的NALU组成,NALU由NALU头和NALU主体构成。NALU头前面带有00 00 00 01或00 00 01分隔符,可以以此来计算NALU头的数量。The code stream of a frame of H264 (for example, the code stream in the annex-b packaging mode) is composed of a series of NALUs, and the NALU is composed of a NALU header and a NALU body. The NALU header is preceded by a 00 00 00 01 or 00 00 01 delimiter, which can be used to calculate the number of NALU headers.
S23、判断视频包对应NALU头的数据类型是否大于第二预设阈值,若是则进入下一步,若否则判断为视频包数据非法并丢弃;S23, determine whether the data type of the corresponding NALU header of the video packet is greater than the second preset threshold, if so, enter the next step, if otherwise, determine that the video packet data is illegal and discarded;
在本实施例中,设置第二预设阈值为31。In this embodiment, the second preset threshold is set to 31.
按照H264的标准文档定义,NALU头的数据类型范围在0~31以内,因此NALU头超出31即为数据非法。According to the definition of the H264 standard document, the data type of the NALU header is within the range of 0 to 31. Therefore, if the NALU header exceeds 31, the data is illegal.
在本实施例中,在步骤S23之后还包括:判断视频包是否为关键帧,若是则将其数据结构中的关键帧标志位key_flag设置为1,否则将其关键帧标志位key_flag设置为0。In this embodiment, after step S23, it further includes: judging whether the video packet is a key frame, if so, setting the key frame flag key_flag in the data structure to 1, otherwise, setting the key frame flag key_flag to 0.
其中,判断是否为关键帧的算法为,判断如下运算结果是否为5:Among them, the algorithm for judging whether it is a key frame is to judge whether the following operation result is 5:
NALU数据类型对应的二进制数值与31对应的二进制数值进行与逻辑运算。The binary value corresponding to the NALU data type is logically ANDed with the binary value corresponding to 31.
本实施例在视频数据筛选过程中,对关键帧进行标识,有利于视频解码时快速识别当前帧是否为关键帧,进而采用合适的解码方式,以提高解码效率。In this embodiment, in the process of video data screening, the key frame is identified, which is beneficial to quickly identify whether the current frame is a key frame during video decoding, and then adopt an appropriate decoding method to improve decoding efficiency.
S24、判断视频包对应NALU头的数据类型是否为目标值,若是则标记为的目标视频包数据,若否则判断为视频包数据非法并丢弃。S24. Determine whether the data type of the NALU header corresponding to the video packet is the target value, and if so, mark it as the target video packet data, if otherwise, determine that the video packet data is illegal and discard it.
在本实施例中,目标视频包数据为包含SPS单元的数据包,SPS为SequenceParamater Set的缩写,意为序列参数集;目标值设置为7。In this embodiment, the target video packet data is a data packet including an SPS unit, and SPS is an abbreviation of SequenceParamater Set, which means sequence parameter set; the target value is set to 7.
本实施例根据视频码流的正常规格属性,设置对应于NALU头的数量、NALU头的数据类型的第一预设阈值、第二预设阈值,对视频包进行初步的筛选,可快速过滤掉非法数据,提高视频包数据的可读性,从而提高视频播放的流畅性。In this embodiment, according to the normal specification attribute of the video stream, the first preset threshold and the second preset threshold corresponding to the number of NALU headers and the data type of the NALU header are set, and the video packets are preliminarily screened, which can be quickly filtered out. Illegal data, improve the readability of video packet data, thereby improving the smoothness of video playback.
S3、获取每一目标视频包数据的属性信息,并根据属性信息确定目标解码方式,包括步骤S31~S32:S3. Obtain attribute information of each target video packet data, and determine the target decoding mode according to the attribute information, including steps S31-S32:
S31、读取目标视频包数据的序列参数集(即SPS,Sequence Paramater Set)中的profile属性、level属性,判断profile属性、level属性是否均不大于第三预设阈值,若是则进入下一步,若否则确定其目标解码方式为软解码;S31, read the profile attribute and the level attribute in the sequence parameter set (ie SPS, Sequence Paramater Set) of the target video packet data, and determine whether the profile attribute and the level attribute are not greater than the third preset threshold, and if so, go to the next step, If otherwise, determine that its target decoding mode is soft decoding;
其中,第三预设阈值包括硬解码的profile属性最大值、level属性最大值。The third preset threshold includes the hard-decoded maximum value of the profile attribute and the maximum value of the level attribute.
S32、从序列参数集中读取视频清晰度,并判断视频清晰度是否大于第四预设阈值,若是则确定其目标解码方式为硬解码,若否则确定其目标解码方式为软解码;S32, read the video definition from the sequence parameter set, and determine whether the video definition is greater than the fourth preset threshold, if so, determine that its target decoding mode is hard decoding, if otherwise, determine that its target decoding mode is soft decoding;
其中,视频清晰度包括视频高度和视频宽度,第四预设阈值包括硬解码的视频高度最大值、视频宽度最大值。The video definition includes video height and video width, and the fourth preset threshold includes hard-decoded maximum video height and maximum video width.
本实施例以硬解码的解码能力为限制,设置对应于视频包数据profile属性和level属性、视频清晰度的第三预设阈值、第四预设阈值,将符合硬解码需求的视频文件优先分配为硬解码,从而降低CPU占用率,提高解码效率。This embodiment is limited by the decoding capability of hard decoding, and sets a third preset threshold and a fourth preset threshold corresponding to the video packet data profile attribute and level attribute, video definition, and preferentially allocates video files that meet the hard decoding requirements. It is hard decoding, thereby reducing CPU usage and improving decoding efficiency.
S4、当视频码流对应的目标解码方式为硬解码时,创建硬解码插件并进行视频解码,包括步骤S41~S43:S4. When the target decoding mode corresponding to the video code stream is hard decoding, create a hard decoding plug-in and perform video decoding, including steps S41 to S43:
S41、创建H264解码类型的硬解码插件,包括步骤A1~A4:S41. Create a hard decoding plug-in of the H264 decoding type, including steps A1 to A4:
A1、在枚举类型列表里面增加H264解码类型;A1. Add H264 decoding type to the enumeration type list;
A2、复制H264解码类型的硬解码库头文件、硬解码库,并设置编译输出目录;A2. Copy the hard decoding library header file and hard decoding library of H264 decoding type, and set the compilation output directory;
A3、配置H264解码类型的CMA(Contiguous Memory Allocator,连续内存块)起始地址及相关参数;A3. Configure the starting address and related parameters of the CMA (Contiguous Memory Allocator, continuous memory block) of the H264 decoding type;
在本实施例中,相关参数包括硬解码器的名字、MIME类型、解析的最大及最小分辨率、波特率等参数。In this embodiment, the relevant parameters include parameters such as the name of the hard decoder, the MIME type, the parsed maximum and minimum resolution, and the baud rate.
A4、编译步骤A1~A3,完成H264解码类型的硬解码插件的创建。A4. Compilation steps A1 to A3 complete the creation of a hard decoding plug-in of the H264 decoding type.
S42、通过编码器/解码器(即MediaCodec)组件启动H264解码类型的硬解码插件,包括步骤B1~B2:S42, start the hard decoding plug-in of the H264 decoding type through the encoder/decoder (ie MediaCodec) component, including steps B1-B2:
B1、配置编码器/解码器组件的MIME类型为H264解码类型;B1. Configure the MIME type of the encoder/decoder component as H264 decoding type;
B2、在编码器/解码器组件启动MIME类型的插件,进而启动对应的H264解码类型的硬解码插件。B2. Start the MIME type plug-in in the encoder/decoder component, and then start the corresponding H264 decoding type hard decoding plug-in.
S43、将目标视频包数据发送到VPU解码器进行硬件解码输出,包括步骤C1~C4:S43, sending the target video packet data to the VPU decoder for hardware decoding output, including steps C1-C4:
C1、驱动FFmpeg读取视频码流,分离其对应的extradata信息、音频流、视频流;C1. Drive FFmpeg to read the video stream, and separate its corresponding extradata information, audio stream, and video stream;
C2、根据播放要求设置extradata的地址、缓存大小;C2. Set the address and cache size of extradata according to the playback requirements;
C3、通过FFmpeg解析extradata,得到序列参数集、图像参数集并合并为一个内存缓冲器;C3. Parse the extradata through FFmpeg to obtain the sequence parameter set and the image parameter set and combine them into a memory buffer;
C4、启动VPU解码器读取内存缓冲器,进行解码配置并根据目标视频包数据进行硬件解码输出。C4. Start the VPU decoder to read the memory buffer, perform decoding configuration, and perform hardware decoding output according to the target video packet data.
具体为:启动VPU解码器后,将内存缓冲器(内存Buffer)的地址发送给VPU解码器,VPU解码器读取到内存Buffer的信息后,完成解码前的配置工作。随后,通过MediaCodec的接口将内存缓冲器以CMA内存方式发送给VPU解码器进行硬件解码输出。Specifically, after starting the VPU decoder, the address of the memory buffer (memory buffer) is sent to the VPU decoder, and after reading the information of the memory buffer, the VPU decoder completes the configuration work before decoding. Then, the memory buffer is sent to the VPU decoder in the form of CMA memory through the interface of MediaCodec for hardware decoding output.
本实施例通过对播放器进行设置,为视频码流创建H264解码类型的硬解码插件,进而启动VPU解码器进行硬件解码输出,能够充分的利用系统中的硬件资源,降低CPU的负荷,有效的提升了视频解码效率。In this embodiment, by setting the player, creating a hard decoding plug-in of H264 decoding type for the video stream, and then starting the VPU decoder for hardware decoding output, the hardware resources in the system can be fully utilized, the CPU load can be reduced, and the effective Improved video decoding efficiency.
S5、当视频码流对应的目标解码方式为软解码时,采取FFmpeg软解码方式,按照H264的视频编码规范格式对目标视频包数据进行视频解码。S5. When the target decoding mode corresponding to the video code stream is soft decoding, the FFmpeg soft decoding mode is adopted to perform video decoding on the target video packet data according to the H264 video coding standard format.
本发明实施例在获取到解封装视频码流之后,进行数据储存得到视频包队列,随后根据预设筛选规则对视频包队列进行数据筛选,可在解码之前就过滤掉非法数据,减少解码异常的产生,提高解码效率;随后,根据目标视频包数据的属性信息确定其对应的目标解码方式,并在目标解码方式为硬解码时,创建硬解码插件并进行视频解码,通过预先识别视频码流中视频帧的属性信息,实现对其编码格式的检查,进而为其分配对应的解码方式,从而确保播放器传输给软解码器或者是硬解码器的数据格式是支持的,使得视频可正常播放。In this embodiment of the present invention, after the decapsulated video stream is acquired, data is stored to obtain a video packet queue, and then data filtering is performed on the video packet queue according to preset screening rules, so that illegal data can be filtered out before decoding, thereby reducing abnormal decoding. Then, according to the attribute information of the target video packet data, the corresponding target decoding mode is determined, and when the target decoding mode is hard decoding, a hard decoding plug-in is created and video decoding is performed. The attribute information of the video frame can check its encoding format, and then assign the corresponding decoding method to it, so as to ensure that the data format transmitted by the player to the soft decoder or hard decoder is supported, so that the video can be played normally.
上述实施例为本发明较佳的实施方式,但本发明的实施方式并不受上述实施例的限制,其他的任何未背离本发明的精神实质与原理下所作的改变、修饰、替代、组合、简化,均应为等效的置换方式,都包含在本发明的保护范围之内。The above-mentioned embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited by the above-mentioned embodiments, and any other changes, modifications, substitutions, combinations, The simplification should be equivalent replacement manners, which are all included in the protection scope of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111424627.6A CN114339408A (en) | 2021-11-26 | 2021-11-26 | Video decoding method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111424627.6A CN114339408A (en) | 2021-11-26 | 2021-11-26 | Video decoding method |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN114339408A true CN114339408A (en) | 2022-04-12 |
Family
ID=81047248
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202111424627.6A Pending CN114339408A (en) | 2021-11-26 | 2021-11-26 | Video decoding method |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN114339408A (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114666603A (en) * | 2022-05-06 | 2022-06-24 | 厦门美图之家科技有限公司 | Video decoding method and device, electronic equipment and storage medium |
| CN114745600A (en) * | 2022-06-10 | 2022-07-12 | 中国传媒大学 | A method and device for labeling video based on SEI |
| CN116320468A (en) * | 2023-03-26 | 2023-06-23 | 苏州浪潮智能科技有限公司 | A method, system, terminal and medium for multi-process encoding and decoding homologous files |
| CN116886678A (en) * | 2023-09-06 | 2023-10-13 | 中移(杭州)信息技术有限公司 | Abnormal code stream filtering method, system, electronic device and storage medium |
Citations (13)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101986708A (en) * | 2010-10-29 | 2011-03-16 | 北京中星微电子有限公司 | Video decoding method and decoder |
| CN105898496A (en) * | 2015-11-18 | 2016-08-24 | 乐视网信息技术(北京)股份有限公司 | HLS stream hardware decoding method based on Android device and device |
| CN105992056A (en) * | 2015-01-30 | 2016-10-05 | 腾讯科技(深圳)有限公司 | Video decoding method and device |
| CN106034252A (en) * | 2015-03-12 | 2016-10-19 | 深圳市腾讯计算机系统有限公司 | Streaming media processing method and device |
| WO2017054462A1 (en) * | 2015-09-28 | 2017-04-06 | 腾讯科技(深圳)有限公司 | Video decoding method, server and mobile terminal |
| CN106851217A (en) * | 2017-03-14 | 2017-06-13 | 深圳市创维群欣安防科技股份有限公司 | The coding/decoding method and system of a kind of monitoring display device |
| CN108235096A (en) * | 2018-01-18 | 2018-06-29 | 湖南快乐阳光互动娱乐传媒有限公司 | Method for intelligently switching soft decoding and playing video through hard decoding of mobile terminal |
| CN108401188A (en) * | 2018-03-05 | 2018-08-14 | 青岛海信传媒网络技术有限公司 | A kind of method and device of media play |
| CN108419041A (en) * | 2017-02-09 | 2018-08-17 | 北京视联动力国际信息技术有限公司 | A kind of method and apparatus of video data processing |
| CN109379630A (en) * | 2018-11-27 | 2019-02-22 | Oppo广东移动通信有限公司 | Video processing method and device, electronic equipment and storage medium |
| CN110572622A (en) * | 2019-09-30 | 2019-12-13 | 威创集团股份有限公司 | Video decoding method and device |
| CN113055744A (en) * | 2020-08-31 | 2021-06-29 | 惠州华阳通用电子有限公司 | Video decoding method and device |
| CN113645490A (en) * | 2021-06-23 | 2021-11-12 | 天津津航计算技术研究所 | Soft and hard combined multi-channel video synchronous decoding method |
-
2021
- 2021-11-26 CN CN202111424627.6A patent/CN114339408A/en active Pending
Patent Citations (13)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101986708A (en) * | 2010-10-29 | 2011-03-16 | 北京中星微电子有限公司 | Video decoding method and decoder |
| CN105992056A (en) * | 2015-01-30 | 2016-10-05 | 腾讯科技(深圳)有限公司 | Video decoding method and device |
| CN106034252A (en) * | 2015-03-12 | 2016-10-19 | 深圳市腾讯计算机系统有限公司 | Streaming media processing method and device |
| WO2017054462A1 (en) * | 2015-09-28 | 2017-04-06 | 腾讯科技(深圳)有限公司 | Video decoding method, server and mobile terminal |
| CN105898496A (en) * | 2015-11-18 | 2016-08-24 | 乐视网信息技术(北京)股份有限公司 | HLS stream hardware decoding method based on Android device and device |
| CN108419041A (en) * | 2017-02-09 | 2018-08-17 | 北京视联动力国际信息技术有限公司 | A kind of method and apparatus of video data processing |
| CN106851217A (en) * | 2017-03-14 | 2017-06-13 | 深圳市创维群欣安防科技股份有限公司 | The coding/decoding method and system of a kind of monitoring display device |
| CN108235096A (en) * | 2018-01-18 | 2018-06-29 | 湖南快乐阳光互动娱乐传媒有限公司 | Method for intelligently switching soft decoding and playing video through hard decoding of mobile terminal |
| CN108401188A (en) * | 2018-03-05 | 2018-08-14 | 青岛海信传媒网络技术有限公司 | A kind of method and device of media play |
| CN109379630A (en) * | 2018-11-27 | 2019-02-22 | Oppo广东移动通信有限公司 | Video processing method and device, electronic equipment and storage medium |
| CN110572622A (en) * | 2019-09-30 | 2019-12-13 | 威创集团股份有限公司 | Video decoding method and device |
| CN113055744A (en) * | 2020-08-31 | 2021-06-29 | 惠州华阳通用电子有限公司 | Video decoding method and device |
| CN113645490A (en) * | 2021-06-23 | 2021-11-12 | 天津津航计算技术研究所 | Soft and hard combined multi-channel video synchronous decoding method |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114666603A (en) * | 2022-05-06 | 2022-06-24 | 厦门美图之家科技有限公司 | Video decoding method and device, electronic equipment and storage medium |
| CN114666603B (en) * | 2022-05-06 | 2024-05-03 | 厦门美图之家科技有限公司 | Video decoding method and device, electronic equipment and storage medium |
| CN114745600A (en) * | 2022-06-10 | 2022-07-12 | 中国传媒大学 | A method and device for labeling video based on SEI |
| CN116320468A (en) * | 2023-03-26 | 2023-06-23 | 苏州浪潮智能科技有限公司 | A method, system, terminal and medium for multi-process encoding and decoding homologous files |
| CN116886678A (en) * | 2023-09-06 | 2023-10-13 | 中移(杭州)信息技术有限公司 | Abnormal code stream filtering method, system, electronic device and storage medium |
| CN116886678B (en) * | 2023-09-06 | 2023-12-05 | 中移(杭州)信息技术有限公司 | Abnormal code stream filtering method, system, electronic equipment and storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN114339408A (en) | Video decoding method | |
| JP4299836B2 (en) | Data processing device | |
| JP6585773B2 (en) | Method for receiving multimedia data in a hybrid network | |
| JP4481889B2 (en) | Data recording apparatus and method, program, and recording medium | |
| JP2001346205A (en) | Method for concealing signal error | |
| JPWO2006033279A1 (en) | Data processing device | |
| CN101124636A (en) | Information storage medium, method and apparatus for reproducing information from information storage medium, and recording apparatus and recording method for recording video data on information storage medium | |
| CN100481919C (en) | Data stream format conversion method and recording method for the same | |
| JP5351972B2 (en) | Multimedia data recording | |
| CN100433821C (en) | Image processing apparatus | |
| JP2006512835A (en) | VOBU generation method in HD-DVD system | |
| JP2004128938A (en) | AV data recording and reproducing apparatus and method | |
| JP4791969B2 (en) | Data processing device | |
| CN100454225C (en) | Device and method for storing real-time digital information signal stream | |
| US10354695B2 (en) | Data recording control device and data recording control method | |
| EP1903572A2 (en) | Method and system for fast format transformation | |
| CN1985513A (en) | Stream recording/reproducing apparatus | |
| CN1536573A (en) | Apparatus and method for duplicating digital data | |
| US7493016B2 (en) | Recording device, playback device and program | |
| JP5191294B2 (en) | Information processing apparatus and program | |
| CN100386799C (en) | Voice frame calculating method for audio decoding | |
| CN100593952C (en) | Multiplexer and multiplexing method | |
| JP4490691B2 (en) | Apparatus, record carrier and method for recording a sequence of video data signals | |
| US20040076406A1 (en) | Information recording apparatus and method | |
| CN101025986A (en) | Recording and reproducing apparatus |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20220412 |
|
| RJ01 | Rejection of invention patent application after publication |