A method for selecting a prediction mode in image coding
By pre-setting a set of encoding prediction modes and selecting the optimal encoding prediction mode in image coding, the problems of low image coding compression efficiency and high resource consumption in the prior art are solved, and efficient image coding with low hardware cost is achieved.
Patent Information
- Application Number
- CN202511277999.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-09
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2045-09-09
AI Technical Summary
Existing image coding methods fail to fully utilize redundant image information, resulting in low compression efficiency. Furthermore, video coding consumes a lot of resources, has high latency, and a large error propagation range in low-hardware-cost scenarios.
Several preset coding prediction modes are adopted, and a fixed number of coding prediction mode sets are selected according to the coding scenario. The optimal coding prediction mode is selected through intra-frame and inter-frame coding prediction modes, and the optimal coding prediction mode value is sent in the coding bitstream. Image coding is performed using absolute reference sample values and recovered sample values.
It improves the compression efficiency of image coding, reduces resource consumption and latency, avoids error propagation, and enhances image quality stability.
Smart Images

Figure CN120769037B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image coding, in particular to a method for selecting a prediction mode in image coding. BACKGROUND
[0002] The conventional image coding methods such as JPEG, JPEG 2000 and JPEG XS in the prior art are simple in implementation, but simple in prediction, without prediction or using only the data of the adjacent blocks above the current block for prediction, without making full use of the redundancy information of the image, resulting in low compression efficiency of the image.
[0003] Although the video coding such as H264 makes use of the redundancy information of the image and has multiple prediction modes, it still has some problems, such as the inter-frame prediction involving motion estimation and being complex in implementation and consuming more resources, and the selection of the current macroblock prediction mode requiring the use of the reference samples after the recovery of the current frame, resulting in high delay, and in the case of poor local recovery of the coded image, i.e. poor recovery of the current macroblock, the macroblock taking the current macroblock as a reference is likely to be affected, resulting in error propagation and expansion of the error influence range. SUMMARY
[0004] In view of the above, in view of the deficiencies in the prior art, the present application provides a method for selecting a prediction mode in image coding, which can reduce the coding delay and improve the compression efficiency of image coding in a low hardware cost application scenario.
[0005] In order to solve the above problems, the method for selecting a prediction mode in image coding of the present application comprises the following steps:
[0006] (1) presetting a plurality of coding prediction modes, each coding prediction mode corresponding to a set of reference sample values, from which a macroblock prediction value can be obtained;
[0007] (2) selecting a fixed number of coding prediction modes as a selection set of coding prediction modes in the corresponding scene according to the coding scene;
[0008] (3) selecting an optimal coding prediction mode according to the macroblock prediction value corresponding to each coding prediction mode in the selection set for the current macroblock;
[0009] (4) setting a prediction mode field to place the value of the optimal coding prediction mode and sending it to the decoding end together with the coded bitstream.
[0010] 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 the reference sample value according to the pixel depth in the coding process.
[0011] wherein the encoding prediction mode further comprises an inter-frame encoding prediction mode, and the reference sample value of the current macroblock in the inter-frame encoding prediction mode is the restored sample value at the corresponding position of the previous image frame.
[0012] wherein the encoding scene comprises a pure intra-frame scene and a general scene; the pure intra-frame scene can only adopt the conventional intra-frame encoding prediction mode, and the general scene can adopt the intra-frame encoding prediction mode and the inter-frame encoding prediction mode.
[0013] wherein the step of determining the selection set of the encoding prediction mode in the general scene comprises the following steps:
[0014] (21) creating an image data set of a pure intra-frame scene, and the size of the image data set and the pixel size of the image are set according to actual application;
[0015] (22) configuring network parameters, taking all the conventional intra-frame encoding prediction modes as the selection set of the encoding prediction mode, selecting the optimal encoding prediction mode to encode the image data set, and calculating the first peak signal-to-noise ratio after decoding;
[0016] (23) removing a certain conventional intra-frame encoding prediction mode in the selection set, and retaining other conventional intra-frame encoding prediction modes, and then selecting the optimal encoding prediction mode in the remaining selection set to encode the image data set, and calculating the second peak signal-to-noise ratio after decoding;
[0017] (24) comparing the first peak signal-to-noise ratio with the second peak signal-to-noise ratio in turn, selecting the second peak signal-to-noise ratio with the smallest difference from the first peak signal-to-noise ratio, and recording the corresponding removed conventional intra-frame encoding prediction mode as a negligible conventional intra-frame encoding prediction mode;
[0018] (25) replacing the negligible conventional intra-frame encoding prediction mode with an isolated intra-frame encoding prediction mode to form the selection set of the encoding prediction mode in the intra-frame encoding of the general scene; and replacing the negligible conventional intra-frame encoding prediction mode with an inter-frame encoding prediction mode to form the selection set of the encoding prediction mode in the inter-frame encoding of the general scene.
[0019] wherein the step (3) of selecting the optimal encoding prediction mode comprises the following steps:
[0020] (31) inputting the position information of the current macroblock and the selection set of the encoding prediction mode in the corresponding scene;
[0021] (32) for the conventional intra-frame encoding prediction mode, obtaining the reference sample value corresponding to the encoding prediction mode in the source image of the image frame where the current macroblock is located;
[0022] (33) obtaining the macroblock prediction value corresponding to each encoding prediction mode in the selection set, and selecting the optimal encoding prediction mode in the selection set according to a preset rule.
[0023] In step (4), the prediction mode field comprises a mark bit and a data bit, and the prediction mode field is set to place the optimal encoding prediction mode value, comprising the following steps:
[0024] (41) initializing the optimal encoding prediction mode value of the previous macroblock;
[0025] (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 mark 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;
[0026] (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 mark 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;
[0027] (44) the mark 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.
[0028] Compared with the prior art, the present application has the following advantages:
[0029] By presetting several encoding prediction modes, in addition to obtaining the reference sample value according to the current image, the absolute reference sample value and the restored sample value of the reference image are also used as the reference sample value, the image redundancy information is effectively utilized, the compression efficiency is improved, the absolute reference sample value can block and isolate the local block, effectively avoiding error propagation, 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, which can reduce the bit occupied by the encoding prediction mode and save the code stream; further optimizing the prediction mode selection, for the regular intra-frame encoding prediction mode, the reference sample value corresponding to the encoding prediction mode is obtained in the source image where the current macroblock is located, and then the optimal encoding prediction mode is selected in the selection set according to the macroblock prediction value, which reduces resource consumption and delay, and even in the case of low cost, high encoding efficiency and good subjective effect can be achieved. BRIEF DESCRIPTION OF DRAWINGS
[0030] Figure 1 is a flowchart of the image encoding prediction mode selection method in the present application;
[0031] Figure 2 is a schematic diagram of the encoding prediction mode set in the present application,Figure 2 (a) is a schematic diagram of a regular intra coding prediction mode model_0; Figure 2 (b) is a schematic diagram of a regular intra coding prediction mode model_1; Figure 2 (c) is a schematic diagram of a regular intra coding prediction mode model_2; Figure 2 (d) is a schematic diagram of a regular intra coding prediction mode model_3; Figure 2 (e) is a schematic diagram of a regular intra coding prediction mode model_4; Figure 2 (f) is a schematic diagram of a regular intra coding 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;
[0032] Figure 3 is a schematic diagram of image frame distribution in a general scenario;
[0033] Figure 4 is another schematic diagram of image frame distribution in a general scenario;
[0034] Figure 5 is a schematic diagram of a flow of selecting an optimal coding prediction mode in the present application. DETAILED DESCRIPTION
[0035] The present application will be further described below in connection with embodiments.
[0036] In the image coding process, coding prediction is generally performed in units of macroblocks, and the selection of coding prediction modes in the coding prediction process affects the stability of image quality, coding efficiency and compression efficiency. The present application improves the selection of image coding prediction modes, which can save code streams, improve coding compression performance, and achieve higher coding efficiency and better subjective effect for FPGA or low hardware cost implementation scenarios.
[0037] As shown in Figure 1 the image coding prediction mode selection method in the present application includes the following steps:
[0038] (1) a plurality of coding prediction modes are preset, each coding prediction mode corresponds to a set of reference sample values, and a macroblock prediction value can be obtained according to the reference sample values;
[0039] (2) According to the coding scene, a fixed number of coding prediction modes are selected as a selection set of coding prediction modes under the corresponding scene;
[0040] (3) For the current macroblock, the optimal coding prediction mode is selected according to the macroblock prediction value corresponding to each coding prediction mode in the selection set;
[0041] (4) The prediction mode field is set to place the optimal coding prediction mode value, and is sent to the decoding end together with the coding code stream.
[0042] The above steps will be described in detail below in combination with specific embodiments.
[0043] In the present application, image coding includes intra-frame coding and inter-frame coding. Intra-frame coding encodes the macroblock only through intra-frame coding prediction; inter-frame coding encodes the macroblock through inter-frame coding prediction. Intra-frame coding prediction and inter-frame coding prediction are mainly distinguished by the reference sample value corresponding to the coding prediction mode. Intra-frame coding prediction refers to the process of using the recovered sample value of the current frame to predict the generation of the current macroblock; inter-frame coding prediction refers to the process of using the recovered sample value of the reference image (i.e. the previous frame) as the reference sample value to predict the generation of the current macroblock. For ease of description, the present application will refer to the coding prediction mode using 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 using the recovered sample value of the corresponding position of the previous frame image as the reference sample value as the inter-frame coding prediction mode.
[0044] Setting of coding prediction mode
[0045] As shown in Figure 2 , in the present application, 11 coding prediction modes are set for the coding prediction of 4x4 macroblocks, including intra-frame coding prediction modes and inter-frame coding prediction modes, wherein the intra-frame coding prediction modes include conventional intra-frame coding prediction modes model_0 to model_8 and isolated intra-frame coding prediction mode model_9; the above conventional coding prediction modes model_0 to model_8 are the same as the intra_4x4 intra-frame prediction mode in H264, and the corresponding sample reference values are as follows.
[0046] The 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 prediction value pred4x4 L [x, y],x, y = 0..3 is calculated as follows:
[0047] pred4x4 L[x, y] = p[x,-1], x, y = 0..3.
[0048] The regular intra coding prediction mode model_1 (Horizontal) predicts the current macroblock using the sample values to the left of the current macroblock as sample reference values. Let the values to the left of the current macroblock be p[-1, y], y = 0..3, the prediction value pred4x4 L [x, y], x, y = 0..3, is obtained as follows:
[0049] pred4x4 L [x, y] = p[-1, y] x,y = 0..3.
[0050] The regular intra coding prediction mode model_2 (DC) predicts the current macroblock using the average of the sample values to the left of the current macroblock as sample reference value. Let the average of the values to the left of the current macroblock be p[-1, y], y = 0..3, the prediction value pred4x4 L [x, y], x, y = 0..3, is obtained as follows:
[0051] pred4x4 L [x, y] = ( p[0,-1]+p[1,-1]+p[2,-1]+p[3,-1]+
[0052] p[-1, 0]+p[-1, 1]+p[-1, 2]+p[-1, 3]+4 )>>3.
[0053] The regular intra coding prediction mode model_3 (Diagonal Down-Left) predicts the current macroblock using the sample values to the left and below of the current macroblock as sample reference values. Let the values to the left and below of the current macroblock be p[x, y], x, y = 0..3, the prediction value pred4x4 L [x, y], x, y = 0..3, is obtained as follows:
[0054] If x is equal to 3 and y is equal to 3,
[0055] pred4x4 L [x, y] = ( p[6,-1]+3 * p[7,-1]+2 )>>2;
[0056] Else (neither x nor y is equal to 3)
[0057] pred4x4 L [x, y] = ( p[x+y,-1]+2 * p[x+y+1,-1]+p[x+y+2,-1]+2 )>>2.
[0058] The regular intra coding prediction mode model_4 (Diagonal Down-Right) predicts the current macroblock using the sample values to the left and above of the current macroblock as sample reference values. Let the values to the left and above of the current macroblock be p[x, y], x, y = 0..3, the prediction value pred4x4 L[x, y], x, y = 0..3 are obtained as follows:
[0059] If x is greater than y, then
[0060] pred4x4 L [x, y] = ( p[x- y-2,-1]+2 * p[x- y-1,-1]+p[x-y,-1]+2 )>>2,
[0061] Otherwise, if x is less than y
[0062] pred4x4 L [x, y] = ( p[-1, y- x- 2]+2 * p[-1, y- x- 1]+p[-1, y- x]+2 )>>2,
[0063] Otherwise (x is equal to y)
[0064] pred4x4 L [x, y] = ( p[0,-1]+2 * p[-1,-1]+p[-1, 0]+2 )>>2.
[0065] The regular intra coding prediction mode model_5 (Vertical-Right), with zVR=2*x-y, the current macroblock prediction value pred4x4 L [x, y], x, y = 0..3 are obtained as follows:
[0066] If zVR is equal to 0, 2, 4 or 6, then
[0067] pred4x4 L [x, y] = ( p[x- ( y>>1 )-1,-1]+p[x- ( y>>1 ),-1]+1 )>>1,
[0068] Otherwise, if zVR is equal to 1, 3 or 5, then
[0069] pred4x4 L [x, y] = ( p[x- ( y>>1 )-2,-1]+2 * p[x- ( y>>1 )- 1,-1]+p[x-( y>>1 ),-1]+2 )>>2,
[0070] Otherwise, if zVR is equal to -1, then
[0071] pred4x4 L [x, y] = ( p[-1, 0]+2 * p[-1,-1]+p[0,-1]+2 )>>2,
[0072] Otherwise (zVR equals -2 or -3),
[0073] pred4x4 L [x, y] = ( p[-1, y- 1]+2 * p[-1, y- 2]+p[-1, y- 3]+2 )>>2.
[0074] The regular intra coding prediction mode model_6 (Horizontal-Down), with zHD= 2 * y - x, the current macroblock prediction pred4x4L[x, y], x, y = 0..3 is obtained in the following way:
[0075] If zHD equals 0, 2, 4 or 6, then
[0076] pred4x4 L [x, y] = ( p[-1, y- ( x>>1 )- 1]+p[-1, y- ( x>>1 )]+1 )>>1,
[0077] Otherwise, if zHD equals 1, 3 or 5, then
[0078] pred4x4 L [x, y] = ( p[-1, y- ( x>>1 )- 2]+2 * p[-1, y- ( x>>1 )- 1]+p[-1, y- ( x>>1 )]+2 )>>2,
[0079] Otherwise, if zHD equals -1,
[0080] pred4x4 L [x, y] = ( p[-1, 0]+2 * p[-1,-1]+p[0,-1]+2 )>>2,
[0081] Otherwise (zHD equals -2 or -3), then
[0082] pred4x4 L [x, y] = ( p[x- 1,-1]+2 * p[x- 2,-1]+p[x- 3,-1]+2 )>>2.
[0083] The regular intra coding prediction mode model_7 (Vertical-Left), the current macroblock prediction value pred4x4 L [x,y], x, y = 0..3 is obtained in the following way:
[0084] if y is equal to 0 or 2,
[0085] pred4x4 L [x, y] = ( p[x+( y>>1 ),-1]+p[x+( y>>1 )+1,-1]+1)>>1,
[0086] else (y is equal to 1 or 3)
[0087] pred4x4 L [x,y]=(p[x+( y>>1 ),-1]+2 * p[x+( y>>1 )+1,-1]+p[x+( y>>1 )+2,-1]+2 )>>2.
[0088] The regular intra coding prediction mode model_8 (Horizontal-Up) with the variable zHU equal to x+2*y, the current macroblock prediction value pred4x4 L [x, y], x, y = 0..3 is obtained in the following way:
[0089] if zHU is equal to 0, 2 or 4,
[0090] pred4x4 L [x, y] = ( p[-1, y+( x>>1 )]+p[-1, y+( x>>1 )+1]+1 )>>1,
[0091] else if zHU is equal to 1 or 3,
[0092] pred4x4 L [x,y]=(p[-1,y+( x>>1 )]+2*p[-1, y+( x>>1 )+1]+p[-1, y+( x>>1 )+2]+2 )>>2,
[0093] else if zHU is equal to 5,
[0094] pred4x4 L [x, y] = ( p[-1, 2]+3 * p[-1, 3]+2 )>>2,
[0095] else (zHU is greater than 5)
[0096] pred4x4 L [x, y] = p[-1, 3].
[0097] The isolation intra-frame coding prediction mode model_9 (Fix Value) above predicts with a fixed value as the reference sample value. If the image to be coded is very complex and the network transmission bandwidth is limited, then in the coding process, a large QP (Quantization Parameter) is needed to meet the network bandwidth, and when the QP is large, the restored sample value will be relatively fuzzy, and the distortion will be relatively large. If the macro block is coded, the restored sample value with poor recovery is selected as the reference sample value, and the current block recovery is also poor, which will lead to error accumulation and unstable image quality. In the present application, the isolation intra-frame coding prediction mode model_9 is set, and the fixed value is used as the reference sample value to directly obtain the macro block prediction value, so that the recovery of the current macro block is not affected by the surrounding pixels no matter how well the surrounding pixels are recovered. And when the image is complex, the surrounding pixels are recovered (such as a random image), and the isolation intra-frame coding prediction mode model_9 is relatively easy to select.
[0098] The fixed value is calculated according to the pixel depth in the coding process, and the calculation method is fix_val = 1<<(depth-1), wherein fix_val is the fixed value, and depth is the pixel depth in the coding process. For example, if the pixel depth is 10 bits in the coding process, then fix_val is 512 (1<<9).
[0099] The symbol "<<" represents left shift, and ">>" represents right shift.
[0100] In the present application, based on the control of hardware cost, motion estimation is not performed, and the block data of the corresponding position of the previous frame is directly used to obtain the reference sample value, and the inter-frame coding prediction mode model_10 (Ref Blk) is set. That is, in the coding process, the inter-frame coding prediction mode model_10 directly obtains the macro block prediction value by taking the 4x4 restored sample value of the corresponding position of the reference frame, that is, the previous frame, as the reference sample value.
[0101] (2) Determine the selection set of the coding prediction mode according to the coding scene and the coding mode
[0102] The present application relates to two scenes, one of which can only use intra-frame coding, and in the present application, this kind of scene is marked as a pure intra-frame scene, and the second kind of scene can use both intra-frame coding and inter-frame coding, and is marked as a general scene.
[0103] In different scenes, the selection set of the coding prediction mode is limited to 9 kinds in the present application, which can save the code stream and improve the coding compression performance.
[0104] Pure intra-frame scenes can be applied in situations where hardware conditions are limited and DDR (Double Data Rate) is unavailable. The entire encoding process only uses the data of the current frame and involves only intra-frame coding modes. In this invention, the selection set of coding prediction modes for pure intra-frame scenes is set as follows: Figure 2 The nine modes in the conventional intra-frame coding prediction mode are model_0 to model_8.
[0105] For general scenarios, intra-frame coding and inter-frame coding are used. This invention relates to two general scenarios.
[0106] For general scenarios, determining the selection set of coding prediction modes includes the following steps:
[0107] (21) Create an image dataset of a pure intra-frame scene. The size of the image dataset and the image pixel size are set according to the specific application.
[0108] (22) Configure network parameters, use all regular intra-frame coding prediction modes model_0 to model_8 as the selection set of coding prediction modes, select the optimal coding prediction mode to encode the image dataset, and calculate the first peak signal-to-noise ratio (PSNR) after decoding.
[0109] (23) Remove a certain regular intra-frame coding prediction mode model_i (i=0,1,2,......,8) from the selection set, and retain the other coding prediction modes. Then, select the optimal coding prediction mode from the remaining coding prediction modes to encode the image dataset, and calculate the second peak signal-to-noise ratio (PSNR) after decoding. i ;
[0110] (24) Compare the first peak signal-to-noise ratio (PSNR) with the second peak signal-to-noise ratio (PSNR) in sequence. i Choose the second peak signal-to-noise ratio (PSNR) that has the smallest difference from the first PSNR. i Determine which conventional intra-frame coding prediction mode has the least impact on the first peak signal-to-noise ratio (PSNR) when replacing it, and denote the corresponding removed conventional intra-frame coding prediction mode model_i as the negligible conventional intra-frame coding prediction mode.
[0111] (25) Replace the ignorable regular intra-frame coding prediction mode with the isolated intra-frame coding prediction mode to form a selection set of coding prediction modes for intra-frame coding in general scenarios; replace the ignorable regular intra-frame coding prediction mode with the inter-frame coding prediction mode to form a selection set of coding prediction modes for inter-frame coding in general scenarios.
[0112] As an implementation, an image data set composed of 265 image data is created, including natural images, screen images, etc., the image size is 3840x2160, and the network bandwidth is 500 Mbps. The above parameters can be set according to actual needs. The general scene in the present application includes the following two modes.
[0113] As shown in Figure 3 , in the encoding process, the image frame is encoded once every fixed time, and the corresponding frame is marked as an I frame (intraframe frame, key frame). The remaining frames are encoded using interframe encoding, and are marked as P frames (forward predicted frames, forward reference frames). If the first peak signal-to-noise ratio PSNR is least affected by replacing the conventional intraframe encoding prediction mode model_8, it is a negligible conventional intraframe encoding prediction mode, and the conventional intraframe encoding prediction mode model_0 to model_7 and the isolated intraframe encoding prediction mode model_9 in Figure 2 are selected as the selection set for the I frame, and the conventional intraframe encoding prediction mode model_0 to model_7 and the interframe encoding prediction mode model_10 in Figure 2 are selected as the selection set for the P frame.
[0114] As shown in Figure 4 , the GDR mode (Gradual Decoding Refresh, gradual decoding refresh) is used, and each frame contains both intraframe and interframe encoding modes. Specifically, each frame is divided into n equal parts, and 1 part is selected for intraframe encoding, referred to as an intraframe strip, and the remaining parts are encoded using interframe encoding, referred to as an interframe strip. The second has the advantage that the size of each frame code stream is more uniform, which is helpful for network transmission. In this scenario, the intraframe strip uses intraframe encoding, and if the first peak signal-to-noise ratio PSNR is least affected by the conventional intraframe encoding prediction mode model_8, it is a negligible conventional intraframe encoding prediction mode. The conventional intraframe encoding prediction mode model_0 to model_7 and the isolated intraframe encoding prediction mode model_9 are selected as the selection set, the interframe strip uses interframe encoding, and the present application selects the conventional intraframe encoding prediction mode model_0 to model_7 and the interframe encoding prediction mode model_10 as the selection mode.
[0115] (3) Selecting the optimal encoding prediction mode in the selection set of encoding prediction modes
[0116] As shown in Figure 5 , the selection of the optimal encoding prediction mode needs to go through the following steps:
[0117] (31) inputting position information of the current macroblock and a selection set of encoding prediction modes in the corresponding scene;
[0118] (32) for a regular intra-frame encoding prediction mode, reference sample values corresponding to the encoding prediction mode are obtained in a source image of the image frame where the current macroblock is located; for an inter-frame encoding prediction mode, the reference sample values of the current macroblock still adopt the restored sample values in the corresponding position of the previous image frame; the reference sample values of the isolated intra-frame encoding prediction mode still adopt fixed values;
[0119] (33) obtaining macroblock prediction values corresponding to each encoding prediction mode in the selection set, and selecting the optimal encoding prediction mode in the selection set according to a preset rule.
[0120] The preset rule of the above step (33) is that: subtracting pixel components in the corresponding positions of the current macroblock and the macroblock prediction value, then taking the absolute value of the difference value to sum, taking the obtained value as an evaluation index, and taking the encoding prediction mode with the minimum value as the optimal encoding prediction mode, that is, SAD (sum of Absolute difference) of H264.
[0121] In the prior art, when the next macroblock selects the optimal encoding prediction mode, the reference sample values of each intra-frame encoding prediction mode need to use the image information decoded by the previous macroblock, that is, the next macroblock can use the image information decoded by the current macroblock to complete a new round of selection of the optimal encoding prediction mode after the current macroblock is processed by steps such as DCT, quantization, inverse quantization, IDCT, etc.
[0122] Compared with the prior art, although in the actual encoding process, the regular intra-frame prediction encoding mode in the present application still uses the restored sample values of the current frame as the reference sample values to predict and generate the current macroblock; the inter-frame encoding prediction still uses the restored sample values of the reference image (i.e. the previous frame) as the reference sample values to predict and generate the current macroblock. However, when selecting the optimal encoding prediction mode, the reference sample values of the regular intra-frame prediction encoding mode are directly obtained by using the source image information, so that after the optimal encoding prediction mode of the current macroblock is determined, the next macroblock can be directly processed, reducing the delay.
[0123] (4) encoding of the optimal encoding prediction mode
[0124] Considering that 9 encoding prediction modes are used, 3 bit data bits and 1 bit flag bit can be used to represent, but more than 9 modes must use 4 bits, so that the prediction mode of each macro block has one more bit, which will increase the encoding overhead. For example, a 3840x2160 image has 518400 4x4 macro blocks, and if the prediction mode of each block is encoded, the prediction algorithm with more than 9 modes will have 518400 more bits than 9 modes; if the network bandwidth is 500Mbps, 60 frames per second, and the average compression size of a 3840x2160 image is 8333333 bits, then 518400 bits occupy 6% of the code stream. In order to save the code stream, the less commonly used prediction mode is directly replaced, and finally 9 prediction modes are limited regardless of the scene.
[0125] In the present application, the prediction mode field is set to place the optimal encoding prediction mode value. For example, in the present application, the encoding prediction selection set includes 9 prediction encoding modes, the prediction mode field includes 1 bit flag bit and 3 bit data bit, and the length code_len of the prediction mode field is adjusted according to the size relationship between the optimal encoding prediction mode value of the current macro block and the optimal encoding prediction mode value of the last macro block, and the value is 1 or 4. Specifically, the encoding of the optimal encoding prediction mode includes the following steps:
[0126] (41) initialize the optimal encoding prediction mode value prev_mode of the last macro block;
[0127] (42) if the optimal encoding prediction mode value curr_mode of the current macro block is equal to the optimal encoding prediction mode value prev_mode of the last macro block, the flag bit mode_is_equal_flag of the prediction mode field is 1, and the length code_len of the prediction mode field is 1; otherwise, step (43) is entered;
[0128] (43) if the optimal encoding prediction mode value curr_mode of the current macro block is less than the optimal encoding prediction mode value prev_mode of the last macro block, the flag bit mode_is_equal_flag of the prediction mode field is 0, the value code_val of the data bit is the optimal encoding prediction mode value curr_mode of the current macro block, and the length code_len of the prediction mode field is 4; otherwise, step (44) is entered;
[0129] (44) the flag bit mode_is_equal_flag of the prediction mode field is 0, the value code_val of the data bit is the optimal encoding prediction mode value curr_mode-1 of the current macro block, and the length code_len of the prediction mode field is 4.
[0130] The value range of the optimal encoding prediction mode value prev_mode of the previous macroblock in the step (43) is 0~8. Since the optimal encoding prediction mode value curr_mode of the current macroblock is less than the optimal encoding prediction mode value prev_mode of the previous macroblock, the optimal encoding prediction mode value curr_mode of the current macroblock is at most 7. Therefore, only 3 bits of data and 1 bit of mark "0" need to be encoded.
[0131] The value of the optimal encoding prediction mode value curr_mode of the current macroblock in the step (44) is 1~8, which is greater than the optimal encoding prediction mode value prev_mode of the previous macroblock. Therefore, it is impossible to be less than 1. If the optimal encoding prediction mode value curr_mode of the current macroblock is less than 8, the value code_val (curr_mode-1) of the data bit is less than 7, and 3 bits of data are enough. If the optimal encoding prediction mode value curr_mode of the current macroblock is equal to 8, the value code_val of the data bit is 7 (curr_mode-1), and 3 bits are still enough. Therefore, only 3 bits of data and 1 bit of mark "0" need to be encoded.
[0132] At the decoding end, the optimal encoding prediction mode is decoded, including the following steps:
[0133] (51) The optimal encoding prediction mode value prev_mode of the previous macroblock is initialized, and the initial value is consistent with that of the encoding end.
[0134] (52) If the mark bit mode_is_equal_flag of the prediction mode field is 1, the optimal encoding prediction mode value curr_mode of the current macroblock is equal to the optimal encoding prediction mode value prev_mode of the previous macroblock. Otherwise, step (53) is entered.
[0135] (53) If the value code_val of the data bit is greater than the optimal encoding prediction mode value prev_mode of the previous macroblock, the optimal encoding prediction mode value curr_mode of the current macroblock is set to the value code_val+1 of the data bit. Otherwise, step (54) is entered.
[0136] (54) The optimal encoding prediction mode value curr_mode of the current macroblock is set to the value code_val of the data bit.
[0137] That is, the present application can encode 9 encoding prediction modes in the selection mode by using only 4 bits (including the mark bit), and the decoding end can also be effectively decoded.
[0138] In the present application, only the coding prediction of 4x4 macroblocks is taken as an example. The present application 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.
[0139] The preferred embodiments of the present application are described in detail above, but the present application is not limited to the specific details of the above-described embodiments. Within the technical concept of the present application, various equivalent transformations of the technical solutions of the present application can be made, and these equivalent transformations all belong to the protection scope of the present application.
Claims
1. A method for selecting an image coding prediction mode, characterized in that, The method includes the following steps: (1) Several coding prediction modes are preset, each coding prediction mode corresponds to a set of reference sample values, and macroblock prediction values can be obtained based on the reference sample values; (2) Select a fixed number of coding prediction modes as the selection set of coding prediction modes for the corresponding coding scenario; the coding prediction modes include intra-frame coding prediction modes, which include regular intra-frame coding prediction modes and isolated intra-frame coding prediction modes; the coding scenario includes pure intra-frame scenarios and general scenarios, and the general scenarios can adopt intra-frame coding prediction modes. (3) For the current macroblock, select the optimal coding prediction mode based on the macroblock prediction value corresponding to each coding prediction mode in the selection set; (4) Set the prediction mode field to place the optimal encoding prediction mode value and send it to the decoding end along with the encoded bitstream; The step (2) of determining the selection set of coding prediction modes in the general scenario includes the following steps: (21) Create an image dataset of a pure intra-frame scene. The size of the image dataset and the image pixel size are set according to the specific application. (22) Configure network parameters, use all regular intra-frame coding prediction modes as the selection set of coding prediction modes, select the optimal coding prediction mode to encode the image dataset, and calculate the first peak signal-to-noise ratio after decoding. (23) Remove a certain regular intra-frame coding prediction mode from the selection set, retain other regular intra-frame coding prediction modes, and then select the optimal coding prediction mode from the remaining selection set to encode the image dataset and calculate the second peak signal-to-noise ratio after decoding. (24) Compare the first peak signal-to-noise ratio and the second peak signal-to-noise ratio in turn, select the second peak signal-to-noise ratio that is least different from the first peak signal-to-noise ratio, and denote the corresponding removed conventional intra-frame coding prediction mode as the negligible conventional intra-frame coding prediction mode. (25) Replace the ignorable regular intra-frame coding prediction mode with an isolated intra-frame coding prediction mode to form a selection set of coding prediction modes for intra-frame coding in general scenarios.
2. The image coding prediction mode selection method according to claim 1, characterized in that, The conventional intra-frame coding prediction mode includes the intra-frame coding prediction mode in H.264, and the isolated intra-frame coding prediction mode calculates the reference sample value based on the pixel depth during the coding process.
3. The image coding prediction mode selection method according to claim 1, characterized in that, The coding prediction mode also includes an inter-frame coding prediction mode, in which the reference sample value of the current macroblock is the recovered sample value at the corresponding position in the previous frame image.
4. The image coding prediction mode selection method according to claim 3, characterized in that, The general scenario can also use the inter-frame coding prediction mode. In step (25), the inter-frame coding prediction mode is used to replace the ignorable conventional intra-frame coding prediction mode, forming a selection set of coding prediction modes for inter-frame coding in the general scenario.
5. The image coding prediction mode selection method according to claim 4, characterized in that, 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.
6. The image coding prediction mode selection method according to claim 4, characterized in that, In the general scenario, the image frames use GDR (Geometric Rendering), with intra-frame bars using intra-frame coding and inter-frame bars using inter-frame coding.
7. The image coding prediction mode selection method according to claim 1, characterized in that, The pure intra-frame scene can only use the conventional intra-frame coding prediction mode, and the selection set of coding prediction modes in the pure intra-frame scene only includes the conventional intra-frame coding prediction mode.
8. The image coding prediction mode selection method according to any one of claims 1 to 7, characterized in that, Step (3) involves selecting the optimal coding prediction mode, including the following steps: (31) Input the current macroblock location information and the selection set of coding prediction modes in the corresponding scenario; (32) For the conventional intra-frame coding prediction mode, obtain the reference sample value corresponding to the coding prediction mode in the source image of the image frame where the current macroblock is located; (33) Obtain the macroblock prediction value corresponding to each coding prediction mode in the selection set, and select the optimal coding prediction mode in the selection set according to the preset rules.
9. The image coding prediction mode selection method according to any one of claims 1 to 7, characterized in that, The prediction mode field mentioned in step (4) includes a marker bit and a data bit. Setting the prediction mode field to place the optimal encoded 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 set the flag bit of the prediction mode field to 1 and set the length of the prediction mode field 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, then set the flag bit of the prediction mode field to 0, the value of the data bit to the optimal coding prediction mode value of the current macroblock, and the length of the prediction mode field to 4; otherwise, proceed to step (44). (44) Set the flag bit of the prediction mode field to 0, the value of the data bit to the optimal coding prediction mode value of the current macroblock minus 1, and the length of the prediction mode field to 4.
Citation Information
Patent Citations
Device for encoding moving image, method of controlling the same, and program
JP2011041014A