Mode decision method for transcoding B frame from H264 to HEVC and storage medium

By analyzing the motion vector difference and quantization parameters during the H264 stream decoding process, the segmentation and decision-making of HEVC coding units are optimized, solving the problem of low transcoding compression ratio in existing technologies and achieving higher compression ratio and computational efficiency.

CN121728074APending Publication Date: 2026-03-24CHINA TELECOM DIGITAL INTELLIGENCE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-20
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

Existing mode decision methods for transcoding B-frames from H.264 to HEVC fail to adequately consider the impact of motion vector prediction accuracy and bit rate distortion, resulting in a lower-than-expected compression ratio after transcoding.

Method used

By analyzing the motion vector difference and quantization parameter information of the decoding unit region during H264 stream decoding, the accuracy of motion vector multiplexing of the current coding unit is predicted. In the HEVC encoding process, coding unit segmentation and decision-making are performed to improve the accuracy of mode decision and compression ratio.

Benefits of technology

While saving transcoding computation, it improves the accuracy of mode decision-making and compression ratio, and outputs higher quality HEVC video streams.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121728074A_ABST
    Figure CN121728074A_ABST
Patent Text Reader

Abstract

The invention discloses a mode decision method for transcoding a B frame from H264 to HEVC and a storage medium, and the method comprises the steps: decoding each decoding block of the B frame through employing an H264 decoder, and obtaining decoding block information; in an HEVC encoder, when each maximum encoding unit is used for encoding, the maximum encoding unit is quartered, decoding block information in the current encoding unit is read, and if the decoding block information of each decoding block in the current encoding unit meets a rapid decision condition, the current encoding unit is used as a whole for encoding; otherwise, if the decoding block information of each decoding block in the current coding unit meets the continuous segmentation condition, quartering the current coding unit; otherwise, calculating the coding residual error of the current coding unit, and if the coding residual error of the current coding unit is smaller than the residual error threshold value, performing coding by taking the current coding unit as a whole; otherwise, executing the operation of quartering the current coding unit. According to the invention, the accuracy and the compression ratio of mode decision are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of audio and video encoding and decoding technology, specifically to a mode decision method and storage medium for transcoding B-frames from H.264 to HEVC. Background Technology

[0002] B-frames are encoded frames that use forward and backward inter-frame references during audio and video encoding and decoding. They are bidirectional prediction frames, and while their compression rate is higher than that of P-frames, they also have higher computational complexity. Without an optimized transcoding scheme, they will consume a lot of computation.

[0003] Existing mode decision-making methods for transcoding B-frames from H.264 to HEVC typically first decode the H.264 video stream and record each... The motion vectors of the block are used, and then this information is directly reused during HEVC encoding. The motion vectors at the time of decoding are used as the optimal motion vectors for mode decision-making, thus saving computational complexity in motion estimation and mode decision-making. However, this mode decision-making method does not fully consider the prediction accuracy of the motion vectors reused in this region and the impact of the coding unit on the bit rate distortion, which can easily lead to a decrease in the accuracy of transcoding mode decision-making and a lower-than-expected compression ratio after transcoding. Summary of the Invention

[0004] To address the problems existing in the prior art, this invention provides a mode decision method and storage medium for transcoding H.264 to HEVC B-frames. By analyzing the motion vector difference and quantization parameter information of the decoding unit region during the H.264 stream decoding process, the accuracy of the motion vector multiplexed by the current coding unit and its impact on bit rate distortion are predicted, thereby more accurately segmenting the coding unit and achieving a better compression ratio for the transcoded HEVC stream while saving a significant amount of transcoding computation.

