Image encoding method, apparatus, device, and medium

By selecting image macroblocks with smooth motion and performing differential coding in the frequency domain, the problem of balancing compression efficiency and computational consumption in existing technologies is solved, achieving efficient and low-power video coding.

CN122340271APending Publication Date: 2026-07-03JINAN MAIWEI INTELLIGENT TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JINAN MAIWEI INTELLIGENT TECHNOLOGY CO LTD
Filing Date
2026-05-27
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively balance compression efficiency and computational cost in video coding. Traditional video coding standards are computationally complex, have high hardware costs and power consumption, and JPEG only supports intra-frame compression, failing to utilize temporal correlations, resulting in low compression efficiency.

Method used

By acquiring the motion intensity of image macroblocks, macroblocks with relatively smooth motion are selected, and differential operations and quantization encoding are performed in the frequency domain to generate encoded data. The strong correlation of frequency domain coefficients is utilized to avoid redundant encoding caused by pixel domain residuals.

Benefits of technology

It improves compression efficiency, reduces encoding complexity and hardware power consumption, and meets the high-efficiency and low-power encoding requirements of scenarios such as ultra-high-definition video, IoT and mobile terminals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122340271A_ABST
    Figure CN122340271A_ABST
Patent Text Reader

Abstract

This disclosure provides an image encoding method, apparatus, device, and medium, relating to the field of image processing technology. The method includes: acquiring the motion intensity of an image macroblock; acquiring the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of a corresponding reference image macroblock when the motion intensity is greater than a first threshold and less than or equal to a second threshold; performing a differential operation on the frequency domain coefficients and the reference frequency domain coefficients in the frequency domain to obtain differential frequency domain coefficients; and quantizing and encoding the differential frequency domain coefficients to obtain the encoded data of the image macroblock. This effectively balances compression efficiency and computational cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of image processing technology, and in particular to an image encoding method, apparatus, device and medium. Background Technology

[0002] With the rapid popularization of ultra-high-definition video, the Internet of Things, and mobile terminals, the amount of video data is growing explosively, creating an urgent need for efficient video coding. Although traditional video coding standards have high compression efficiency, their computational complexity, hardware cost, and power consumption are high, making them unsuitable for low-power scenarios. Furthermore, the Joint Photographic Experts Group (JPEG) only supports intra-frame compression and cannot utilize temporal correlations, resulting in relatively low compression efficiency. Therefore, existing technologies struggle to effectively balance compression efficiency and computational cost. Summary of the Invention

[0003] This disclosure provides an image encoding method, apparatus, device, and medium to at least solve the above-mentioned technical problems existing in the prior art.

[0004] In a first aspect, embodiments of this disclosure provide an image encoding method, the method comprising: The motion intensity of the image macroblock is obtained, which characterizes the degree of motion intensity of the image macroblock relative to the matching macroblock obtained from motion estimation. When the motion intensity is greater than a first threshold and less than or equal to a second threshold, the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the reference image macroblock corresponding to the image macroblock are obtained, where the first threshold is less than the second threshold. In the frequency domain, the frequency domain coefficients and the reference frequency domain coefficients are differentially processed to obtain the differential frequency domain coefficients. The differential frequency domain coefficients are quantized and encoded to obtain the encoded data of the image macroblock.

[0005] Secondly, embodiments of this disclosure provide an image encoding method apparatus, the apparatus comprising: The acquisition module is used to acquire the motion intensity of image macroblocks. Motion intensity characterizes the degree of motion intensity of the image macroblock relative to the matching macroblock obtained by motion estimation. The acquisition module is also used to acquire the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the reference image macroblock corresponding to the image macroblock when the motion intensity is greater than the first threshold and less than or equal to the second threshold, wherein the first threshold is less than the second threshold. The differential operation module is used to perform differential operations on the frequency domain coefficients and the reference frequency domain coefficients in the frequency domain to obtain differential frequency domain coefficients. The quantization and encoding module is used to quantize and encode the differential frequency domain coefficients to obtain the encoded data of the image macroblock.

[0006] Thirdly, embodiments of this disclosure provide an electronic device, including: 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, the instructions being executed by the at least one processor to enable the at least one processor to perform the image encoding method of the first aspect.

[0007] Fourthly, embodiments of this disclosure provide a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the image encoding method according to the first aspect.

[0008] The beneficial technical effects of the image coding method provided in this disclosure are at least as follows: It can accurately select image macroblocks with relatively smooth motion based on the motion intensity of the image macroblock relative to the matching macroblock. For the selected image macroblock, its frequency domain coefficients and the reference frequency domain coefficients of the corresponding reference image macroblock are obtained, and a difference operation is performed on the two in the frequency domain to obtain differential frequency domain coefficients. Subsequently, the differential frequency domain coefficients are quantized and encoded to generate the encoded data corresponding to the image macroblock. Thus, for image macroblocks with relatively smooth motion, the traditional pixel domain residual calculation can be migrated to the frequency domain for differential coding. This fully utilizes the strong correlation of frequency domain coefficients in relatively smooth regions, avoids redundant coding caused by non-zero pixel domain residuals, effectively improves compression efficiency, and only performs the above operations on the selected macroblocks, avoiding full-scale complex calculations. Therefore, while improving compression efficiency, it effectively reduces coding complexity and hardware power consumption, better meeting the high-efficiency and low-power coding requirements of ultra-high-definition video, IoT, and mobile terminals.

[0009] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0010] Figure 1 This is one of the flowcharts illustrating an image encoding method provided in this disclosure. Figure 2 This is an example diagram showing the frequency domain location of differential frequency domain coefficients provided in an embodiment of this disclosure; Figure 3 This is a schematic diagram of the structure of an image encoding system provided in an embodiment of this disclosure; Figure 4 This is a schematic diagram of the structure of an image encoding device provided in an embodiment of this disclosure; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0011] To make the objectives, features, and advantages of this disclosure more apparent and understandable, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without creative effort are within the scope of protection of this disclosure.

[0012] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0013] If the application documents contain similar descriptions such as "first / second", the following explanation shall be added: In the following description, the terms "first / second / third" are used only to distinguish similar objects and do not represent a specific order of objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0014] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0015] This disclosure provides an image encoding method, apparatus, device, and medium to at least solve the technical problem in the prior art that it is difficult to effectively balance compression efficiency and computational consumption. The image encoding method provided by this disclosure will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0016] Figure 1 This is a flowchart illustrating an image encoding method provided in an embodiment of this disclosure. Figure 1 .

[0017] like Figure 1 As shown, the image encoding method provided in this disclosure embodiment may include the following steps: S110, obtain the motion intensity of the image macroblock.

