CN101998117A - Video transcoding method and device - Google Patents
Video transcoding method and device Download PDFInfo
- Publication number
- CN101998117A CN101998117A CN 200910165221 CN200910165221A CN101998117A CN 101998117 A CN101998117 A CN 101998117A CN 200910165221 CN200910165221 CN 200910165221 CN 200910165221 A CN200910165221 A CN 200910165221A CN 101998117 A CN101998117 A CN 101998117A
- Authority
- CN
- China
- Prior art keywords
- macro block
- input code
- encoded
- coding
- information
- 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.)
- Granted
Links
Images
Landscapes
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
本发明实施例公开了一种视频转码方法和装置,所述视频转码方法包括:对输入码流进行解码,提取解码后的输入码流的宏块信息,根据所述输入码流确定像素转码率;当确定的所述像素转码率小于预设的第一门限值时,根据所述宏块信息对所述解码后的输入码流进行编码;当所述像素转码率大于所述第一门限值时,根据所述宏块信息重新确定宏块编码模式,并根据重新确定的宏块编码模式对所述解码后的输入码流进行编码。本发明实施例在确保恢复的视频质量的前提下,提高了转码速度,更好地满足了实时视频转码的要求。
The embodiment of the present invention discloses a video transcoding method and device. The video transcoding method includes: decoding the input code stream, extracting the macroblock information of the decoded input code stream, and determining the pixel according to the input code stream Transcoding rate; when the determined pixel transcoding rate is less than a preset first threshold value, encode the decoded input code stream according to the macroblock information; when the pixel transcoding rate is greater than When the first threshold is set, a macroblock coding mode is re-determined according to the macroblock information, and the decoded input code stream is coded according to the re-determined macroblock coding mode. The embodiments of the present invention increase the transcoding speed on the premise of ensuring the restored video quality, and better meet the requirements of real-time video transcoding.
Description
技术领域technical field
本发明实施例涉及通信技术领域,特别涉及一种视频转码方法和装置。Embodiments of the present invention relate to the field of communication technologies, and in particular, to a video transcoding method and device.
背景技术Background technique
随着移动通信技术的不断发展,网络接入速度的飞速提升,移动终端的越趋智能化,以及数字压缩技术的日益优化,移动终端已从简单的通信、联络工具,发展成为一个多媒体智能平台。与此同时,传统的彩信、图铃下载等增值业务已无法满足用户的需求。移动流媒体的出现将改变这种状况,移动流媒体能为用户提供包括视频点播、移动视频聊天、移动视频监控等服务。移动流媒体是移动通信和流媒体传输的结合,通过移动网络在移动终端上采用流媒体技术进行数据传输。然而,移动终端的多样性,无线网络的波动性以及移动终端的处理能力限制了移动流媒体的发展。With the continuous development of mobile communication technology, the rapid increase of network access speed, the increasingly intelligent mobile terminal, and the increasingly optimized digital compression technology, the mobile terminal has developed from a simple communication and contact tool to a multimedia intelligent platform. . At the same time, traditional value-added services such as MMS and picture and ring download can no longer meet the needs of users. The emergence of mobile streaming media will change this situation. Mobile streaming media can provide users with services including video on demand, mobile video chat, and mobile video surveillance. Mobile streaming media is a combination of mobile communication and streaming media transmission, using streaming media technology on mobile terminals for data transmission through mobile networks. However, the diversity of mobile terminals, the volatility of wireless networks, and the processing capabilities of mobile terminals limit the development of mobile streaming media.
码率变换的视频转码可以根据移动终端的处理能力以及网络带宽的条件,提供最合适的视频流,因此是促进移动流媒体发展的关键技术。码率转换最直接的办法是采用级联的全解全编转码器。全解全编转码器分为两个部分:先由解码器对输入视频流进行完全解码,再由一个编码器按照目标码率对解码后的视频进行编码压缩。通过将解码后的视频流按目标码率进行重新编码,从而能够得到最佳的图像质量。The video transcoding of code rate conversion can provide the most suitable video stream according to the processing capability of the mobile terminal and the conditions of the network bandwidth, so it is a key technology to promote the development of mobile streaming media. The most direct method of code rate conversion is to use cascaded full-decoding and full-coding transcoders. The full-decoding and full-coding transcoder is divided into two parts: first, the decoder completely decodes the input video stream, and then an encoder encodes and compresses the decoded video according to the target bit rate. By re-encoding the decoded video stream according to the target bit rate, the best image quality can be obtained.
在实现本发明的过程中,发明人发现现有技术至少存在以下问题:现有技术提供的视频转码方案在实现时需要对输入码流进行完全解码,然后对解码后的输入码流重新进行运动估计、编码模式判决等编码操作,运算复杂度高,使得转码速度低,不能更好地满足实时视频转码的要求。In the process of realizing the present invention, the inventor found that the prior art has at least the following problems: the video transcoding scheme provided by the prior art needs to fully decode the input code stream, and then re-decode the decoded input code stream. Coding operations such as motion estimation and coding mode judgment have high computational complexity, which makes the transcoding speed low and cannot better meet the requirements of real-time video transcoding.
发明内容Contents of the invention
本发明实施例提供一种视频转码方法和装置,以实现根据输入码流和输出码流的像素转码率,实时选择宏块编码模式,在确保恢复视频质量的前提下,提高转码速度。Embodiments of the present invention provide a video transcoding method and device to realize real-time selection of a macroblock encoding mode according to the pixel transcoding rate of the input code stream and output code stream, and increase the transcoding speed under the premise of ensuring the restoration of video quality .
本发明实施例提供了一种视频转码方法,包括:An embodiment of the present invention provides a video transcoding method, including:
对输入码流进行解码,提取解码后的输入码流的宏块信息,根据所述输入码流确定像素转码率;Decoding the input code stream, extracting the macroblock information of the decoded input code stream, and determining the pixel transcoding rate according to the input code stream;
当确定的所述像素转码率小于预设的第一门限值时,根据所述宏块信息对所述解码后的输入码流进行编码;When the determined pixel transcoding rate is less than a preset first threshold value, encode the decoded input code stream according to the macroblock information;
当所述像素转码率大于所述第一门限值时,根据所述宏块信息重新确定宏块编码模式,并根据重新确定的宏块编码模式对所述解码后的输入码流进行编码。When the pixel transcoding rate is greater than the first threshold value, re-determine the macro-block coding mode according to the macro-block information, and code the decoded input code stream according to the re-determined macro-block coding mode .
本发明实施例还提供一种视频转码装置,包括:The embodiment of the present invention also provides a video transcoding device, including:
解码模块,用于对输入码流进行解码;Decoding module, used to decode the input code stream;
提取模块,用于提取所述解码模块解码后的输入码流的宏块信息;An extraction module, configured to extract the macroblock information of the input stream decoded by the decoding module;
像素转码率确定模块,用于根据所述输入码流确定像素转码率;A pixel transcoding rate determining module, configured to determine a pixel transcoding rate according to the input code stream;
编码模块,用于当所述像素转码率确定模块确定的像素转码率小于预设的第一门限值时,根据所述提取模块提取的宏块信息对所述解码模块解码后的输入码流进行编码;An encoding module, configured to decode the input of the decoding module according to the macroblock information extracted by the extracting module when the pixel transcoding rate determined by the pixel transcoding rate determination module is less than a preset first threshold value Encode the code stream;
编码模式确定模块,用于当所述像素转码率确定模块确定的像素转码率大于所述第一门限值时,根据所述提取模块提取的宏块信息重新确定宏块编码模式;所述编码模块还用于根据所述编码模式确定模块重新确定的宏块编码模式对所述解码模块解码后的输入码流进行编码。An encoding mode determination module, configured to re-determine the macroblock encoding mode according to the macroblock information extracted by the extraction module when the pixel transcoding rate determined by the pixel transcoding rate determination module is greater than the first threshold value; The encoding module is further configured to encode the input code stream decoded by the decoding module according to the macroblock encoding mode re-determined by the encoding mode determining module.
本发明实施例根据像素转码率和输入码流的宏块信息实时确定宏块编码模式,然后再根据确定的宏块编码模式进行编码,从而在确保恢复的视频质量的前提下,提高了转码速度,更好地满足了实时视频转码的要求。In the embodiment of the present invention, the macroblock encoding mode is determined in real time according to the pixel transcoding rate and the macroblock information of the input code stream, and then encoding is performed according to the determined macroblock encoding mode, thereby improving the conversion rate while ensuring the restored video quality. The coding speed better meets the requirements of real-time video transcoding.
附图说明Description of drawings
为了更清楚地说明本发明或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the present invention or the technical solutions in the prior art, the accompanying drawings that need to be used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings in the following description are only the present invention. For some embodiments of the invention, those skilled in the art can also obtain other drawings based on these drawings without creative effort.
图1为本发明视频转码方法一个实施例的流程图;FIG. 1 is a flowchart of an embodiment of the video transcoding method of the present invention;
图2为本发明视频转码方法另一个实施例的流程图;FIG. 2 is a flowchart of another embodiment of the video transcoding method of the present invention;
图3为本发明视频转码装置一个实施例的结构示意图;FIG. 3 is a schematic structural diagram of an embodiment of a video transcoding device according to the present invention;
图4为本发明视频转码装置另一个实施例的结构示意图;FIG. 4 is a schematic structural diagram of another embodiment of the video transcoding device of the present invention;
图5为本发明Carphone.qcif序列的PSNR性能对比示意图;Fig. 5 is the comparative schematic diagram of PSNR performance of Carphone.qcif sequence of the present invention;
图6为本发明Carphone.qcif序列的转码速度对比示意图;Fig. 6 is a comparative schematic diagram of the transcoding speed of the Carphone.qcif sequence of the present invention;
图7为本发明Foreman.cif序列的PSNR性能对比示意图;Fig. 7 is a schematic diagram of PSNR performance comparison of the Foreman.cif sequence of the present invention;
图8为本发明Foreman.cif序列的转码速度对比示意图。Fig. 8 is a schematic diagram of the comparison of the transcoding speed of the Foreman.cif sequence of the present invention.
具体实施方式Detailed ways
下面将结合本发明中的附图,对本发明中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the present invention. Obviously, the described embodiments are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
本发明实施例提供一种视频转码方法,通过复用输入码流中的图像信息、运动矢量、宏块编码类型、预测残差等信息,简化编码模式判决、运动估计等操作以降低转码运算复杂度,提高转码速度。An embodiment of the present invention provides a video transcoding method. By multiplexing information such as image information, motion vectors, macroblock coding types, and prediction residuals in the input code stream, operations such as coding mode judgment and motion estimation are simplified to reduce the cost of transcoding. Computational complexity, improve transcoding speed.
图1为本发明视频转码方法一个实施例的流程图,如图1所示,包括:Fig. 1 is a flowchart of an embodiment of the video transcoding method of the present invention, as shown in Fig. 1, including:
步骤101,对输入码流进行解码,提取解码后的输入码流的宏块信息,根据输入码流确定像素转码率。
步骤102,当确定的像素转码率小于预设的第一门限值时,根据该宏块信息对解码后的输入码流进行编码。
其中,像素转码率为输入码流中平均每像素占用的比特数与预设的输出码流中平均每像素占用的比特数的比值,其中,预设的输出码流中平均每像素占用的比特数为一表示期望输出的数值,与转码需要过程中的相关指标及输入码流中的相关信息(如码率等)有关。像素转码率表示输入码流与预期的输出码流之间的相似程度,像素转码率越小,表示输入码流与预期的输出码流之间的相似性越高。Among them, the pixel conversion rate is the ratio of the average number of bits per pixel in the input code stream to the average number of bits per pixel in the preset output code stream, where the average number of bits per pixel in the preset output code stream The number of bits is a value representing the desired output, which is related to relevant indicators in the transcoding process and relevant information in the input code stream (such as code rate, etc.). The pixel transcoding rate indicates the degree of similarity between the input code stream and the expected output code stream. The smaller the pixel transcoding rate, the higher the similarity between the input code stream and the expected output code stream.
当像素转码率小于预设的第一门限值时,解码后的输入码流与预期的输出码流之间具有较强的相似性,因此不需要对输入码流进行较大的调整,可以根据解码后的输入码流的宏块信息对解码后的输入码流进行编码。When the pixel conversion rate is less than the preset first threshold value, there is a strong similarity between the decoded input code stream and the expected output code stream, so there is no need to make major adjustments to the input code stream, The decoded input code stream may be encoded according to the macroblock information of the decoded input code stream.
步骤103,当像素转码率大于该第一门限值时,根据该宏块信息重新确定宏块编码模式,并根据重新确定的宏块编码模式对解码后的输入码流进行编码。
具体地,当像素转码率大于该第一门限值时,解码后的输入码流与预期的输出码流之间的差异性较大,因此根据解码后的输入码流的宏块信息对解码后的输入码流进行编码,无法保证转码后的输出码流的视频质量。这种情况下,需要根据解码后的输入码流中的宏块信息重新确定宏块编码模式,再根据重新确定的宏块编码模式对解码后的输入码流进行编码。Specifically, when the pixel transcoding rate is greater than the first threshold value, the difference between the decoded input code stream and the expected output code stream is relatively large, so according to the macroblock information of the decoded input code stream The decoded input stream is encoded, and the video quality of the transcoded output stream cannot be guaranteed. In this case, it is necessary to re-determine the macroblock coding mode according to the macroblock information in the decoded input code stream, and then encode the decoded input code stream according to the newly determined macroblock coding mode.
本实施例中,根据输入码流中平均每像素占用的比特数和预设的输出码流中平均每像素占用的比特数,可以确定上述像素转码率。In this embodiment, the pixel conversion rate can be determined according to the average number of bits occupied per pixel in the input code stream and the preset average number of bits occupied per pixel in the output code stream.
具体地,码流中平均每像素占用的比特数为bpp,bpp可以通过式(1)计算,Specifically, the average number of bits per pixel in the code stream is bpp, and bpp can be calculated by formula (1),
bpp=R/(F×W×H) (1)bpp=R/(F×W×H) (1)
式(1)中,R标识码流的码率,F表示码流的帧率,W和H分别表示图像的宽度和高度。In formula (1), R identifies the code rate of the code stream, F represents the frame rate of the code stream, W and H represent the width and height of the image, respectively.
对输入码流进行解码之后,可以获得输入码流的码率和帧率,以及解码后的输入码流中图像的宽度和高度,根据这些参数即可计算得到解码后的输入码流中平均每像素占用的比特数;以上只是获得输入码流的码率和帧率,以及输入码流中图像的宽度和高度,进而获得输入码流中平均每像素占用的比特数的一种方式,本发明实施例并不局限于此,输入码流的码率和帧率,以及输入码流中图像的宽度和高度并不一定在解码后才能得到,上述参数也可以通过其他方式获得,例如:预先输入上述参数;本发明实施例对获得输入码流的码率和帧率,以及输入码流中图像的宽度和高度的方式不作限定。After decoding the input code stream, the code rate and frame rate of the input code stream can be obtained, as well as the width and height of the image in the decoded input code stream, and the average The number of bits occupied by a pixel; the above is only a way to obtain the code rate and frame rate of the input code stream, and the width and height of the image in the input code stream, and then obtain the average number of bits occupied by each pixel in the input code stream. The present invention The embodiment is not limited thereto, the code rate and frame rate of the input code stream, and the width and height of the image in the input code stream may not be obtained after decoding, and the above parameters can also be obtained in other ways, for example: pre-input The above parameters; the embodiments of the present invention do not limit the way to obtain the code rate and frame rate of the input code stream, and the width and height of the image in the input code stream.
另外,可以根据转码要求预先设置输出码流的码率和帧率,以及输出码流中图像的宽度和高度,根据这些参数即可计算得到预设的输出码流中平均每像素占用的比特数。In addition, the code rate and frame rate of the output code stream can be preset according to the transcoding requirements, as well as the width and height of the image in the output code stream. According to these parameters, the average bit occupied by each pixel in the preset output code stream can be calculated. number.
其中,该宏块信息包括:块类型信息、分块模式信息、运动矢量信息、块编码类型(Coded Block Pattern;以下简称:CBP)信息、量化参数和宏块残差等编码所需的信息;宏块编码模式包括:块类型信息、分块模式信息和运动矢量信息。Among them, the macroblock information includes: block type information, block mode information, motion vector information, block coding type (Coded Block Pattern; hereinafter referred to as: CBP) information, quantization parameters, and macroblock residual information required for coding; The block coding mode includes: block type information, block mode information and motion vector information.
上述步骤102和步骤103的执行顺序不分先后,可并行执行。The above-mentioned
本实施例根据像素转码率和输入码流的宏块信息实时确定宏块编码模式,然后再根据确定的宏块编码模式进行编码,从而在确保恢复的视频质量的前提下,提高了转码速度,更好地满足了实时视频转码要求。In this embodiment, the macroblock encoding mode is determined in real time according to the pixel transcoding rate and the macroblock information of the input code stream, and then encoding is performed according to the determined macroblock encoding mode, thereby improving the transcoding while ensuring the restored video quality. The speed better meets the requirements of real-time video transcoding.
图2为本发明视频转码方法另一个实施例的流程图,如图2所示,包括:Fig. 2 is a flowchart of another embodiment of the video transcoding method of the present invention, as shown in Fig. 2, including:
步骤201,对输入码流进行解码,提取解码后的输入码流的宏块信息。
步骤202,根据输入码流中平均每像素占用的比特数和预设的输出码流中平均每像素占用的比特数,确定像素转码率。Step 202: Determine the pixel transcoding rate according to the average number of bits per pixel in the input code stream and the preset average number of bits per pixel in the output code stream.
具体地,码流中平均每像素占用的比特数为bpp,bpp可以通过式(1)计算。Specifically, the average number of bits occupied by each pixel in the code stream is bpp, and bpp can be calculated by formula (1).
对输入码流进行解码之后,可以获得输入码流的码率和帧率,以及解码后的输入码流中图像的宽度和高度,根据这些参数即可计算得到解码后的输入码流中平均每像素占用的比特数;以上只是获得输入码流的码率和帧率,以及输入码流中图像的宽度和高度,进而获得输入码流中平均每像素占用的比特数的一种方式,本发明实施例并不局限于此,输入码流的码率和帧率,以及输入码流中图像的宽度和高度并不一定在解码后才能得到,上述参数也可以通过其他方式获得,例如:预先输入上述参数;本发明实施例对获得输入码流的码率和帧率,以及输入码流中图像的宽度和高度的方式不作限定。After decoding the input code stream, the code rate and frame rate of the input code stream can be obtained, as well as the width and height of the image in the decoded input code stream, and the average The number of bits occupied by a pixel; the above is only a way to obtain the code rate and frame rate of the input code stream, and the width and height of the image in the input code stream, and then obtain the average number of bits occupied by each pixel in the input code stream. The present invention The embodiment is not limited thereto, the code rate and frame rate of the input code stream, and the width and height of the image in the input code stream may not be obtained after decoding, and the above parameters can also be obtained in other ways, for example: pre-input The above parameters; the embodiments of the present invention do not limit the way to obtain the code rate and frame rate of the input code stream, and the width and height of the image in the input code stream.
另外,可以根据转码要求预先设置输出码流的码率和帧率,以及输出码流中图像的宽度和高度,根据这些参数即可计算得到预设的输出码流中平均每像素占用的比特数。In addition, the code rate and frame rate of the output code stream can be preset according to the transcoding requirements, as well as the width and height of the image in the output code stream. According to these parameters, the average bit occupied by each pixel in the preset output code stream can be calculated. number.
输入码流中平均每像素占用的比特数与预设的输出码流中平均每像素占用的比特数的比值,即为像素转码率。以ω表示像素转码率,以bppi表示输入码流中平均每像素占用的比特数,以bppo表示预设的输出码流中平均每像素占用的比特数,则,The ratio of the average number of bits per pixel in the input code stream to the preset average number of bits per pixel in the output code stream is the pixel conversion rate. Use ω to represent the pixel transcoding rate, bpp i to represent the average number of bits per pixel in the input code stream, and bpp o to represent the average number of bits per pixel in the preset output code stream, then,
ω=bppi/bppo (2)ω=bpp i /bpp o (2)
像素转码率表示输入码流与预期的输出码流之间的相似程度,像素转码率越小,表示输入码流与预期的输出码流之间的相似性越高。The pixel transcoding rate indicates the degree of similarity between the input code stream and the expected output code stream. The smaller the pixel transcoding rate, the higher the similarity between the input code stream and the expected output code stream.
步骤203,判断像素转码率是否大于预设的第一门限值。如果该像素转码率小于该第一门限值,则执行步骤204~步骤206;如果该像素转码率大于该第一门限值,则执行步骤207。
本实施例中,预先设置第一门限值α,这里的α的取值为一经验值,可以将α在一定范围内取多个值,通过多次仿真调试后得到最佳的数量,如α可以取0.5、或0.45等,本文中的其他门限值也可用类似方法获取。当设置第一门限值α后,判断像素转码率ω是否大于α。如果ω>α,则表示解码后的输入码流与预期的输出码流之间的差异性较大,因此根据解码后的输入码流的宏块信息对解码后的输入码流进行编码无法保证转码后的输出码流的视频质量。这种情况下,需要根据解码后的输入码流中的宏块信息重新确定宏块编码模式,再根据重新确定的宏块编码模式对解码后的输入码流进行编码;In this embodiment, the first threshold value α is preset, and the value of α here is an empirical value, and α can take multiple values within a certain range, and the optimal number can be obtained after multiple simulations and debugging, such as α can be 0.5, or 0.45, etc. Other threshold values in this paper can also be obtained by similar methods. After setting the first threshold value α, it is judged whether the pixel transcoding rate ω is greater than α. If ω>α, it means that the difference between the decoded input code stream and the expected output code stream is large, so the encoding of the decoded input code stream according to the macroblock information of the decoded input code stream cannot guarantee The video quality of the transcoded output stream. In this case, it is necessary to re-determine the macroblock coding mode according to the macroblock information in the decoded input code stream, and then encode the decoded input code stream according to the newly determined macroblock coding mode;
如果ω<α,则表示解码后的输入码流与预期的输出码流之间具有较强的相似性,因此不需要对输入码流进行较大的调整,可以根据解码后的输入码流的宏块信息对解码后的输入码流进行编码。If ω<α, it means that there is a strong similarity between the decoded input code stream and the expected output code stream, so there is no need to make major adjustments to the input code stream. The macroblock information encodes the decoded input stream.
步骤204,根据解码后的输入码流的宏块信息对解码后的输入码流的每一帧进行编码之后,计算编码后的输出帧的第一失真度,以及该输出帧对应的输入帧的第二失真度,并计算第一失真度与第二失真度的比值。Step 204: After encoding each frame of the decoded input code stream according to the macroblock information of the decoded input code stream, calculate the first distortion degree of the coded output frame, and the corresponding input frame distortion degree of the output frame second degree of distortion, and calculate the ratio of the first degree of distortion to the second degree of distortion.
输入码流是由一帧一帧的图像组成的,每一帧图像包括多个宏块,宏块中的头比特表示宏块编码模式、运动矢量等信息所占用的比特,头比特的长度与量化参数(Quantization Parameter;以下简称:QP)基本无关;而宏块中的纹理比特指宏块残差所占用的比特,纹理比特的长度与QP密切相关。The input code stream is composed of images frame by frame. Each frame image includes multiple macroblocks. The header bits in the macroblocks represent the bits occupied by information such as macroblock coding mode and motion vector. The length of the header bits is the same as The quantization parameter (Quantization Parameter; hereinafter referred to as: QP) is basically irrelevant; while the texture bits in the macroblock refer to the bits occupied by the macroblock residual, and the length of the texture bits is closely related to the QP.
当ω<α时,可以直接根据解码后的输入码流的宏块信息对该解码后的输入码流进行编码。在编码时,完全复用输入宏块的运动信息,因此输出宏块的头比特数与对应的输入宏块的头比特数非常接近。这时,编码后的输出码流与输入码流的主要差别在于纹理比特数。由于码率转码通常都是码率降低转码,即编码后的输出宏块所采用的QP一般不小于输入宏块的QP,即输出宏块的纹理比特数会小于输入宏块的纹理比特数。当输出宏块的QP略大于输入宏块的QP时,输出宏块的纹理比特数略小于输入宏块的纹理比特数,这时输出码流的码率与输入码流的码率相差不大,因此可以保证输出码流的质量。当输出宏块的QP大于输入宏块的QP较多时,输出宏块的纹理比特数远远小于输入宏块的纹理比特数,这时输出码流的码率与输入码流的码率相差较大,输出码流的质量大大下降。When ω<α, the decoded input code stream can be encoded directly according to the macroblock information of the decoded input code stream. During encoding, the motion information of the input macroblock is fully multiplexed, so the number of header bits of the output macroblock is very close to the number of header bits of the corresponding input macroblock. At this time, the main difference between the coded output code stream and the input code stream lies in the number of texture bits. Since code rate transcoding is usually code rate reduction transcoding, that is, the QP used by the encoded output macroblock is generally not less than the QP of the input macroblock, that is, the number of texture bits of the output macroblock will be less than the texture bits of the input macroblock number. When the QP of the output macroblock is slightly larger than the QP of the input macroblock, the number of texture bits of the output macroblock is slightly smaller than the number of texture bits of the input macroblock, and the code rate of the output code stream is not much different from the code rate of the input code stream , so the quality of the output stream can be guaranteed. When the QP of the output macroblock is larger than the QP of the input macroblock, the number of texture bits of the output macroblock is much smaller than the number of texture bits of the input macroblock, and the code rate of the output code stream is relatively different from that of the input code stream. If it is too large, the quality of the output code stream will be greatly reduced.
为保证编码后的输出码流的视频质量,本实施例在根据解码后的输入码流的宏块信息对解码后的输入码流的每一帧进行编码之后,均计算编码后的输出帧的第一失真度与该输出帧对应的输入帧的第二失真度的比值。具体可以为:In order to ensure the video quality of the coded output code stream, in this embodiment, after each frame of the decoded input code stream is encoded according to the macroblock information of the decoded input code stream, the value of the coded output frame is calculated. A ratio of the first degree of distortion to the second degree of distortion of the input frame corresponding to the output frame. Specifically, it can be:
首先,计算编码后的输出帧中每个宏块的纹理比特数与该宏块的总比特数的第一比值,并计算编码后的输出帧中所有宏块的第一比值的均值,该第一比值的均值即为第一失真度;具体地,以R(Mo)表示该第一比值,First, calculate the first ratio of the number of texture bits of each macroblock in the encoded output frame to the total number of bits of the macroblock, and calculate the average value of the first ratios of all macroblocks in the encoded output frame, the first The mean value of a ratio is the first degree of distortion; specifically, the first ratio is represented by R(M o ),
式(3)中,Tex(Mo)为输出帧中宏块的纹理比特数,Total(Mo)为该宏块的总比特数。计算完输出帧中每个宏块的第一比值之后,计算该输出帧中所有宏块的第一比值的均值,该第一比值的均值即为第一失真度Ro。In formula (3), Tex(M o ) is the number of texture bits of the macroblock in the output frame, and Total(M o ) is the total number of bits of the macroblock. After the first ratio of each macroblock in the output frame is calculated, the average value of the first ratios of all macroblocks in the output frame is calculated, and the average value of the first ratio is the first degree of distortion R o .
然后,计算上述输出帧对应的输入帧中每个宏块的纹理比特数与该宏块的总比特数的第二比值,并计算该输入帧中所有宏块的第二比值的均值,该第二比值的均值为第二失真度;具体地,以R(Mi)表示该第二比值,Then, calculate the second ratio of the number of texture bits of each macroblock in the input frame corresponding to the above output frame to the total number of bits of the macroblock, and calculate the average value of the second ratios of all macroblocks in the input frame, the first The average of the two ratios is the second degree of distortion; specifically, the second ratio is represented by R(M i ),
式(4)中,Tex(Mi)为输入帧中宏块的纹理比特数,Total(Mi)为该宏块的总比特数。计算完输入帧中每个宏块的第二比值之后,计算该输入帧中所有宏块的第二比值的均值,该第二比值的均值即为第二失真度Ri。In formula (4), Tex(M i ) is the number of texture bits of the macroblock in the input frame, and Total(M i ) is the total number of bits of the macroblock. After calculating the second ratio of each macroblock in the input frame, calculate the average value of the second ratios of all macroblocks in the input frame, and the average value of the second ratio is the second distortion degree R i .
最后,计算第一失真度与第二失真度的比值Ro/Ri。Finally, the ratio R o /R i of the first distortion degree to the second distortion degree is calculated.
步骤205,判断该第一失真度与第二失真度的比值是否小于预设的第二门限值。如果该失真度小于预设的第二门限值,则执行步骤207;如果该失真度大于预设的第二门限值,则执行步骤206。
本实施例中,预先设置第二门限值β,这里的β的取值为经验值,可以将β在一定范围内取多个值,通过多次仿真调试后得到最佳的数量,如β可以取0.55或0.65等。在设置第二门限值β后,判断第一失真度与第二失真度的比值Ro/Ri是否小于β。如果Ro/Ri<β,则可以确定输出码流的视频质量下降过多,不能继续根据解码后的输入码流的宏块信息,对解码后的输入码流中后续待编码的码流进行编码,而需要根据解码后的输入码流的宏块信息重新确定宏块编码模式,然后根据重新确定的宏块编码模式对后续待编码的码流进行编码,直至对该解码后的输入码流的编码结束;如果Ro/Ri>β,则可以确定输出码流的视频质量符合预定的转码要求,可以继续根据解码后的输入码流的宏块信息对解码后的输入码流进行编码,此后对每一帧进行编码之后,均计算Ro/Ri,并判断Ro/Ri与β的大小关系,只要Ro/Ri>β,就可以继续根据解码后的输入码流的宏块信息对解码后的输入码流进行编码,而一旦Ro/Ri<β,就需要根据解码后的输入码流的宏块信息重新确定宏块编码模式,然后根据重新确定的宏块编码模式对解码后的输入码流中后续待编码的码流进行编码,直至对该解码后的输入码流的编码结束。In this embodiment, the second threshold value β is set in advance, where the value of β is an empirical value, and β can take multiple values within a certain range, and the optimal number can be obtained after multiple simulations and debugging, such as β Can take 0.55 or 0.65 and so on. After setting the second threshold value β, it is judged whether the ratio R o /R i of the first distortion degree to the second distortion degree is smaller than β. If R o /R i <β, it can be determined that the video quality of the output code stream has dropped too much, and the subsequent code streams to be encoded in the decoded input code stream cannot be further processed according to the macroblock information of the decoded input code stream To encode, it is necessary to re-determine the macroblock coding mode according to the macroblock information of the decoded input code stream, and then encode the subsequent code stream to be coded according to the re-determined macroblock coding mode until the decoded input code The coding of the stream ends; if R o /R i > β, it can be determined that the video quality of the output code stream meets the predetermined transcoding requirements, and the decoded input code stream can be continued according to the macroblock information of the decoded input code stream After encoding, after each frame is encoded, R o /R i is calculated, and the relationship between R o /R i and β is judged. As long as R o /R i > β, you can continue to use the decoded input The macroblock information of the code stream encodes the decoded input code stream, and once R o /R i <β, it is necessary to re-determine the macroblock coding mode according to the macroblock information of the decoded input code stream, and then according to the re-determined The macroblock encoding mode encodes subsequent code streams to be encoded in the decoded input code stream until the encoding of the decoded input code stream ends.
步骤206,根据解码后的输入码流的宏块信息对解码后的输入码流进行编码。
优选地,在根据解码后的输入码流的宏块信息对解码后的输入码流进行编码时,还可以提取该宏块信息中的CBP信息,CBP信息的主要作用是指示宏块残差(亮度和色度)经离散余弦变换(Discrete Cosine Transform;以下简称:DCT)和量化后为零的部分。由于在根据解码后的输入码流的宏块信息进行编码时,完全复用了输入码流的运动信息,故可以近似认为编码后的输出宏块的残差与输入宏块的残差分布类似,此时可以认为输出宏块中为零的部分经编码转码后仍然为零,因此可以对待编码的帧中CBP信息指示为零的宏块直接进行熵编码,从而可以省去对CBP信息指示为零的宏块进行DCT、量化、反量化和离散余弦逆变换(Inverse Discrete Cosine Transform;以下简称:IDCT)的时间。采用这种方式可以提高转码速度,但同时也会降低编码后的输出码流的峰值信噪比(Peak Signal to Noise Ratio;以下简称:PSNR)值。Preferably, when the decoded input code stream is encoded according to the macroblock information of the decoded input code stream, CBP information in the macroblock information can also be extracted, and the main function of the CBP information is to indicate the macroblock residual ( Luminance and chrominance) after discrete cosine transform (Discrete Cosine Transform; hereinafter referred to as: DCT) and quantized part is zero. Since the motion information of the input code stream is completely multiplexed when encoding according to the macroblock information of the decoded input code stream, it can be approximately considered that the residual of the encoded output macroblock is similar to the residual distribution of the input macroblock At this time, it can be considered that the part of the output macroblock that is zero is still zero after encoding and transcoding, so the macroblock whose CBP information is indicated as zero in the frame to be encoded can be directly entropy encoded, so that the CBP information indication can be omitted Time for performing DCT, quantization, inverse quantization, and inverse discrete cosine transform (Inverse Discrete Cosine Transform; hereinafter referred to as: IDCT) for a macroblock that is zero. Using this method can increase the transcoding speed, but at the same time it will also reduce the peak signal-to-noise ratio (Peak Signal to Noise Ratio; hereinafter referred to as: PSNR) value of the encoded output stream.
步骤207,根据解码后的输入码流的宏块信息重新确定宏块编码模式,并根据重新确定的宏块编码模式对后续待编码的码流进行编码。
当ω>α或Ro/Ri<β时,可以确定输出码流的视频质量下降过多,不能继续根据解码后的输入码流的宏块信息,对解码后的输入码流进行编码,而需要根据解码后的输入码流的宏块信息重新确定宏块编码模式,然后根据重新确定的宏块编码模式对解码后的输入码流中后续待编码的码流进行编码,直至对该解码后的输入码流的编码结束。When ω>α or R o /R i <β, it can be determined that the video quality of the output code stream has degraded too much, and the decoded input code stream cannot be encoded according to the macroblock information of the decoded input code stream. However, it is necessary to re-determine the macroblock coding mode according to the macroblock information of the decoded input code stream, and then encode the subsequent code streams in the decoded input code stream according to the re-determined macro block coding mode until the decoding After the encoding of the input code stream ends.
例如,当ω>α或Ro/Ri<β时,可以根据解码后的输入码流的宏块信息确定待编码的宏块的块类型,然后根据不同的块类型选择不同的宏块编码模式等,这里的宏块信息包括:块类型信息、分块模式信息、运动矢量信息、CBP信息、量化参数和宏块残差等编码所需的信息;宏块编码模式包括:块类型信息、分块模式信息和运动矢量信息。For example, when ω>α or R o /R i <β, the block type of the macroblock to be encoded can be determined according to the macroblock information of the decoded input code stream, and then different macroblock coding can be selected according to different block types mode, etc. The macroblock information here includes: block type information, block mode information, motion vector information, CBP information, quantization parameters, and macroblock residuals and other information required for encoding; the macroblock coding mode includes: Block mode information and motion vector information.
对解码后的输入码流中的每一帧执行上述步骤201~步骤207,直至对该解码后的输入码流的编码结束。The above-mentioned
本实施例中,在确定了像素转码率之后,判断该像素转码率是否大于预设的第一门限值之前,即在步骤202和步骤203之间,还可以先根据解码后的输入码流中的宏块信息,确定待编码的宏块是否为Skip块;如果该待编码的宏块为Skip块,则可以跳过该Skip块,直接对该Skip块的下一宏块进行编码,从而可以省略运动估计及后续的编码过程,大幅度提高转码速度。In this embodiment, after the pixel transcoding rate is determined, before judging whether the pixel transcoding rate is greater than the preset first threshold value, that is, between
在H.264预测帧中,使用率失真优化方法来选择宏块的编码模式,即将预测误差和信息编码码率结合起来选择编码模式:In the H.264 predicted frame, the rate-distortion optimization method is used to select the coding mode of the macroblock, that is, the prediction error and the information coding rate are combined to select the coding mode:
Jmode(MBx,y,Ix,y)=DREC(MBx,y,Ix,y)+λRREC(Bx,y,Ix,y) (5)J mode (MB x, y , I x, y ) = D REC (MB x, y , I x, y ) + λR REC (B x, y , I x, y ) (5)
式(5)中,Ix,y表示MBx,y的可选预测模式,包括帧内编码模式和帧间编码模式,Lagrangian参数λ的值为λ=2QP/6-2(QP是量化参数),RREC和DREC分别表示对应预测模式下的编码比特数和由量化造成的解码恢复图像失真。对于帧F中的第m个宏块M(F,m),将经过模式判决和运动估计后得到的最优率失真代价记为RD(M(F,m)),则对于Skip模式,由于熵编码中几乎不占用比特,则其率失真代价函数为:In formula (5), I x, y represent the optional prediction modes of MB x, y , including intra-frame coding mode and inter-frame coding mode, and the value of Lagrangian parameter λ is λ=2 QP/6-2 (QP is quantization parameter), R REC and D REC represent the number of coded bits in the corresponding prediction mode and the distortion of the decoded restored image caused by quantization, respectively. For the mth macroblock M(F, m) in the frame F, the optimal rate-distortion cost obtained after mode decision and motion estimation is denoted as RD(M(F, m)), then for the Skip mode, since Almost no bits are occupied in entropy coding, so its rate-distortion cost function is:
RDSkip(M(F,m))=DREC(M(F,m),Skip) (6)RD Skip (M(F, m)) = D REC (M(F, m), Skip) (6)
记解码侧当前帧为FDC,解码侧当前帧对应的参考帧为FDR,编码侧当前帧为FEC,编码侧当前帧对应的参考帧为FER。如果式(7)成立,则待编码宏块可以编码为Skip块,其中ρ的取值为一经验值,可以将ρ在一定范围内取多个值,通过多次仿真调试后得到最佳的数量,如ρ可以取0.55或0.5等。Note that the current frame on the decoding side is F DC , the reference frame corresponding to the current frame on the decoding side is F DR , the current frame on the encoding side is F EC , and the reference frame corresponding to the current frame on the encoding side is F ER . If formula (7) holds true, then the macroblock to be coded can be coded as a Skip block, where the value of ρ is an empirical value, and ρ can take multiple values within a certain range, and the best value can be obtained after multiple simulations and debugging. Quantity, such as ρ can take 0.55 or 0.5 and so on.
利用该方法对输入码流的宏块编码模式进行预判,若待编码宏块为Skip块,则不再对该待编码宏块进行运动估计和后续的编码过程,从而提高了转码速度。The method is used to predict the encoding mode of the macroblock of the input code stream. If the macroblock to be encoded is a Skip block, motion estimation and subsequent encoding process will not be performed on the macroblock to be encoded, thereby increasing the transcoding speed.
本发明实施例根据像素转码率和输入码流的宏块信息实时确定宏块编码模式,然后再根据确定的宏块编码模式进行编码,从而在确保恢复的视频质量的前提下,提高了转码速度,更好地满足了实时视频转码的要求,同时,本发明实施例还对输入码流的宏块编码模式进行预判,若待编码宏块为Skip块,则不再对该待编码宏块进行运动估计和后续的编码过程,从而更进一步提高了转码速度。In the embodiment of the present invention, the macroblock encoding mode is determined in real time according to the pixel transcoding rate and the macroblock information of the input code stream, and then encoding is performed according to the determined macroblock encoding mode, thereby improving the conversion rate while ensuring the restored video quality. The code speed better meets the requirements of real-time video transcoding. At the same time, the embodiment of the present invention also predicts the encoding mode of the macroblock of the input code stream. If the macroblock to be encoded is a Skip block, the awaiting Coded macroblocks are used for motion estimation and subsequent encoding process, thus further improving the transcoding speed.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps for realizing the above-mentioned method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the It includes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other various media that can store program codes.
图3为本发明视频转码装置一个实施例的结构示意图,本实施例的视频转码装置可以为一通信设备,或者位于通信设备中,该通信设备可以为网关、媒体服务器或数字电视等。如图3所示,该视频转码装置可以包括:解码模块31、提取模块32、像素转码率确定模块33、编码模块34和编码模式确定模块35。FIG. 3 is a schematic structural diagram of an embodiment of a video transcoding device of the present invention. The video transcoding device of this embodiment may be a communication device, or be located in a communication device, and the communication device may be a gateway, a media server, or a digital TV. As shown in FIG. 3 , the video transcoding device may include: a
其中,解码模块31用于对输入码流进行解码;Wherein, the
提取模块32可以提取解码模块31解码后的输入码流的宏块信息;The extracting
像素转码率确定模块33可以根据输入码流确定像素转码率;The pixel transcoding
编码模块34可以在像素转码率确定模块33确定的像素转码率小于预设的第一门限值时,根据提取模块32提取的宏块信息对解码模块31解码后的输入码流进行编码;当像素转码率小于预设的第一门限值时,解码后的输入码流与预期的输出码流之间具有较强的相似性,因此不需要对输入码流进行较大的调整,编码模块34可以根据解码后的输入码流的宏块信息对解码后的输入码流进行编码;The
编码模式确定模块35可以在像素转码率确定模块33确定的像素转码率大于第一门限值时,根据提取模块32提取的宏块信息重新确定宏块编码模式;这时,编码模块34还可以根据编码模式确定模块35重新确定的宏块编码模式对解码模块31解码后的输入码流进行编码;具体地,当像素转码率大于该第一门限值时,解码后的输入码流与预期的输出码流之间的差异性较大,因此根据解码后的输入码流的宏块信息对解码后的输入码流进行编码无法保证转码后的输出码流的视频质量。这种情况下,需要由编码模式确定模块35根据输入码流中的宏块信息重新确定宏块编码模式,编码模块34再根据重新确定的宏块编码模式对解码后的输入码流进行编码。The encoding
本实施例中的宏块信息包括:块类型信息、分块模式信息、运动矢量信息、CBP信息、量化参数和宏块残差等编码所需的信息;宏块编码模式包括:块类型信息、分块模式信息和运动矢量信息。The macroblock information in this embodiment includes: information required for encoding such as block type information, block mode information, motion vector information, CBP information, quantization parameters, and macroblock residuals; the macroblock coding mode includes: block type information, Block mode information and motion vector information.
本实施例中,编码模块34可以在像素转码率确定模块33确定的像素转码率小于预设的第一门限值时,根据提取模块32提取的宏块信息对解码模块31解码后的输入码流进行编码;当像素转码率确定模块33确定的像素转码率大于预设的第一门限值时,编码模式确定模块35根据像素转码率和解码后的输入码流的宏块信息实时确定宏块编码模式,然后编码模块34根据编码模式确定模块35确定的宏块编码模式进行编码,从而在确保恢复的视频质量的前提下,提高了转码速度,更好地满足了实时视频转码的要求。In this embodiment, when the pixel transcoding rate determined by the pixel transcoding
图4为本发明视频转码装置另一个实施例的结构示意图,本实施例的视频转码装置可以为一通信设备,或者位于通信设备中,该通信设备可以为网关、媒体服务器或数字电视等。如图4所示,该视频转码装置包括:解码模块41、提取模块42、像素转码率确定模块43、编码模块44、编码模式确定模块45和Skip块确定模块46。Fig. 4 is a schematic structural diagram of another embodiment of the video transcoding device of the present invention. The video transcoding device of this embodiment may be a communication device, or be located in a communication device, and the communication device may be a gateway, a media server or a digital TV, etc. . As shown in FIG. 4 , the video transcoding device includes: a
其中,解码模块41用于对输入码流进行解码;Wherein, the
提取模块42可以提取解码模块41解码后的输入码流的宏块信息;The
像素转码率确定模块43可以根据输入码流确定像素转码率;像素转码率确定模块43具体可以根据输入码流中平均每像素占用的比特数和预设的输出码流中平均每像素占用的比特数,确定像素转码率;具体地,码流中平均每像素占用的比特数为bpp,bpp可以通过式(1)计算,解码模块41对输入码流进行解码之后,可以获得输入码流的码率和帧率,以及解码后的输入码流中图像的宽度和高度,根据这些参数即可计算得到解码后的输入码流中平均每像素占用的比特数;以上只是获得输入码流的码率和帧率,以及输入码流中图像的宽度和高度,进而获得输入码流中平均每像素占用的比特数的一种方式,本发明实施例并不局限于此,输入码流的码率和帧率,以及输入码流中图像的宽度和高度并不一定在解码后才能得到,上述参数也可以通过其他方式获得,例如:预先输入上述参数。本发明实施例对获得输入码流的码率和帧率,以及输入码流中图像的宽度和高度的方式不作限定。The pixel transcoding
另外,可以根据转码要求预先设置输出码流的码率和帧率,以及输出码流中图像的宽度和高度,根据这些参数即可计算得到预设的输出码流中平均每像素占用的比特数。In addition, the code rate and frame rate of the output code stream can be preset according to the transcoding requirements, as well as the width and height of the image in the output code stream. According to these parameters, the average bit occupied by each pixel in the preset output code stream can be calculated. number.
编码模块44可以在像素转码率确定模块43确定的像素转码率小于预设的第一门限值时,根据提取模块42提取的宏块信息对解码模块41解码后的输入码流进行编码;当像素转码率小于预设的第一门限值时,解码后的输入码流与预期的输出码流之间具有较强的相似性,因此不需要对输入码流进行较大的调整,编码模块44可以根据解码后的输入码流的宏块信息对解码后的输入码流进行编码;The
编码模式确定模块45可以在像素转码率确定模块43确定的像素转码率大于第一门限值时,根据提取模块42提取的宏块信息重新确定宏块编码模式;这时,编码模块44还可以根据编码模式确定模块45重新确定的宏块编码模式对解码模块41解码后的输入码流进行编码;具体地,当像素转码率大于该第一门限值时,解码后的输入码流与预期的输出码流之间的差异性较大,因此根据解码后的输入码流的宏块信息对解码后的输入码流进行编码无法保证转码后的输出码流的视频质量。这种情况下,需要由编码模式确定模块45根据输入码流中的宏块信息重新确定宏块编码模式,编码模块44再根据重新确定的宏块编码模式对解码后的输入码流进行编码。The encoding
其中,编码模块44可以包括失真度计算子模块441、第一编码子模块442和第二编码子模块443。Wherein, the
失真度计算子模块441用于在根据提取模块42提取的宏块信息对解码模块41解码后的输入码流的每一帧进行编码之后,计算编码后的输出帧的第一失真度,以及该输出帧对应的输入帧的第二失真度,并计算第一失真度与第二失真度的比值;具体地,失真度计算子模块441可以计算编码后的输出帧中每个宏块的纹理比特数与该宏块的总比特数的第一比值,并计算编码后的输出帧中所有宏块的第一比值的均值,该第一比值的均值即为第一失真度;失真度计算子模块441还可以计算输出帧对应的输入帧中每个宏块的纹理比特数与该宏块的总比特数的第二比值,并计算输入帧中所有宏块的第二比值的均值,第二比值的均值为第二失真度。The
第一编码子模块442可以当失真度计算子模块441计算的比值大于预设的第二门限值时,根据提取模块42提取的宏块信息对解码模块41解码后的输入码流进行编码;编码模式确定模块45还用于当失真度计算子模块441计算的比值小于上述第二门限值时,根据提取模块42提取的宏块信息重新确定宏块编码模式;这时第二编码子模块443可以根据编码模式确定模块45重新确定的宏块编码模式对解码后的输入码流中后续待编码的码流进行编码,直至对该解码后的输入码流的编码结束。The
具体地,当失真度计算子模块441计算的比值小于预设的第二门限值时,则可以确定输出码流的视频质量下降过多,不能继续根据提取模块42提取的宏块信息对解码后的输入码流进行编码,而需要编码模式确定模块45根据提取模块42提取的宏块信息重新确定宏块编码模式,然后第二编码子模块443根据重新确定的宏块编码模式对解码后的输入码流中后续待编码的码流进行编码,直至对该解码后的输入码流的编码结束;当失真度计算子模块441计算的比值大于预设的第二门限值时,可以确定输出码流的视频质量符合预定的转码要求,因此第一编码子模块442可以继续根据提取模块42提取的宏块信息对解码模块41解码后的输入码流进行编码,此后对每一帧进行编码之后,失真度计算子模块441均要计算第一失真度与所述第二失真度的比值,只要失真度计算子模块441计算的比值大于预设的第二门限值,第一编码子模块442就可以继续根据提取模块42提取的宏块信息对解码后的输入码流进行编码,而一旦失真度计算子模块441计算的比值小于预设的第二门限值,就需要编码模式确定模块45根据提取模块42提取的宏块信息重新确定宏块编码模式,然后由第二编码子模块443根据编码模式确定模块45重新确定的宏块编码模式对解码后的输入码流中后续待编码的码流进行编码,直至对该解码后的输入码流的编码结束。Specifically, when the ratio calculated by the distortion
本实施例中,提取模块42可以提取宏块信息中的块编码类型CBP信息;第一编码子模块442具体用于对该CBP信息指示为零的宏块直接进行熵编码。In this embodiment, the extracting
本实施例中,在像素转码率确定模块43确定了像素转码率之后,Skip块确定模块46可以先根据提取模块42提取的宏块信息,确定待编码的宏块是否为Skip块;这时,编码模块44可以在Skip块确定模块46确定待编码的宏块为Skip块时,不再对该待编码宏块进行运动估计和后续的编码过程,直接对该Skip块的下一宏块进行编码,从而大大的提高了转码速度。In this embodiment, after the pixel transcoding
具体地,Skip块确定模块46确定待编码的宏块为Skip块的步骤包括:Specifically, the Skip
当帧F中的第m个宏块为M(F,m),经过模式判决和运动估计后得到的最优率失真代价为RD(M(F,m)),解码侧当前帧为FDC,解码侧当前帧对应的参考帧为FDR,编码侧当前帧为FEC,编码侧当前帧对应的参考帧为FER,待编码的宏块的RDSkip(M(FEC,m))满足When the mth macroblock in frame F is M(F, m), the optimal rate-distortion cost obtained after mode decision and motion estimation is RD(M(F, m)), and the current frame on the decoding side is F DC , the reference frame corresponding to the current frame on the decoding side is F DR , the current frame on the encoding side is F EC , the reference frame corresponding to the current frame on the encoding side is F ER , the RD Skip (M(F EC , m)) of the macroblock to be encoded satisfy
Skip块确定模块46确定待编码的宏块为Skip块;其中,ρ为大于0的正数,RDSkip(M(FEC,m))为待编码的宏块的最优率失真代价,The Skip
RDSkip(M(FEC,m))=DREC(M(FEC,m),Skip)。RD Skip (M(F EC ,m))=D REC (M(F EC ,m),Skip).
需要说明的是,上述各模块可以通过处理器或其他硬件实现,例如,可以通过个人电脑(Personal Computer;以下简称:PC)机的中央处理单元(Central Processing Unit;以下简称:CPU)、或数字信号处理器(Digital Signal Processor;以下简称:DSP)、或现场可编程门阵列(Field Programmable Gate Array;以下简称:FPGA),或专用的转码处理器或其他硬件实现。It should be noted that the above-mentioned modules can be implemented by a processor or other hardware, for example, by a central processing unit (Central Processing Unit; hereinafter referred to as: CPU) of a personal computer (Personal Computer; hereinafter referred to as: PC), or a digital Signal processor (Digital Signal Processor; hereinafter referred to as: DSP), or Field Programmable Gate Array (Field Programmable Gate Array; hereinafter referred to as: FPGA), or a dedicated transcoding processor or other hardware implementation.
本发明实施例根据像素转码率和输入码流的宏块信息实时确定宏块编码模式,然后再根据确定的宏块编码模式进行编码,从而在确保恢复的视频质量的前提下,提高了转码速度,更好地满足了实时视频转码的要求。同时,本发明实施例还对输入码流的宏块编码模式进行预判,若待编码宏块为Skip块,则不再对该待编码宏块进行运动估计和后续的编码过程,从而更进一步提高了转码速度。In the embodiment of the present invention, the macroblock encoding mode is determined in real time according to the pixel transcoding rate and the macroblock information of the input code stream, and then encoding is performed according to the determined macroblock encoding mode, thereby improving the conversion rate while ensuring the restored video quality. The coding speed better meets the requirements of real-time video transcoding. At the same time, the embodiment of the present invention also predicts the encoding mode of the macroblock of the input code stream. If the macroblock to be encoded is a Skip block, the motion estimation and subsequent encoding process of the macroblock to be encoded will no longer be performed, thereby further Improved transcoding speed.
本发明实施例提供一种视频转码方法和装置,通过本发明实施例提供的方法和装置,可以大大提高转码速度。本发明实施例使用四分之一公用中分辨率图像格式(Quarter Common Intermediate Format;以下简称:QCIF)和公用中分辨率图像格式(Common Intermediate Format;以下简称:CIF)的两个标准测试序列:“Carphone.qcif”和“Foreman.cif”,各取300帧,分别采用全搜索算法的全解全编的级联转码器和本发明实施例提出的视频转码装置进行码率转码。Embodiments of the present invention provide a video transcoding method and device, and the transcoding speed can be greatly improved through the method and device provided by the embodiments of the present invention. The embodiment of the present invention uses two standard test sequences of quarter common intermediate resolution image format (Quarter Common Intermediate Format; hereinafter referred to as: QCIF) and common intermediate resolution image format (Common Intermediate Format; hereinafter referred to as: CIF): "Carphone.qcif" and "Foreman.cif" each take 300 frames, respectively use the cascaded transcoder with full search algorithm, full solution and full encoding, and the video transcoding device proposed by the embodiment of the present invention to perform code rate transcoding.
实验中对于QCIF格式序列,首先生成码率为768kbps、帧率为25帧/秒的测试码流,然后分别通过级联转码器和本发明实施例的视频转码装置生成起始目标码率为64kbps,每次递增64kbps直至768kbps的输出码流,输出码流的帧率为默认的25帧/秒,记录相应的级联转码器和本发明实施例的视频转码装置的转码结果。而对于CIF格式序列,首先生成码率为2024kbps、帧率为25帧/秒的测试码流,然后分别通过级联转码器和本发明实施例的视频转码装置生成起始目标码率为64kbps,每次递增64kbps直至1984kbps的输出码流,记录相应的级联转码器和本发明实施例的视频转码装置的转码结果。实验中取α=5,β=0.55,ρ=0.55。For the QCIF format sequence in the experiment, first generate a test code stream with a code rate of 768kbps and a frame rate of 25 frames per second, and then generate an initial target code rate through the cascaded transcoder and the video transcoding device of the embodiment of the present invention respectively It is 64kbps, and each increment increases by 64kbps until the output code stream of 768kbps. The frame rate of the output code stream is 25 frames per second by default. Record the transcoding results of the corresponding cascaded transcoder and the video transcoding device of the embodiment of the present invention . For the CIF format sequence, first generate a test code stream with a code rate of 2024kbps and a frame rate of 25 frames per second, and then generate the initial target code rate through the cascade transcoder and the video transcoding device of the embodiment of the present invention respectively 64kbps, increasing by 64kbps each time until the output code stream of 1984kbps, recording the transcoding results of the corresponding cascaded transcoders and the video transcoding device of the embodiment of the present invention. In the experiment, α = 5, β = 0.55, and ρ = 0.55.
图5为本发明Carphone.qcif序列的PSNR性能对比示意图;图6为本发明Carphone.qcif序列的转码速度对比示意图;图7为本发明Foreman.cif序列的PSNR性能对比示意图;图8为本发明Foreman.cif序列的转码速度对比示意图。在图5~图8中,-◆-表示全搜索算法的全解全编的级联转码器得到的转码结果,-■-表示本发明实施例的视频转码装置的转码结果。Fig. 5 is the comparative schematic diagram of the PSNR performance of the Carphone.qcif sequence of the present invention; Fig. 6 is the comparative schematic diagram of the transcoding speed of the Carphone.qcif sequence of the present invention; Fig. 7 is the comparative schematic diagram of the PSNR performance of the Foreman.cif sequence of the present invention; Fig. 8 is this Schematic diagram of the transcoding speed comparison of the invented Foreman.cif sequence. In FIGS. 5 to 8 , -◆- represents the transcoding result obtained by the cascaded transcoder of full-decoding and full-coding of the full search algorithm, and -■- represents the transcoding result of the video transcoding device according to the embodiment of the present invention.
图5~图8分别给出了“Carphone.qcif”和“Foreman.cif”序列分别采用本发明实施例的视频转码装置和级联转码器进行转码的性能比较结果。由图5和图7可以看出,本发明实施例的视频转码装置的PSNR性能与级联转码器的PSNR性能相比,低目标码率时PSNR差值在1dB左右,高目标码率时PSNR差值在0.5dB以内;由图6和图8可以看出,本发明实施例的视频转码装置与级联转码器相比,转码速度提高在45%左右,最高可至60%。因此,综合权衡考虑转码后恢复视频质量和转码运算速度后,本发明实施例提出的视频转码方法和装置是一种较优的视频码率转码方案,可用于实际视频通信系统。Figures 5 to 8 respectively show the performance comparison results of the "Carphone.qcif" and "Foreman.cif" sequences being transcoded by the video transcoding device and the cascaded transcoder according to the embodiment of the present invention. It can be seen from Fig. 5 and Fig. 7 that, compared with the PSNR performance of the cascaded transcoder, the PSNR performance of the video transcoding device according to the embodiment of the present invention is about 1dB when the target bit rate is low, and the PSNR difference is about 1dB when the target bit rate is high. When the PSNR difference is within 0.5dB; it can be seen from Figure 6 and Figure 8 that compared with the cascaded transcoder, the video transcoding device of the embodiment of the present invention can increase the transcoding speed by about 45%, up to 60 %. Therefore, the video transcoding method and device proposed in the embodiment of the present invention is a better video bit rate transcoding solution, which can be used in actual video communication systems after comprehensively considering the restoration of video quality after transcoding and the speed of transcoding operations.
本领域技术人员可以理解附图只是一个优选实施例的示意图,附图中的模块或流程并不一定是实施本发明所必须的。Those skilled in the art can understand that the drawing is only a schematic diagram of a preferred embodiment, and the modules or processes in the drawing are not necessarily necessary for implementing the present invention.
本领域技术人员可以理解实施例中的装置中的模块可以按照实施例描述进行分布于实施例的装置中,也可以进行相应变化位于不同于本实施例的一个或多个装置中。上述实施例的模块可以合并为一个模块,也可以进一步拆分成多个子模块。Those skilled in the art can understand that the modules in the device in the embodiment can be distributed in the device in the embodiment according to the description in the embodiment, or can be located in one or more devices different from the embodiment according to corresponding changes. The modules in the above embodiments can be combined into one module, and can also be further split into multiple sub-modules.
最后应说明的是:以上实施例仅用以说明本发明的技术方案而非对其进行限制,尽管参照较佳实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对本发明的技术方案进行修改或者等同替换,而这些修改或者等同替换亦不能使修改后的技术方案脱离本发明技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that: it still Modifications or equivalent replacements can be made to the technical solutions of the present invention, and these modifications or equivalent replacements cannot make the modified technical solutions deviate from the spirit and scope of the technical solutions of the present invention.
Claims (15)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN 200910165221 CN101998117B (en) | 2009-08-13 | 2009-08-13 | Video transcoding method and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN 200910165221 CN101998117B (en) | 2009-08-13 | 2009-08-13 | Video transcoding method and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN101998117A true CN101998117A (en) | 2011-03-30 |
| CN101998117B CN101998117B (en) | 2013-01-30 |
Family
ID=43787594
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN 200910165221 Expired - Fee Related CN101998117B (en) | 2009-08-13 | 2009-08-13 | Video transcoding method and device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN101998117B (en) |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103220550A (en) * | 2012-01-19 | 2013-07-24 | 华为技术有限公司 | Method and device for video conversion |
| CN104994407A (en) * | 2015-06-26 | 2015-10-21 | 安徽广行通信科技股份有限公司 | Concentrated self-adaptive video transcoding method |
| CN105187835A (en) * | 2014-05-30 | 2015-12-23 | 阿里巴巴集团控股有限公司 | Adaptive video transcode method and device based on contents |
| CN105898315A (en) * | 2015-12-07 | 2016-08-24 | 乐视云计算有限公司 | Video transcoding method and device and system |
| CN112738519A (en) * | 2020-12-16 | 2021-04-30 | 西安万像电子科技有限公司 | An image coding method, device, electronic device and storage medium |
| CN113038277A (en) * | 2021-03-15 | 2021-06-25 | 北京汇钧科技有限公司 | Video processing method and device |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN100558169C (en) * | 2007-03-23 | 2009-11-04 | 武汉大学 | Quick selection method of inter-frame mode in video transcoding |
| CN101039418A (en) * | 2007-04-26 | 2007-09-19 | 武汉大学 | Method for selecting quickly inter-frame mode during video transcoding |
-
2009
- 2009-08-13 CN CN 200910165221 patent/CN101998117B/en not_active Expired - Fee Related
Cited By (11)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103220550A (en) * | 2012-01-19 | 2013-07-24 | 华为技术有限公司 | Method and device for video conversion |
| CN103220550B (en) * | 2012-01-19 | 2016-12-07 | 华为技术有限公司 | The method and device of video conversion |
| US9872021B2 (en) | 2012-01-19 | 2018-01-16 | Huawei Technologies Co., Ltd. | Video conversion method and apparatus |
| CN105187835A (en) * | 2014-05-30 | 2015-12-23 | 阿里巴巴集团控股有限公司 | Adaptive video transcode method and device based on contents |
| CN105187835B (en) * | 2014-05-30 | 2019-02-15 | 阿里巴巴集团控股有限公司 | Adaptive video code-transferring method and device based on content |
| US10645449B2 (en) | 2014-05-30 | 2020-05-05 | Alibaba Group Holding Limited | Method and apparatus of content-based self-adaptive video transcoding |
| CN104994407A (en) * | 2015-06-26 | 2015-10-21 | 安徽广行通信科技股份有限公司 | Concentrated self-adaptive video transcoding method |
| CN105898315A (en) * | 2015-12-07 | 2016-08-24 | 乐视云计算有限公司 | Video transcoding method and device and system |
| CN112738519A (en) * | 2020-12-16 | 2021-04-30 | 西安万像电子科技有限公司 | An image coding method, device, electronic device and storage medium |
| CN112738519B (en) * | 2020-12-16 | 2025-02-14 | 西安万像电子科技有限公司 | Image encoding method, device, electronic device and storage medium |
| CN113038277A (en) * | 2021-03-15 | 2021-06-25 | 北京汇钧科技有限公司 | Video processing method and device |
Also Published As
| Publication number | Publication date |
|---|---|
| CN101998117B (en) | 2013-01-30 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8300696B2 (en) | Transcoding for systems operating under plural video coding specifications | |
| US7058127B2 (en) | Method and system for video transcoding | |
| CN100399829C (en) | Video transcoding method and device and motion vector interpolation method | |
| US9503725B2 (en) | Method and apparatus for encoding/decoding image for performing intraprediction using pixel value filtered according to prediction mode | |
| KR101608426B1 (en) | Method for predictive intra coding/decoding for video and apparatus for same | |
| CN113497937B (en) | Image coding method, image decoding method and related device | |
| JP5166339B2 (en) | Method and apparatus for encoding and / or decoding intra prediction mode information of image | |
| CN101584218B (en) | Encoding and decoding method and device based on intra-frame prediction | |
| CN107409219B (en) | Method, apparatus, apparatus, and computer-readable storage medium for decoding video information | |
| CN113747176A (en) | Image encoding method, image decoding method and related device | |
| EP2088782B1 (en) | A method and a device for transcoding video | |
| JP2006524000A (en) | Video transcoding | |
| CN105681797B (en) | A kind of DVC-HEVC video transcoding methods based on prediction residual | |
| CN101909211B (en) | H.264/AVC high-efficiency transcoder based on fast mode decision | |
| CN101998117B (en) | Video transcoding method and device | |
| EP1662799A2 (en) | Video down-sampling transcoding method and device | |
| CN101888550A (en) | Quantization parameter encoding method and device in slice header information | |
| JP2010526515A (en) | Video coding mode selection using estimated coding cost | |
| KR100713400B1 (en) | H.263 / MFP Video Encoder Using Average Histogram Error Method and Its Control Method | |
| CN110710204A (en) | Method and apparatus for encoding and decoding a data stream representing at least one image | |
| CN109495745B (en) | A Lossless Compression and Decoding Method Based on Inverse Quantization/Inverse Transform | |
| CN101674480B (en) | Method and device for selecting encoding modes | |
| KR20110024574A (en) | Integrated video encoding method and apparatus | |
| CN117478881A (en) | Video information processing methods, systems, equipment and storage media | |
| Usman et al. | Exploiting the spatio-temporal attributes of HD videos: A bandwidth efficient approach |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| C14 | Grant of patent or utility model | ||
| GR01 | Patent grant | ||
| CF01 | Termination of patent right due to non-payment of annual fee | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20130130 Termination date: 20180813 |