[0005] To achieve the above technical objectives, the present invention adopts the following technical solution: A mode decision method for transcoding B-frames from H.264 to HEVC includes the following steps: Step S1: Use the H.264 decoder to decode each decoding block of the B frame to obtain the decoding block information; Step S2: In the HEVC encoder, when each maximum coding unit is encoded, the maximum coding unit is divided into four equal parts; Step S3: Read the decoding block information within the current coding unit. If the decoding block information of each decoding block within the current coding unit satisfies the fast decision condition, encode the current coding unit as a whole; otherwise, proceed to step S4. Step S4: If the decoding block information of each decoding block in the current coding unit meets the conditions for continued segmentation, divide the current coding unit into four equal parts; otherwise, proceed to step S6. Step S5: Repeat steps S3-S6 until the size of the segmented encoding unit reaches the preset size, and encode the encoding unit of the preset size as a whole; Step S6: Calculate the coding residual of the current coding unit. If the coding residual of the current coding unit is less than the residual threshold, encode the current coding unit as a whole; otherwise, divide the current coding unit into four equal parts and repeat steps S3-S6. Further, the decoded block information includes: the prediction mode, quantization parameters, forward motion vector, forward motion vector difference, backward motion vector, and backward motion vector difference of the decoded block.

[0006] Furthermore, the prediction modes of the decoded block include: forward prediction mode, backward prediction mode, bidirectional prediction mode, and intra-frame prediction mode.

[0007] Furthermore, satisfying the fast decision condition in step S3 means that the prediction mode, forward motion vector, and backward motion vector of each decoding block within the current coding unit are exactly the same.

[0008] Further, in step S4, satisfying the condition for continued segmentation means: if each of the four equal regions of the current coding unit has an intra-frame prediction mode during decoding, the current coding unit is divided into four equal regions; otherwise, it is determined how many sets of inconsistent forward motion vectors and backward motion vectors exist in the four equal regions of the current coding unit. If more than one set is inconsistent, the current coding unit is divided into four equal regions; otherwise, it is determined whether the quantization parameter during decoding in the four equal regions where the forward motion vectors and backward motion vectors are inconsistent is less than the average quantization parameter of the entire frame. If so, the current coding unit is divided into four equal regions.

[0009] Further, step S6 calculates the coding residual of the current coding unit by taking the residual of the four equally divided regions in the current coding unit where the forward motion vector and the backward motion vector are inconsistent and the quantization parameter during decoding is not less than the average quantization parameter of the whole frame as the coding residual of the current coding unit.

[0010] Furthermore, when the prediction mode of the four-part region used for residual calculation is a bidirectional prediction mode, it is determined whether the mean of the absolute values ​​of the forward motion vector difference and the backward motion vector difference in the four-part region exceeds the first pixel threshold. If so, the current coding unit is divided into four parts, and steps S3-S6 are repeated; otherwise, the first decoding residual is calculated based on the forward motion vector difference and the backward motion vector difference in the four-part region, and the first residual threshold is set based on the first decoding residual. If the coding residual of the current coding unit is less than the first residual threshold, the current coding unit is encoded as a whole.

[0011] Furthermore, when the prediction mode of the four-part region used for residual calculation is the forward prediction mode or the backward prediction mode, it is determined whether the absolute value of the forward motion vector difference or the absolute value of the backward motion vector difference in the four-part region exceeds the second pixel threshold. If so, the current coding unit is divided into four parts, and steps S3-S6 are repeated; otherwise, the second decoding residual is calculated based on the forward motion vector difference or the backward motion vector difference in the four-part region, and the second residual threshold is set based on the second decoding residual. If the coding residual of the current coding unit is less than the second residual threshold, the current coding unit is encoded as a whole.

[0012] Furthermore, the specific process of encoding with a pre-defined size coding unit as a whole is as follows: if the coding unit under the pre-defined size meets the fast decision-making condition, the coding unit under the pre-defined size is directly encoded as a whole; otherwise, the prediction mode of the prediction unit in the coding unit under the pre-defined size is set to... Furthermore, each prediction unit uses the motion vector decoded at the same position as the optimal motion vector, where, Indicates the size of the prediction model.

[0013] Furthermore, the present invention also provides a computer-readable storage medium storing a computer program that causes a computer to execute the mode decision method for transcoding B frames from H.264 to HEVC.