[0018] In some embodiments, the motion intensity described above can be used to characterize the degree of motion intensity of the current image macroblock relative to the matched macroblock obtained from motion estimation. Specifically, a larger motion intensity value indicates a more intense motion state of the image macroblock relative to the matched macroblock, and a lower inter-frame correlation between the two. Conversely, a smaller motion intensity value indicates a smoother motion change of the image macroblock relative to the matched macroblock, and a higher inter-frame correlation between the two. This will not be elaborated further here.

[0019] The aforementioned matching macroblock can be the macroblock that best matches the current image macroblock after a region search is performed on the current image macroblock, and no specific limitation is made here.

[0020] S120: When the motion intensity is greater than the first threshold and less than or equal to the second threshold, obtain the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the reference image macroblock corresponding to the image macroblock.

[0021] The aforementioned reference image macroblock refers to a historical frame image macroblock that has undergone encoding and can be used as a reference for comparison. The frequency domain coefficients and reference frequency domain coefficients mentioned above are transform coefficients obtained by performing a Discrete Cosine Transform (DCT) on the pixel values ​​of the corresponding macroblock, and no specific limitations are imposed here.

[0022] The first and second thresholds mentioned above can be set according to the actual situation. The first threshold can be smaller than the second threshold. For example, the first threshold can be set to 16 and the second threshold can be set to 64. No specific limitation is made here. Both are used to filter out image macroblocks with relatively stable motion and moderate inter-frame correlation. That is, when the motion intensity of an image macroblock is within the range between the first and second thresholds, the motion state of the image macroblock is relatively smooth and the inter-frame correlation is moderate. Further details are not provided here.

[0023] S130 performs a differential operation on the frequency domain coefficients and the reference frequency domain coefficients in the frequency domain to obtain the differential frequency domain coefficients.

[0024] S140 quantizes and encodes the differential frequency domain coefficients to obtain the encoded data of the image macroblock.

[0025] Specifically, the motion intensity of an image macroblock can be obtained, which characterizes the degree of motion intensity of the matching macroblock obtained from the relative motion estimation of the image macroblock. Based on this, if the obtained motion intensity of the image macroblock is greater than a first threshold and less than or equal to a second threshold, it indicates that the motion state of the image macroblock is relatively smooth, and inter-frame differential coding can be used to encode the image macroblock. Specifically, by obtaining the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the corresponding reference image macroblock, and performing a differential operation on the frequency domain coefficients and the reference frequency domain coefficients to obtain differential frequency domain coefficients, and then quantizing and encoding the differential frequency domain coefficients, the encoded data of the image macroblock can be accurately obtained.

[0026] In this embodiment, image macroblocks with relatively smooth motion can be accurately selected based on the motion intensity of the image macroblock relative to the matching macroblock. For the selected image macroblock, its frequency domain coefficients and the reference frequency domain coefficients of the corresponding reference image macroblock are obtained, and a difference operation is performed on the two in the frequency domain to obtain differential frequency domain coefficients. Subsequently, the differential frequency domain coefficients are quantized and encoded to generate the encoded data corresponding to the image macroblock. In this way, for image macroblocks with relatively smooth motion, the traditional pixel domain residual calculation can be migrated to the frequency domain for differential coding. This can fully utilize the strong correlation of frequency domain coefficients in relatively smooth regions, avoid redundant coding caused by non-zero pixel domain residuals, effectively improve compression efficiency, and perform the above operations only on the selected macroblocks, avoiding full-scale complex calculations. Thus, while improving compression efficiency, it effectively reduces coding complexity and hardware power consumption, better meeting the high-efficiency and low-power coding requirements of ultra-high-definition video, IoT, and mobile terminal scenarios.

[0027] In order to accurately calculate the differential frequency domain coefficients, in one embodiment, the above-mentioned S130 may specifically include the following steps: Obtain the quantization step size parameters of the image macroblock and the reference quantization step size parameters of the reference image macroblock; The reference frequency domain coefficients are compensated based on the quantization step size parameter and the reference quantization step size parameter. Differential frequency domain coefficients are obtained by performing differential operations on the frequency domain coefficients and the compensated reference frequency domain coefficients in the frequency domain.

[0028] The quantization step size parameter can be a step size control parameter used to quantize the frequency domain coefficients, adjusting the quantization accuracy and compression ratio. Correspondingly, the reference quantization step size parameter is a step size control parameter used to quantize a reference frequency domain coefficient; no specific limitations are imposed here.

[0029] Specifically, it is possible to obtain the quantization step size parameter of the image macroblock and the reference quantization step size parameter of the reference image macroblock, and to perform compensation processing on the reference frequency domain coefficients based on the quantization step size parameter and the reference quantization step size parameter to obtain the compensated reference frequency domain coefficients adapted to the current quantization standard. Then, it is possible to perform differential operation on the frequency domain coefficients and the compensated reference frequency domain coefficients in the frequency domain to obtain accurate differential frequency domain coefficients.

[0030] In one example, assuming the image macroblock is 16×16, it can be divided into six 8×8 basic blocks based on the luma and chroma components, containing four luma Y sub-blocks, one chroma U sub-block, and one chroma V sub-block. Performing a two-dimensional discrete cosine transform on each basic block generates 64 sets of frequency domain coefficients with 12-bit precision. The specific transform formula is as follows: (1); in, Represents pixel coordinates in the spatial domain. Indicates the horizontal position. Indicates the vertical position. This represents the coordinates corresponding to the frequency domain coefficients in the frequency domain. Represents the horizontal frequency component. Represents the frequency component in the vertical direction. The pixel coordinates in the basic block are pixel values, The coordinates after DCT transformation are The frequency domain coefficients. The coefficient function is shown in the following formula: (2); in, The input parameters of the function are respectively represented in formula (1). or .

[0031] In actual operation, the reference quantization step size parameter and corresponding reference frequency domain coefficients of the reference image macroblock can be read from the reference coefficient cache memory. A single set of coefficients contains 12 bits of coefficient values ​​and 8 bits of reference quantization step size parameters. The differential calculation is then performed using the following formula: (3); in, These are the differential frequency domain coefficients. These are the frequency domain coefficients of the image macroblock. The reference frequency domain coefficients are used as a reference image macroblock. To quantize the step size parameter, For reference quantization step size, These are the compensated reference frequency domain coefficients.

[0032] It should be noted that the above-mentioned division method of "six 8×8 basic blocks" is for the YUV 4:2:0 format. In this format, the four pixels in each 2×2 pixel block have independent luminance components Y, while the chrominance components U and V are shared as a group. Therefore, each 16×16 image macroblock requires the calculation of six sets of DCT transformations (four luminance Y sub-blocks, one chrominance U sub-block, and one chrominance V sub-block). YUV 4:2:0 is a widely used image format, and this disclosure uses it as an example for illustration. In addition, for other formats, such as YUV 4:2:2 (each 2×2 pixel block retains four independent Y components, but only samples two U and two V components, with chrominance components shared every other pixel) and YUV 4:4:4 (each pixel has independent Y, U, and V components), the basic block division method and the number of DCT transformation groups can be adjusted accordingly with reference to the above principle, and this disclosure does not make specific limitations on this.

