Image encoding method, encoding device and computer readable storage medium
By blocking the image and adaptive modification of the residual coefficients, the problem of insufficient image compression rate in the prior art is solved, and higher compression rate and smaller mass loss are achieved.
Patent Information
- Application Number
- CN202210564637.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-23
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2042-05-23
AI Technical Summary
The prior art is difficult to effectively improve the compression rate of images, affecting the user's viewing fluency.
By blocking the image to be processed, the first quantized residual coefficient of each image block is obtained, and based on the relevant information, whether the preset modification conditions are met, if they are satisfied, the first quantized residual coefficient is modified to obtain the second quantized residual coefficient, and then the second quantized residual coefficient is encoded.
Adaptive modification of the quantized residual coefficient is realized, the number of bits used for encoding is reduced, the compression rate of the image is effectively improved, while maintaining a small mass loss.
Smart Images

Figure CN115190298B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image coding technology, and in particular to an image coding method, a coding device and a computer-readable storage medium. Background Art
[0002] Since the amount of raw image data is relatively large, it is usually necessary to compress the raw image data. The compressed data is transmitted to the user end through a wired network or a wireless network, and the user end decodes and views it. By increasing the compression rate of the raw data, the user's viewing smoothness can be greatly improved. Therefore, how to effectively improve the compression rate of the image has become a problem that needs to be solved urgently. Summary of the invention
[0003] The present application provides an image encoding method, an encoding device and a computer-readable storage medium, which can improve the compression rate.
[0004] In order to solve the above technical problems, the technical solution adopted in the present application is: to provide an image encoding method, the method comprising: dividing an image to be processed into blocks to obtain multiple image blocks; obtaining a first quantized residual coefficient of a current block among the multiple image blocks; when it is judged based on the relevant information of the current block that the current block meets the first preset modification condition, obtaining a second quantized residual coefficient, the second quantized residual coefficient is obtained by modifying the first quantized residual coefficient, and the relevant information includes at least one of the first quantized residual coefficient, information of the related blocks of the current block, the texture value of the current block, the cost value of the current block or the image quality of the current block; encoding the second quantized residual coefficient to obtain code stream data corresponding to the current block, wherein the number of the second quantized residual coefficients whose values are the first preset value is less than the number of the first quantized residual coefficients whose values are the first preset value.
[0005] To solve the above technical problems, another technical solution adopted in the present application is: to provide a coding device, which includes a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the image coding method in the above technical solution.
[0006] To solve the above technical problem, another technical solution adopted in the present application is: providing a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, it is used to implement the image encoding method in the above technical solution.
[0007] Through the above scheme, the beneficial effects of the present application are: firstly, the image to be processed is divided into blocks to obtain multiple image blocks; then, the current block among the multiple image blocks is processed to obtain a first quantized residual coefficient; then, based on the relevant information of the current block, it is judged whether the current block meets the first preset modification condition, and if so, a second quantized residual coefficient is obtained, and the second quantized residual coefficient is a coefficient obtained by modifying the first quantized residual coefficient, and the relevant information includes at least one of the first quantized residual coefficient, information of the related blocks of the current block, the texture value of the current block, the cost value of the current block or the image quality of the current block; then, the second quantized residual coefficient is encoded to obtain a code stream corresponding to the current block data, the number of second quantized residual coefficients whose values are the first preset value is less than the number of first quantized residual coefficients whose values are the first preset value; through this scheme, adaptive modification of the quantized residual coefficients of the current block is realized, so that the number of the first preset value in the second quantized residual coefficients generated after the modification is reduced compared with that before the modification. Since the number of the first preset value is reduced, the number of bits used for encoding the first preset value can be reduced, which can effectively improve the compression rate of the encoding while ensuring that the quality loss is very small, and the amount of calculation is very small; moreover, this scheme can be applicable to a variety of image formats and a variety of video standard formats, has a wide range of applicability, and can be applied to scenes without prediction residuals. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0009] Figure 1 It is a flowchart of an embodiment of an image encoding method provided by the present application;
[0010] Figure 2 is a schematic diagram of a current block and a time domain co-located block provided by the present application;
[0011] Figure 3 It is a schematic diagram of the current block and the spatially adjacent blocks provided by this application;
[0012] Figure 4 A schematic diagram of the coefficient scanning order in the current block provided by the present application;
[0013] Figure 5 It is a structural schematic diagram of an embodiment of an encoding device provided by the present application;
[0014] Figure 6 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION
[0015] The present application is further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present application, but are not intended to limit the scope of the present application. Similarly, the following examples are only some embodiments of the present application rather than all embodiments, and all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0016] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0017] It should be noted that the terms "first", "second" and "third" in this application are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first", "second" and "third" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.
[0018] In the image or video standard, the coefficients after the last non-zero coefficient of the image block are all 0, and do not need to be encoded. It is only necessary to record the position of the last non-zero coefficient. Therefore, the closer the position of the last non-zero coefficient is, the fewer bits are required for encoding. Moreover, in general image or video coding standards, for the case where the coefficients are multiple consecutive 0s, run-length coding is used. The more consecutive 0s, the longer the run, and the fewer bits required for encoding. Therefore, if the run length between non-zero coefficients can be increased, the number of bits for encoding can be effectively reduced. Based on this, the present application provides a scheme for modifying parameters between quantization and entropy coding, which can adaptively modify the parameters after quantization processing to reduce the coding length, which is described in detail below.
[0019] See also Figure 1 , Figure 11 is a flow chart of an embodiment of an image encoding method provided by the present application, the method comprising:
[0020] S11: Divide the image to be processed into blocks to obtain multiple image blocks.
[0021] The executor of this embodiment is an encoding device, such as a camera device or a computer or other device with encoding function; the camera device can be used to shoot the current monitoring scene to obtain the image to be processed; or, the image to be processed can be read from a storage device or an image database; or, the image to be processed sent by other devices can be received.
[0022] After obtaining the image to be processed, the image to be processed is divided into blocks using an image block method commonly used in related technologies to obtain multiple image blocks; for each image block in the image to be processed, the following processing is performed to obtain the code stream data corresponding to each image block, and by merging the code stream data corresponding to all image blocks, the code stream data corresponding to the entire image to be processed can be obtained.
[0023] S12: Obtain a first quantized residual coefficient of a current block among multiple image blocks.
[0024] An image block is taken out from all image blocks in turn according to a set order to obtain a current block, and the current block is processed (for example, predicted, transformed or quantized) to obtain a first quantized residual coefficient, which is generated by quantizing the current block.
[0025] For example, the pixel values of the current block are recorded as original coefficients, and the original coefficients can be determined as residual coefficients; or, the original coefficients are predicted to obtain prediction coefficients, and the prediction coefficients are subtracted from the original coefficients to obtain residual coefficients; after obtaining the residual coefficients, the residual coefficients are transformed to obtain transformation coefficients, and the transformation coefficients are quantized to obtain first quantized residual coefficients. Alternatively, the original coefficients can be transformed and quantized to obtain first coefficients; the original coefficients are predicted, transformed, and quantized to obtain second coefficients; the difference between the first coefficient and the second coefficient is calculated to obtain the first quantized residual coefficient.
[0026] S13: when it is determined based on the relevant information of the current block that the current block satisfies the first preset modification condition, obtaining a second quantized residual coefficient.
[0027] The second quantized residual coefficient is obtained by modifying the first quantized residual coefficient; obtaining relevant information of the current block, the relevant information includes at least one of the first quantized residual coefficient, information of related blocks of the current block, texture value of the current block, cost value of the current block or image quality of the current block, and the information of the related blocks includes the relevant threshold of the related blocks; using the relevant information to determine whether the current block meets the first preset modification condition, that is, to determine whether the current block needs to be adaptively modified in coefficients, if necessary, perform subsequent adaptive modification of coefficients; otherwise, do not perform any processing. It can be understood that the second quantized residual coefficient can be generated in the process of determining whether the current block meets the first preset modification condition based on the relevant information of the current block, and there is no need to calculate it again; or, after determining that the current block meets the first preset modification condition, the first quantized residual coefficient is modified to obtain the second quantized residual coefficient.
[0028] Further, the related blocks include at least one of a temporal common position block and a spatial adjacent block, the temporal common position block is an image block in the temporal sequence related image of the image to be processed that has the same position as the current block, the temporal sequence related image is an image whose coding order is prior to the coding order of the image to be processed, that is, the temporal sequence related image is located before the image to be processed in the temporal domain; further, the temporal sequence related image has a high correlation with the image to be processed, that is, an image that is located before the image to be processed in the temporal domain and has a similarity with the image to be processed greater than a preset similarity can be selected as the temporal sequence related image; for example, Figure 2 As shown, image K2 is the image to be processed, image K1 is the previous frame image of image K2, and the position of image block u in image K2 is the same as that of image block h in image K1; the spatial domain adjacent block is the image block adjacent to the current block in the image to be processed, for example, Figure 3 As shown, the image block ag is the spatial domain neighboring block of the current block L.
[0029] In one implementation, a current block related threshold may be first obtained in order to perform subsequent processing operations (to be described below), the related threshold includes a first quantity threshold, a second quantity threshold, a third quantity threshold or a coefficient amplitude threshold, the first quantity threshold is a threshold corresponding to the total number of non-zero coefficients in the image block, the second quantity threshold is a threshold corresponding to the total number of other coefficients (coefficient amplitude is 0) located before the non-zero coefficient and continuous, the third quantity threshold is a threshold corresponding to the total number of other coefficients located after the non-zero coefficient and continuous, and the coefficient amplitude threshold is a threshold corresponding to the amplitude of the non-zero coefficient; if the current block has a time domain common position block or a spatial domain adjacent block, and its quantized residual coefficient has been adaptively modified, then the first quantity threshold of the related block, the second quantity threshold of the related block, the third quantity threshold of the related block or the coefficient amplitude threshold of the related block is obtained; specifically, the following scheme may be used to calculate the related threshold of the current block:
[0030] (A) Option 1
[0031] The correlation threshold of the current block can directly use the threshold corresponding to the time domain common position block, that is, the correlation threshold of the time domain common position block is determined as the correlation threshold of the current block; or, the corresponding threshold of the spatial domain adjacent block is used, that is, the correlation threshold of the time domain common position block is determined as the correlation threshold of the current block. In summary, the correlation threshold of the current block can directly use the first quantity threshold, the second quantity threshold, the third quantity threshold or the coefficient amplitude threshold of the time domain common position block or the spatial domain adjacent block.
[0032] (B) Option 2
[0033] The relevant threshold of the current block can be obtained by calculating the thresholds corresponding to the temporal common position block and the spatial adjacent block. For example, the relevant threshold of the temporal common position block and the relevant threshold of the spatial adjacent block are weighted summed to obtain the relevant threshold of the current block, as shown below:
[0034] B1) performing weighted summation on the first quantity threshold of the temporal co-located blocks and / or the first quantity threshold of the spatial adjacent blocks to obtain the first quantity threshold of the current block.
[0035] The new non-zero coefficient quantity threshold is calculated using the following formula and is used as the first quantity threshold of the current block:
[0036] M=(z a M a +z b M b +z c M c +z d M d +z e M e +z f M f +z g M g +z h M h ) / G (1)
[0037] Where M is the first number threshold of the current block, z i and G is the adjustment coefficient, G>0, M i is the first number threshold of the relevant blocks, and the first number threshold of the relevant blocks can be the number of non-zero coefficients in the relevant blocks; zi≥0, i∈{a, b, c, d, e, f, g, h}, such as Figure 2 and Figure 3 As shown, ag represents adjacent blocks in the spatial domain, and h represents the common position block in the temporal domain.
[0038] B2) Performing weighted summation on the second quantity threshold of the temporal co-located blocks and / or the second quantity threshold of the spatial adjacent blocks to obtain the second quantity threshold of the current block.
[0039] The second quantity threshold of the current block is calculated using the following formula:
[0040] Q 1 =(y a1 Q a1 +y b1 Q b1 +y c1 Q c1 +y d1 Q d1 +y e1 Q e1 +y f1 Q f1 +y g1 Q g1 +y h1 Q h1 ) / F 1 (2)
[0041] Among them, Q 1 is the second quantity threshold of the current block, y sl With F 1 is the adjustment coefficient, Q s1 is the second number threshold of related blocks, s∈{a,b,c,d,e,f,g,h}.
[0042] B3) performing weighted summation on the third quantity threshold of the temporal co-located blocks and / or the third quantity threshold of the spatial adjacent blocks to obtain the third quantity threshold of the current block.
[0043] Q 2 =(y a2 Q a2 +y b2 Q b2 +y c2 Q c2 +y d2 Q d2 +y e2 Q e2 +y f2 Q f2 +y g2 Q g2 +y h2 Q h2 ) / F 2 (3)
[0044] Among them, Q 2 is the third quantity threshold of the current block, y t2 With F 2 is the adjustment coefficient, Qt2 is the third number threshold of related blocks, t∈{a,b,c,d,e,f,g,h}.
[0045] B4) Performing weighted summation on the coefficient amplitude thresholds of the time domain co-located blocks and / or the coefficient amplitude thresholds of the spatial domain adjacent blocks to obtain the coefficient amplitude threshold of the current block.
[0046] P 1 =(y a3 P a +y b3 P b +y c3 P c +y d3 P d +y e3 P e +y f3 P f +y g3 P g +y h3 P h ) / F 3 (4)
[0047] Among them, P 1 is the coefficient amplitude threshold of the current block, P j is the coefficient amplitude threshold of the adjacent block, y j3 With F 3 is the adjustment coefficient, j∈{a,b,c,d,e,f,g,h}.
[0048] It can be understood that in the above calculation formula, some of the spatial adjacent blocks that have been adaptively modified can be selected for calculation according to actual needs; in addition, other methods can also be used to generate the relevant threshold of the current block, which is not limited to the above scheme.
[0049] In one embodiment, if Figure 3 As shown, if the quantized residual coefficients of spatially adjacent blocks a, b and d are adaptively modified, the thresholds corresponding to the spatially adjacent blocks a, b and d (including the second quantity threshold, the third quantity threshold and the coefficient amplitude threshold) are used to calculate the relevant threshold of the current block.
[0050] For example, suppose y a1 =y b1 =y d1 =1,Q a1 =Q b1 =3,Q d1 =2, F 1 =F 2 =F 3 =3,y a2 =y b2 =yd2 =1,Q a2 =Q b2 =4,Q d2 =3,y a3 =y b3 =y d3 =1,P a =P b =P c =1, then Q 1 =(3+3+2) / 3=2, Q 2 =(4+4+3) / 3=3, P 1 =(1+1+1) / 3=1.
[0051] This embodiment adopts a solution of generating the relevant threshold of the current block according to the threshold of the common position in the time domain or the adjacent blocks in the spatial domain, which can make judgments according to the time domain characteristics or the spatial domain characteristics and reduce the amount of calculation.
[0052] The following describes in detail how to determine whether the coefficients of the current block need to be adaptively modified.
[0053] In a first embodiment, a scheme for determining whether the current block needs to perform adaptive coefficient modification may be: determining whether the number of non-zero coefficients in the first quantized residual coefficient is less than or equal to a first quantity threshold of the current block, and the first quantity threshold is greater than or equal to 0; if the number of non-zero coefficients in the first quantized residual coefficient is less than or equal to the first quantity threshold, determining that the current block meets a first preset modification condition; if the number of non-zero coefficients in the first quantized residual coefficient is greater than the first quantity threshold, indicating that there are many non-zero coefficients in the current block, and if a modification operation is performed, it may result in poor quality, and in this case, there is no need to modify the first quantized residual coefficient.
[0054] In one embodiment, if Figure 3 As shown, if the quantized residual coefficients of spatially adjacent blocks a, b and d are subjected to adaptive modification processing, the first quantity threshold of the spatially adjacent blocks a, b and d is processed to obtain the first quantity threshold of the current block; based on the number of non-zero coefficients in the current block and the first quantity threshold of the current block, it is determined whether the current block needs to be subjected to coefficient adaptive modification processing.
[0055] For example, if z a =z b =z d =1, G=3, M a =3,M b =M d =2, then M = (M a +M b +M d) / G=(3+2+2) / 3=2; if the number of non-zero coefficients of the current block is 2, since it is less than M, it can be determined that the current block meets the first preset modification condition, and the coefficient adaptive modification processing is performed on the current block.
[0056] In another embodiment, assuming that the temporal co-location block of the current block and two spatial neighboring blocks undergo coefficient adaptive modification processing, and the numbers of their corresponding non-zero coefficients are 3, 4, and 3 respectively, z a =z b =z h =1, G=3, then M=(3+4+3) / 3=3. If the number of non-zero coefficients in the current block is 2, which is less than 3, the current block satisfies the first preset modification condition.
[0057] According to the thresholds corresponding to the temporal common position block and the two spatial adjacent blocks, the relevant threshold of the current block is calculated; for example, assuming y a1 =y b1 =y h1 =1, other coefficients are 0, Q a1 =3,Q b1 =2, Q h1 =3, then Q 1 =(Q a1 +Q b1 +Q h1 ) / 3=(3+2+3) / 3=2; Assume y a2 =y b2 =y h2 =1,Q a2 =2, Q b2 =2,Q h2 =1, then Q 2 =(2+2+1) / 3=1; Assume y a3 =y b3 =1,y h3 =2,P a =2,P b =2,P h =1, then P 1 =(2+2+1*2) / 3=2.
[0058] In the second embodiment, the scheme for determining whether the current block needs to be adaptively modified in coefficients may be: when the relevant block includes a time domain common position block, determining whether the quantized residual coefficient of the time domain common position block is modified; if the quantized residual coefficient of the time domain common position block is modified, determining that the current block meets the first preset modification condition. Alternatively, when the relevant block includes a spatial domain adjacent block, determining whether the quantized residual coefficient of the spatial domain adjacent block is modified; if the quantized residual coefficient of the spatial domain adjacent block is modified, determining that the current block meets the first preset modification condition. Alternatively, when the relevant block includes a time domain common position block and a spatial domain adjacent block, determining whether the quantized residual coefficient of the time domain common position block and the quantized residual coefficient of the spatial domain adjacent block are both modified; if so, determining that the current block meets the first preset modification condition.
[0059] In the third embodiment, the scheme for determining whether the current block needs to be adaptively modified in coefficients may be: determining whether the texture value of the current block is less than a preset texture threshold; if the texture value of the current block is less than the preset texture threshold, it indicates that the texture of the current block is relatively simple, and at this time it can be determined that the current block meets the first preset modification condition, that is, the first quantization parameter needs to be modified. Specifically, the texture value may be obtained by processing the texture features of the current block using methods in the relevant technology, such as: obtaining the grayscale histogram of the current block, analyzing the grayscale histogram, and determining whether the texture is relatively simple; or calculating the gradient value of the current block, if the gradient value is less than a set value, the texture is considered to be simple; or calculating the motion information of the current block, if the motion information is less than a preset threshold, the texture is considered to be simple, for example: pre-processing algorithms such as Euclidean distance or Sobel operator may be used to calculate the areas with large color changes or motion changes in the image to be processed.
[0060] In a fourth embodiment, a scheme for determining whether the current block needs to perform adaptive coefficient modification may be: modifying the first quantized residual coefficient to obtain a second quantized residual coefficient, wherein the modification scheme for the first quantized residual coefficient will be described below; calculating the difference between the cost value corresponding to the second quantized residual coefficient and the cost value corresponding to the first quantized residual coefficient; determining whether the difference falls within a preset threshold range; if the difference falls within the preset threshold range, determining that the current block meets the first preset modification condition.
[0061] Furthermore, a coefficient modification mechanism is set based on a certain cost calculation method (for example, a rate-distortion cost calculation method): the rate-distortion cost before the coefficient modification (referred to as the first cost) is compared with the rate-distortion cost after the coefficient modification (referred to as the second cost); if the difference between the first cost and the second cost is within a preset threshold range, the adaptive modification of the coefficient of the current block takes effect, otherwise, no processing is performed or the magnitude of the modification is reduced.
[0062] In one embodiment, taking the encoding format of the Joint Photographic Experts Group (JPEG) as an example, a frame of the image to be processed is divided into multiple minimum coding units (MCU), and the MCU can be composed of several 8×8 macroblocks. First, the coefficient of the quantization residual coefficient corresponding to each MCU is adaptively modified; then based on the sum of absolute transformed difference (SATD), the first cost and the second cost are calculated and compared; if the ratio of the second cost to the first cost does not exceed 5%, it indicates that the first quantization residual coefficient of the current block needs to be modified. At this time, the second quantization residual coefficient is the coefficient obtained by modifying the first quantization residual parameter; otherwise, no modification is performed. It can be understood that the method for calculating the cost can be adjusted according to the actual calculation complexity and accuracy requirements, and is not limited to SATD. For example, the sum of squared errors (SSE) or mean squared error (MSE) can also be used.
[0063] This scheme can first adopt different non-zero coefficient amplitude modification schemes within different distortion cost ranges; then compare the costs before and after the coefficient modification, and make a decision to determine whether the amplitude modification of the non-zero coefficient is effective, which can effectively improve the encoding compression rate while the loss is controllable.
[0064] In the fifth embodiment, the scheme for determining whether the current block needs to perform adaptive coefficient modification may be: based on the second quantity threshold, the third quantity threshold and the coefficient amplitude threshold, modify the non-zero coefficients in the first quantized residual coefficient to obtain the second quantized residual coefficient; determine whether the difference between the cost value corresponding to the first quantized residual coefficient and the cost value corresponding to the second quantized residual coefficient is less than a preset difference threshold; if so, determine that the current block meets the first preset modification condition.
[0065] In the sixth embodiment, a scheme for determining whether the current block needs to be adaptively modified in coefficients may be: determining whether the current block satisfies a first preset modification condition based on the image quality of the current block. Specifically, when the image quality of the current block falls within a preset quality range, it is determined that the current block satisfies the first preset modification condition, and the preset quality range includes a quality level interval.
[0066] In the seventh embodiment, the scheme for determining whether the current block needs to be adaptively modified in coefficients may be: adopting a comprehensive judgment method of image quality and cost, modifying the first quantized residual coefficient in different quality level intervals, and then comparing the cost value corresponding to the first quantized residual coefficient with the cost value corresponding to the second quantized residual coefficient, and determining whether the coefficient modification is effective according to the relationship between the difference between the two and a preset difference threshold. Specifically, when the image quality of the current block falls within the preset quality range, the first quantized residual coefficient is modified to obtain the second quantized residual coefficient; determining whether the difference between the cost value corresponding to the first quantized residual coefficient and the cost value corresponding to the second quantized residual coefficient is less than the first difference threshold; if the difference is less than the first difference threshold, determining that the current block meets the first preset modification condition.
[0067] Furthermore, the quality level interval corresponding to the image quality of the current block is obtained to obtain the current quality level interval; it is determined whether the current block satisfies the second modification condition corresponding to the current quality level interval; if the current block satisfies the second modification condition corresponding to the current quality level interval, the first quantized residual coefficient is modified based on the modification strategy matching the current quality level interval, the second quantity threshold, the third quantity threshold and the coefficient amplitude threshold to obtain the second quantized residual coefficient.
[0068] This scheme proposes to adopt different non-zero coefficient amplitude modification schemes under different quality ranges and within different distortion cost ranges, compare the costs before and after the coefficient modification, and make a decision to determine whether to modify the amplitude of the non-zero coefficient of the current block, effectively improving the encoding compression rate while the loss is controllable.
[0069] After determining that the coefficients of the current block need to be adaptively modified, the non-zero coefficients in the current block can be traversed according to the set conditions to determine which non-zero coefficients need to be adaptively modified, which is described in detail below.
[0070] In the first embodiment, the scheme for determining whether the non-zero parameters in the first quantized residual coefficient need to be modified can be: determining whether there is a related block in the current block; if there is a related block in the current block, calculating the related threshold of the current block based on the related threshold of the related block; determining whether the non-zero coefficients in the current block meet the second preset modification condition based on the related threshold of the current block and the related information, and if so, modifying the non-zero coefficients in the first quantized residual coefficient to generate the second quantized residual coefficient. Several specific implementation schemes are introduced below:
[0071] (1) Solution 1
[0072] Select the current non-zero coefficient from the first quantized residual coefficient in sequence according to the scanning order; when the current non-zero coefficient has a previous non-zero coefficient, obtain the number of other coefficients between the current non-zero coefficient and the previous non-zero coefficient to obtain a first number; based on the first number, determine whether the current non-zero coefficient meets the second preset modification condition. Alternatively, when the current non-zero coefficient has a next non-zero coefficient, obtain the number of other coefficients between the non-zero coefficient and the next non-zero coefficient to obtain a second number; based on the second number, determine whether the current non-zero coefficient meets the second preset modification condition. Alternatively, when the current non-zero coefficient has a previous non-zero coefficient and a next non-zero coefficient, obtain the number of other coefficients between the current non-zero coefficient and the previous non-zero coefficient to obtain a first number; obtain the number of other coefficients between the non-zero coefficient and the next non-zero coefficient to obtain a second number; based on the first number and the second number, determine whether the current non-zero coefficient meets the second preset modification condition; if the current non-zero coefficient meets the second preset modification condition, modify the current non-zero coefficient. Specifically, the other coefficients are coefficients whose amplitudes are 0. For a non-zero coefficient P at a certain position, if it satisfies the scanning order that the amplitudes of the preceding M consecutive coefficients (M is greater than the second quantity threshold) and / or the following N consecutive coefficients (N is greater than the third quantity threshold) are all 0, then the non-zero coefficient P is modified so that its amplitude becomes 0, so as to increase the number of zero coefficients of the current block and improve the compression rate.
[0073] Further, when the first number is greater than or equal to the first preset number, it can be determined that the non-zero coefficient meets the second preset modification condition. Alternatively, when the second number is greater than or equal to the second preset number, it can be determined that the non-zero coefficient meets the second preset modification condition, and the non-zero coefficient is modified. Alternatively, when the first number is greater than or equal to the first preset number, and the second number is greater than or equal to the second preset number, it can be determined that the non-zero coefficient meets the second preset modification condition, and the non-zero coefficient is modified.
[0074] (2) Solution 2
[0075] It is determined whether the amplitude of the non-zero coefficient in the first quantized residual coefficient is less than the coefficient amplitude threshold; if the amplitude of the non-zero coefficient is less than the coefficient amplitude threshold, the non-zero coefficient is modified.
[0076] It can be understood that in this embodiment, the amplitude is defined as greater than or equal to 0. If the amplitude is defined as a value that can be less than 0, the absolute value of the amplitude is compared with the magnitude relationship of the coefficient amplitude threshold; for example, the amplitude of the non-zero coefficient is recorded as P, and the coefficient amplitude threshold is recorded as P 1 , when |P|≤P 1 When |P| is reduced, the sign bit of the non-zero coefficient remains unchanged.
[0077] In the second embodiment, the scheme for determining whether the non-zero parameters in the first quantized residual coefficient need to be modified may be: determining whether the scanning position of the non-zero coefficient in the first quantized residual coefficient is greater than or equal to the scanning position threshold; if the scanning position of the non-zero coefficient is greater than or equal to the scanning position threshold, and the scanning position threshold is greater than or equal to 0, then modifying the non-zero coefficient.
[0078] For example, assuming that the first quantity threshold M of the current block is 3, there is a time domain common position block in the current block, and the time domain common position block has undergone coefficient adaptive modification; if the number of non-zero coefficients of the current block is 2, since it is less than M, it is determined that the current block meets the first preset modification condition, and the non-zero coefficients of the current block are adaptively modified; if the size of the current block is 8×8, it has 64 coefficients, and the scanning position threshold Y is set to 16, that is, the non-zero coefficients after scanning position 16 are only subjected to coefficient adaptive modification processing.
[0079] In the third embodiment, the scheme for determining whether the non-zero parameters in the first quantized residual coefficient need to be modified may be: determining whether the number of non-zero coefficients in the first quantized residual coefficient is less than the first number threshold and whether the scanning position is greater than or equal to the scanning position threshold; if so, modifying the non-zero coefficients. Alternatively, determining whether the number of non-zero coefficients in the first quantized residual coefficient is less than the first number threshold and whether the amplitude of the non-zero coefficient is less than the coefficient amplitude threshold; if the number of non-zero coefficients in the first quantized residual coefficient is less than the first number threshold and the amplitude of the non-zero coefficient is less than the coefficient amplitude threshold, modifying the non-zero coefficient.
[0080] This scheme performs adaptive coefficient modification processing on the current block based on the position and amplitude of non-zero coefficients, which can reduce the number of coding bits and improve the compression rate.
[0081] The solution provided by this embodiment will be described below in combination with the modification solution of non-zero coefficients, the above-mentioned solution for determining whether the current block needs to be modified, and the solution for determining which non-zero parameters in the current block need to be modified.
[0082] In the first embodiment, the scheme for modifying the non-zero coefficients may be: calculating the difference between the amplitude of the non-zero coefficients and the adjustment step length; determining whether the difference is less than a second preset value; if the difference is less than the second preset value, determining the amplitude of the non-zero coefficients as the second preset value; if the difference is greater than or equal to the second preset value, modifying the amplitude of the non-zero coefficients to the absolute value of the difference. Specifically, the second preset value may be 0, and a weighted sum is taken for the first number corresponding to the non-zero coefficients and the second number corresponding to the non-zero coefficients to obtain the adjustment step length, that is, the non-zero coefficients are modified using the following formula:
[0083]
[0084] Delta=(x1 *Q 1 +x 2 *Q 2 +k) / E (6)
[0085] Among them, E, x 1 、x 2 and k are adjustment coefficients, E>0, x 1 ≥0,x 2 ≥0, k≥0, P m ≥0, Delta≥0, |P| represents the absolute value of P, P m Indicates the magnitude of the modified coefficient.
[0086] In one embodiment, the first preset condition can be set to: determine whether the first quantity corresponding to the current block is less than the first quantity threshold; the second preset condition can be set to: determine whether the first quantity corresponding to the non-zero parameter is greater than or equal to the second quantity threshold, or determine whether the second quantity corresponding to the non-zero parameter is greater than or equal to the third quantity threshold.
[0087] For example, taking JPEG format image encoding as an example, a frame of image to be processed is divided into multiple MCUs, and MCU can be composed of several 8×8 macroblocks, and each macroblock is transformed and quantized; Figure 4 As shown, the coefficient scanning order in an 8×8 macroblock is recorded as 0-63. It is assumed that the coefficients of scanning positions 0, 2, 6 and 13 are non-zero, the coefficients of scanning positions 1, 3-5 and 7-12 are all 0, and the coefficients after scanning position 13 are all 0.
[0088] A) Setting the first quantity threshold M of the current block to 5, if the number of non-zero coefficients of the current block is 4, the coefficients of the current block may be adaptively modified.
[0089] B) The second quantity threshold Q of the current block 1 =3, the third quantity threshold Q of the current block 2 =0.
[0090] C) Set the coefficient amplitude threshold P of the current block 1 =1, x1=x2=1, E=2, k=0, then Delta=(3+0) / 2=1, set Figure 4 The absolute values of coefficient C at scanning position 13 and coefficient B at scanning position 6 are both 1.
[0091] C1) From Figure 4 Starting from the position where the last non-zero coefficient (i.e. coefficient C) is located, there are 6 consecutive 0s before coefficient C (the coefficients of scanning positions 7-12 are all 0). Since the first quantity corresponding to coefficient C is greater than Q 1 , then the coefficient C is modified, the amplitude of the coefficient C is Pm =||1|–1|=0, at this time Figure 4 The last non-zero coefficient in becomes coefficient B at scan position 6.
[0092] C2) There are three consecutive zeros before coefficient B, so the first quantity corresponding to coefficient C is equal to Q 1 , then the amplitude P of coefficient B m =||1|–1|=0, at this time Figure 4 The last non-zero coefficient in becomes coefficient A at scan position 2.
[0093] C3) Since there is only one non-zero coefficient before coefficient A, it does not meet the conditions and is therefore not modified.
[0094] C4) Since the coefficient S is Figure 4 The first non-zero coefficient in , which has no non-zero coefficient before it, does not meet the conditions and is not modified.
[0095] In another embodiment, the first preset condition can be set to: determine whether the first quantity corresponding to the current block is less than or equal to the first quantity threshold; the second preset condition can be set to: determine whether the first quantity corresponding to the non-zero parameter is greater than or equal to the second quantity threshold, whether the second quantity corresponding to the non-zero parameter is greater than or equal to the third quantity threshold, and whether the amplitude of the non-zero parameter is greater than the coefficient amplitude threshold.
[0096] For example, Figure 4 As shown, assuming that the coefficients of scanning positions 0, 2, 6, 13 and 15 are non-zero coefficients, the coefficients of scanning positions 1, 3-5, 7-12 and 14 are all 0, and the coefficients after scanning position 15 are all 0, that is, there are 5 non-zero coefficients.
[0097] A) Setting the first quantity threshold M=5, the current block satisfies the first preset modification condition.
[0098] B) Setting the second quantity threshold Q 1 =3, the third quantity threshold Q 2 =4.
[0099] C) Set the coefficient amplitude threshold P 1 =1.
[0100] C1) Starting from the last non-zero coefficient (ie coefficient D), there is only one 0 in front and only three 0s in the back, so coefficient D does not meet the second preset modification condition and is not modified.
[0101] C2) There is only one 0 after coefficient C, so coefficient C does not meet the conditions and is not modified.
[0102] C3) The coefficient B has 3 zeros in front and 6 zeros in the back, and the amplitude P of the coefficient B is 1 (≤P 1 ), so the coefficient B satisfies the second preset modification condition.
[0103] If we set x1=x2=1, E=3, k=0, then Delta=(3+4) / 3=2, |P|–Delta=|1|–2<0, then P m =0, setting coefficient B directly to 0 can effectively increase the run length between non-zero coefficients and reduce the number of encoded bits.
[0104] C4) There is only one 0 in front of coefficient A, which does not meet the second preset modification condition and is not modified.
[0105] C5) There is only one 0 after the coefficient S, which does not meet the second preset modification condition and is not modified.
[0106] In a second embodiment, a modification scheme for the first quantized residual coefficient may be: obtaining a mapping table, the mapping table including at least one quality level interval and modification information corresponding to the quality level interval, the modification information including a modification strategy; matching the image quality of the current block with the mapping table to obtain current modification information, the current modification information being modification information that matches the image quality; modifying the first quantized residual coefficient using the modification strategy in the current modification information to obtain a second quantized residual coefficient.
[0107] Further, the modification information also includes a second modification condition, and at least one quality level interval includes a first quality level interval and a second quality level interval; when the image quality falls within the first quality level interval, if the first number corresponding to the non-zero coefficient is greater than or equal to the second number threshold, or the second number corresponding to the non-zero coefficient is greater than or equal to the third number threshold, then it is determined that the non-zero coefficient meets the second modification condition in the current modification information. When the image quality falls within the second quality level interval, if the first number corresponding to the non-zero coefficient is greater than or equal to the second number threshold, and the second number corresponding to the non-zero coefficient is greater than or equal to the third number threshold, then it is determined that the non-zero coefficient meets the second modification condition in the current modification information; wherein the minimum value of the second quality level interval is greater than the maximum value of the first quality level interval, and the larger the value in the quality level interval, the better the image quality and the lower the compression rate.
[0108] For example, taking JPEG format image encoding as an example: a frame of image to be processed is divided into multiple MCUs, and MCU can be composed of several 8×8 macroblocks; set the quality level interval, and different coefficient modification methods are used for different quality level intervals; assuming that the quality level range is (0, 100], the preset quality range is (0, 70], the first quantity threshold is recorded as M, and the second quantity threshold is recorded as Q 1 , the third quantity threshold is denoted as Q2 , the adopted scheme is as follows:
[0109] A) If the image quality of the current block falls within (0, 20], the second preset modification condition is: the first number corresponding to the non-zero coefficients is greater than / equal to Q 1 Or the second number corresponding to the non-zero coefficient is greater than / equal to Q 2 .
[0110] Assume M = 5, P 1 =1,Q 1= 3. Q 2 =2, the amplitude of the non-zero coefficient P is 1, with 3 zeros in front and 2 zeros in the back.
[0111] A1) If x 1 =1,x 2 =0, E = 2, then Delta = (1*3) / 2 = 1, P m =|1–1|=0, that is, the non-zero coefficient is modified to 0.
[0112] A2) If x 1 =0,x 2 =1, E = 2, then Delta = (1*2) / 2 = 1, P m =|1–1|=0, that is, the non-zero coefficient is modified to 0.
[0113] B) If the image quality of the current block falls within (20, 40], the second preset modification condition is: the first number corresponding to the non-zero coefficients is greater than / equal to Q 1 Or the second number corresponding to the non-zero coefficient is greater than / equal to Q 2 .
[0114] Assume that M=3, and the current block contains very few non-zero coefficients, such as only 3 non-zero coefficients.
[0115] If the magnitude of a non-zero coefficient P is 1, P 1 =1,Q 1 =4,Q 2 =3,x 1 =1,x 2 =0, E = 3, then Delta = (1*4 + 0*3) / 3 = 1, P m =|1–1|=0, then the non-zero coefficient P is modified to 0.
[0116] C) If the image quality of the current block falls within (40, 70], the second preset modification condition is: the first number corresponding to the non-zero coefficients is greater than / equal to Q 1 , and the second number corresponding to the non-zero coefficients is greater than / equal to Q 2 .
[0117] Assume that M=2, and the current block contains only a few non-zero coefficients, such as only 2 non-zero coefficients.
[0118] If the magnitude of a non-zero coefficient P is 1, P 1 =1,Q 1 =6, Q 2 =4,x 1 =1,x 2 =1, E = 5, then Delta = (1*6+1*4) / 5 = 2, |P|–Delta = |1|–2 < 0, P m =0, the non-zero coefficient P is modified to 0.
[0119] D) If the image quality of the current block falls within (70, 100], no coefficient adaptive modification processing is performed.
[0120] This embodiment adopts different coefficient adaptive modification methods based on different quality level intervals, which can effectively reduce the loss and improve the compression rate.
[0121] In the third embodiment, the first preset condition is: judging whether the number of non-zero coefficients in the current block is greater than a first quantity threshold of the current block; the second preset condition includes: judging whether the first number corresponding to the non-zero coefficients in the current block is greater than or equal to the second quantity threshold, and / or judging whether the second number corresponding to the non-zero coefficients in the current block is greater than or equal to the third quantity threshold, and / or judging whether the amplitude of the non-zero coefficients in the current block is greater than or equal to the coefficient amplitude threshold.
[0122] For example, assuming that the coefficients of the common position block in the time domain are adaptively modified, the first quantity threshold is 3, and the first quantity threshold M of the current block is 3; if the first quantity of the current block is 2, which is less than 3, it is determined that the current block meets the first preset modification condition, and the coefficients of the common position block in the time domain are adaptively modified. 1 =3, the third quantity threshold Q 2 =4, coefficient amplitude threshold P 1 =1, the scheme in the above embodiment is used to perform coefficient adaptive modification processing on the current block.
[0123] In the fourth embodiment, under different qualities, the correlation threshold of the current block is calculated based on the correlation threshold of the spatial adjacent blocks or the temporal common blocks, and the scheme in the above embodiment is used to perform coefficient adaptive modification processing on the current block.
[0124] In the fifth embodiment, the relevant threshold of the current block is first calculated based on the threshold of the spatial adjacent blocks or the temporal common position blocks, and the coefficient of the current block is adaptively modified using the scheme in the above embodiment; then, based on the rate-distortion calculation method, it is determined whether the coefficient modification is effective.
[0125] In the sixth embodiment, the scheme in the above embodiment can also be used to perform coefficient adaptive modification processing on the current block based on the relevant thresholds of spatially adjacent blocks or temporally common blocks under different qualities; then, based on the rate-distortion calculation method, determine whether the coefficient modification is effective.
[0126] It is understandable that the various solutions mentioned above can be used in combination according to actual quality or application needs, and are not limited to the above solutions.
[0127] S14: Encode the second quantized residual coefficient to obtain code stream data corresponding to the current block.
[0128] If it is determined that the current block needs to be processed for coefficient adaptive modification, then after obtaining the second quantized residual coefficient, the second quantized residual coefficient is encoded to obtain the code stream data of the current block, and the number of the second quantized residual coefficients whose values are the first preset value is greater than the number of the first quantized residual coefficients whose values are the first preset value; if it is determined that the current block does not need to be processed for coefficient adaptive modification, the first quantized residual coefficient is directly encoded to obtain the corresponding code stream data. Specifically, the first preset value is a non-zero coefficient, such as: 1. Since the number of non-zero coefficients in the second quantized residual coefficient decreases and the number of zero coefficients increases compared to the first quantized residual coefficient, the number of bits used for encoding the non-zero coefficients can be reduced, so that the number of bits of the code stream data corresponding to the same current block is reduced compared to the scheme before the modification.
[0129] This embodiment proposes a method for adaptive image processing based on coefficients generated after quantization, and uses the amplitude of the non-zero coefficients after quantization, the number of non-zero coefficients, the position of the non-zero coefficients, or the number of consecutive zero coefficients located before or after the non-zero coefficients in the scanning order to modify the quantization parameters of the current block; considering the spatial correlation of the coefficient positions, the correlation of adjacent blocks in the spatial domain, and the coefficients of blocks in the same position in the temporal domain, the quantization residual coefficients of the current block can be adaptively modified, which can effectively improve the encoding compression rate with very little quality loss and a small amount of calculation; moreover, the adopted scheme can be applicable to a variety of image formats and a variety of video standard formats, and has a wide range of applicability, and can be applied to scenarios without prediction residuals.
[0130] See also Figure 5 , Figure 5 It is a structural diagram of an embodiment of an encoding device provided in the present application. The encoding device 50 includes a memory 51 and a processor 52 connected to each other. The memory 51 is used to store a computer program. When the computer program is executed by the processor 52, it is used to implement the image encoding method in the above-mentioned embodiment.
[0131] See also Figure 6 , Figure 6 It is a structural diagram of an embodiment of a computer-readable storage medium provided in the present application. The computer-readable storage medium 60 is used to store a computer program 61. When the computer program 61 is executed by a processor, it is used to implement the image encoding method in the above embodiment.
[0132] The computer-readable storage medium 60 may be a server, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which may store program codes.
[0133] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.
[0134] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only illustrative, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0135] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0136] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0137] The above are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. An image coding method, characterized in that: include: Divide the image to be processed into blocks to obtain multiple image blocks; Obtaining a first quantized residual coefficient of a current block among the multiple image blocks; When it is determined based on the relevant information of the current block that the current block satisfies a first preset modification condition, a second quantized residual coefficient is obtained; wherein the second quantized residual coefficient is obtained by modifying the first quantized residual coefficient, and the relevant information includes at least one of the first quantized residual coefficient, information of a related block of the current block, a texture value of the current block, a cost value of the current block, or an image quality of the current block; The second quantized residual coefficients are encoded to obtain code stream data corresponding to the current block, wherein the number of the second quantized residual coefficients whose values are the first preset value is greater than the number of the first quantized residual coefficients whose values are the first preset value.
2. The image encoding method according to claim 1, characterized in that The related block includes at least one of a temporal common position block and a spatial adjacent block, the temporal common position block is an image block in a temporally related image of the image to be processed having the same position as the current block, the temporally related image is an image whose coding order is prior to that of the image to be processed, and the spatial adjacent block is an image block in the image to be processed that is adjacent to the current block; Before the step of obtaining the second quantized residual coefficient, the method includes: When the related block includes the time-domain co-located block, if it is determined whether the quantized residual coefficient of the time-domain co-located block is modified, then it is determined that the current block satisfies the first preset modification condition; or When the related block includes the spatial neighboring block, if it is determined that the quantized residual coefficient of the spatial neighboring block is modified, then determining that the current block satisfies the first preset modification condition; or When the related blocks include the temporal co-located blocks and the spatial neighboring blocks, if it is determined whether the quantized residual coefficients of the temporal co-located blocks are modified, it is determined that the current block satisfies the first preset modification condition.
3. The image encoding method according to claim 1 or 2, characterized in that: The information of the relevant block includes a relevant threshold of the relevant block, and before the step of obtaining the second quantized residual coefficient, the step further includes: When there is a related block for the current block, calculating a related threshold of the current block based on the related threshold of the related block; Based on the relevant threshold of the current block and the relevant information, determining whether the non-zero coefficients in the current block meet a second preset modification condition; If so, the non-zero coefficients in the first quantized residual coefficients are modified to generate the second quantized residual coefficients.
4. The image encoding method according to claim 3, characterized in that: The step of calculating the correlation threshold of the current block based on the correlation threshold of the relevant block comprises: Determine the correlation threshold of the time domain common position block as the correlation threshold of the current block; or Determine the correlation threshold of the spatial adjacent block as the correlation threshold of the current block; or A weighted sum is performed on the correlation threshold of the temporal co-located block and the correlation threshold of the spatial adjacent block to obtain the correlation threshold of the current block.
5. The image encoding method according to claim 3, characterized in that: The relevant threshold includes a first quantity threshold, and before the step of obtaining the second quantized residual coefficient, the step further includes: Determining whether the number of non-zero coefficients in the first quantized residual coefficient is less than or equal to a first number threshold of the current block; If so, it is determined that the current block meets the first preset modification condition.
6. The image encoding method according to claim 3, characterized in that: The step of judging whether the non-zero coefficients in the current block meet the second preset modification condition based on the relevant threshold of the current block and the relevant information comprises: Selecting current non-zero coefficients from the first quantized residual coefficients in sequence according to a scanning order; When the current non-zero coefficient has a previous non-zero coefficient, obtain the number of other coefficients between the current non-zero coefficient and the previous non-zero coefficient to obtain a first number; based on the first number, determine whether the current non-zero coefficient satisfies the second preset modification condition; or When the current non-zero coefficient has a next non-zero coefficient, obtaining the number of other coefficients between the non-zero coefficient and the next non-zero coefficient to obtain a second number; based on the second number, determining whether the current non-zero coefficient satisfies the second preset modification condition; or When the current non-zero coefficient has a previous non-zero coefficient and a next non-zero coefficient, obtain the number of other coefficients between the current non-zero coefficient and the previous non-zero coefficient to obtain a first number; obtain the number of other coefficients between the non-zero coefficient and the next non-zero coefficient to obtain a second number; based on the first number and the second number, determine whether the current non-zero coefficient meets the second preset modification condition.
7. The image encoding method according to claim 6, characterized in that: The step of judging whether the current non-zero coefficient satisfies the second preset modification condition based on the first quantity includes: When the first number is greater than or equal to the first preset number, determining that the non-zero coefficient satisfies the second preset modification condition; The step of judging whether the current non-zero coefficient satisfies the second preset modification condition based on the second number includes: When the second number is greater than or equal to the second preset number, determining that the non-zero coefficient satisfies the second preset modification condition; The step of judging whether the current non-zero coefficient satisfies the second preset modification condition based on the first number and the second number includes: When the first number is greater than or equal to the first preset number, and the second number is greater than or equal to the second preset number, it is determined that the non-zero coefficient satisfies the second preset modification condition.
8. The image encoding method according to claim 7, characterized in that: Before the step of obtaining the second quantized residual coefficient, the method further includes: Based on the image quality of the current block, it is determined whether the current block satisfies the first preset modification condition.
9. The image encoding method according to claim 8, characterized in that: Before the step of obtaining the second quantized residual coefficient, the method includes: Acquire a mapping table, the mapping table comprising at least one quality level interval and modification information corresponding to the quality level interval, the modification information comprising a modification strategy; Matching the image quality of the current block with the mapping table to obtain current modification information, where the current modification information is modification information that matches the image quality; The first quantized residual coefficient is modified using the modification strategy in the current modification information to obtain the second quantized residual coefficient.
10. The image encoding method according to claim 9, characterized in that: The relevant threshold further includes a second quantity threshold and a third quantity threshold, the modification information further includes a second modification condition, the at least one quality level interval includes a first quality level interval and a second quality level interval, and before the step of modifying the first quantized residual coefficient by using the modification strategy in the current modification information, the step includes: When the image quality falls within the first quality level interval, if the first number corresponding to the non-zero coefficient is greater than or equal to the second number threshold, or the second number corresponding to the non-zero coefficient is greater than or equal to the third number threshold, it is determined that the non-zero coefficient satisfies the second modification condition in the current modification information; When the image quality falls within the second quality level interval, if the first number corresponding to the non-zero coefficient is greater than or equal to the second number threshold, and the second number corresponding to the non-zero coefficient is greater than or equal to the third number threshold, determining that the non-zero coefficient satisfies the second modification condition in the current modification information; The minimum value of the second quality level interval is greater than the maximum value of the first quality level interval.
11. The image encoding method according to claim 9, characterized in that: The step of judging whether the current block satisfies the first preset modification condition based on the image quality of the current block further includes: When the image quality of the current block falls within a preset quality range, determining that the current block satisfies the first preset modification condition; or When the image quality of the current block falls within the preset quality range, the first quantized residual coefficient is modified to obtain the second quantized residual coefficient; it is determined whether the difference between the cost value corresponding to the first quantized residual coefficient and the cost value corresponding to the second quantized residual coefficient is less than a first difference threshold; if so, it is determined that the current block meets the first preset modification condition.
12. The image encoding method according to claim 8, characterized in that: Before the step of obtaining the second quantized residual coefficient, the method further includes: Obtaining a quality level interval corresponding to the image quality of the current block to obtain a current quality level interval; Determining whether the current block satisfies a second modification condition corresponding to the current quality level interval; If so, the first quantized residual coefficient is modified based on the modification strategy, the second quantity threshold, the third quantity threshold and the coefficient amplitude threshold that match the current quality level interval to obtain the second quantized residual coefficient.
13. The image encoding method according to claim 3, characterized in that: Before the step of obtaining the second quantized residual coefficient, the method further includes: Based on a second quantity threshold, a third quantity threshold, and a coefficient amplitude threshold, modifying non-zero coefficients in the first quantized residual coefficients to obtain the second quantized residual coefficients; Determine whether a difference between a cost value corresponding to the first quantized residual coefficient and a cost value corresponding to the second quantized residual coefficient is less than a preset difference threshold; If so, it is determined that the current block meets the first preset modification condition.
14. The image encoding method according to claim 3, characterized in that: Before the step of obtaining the second quantized residual coefficient, the method further includes: Determine whether the amplitude of the non-zero coefficient in the first quantized residual coefficient is less than a coefficient amplitude threshold; if so, modify the non-zero coefficient; or When the number of non-zero coefficients in the first quantized residual coefficient is less than a first number threshold, if the amplitude of the non-zero coefficient is less than the coefficient amplitude threshold, the non-zero coefficient is modified.
15. The image encoding method according to claim 3, characterized in that: Before the step of obtaining the second quantized residual coefficient obtained by modifying the first quantized residual coefficient, the method further includes: Determining whether a scanning position of a non-zero coefficient in the first quantized residual coefficient is greater than or equal to a scanning position threshold; If so, the non-zero coefficients are modified.
16. The image encoding method according to claim 14 or 15, characterized in that: The step of modifying the non-zero coefficients comprises: Calculating the difference between the amplitude of the non-zero coefficient and the adjustment step size; If the difference is less than a second preset value, the amplitude of the non-zero coefficient is determined to be the second preset value; if the difference is greater than or equal to the second preset value, the amplitude of the non-zero coefficient is modified to the absolute value of the difference.
17. The image encoding method according to claim 16, characterized in that: Before the step of calculating the difference between the amplitude of the non-zero coefficient and the adjustment step size, the method further comprises: A weighted sum is performed on a first quantity corresponding to the non-zero coefficient and a second quantity corresponding to the non-zero coefficient to obtain the adjustment step size.
18. The image encoding method according to claim 1, characterized in that: Before the step of obtaining the second quantized residual coefficient, the method further includes: Determining whether the texture value of the current block is less than a preset texture threshold; If so, it is determined that the current block meets the first preset modification condition.
19. The image encoding method according to claim 1, characterized in that: Before the step of obtaining the second quantized residual coefficient, the method further includes: Modifying the first quantized residual coefficient to obtain the second quantized residual coefficient; Calculating a difference between a cost value corresponding to the second quantized residual coefficient and a cost value corresponding to the first quantized residual coefficient; Determine whether the difference is greater than a preset difference threshold; If so, it is determined that the current block meets the first preset modification condition.
20. An encoding device, characterized in that: It comprises a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the image encoding method according to any one of claims 1 to 19.
21. A computer-readable storage medium for storing a computer program, characterized in that: When the computer program is executed by a processor, it is used to implement the image encoding method according to any one of claims 1 to 19.
Citation Information
Patent Citations
Quantization matrix selecting method, apparatus of coding and coding / decoding method and system
CN101043633A
High-fidelity H.264 / AVC video three-coefficient reversible steganography method
CN108366259A