[0014] Compared with the prior art, the present invention has the following beneficial effects: (1) The mode decision method of H264 to HEVC transcoding B frame of the present invention, while using decoding to obtain the forward motion vector and backward motion vector of the decoded block, analyzes the motion vector difference and prediction mode of the decoded block information obtained in the decoding process, predicts the accuracy of the current region multiplexing motion vector and the impact on bit rate distortion, thereby more accurately adjusting the size of the coding unit and making better mode decision selection; (2) The mode decision method for transcoding B frames from H264 to HEVC in this invention introduces a quantization parameter analysis process based on the decoding block. The quantization parameters of the transcoding region are used to determine the influence of the region on the distortion rate, thereby making a more accurate decision on the size of the HEVC coding unit.

[0015] In summary, the mode decision method for transcoding B-frames from H.264 to HEVC in this invention can improve the accuracy of mode decision and compression ratio. Attached Figure Description

[0016] Figure 1 This is a flowchart of the mode decision method for transcoding B frames from H.264 to HEVC according to the present invention; Figure 2This is a schematic diagram of the decoding block information in this invention. Detailed Implementation

[0017] The technical solution of the present invention will be further explained and described below with reference to the accompanying drawings.

[0018] like Figure 1 This is a flowchart of the mode decision method for transcoding B-frames from H.264 to HEVC according to the present invention. The mode decision method includes the following steps: Step S1: Using the H.264 decoder, each B-frame... The decoded block is decoded to obtain the decoded block information; such as Figure 2 The decoding block information includes: the prediction mode, quantization parameters, forward motion vector, forward motion vector difference, backward motion vector, and backward motion vector difference. Larger quantization parameters correspond to larger quantization step sizes, which can easily lead to greater distortion. The forward and backward motion vectors can be obtained using forward and backward prediction, respectively. Larger forward and backward motion vector differences indicate that the optimal inter-frame position of the current region is farther from the predicted position. The prediction modes of the decoding block include: forward prediction mode, backward prediction mode, bidirectional prediction mode, and intra-frame prediction mode.

[0019] Step S2: In the HEVC encoder, when each maximum coding unit (MCU) is encoded, a decision mode selection is required to segment the MCU, and subsequent encoding is performed according to the optimal motion vector of the coding unit under the decision mode. In the HEVC encoder, the size of the MCU is typically 6. The largest coding unit is divided into four equal parts, resulting in four subunits. The encoding unit.

[0020] Step S3: Read the decoding block information in the current coding unit. If the decoding block information of each decoding block in the current coding unit meets the fast decision condition, the current coding unit is encoded as a whole, which greatly reduces the coding time; otherwise, proceed to step S4. The fast decision condition means that the prediction mode, forward motion vector and backward motion vector of each decoding block in the current coding unit are completely the same, indicating that the current coding unit has high accuracy when reusing decoding information.

[0021] Step S4: When the current coding unit does not meet the fast decision-making condition, many smaller blocks within it can reuse the decoding block information for decision mode segmentation. If the decoding block information of each decoding block within the current coding unit meets the condition for continued segmentation, the current coding unit is divided into four equal parts, splitting it into four groups. The coding unit significantly increases the effective area of ​​the fast decision mode, thereby further improving the coding speed during transcoding; otherwise, proceed to step S6. The condition for continued segmentation is as follows: if each of the four equal parts of the current coding unit has an intra-frame prediction mode during decoding, the current coding unit is divided into four equal parts; otherwise, it is determined how many sets of inconsistent forward and backward motion vectors exist within the four equal parts of the current coding unit. If more than one set is inconsistent, the current coding unit is divided into four equal parts; otherwise, it is determined whether the quantization parameter during decoding within the four equal parts where the forward and backward motion vectors are inconsistent is less than the average quantization parameter of the entire frame. If so, it indicates that the regional coding of the current coding unit has a greater impact on rate distortion compared to other regions. The area needs to be larger, so the current coding unit is divided into four equal parts.

[0022] Step S5: Repeat steps S3-S6 until the size of the segmented coding units reaches the preset size, and encode the coding units of the preset size as a whole; specifically, if the coding units under the preset size meet the fast decision condition, encode the coding units under the preset size directly as a whole; otherwise, set the prediction mode of the prediction unit in the coding unit under the preset size to Furthermore, each prediction unit uses the motion vector decoded at the same position as the optimal motion vector. In this invention, the preset size is... , This indicates the size of the prediction model, with a value of [value missing]. .

