Image coding method and device, electronic equipment, chip and medium
By dividing images and calculating errors, target encoding parameters are determined, and the problem of inaccurate estimates of the number of encoding bits in the prior art is solved, and compression efficiency and image quality are improved.
Patent Information
- Application Number
- CN202311028091.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-15
- Publication Date
- 2025-02-21
AI Technical Summary
The estimate of the number of coded bits in the prior art is inaccurate, resulting in lower compression efficiency and image quality.
By dividing the input image, obtaining the image block and its encoding parameters, determining the absolute error of the image block and the target encoding parameters, and quantizing the encoding based on these parameters.
Improves the accuracy of the number of coded bits, improves compression efficiency and image quality.
Smart Images

Figure CN119496904A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of digital image processing, and in particular to an image encoding method, device, electronic device, chip and medium. Background Art
[0002] In daily life, the amount of digitized image data is too large. At the same time, the growth of image demand now exceeds the limit of network bandwidth. There is a lot of redundant data, which is very difficult to store, transmit and process. Therefore, image compression can be used to remove these redundancies to reduce the number of bits required to represent data, thereby reducing the space occupied by the image. At present, most image compression technologies use random access (Random Access) encoding. Random access is a data access method that accesses data according to their location in the memory as a location identifier. When using random access, there is no need to read the previous data in a specific order, but only to access the specified location to quickly access the required data.
[0003] However, the related art only considers the sum of the absolute values of the gradients for encoding, or requires additional storage of the location information of the compressed data to be transmitted in addition to the compressed data. There is less reference data information, which will lead to inaccurate estimation of the number of coding bits, resulting in low compression efficiency and low image quality after compression. Summary of the invention
[0004] The present disclosure provides an image encoding method, device, electronic device, chip and medium to solve the problem of inaccurate estimation of the number of encoding bits in the related art, resulting in low compression efficiency and low quality of the compressed image.
[0005] A first aspect embodiment of the present disclosure proposes an image encoding method, which includes: dividing an input image to obtain a first image block and a first encoding parameter of the first image block; determining the absolute error sum of a second image block in the first image block; determining a target encoding parameter of the second image block based on the absolute error sum and the first encoding parameter; determining a first quantization parameter based on the target encoding parameter, and encoding the second image block using the first quantization parameter.
[0006] In some embodiments of the present disclosure, determining the sum of absolute errors of a second image block in a first image block includes: dividing the first image block according to a preset size to determine the second image block; determining the pixel value of each pixel in the second image block; determining the sum of absolute errors of the second image block based on the pixel value and the predicted pixel value, wherein the predicted pixel value is the pixel value in a third image block after encoding and reconstruction, and the sum of absolute errors is the sum of the absolute values of the differences between the pixel value and the predicted pixel value.
[0007] In some embodiments of the present disclosure, determining the target coding parameter of the second image block based on the absolute error sum and the first coding parameter includes: determining the second coding parameter and the third coding parameter of the second image block, the second coding parameter and the third coding parameter being used to control the range of the target coding parameter; determining the fourth coding parameter of the second image block based on the first coding parameter and the number of second image blocks in the first image block; determining the fifth coding parameter based on the absolute error sum of the second image block; determining the sixth coding parameter based on the position information of the second image block in the first image block; and determining the target coding parameter based on the second coding parameter, the third coding parameter, the fourth coding parameter, the fifth coding parameter and the sixth coding parameter.
[0008] In some embodiments of the present disclosure, based on the second coding parameter, the third coding parameter, the fourth coding parameter, the fifth coding parameter and the sixth coding parameter, determining the target coding parameter includes: adding the second coding parameter, the third coding parameter, the fourth coding parameter, the fifth coding parameter and the sixth coding parameter to obtain a statistical value; based on the statistical value, determining the seventh coding parameter; judging the size of the seventh coding parameter and the third coding parameter to determine the target coding parameter.
[0009] In some embodiments of the present disclosure, judging the size of the seventh coding parameter and the third coding parameter and determining the target coding parameter includes: if the seventh coding parameter is smaller than the third coding parameter, determining the seventh coding parameter as the target coding parameter.
[0010] In some embodiments of the present disclosure, judging the size of the seventh coding parameter and the third coding parameter and determining the target coding parameter includes: if the seventh coding parameter is greater than or equal to the third coding parameter, determining the third coding parameter as the target coding parameter.
[0011] In some embodiments of the present disclosure, based on a target coding parameter, a first quantization parameter is determined, and encoding the second image block using the first quantization parameter includes: determining multiple quantization parameters in a first quantization parameter set for the second image block; encoding the second image block using the multiple quantization parameters respectively, taking the quantization parameter corresponding to the eighth coding parameter as the first quantization parameter, the eighth coding parameter being less than or equal to the target coding parameter; encoding the second image block using the first coding parameter.
[0012] In some embodiments of the present disclosure, the method also includes: encoding the second image block through the first quantization parameter to determine a ninth encoding parameter; based on the ninth encoding parameter, determining an actual encoding parameter of the first image block; if the actual encoding parameter is smaller than the first encoding parameter, padding the actual encoding parameter so that the size of the actual encoding parameter is the same as the size of the first encoding parameter.
[0013] A second aspect embodiment of the present disclosure proposes an image encoding device, which includes: an acquisition unit, used to divide an input image, obtain a first image block and a first encoding parameter of the first image block; a first determination unit, used to determine the absolute error sum of the second image block in the first image block; a second determination unit, used to determine a target encoding parameter of the second image block based on the absolute error sum and the first encoding parameter; a third determination unit, used to determine a first quantization parameter based on the target encoding parameter, and encode the second image block using the first quantization parameter.
[0014] In some embodiments of the present disclosure, the first determination unit 520 is used to: divide the first image block to determine the second image block; determine the pixel value of each pixel in the second image block; and determine the absolute error sum of the second image block based on the pixel value.
[0015] In some embodiments of the present disclosure, the second determination unit 530 is used to: determine a second encoding parameter and a third encoding parameter of the second image block, the second encoding parameter and the third encoding parameter are used to control the range of the target encoding parameter; determine a fourth encoding parameter of the second image block based on the first encoding parameter and the number of second image blocks in the first image block; determine a fifth encoding parameter based on the absolute error sum of the second image block; determine a sixth encoding parameter based on position information of the second image block in the first image block; and determine the target encoding parameter based on the second encoding parameter, the third encoding parameter, the fourth encoding parameter, the fifth encoding parameter and the sixth encoding parameter.
[0016] In some embodiments of the present disclosure, the second determination unit 530 is used to: add the second coding parameter, the third coding parameter, the fourth coding parameter, the fifth coding parameter and the sixth coding parameter to obtain a statistical value; determine the seventh coding parameter based on the statistical value; judge the size of the seventh coding parameter and the third coding parameter to determine the target coding parameter.
[0017] In some embodiments of the present disclosure, the second determination unit 530 is used to: if the seventh coding parameter is less than the third coding parameter, determine the seventh coding parameter as the target coding parameter; if the seventh coding parameter is greater than or equal to the third coding parameter, determine the third coding parameter as the target coding parameter.
[0018] In some embodiments of the present disclosure, the third determination unit 540 is used to: determine multiple quantization parameters in the first quantization parameter list of the second image block; encode the second image block using the multiple quantization parameters respectively, and use the quantization parameter corresponding to the eighth encoding parameter as the first quantization parameter, and the eighth encoding parameter is less than or equal to the target encoding parameter; encode the second image block using the first encoding parameter.
[0019] In some embodiments of the present disclosure, the third determination unit 540 is further used to: encode the second image block using the first quantization parameter to determine a ninth encoding parameter; determine an actual encoding parameter of the first image block based on the ninth encoding parameter; if the actual encoding parameter is smaller than the first encoding parameter, pad the actual encoding parameter so that the size of the actual encoding parameter is the same as the size of the first encoding parameter.
[0020] The third aspect embodiment of the present disclosure proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in the first aspect embodiment of the present disclosure.
[0021] The fourth aspect embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method described in the first aspect embodiment of the present disclosure.
[0022] The fifth aspect embodiment of the present disclosure proposes a chip, which includes one or more interface circuits and one or more processors; the interface circuit is used to receive signals from a memory of an electronic device and send signals to the processor, the signals including computer instructions stored in the memory, and when the processor executes the computer instructions, the electronic device executes the method described in the first aspect embodiment of the present disclosure.
[0023] In summary, according to the image coding method proposed in the present invention, the input image is divided to obtain a first image block and a first coding parameter of the first image block; the absolute error sum of the second image block in the first image block is determined; based on the absolute error sum and the first coding parameter, the target coding parameter of the second image block is determined; based on the target coding parameter, a first quantization parameter is determined, and the second image block is encoded by the first quantization parameter, so that the absolute error sum, relevant parameters of the first image block and the first coding parameter are fully utilized in the encoding process, the data information used in the encoding process is enriched, the target coding parameter is estimated by the enriched data information, and the estimation accuracy is improved. At the same time, encoding is performed by accurate target coding parameters to improve compression efficiency and compressed image quality.
[0024] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0026] Figure 1 A flowchart of an image encoding method provided by an embodiment of the present disclosure;
[0027] Figure 2 A flowchart of an image encoding method provided by an embodiment of the present disclosure;
[0028] Figure 3 A schematic diagram of a rate control algorithm provided by an embodiment of the present disclosure;
[0029] Figure 4 A schematic diagram of a specific image compression method supporting random access provided by an embodiment of the present disclosure;
[0030] Figure 5 A schematic diagram of the structure of an image encoding device provided by an embodiment of the present disclosure;
[0031] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure;
[0032] Figure 7 A schematic diagram of the structure of a chip provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0033] The embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions.
[0034] In daily life, the amount of digitized image data is too large. At the same time, the growth of image demand now exceeds the limitation of network bandwidth. There is a lot of redundant data, which is very difficult to store, transmit and process. Therefore, image compression can be used to remove these redundant data to reduce the number of bits required to represent data, thereby reducing the space occupied by the image. Image compression technology can be divided into two categories: lossy compression and lossless compression. Common lossy compression is JPEG compression based on discrete cosine transform (DCT). JPEG is a standard way to compress grayscale images and true color images. The JPEG compression process first divides the image into 8*8 sub-blocks, and performs DCT transformation, quantization, and entropy coding on each sub-block in order from left to right and from top to bottom. Lossless compression includes JPEG lossless compression. JPEG lossless is a standard added by the Joint Image Group in 1993 to achieve lossless compression of images. Its main content can be summarized as pixel-by-pixel prediction and entropy coding of the input image.
[0035] At present, most image compression technologies use random access encoding. Random access is a data access method that accesses data according to their location in the memory as a location identifier. The encoding method that supports random access usually divides the input image into sub-blocks of the same size. The length of the bitstream encoded for each sub-block is the same. The sub-blocks are encoded in sequence and written into the bitstream. Each sub-block is encoded independently without dependency. The decoder can randomly decode the sub-block at the desired position according to demand without decoding the entire image. Another method that supports random access divides the input image into sub-blocks. The encoding length of each sub-block is variable. The position of the encoded bitstream of each sub-block in the entire bitstream file is saved and transmitted together with the bitstream. The decoder can only decode each sub-block according to its position in the bitstream. This method also supports random decoding of sub-blocks at specific positions in the image.
[0036] Specifically, the compression method for images in the related art is to control the code stream of each line of the image to a set length. The decoding end can decode the corresponding code stream according to the specified line number. The encoding process is roughly as follows: the input single-line image is divided into macroblocks, and the cost of the macroblock, that is, the sum of absolute differences (SAD), is calculated by calculating the gradient of two adjacent pixels. The rate control will calculate the optimal quantization level based on the SAD using a virtual buffer model, and then calculate the encoding quantization level of the MB based on information such as the target number of bits, and perform encoding, that is, write the code stream. Alternatively, by encoding the data fragment into compressed data of variable size, and also saving the storage address and offset of the compressed data, the decoder decodes the corresponding data fragment according to the position and offset.
[0037] It can be seen that the related art adopts a row-level code control algorithm or stores additional location information of the transmitted compressed data when transmitting compressed data. The code control algorithm only considers the sum of absolute differences (SAD), and the sum of absolute differences is calculated by the sum of absolute values of gradients. There is less data information available for reference, which will lead to inaccurate estimation of the number of coding bits, or require additional storage of information other than the transmitted compressed data, resulting in low compression efficiency and low image quality after compression.
[0038] In order to solve the problems existing in the related art, the present disclosure proposes an image coding method, which divides the image into image blocks of the same size by encoding the image, and the same coding length is assigned to each image block, and the image block is divided into smaller sub-blocks, and a reasonable code rate control algorithm is designed to assign a reasonable coding length to each sub-block. The decoding end can randomly decode the corresponding sub-block according to the demand, and there is no need to decode the entire frame of the image. The code rate control algorithm can effectively ensure that the sub-block coding length does not exceed the specified length, and a reasonable coding bit length is assigned to sub-blocks with different content complexities, and the coding bits assigned to each sub-block are guaranteed to float within a reasonable range. In the code rate control algorithm, not only the absolute error and the position of the sub-block are considered, but also the absolute error and the prediction value are calculated by subtracting the pixel value from the prediction value, enriching the data information used in the coding process, and improving the accuracy of the estimated target coding parameters, thereby improving the compression efficiency and the quality of the compressed image, and reducing the image size as much as possible under acceptable visual damage, which is convenient for transmission and storage.
[0039] The method proposed in the present disclosure can be applied to application scenarios suitable for image encoding and decoding, and can also be applied to fields such as terminal photography, video recording and industrial camera imaging. Specifically, it can be applied to the process of image compression supporting random access, which is not limited in the embodiments of the present disclosure.
[0040] The image encoding method provided by the present application is described in detail below with reference to the accompanying drawings.
[0041] Figure 1 The following is a flowchart of an image encoding method provided by an embodiment of the present disclosure. Figure 1 As shown, the image encoding method includes steps 101-104.
[0042] Step 101: divide the input image into parts to obtain a first image block and a first encoding parameter of the first image block.
[0043] In an embodiment of the present disclosure, an input image is divided into multiple first image blocks, each of which has the same size and the same first encoding parameter. The specific size of the first image block can be set according to actual needs and is not limited in the embodiment of the present disclosure.
[0044] The first coding parameter refers to the number of coding bits allocated to each first image block according to the image compression rate. For example, the size of the first image block is 64*4, the input image is 10 bits, and the image compression rate is 0.7, then the first coding parameter is 64*4*10*0.7.
[0045] The image formats of the input images include but are not limited to YUV, RGB, and Bayer. The Bayer format is the original image inside the camera, which sets the values of the two missing sensors on the corresponding pixels to 0 and outputs a 3-channel color image. The RGB format represents the color image based on the principle of three primary colors, that is, each pixel of the color image is represented by a set of (R, G, B) values. Different values of these three components will present different colors. The YUV format represents the image brightness component and chromaticity component separately. YUV is divided into three components. Y represents brightness (Luminance or Luma), which is the grayscale value; U and V represent chromaticity (Chrominance or Chroma), which describes the hue and saturation of the image and is used to specify the color of the pixel.
[0046] Step 102: Determine the absolute error sum of the second image block in the first image block.
[0047] In an embodiment of the present disclosure, the second image block is obtained by dividing the first image block, wherein each second image block divided in the first image block has the same size, the size of the second image block is less than or equal to the first image block, and the second image block is divided according to a preset size, which may be a preset matrix size. The specific preset size is set based on actual needs and is not limited in the embodiment of the present disclosure.
[0048] The sum of absolute differences of the second image block refers to the sum of the absolute values of the differences between the pixel prediction values and the pixel values in the second image block, namely SAD (Sum of absolute differences), which is often used in image block matching. The absolute values of the differences between the corresponding values of each pixel are summed up, and reasonable target coding parameters are assigned to the second image block accordingly.
[0049] Step 103: Determine a target encoding parameter of the second image block based on the absolute error sum and the first encoding parameter.
[0050] In the embodiment of the present disclosure, the second coding parameter, the third coding parameter, the fourth coding parameter, the fifth coding parameter and the sixth coding parameter are determined according to the absolute error sum and the first coding parameter, and then the target coding parameter is calculated according to the above coding parameters. The second coding parameter, the third coding parameter, the fourth coding parameter, the fifth coding parameter and the sixth coding parameter are coding parameters required to calculate the target coding parameter, which are used to ensure that the coding parameter of the second image block does not exceed the specified length, and to allocate reasonable coding parameters to the second image blocks with different absolute error sums, that is, to ensure that the coding parameter allocated to each second image block floats within a reasonable range.
[0051] Step 104: determine a first quantization parameter based on the target encoding parameter, and encode the second image block using the first quantization parameter.
[0052] In an embodiment of the present disclosure, a first quantization parameter is determined according to the quantization parameters in the quantization parameter list and the target coding parameter, wherein the first quantization parameter refers to a coding parameter obtained by encoding the quantization parameters in the quantization parameter list which is less than or equal to the quantization parameter corresponding to the target coding parameter.
[0053] The current second image block is encoded according to the determined first quantization parameter.
[0054] In summary, according to the image coding method proposed in the present invention, the input image is divided to obtain a first image block and a first coding parameter of the first image block; the absolute error sum of the second image block in the first image block is determined; based on the absolute error sum and the first coding parameter, the target coding parameter of the second image block is determined; based on the target coding parameter, a first quantization parameter is determined, and the second image block is encoded by the first quantization parameter, so that the absolute error sum, relevant parameters of the first image block and the first coding parameter are fully utilized in the encoding process, the data information used in the encoding process is enriched, the target coding parameter is estimated by the enriched data information, and the estimation accuracy is improved. At the same time, encoding is performed by accurate target coding parameters to improve compression efficiency and compressed image quality.
[0055] based on Figure 1 The embodiment shown, Figure 2 The following further shows a flowchart of an image encoding method proposed in the present disclosure. Figure 2 based on Figure 1 In the embodiment shown, step 103 and step 104 are further defined. Figure 2 In the embodiment shown, step 103 includes step 203, step 204, step 205, and step 206, and step 104 includes step 207 and step 208. The method is applied to image coding scenarios, such as Figure 2 As shown, the method comprises the following steps:
[0056] Step 201: divide the input image into parts to obtain a first image block and a first encoding parameter of the first image block.
[0057] In an embodiment of the present disclosure, an input image is divided into first image blocks (Tile) of the same size, and each first image block is allocated the same first encoding parameter (tile_target_bits).
[0058] Step 202: Determine the absolute error sum of the second image block in the first image block.
[0059] In an embodiment of the present disclosure, the first image block is divided according to a preset size to determine the second image block; the pixel value of each pixel in the second image block is determined; based on the pixel value and the predicted pixel value, the absolute error sum of the second image block is determined, the predicted pixel value is the pixel value in the third image block after encoding and reconstruction, and the absolute error sum is the sum of the absolute values of the differences between the pixel value and the predicted pixel value. In the present disclosure, the absolute error sum is determined based on the pixel value and the predicted pixel value of the second image block; the third image block after encoding and reconstruction refers to the image block around the second image block that has been encoded and reconstructed, wherein reconstruction refers to the process of restoring the encoded data to the original image. The predicted pixel value is the pixel value of the third image block, that is, the pixel value in the encoded and reconstructed image block that is closest to the current pixel value of the second image block.
[0060] In an optional embodiment of the present disclosure, the input first image block is divided into second image blocks (MB, Micro Block) of the same size, and prediction processing is performed to calculate the absolute error sum (SAD, Sum of Absolute Differences) of the second image block through Formula 1, where the absolute error sum is the sum of the absolute values of the differences between each pixel value in the second image block and the predicted value.
[0061]
[0062] Where SAD represents the sum of absolute differences, pixel(i) represents the pixel value of the second image, pred(i) represents the predicted pixel value, and mb _ size represents the size of the second image block, and i represents the position of the pixel.
[0063] In the present disclosure, the absolute error sum is used to describe the content complexity of the second image block, and is used to allocate a reasonable number of bits to the second image block later, that is, to determine the target coding parameters. In other words, the larger the absolute error sum is, the higher the content complexity of the second image block is, and the more bits can be allocated.
[0064] Step 203: determine a second encoding parameter and a third encoding parameter of the second image block, where the second encoding parameter and the third encoding parameter are used to control the range of the target encoding parameter.
[0065] In an embodiment of the present disclosure, the second encoding parameter and the third encoding parameter of the second image block may be determined according to the bit width, compression rate, and absolute error of the input image, and the specific calculation method is not limited in the present disclosure.
[0066] The second coding parameter can be defined as the minimum number of coding bits (mb_min_bits), and the third coding parameter can be defined as the maximum number of coding bits (mb_max_bits), which are used to control the value of the target coding parameter to be within a reasonable range. It can be understood that the second coding parameter and the third coding parameter in the current first image block are the minimum value and the maximum value obtained by mathematical calculation, and the maximum value and the minimum value do not change in the current first image block.
[0067] Step 204: Determine a fourth encoding parameter of the second image block based on the first encoding parameter and the number of second image blocks in the first image block.
[0068] In an embodiment of the present disclosure, the fourth coding parameter can be defined as the average number of coding bits (mb_ave_bits). Because the encoding of the second image block in the present disclosure is performed according to a certain order, the number of encoded second image blocks and the first coding parameter encoded in the current first image block can be directly obtained by encoding the current second image block. The number of remaining unencoded second image blocks (mb_left_num) and the unencoded first coding parameter (tile_left_bits) can be obtained through the number of encoded second image blocks and the first coding parameter encoded in the current first image block. The fourth coding parameter is the ratio of the number of remaining unencoded second image blocks to the unencoded first coding parameter.
[0069] In an optional embodiment of the present disclosure, the average number of allocable bits of the current second image block is calculated by Formula 2:
[0070]
[0071] Wherein, mb_ave_bits represents the fourth coding parameter, i.e., the average number of bits that can be allocated. tile_left_bits represents the number of remaining usable bits of the current first image block, which is obtained by subtracting the number of encoded bits from the first coding parameter (tile_target_bits). mb_left_num represents the number of remaining unencoded second image blocks of the current first image block, which is obtained by subtracting the number of encoded second image blocks from the total number of second image blocks in the first image block.
[0072] Step 205: Determine a fifth encoding parameter based on the absolute error sum of the second image block.
[0073] In an embodiment of the present disclosure, the absolute error sum of the first image block is determined based on the absolute error sum of the second image block, in other words, the absolute error sum of the second image block in the first image block is added to obtain the absolute error sum of the first image block. The fifth encoding parameter is determined by the absolute error sum of the current second image block and the absolute error sum of the first image block of the current second image block.
[0074] In an optional embodiment of the present disclosure, a fifth encoding parameter, namely, risk bit number allocation, is determined according to the content complexity (SAD) of the current second image block:
[0075] sad_adv_mb_bits = function1(mb_sad,tile_sad) Formula 3
[0076] Among them, sad_adv_mb_bits represents the fifth coding parameter, mb_sad represents the absolute error sum of the current second image block, tile_sad represents the absolute error sum of the entire first image block, that is, the sum of the absolute error sums of all second image blocks in the first image block, and function1(,) represents the formula for calculating the fifth coding parameter based on the absolute error sum.
[0077] Step 206: Determine a sixth encoding parameter based on the position information of the second image block in the first image block.
[0078] In an embodiment of the present disclosure, the position information refers to the position identifier corresponding to the second image block in the first image block. The position identifier can specifically be a number. For example, the encoding order of multiple second image blocks in the first image block is 1, 2, and 3, and the current second image block is the second second image block, then the position information at this time is 2.
[0079] In an optional embodiment of the present disclosure, the sixth coding parameter is determined according to the position information of the current second image block in the first image block, that is, the secondary risk allocation. Risk allocation refers to the process of determining the sixth coding parameter by using the number of second image blocks and the position of the second image block in the first image block through a preset formula, as shown in Formula 4:
[0080] pos_adv_mb_bits = function2(mb_idx, mb_num) Formula 4
[0081] Among them, pos_adv_mb_bits represents the sixth coding parameter, mb_idx represents the position information of the current second image block in the entire first image block, mb_num represents the number of second image blocks contained in the current first image block, and function2(,) represents the formula for obtaining the sixth coding parameter using the position information.
[0082] Step 207: determine a target coding parameter based on the second coding parameter, the third coding parameter, the fourth coding parameter, the fifth coding parameter and the sixth coding parameter.
[0083] In the embodiment of the present disclosure, the second coding parameter, the third coding parameter, the fourth coding parameter, the fifth coding parameter and the sixth coding parameter are added to obtain a statistical value; based on the statistical value, the seventh coding parameter is determined; the size of the seventh coding parameter and the third coding parameter is judged to determine the target coding parameter. If the seventh coding parameter is less than the third coding parameter, the seventh coding parameter is determined to be the target coding parameter; if the seventh coding parameter is greater than or equal to the third coding parameter, the third coding parameter is determined to be the target coding parameter.
[0084] The statistical value refers to the sum of the coding parameters obtained by adding the second coding parameter, the third coding parameter, the fourth coding parameter, the fifth coding parameter and the sixth coding parameter, that is, the sum of the number of coding bits after the addition.
[0085] In an optional embodiment of the present disclosure, based on the above-determined coding parameters, the seventh coding parameter of the current second image block is determined by Formula 5, and the seventh coding parameter within a reasonable range is used as the target coding parameter:
[0086] mb_target_bits=(mb_min_bits+sad_adv_mb_bits+pos_adv_mb_bits+mb_ave_bits)>>1
[0087] mb_target_bits = MIN(mb_target_bits, mb_max_bits) Formula 5
[0088] Among them, >>1 means shifting right by one bit, that is, dividing by 2; mb_target_bits in the first formula in Formula 4 represents the seventh coding parameter; mb_target_bits in the second formula in Formula 4 represents the target coding parameter within a reasonable range; mb_min_bits represents the second coding parameter; sad_adv_mb_bits represents the fifth coding parameter; pos_adv_mb_bits represents the sixth coding parameter; mb_ave_bits represents the fourth coding parameter; mb_max_bits represents the third coding parameter.
[0089] It can be understood that the target coding parameter is determined by judging the size of the seventh coding parameter and the third coding parameter. The target coding parameter can be controlled within the range of the third coding parameter. Similarly, the target coding parameter can also be determined by judging the size of the seventh coding parameter and the second coding parameter. If the seventh coding parameter is less than the second coding parameter, the second coding parameter is determined to be the target coding parameter, and if the seventh coding parameter is greater than or equal to the second coding parameter, the second coding parameter is determined to be the target coding parameter.
[0090] like Figure 3 The model corresponding to the bit rate control algorithm of the present disclosure is shown, and the target coding parameter can be controlled between the second coding parameter and the third coding parameter, and gradually approach the fourth coding parameter. The bit rate control algorithm can effectively ensure that the number of coding bits of the current first image block does not exceed the target number of bits, and the number of bits allocated between each second image block can be guaranteed to float within a reasonable range based on the consideration of content complexity.
[0091] Step 208: Determine a first quantization parameter based on the target encoding parameter to encode the second image block.
[0092] In an embodiment of the present disclosure, multiple quantization parameters in a first quantization parameter set of a second image block are determined; the second image block is encoded using the multiple quantization parameters respectively, and the quantization parameter corresponding to the eighth encoding parameter is used as the first quantization parameter, and the eighth encoding parameter is less than or equal to the target encoding parameter.
[0093] The first quantization parameter set may be in the form of a first quantization parameter list or a first quantization parameter matrix, which is not limited in the disclosed embodiment. The first quantization parameter refers to a quantization parameter corresponding to the first encoding parameter obtained by encoding by traversing multiple quantization parameters in ascending order and being less than or equal to the target encoding parameter. The first encoding parameter less than or equal to the target encoding parameter is the eighth encoding parameter.
[0094] In order to ensure the same coding length in random access during the encoding process, it is necessary to determine the size relationship between the first coding parameter and the actual coding parameter, that is, to encode the second image block through the first quantization parameter to determine the ninth coding parameter; based on the ninth coding parameter, to determine the actual coding parameter of the first image block; if the actual coding parameter is smaller than the first coding parameter, to fill the actual coding parameter so that the size of the actual coding parameter is the same as the size of the first coding parameter.
[0095] Among them, based on the ninth encoding parameter, determining the actual encoding parameter of the first image block specifically includes: encoding each second image block in the first image block to obtain the ninth encoding parameter corresponding to each second image block, and adding all the ninth encoding parameters in the first image block to obtain the actual encoding parameter of the first image block.
[0096] In an optional embodiment of the present disclosure, after determining the target coding parameter (mb_target_bits) of the second image block, the first quantization list of the current second image block, that is, all candidate QPs, is traversed. The value range of the candidate QP is [0, bitdepth], where bitdepth represents the bit width of the current image. The second image block is encoded by the candidate QPs in turn to obtain the coding parameters corresponding to all candidate QPs. Among them, the coding method is determined by adaptive prediction and Golomb coding. Determine the eighth coding parameter in the coding parameter that is less than or equal to the target coding parameter of the second image block, and use the QP corresponding to the eighth coding parameter as the QP required for the final encoding, that is, the first quantization parameter.
[0097] When encoding the second image block by the finally determined first quantization parameter, the encoding QP is used to encode the current second image block and write the bitstream operation. If the number of bits actually used for encoding the first image block is less than the first encoding parameter of the first image block, the remaining bit length (tile_target_bits-tile_use_bits) of the first image block is filled with 0 to the length of tile_target_bits, where tile_use_bits represents the actual bit length used for encoding the first image block. In this way, it can be ensured that the length of each first image block after encoding is the same as the first encoding parameter.
[0098] In summary, through the method provided by the present disclosure, by dividing the input image, obtaining the first image block and the first coding parameter of the first image block, determining the absolute error sum of the second image block in the first image block, determining the second coding parameter and the third coding parameter of the second image block, the second coding parameter and the third coding parameter are used to control the range of the target coding parameter, based on the first coding parameter and the number of the second image blocks in the first image block, determining the fourth coding parameter of the second image block, based on the absolute error sum of the second image block, determining the fifth coding parameter, based on the position information of the second image block in the first image block, determining the sixth coding parameter, based on the second coding parameter, the third coding parameter The target coding parameter is determined by using a fourth coding parameter, a fifth coding parameter and a sixth coding parameter. Based on the target coding parameter, a first quantization parameter is determined to encode the second image block, thereby enriching the data information used in the encoding process, improving the accuracy of estimating the target coding parameter, and effectively ensuring that the coding length of the second image block does not exceed the specified length, and that a reasonable coding bit length is allocated to the second image blocks with different content complexities, and that the coding bits allocated to each second image block float within a reasonable range. Under acceptable visual damage, the image size is reduced as much as possible to facilitate transmission and storage, thereby improving compression efficiency and compressed image quality.
[0099] based on Figure 1 , Figure 2 The embodiment shown, as Figure 4 A schematic diagram of a specific image compression method supporting random access is shown.
[0100] In an embodiment of the present disclosure, an input image is first divided into first image blocks (Tile) of the same size, and the same number of coding bits, i.e., a first coding parameter, is allocated to each first image block. The first image block is then divided into second image blocks (MB) of the same size, and the size of the second image block is less than or equal to the first image block.
[0101] Preprocess the first image block and analyze the content complexity of each second image block, that is, the absolute error sum. And obtain the target number of bits for each second image block, that is, the target coding parameter, through the absolute error sum of the second image block. Traverse all candidate QPs, that is, the first quantization list, and use the target coding parameter to find the coding parameter whose coding parameter is less than or equal to the target coding parameter, so as to determine the minimum QP corresponding to the above coding bit number, that is, the first quantization parameter, and use the first quantization parameter as the final coding QP to encode the second image block, that is, write it into the bitstream.
[0102] In summary, by utilizing the absolute error and the first coding parameter to encode the second image block, the data information utilized in the coding process is enriched, the accuracy of estimating the target coding parameters is improved, and reasonable coding bit lengths are allocated to second image blocks of different content complexities, and the coding bits allocated to each second image block are ensured to fluctuate within a reasonable range. Under acceptable visual damage, the image size is reduced as much as possible to facilitate transmission and storage, thereby improving compression efficiency and compressed image quality.
[0103] Figure 5 FIG. 5 is a schematic diagram of the structure of an image encoding device 500 provided in an embodiment of the present disclosure. Figure 5 As shown, the image encoding device includes:
[0104] An acquisition unit 510 is configured to divide the input image and acquire a first image block and a first encoding parameter of the first image block;
[0105] A first determining unit 520, configured to determine a sum of absolute errors of the second image block in the first image block;
[0106] A second determining unit 530, configured to determine a target coding parameter of a second image block based on the absolute error sum and the first coding parameter;
[0107] The third determining unit 540 is configured to determine a first quantization parameter based on a target encoding parameter, and encode the second image block using the first quantization parameter.
[0108] In some embodiments, the first determination unit 520 is used to: divide the first image block according to a preset size to determine the second image block; determine the pixel value of each pixel in the second image block; and determine the absolute error sum of the second image block based on the pixel value and the predicted pixel value, where the predicted pixel value is the pixel value in the third image block after encoding and reconstruction, and the absolute error sum is the sum of the absolute values of the differences between the pixel value and the predicted pixel value.
[0109] In some embodiments, the second determination unit 530 is used to: determine a second encoding parameter and a third encoding parameter of the second image block, the second encoding parameter and the third encoding parameter are used to control the range of the target encoding parameter; determine a fourth encoding parameter of the second image block based on the first encoding parameter and the number of second image blocks in the first image block; determine a fifth encoding parameter based on the absolute error sum of the second image block; determine a sixth encoding parameter based on the position information of the second image block in the first image block; and determine the target encoding parameter based on the second encoding parameter, the third encoding parameter, the fourth encoding parameter, the fifth encoding parameter and the sixth encoding parameter.
[0110] In some embodiments, the second determination unit 530 is used to: add the second encoding parameter, the third encoding parameter, the fourth encoding parameter, the fifth encoding parameter and the sixth encoding parameter to obtain a statistical value; determine the seventh encoding parameter based on the statistical value; judge the size of the seventh encoding parameter and the third encoding parameter to determine the target encoding parameter.
[0111] In some embodiments of the present disclosure, the second determining unit 530 is configured to: if the seventh coding parameter is less than the third coding parameter, determine the seventh coding parameter as the target coding parameter.
[0112] In some embodiments of the present disclosure, the second determining unit 530 is used to: if the seventh coding parameter is greater than or equal to the third coding parameter, determine the third coding parameter as the target coding parameter.
[0113] In some embodiments, the third determination unit 540 is used to: determine multiple quantization parameters in the first quantization parameter list of the second image block; encode the second image block using the multiple quantization parameters respectively, and use the quantization parameter corresponding to the eighth encoding parameter as the first quantization parameter, and the eighth encoding parameter is less than or equal to the target encoding parameter; encode the second image block using the first encoding parameter.
[0114] In some embodiments, the third determination unit 540 is further used to: encode the second image block using the first quantization parameter to determine a ninth encoding parameter; determine an actual encoding parameter of the first image block based on the ninth encoding parameter; if the actual encoding parameter is less than the first encoding parameter, pad the actual encoding parameter so that the size of the actual encoding parameter is the same as the size of the first encoding parameter.
[0115] In summary, through the image encoding device, the input image is divided to obtain the first image block and the first encoding parameter of the first image block; the absolute error sum of the second image block in the first image block is determined; based on the absolute error sum and the first encoding parameter, the target encoding parameter of the second image block is determined; based on the target encoding parameter, the first quantization parameter is determined, and the second image block is encoded by the first quantization parameter, so that the absolute error sum, the relevant parameters of the first image block and the first encoding parameter are fully utilized in the encoding process, the data information used in the encoding process is enriched, the target encoding parameter is estimated by the enriched data information, and the estimation accuracy is improved. At the same time, encoding is performed by accurate target encoding parameters to improve compression efficiency and compressed image quality.
[0116] Corresponding to the methods provided in the above-mentioned embodiments, the present disclosure also provides an image encoding device. Since the device provided in the embodiments of the present disclosure corresponds to the methods provided in the above-mentioned embodiments, the implementation method is also applicable to the device provided in this embodiment and will not be described in detail in this embodiment.
[0117] In the embodiments provided in the present application, the methods and devices provided in the embodiments of the present application are introduced. In order to implement the functions in the methods provided in the embodiments of the present application, the electronic device may include a hardware structure and a software module, and implement the functions in the form of a hardware structure, a software module, or a hardware structure plus a software module. A function of the functions may be executed in the form of a hardware structure, a software module, or a hardware structure plus a software module.
[0118] Figure 6 is a block diagram of an electronic device 600 for implementing the above-mentioned image encoding method according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0119] Reference Figure 6 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .
[0120] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0121] The memory 604 is configured to store various types of data to support operations on the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0122] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.
[0123] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0124] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.
[0125] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0126] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of user contact with the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0127] The communication component 616 is configured to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 1000 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, 4G LTE, 5G NR (NewRadio) or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0128] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0129] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the above instructions can be executed by the processor 620 of the electronic device 600 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0130] The embodiments of the present disclosure further provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the image encoding method described in the above embodiments of the present disclosure.
[0131] An embodiment of the present disclosure further provides a computer program product, including a computer program, which executes the image encoding method described in the above embodiment of the present disclosure when a processor is used to execute the computer program.
[0132] The embodiment of the present disclosure also provides a chip, such as Figure 7 As shown, the chip includes one or more interface circuits 710 and one or more processors 720; the interface circuit 710 is used to receive signals from the memory of the electronic device and send signals to the processor 720, the signals include computer instructions stored in the memory, when the processor 720 executes the computer instructions, the electronic device executes the image encoding method described in the above embodiments of the present disclosure.
[0133] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0134] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0135] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0136] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processing module, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (control method), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or otherwise processing in a suitable manner if necessary, and then stored in a computer memory.
[0137] It should be understood that the various parts of the embodiments of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0138] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0139] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium. The above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0140] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. An image coding method, characterized in that: The method comprises: Dividing an input image to obtain a first image block and a first encoding parameter of the first image block; determining a sum of absolute errors of a second image block in the first image block; Determining a target encoding parameter of the second image block based on the absolute error sum and the first encoding parameter; Based on the target encoding parameter, a first quantization parameter is determined, and the second image block is encoded using the first quantization parameter.
2. The method according to claim 1, characterized in that Determining the absolute error sum of the second image block in the first image block comprises: Dividing the first image block according to a preset size to determine a second image block; Determine a pixel value of each pixel in the second image block; Based on the pixel values and the predicted pixel values, the absolute error sum of the second image block is determined, the predicted pixel values are pixel values in the third image block after encoding and reconstruction, and the absolute error sum is the sum of the absolute values of the differences between the pixel values and the predicted pixel values.
3. The method according to claim 2, characterized in that The determining, based on the absolute error sum and the first encoding parameter, a target encoding parameter of the second image block comprises: Determining a second encoding parameter and a third encoding parameter of the second image block, where the second encoding parameter and the third encoding parameter are used to control a range of the target encoding parameter; Determining a fourth encoding parameter of the second image block based on the first encoding parameter and the number of the second image blocks in the first image block; determining a fifth encoding parameter based on the absolute error sum of the second image block; Determining a sixth encoding parameter based on position information of the second image block in the first image block; The target encoding parameter is determined based on the second encoding parameter, the third encoding parameter, the fourth encoding parameter, the fifth encoding parameter and the sixth encoding parameter.
4. The method according to claim 3, characterized in that: The determining the target coding parameter based on the second coding parameter, the third coding parameter, the fourth coding parameter, the fifth coding parameter, and the sixth coding parameter comprises: Add the second encoding parameter, the third encoding parameter, the fourth encoding parameter, the fifth encoding parameter and the sixth encoding parameter to obtain a statistical value; Based on the statistical value, determining the seventh encoding parameter; The magnitude of the seventh coding parameter and the third coding parameter is determined to determine the target coding parameter.
5. The method according to claim 4, characterized in that The determining the size of the seventh coding parameter and the third coding parameter to determine the target coding parameter includes: If the seventh encoding parameter is less than the third encoding parameter, the seventh encoding parameter is determined as the target encoding parameter.
6. The method according to claim 4, characterized in that The determining the size of the seventh coding parameter and the third coding parameter to determine the target coding parameter includes: If the seventh encoding parameter is greater than or equal to the third encoding parameter, the third encoding parameter is determined to be the target encoding parameter.
7. The method according to claim 1, characterized in that The determining a first quantization parameter based on the target encoding parameter, and encoding the second image block by using the first quantization parameter comprises: Determining a plurality of quantization parameters in a first quantization parameter set for the second image block; Encode the second image block using the multiple quantization parameters respectively, use the quantization parameter corresponding to the eighth encoding parameter as the first quantization parameter, and the eighth encoding parameter is less than or equal to the target encoding parameter; The second image block is encoded using the first encoding parameter.
8. The method according to claim 7, characterized in that The method further comprises: Encoding the second image block by using the first quantization parameter to determine a ninth encoding parameter; Determining an actual encoding parameter of the first image block based on the ninth encoding parameter; If the actual encoding parameter is smaller than the first encoding parameter, the actual encoding parameter is padded so that the size of the actual encoding parameter is the same as the size of the first encoding parameter.
9. An image encoding device, characterized in that: The device comprises: An acquisition unit, configured to divide the input image, and acquire a first image block and a first encoding parameter of the first image block; A first determining unit, configured to determine a sum of absolute errors of a second image block in the first image block; A second determining unit, configured to determine a target encoding parameter of the second image block based on the absolute error sum and the first encoding parameter; The third determining unit is configured to determine a first quantization parameter based on the target encoding parameter, and encode the second image block by using the first quantization parameter.
10. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.
11. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-8.
12. A chip, characterized in that: It comprises one or more interface circuits and one or more processors; the interface circuit is used to receive a signal from a memory of an electronic device and send the signal to the processor, the signal includes a computer instruction stored in the memory, and when the processor executes the computer instruction, the electronic device executes the method described in any one of claims 1 to 8.