[0033] In this embodiment, by introducing the quantization step size parameter of the image macroblock and the reference quantization step size parameter of the reference image macroblock, the reference frequency domain coefficients are compensated, which can eliminate the coefficient deviation caused by the inconsistency of the quantization step size between the current image macroblock and the reference macroblock, effectively improving the accuracy of the differential frequency domain coefficients, and thus facilitating the optimization of subsequent coding processing effects.

[0034] Based on this, in order to simplify the calculation process and reduce computational overhead, in one embodiment, the step of compensating the reference frequency domain coefficients according to the quantization step size parameter and the reference quantization step size parameter may specifically include: Using the quantization step size parameter and the reference quantization step size parameter as indexes, the scaling factor is queried through a preset lookup table; The compensated reference frequency domain coefficients are determined based on the product of the reference frequency domain coefficients and the scaling factor.

[0035] The aforementioned preset lookup table can be pre-set based on practical experience or circumstances for querying scaling factors, and is not specifically limited here. The aforementioned scaling factor can be used to characterize the proportional relationship between the quantization step size parameter and the reference quantization step size parameter, and is not specifically limited here.

[0036] Specifically, the corresponding scaling factor can be quickly obtained by using the quantization step size parameter and the reference quantization step size parameter as indexes through a preset lookup table, and the accurate and suitable compensated reference frequency domain coefficients can be obtained based on the product of the reference frequency domain coefficients and the scaling factor.

[0037] In one example, the steps described above, which use the quantization step size parameter and the reference quantization step size parameter as indexes to look up the scaling factor through a preset lookup table, can be represented by the following formula: (4); in, A 64×64 pre-defined lookup table is used to store data with a scaling factor of 1 / 256. This is the scaling factor obtained from the query.

[0038] Based on this, the compensated reference frequency domain coefficients can be calculated using the following formula: (5); in, Indicates moving to the right z1 depends on the actual situation; for example, it can be set to 8. No specific limit is made here.

[0039] The calculation process only requires one fixed-point multiplication and shift operation, without the need for floating-point operations, which greatly reduces the computational complexity.

[0040] In this embodiment, the corresponding scaling factor can be quickly obtained by looking up a table, and the reference frequency domain coefficients can be adaptively adjusted based on the scaling factor. This not only accurately obtains the compensated reference frequency domain coefficients, but also greatly simplifies the overall calculation logic, effectively avoids coefficient deviations caused by inconsistent quantization step sizes, and thus improves the accuracy of the differential frequency domain coefficients.

[0041] In order to accurately obtain the encoded data of image macroblocks, in one embodiment, the above-mentioned S140 may specifically include the following steps: The differential frequency domain coefficients are classified according to their frequency domain location to obtain differential frequency domain coefficients of at least two categories; According to the processing strategies corresponding to different categories, the differential frequency domain coefficients of each category are processed to obtain the processed differential frequency domain coefficients. The processed differential frequency domain coefficients are quantized and encoded to obtain the encoded data of the image macroblock.

[0042] The frequency domain position mentioned above refers to the position of the differential frequency domain coefficient in the frequency domain matrix after DCT transformation. It is used to distinguish between DC coefficient, low-frequency AC coefficient, mid-frequency AC coefficient, and high-frequency AC coefficient. No specific limitation is made here.