[0023] Step S6: The residual of the four equal regions in the current coding unit where the forward and backward motion vectors are inconsistent and the quantization parameter during decoding is not less than the average quantization parameter of the entire frame is taken as the coding residual of the current coding unit. If the coding residual of the current coding unit is less than the residual threshold, the current coding unit is encoded as a whole; otherwise, the current coding unit is divided into four equal parts, and steps S3-S6 are repeated. The residual threshold can be used to determine whether the motion vectors are accurately reused during decoding. If the coding residual is greater than or equal to the residual threshold, it means that the current coding region is not suitable for reusing the decoding block information, thus failing to meet the conditions for fast decision-making. By comparing with the residual threshold, the mode decision time can be significantly reduced at the expense of a small compression ratio. The relatively low residual threshold also ensures that the sacrificed compression ratio is very small.

[0024] When the prediction mode for the four-part region used for residual calculation is a bidirectional prediction mode, it is determined whether the average of the absolute values ​​of the forward motion vector difference and the backward motion vector difference within the four-part region exceeds a first pixel threshold. If so, the current coding unit is divided into four parts, and steps S3-S6 are repeated; otherwise, a first decoding residual is calculated based on the forward motion vector difference and the backward motion vector difference within the four-part region, and a first residual threshold is set based on the first decoding residual. If the coding residual of the current coding unit is less than the first residual threshold, the current coding unit is encoded as a whole. In this invention, the first pixel threshold is set to 4 pixels, and the first residual threshold is set to the first decoding residual plus 12.

[0025] When the prediction mode for the four-part region used for residual calculation is either forward prediction mode or backward prediction mode, it is determined whether the absolute value of the forward motion vector difference or the absolute value of the backward motion vector difference within the four-part region exceeds the second pixel threshold. If so, the current coding unit is divided into four parts, and steps S3-S6 are repeated; otherwise, the second decoding residual is calculated based on the forward motion vector difference or the backward motion vector difference within the four-part region, and the second residual threshold is set based on the second decoding residual. If the coding residual of the current coding unit is less than the second residual threshold, the current coding unit is encoded as a whole. In this invention, the second pixel threshold is set to 6 pixels, and the second residual threshold is set to the second decoding residual plus 16.

[0026] This invention, while utilizing decoding to obtain the forward and backward motion vectors of the decoded block, analyzes the motion vector difference and prediction mode of the encoded unit region obtained during the decoding process to predict the accuracy of the current region's multiplexing motion vector and its impact on bit rate distortion. This allows for more accurate adjustment of the encoded unit size and better mode decision selection.

[0027] When the live streaming device only supports H264 encoding, or when the on-demand video stream is stored in H264 format, if you want to reduce the bandwidth pressure of the downlink video stream, you can use the mode decision method of the present invention, which includes H264 to HEVC B-frame transcoding, on the server side. This saves a lot of transcoding computation on the basis of real-time transcoding, and at the same time, outputs HEVC video streams with higher compression ratio.

[0028] In one embodiment of the present invention, a computer-readable storage medium is also provided, storing a computer program that causes a computer to execute the mode decision method for transcoding B frames from H.264 to HEVC.

[0029] In the embodiments disclosed in this application, a computer storage medium may be a tangible medium that may contain or store programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of computer storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0030] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0031] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should be considered within the scope of protection of the present invention.

Claims

1. A mode decision method for transcoding B-frames from H.264 to HEVC, characterized in that, Includes the following steps: Step S1: Use the H.264 decoder to decode each decoding block of the B frame to obtain the decoding block information; Step S2: In the HEVC encoder, when each maximum coding unit is encoded, the maximum coding unit is divided into four equal parts; Step S3: Read the decoding block information in the current coding unit. If the decoding block information of each decoding block in the current coding unit meets the fast decision condition, encode the current coding unit as a whole. Otherwise, proceed to step S4; Step S4: If the decoding block information of each decoding block in the current coding unit satisfies the condition for continued segmentation, divide the current coding unit into four equal parts; Otherwise, proceed to step S6; Step S5: Repeat steps S3-S6 until the size of the segmented encoding unit reaches the preset size, and encode the encoding unit of the preset size as a whole; Step S6: Calculate the coding residual of the current coding unit. If the coding residual of the current coding unit is less than the residual threshold, encode the current coding unit as a whole. Otherwise, execute the process of dividing the current encoding unit into four equal parts and repeating steps S3-S6.

