Method of encoding with reduced code rate and corresponding decoding method
By introducing an enhanced SI frame structure into video coding, and combining encoding and decoding methods for basic I frames and supplementary frames, the problem of low I frame compression efficiency in security monitoring videos is solved, achieving higher encoding compression rates and lower storage costs while maintaining video quality.
Patent Information
- Application Number
- CN202111546623.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-16
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2041-12-16
AI Technical Summary
Existing video coding standards have low compression efficiency for I-frames in security surveillance videos, resulting in high bitrates, which affects encoding and compression efficiency and storage costs.
An enhanced SI frame structure is adopted, in which each SI frame includes a basic I frame and a supplementary frame. The basic I frame is encoded using a larger quantization factor, and the supplementary frame uses inter-frame prediction. The SI frame encoded data is obtained by superposition and corresponding restoration processing is performed during decoding.
It achieves further compression of video encoding, reduces transmission and storage costs, and maintains video playback quality, with only a brief drop in quality during random access.
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of video coding, and particularly relates to a coding method for reducing code rate. BACKGROUND
[0002] At present, popular video coding standards, such as international video standards H.264, H265, and domestic video standards AVS2, AVS3, and the like, are similar in video compression principle, and are all based on removal of intra-frame and inter-frame redundant information, then transformation, quantization processing, and finally entropy coding. Whether the compression rate is high depends on whether the redundant information is completely removed.
[0003] A video is composed of a plurality of continuous images, and each image is coded and compressed into a frame. An encoder codes a plurality of continuous images to produce a picture group (GOP) in segments. A GOP is composed of an I frame and a plurality of B / P frames, and is a frame set that can be independently decoded. The I frame is an intra-coded frame (also referred to as a key frame), only intra-frame prediction is performed, and no inter-frame redundant information in the time domain is removed, so the coding and compression efficiency is low, but the I frame can be independently decoded and does not depend on the previous coded frame. The P frame is a forward prediction frame (forward reference frame), and the B frame is a bidirectional interpolation frame (bidirectional reference frame). The P and B frames remove the redundant information in the time domain, and the encoder only needs to code the residual value of the P / B frame after prediction of the previous reference frame, so the compression efficiency is high, but the decoding of the P and B frames needs to depend on the frame information that has been decoded, and the P and B frames cannot be independently decoded.
[0004] At present, video compression is generally adopted in the production domain of a television station, and only I frame coding and compression is used, that is, a GOP only contains an I frame. Other video fields use I, P, and B frame coding to improve the compression efficiency. Since the P and B frames remove the redundant information in the time domain, the compression efficiency of the P and B frames is much higher than that of the I frame. Usually, the number of bytes of each I frame is more than 5 times that of the P or B frame under the same coding quality of television and film video.
[0005] However, for security monitoring video, there is a lot of inter-frame redundant information, and the number of bytes of I frame can be hundreds or even thousands times of P and B frames. In addition, for I frame, if the compression efficiency is to be improved, a large quantization factor must be added, but the effect is that the quality of the decoded restoration is poor. Typically, for H264 / H265 video compression standard, the compression efficiency is increased by about one time when the quantization factor is increased by 6. Generally, security monitoring video needs to be played back at a fixed time point, so the number of frames per GOP should not be too large, typically one second per GOP. Thus, most of the bytes of the compressed video stream are occupied by I frames. Because the compression efficiency of I frame is low at the same quality, and the interval of I frame, i.e. the number of GOP frames, cannot be too large, which will seriously hinder the coding compression efficiency. SUMMARY
[0006] In view of the above problems, the present application provides a coding method for further compressing I frame to reduce the code rate and a corresponding decoding method.
[0007] To solve the above technical problems, the present application adopts the following technical solutions:
[0008] The first aspect of the embodiment of the present application provides a coding method for reducing the code rate, comprising the following steps:
[0009] When the video coding is started, the size of GOP is set as N, and the number of normal I frame period is set as M. In every M consecutive GOPs, the first frame of the first GOP is a normal I frame, and the first frame of the remaining GOPs is an enhanced SI frame. Each SI frame includes a basic I frame and a supplementary frame, and the supplementary frame is obtained by using inter-frame prediction to code the basic I frame and the original frame.
[0010] When the nth frame (n=1, 2, 3,...) is input, the frame type of the frame is determined. When n is an integer multiple of N, the frame is coded as a normal I frame or an SI frame.
[0011] When the normal I frame is coded, a normal coding method is used, and when the SI frame is coded, an SI frame coding method is used.
[0012] In a possible design of the first aspect, if n is not an integer multiple of N, the frame is a normal P or B frame.
[0013] In a possible design of the first aspect, the SI frame coding method comprises:
[0014] When the basic I frame is coded, a larger quantization factor is used, so that the number of bytes of the basic I frame is much smaller than that of the normal coded I frame. When the supplementary frame is coded, inter-frame prediction is used. Then, the coding data of the basic I frame and the coding data of the supplementary frame are superimposed to obtain the coding data of the entire SI frame.
[0015] In one possible design of the first aspect, a larger quantization factor is used when encoding the base I-frame, so that the number of bytes in the base I-frame is much smaller than that of a normally encoded I-frame. Specifically, this includes:
[0016] First, the base I-frame of the SI frame is encoded with a larger quantization factor. If this frame is a normal I-frame, the quantization factor used is Qp, then the quantization factor used to encode this base I-frame is Qp+delta, where delta is a positive integer. At the same time, it is ensured that Qp+delta is within the range allowed by the encoding specification. Let the compressed bitstream data obtained after encoding the base I-frame be D_basicI, the number of data bytes be Len_basicI, the original input frame be Org, and the decoded and reconstructed frame of the base I-frame be Rec1.
[0017] In one possible design of the first aspect, when encoding supplementary frames, the use of inter-frame prediction specifically includes:
[0018] Let Res1 be the residual frame between the original frame and the decoded / reconstructed frame of the base I-frame. The residual frame Res1 is obtained by subtracting Org from Rec1 pixel by pixel. Each pixel of the residual frame is then incremented by 2. Bitdepth-1 And by using saturation, the pixel value is limited to [0, 2]. Bitdepth Within the range of [-1], where Bitdepth is the bit depth of the original video data, and let the number of pixels in the video frame be L.
[0019] Res1[i]=Clip(Org[i]-Rec1[i]+2 Bitdepth-1 ,0,2 Bitdepth -1)
[0020] Where Org[i] represents the value of the i-th pixel in the original frame, i = 1 to L; Rec1[i] and Res1[i] represent the i-th pixel values of Rec1 and Res1 respectively. The Clip(x,a,b) function means that if x is less than a, the value of Clip(x,a,b) is a; if x is greater than b, the value of Clip(x,a,b) is b; otherwise, it is equal to x.
[0021] Select an encoded frame preceding the current I-frame in the time domain, and let its decoded and reconstructed frame be Rec0. Subtract Rec0 from Rec1 pixel by pixel to obtain the residual frame Res0. Increase the depth of each pixel in the residual frame by 2 bits and limit the pixel value to the range [0, 2 bits depth - 1] through saturation.
[0022] Res0[i]=Clip(Rec0[i]-Rec1[i]+2 Bitdepth-1 ,0,2 Bitdepth -1)
[0023] A new encoder is created, taking Res0 frame as reference frame and Res1 frame as input frame to encode P frame, and a coded supplemental frame is obtained, wherein the coded compression data of the supplemental frame is D_supp, and the coded data length is Len_supp.
[0024] In a possible design of the first aspect, the size of N is the frame rate.
[0025] The second aspect of the embodiment of the present application provides a decoding method for decoding the coded frame obtained by using any of the above coding methods to reduce the code rate, comprising: at the decoding end, if it is a normal I, P or B frame, decoding is performed in a normal manner; and if it is an SI frame, decoding is performed in the coding manner corresponding to the SI frame.
[0026] In a possible design of the second aspect, the decoding in the coding manner corresponding to the SI frame specifically comprises:
[0027] First, the base I frame and the supplemental frame are separated from the whole frame, the base I frame is decoded using the standard I frame decoding manner to obtain a decoded frame Dec1; then it is judged whether the reference frame corresponding to the supplemental frame exists, if not, the supplemental frame is discarded, and Dec1 is the final decoded frame; if the reference frame of the supplemental frame exists, the decoded frame of the reference frame is set as Dec0, and then the reference frame Ref0 is calculated as:
[0028] Ref[i] = Clip(Dec0[i] - Dec1[i] + 2 Bitdepth-1 , 0, 2 Bitdepth -1)
[0029] Wherein, Dec0[i], Dec1[i] and Ref[i] represent the i-th pixel value of Dec0, Dec1 and Ref frame respectively.
[0030] The supplemental frame is decoded using the reference frame Ref to obtain a decoded frame Dec2;
[0031] The final decoded frame Dec is obtained by superimposing Dec1 and Dec2 to complete the decoding of the whole SI frame:
[0032] Dec[i] = Clip(Dec1[i] + Dec2[2] - 2 Bitdepth-1 , 0, 2 Bitdepth -1).
[0033] The present application has the following beneficial effects:
[0034] (1) The video encoding and decoding, especially the security monitoring video encoding and decoding, can be further compressed and encoded to reduce the transmission cost and reduce the storage cost.
[0035] (2) After using the technical implementation of the present application, the video file is greatly reduced in size, but the playing quality remains unchanged. The only drawback is that the quality decreases slightly for a short period of time after random access, but it quickly recovers, basically not reducing the video experience.
[0036] (3) The technical solution of the embodiment of the present application is based on the appropriate private extension of the existing video standard, such as the introduction of a new frame type SI, and the encoding and decoding process of the SI frame are private extensions. In exchange for a small reduction in video experience, a more optimal compression rate is obtained. The applicable video standards include commonly used international and domestic video compression standards such as H264, H265, AVS2, AVS3, and AV1. DETAILED DESCRIPTION
[0037] The technical solutions in the embodiments of the present application will be described clearly and completely below. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of the present application.
[0038] The encoding method for reducing code rate in the embodiment of the present application includes the following steps:
[0039] At the start of video encoding, the GOP size is set to N, and the number of normal I frame periods is set to M. In each consecutive M GOPs, the first frame of the first GOP is a normal I frame, and the first frame of the remaining GOPs is an enhanced SI frame. Each SI frame includes a basic I frame and a supplementary frame. The supplementary frame is obtained by using inter-frame prediction to encode the basic I frame and the original frame. The basic I frame is a normal standard I frame, but the quantization factor is appropriately increased, so that it can be decoded separately and the restored frame quality may be poor. The supplementary frame uses inter-frame prediction, and the decoded and reconstructed frame is added to the reconstructed data of the basic I frame to obtain a reconstructed frame with better quality.
[0040] When the nth frame (n = 1, 2, 3,...) is input, the frame type of the frame is first determined. If n is an integer multiple of N, the frame is encoded as a normal I frame or an SI frame. If n is not an integer multiple of N, the frame is a normal P or B frame.
[0041] When encoding a normal I frame, a normal encoding method is used. When encoding an SI frame, an SI frame encoding method is used.
[0042] In an embodiment of the present application, a typical N is equal to the frame rate. For example, if the frame rate is 25 FPS, then N = 25. Typically, M = 10.
[0043] In an embodiment of the present application, the SI frame encoding method comprises: using a larger quantization factor when encoding the basic I frame, so that the byte number of the basic I frame is much smaller than that of a normally encoded I frame; using inter-frame prediction when encoding the supplementary frame; and superimposing the basic I frame encoding data and the supplementary frame encoding data to obtain the entire SI frame encoding data, and the superimposition mode can be appropriately selected, such as placing the supplementary frame data in the user data area or SEI data area of the basic I frame data. The combination mode is not limited in the embodiment of the present application. Thus, the encoding of the SI frame is completed.
[0044] Further, in an embodiment of the present application, using a larger quantization factor to make the byte number of the basic I frame much smaller than that of a normally encoded I frame specifically comprises: first encoding the basic I frame of the SI frame with a larger quantization factor, if the frame is a normal I frame, the quantization factor used is Qp, then the quantization factor used for encoding the basic I frame is Qp+delta, delta is a positive integer, and Qp+delta is ensured to be within the range allowed by the encoding specification, assuming that the compressed code stream data obtained after encoding the basic I frame is D_basicI, the data byte number is Len_basicI, the original input frame is Org, and the decoded reconstructed frame of the basic I frame is Rec1. Delta is a positive integer, and typically delta is 12. The larger Qp is, the more distortion is, and the higher the compression rate is. Typically, when Qp increases by 6, the byte number of the encoded and compressed frame can be reduced by about half.
[0045] In an embodiment of the present application, when encoding the supplementary frame, using inter-frame prediction specifically comprises: assuming that the residual frame of the original frame and the decoded reconstructed frame of the basic I frame is Res1, i.e. the residual frame Res1 is obtained by subtracting the original frame Org from the decoded reconstructed frame Rec1 pixel by pixel, adding 2 Bitdepth-1 to each pixel of the residual frame, and limiting the pixel value in the range of [0, 21 Bitdepth -1] through saturation, wherein Bitdepth is the bit depth of the original video data, and typically Bitdepth is 8 in the monitoring field, and assuming that the pixel number of the video frame is L, which includes luminance and chrominance, i.e. for a 4:2:0 sampling video frame with a resolution of WxH, L=WxHx3 / 2, i.e.:
[0046] Res1[i]=Clip(Org[i]-Rec1[i]+2 Bitdepth-1 ,0,2 Bitdepth -1)
[0047] Wherein, Org[i] represents the value of the i-th pixel of the original frame, i=1~L; Rec1[i] and Res1[i] represent the i-th pixel value of Rec1 and Res1 respectively, wherein, the function of Clip(x, a, b) represents that if x is less than a, the value of Clip(x, a, b) is a, if x is greater than b, the value of Clip(x, a, b) is b, otherwise equal to x;
[0048] One encoding frame before the current I frame time domain is selected, and the decoded reconstruction frame thereof is set as Rec0; the residual frame Res0 is obtained by subtracting Rec0 from Rec1 pixel by pixel; each pixel of the residual frame is increased by 2 Bitdepth-1 , and the pixel value is limited in the range of [0, 2 Bitdepth -1] through saturation, that is:
[0049] Res0[i] = Clip(Rec0[i]-Rec1[i]+2 Bitdepth-1 ,0,2 Bitdepth -1)
[0050] A new encoder is created, and the Res0 frame is used as a reference frame, and the Res1 is used as an input frame to perform P frame encoding to obtain an encoded supplementary frame; the encoded compression data of the supplementary frame is set as D_supp, and the length of the encoded data is Len_supp.
[0051] Corresponding to the coding method for reducing the code rate of the embodiment of the application, the embodiment of the application simultaneously provides a decoding method for decoding the encoded frame obtained according to the coding method for reducing the code rate as above, comprising: at the decoding end, if it is a normal I, P, B frame, a normal mode is used for decoding; if it is an SI frame, the SI frame is decoded and restored in the corresponding encoding mode of the SI frame.
[0052] In an embodiment of the application, the decoding and restoring in the corresponding encoding mode of the SI frame specifically comprises:
[0053] First, the basic I frame and the supplementary frame are separated from the whole frame; the basic I frame is decoded by using the standard I frame decoding mode to obtain the decoded frame Dec1; then it is judged whether the reference frame corresponding to the supplementary frame exists or not; if not, the supplementary frame is discarded, and Dec1 is the final decoded frame; if the reference frame of the supplementary frame exists, the decoded frame of the reference frame is set as Dec0, and then the reference frame Ref0 is calculated as:
[0054] Ref[i] = Clip(Dec0[i]-Dec1[i]+2 Bitdepth-1 ,0,2 Bitdepth -1)
[0055] Wherein Dec0[i], Dec1[i], Ref[i] represent the i-th pixel value of Dec0, Dec1, Ref frame respectively;
[0056] With Ref frame as the reference frame, the decoding supplementary frame obtains the decoding frame Dec2;
[0057] Through superimposition of Dec1 and Dec2, the final decoding frame Dec is obtained, and the decoding of the whole SI frame is completed:
[0058] Dec[i] = Clip(Dec1[i] + Dec2[2] - 2 Bitdepth-1 , 0, 2 Bitdepth -1).
[0059] It should be understood that the example embodiments described herein are illustrative and non-limiting. Although one or more embodiments of the application have been described, it will be understood by those of ordinary skill in the art that various changes in form and details can be made therein without departing from the spirit and scope of the application as defined by the following claims.
Claims
1. An encoding method for reducing bit rate, characterized in that, Includes the following steps: When video encoding starts, the GOP size is first set to N, and the number of normal I-frame cycles is set to M. In every M consecutive GOPs, the first frame of the first GOP is a normal I-frame, and the first frame of the remaining GOPs is an enhanced SI frame. Each SI frame includes a base I-frame and a supplementary frame. The supplementary frame is obtained by encoding the base I-frame and the original frame using inter-frame prediction. When the nth frame is input, the frame type encoded by this frame is first determined. If n is an integer multiple of N, then this frame is encoded as a normal I frame or an SI frame. When encoding a normal I-frame, use the normal encoding method; When encoding SI frames, the SI frame encoding method is used; SI frame coding methods include: When encoding the base I-frame, a large quantization factor is used, making the number of bytes in the base I-frame much smaller than that of a normally encoded I-frame; when encoding the supplementary frame, inter-frame prediction is used; and then the base I-frame encoded data and the supplementary frame encoded data are superimposed to obtain the entire SI frame encoded data. When encoding the base I-frame, a larger quantization factor is used, resulting in a base I-frame having a much smaller byte count than a normally encoded I-frame. Specifically: First, the base I-frame of the SI frame is encoded with a larger quantization factor. If this frame is a normal I-frame, the quantization factor used is Qp, then the quantization factor used to encode this base I-frame is Qp+delta, where delta is a positive integer. At the same time, it is ensured that Qp+delta is within the range allowed by the encoding specification. Let the compressed bitstream data obtained after encoding the base I-frame be D_basicI, the number of data bytes be Len_basicI, the original input frame be Org, and the decoded and reconstructed frame of the base I-frame be Rec1. When encoding supplementary frames, inter-frame prediction specifically includes: Let Res1 be the residual frame between the original frame and the decoded / reconstructed frame of the base I-frame. The residual frame Res1 is obtained by subtracting Org from Rec1 pixel by pixel. Each pixel of the residual frame is then incremented by 2. Bitdepth-1 And by using saturation, the pixel value is limited to [0, 2]. Bitdepth Within the range of [-1], where Bitdepth is the bit depth of the original video data, and let the number of pixels in the video frame be L. Res1[i]=Clip(Org[i]-Rec1[i]+2 Bitdepth-1 ,0,2 Bitdepth -1) Where Org[i] represents the value of the i-th pixel in the original frame, i = 1 to L; Rec1[i] and Res1[i] represent the i-th pixel values of Rec1 and Res1 respectively. The Clip(x,a,b) function means that if x is less than a, the value of Clip(x,a,b) is a; if x is greater than b, the value of Clip(x,a,b) is b; otherwise, it is equal to x. Select an encoded frame preceding the current I-frame in the time domain, and let its decoded and reconstructed frame be Rec0. Subtract Rec0 from Rec1 pixel by pixel to obtain the residual frame Res0. Increase each pixel of the residual frame by 2. Bitdepth-1 And by using saturation, the pixel value is limited to [0, 2]. Bitdepth Within the range of -1], that is: Res0[i]=Clip(Rec0[i]-Rec1[i]+2 Bitdepth-1 ,0,2 Bitdepth -1) Create a new encoder, using Res0 frame as the reference frame and Res1 frame as the input frame, to perform P-frame encoding and obtain the encoded supplementary frame. Let the encoded compressed data of the supplementary frame be D_supp and the encoded data length be Len_supp.
2. The encoding method for reducing bit rate as described in claim 1, characterized in that, If n is not an integer multiple of N, then this frame is a normal P or B frame.
3. The encoding method for reducing bit rate as described in claim 1 or 2, characterized in that, The size of N is the frame rate.
4. A decoding method, characterized in that, The method for decoding encoded frames obtained by the encoding method for reducing bit rate according to any one of claims 1 to 3 includes: at the decoding end, if it is a normal I, P, or B frame, then it is decoded in a normal manner; if it is an SI frame, then it is decoded and restored using the encoding method corresponding to the SI frame.
Citation Information
Patent Citations
Content driven transcoder that orchestrates multimedia transcoding using content information
CN101313580A