[0043] In one example, after performing DCT transform and differential operations on an 8×8 basic block, 64 differential frequency domain coefficients are obtained, each corresponding to a frequency domain position, such as... Figure 2 As shown ( Figure 2 The values ​​in the table represent the frequency domain positions of the frequency domain matrix after the DCT transform. Figure 2The frequency domain positions shown are as follows: if the frequency domain position is 0, the corresponding coefficient is the DC coefficient; if the frequency domain position is 1-5, the corresponding coefficient is the low-frequency AC coefficient; if the frequency domain position is 6-35, the corresponding coefficient is the mid-frequency AC coefficient; and if the frequency domain position is 36-63, the corresponding coefficient is the high-frequency AC coefficient. No further restrictions are imposed here.

[0044] Specifically, the differential frequency domain coefficients can be classified according to their corresponding frequency domain positions to obtain at least two categories of differential frequency domain coefficients. The differential frequency domain coefficients of each category can be processed according to the processing strategies corresponding to different categories to obtain the processed differential frequency domain coefficients. Finally, the processed differential frequency domain coefficients are quantized and encoded to obtain the encoded data of the image macroblock.

[0045] It should be noted here that the processing strategies for the differential frequency domain coefficients corresponding to different frequency domain positions are as follows: If the differential frequency domain coefficient is a DC coefficient, a separate differential coding strategy is adopted. Since the DC coefficient represents the overall average brightness of the image macroblock and has the highest energy, its value may still be large even after differential operation. Separate coding can ensure the coding accuracy of brightness information. If the differential frequency domain coefficient is a low-frequency AC coefficient, a direct differential coding strategy is adopted to preserve the high precision of the coefficient. If the differential frequency domain coefficient is a mid-to-high frequency AC coefficient and the absolute value of the differential frequency domain coefficient is less than 4, it is forcibly set to zero to make full use of the human visual masking effect and compress redundant data without affecting the visual experience. If the frequency domain coefficient is a high-frequency AC coefficient and the high-frequency AC coefficient corresponding to the reference image macroblock is zero, and the current differential frequency domain coefficient is less than the quantization step size parameter, the zero value is directly reused to further reduce coding redundancy.

[0046] Thus, the differential frequency domain coefficients can be quantized using the following formula: (6); in, These are the quantized differential frequency domain coefficients. These are the original differential frequency domain coefficients. To quantize the step size parameter, This is the quantization function.

[0047] Subsequently, after quantization, a zigzag scan, run-length encoding, and Huffman encoding are performed to obtain the corresponding encoded data.

[0048] In this embodiment, the differential frequency domain coefficients are classified according to their frequency domain location, and different processing strategies are adopted for different categories of differential frequency domain coefficients. This process preserves the encoding accuracy of key information such as DC coefficients and low-frequency AC coefficients, while also compressing mid-to-high frequency redundant data through visual masking effects and zero-value reuse. This further improves encoding efficiency and compression performance while ensuring image visual quality, better meeting the encoding requirements of low power consumption and high compression.

[0049] In order to provide a comprehensive and detailed description of the image encoding method provided in the embodiments of this disclosure, in one embodiment, the image encoding method provided in the embodiments of this disclosure may further include the following steps: When the motion intensity is less than or equal to the first threshold, the encoded data of the target image macroblock with the same spatial coordinates as the image macroblock is obtained; Determine the encoded data of the target image macroblock, which is the encoded data of the image macroblock.

[0050] The target image macroblock is an image macroblock in a historical frame that has been encoded and has the same spatial location as the current image macroblock; no specific limitation is made here.

[0051] Specifically, when the motion intensity is less than or equal to the first threshold, it indicates that the motion amplitude of the matching macroblock obtained by relative motion estimation of the image macroblock is extremely small and the inter-frame correlation is extremely high. At this time, the encoded data of the target image macroblock with the same spatial coordinates can be directly reused without performing frequency domain transformation, differential, quantization and encoding operations on the current image macroblock.

[0052] In this embodiment, based on the motion intensity of the matching macroblocks estimated by the relative motion of the image macroblocks, image macroblocks with extremely low motion intensity and extremely high inter-frame correlation can be accurately screened out. For the screened image macroblocks, the encoded data of the target image macroblocks with the same spatial coordinates as the image macroblocks can be directly reused. In this way, the encoding process can be simplified to the greatest extent, the amount of computation and hardware power consumption can be further reduced, while ensuring encoding consistency and improving the overall encoding efficiency.

[0053] In another embodiment, the image encoding method provided in this disclosure may further include the following steps: When the motion intensity is greater than the second threshold, the image macroblock is encoded using a preset intra-frame coding method to obtain the encoded data of the image macroblock.

[0054] The preset intra-frame encoding method is a method that encodes based solely on the information within the current image macroblock, without relying on historical frame data. For example, the preset intra-frame encoding method can be JPEG encoding, without any specific limitation here.

[0055] Specifically, when the motion intensity is greater than the second threshold, it indicates that the motion of the image macroblock relative to the matching macroblock is intense and the inter-frame correlation is weak. At this time, the image macroblock can be encoded using a preset intra-frame coding method to obtain the corresponding coded data.

[0056] In this embodiment, based on the motion intensity of the matching macroblocks obtained by relative motion estimation of image macroblocks, image macroblocks with excessively high motion intensity and weak inter-frame correlation can be accurately screened, and intra-frame coding can be applied to the image macroblocks, thereby avoiding invalid inter-frame prediction and differential operations, so as to ensure coding efficiency and image reconstruction quality.

[0057] Furthermore, in order to describe the image encoding method provided by the embodiments of this disclosure in more detail and accurately, in one embodiment, the image encoding method provided by the embodiments of this disclosure may further include: Obtain the flatness information of image macroblocks.

[0058] The flatness information mentioned above is used to characterize the uniformity of pixel value distribution within the image region corresponding to the image macroblock, and no specific limitations are made here.

[0059] It should be noted that this flatness information can be identified numerically. A value of 1 indicates that the image region corresponding to the macroblock is flat, while a value of 0 indicates that the image region corresponding to the macroblock is not flat. Alternatively, it can be identified by "yes" or "no," but this is not specifically limited here.

[0060] Based on this, the aforementioned S120 may specifically include: When the flatness information indicates that the image region corresponding to the image macroblock belongs to a flat region, and the motion intensity is greater than the first threshold and less than or equal to the third threshold, the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the reference image macroblock corresponding to the image macroblock are obtained.

[0061] The third threshold can be determined according to the actual situation, and the third threshold is greater than the second threshold. For example, the third threshold can be set to 128, which will not be elaborated on here.

[0062] Specifically, the flatness information of the image macroblock can be obtained first to determine whether the image macroblock is a flat region with gradual pixel changes. Based on this, if the flatness information indicates that the image region corresponding to the image macroblock is a flat region, and the motion intensity is greater than a first threshold and less than or equal to a third threshold, it indicates that the motion state of the image macroblock is relatively smooth. Then, the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the corresponding reference image macroblock can be obtained, and the image macroblock can be encoded using inter-frame differential coding.

[0063] Alternatively, if the flatness information indicates that the image region corresponding to the image macroblock is a flat region and the motion intensity is greater than the third threshold, then the image macroblock is encoded using a preset intra-frame coding method to generate corresponding coded data. The specific encoding process will not be described here.

[0064] Alternatively, if the flatness information indicates that the image region corresponding to the image macroblock is a flat region and the motion intensity is less than or equal to the first threshold, then the target image macroblock encoded data that is consistent with the spatial coordinates of the image macroblock is directly retrieved for reuse.

[0065] Meanwhile, the image coding method provided in this embodiment can add a valid flag bit for a reference image macroblock as an auxiliary determination condition, and combine the flag bit state to jointly complete the coding decision: If the valid flag bit of the reference image macroblock is the first flag bit (indicating that the reference image macroblock is valid), and the flatness information indicates that the image region corresponding to the image macroblock is a flat region and the motion intensity is less than or equal to the first threshold, the coding data of the target image macroblock with the same spatial coordinates is directly reused. If the valid flag bit of the reference image macroblock is the second flag bit (indicating that the reference image macroblock is invalid), and the flatness information indicates that the image region corresponding to the image macroblock is a flat region and the motion intensity is between the first threshold and the third threshold, the corresponding frequency domain coefficients and the reference frequency domain coefficients are obtained for inter-frame coding; if the flatness information indicates that the image region corresponding to the image macroblock is a flat region and the motion intensity is greater than the third threshold, then intra-frame coding is uniformly used to complete the image macroblock coding.

[0066] It should be noted that the valid flag bits of the aforementioned reference image macroblocks can be obtained from a static region mapping table. This table is maintained in on-chip static random-access memory (SRAM) at a resolution of macroblock (MB), meaning each bit corresponds to a macroblock location. Initially, all locations are marked as 1 (i.e., valid). When a macroblock is determined to be in fast motion, the corresponding location in the SRAM is written to 0 (i.e., invalid), and a countdown timer is started (freezing for 64 frames by default). During the countdown, even if the motion intensity indicates low-intensity motion, it is still forcibly classified as slow mode to avoid misjudgment of static regions.

[0067] In this embodiment, by combining flatness information with motion intensity for dual screening, image macroblocks suitable for frequency domain differential coding can be selected more accurately, further improving the adaptability of the coding strategy. While ensuring image details, redundant calculations are further reduced, and overall compression efficiency is improved.

[0068] In order to accurately obtain the flatness information of image macroblocks, in one embodiment, the step of obtaining the flatness information of image macroblocks includes: Calculate the first gradient value of the image macroblock in the first direction and the second gradient value of the image macroblock in the second direction; When both the first gradient value and the second gradient value satisfy the preset flatness condition, flatness information is generated to indicate that the image region corresponding to the image macroblock belongs to the flat region.

[0069] In some embodiments, the first direction may be perpendicular to the second direction, wherein the first direction may be horizontal and the second direction may be vertical, without specific limitation.

[0070] In addition, the first gradient value can characterize the pixel change amplitude in the first direction, and correspondingly, the second gradient value is used to characterize the pixel change amplitude of the image macroblock in the second direction, without being specifically limited here.

[0071] The aforementioned preset flatness condition can be determined according to the actual situation. It is used to determine whether the image region corresponding to the image macroblock is a flat region. For example, the preset flatness condition can be set to the first gradient value and the second gradient value being less than the first preset flatness threshold, or the sum of the first gradient value and the second gradient value being less than the second preset flatness threshold, etc. The first preset flatness threshold and the second preset flatness threshold can be determined according to the actual situation, and no specific limitation is made here.

[0072] Specifically, the gradient values ​​of the image macroblock in two mutually perpendicular directions, namely the first gradient value and the second gradient value, can be calculated separately. By judging whether the first gradient value and the second gradient value meet the preset flatness condition, it can be accurately judged whether the pixel distribution inside the image macroblock is uniform and whether the texture is smooth. When the first gradient value and the second gradient value meet the preset flatness condition, it indicates that the pixel distribution inside the image macroblock is uniform and the texture is smooth. Then, flatness information is generated to indicate that the image region corresponding to the image macroblock belongs to the flat region.

[0073] In one example, the first gradient value can be obtained through The calculation shows that the second gradient value can be obtained through... The calculation yielded that, For spatial coordinates pixel values, Spatial coordinates , Spatial coordinates are The pixel value is not specifically limited here.

[0074] In this embodiment, the image macroblock is determined to be a flat region by calculating the gradient values ​​of the image macroblock in two mutually perpendicular directions and determining whether the gradient values ​​meet the preset flatness condition. The determination method is simple, efficient and computationally inefficient. In this way, flatness information can be accurately obtained without significantly increasing the coding complexity.

[0075] In addition, in order to accurately obtain the motion intensity of the image macroblock relative to the matching macroblock, so that the encoding method can be selected according to the specific value of the motion intensity to obtain the encoded data of the image macroblock, in one embodiment, the above S110 may specifically include the following steps: By performing motion estimation on image macroblocks, residual information between image macroblocks and matching macroblocks, as well as motion information of image macroblocks relative to matching macroblocks, can be obtained. The motion intensity is calculated based on the residual information and motion information.

[0076] The residual information can characterize the degree of pixel difference between the image macroblock and the matching macroblock, and the motion information can characterize the spatial offset between the image macroblock and the matching macroblock. The motion information can include a motion vector. Specifically, the motion vector can include a first component of the image macroblock in a first direction and a second component of the image macroblock in a second direction, without being specifically limited here.

[0077] Specifically, motion estimation can be performed on image macroblocks first to obtain residual information between the image macroblock and the matching macroblock, as well as motion information of the image macroblock relative to the matching macroblock. Then, based on the residual information and motion information, a comprehensive calculation is performed to obtain the motion intensity that can accurately reflect the motion state of the image macroblock and the degree of inter-frame correlation.

[0078] In one example, the steps described above for calculating the motion intensity based on residual information and motion information can be represented by the following formula: (7); in, For exercise intensity, For residual information, Shift it to the right when processing residual information for hardware. The position, It can be set to 8 (mathematically, it represents the integer part of the quotient after dividing by 256). , For example, motion vector components, For the first component of the image macroblock in the first direction, This is the second component of the image macroblock in the second direction.

[0079] In this embodiment, by performing motion estimation on image macroblocks, obtaining corresponding residual information and motion information, and combining the residual information and motion information to calculate motion intensity, the motion characteristics and inter-frame correlation of image macroblocks can be described more comprehensively and accurately, which facilitates the subsequent adaptive selection of the corresponding encoding method based on the motion intensity.

[0080] Based on this, in one embodiment, before obtaining the residual information between the image macroblock and the matching macroblock, and the motion information of the image macroblock relative to the matching macroblock by performing motion estimation on the image macroblock, the image coding method provided in this disclosure embodiment may further include: Within a first search range centered on an image macroblock, the image macroblock is searched with a step length to obtain multiple first matching macroblocks, and a first target matching macroblock that meets the first preset condition is selected from the multiple first matching macroblocks. Within a second search range centered on the first target matching macroblock, the first target matching macroblock is searched with a second step size to obtain multiple second matching macroblocks. From these multiple second matching macroblocks, second matching macroblocks that meet the second preset conditions are selected as matching macroblocks.

[0081] In some embodiments, the first search and the first step length are used to achieve coarse positioning, quickly determining the approximate direction of motion; the second search and the second step length are used to achieve fine positioning, further improving the accuracy of motion estimation. Therefore, the second search range is smaller than the first search range, and / or the second step length is smaller than the first step length, which is not specifically limited here.

[0082] Specifically, firstly, a sparse search is performed within a relatively large search range centered on the image macroblock (i.e., the first search range) with a relatively coarse step size (i.e., the first step size) to obtain multiple first matching macroblocks, from which the first target matching macroblock that meets the first preset condition is selected. Subsequently, a fine search is performed within a smaller search range centered on the first target matching macroblock (i.e., the second search range) with a relatively fine step size (i.e., the second step size) to obtain multiple second matching macroblocks, from which the second matching macroblock that meets the second preset condition is selected as the final matching macroblock.

[0083] The first and second preset conditions can both be preset based on practical experience. For example, the first preset condition can be the minimum sum of the absolute differences between the image macroblock and the first matching macroblock, and the second preset condition can be the minimum sum of the absolute differences between the first target matching macroblock and the second matching macroblock. No specific limitations are imposed here. In one example, if the image macroblock is 16×16, it is downsampled by 4:1 (averaging every 4×4 blocks) to generate an 8×8 low-resolution block for the coarse search stage, as shown in the following formula: (8); in, , [0, 7]. The coordinates of the 8×8 low-resolution block obtained after downsampling the current 16×16 image macroblock are: The pixel value is . m is the row offset within the 4×4 pixel block, and n is the column offset within the 4×4 pixel block, both ranging from 0 to 3. The coordinates of the 16×16 image macroblock to be encoded are Pixel values; This represents the pixel coordinates in the spatial domain within the 16×16 macroblock, where For the row index of the image macroblock, This is the column index for the image macroblock, corresponding to the 8×8 low-resolution block. The specific pixels within the 4×4 pixel block corresponding to the position.

[0084] Based on this 8×8 low-resolution block, a coarse search can be performed: Centered on the original 16×16 image macroblock, the first search range is set to ±8 pixels, and the first step length is 4 pixels, resulting in a total of 9 first-matching macroblocks, whose position set... The formula is shown below: (9); The corresponding position offset is ∈ Calculate the 8×8 Sum of Absolute Differences (SAD): (10); in, The position offset is The SAD value corresponding to the first matching macroblock. The coordinates of the macroblock in the aforementioned low-resolution block image are pixel values, The coordinates in the first matching macroblock are The pixel value.

[0085] The position with the smallest SAD value is selected as the candidate direction for the first target macroblock matching: (11); in, The position offset of the macroblock to match the first target.

[0086] Next, using the first target matching macroblock as the center, a second search range of ±2 pixels and a second step size of 1 pixel are set for a fine search, resulting in a set of 25 second matching macroblocks. as follows: (12); Among them, here , ∈ .

[0087] For each position offset ∈ Calculate the SAD of the complete 16×16 block: (13); in, Here, curr16×16[i][j] represents the SAD value corresponding to the second matching macroblock, and curr16×16[i][j] represents the coordinates of the current 16×16 image macroblock to be encoded. pixel values, The coordinates in the 16×16 block for the second matching macroblock are The pixel value.

[0088] Filter out the positions with the smallest SAD values ​​to determine the final matching macroblocks and their corresponding smallest SAD values: (14); (15); in, This is the final offset of the matching macroblock. This refers to the residual information between the image macroblock and the final matched macroblock. It should be noted that the aforementioned... = , = .

[0089] In this embodiment, candidate regions are first quickly identified through a large-scale, coarse-step search, followed by a precise search with a small-scale, fine-step search, thereby efficiently determining the optimal matching macroblock. Thus, this hierarchical two-step motion search significantly reduces the computational load and complexity of the search while maintaining motion estimation accuracy, balancing coding efficiency and search accuracy, and making it more suitable for coding scenarios with low power consumption and high real-time requirements.

[0090] Furthermore, this disclosure also provides an image encoding system, which can be specifically described in conjunction with the appendix. Figure 3 A detailed description of an image encoding system provided in the embodiments of this disclosure is provided below.

[0091] Figure 3This is a schematic diagram of the structure of an image encoding system provided in an embodiment of this disclosure.

[0092] like Figure 3 As shown, the image coding system 300 provided in this embodiment may include a simplified motion estimation unit 31, a hierarchical prediction mode selector 32, a DCT domain differential encoder 33, and a reference coefficient cache manager 34. The hierarchical prediction mode selector 32 is connected to the simplified motion estimation unit 31, the DCT domain differential encoder 33, and the reference coefficient cache manager 34, respectively. The DCT domain differential encoder 33 is connected to the reference coefficient cache manager 34; however, no specific limitations are applied here.

[0093] The simplified motion estimation unit 31 is used to perform a two-step motion search (coarse search + fine search) on the image macroblock. By performing a sparse search with a large range of coarse steps and a precise search with a small range of fine steps on the image macroblock, the optimal matching macroblock is determined, and the motion intensity of the image macroblock relative to the matching macroblock is calculated and output.

[0094] Hierarchical prediction mode selector 32: Based on the motion intensity information output by the simplified motion estimation unit and combined with the flatness information of the image macroblock, it divides the image macroblock into three modes: static, slow, or fast, so that they correspond to different coding strategies.

[0095] DCT domain differential encoder 33: When a slow mode is determined, it combines the quantization step size parameter of the image macroblock with the reference quantization step size parameter of the reference image macroblock to perform compensation processing on the reference frequency domain coefficients, and then performs frequency domain differential operation, quantization and encoding to obtain the corresponding encoded data.

[0096] Reference coefficient cache manager 34: It is mainly responsible for managing the reference coefficient cache. Its architecture breaks through the traditional pixel domain reference frame storage method. It only stores the reference frequency domain coefficients (not pixel values) of the reference image macroblock after DCT transformation, as well as the reference quantization step size parameters and valid flag bits.

[0097] The aforementioned reference coefficient cache manager can employ a three-dimensional index address, with the three dimensions defined as follows: Dimension 1: MB address (for 1080p video, a total of 8160 macroblocks, requiring a 13-bit address for identification); Dimension 2: 8×8 block index (each 16×16 image macroblock contains 4 luma Y subblocks, 1 chroma U subblock, and 1 chroma V subblock, totaling 6 8×8 basic subblocks, requiring a 3-bit index for differentiation); Dimension 3: coefficient position (each 8×8 basic subblock generates 64 frequency domain coefficients after DCT transformation, requiring a 6-bit index to identify the specific position of each coefficient).

[0098] Based on this, the entry storage format corresponding to each index address is as follows: [Reference quantization step size parameter Q (8 bits) | Reference frequency domain coefficient (12 bits) | Reference image block valid flag (1 bit)].

[0099] Furthermore, the caching strategy employed by the aforementioned reference coefficient cache manager is as follows: Static region caching: For image macroblocks marked as static, the reference coefficient cache manager locks their corresponding DCT frequency domain coefficients in the cache, prohibiting overwriting and ensuring fast access; Dynamic replacement: A replacement strategy based on video temporal correlation is adopted, prioritizing the retention of reference coefficients for image macroblocks referenced within the most recent N frames, improving cache hit rate; Compressed storage: Bitmap compression is used for all-zero DCT subblocks, requiring only 1 bit per 8×8 basic subblock to indicate whether it is an all-zero block, effectively reducing cache storage overhead. In addition, the reference coefficient cache manager control logic can automatically generate a Valid_ref (i.e., reference valid) signal. When the requested reference image macroblock coefficients are not in the on-chip cache during encoding, the Valid_ref signal triggers a double data rate read request, simultaneously freezing the encoding processing of the current image macroblock until the reference coefficient data is read and processing resumes, ensuring the continuity and accuracy of the encoding process.

[0100] Based on the same inventive concept, this disclosure provides an image encoding device, which can be specifically described in conjunction with the appendix. Figure 4 A detailed description of an image encoding apparatus provided in the embodiments of this disclosure will be given.

[0101] Figure 4 This is a schematic diagram of the structure of an image encoding device provided in an embodiment of this disclosure.

[0102] like Figure 4 As shown, the image encoding device 400 may include: The acquisition module 410 is used to acquire the motion intensity of the image macroblock, where the motion intensity characterizes the degree of motion intensity of the image macroblock relative to the matching macroblock obtained by motion estimation. The acquisition module 410 is also used to acquire the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the reference image macroblock corresponding to the image macroblock when the motion intensity is greater than the first threshold and less than or equal to the second threshold, wherein the first threshold is less than the second threshold. The differential operation module 420 is used to perform differential operations on the frequency domain coefficients and the reference frequency domain coefficients in the frequency domain to obtain differential frequency domain coefficients. The quantization and encoding module 430 is used to quantize and encode the differential frequency domain coefficients to obtain the encoded data of the image macroblock.

[0103] In one embodiment, the image encoding apparatus provided in this disclosure may include: The acquisition module is also used to acquire the quantization step size parameters of the image macroblock and the reference quantization step size parameters of the reference image macroblock; The compensation module is used to compensate the reference frequency domain coefficients based on the quantization step size parameters and the reference quantization step size parameters. The differential operation module is specifically used to perform differential operations on the frequency domain coefficients and the compensated reference frequency domain coefficients in the frequency domain to obtain differential frequency domain coefficients.

[0104] In one embodiment, the image encoding apparatus provided in this disclosure may include: The acquisition module is also used to query the scaling factor through a preset lookup table using the quantization step size parameter and the reference quantization step size parameter as indexes. The scaling factor represents the proportional relationship between the quantization step size parameter and the reference quantization step size parameter. The determination module is used to determine the compensated reference frequency domain coefficients based on the product of the reference frequency domain coefficients and the scaling factor.

[0105] In one embodiment, the image encoding apparatus provided in this disclosure may include: The classification module is used to classify the differential frequency domain coefficients according to their frequency domain location, and obtain differential frequency domain coefficients of at least two categories; The processing module is used to process the differential frequency domain coefficients of each category according to the processing strategies corresponding to different categories, so as to obtain the processed differential frequency domain coefficients. The quantization and encoding module is specifically used to quantize and encode the processed differential frequency domain coefficients to obtain the encoded data of the image macroblock.

[0106] In one embodiment, the image encoding apparatus provided in this disclosure may include: The acquisition module is also used to acquire the encoded data of a target image macroblock that has the same spatial coordinates as the image macroblock when the motion intensity is less than or equal to a first threshold. The determination module is used to determine the encoded data of the target image macroblock, which is the encoded data of the image macroblock.

[0107] In one embodiment, the image encoding apparatus provided in this disclosure may include: The encoding module is used to encode image macroblocks using a preset intra-frame coding method when the motion intensity is greater than a second threshold, so as to obtain the encoded data of the image macroblocks.

[0108] In one embodiment, the image encoding apparatus provided in this disclosure may include: The acquisition module is also used to acquire the flatness information of image macroblocks. The flatness information is used to characterize the uniformity of pixel value distribution within the image region corresponding to the image macroblock. The acquisition module is specifically used to acquire the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the reference image macroblock when the flatness information indicates that the image region corresponding to the image macroblock belongs to a flat region and the motion intensity is greater than the first threshold and less than or equal to the third threshold; wherein the third threshold is greater than the second threshold.

[0109] In one embodiment, the image encoding apparatus provided in this disclosure may include: The calculation module is used to calculate the first gradient value of the image macroblock in a first direction and the second gradient value of the image macroblock in a second direction, wherein the first direction and the second direction are perpendicular to each other; The determination module is used to generate flatness information to indicate that the image region corresponding to the image macroblock belongs to the flat region, provided that both the first gradient value and the second gradient value satisfy the preset flatness condition.

[0110] In one embodiment, the image encoding apparatus provided in this disclosure may include: The acquisition module is specifically used to obtain residual information between the image macroblock and the matching macroblock, as well as motion information of the image macroblock relative to the matching macroblock, by performing motion estimation on the image macroblock; wherein, the residual information represents the degree of pixel difference between the image macroblock and the matching macroblock, and the motion information represents the spatial offset between the image macroblock and the matching macroblock. The calculation module is used to calculate the motion intensity based on the residual information and motion information.

[0111] In one embodiment, the image encoding apparatus provided in this disclosure may include: The search module is used to search for image macroblocks within a first search range centered on the image macroblocks, with a step length, to obtain multiple first matching macroblocks, and to filter the first target matching macroblocks that meet the first preset conditions from the multiple first matching macroblocks. The search module is also used to search for the first target matching macroblock with a second step size within a second search range centered on the first target matching macroblock, to obtain multiple second matching macroblocks, and to select second matching macroblocks that meet the second preset conditions from the multiple second matching macroblocks as matching macroblocks; Wherein, the second search range is smaller than the first search range, and / or the second step size is smaller than the first step size.

[0112] It is understood that, when implementing the corresponding image encoding method, the image encoding method apparatus provided in the above embodiments can allocate the above processing to different program modules as needed to complete all or part of the processing described above. Furthermore, the apparatus and the corresponding method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process is detailed in the method embodiments, which will not be repeated here.

[0113] This application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform an image encoding method.

[0114] This application provides a computer-readable storage medium storing executable instructions, wherein the executable instructions are stored and when executed by a processor, the processor will execute the image encoding method provided in this application.

[0115] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.

[0116] In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.

[0117] As an example, executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborating files (e.g., a file that stores one or more modules, subroutines, or code sections).

[0118] As an example, executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.

[0119] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure; as shown below. Figure 5 As shown, the electronic device 50 includes: a processor 501, and a memory 502 communicatively connected to the processor 501; the memory 502 stores instructions executable by the processor 501. The instructions are executed by the processor 501 to enable the processor 501 to perform: The motion intensity of the image macroblock is obtained, which characterizes the degree of motion intensity of the image macroblock relative to the matching macroblock obtained from motion estimation. When the motion intensity is greater than a first threshold and less than or equal to a second threshold, the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the reference image macroblock corresponding to the image macroblock are obtained, where the first threshold is less than the second threshold. In the frequency domain, the frequency domain coefficients and the reference frequency domain coefficients are differentially processed to obtain the differential frequency domain coefficients. The differential frequency domain coefficients are quantized and encoded to obtain the encoded data of the image macroblock.

[0120] The electronic devices and corresponding image encoding methods provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.

[0121] In practical applications, the electronic device 50 may further include at least one network interface 503. The various components of the electronic device 50 are coupled together via a bus system 504. It is understood that the bus system 504 is used to implement communication between these components. In addition to a data bus, the bus system 504 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 5 All buses are labeled as bus system 504. The number of processors 501 and the number of memories 502 can be at least one. The network interface 503 is used for wired or wireless communication between the electronic device 50 and other devices.

[0122] The memory 502 in this embodiment is used to store various types of data to support the operation of the electronic device 50.

[0123] The methods disclosed in the above embodiments of this disclosure can be applied to or implemented by processor 501. Processor 501 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 501 or by instructions in software form. The processor 501 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 501 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this disclosure can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 502. Processor 501 reads the information in memory 502 and, in conjunction with its hardware, completes the steps of the aforementioned image encoding method.

[0124] In some embodiments, the electronic device 50 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned methods.

[0125] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0126] In the above description, the term "some embodiments" refers to a subset of all possible embodiments. However, it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0127] Unless otherwise defined, all technical and scientific terms used in this disclosure have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure belongs. The terminology used in this disclosure is for the purpose of describing embodiments of this disclosure only and is not intended to be limiting of this disclosure.