2. The mode decision method for transcoding B-frames from H.264 to HEVC according to claim 1, characterized in that, The decoding block information includes: the prediction mode, quantization parameters, forward motion vector, forward motion vector difference, backward motion vector, and backward motion vector difference of the decoding block.

3. The mode decision method for transcoding B-frames from H.264 to HEVC according to claim 2, characterized in that, The prediction modes of the decoded block include: forward prediction mode, backward prediction mode, bidirectional prediction mode, and intra-frame prediction mode.

4. The mode decision method for transcoding B-frames from H.264 to HEVC according to claim 2, characterized in that, The fast decision condition in step S3 means that the prediction mode, forward motion vector and backward motion vector of each decoding block in the current coding unit are exactly the same.

5. The mode decision method for transcoding B-frames from H.264 to HEVC according to claim 3, characterized in that, In step S4, satisfying the condition for continued segmentation means that if each of the four equal regions of the current coding unit has an intra-frame prediction mode during decoding, the current coding unit will be divided into four equal parts. Otherwise, determine how many sets of inconsistent forward and backward motion vectors exist in the four-part region within the current coding unit. If more than one set is inconsistent, divide the current coding unit into four equal parts. Otherwise, determine whether the quantization parameter during decoding is less than the average quantization parameter of the entire frame in the four-part region where the forward motion vector and the backward motion vector are inconsistent. If so, divide the current coding unit into four parts.

6. The mode decision method for transcoding B-frames from H.264 to HEVC according to claim 5, characterized in that, Step S6 calculates the coding residual of the current coding unit as follows: the residual of the four equally divided regions in the current coding unit where the forward motion vector and the backward motion vector are inconsistent and the quantization parameter during decoding is not less than the average quantization parameter of the whole frame is taken as the coding residual of the current coding unit.

7. The mode decision method for transcoding B-frames from H.264 to HEVC according to claim 6, characterized in that, When the prediction mode for the four-part region used for residual calculation is the bidirectional prediction mode, it is determined whether the absolute values ​​of the forward motion vector difference and the backward motion vector difference in the four-part region both exceed the first pixel threshold. If so, the current coding unit is divided into four parts, and steps S3-S6 are repeated. Otherwise, the first decoding residual is calculated based on the forward motion vector difference and the backward motion vector difference in the four-part region, and the first residual threshold is set based on the first decoding residual. If the coding residual of the current coding unit is less than the first residual threshold, the current coding unit is encoded as a whole.

8. The mode decision method for transcoding B-frames from H.264 to HEVC according to claim 6, characterized in that, When the prediction mode of the four-part region used for residual calculation is forward prediction mode or backward prediction mode, determine whether the absolute value of the forward motion vector difference or the absolute value of the backward motion vector difference in the four-part region exceeds the second pixel threshold. If so, divide the current coding unit into four parts and repeat steps S3-S6; otherwise, calculate the second decoding residual based on the forward motion vector difference or the backward motion vector difference in the four-part region, set the second residual threshold based on the second decoding residual, and if the coding residual of the current coding unit is less than the second residual threshold, encode the current coding unit as a whole.

9. The mode decision method for transcoding B-frames from H.264 to HEVC according to claim 3, characterized in that, The specific process of encoding with a pre-defined size coding unit as a whole is as follows: if the coding unit under the pre-defined size meets the fast decision condition, the coding unit under the pre-defined size is directly encoded as a whole; otherwise, the prediction mode of the prediction unit in the coding unit under the pre-defined size is set to... Furthermore, each prediction unit uses the motion vector decoded at the same position as the optimal motion vector, where, Indicates the size of the prediction model.

10. A computer-readable storage medium storing a computer program, characterized in that, The computer program causes the computer to perform the mode decision method for transcoding B frames from H.264 to HEVC as described in any one of claims 1-9.