Image coding prediction mode selection method
By presetting multiple coding prediction modes and selection sets in image coding, combining intra-frame and inter-frame coding, and utilizing absolute reference sample values and restored sample values, the problems of high resource consumption and high latency in existing technologies are solved, and efficient image compression and improved stability are achieved.
Patent Information
- Application Number
- CN202511277999.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-09
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-09-09
AI Technical Summary
Existing image coding methods fail to fully utilize image redundant information, resulting in low compression efficiency, high resource consumption and high latency.
A number of preset coding prediction modes are adopted, and a fixed number of coding prediction modes are selected as a selection set according to the coding scenario. The optimal coding prediction mode is selected through intra-frame and inter-frame coding prediction modes. The absolute reference sample value and the restored sample value are used to reduce error propagation and optimize the prediction mode selection.
It improves the compression efficiency of image coding, reduces resource consumption and delay, and enhances the stability of image quality, especially in low-hardware cost scenarios, where high coding efficiency can still be achieved.
Smart Images

Figure CN120769037A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image coding and decoding, and in particular to a method for selecting an image coding prediction mode. Background Art
[0002] Conventional image coding methods in the existing technology, such as JPEG, JPEG 2000, and JPEG XS, are simple to implement but have simple predictions. They do not make any predictions or only use the data of the adjacent blocks above the current block for prediction. They do not fully utilize the redundant information of the image, resulting in low image compression efficiency.
[0003] Although video encoding such as H264 utilizes redundant information of images and has multiple prediction modes, and although the compression rate is high, there are still some problems. For example, inter-frame prediction includes motion estimation, which is complex to implement and consumes a lot of resources. In addition, the selection of the current macroblock prediction mode requires the use of the reference sample value after the current frame is restored, resulting in high latency. In addition, when the local recovery of the encoded image is poor, that is, the current macroblock is poorly recovered, it is very likely that the macroblocks with the current macroblock as reference will also be affected, causing error propagation and the expansion of the error impact range. Summary of the Invention
[0004] In view of this, and in response to the deficiencies in the prior art, the present invention proposes an image coding prediction mode selection method, which can reduce coding delay and improve image coding compression efficiency in low hardware cost application scenarios.
[0005] In order to solve the above problems, the image coding prediction mode selection method of the present invention includes the following steps: (1) Preset several coding prediction modes, each of which corresponds to a set of reference sample values, and macroblock prediction values can be obtained based on the reference sample values; (2) Selecting a fixed number of coding prediction modes according to the coding scenario as a selection set of coding prediction modes for the corresponding scenario; (3) For the current macroblock, select the optimal coding prediction mode according to the macroblock prediction values corresponding to each coding prediction mode in the selection set; (4) Set the prediction mode field to place the optimal coding prediction mode value and send it to the decoding end along with the encoded bitstream.
[0006] Among them, the coding prediction mode includes the intra-frame coding prediction mode, the intra-frame coding prediction mode includes the conventional intra-frame coding prediction mode and the isolated intra-frame coding prediction mode, the conventional intra-frame coding prediction mode includes the intra-frame coding prediction mode in H264, and the isolated intra-frame coding prediction mode calculates the reference sample value according to the pixel depth in the encoding process.
[0007] The coding prediction mode also includes an inter-frame coding prediction mode. In the inter-frame coding prediction mode, the reference sample value of the current macroblock is the restored sample value at the corresponding position of the previous frame image.
[0008] Among them, the coding scenes include pure intra-frame scenes and general scenes; the pure intra-frame scene can only use the conventional intra-frame coding prediction mode, and the general scene can use the intra-frame coding prediction mode and the inter-frame coding prediction mode.
[0009] Determining the selection set of encoding prediction modes in the general scenario includes the following steps: (21) Create an image dataset of pure intra-frame scenes. The size of the image dataset and the image pixel size are set according to the actual application; (22) Configuring network parameters, taking all conventional intra-frame coding prediction modes as a selection set of coding prediction modes, selecting the optimal coding prediction mode to encode the image data set, and calculating the first peak signal-to-noise ratio after decoding; (23) removing a certain conventional intra-frame coding prediction mode from the selection set, retaining the other conventional intra-frame coding prediction modes, and then selecting the optimal coding prediction mode from the remaining selection set to encode the image data set, and calculating the second peak signal-to-noise ratio after decoding; (24) comparing the first peak signal-to-noise ratio and the second peak signal-to-noise ratio in sequence, selecting the second peak signal-to-noise ratio that has the smallest difference from the first peak signal-to-noise ratio, and recording the corresponding removed conventional intra-frame coding prediction mode as a negligible conventional intra-frame coding prediction mode; (25) An isolated intra-frame coding prediction mode is used to replace an ignored conventional intra-frame coding prediction mode, thereby forming a selection set of coding prediction modes for intra-frame coding in general scenarios; an inter-frame coding prediction mode is used to replace an ignored conventional intra-frame coding prediction mode, thereby forming a selection set of coding prediction modes for inter-frame coding in general scenarios.
[0010] The step (3) of selecting the optimal coding prediction mode includes the following steps: (31) Input the location information of the current macroblock and the selection set of coding prediction modes in the corresponding scene; (32) For a conventional intra-frame coding prediction mode, a reference sample value corresponding to the coding prediction mode is obtained in the source image of the image frame where the current macroblock is located; (33) Obtaining the macroblock prediction value corresponding to each coding prediction mode in the selection set, and selecting the optimal coding prediction mode in the selection set according to a preset rule.
[0011] The prediction mode field in step (4) includes a flag bit and a data bit, and setting the prediction mode field to place the optimal coding prediction mode value includes the following steps: (41) Initialize the optimal coding prediction mode value of the previous macroblock; (42) If the optimal encoding prediction mode value of the current macroblock is equal to the optimal encoding prediction mode value of the previous macroblock, the flag bit of the prediction mode field is set to 1, and the length of the prediction mode field is set to 1; otherwise, step (43) is entered; (43) If the optimal encoding prediction mode value of the current macroblock is less than the optimal encoding prediction mode value of the previous macroblock, the flag bit of the prediction mode field is set to 0, the value of the data bit is the optimal encoding prediction mode value of the current macroblock, and the length of the prediction mode field is set to 4; otherwise, step (44) is entered; (44) The flag bit of the prediction mode field is set to 0, the value of the data bit is the optimal encoding prediction mode value of the current macroblock minus 1, and the length of the prediction mode field is set to 4.
[0012] Compared with the prior art, the present application has the following advantages: By presetting several encoding prediction modes, in addition to obtaining reference sample values according to the current image, the absolute reference sample values and the restored sample values of the reference image are also used as the reference sample values, the image redundancy information is effectively utilized, the compression efficiency is improved, the absolute reference sample values can block and isolate the local blocks, error transmission is effectively avoided, and the image quality stability is improved; by setting a fixed number of encoding prediction modes in the selection set, different encoding prediction mode selection sets are determined for different scenes, the bit positions occupied by the encoding prediction modes are reduced, and the code stream is saved; the prediction mode selection is further optimized, for the regular intra-frame encoding prediction mode, the reference sample values corresponding to the encoding prediction mode are obtained in the source image where the current macroblock is located, and the optimal encoding prediction mode is selected from the selection set according to the macroblock prediction value, so that the resource consumption and the delay are reduced, and even in the case of low cost, high encoding efficiency and good subjective effect can be achieved. BRIEF DESCRIPTION OF DRAWINGS
[0013] Figure 1 is a flowchart of the image encoding prediction mode selection method in the present application; Figure 2 is a schematic diagram of the encoding prediction modes set in the present application, Figure 2 (a) is a schematic diagram of a regular intra-frame encoding prediction mode model_0; Figure 2 (b) is a schematic diagram of a regular intra-frame encoding prediction mode model_1; Figure 2 (c) is a schematic diagram of a regular intra-frame encoding prediction mode model_2; Figure 2 (d) is a schematic diagram of a regular intra-frame encoding prediction mode model_3; Figure 2 (e) is a schematic diagram of a regular intra-frame encoding prediction mode model_4; Figure 2 (f) is a schematic diagram of a regular intra-frame encoding prediction mode model_5; Figure 2(g) is a schematic diagram of a regular intra coding prediction mode model_6; Figure 2 (h) is a schematic diagram of a regular intra coding prediction mode model_7; Figure 2 (i) is a schematic diagram of a regular intra coding prediction mode model_8; Figure 2 (j) is a schematic diagram of an isolated intra coding prediction mode model_9; Figure 2 (k) is a schematic diagram of an inter coding prediction mode model_10; Figure 3 is a schematic diagram of image frame distribution in a general scenario; Figure 4 is another schematic diagram of image frame distribution in a general scenario; Figure 5 is a schematic diagram of the flow of selecting the optimal coding prediction mode in the present application. DETAILED DESCRIPTION
[0014] The present application will be further described in conjunction with the embodiments.
[0015] In the image coding process, generally, macroblocks are taken as the unit for coding prediction, and the selection of the coding prediction mode in the coding prediction process will affect the stability of the image quality, the coding efficiency and the compression efficiency. The present application improves the selection of the image coding prediction mode, can save the code stream, improve the coding compression performance, and can achieve higher coding efficiency and better subjective effect for the FPGA or low hardware cost implementation scenario.
[0016] As shown in Figure 1 , the image coding prediction mode selection method in the present application comprises the following steps: (1) preset a plurality of coding prediction modes, each coding prediction mode corresponds to a group of reference sample values, and the macroblock prediction value can be obtained according to the reference sample value; (2) select a fixed number of coding prediction modes as the selection set of the coding prediction mode in the corresponding scenario according to the coding scenario; (3) select the optimal coding prediction mode according to the macroblock prediction value corresponding to each coding prediction mode in the selection set for the current macroblock; (4) set the prediction mode field to place the optimal coding prediction mode value, and send it to the decoding end together with the coding code stream.
[0017] The above steps will be described in detail in conjunction with the specific embodiments.
[0018] Image coding in the present invention includes intra-frame coding and inter-frame coding. Intra-frame coding encodes macroblocks only through intra-frame coding prediction; inter-frame coding also encodes macroblocks through inter-frame coding prediction. Intra-frame coding prediction and inter-frame coding prediction are mainly distinguished by the reference sample values corresponding to the coding prediction mode. Intra-frame coding prediction refers to the process of using the restored sample values in the current frame as reference sample values to predict and generate the current macroblock; inter-frame coding prediction refers to the process of using the restored sample values of the reference image (i.e., the previous frame) as reference sample values to predict and generate the current macroblock. For the sake of ease of description, the present invention refers to the coding prediction mode that uses the data of the corresponding block in the current frame as the reference sample value as the conventional intra-frame coding prediction mode, and the coding prediction mode that uses the restored sample values of the corresponding position of the previous frame image as the reference sample value as the inter-frame coding prediction mode.
[0019] Coding prediction mode setting like Figure 2 As shown, in the present invention, taking the coding prediction of 4x4 macroblock as an example, 11 coding prediction modes are set, including intra-frame coding prediction mode and inter-frame coding prediction mode, wherein the intra-frame coding prediction mode includes conventional intra-frame coding prediction modes model_0 to model_8 and isolated intra-frame coding prediction mode model_9; the above-mentioned conventional coding prediction modes model_0 to model_8 are the same as the intra_4x4 intra-frame prediction mode in H264, and their corresponding sample reference values are as follows.
[0020] Conventional intra-frame coding prediction mode model_0 (Vertical) uses the sample value above the current macroblock as the sample reference value to predict the current macroblock. Assuming that the value above the current macroblock is p[x,-1], x=0..3, then the predicted value of the current macroblock is pred4x4 L [x, y], x, y = 0..3 is calculated as follows: pred4x4 L [x, y] = p[x,-1], x, y = 0..3.
[0021] Conventional intra-frame coding prediction mode model_1 (Horizontal) uses the sample value to the left of the current macroblock as the sample reference value to predict the current macroblock. Assume that the value to the left of the current macroblock is p[-1, y], y = 0..3, and the current macroblock prediction value pred4x4 L [x, y], x, y = 0..3 is as follows: pred4x4 L [x, y] = p[-1, y]x,y = 0..3.
[0022] Conventional intra-frame coding prediction mode model_2 (DC), current macroblock prediction value pred4x4 L [x, y], x, y = 0..3 is obtained as follows: pred4x4 L [x, y] = ( p[0,-1]+p[1,-1]+p[2,-1]+p[3,-1]+ p[-1, 0]+p[-1, 1]+p[-1, 2]+p[-1, 3]+4 )>>3 .
[0023] Conventional intra-frame coding prediction mode model_3 (Diagonal Down-Left), current macroblock prediction value pred4x4 L [x, y], x, y = 0..3 is obtained as follows: If x equals 3 and y equals 3, pred4x4 L [x, y] = ( p[6,-1]+3 * p[7,-1]+2 )>>2; Otherwise (x, y are not equal to 3) pred4x4 L [x, y] = ( p[x+y,-1]+2 * p[x+y+1,-1]+p[x+y+2,-1]+2 )>>2.
[0024] Conventional intra-frame coding prediction mode model_4 (Diagonal Down-Right), the prediction value of the current macroblock pred4x4 L [x, y], x, y = 0..3 is obtained as follows: If x is greater than y, then pred4x4 L [x, y] = ( p[x- y-2,-1]+2 * p[x- y-1,-1]+p[xy,-1]+2 )>>2, Otherwise, if x is less than y pred4x4 L [x, y] = ( p[-1, y- x- 2]+2 * p[-1, y- x- 1]+p[-1, y- x]+2 )>>2, Otherwise (x equals y) pred4x4 L [x, y] = ( p[0,-1]+2 * p[-1,-1]+p[-1, 0]+2 )>>2.
[0025] Conventional intra-frame coding prediction mode model_5 (Vertical-Right), set zVR=2*xy, current macroblock prediction value pred4x4 L [x, y], the values of x, y = 0, 3 are as follows: If zVR is equal to 0, 2, 4, or 6, then pred4x4 L [x, y] = ( p[x- ( y>>1 )-1,-1]+p[x- ( y>>1 ),-1]+1 )>>1, Otherwise, if zVR is equal to 1, 3, or 5, then pred4x4 L [x, y] = ( p[x- ( y>>1 )-2,-1]+2 * p[x- ( y>>1 )- 1,-1]+p[x-( y>>1 ),-1]+2 )>>2, Otherwise, if zVR is equal to -1, then pred4x4 L [x, y] = ( p[-1, 0]+2 * p[-1,-1]+p[0,-1]+2 )>>2, Otherwise (zVR is equal to -2 or -3), pred4x4 L [x, y] = ( p[-1, y- 1]+2 * p[-1, y- 2]+p[-1, y- 3]+2 )>>2.
[0026] Conventional intra-frame coding prediction mode model_6 (Horizontal-Down), set zHD = 2 * y - x, the current macroblock prediction pred4x4L[x, y], x, y = 0..3 is obtained as follows: If zHD is equal to 0, 2, 4, or 6, then pred4x4 L [x, y] = ( p[-1, y- ( x>>1 )- 1]+p[-1, y- ( x>>1 )]+1 )>>1, Otherwise, if zHD is equal to 1, 3, or 5, then pred4x4 L [x, y] = ( p[-1, y- ( x>>1 )- 2]+2 * p[-1, y- ( x>>1 )- 1]+p[-1, y- ( x>>1 )]+2 )>>2, Otherwise, if zHD is equal to -1, pred4x4 L [x, y] = ( p[-1, 0]+2 * p[-1,-1]+p[0,-1]+2 )>>2, Otherwise (zHD is -2 or -3), then pred4x4 L [x, y] = ( p[x- 1,-1]+2 * p[x- 2,-1]+p[x- 3,-1]+2 )>>2.
[0027] Conventional intra-frame coding prediction mode model_7 (Vertical-Left), current macroblock prediction value pred4x4 L [x,y], x, y = 0..3 is obtained as follows: If y is equal to 0 or 2, pred4x4 L [x, y] = ( p[x+( y>>1 ),-1]+p[x+( y>>1 )+1,-1]+1)>>1, Otherwise (y is equal to 1 or 3) pred4x4 L [x,y]=(p[x+( y>>1 ),-1]+2 * p[x+( y>>1 )+1,-1]+p[x+( y>>1 )+2,-1]+2 )>>2.
[0028] Conventional intra-frame coding prediction mode model_8 (Horizontal-Up), set variable zHU equal to x+2*y, current macroblock prediction value pred4x4 L [x, y], x, y = 0..3 is obtained as follows: If zHU is equal to 0, 2, or 4, pred4x4 L [x, y] = ( p[-1, y+( x>>1 )]+p[-1, y+( x>>1 )+1]+1 )>>1, Otherwise, if zHU is equal to 1 or 3, pred4x4 L [x,y]=(p[-1,y+( x>>1 )]+2*p[-1, y+( x>>1 )+1]+p[-1, y+( x>>1 )+2]+2 )>>2, Otherwise, if zHU is equal to 5, pred4x4 L[x, y] = ( p[-1, 2]+3 * p[-1, 3]+2 )>>2, Otherwise (zHU is greater than 5) pred4x4 L [x, y] = p[-1, 3].
[0029] The isolated intra-frame coding prediction mode model_9 (Fix Value) described above uses a fixed value as the reference sample value for prediction. If the image to be encoded is complex and the network transmission bandwidth is limited, a large QP (Quantization Parameter) is required during the encoding process to meet the network bandwidth. When the QP is large, the recovered sample values will be blurry and distorted. If a poorly recovered sample value is selected as the reference sample value when encoding a macroblock, the recovery of the current block will also be poor, which will lead to error accumulation and unstable recovered image quality. In the present invention, the isolated intra-frame coding prediction mode model_9 is set, and a fixed value is used as the reference sample value to directly derive the macroblock prediction value. In this way, regardless of the recovery of the surrounding pixels, the recovery of the current macroblock will not be affected by the surrounding pixels. Moreover, when the image is complex and the surrounding pixels are poorly recovered (such as in a random image), it is relatively easy to select the isolated intra-frame coding prediction mode model_9.
[0030] The above fixed value is calculated based on the pixel depth during encoding, as fix_val = 1<<(depth-1), where fix_val is a fixed value and depth is the pixel depth during encoding. For example, if the pixel depth during encoding is 10 bits, then fix_val is 512 (1<<9).
[0031] The above symbol “<<” indicates a shift to the left, and ">>” indicates a shift to the right.
[0032] To minimize hardware costs, this invention eliminates motion estimation and directly uses the block data at the corresponding position in the previous frame to obtain reference samples. This inter-frame coding prediction mode, model_10 (Ref Blk), is set. That is, during the encoding process, inter-frame coding prediction mode, model_10, uses the 4x4 restored samples at the corresponding position in the reference frame (the previous frame) as reference samples to directly derive macroblock predictions.
[0033] (2) Determine the selection set of coding prediction modes based on the coding scenario and coding mode The present invention relates to two scenarios. One is that only intra-frame coding can be used, and this type of scenario is marked as a pure intra-frame scenario in the present invention. The second is that both intra-frame coding and inter-frame coding can be used, and this type of scenario is marked as a general scenario.
[0034] In different scenarios, the present application limits the selection set of the encoding prediction mode to 9, which can save the code stream and improve the encoding compression performance.
[0035] The pure intra scene can be applied in the condition of limited hardware, without DDR (Double Data Rate, double rate synchronous dynamic random access memory), the whole encoding process only uses the data of the current frame, only involves the intra encoding mode, and the selection set of the encoding prediction mode of the pure intra scene in the present application is set to the nine modes of the conventional intra encoding prediction modes model_0 to model_8. Figure 2
[0036] For the general scene, the intra encoding and the inter encoding are used, and the present application relates to two general scenes.
[0037] For the general scene, the selection set of the encoding prediction mode includes the following steps: (21) An image data set of a pure intra scene is created, and the size of the image data set and the image pixel size are set according to the actual application; (22) The network parameters are configured, all the conventional intra encoding prediction modes model_0 to model_8 are taken as the selection set of the encoding prediction mode, the optimal encoding prediction mode is selected to encode the image data set, and the first peak signal-to-noise ratio PSNR after decoding is calculated; (23) A certain conventional intra encoding prediction mode model_i (i=0, 1, 2, …, 8) in the selection set is removed, the other encoding prediction modes are reserved, then the optimal encoding prediction mode is selected from the remaining encoding prediction modes to encode the image data set, and the second peak signal-to-noise ratio PSNR after decoding is calculated i ; (24) The values of the first peak signal-to-noise ratio PSNR and the second peak signal-to-noise ratio PSNR i are compared in sequence, the second peak signal-to-noise ratio PSNR i with the smallest difference from the first peak signal-to-noise ratio PSNR is selected, it is determined which conventional intra encoding prediction mode to replace to have the least influence on the first peak signal-to-noise ratio PSNR, and the removed conventional intra encoding prediction mode model_i is recorded as the negligible conventional intra encoding prediction mode; (25) The isolated intra encoding prediction mode is used to replace the negligible conventional intra encoding prediction mode to form the selection set of the encoding prediction mode when the intra encoding is used in the general scene, and the inter encoding prediction mode is used to replace the negligible conventional intra encoding prediction mode to form the selection set of the encoding prediction mode when the inter encoding is used in the general scene.
[0038] As an implementation, an image dataset consisting of 265 images is created, including natural images, screen images, etc., with an image size of 3840x2160 and a network bandwidth of 500Mbps. The above-mentioned parameters can be set according to actual needs. The general scenarios in this invention include the following two methods.
[0039] like Figure 3 As shown in the figure, during the encoding process, the image frame is intra-coded once every fixed time, and the corresponding frame is marked as an I frame (intraframe frame, key frame), and the remaining frames are inter-coded and marked as P frames (forward Predicted frame, forward reference frame). If the conventional intra-frame coding prediction mode model_8 is replaced with the least impact on the first peak signal-to-noise ratio (PSNR), it is the conventional intra-frame coding prediction mode that can be ignored. For I frames, select Figure 2 The nine prediction modes model_0 to model_7 and the isolated intra-frame coding prediction mode model_9 are selected as a set. For P frame selection Figure 2 The nine prediction modes including conventional intra-frame coding prediction modes model_0 to model_7 and inter-frame coding prediction mode model_10 are selected as a set.
[0040] like Figure 4 As shown, the GDR method (Gradual Decoding Refresh) is used, and each frame contains two coding methods: intra-frame and inter-frame. Specifically, each frame is divided into n equal parts, and one of them is selected for intra-frame coding, which is called intra-frame strip, and the rest of the parts are inter-frame coded, which is called inter-frame strip. The advantage of the second method over the first method is that the code stream size of each frame is more uniform, which is conducive to network transmission. In this scenario, the intra-frame strip adopts intra-frame coding. If the conventional intra-frame coding prediction mode model_8 has the least effect on the first peak signal-to-noise ratio PSNR, it is an ignorable conventional intra-frame coding prediction mode. The nine prediction modes of conventional intra-frame coding prediction modes model_0 to model_7 and isolated intra-frame coding prediction mode model_9 are selected as the selection set. The inter-frame strip adopts inter-frame coding. The present invention selects the nine prediction modes of conventional intra-frame coding prediction modes model_0 to model_7 and inter-frame coding prediction mode model_10 as the selection modes.
[0041] (3) Select the optimal coding prediction mode from the selection set of coding prediction modes like Figure 5 As shown, the selection of the optimal coding prediction mode requires the following steps: (31) Input the location information of the current macroblock and the selection set of coding prediction modes in the corresponding scene; (32) For the conventional intra-frame coding prediction mode, the reference sample value corresponding to the coding prediction mode is obtained from the source image of the image frame where the current macroblock is located; for the inter-frame coding prediction mode, the reference sample value of the current macroblock still uses the restored sample value at the corresponding position in the previous frame image; the reference sample value of the isolated intra-frame coding prediction mode still uses a fixed value; (33) Obtaining the macroblock prediction value corresponding to each coding prediction mode in the selection set, and selecting the optimal coding prediction mode in the selection set according to a preset rule.
[0042] The preset rule of the above step (33) is: subtract the pixel components at the corresponding positions of the current macroblock and the macroblock prediction value, then take the absolute value of the difference and sum it, use the obtained value as the evaluation index, and use the encoding prediction mode with the smallest value as the optimal encoding prediction mode, which is the SAD (sum of Absolute difference) of H264.
[0043] In the prior art, when selecting the optimal coding prediction mode for the next macroblock, the reference sample values used in each intra-frame coding prediction mode need to utilize the image information decoded from the previous macroblock. That is, the current macroblock must undergo DCT, quantization, inverse quantization, IDCT and other processing before the next macroblock can utilize the decoded image information of the current macroblock to complete a new round of optimal coding prediction mode selection.
[0044] Compared to the prior art, although the conventional intra-frame prediction coding mode of the present invention still uses the recovered sample values within the current frame as reference samples to predict the process of generating the current macroblock during the actual encoding process, and the inter-frame coding prediction still uses the recovered sample values of the reference image (i.e., the previous frame) as reference samples to predict the process of generating the current macroblock, the present invention directly uses the source image information as the reference sample values when selecting the optimal coding prediction mode. This allows the next macroblock to be processed directly after the optimal coding prediction mode for the current macroblock is determined, reducing latency.
[0045] (4) Coding of the optimal coding prediction mode Considering the use of nine coding prediction modes, a 3-bit data bit combined with a 1-bit flag bit can be used to represent them. However, if there are more than nine modes, 4 bits must be used, which means that each macroblock prediction mode requires an extra bit, increasing the coding overhead. For example, a 3840x2160 image has a total of 518,400 4x4 macroblocks. If the prediction mode for each block is encoded, a prediction algorithm with more than nine modes will require 518,400 more bits than the 9 modes. If the network bandwidth is 500Mbps and the frame rate is 60 frames per second, the average compressed size of a 3840x2160 image is 8333333 bits, so 518,400 bits occupy 6% of the bitstream. To save bitstream, infrequently used prediction modes are directly replaced, and ultimately, all scenarios are limited to 9 prediction modes.
[0046] In the present invention, a prediction mode field is set to store the optimal coding prediction mode value. Taking the coding prediction selection set of the present invention including 9 prediction coding modes as an example, the prediction mode field includes a 1-bit flag bit and 3-bit data bits. The length of the prediction mode field, code_len, is adjusted according to the size relationship between the optimal coding prediction mode value of the current macroblock and the optimal coding prediction mode value of the previous macroblock, and the value is 1 or 4. Specifically, encoding the optimal coding prediction mode includes the following steps: (41) Initialize the optimal coding prediction mode value prev_mode of the previous macroblock; (42) If the optimal coding prediction mode value curr_mode of the current macroblock is equal to the optimal coding prediction mode value prev_mode of the previous macroblock, then set the flag bit mode_is_equal_flag of the prediction mode field to 1 and set the length code_len of the prediction mode field to 1; otherwise, proceed to step (43); (43) If the optimal coding prediction mode value curr_mode of the current macroblock is less than the optimal coding prediction mode value prev_mode of the previous macroblock, then set the flag bit mode_is_equal_flag of the prediction mode field to 0, the value of the data bit code_val to the optimal coding prediction mode value curr_mode of the current macroblock, and the value of the length code_len of the prediction mode field to 4; otherwise, proceed to step (44); (44) Let the flag bit mode_is_equal_flag of the prediction mode field be 0, the value of the data bit code_val be the optimal coding prediction mode value curr_mode-1 of the current macroblock, and the value of the length code_len of the prediction mode field be 4.
[0047] In the above step (43), the value range of the optimal coding prediction mode value prev_mode of the previous macroblock is 0~8. Since the optimal coding prediction mode value curr_mode of the current macroblock is smaller than the optimal coding prediction mode value prev_mode of the previous macroblock, the maximum optimal coding prediction mode value curr_mode of the current macroblock is 7. Therefore, only 3 bits of data and 1 bit of mark bit "0" need to be encoded.
[0048] In the above step (44), the optimal coding prediction mode value curr_mode of the current macroblock ranges from 1 to 8. Since it is greater than the optimal coding prediction mode value prev_mode of the previous macroblock, it cannot be less than 1. If the optimal coding prediction mode value curr_mode of the current macroblock is less than 8, the data bit value code_val (curr_mode-1) is less than 7, and 3 bits of data bits are sufficient. If the optimal coding prediction mode value curr_mode of the current macroblock is equal to 8, since the data bit value code_val is 7 (curr_mode-1), 3 bits are still sufficient, so only 3 bits of data bits and 1 bit of mark bit "0" need to be encoded.
[0049] At the decoding end, corresponding to the encoding end, decoding the optimal coding prediction mode includes the following steps: (51) Initialize the optimal coding prediction mode value prev_mode of the previous macroblock, and the initial value is consistent with the encoding end; (52) If the flag bit mode_is_equal_flag of the prediction mode field is 1, the optimal coding prediction mode value curr_mode of the current macroblock is set to be equal to the optimal coding prediction mode value prev_mode of the previous macroblock; otherwise, proceed to step (53); (53) If the data bit value code_val is greater than the optimal coding prediction mode value prev_mode of the previous macroblock, the optimal coding prediction mode value curr_mode of the current macroblock is set to the data bit value code_val+1; otherwise, proceed to step (54); (54) Let the optimal coding prediction mode value curr_mode of the current macroblock be the value of the data bit code_val.
[0050] That is, the present invention can encode the nine coding prediction modes in the selection mode using only 4 bits (including the flag bit), and can also be effectively decoded at the decoding end.
[0051] The present invention only takes the coding prediction of 4x4 macroblocks as an example. The method of the present invention is still applicable to macroblocks of other sizes, such as 8x8. The only difference is that the total number of macroblocks in each image is different.
[0052] The preferred embodiments of the present invention are described in detail above. However, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all fall within the scope of protection of the present invention.
Claims
1. A method for selecting an image coding prediction mode, characterized in that: The method comprises the following steps: (1) Preset a number of coding prediction modes, each of which corresponds to a set of reference sample values, and a macroblock prediction value can be obtained based on the reference sample values; (2) Selecting a fixed number of coding prediction modes according to the coding scenario as a selection set of coding prediction modes for the corresponding scenario; (3) For the current macroblock, select the optimal coding prediction mode according to the macroblock prediction values corresponding to each coding prediction mode in the selection set; (4) Set the prediction mode field to place the optimal coding prediction mode value and send it to the decoding end along with the encoded bitstream.
2. The image coding prediction mode selection method according to claim 1, wherein: The coding prediction mode includes an intra-frame coding prediction mode, the intra-frame coding prediction mode includes a conventional intra-frame coding prediction mode and an isolated intra-frame coding prediction mode, the conventional intra-frame coding prediction mode includes the intra-frame coding prediction mode in H264, and the isolated intra-frame coding prediction mode calculates a reference sample value according to a pixel depth in the coding process.
3. The image coding prediction mode selection method according to claim 2, wherein: The coding prediction mode also includes an inter-frame coding prediction mode, in which the reference sample value of the current macroblock is the restored sample value at the corresponding position of the previous frame image.
4. The image coding prediction mode selection method according to claim 3, wherein: The coding scenarios include pure intra-frame scenarios and general scenarios; the pure intra-frame scenarios can only adopt a conventional intra-frame coding prediction mode, and the general scenarios can adopt an intra-frame coding prediction mode and an inter-frame coding prediction mode.
5. The image coding prediction mode selection method according to claim 4, characterized in that: The selection set of coding prediction modes in the pure intra-frame scenario only includes conventional intra-frame coding prediction modes.
6. The image coding prediction mode selection method according to claim 4, wherein: Determining the selection set of coding prediction modes in the general scenario includes the following steps: (21) Create an image dataset of pure intra-frame scenes. The size of the image dataset and the image pixel size are set according to the actual application; (22) Configuring network parameters, taking all conventional intra-frame coding prediction modes as a selection set of coding prediction modes, selecting the optimal coding prediction mode to encode the image data set, and calculating the first peak signal-to-noise ratio after decoding; (23) removing a certain conventional intra-frame coding prediction mode from the selection set, retaining the other conventional intra-frame coding prediction modes, and then selecting the optimal coding prediction mode from the remaining selection set to encode the image data set, and calculating the second peak signal-to-noise ratio after decoding; (24) comparing the first peak signal-to-noise ratio and the second peak signal-to-noise ratio in sequence, selecting the second peak signal-to-noise ratio that has the smallest difference from the first peak signal-to-noise ratio, and recording the corresponding removed conventional intra-frame coding prediction mode as a negligible conventional intra-frame coding prediction mode; (25) An isolated intra-frame coding prediction mode is used to replace an ignored conventional intra-frame coding prediction mode, thereby forming a selection set of coding prediction modes for intra-frame coding in general scenarios; an inter-frame coding prediction mode is used to replace an ignored conventional intra-frame coding prediction mode, thereby forming a selection set of coding prediction modes for inter-frame coding in general scenarios.
7. The image coding prediction mode selection method according to claim 6, wherein: The image frames in the general scenario include I frames and P frames, and intra-frame coding is used for I frame images; Inter-frame coding is used for P-frame images.
8. The image coding prediction mode selection method according to claim 6, wherein: The image frames in the general scenario adopt the GDR method, the intra-frame strips adopt intra-frame coding, and the inter-frame strips adopt inter-frame coding.
9. The image coding prediction mode selection method according to any one of claims 5 to 8, characterized in that: Selecting the optimal coding prediction mode in step (3) includes the following steps: (31) Input the location information of the current macroblock and the selection set of coding prediction modes in the corresponding scene; (32) For a conventional intra-frame coding prediction mode, a reference sample value corresponding to the coding prediction mode is obtained in the source image of the image frame where the current macroblock is located; (33) Obtaining the macroblock prediction value corresponding to each coding prediction mode in the selection set, and selecting the optimal coding prediction mode in the selection set according to a preset rule.
10. The image coding prediction mode selection method according to any one of claims 5 to 8, characterized in that: The prediction mode field in step (4) includes a flag bit and a data bit, and setting the prediction mode field to place the optimal coding prediction mode value includes the following steps: (41) Initialize the optimal coding prediction mode value of the previous macroblock; (42) If the optimal coding prediction mode value of the current macroblock is equal to the optimal coding prediction mode value of the previous macroblock, then the flag bit of the prediction mode field is set to 1 and the length of the prediction mode field is set to 1; otherwise, proceed to step (43); (43) If the optimal coding prediction mode value of the current macroblock is less than the optimal coding prediction mode value of the previous macroblock, the flag bit of the prediction mode field is set to 0, the value of the data bit is the optimal coding prediction mode value of the current macroblock, and the length of the prediction mode field is 4; otherwise, proceed to step (44); (44) Let the mark bit of the prediction mode field be 0, the value of the data bit be the optimal coding prediction mode value of the current macroblock minus 1, and the length of the prediction mode field be 4.
Citation Information
Patent Citations
Image encoding method
CN109561304A
Device for encoding moving image, method of controlling the same, and program
JP2011041014A
Video coding device, video coding method, video coding program, and computer-readable recording medium
WO2012141221A1
Cited By
Image coding method and error code stream substitution method
CN121037578A
Image coding prediction mode selection method
WO2026124129A1