[0128] It should be understood that in the various embodiments of this disclosure, the sequence number of each implementation process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this disclosure.

[0129] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this disclosure, "a plurality of" means two or more, unless otherwise explicitly specified.

[0130] The above description is merely a specific embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.

Claims

1. An image encoding method, characterized in that, The method includes: The motion intensity of an image macroblock is obtained, wherein the motion intensity characterizes the degree of motion intensity of the image macroblock relative to the matching macroblock obtained by motion estimation; When the motion intensity is greater than a first threshold and less than or equal to a second threshold, the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the reference image macroblock corresponding to the image macroblock are obtained, wherein the first threshold is less than the second threshold. In the frequency domain, the frequency domain coefficients and the reference frequency domain coefficients are differentially processed to obtain the differential frequency domain coefficients. The differential frequency domain coefficients are quantized and encoded to obtain the encoded data of the image macroblock.

2. The method according to claim 1, characterized in that, The step of performing a difference operation on the frequency domain coefficients and the reference frequency domain coefficients in the frequency domain to obtain differential frequency domain coefficients includes: Obtain the quantization step size parameter of the image macroblock and the reference quantization step size parameter of the reference image macroblock; The reference frequency domain coefficients are compensated based on the quantization step size parameter and the reference quantization step size parameter. The differential frequency domain coefficients are obtained by performing a differential operation on the frequency domain coefficients and the compensated reference frequency domain coefficients in the frequency domain.

3. The method according to claim 2, characterized in that, The step of compensating the reference frequency domain coefficients based on the quantization step size parameter and the reference quantization step size parameter includes: Using the quantization step size parameter and the reference quantization step size parameter as indexes, a scaling factor is queried through a preset lookup table. The scaling factor represents the proportional relationship between the quantization step size parameter and the reference quantization step size parameter. The compensated reference frequency domain coefficients are determined based on the product of the reference frequency domain coefficients and the scaling factor.

4. The method according to claim 1, characterized in that, The step of quantizing and encoding the differential frequency domain coefficients to obtain the encoded data of the image macroblock includes: The differential frequency domain coefficients are classified according to their frequency domain position to obtain differential frequency domain coefficients of at least two categories. According to the processing strategies corresponding to different categories, the differential frequency domain coefficients of each category are processed to obtain the processed differential frequency domain coefficients. The processed differential frequency domain coefficients are quantized and encoded to obtain the encoded data of the image macroblock.

5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: When the motion intensity is less than or equal to the first threshold, the encoded data of the target image macroblock having the same spatial coordinates as the image macroblock is obtained; The encoded data of the target image macroblock is determined as the encoded data of the image macroblock.

6. The method according to any one of claims 1 to 4, characterized in that, The method further includes: When the motion intensity is greater than the second threshold, the image macroblock is encoded using a preset intra-frame coding method to obtain the encoded data of the image macroblock.

7. The method according to any one of claims 1 to 4, characterized in that, The method further includes: Obtain the flatness information of the image macroblock, wherein the flatness information is used to characterize the uniformity of pixel value distribution within the image region corresponding to the image macroblock; The step of obtaining the frequency domain coefficients of the image macroblock when the motion intensity is greater than a first threshold and less than or equal to a second threshold includes: When the flatness information indicates that the image region corresponding to the image macroblock belongs to a flat region, and the motion intensity is greater than the first threshold and less than or equal to the third threshold, the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the reference image macroblock corresponding to the image macroblock are obtained; wherein, the third threshold is greater than the second threshold.

8. The method according to claim 7, characterized in that, The step of obtaining the flatness information of the image macroblock includes: Calculate a first gradient value of the image macroblock in a first direction and a second gradient value of the image macroblock in a second direction, wherein the first direction and the second direction are perpendicular to each other; When both the first gradient value and the second gradient value satisfy a preset flatness condition, flatness information is generated to indicate that the image region corresponding to the image macroblock belongs to a flat region.

9. The method according to any one of claims 1 to 4, characterized in that, The acquisition of motion intensity of image macroblocks includes: By performing motion estimation on the image macroblock, residual information between the image macroblock and the matching macroblock, as well as motion information of the image macroblock relative to the matching macroblock, are obtained; wherein, the residual information characterizes the degree of pixel difference between the image macroblock and the matching macroblock, and the motion information characterizes the spatial offset between the image macroblock and the matching macroblock; The motion intensity is calculated based on the residual information and the motion information.

10. The method according to claim 9, characterized in that, Before obtaining the residual information between the image macroblock and the matching macroblock, and the motion information of the image macroblock relative to the matching macroblock by performing motion estimation on the image macroblock, the method further includes: Within a first search range centered on the image macroblock, the image macroblock is searched with a first step length to obtain multiple first matching macroblocks, and a first target matching macroblock that meets the first preset condition is selected from the multiple first matching macroblocks. Within a second search range centered on the first target matching macroblock, the first target matching macroblock is searched with a second step size to obtain multiple second matching macroblocks. From the multiple second matching macroblocks, second matching macroblocks that meet the second preset conditions are selected as the matching macroblocks. Wherein, the second search range is smaller than the first search range, and / or, the second step size is smaller than the first step size.

11. An image encoding device, characterized in that, The device includes: An acquisition module is used to acquire the motion intensity of an image macroblock, wherein the motion intensity characterizes the degree of motion intensity of the image macroblock relative to the matching macroblock obtained by motion estimation; The acquisition module is further configured to acquire the frequency domain coefficients of the image macroblock and the reference frequency domain coefficients of the reference image macroblock corresponding to the image macroblock when the motion intensity is greater than the first threshold and less than or equal to the second threshold, wherein the first threshold is less than the second threshold. The differential operation module is used to perform differential operations on the frequency domain coefficients and the reference frequency domain coefficients in the frequency domain to obtain differential frequency domain coefficients; The quantization and encoding module is used to quantize and encode the differential frequency domain coefficients to obtain the encoded data of the image macroblock.

12. The apparatus according to claim 11, characterized in that, The device includes: The acquisition module is further configured to acquire the quantization step size parameter of the image macroblock and the reference quantization step size parameter of the reference image macroblock; The compensation module is used to perform compensation processing on the reference frequency domain coefficients according to the quantization step size parameter and the reference quantization step size parameter; The differential operation module is specifically used to perform differential operations on the frequency domain coefficients and the compensated reference frequency domain coefficients in the frequency domain to obtain the differential frequency domain coefficients.

13. The apparatus according to claim 12, characterized in that, The device includes: The acquisition module is further configured to query a scaling factor through a preset lookup table using the quantization step size parameter and the reference quantization step size parameter as indexes, wherein the scaling factor characterizes the proportional relationship between the quantization step size parameter and the reference quantization step size parameter; The determination module is used to determine the compensated reference frequency domain coefficients based on the product of the reference frequency domain coefficients and the scaling factor.

14. An electronic device, characterized in that, include: At least one processor; And, 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 to enable the at least one processor to perform the image encoding method according to any one of claims 1 to 10.

15. 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 image encoding method according to any one of claims 1 to 10.