Image coding method and device and computer equipment
By dividing the image into non-overlapping regions for feature extraction and hash value calculation, the high computational complexity and resource waste of motion vector search in the H.264 standard are solved, achieving efficient motion vector matching and bitstream optimization.
Patent Information
- Application Number
- CN202610172820.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-06
- Publication Date
- 2026-05-15
AI Technical Summary
Existing motion vector search algorithms struggle to find the globally optimal motion vector in H.264 standard screen encoding, resulting in low inter-frame prediction accuracy and bitstream compression efficiency, as well as high computational complexity. This is especially problematic in scenarios where the screen content lacks globally consistent motion patterns, leading to the unnecessary consumption of significant CPU resources.
By dividing the image into non-overlapping regions of a preset size, extracting features and calculating hash values, a hash table is constructed. The hash table is then used to compare regions and calculate motion vectors, thus selecting the optimal global motion vector and replacing the traditional global search that involves traversing the entire frame of pixels.
It significantly reduces computational load, saves CPU resources, improves inter-frame prediction accuracy and bitstream compression efficiency, and further optimizes the bitstream by adjusting the QP value in scenarios where the window is dragged manually, thus avoiding wasted computing power and reduced image quality.
Smart Images

Figure CN122053838A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing, and in particular to an image encoding method, apparatus, and computer equipment. Background Technology
[0002] In the process of screen encoding using the H.264 standard, if the motion vector (MV) corresponding to the image macroblock can be accurately identified, inter-frame redundancy information can be effectively eliminated, and the encoded bitstream can be significantly reduced.
[0003] Currently, motion vector search (MV) methods mostly employ local search algorithms such as diamond search and hexagonal search. These algorithms only search for the optimal motion vector within a local area around the macroblock, making it difficult to cover the global search space. Therefore, they cannot obtain globally optimal motion vector matching results, which limits the accuracy of inter-frame prediction and the efficiency of bitstream compression. Furthermore, existing global MV search algorithms have high computational complexity. More importantly, in scenarios where the image content does not possess globally consistent motion patterns, these algorithms not only fail to match effective global motion vectors but also waste significant CPU resources. Summary of the Invention
[0004] The purpose of this application is to provide an image encoding method, apparatus, and computer equipment that can save CPU resources.
[0005] To achieve the above objectives, this application provides the following solution: In a first aspect, this application provides an image encoding method, the method comprising: Perform the following steps for each frame of the image: Divide the current frame image into multiple non-overlapping regions of preset size; For each region, feature extraction is performed, and based on the extracted regional feature representation information of each region, the hash value corresponding to each region is calculated; Obtain the hash table of the current frame image. The hash table consists of feature information of each region. The feature information of each region includes: the preset position coordinates of each region and the corresponding hash value. If the current frame image is a keyframe image, save the hash table as a reference hash table; If the current frame image is a non-key frame image, check whether there is a region with the same hash value in the hash table of the current frame image and the reference hash table. If so, calculate the corresponding motion vector based on the preset position coordinates of the region with the same hash value in the current frame image and the reference frame image. If the number of consecutive matching regions meets the preset region number threshold, and the motion vectors of the consecutive matching regions are all the same, the motion vectors of the consecutive matching regions are determined as candidate global motion vectors. For all the candidate global motion vectors, the optimal global motion vector is selected by calculating the absolute value of the transformation error.
[0006] This disclosure divides the current frame image into non-overlapping regions of a preset size. First, features are extracted from each region, and a corresponding hash value is calculated based on the extracted region feature representation information. Then, a hash table containing the preset position coordinates and hash values of each region is constructed. Subsequently, region matching and motion vector calculation are achieved by comparing the hash tables of key frames and non-key frames, ultimately selecting the optimal global motion vector. This lightweight hash calculation and matching replaces the traditional full-frame pixel traversal of global search, significantly reducing the computational load. Even if the global motion vector is not matched, only a small amount of CPU resources are consumed, avoiding wasted computing power.
[0007] In one embodiment, the method further includes: Detect whether there is keyboard and mouse activity; If there is keyboard and mouse operation, calculate the movement speed of the window drag area based on the optimal global motion vector; If the movement rate exceeds a preset threshold, the QP value of the window dragging area is increased; the window dragging area is the region between the window position in the reference frame image and the window position in the current frame image.
[0008] This disclosure slightly adjusts the QP value of the dragged area and utilizes the persistence of vision in the human eye to further reduce the bit rate without affecting the subjective image quality.
[0009] In one embodiment, calculating the movement rate of the window dragging area based on the optimal global motion vector includes: The movement rate is calculated based on the optimal global motion vector, the frame number of the current frame image, the frame number of the reference frame image, and the frame rate.
[0010] This disclosure relies on the optimal global motion vector, frame number, and frame rate calculation rate, eliminating the need for additional data collection and simplifying the calculation logic.
[0011] In one embodiment, increasing the QP value of the window drag area includes: Add 1 to the original QP value.
[0012] This disclosure adopts a fixed strategy of "adding 1 to the original QP value", which is simple and efficient to operate and effectively improves the degree of quantization compression. Small adjustments can avoid image distortion and accurately balance bitstream optimization and subjective visual experience.
[0013] In one embodiment, the preset continuous brightness range consists of 8 groups, each group containing 32 consecutive pixel brightness values, and the pixel brightness value range is 0-255.
[0014] This disclosure clearly defines the grouping rules for brightness ranges, providing a unified input for hash calculations. Brightness values from 0 to 255 are divided into 8 groups, achieving feature dimensionality reduction and decreasing the amount of data and computational power consumed in subsequent calculations. The unified grouping standard ensures the comparability of hash values, improving the accuracy of subsequent inter-frame matching.
[0015] In one embodiment, the feature extraction for each region, and the calculation of the hash value corresponding to each region based on the extracted regional feature representation information, includes: For the pixel brightness value of each region, the total number of pixels in each preset continuous brightness interval is counted to obtain the brightness interval statistics results for each region. The hash value corresponding to each region is calculated based on the number of intervals in the continuous brightness interval, the statistical results of each brightness interval, and the preset modulus.
[0016] This disclosure directly bases its calculations on pixel brightness values within a region, counting the total number of pixels in each preset continuous brightness interval. Then, it combines the number of intervals, the statistical results, and a preset modulus to calculate a hash value. This eliminates the need for complex feature processing and calculations, resulting in low computational cost and reduced overhead, further decreasing the overall computational power consumption of the search process. Simultaneously, the brightness interval statistics accurately reflect the overall brightness distribution characteristics of each region, allowing the generated hash value to effectively distinguish different regions, leading to more accurate matching. It also resists slight pixel noise interference, ensuring the reliability of subsequent region matching and motion vector calculation.
[0017] In one embodiment, the preset position coordinates are the coordinates of the upper left corner.
[0018] This disclosure clearly defines the regional coordinate benchmark, eliminating errors in motion vector calculation. It uniformly adopts the coordinates of the top-left corner of the region, aligning with coding practices and improving matching and calculation efficiency. It avoids deviations caused by inconsistent coordinate rules, ensuring that motion vectors accurately reflect regional displacement.
[0019] In one embodiment, the step of calculating the absolute value of the transformation error and selecting the optimal global motion vector from all candidate global motion vectors includes: Add all the candidate global motion vectors to the motion vector candidate list; Calculate the sum of the absolute values of the transformation errors between each of the candidate global motion vectors and the other candidate global motion vectors in the motion vector candidate list; The candidate global motion vector with the smallest absolute value of transformation error is selected as the optimal global motion vector.
[0020] This disclosure replaces subjective judgment with a quantitative evaluation method that involves candidate list construction, SATD calculation, and minimum value selection. SATD is calculated only for candidate vectors, further reducing computational power consumption and maintaining the lightweight nature of the overall solution.
[0021] The SATD value is calculated only for a small number of vectors in the candidate list, without having to traverse the pixels of the entire frame, thus solving the problem of large SATD computation in the traditional global MV algorithm.
[0022] Secondly, this application provides an image encoding apparatus, the apparatus comprising: a processing module, The processing module is used to perform the following steps on each frame of image: Divide the current frame image into multiple non-overlapping regions of preset size; For each region, feature extraction is performed, and based on the extracted regional feature representation information of each region, the hash value corresponding to each region is calculated; Obtain the hash table of the current frame image. The hash table consists of feature information of each region. The feature information of each region includes: the preset position coordinates of each region and the corresponding hash value. If the current frame image is a keyframe image, save the hash table as a reference hash table; If the current frame image is a non-key frame image, check whether there is a region with the same hash value in the hash table of the current frame image and the reference hash table. If so, calculate the corresponding motion vector based on the preset position coordinates of the region with the same hash value in the current frame image and the reference frame image. If the number of consecutive matching regions meets the preset region number threshold, and the motion vectors of the consecutive matching regions are all the same, the motion vectors of the consecutive matching regions are determined as candidate global motion vectors. For all the candidate global motion vectors, the optimal global motion vector is selected by calculating the absolute value of the transformation error.
[0023] Thirdly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the image encoding method described in any one of the above. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 A flowchart illustrating an image encoding method provided in an embodiment of this application. Figure 1 ; Figure 2 A flowchart illustrating an image encoding method provided in an embodiment of this application. Figure 2 ; Figure 3 A schematic flowchart of an image encoding method provided in an embodiment of this application; Figure 4 This is a schematic diagram of a drag area provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0026] To further illustrate the technical means and effects of the present invention in achieving its intended purpose, the following detailed description of the specific implementation methods, structures, features, and effects of the present invention, in conjunction with the accompanying drawings and preferred embodiments, is provided below.
[0027] Figure 1 This is a flowchart illustrating an image encoding method according to an embodiment of this application, as shown below. Figure 1 As shown, the method includes performing the following steps S101-S107 for each frame of image: S101. Divide the current frame image into multiple non-overlapping regions of preset size.
[0028] A non-overlapping, uniform partitioning method is used to cover the entire image region of the current frame, ensuring that each region is an independent computational unit.
[0029] For example, the macroblock feature corresponding to H.264 screen encoding has a default size of 64×64 pixels.
[0030] S102. Extract features from each region and calculate the hash value corresponding to each region based on the extracted regional feature representation information.
[0031] This disclosure allows for the selection of any pixel-level or region-level feature that can characterize regional features, including but not limited to: brightness features, grayscale features, chromaticity features, texture features, gradient features, edge features, etc., and does not require limitation to a single feature type. It can be flexibly selected according to the image type (such as color image, grayscale image) and application requirements.
[0032] A preset feature extraction algorithm is used to extract selected feature types, transforming the set of pixels within a region into abstract, quantifiable representation information, i.e., region feature representation information.
[0033] In one possible approach, if a single type of feature indicator is not selected, the extracted regional feature representation information can be standardized (e.g., normalized, quantized) to ensure that the feature representation information of different regions and different frames are in the same dimension, thus avoiding subsequent hash generation deviations caused by differences in region size and pixel value range.
[0034] The regional feature representation information corresponding to each region is used as the input data for the hash algorithm. The preset hash algorithm is called to calculate and process the input regional feature representation information. According to the mapping rules of the algorithm, the regional feature representation information is transformed into a hash value of fixed length. The hash value length (such as 64 bits or 128 bits) can be set according to the requirements. The longer the length, the higher the uniqueness of the hash value and the lower the collision rate.
[0035] In one embodiment, step S102 includes the following sub-steps S1021-S1022: S1021. For the pixel brightness value of each region, count the total number of pixels in each preset continuous brightness interval to obtain the brightness interval statistics results for each region.
[0036] In one embodiment, the preset continuous brightness range consists of 8 groups, each group containing 32 consecutive pixel brightness values, and the pixel brightness value range is 0-255.
[0037] Specifically, the pixel brightness value of 0-255 is divided into 8 consecutive brightness ranges, each containing 32 brightness values, namely 0-31 as group 1, 32-63 as group 2, ..., 224-255 as group 8.
[0038] For each 64×64 region, the total number of pixels in each of the eight brightness intervals is counted to obtain the eight sets of brightness interval statistics G0-G7 for that region. The calculation formula is as follows: ; in, This represents the statistical results of the i-th brightness interval, where i represents the brightness interval number (0-7), j represents the pixel brightness value, and P j This represents the number of pixels with a brightness value of j.
[0039] S1022. Calculate the hash value corresponding to each region based on the number of consecutive brightness intervals, the statistical results of each brightness interval, and the preset modulus.
[0040] Specifically, the hash value corresponding to each region is calculated according to the following formula: ; in, This represents the hash value, and i represents the brightness range number (0-7). This represents the statistical results of the luminance interval of the i-th group, and N represents the preset modulus. For example, N can be 256. In this way, the luminance features of each 64×64 region can be converted into a unique hash value in the range of 0-255, which greatly improves the speed of subsequent inter-frame matching.
[0041] This disclosure directly uses pixel brightness value statistics within a region, counting the total number of pixels in each preset continuous brightness interval, and then combining the number of intervals, statistical results, and a preset modulus to calculate a hash value. This eliminates the need for complex feature processing and calculations, resulting in low computational cost and reduced overhead, further lowering the overall computational power consumption of the search process. Simultaneously, brightness interval statistics accurately reflect the overall brightness distribution characteristics of each region, allowing the generated hash value to effectively distinguish different regions, leading to more accurate matching. It also resists slight pixel noise interference, ensuring the reliability of subsequent region matching and motion vector calculation.
[0042] S103. Obtain the hash table of the current frame image. The hash table is composed of feature information of each region. The feature information of each region includes: the preset position coordinates of each region and the corresponding hash value.
[0043] Each record in the hash table is (x, y, Hash_Value), where (x, y) represents the preset position coordinates of the region, used to locate the region's position in the frame, and Hash_Value represents the hash value of the corresponding region.
[0044] S104. If the current frame image is a keyframe image, save the hash table as a reference hash table.
[0045] The keyframe image corresponds to the I-frame in H.264 encoding. The I-frame is the reference frame for inter-frame prediction and can be decoded without relying on other frames.
[0046] The hash table of I-frames is saved as a reference hash table. Subsequent non-key frame images (P-frames / B-frames) can be directly matched based on this table without having to repeatedly calculate the brightness statistics and hash value of the I-frames.
[0047] S105. If the current frame image is a non-key frame image, detect whether there is a region with the same hash value in the hash table of the current frame image and the reference hash table. If so, calculate the corresponding motion vector based on the preset position coordinates of the region with the same hash value in the current frame image and the reference frame image.
[0048] The Hash_Value of each record in the current frame image hash table is compared one by one with the Hash_Value in the reference hash table.
[0049] The hash value is derived from the brightness statistics of the region. If the hash values are the same, it means that the brightness distribution characteristics of the two regions are consistent. If the hash values of two regions are exactly the same, the two regions are determined to be feature-matching regions.
[0050] For each successfully matched feature region, a motion vector is calculated based on its position coordinates in the two frames, using the following formula: ; ; Where (x1, y1) are the preset position coordinates of the target region of the current frame image, and (x0, y0) are the preset position coordinates of the target region of the reference frame image. The target regions of the current frame image and the target regions of the reference frame image are feature matching regions.
[0051] For example, the preset position coordinates are the coordinates of the upper left corner.
[0052] Traditional motion vector search requires pixel-by-pixel comparison of region data, which is extremely computationally intensive. This step achieves matching through hash table lookup, which is a lightweight operation and will not consume excessive CPU resources even for full-frame comparison.
[0053] S106. If the number of consecutive matching regions meets the preset region number threshold, and the motion vectors of the consecutive matching regions are all the same, the motion vectors of the consecutive matching regions are determined as candidate global motion vectors.
[0054] If the number of consecutive feature matching regions in the current frame image and the reference frame image exceeds a preset threshold, and the (mvx, mvy) values of the feature matching regions are the same, then a candidate global motion vector is considered to have been found.
[0055] For example, the preset threshold for the number of regions can be 4, meaning that the number of consecutive feature matching regions between the current frame image and the reference frame image exceeds 4, and the number of consecutive feature matching regions between the current frame image and the reference frame image is greater than 256×256 pixels. If the motion vectors (mvx, mvy) corresponding to all 64×64 sub-regions within the 256×256 consecutive matching region are exactly the same, then the motion vector is determined to be a candidate global motion vector.
[0056] S107. For all the candidate global motion vectors, the optimal global motion vector is selected by calculating the absolute value of the transformation error.
[0057] This disclosure divides the current frame image into non-overlapping regions of a preset size. First, features are extracted from each region, and a corresponding hash value is calculated based on the extracted region feature representation information. Then, a hash table containing the preset position coordinates and hash values of each region is constructed. Subsequently, region matching and motion vector calculation are achieved by comparing the hash tables of key frames and non-key frames, ultimately selecting the optimal global motion vector. This method replaces the traditional full-frame pixel traversal of global search with lightweight hash calculation and matching, significantly reducing computational load. Even if the global motion vector is not matched, only a small amount of CPU resources are consumed, avoiding wasted computing power. Furthermore, this method aligns with H.264 encoding characteristics and can be directly integrated into existing encoding frameworks, improving inter-frame prediction accuracy and bitstream compression efficiency.
[0058] In one embodiment, such as Figure 2 As shown, step S107 includes the following sub-steps S1071-S1073: S1071. Add all the candidate global motion vectors to the motion vector candidate list.
[0059] S1072. Calculate the sum of the absolute values of the transformation errors between each of the candidate global motion vectors and the other candidate global motion vectors in the motion vector candidate list.
[0060] S1073. Select the candidate global motion vector with the smallest absolute value of transformation error as the optimal global motion vector.
[0061] For each candidate global motion vector (mvx, mvy) in the candidate list, lock its corresponding 256×256 global motion region.
[0062] Based on the pixel data of the region in the reference frame image, and combined with the candidate motion vector, the predicted pixel data of the corresponding region in the current frame image is generated.
[0063] Calculate the residual matrix between the predicted pixel data and the actual pixel data of the current frame image.
[0064] Perform an integer discrete cosine transform on the residual matrix, then calculate the sum of the absolute values of all coefficients after the transform, and finally obtain the SATD value corresponding to the candidate vector.
[0065] The magnitude of the Sum of Absolute Transformed Differences (SATD) directly reflects the level of prediction error: the smaller the SATD value, the closer the inter-frame prediction result based on the vector is to the real pixel, and the better the inter-frame redundancy elimination effect.
[0066] This optimal global motion vector will be used as the final motion vector of the 256×256 global motion region of the current frame image, and will be directly used for H.264 inter-frame predictive coding to maximize the elimination of inter-frame redundancy.
[0067] Only after the optimal global motion vector is determined can the next step, the region QP value adjustment process based on the window dragging rate, proceed. If the optimal vector is not selected, the QP value adjustment step will not be triggered to avoid invalid calculations.
[0068] Figure 3 This is a flowchart illustrating an image encoding method according to an embodiment of this application, as shown below. Figure 3 As shown, the method includes performing the following steps S201-S203 for each frame of image: S201. Detect whether there is keyboard and mouse operation.
[0069] This step is a prerequisite for QP value adjustment. In screen encoding scenarios, the generation of global motion vectors mostly originates from keyboard and mouse operations such as window dragging and scroll bar scrolling. By detecting the keyboard and mouse operation status, the application scenarios that require QP value adjustment can be accurately identified, avoiding ineffective adjustments to global motion without keyboard and mouse operation (such as automatic video playback).
[0070] The objects being detected are the input peripheral signals of the encoding device, specifically including mouse drag, click, and scroll wheel sliding signals, as well as keyboard shortcut trigger signals (such as window movement shortcuts).
[0071] The coding system reads the peripheral input logs at the system layer to determine in real time whether there are valid keyboard and mouse operations.
[0072] The purpose of this step is to filter out invalid scenarios, ensuring that subsequent rate calculations and QP value adjustments are only performed in global motion scenarios involving "human window dragging," thereby improving the relevance and effectiveness of the solution.
[0073] If no keyboard and mouse activity is detected, the process will terminate immediately, and no further calculations will be performed.
[0074] S202. If there is keyboard and mouse operation, calculate the movement speed of the window drag area based on the optimal global motion vector.
[0075] In one embodiment, the movement rate is calculated based on the optimal global motion vector, the frame number of the current frame image, the frame number of the reference frame image, and the frame rate.
[0076] The core calculation logic for window dragging rate is based on the displacement of the optimal global motion vector, combined with the frame interval between the reference frame image and the current frame image, to calculate the pixel distance the window moves per unit time. The calculation formula is as follows: ; in, This represents the movement speed of the window drag area, (mvx, mvy) is the optimal global motion vector, frameNo.1 is the frame number of the current frame image, frameNo.0 is the frame number of the reference frame image, and fps is the frame rate.
[0077] S203. If the movement rate exceeds a preset threshold, increase the QP value of the window dragging area; the window dragging area is the area between the window position in the reference frame image and the window position in the current frame image.
[0078] If the calculated window dragging rate is greater than or equal to the preset threshold, the QP value adjustment condition is met, and subsequent adjustment operations are performed; if the rate is less than the preset threshold, the process is terminated, and the original QP value remains unchanged.
[0079] The window dragging area specified in this step refers to the closed area enclosed by the movement trajectory of the upper left and lower right corners of the window between the initial position of the window in the reference frame image and the ending position of the window in the current frame image.
[0080] The QP value is a core parameter in H.264 encoding that controls the degree of quantization. The larger the QP value, the higher the degree of quantization compression and the smaller the encoded bitstream.
[0081] When the window dragging speed exceeds the threshold, the persistence of vision in the human eye will make it impossible to clearly distinguish the details of the dragged area. At this time, appropriately increasing the QP value will not reduce the subjective image quality, but can significantly reduce the amount of encoded data in that area, thus achieving secondary optimization of the bitstream.
[0082] For example, you can add 1 to the original QP value.
[0083] Once the above conditions are met, the QP value of the dragged area is increased by 1. See the definition of the dragged area. Figure 4 The gray rectangles represent the dragged window, and the dashed boxes in the right image indicate the position of the dragged window in the reference frame within the current frame. The window dragging area is the region between the top-left and bottom-right corners of the window's movement path. Figure 4 The shaded area is marked with a diagonal line.
[0084] This disclosure adds a regional QP value adjustment process to the global motion vector search. It first detects keyboard and mouse operations to accurately locate the human window dragging scene, and then calculates the window dragging rate based on the optimal global motion vector, frame number, and frame rate. Only when the rate exceeds a preset threshold is the QP value of the dragging area between the reference frame image and the current frame image window position adjusted. It makes full use of the persistence of vision effect of human eyes. In high-speed dragging scenes, it will not reduce the user's subjective image quality experience, and can further improve the quantization compression degree on the basis of eliminating inter-frame redundancy in global motion vectors, realizing secondary deep optimization of the bitstream. At the same time, this process is only triggered when the global motion vector is hit and the conditions are met. The entire process is based on the existing parameters of the previous steps, without the need for additional data collection, and will not increase the CPU burden of the encoding system. It perfectly balances the bitstream optimization effect, subjective image quality, and computing power consumption.
[0085] In summary, this proposed solution effectively balances CPU usage and bitrate, minimizing CPU load even without a global MV hit. If a global MV hit occurs, adjusting the QP value of the region based on window dragging speed further reduces the bitrate on top of the global MV contribution.
[0086] Based on the same inventive concept, this application also provides an image encoding apparatus for implementing the image encoding method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more image encoding apparatus embodiments provided below can be found in the limitations of the image encoding method described above, and will not be repeated here.
[0087] In one exemplary embodiment, an image encoding apparatus is provided, the apparatus comprising: a processing module, The processing module is used to perform the following steps on each frame of image: Divide the current frame image into multiple non-overlapping regions of preset size; For each region, feature extraction is performed, and based on the extracted regional feature representation information of each region, the hash value corresponding to each region is calculated; Obtain the hash table of the current frame image. The hash table consists of feature information of each region. The feature information of each region includes: the preset position coordinates of each region and the corresponding hash value. If the current frame image is a keyframe image, save the hash table as a reference hash table; If the current frame image is a non-key frame image, check whether there is a region with the same hash value in the hash table of the current frame image and the reference hash table. If so, calculate the corresponding motion vector based on the preset position coordinates of the region with the same hash value in the current frame image and the reference frame image. If the number of consecutive matching regions meets the preset region number threshold, and the motion vectors of the consecutive matching regions are all the same, the motion vectors of the consecutive matching regions are determined as candidate global motion vectors. For all the candidate global motion vectors, the optimal global motion vector is selected by calculating the absolute value of the transformation error.
[0088] In one embodiment, the apparatus further includes: The detection module is used to detect whether there is keyboard and mouse operation; The calculation module is used to calculate the movement rate of the window drag area based on the optimal global motion vector if there is keyboard and mouse operation. An additional module is added to increase the QP value of the window dragging area if the movement rate exceeds a preset threshold; the window dragging area is the region between the window position in the reference frame image and the window position in the current frame image.
[0089] In one embodiment, regarding the calculation of the movement rate of the window dragging area based on the optimal global motion vector, the calculation module is specifically used for: The movement rate is calculated based on the optimal global motion vector, the frame number of the current frame image, the frame number of the reference frame image, and the frame rate.
[0090] In one embodiment, regarding increasing the QP value of the window drag area, the increasing module is specifically used to add 1 to the original QP value.
[0091] In one embodiment, the preset continuous brightness range consists of 8 groups, each group containing 32 consecutive pixel brightness values, and the pixel brightness value range is 0-255.
[0092] In one embodiment, regarding the feature extraction for each region and the calculation of the hash value corresponding to each region based on the extracted regional feature representation information, the processing module is specifically used for: For the pixel brightness value of each region, the total number of pixels in each preset continuous brightness interval is counted to obtain the brightness interval statistics results for each region. The hash value corresponding to each region is calculated based on the number of intervals in the continuous brightness interval, the statistical results of each brightness interval, and the preset modulus.
[0093] In one embodiment, the preset position coordinates are the coordinates of the upper left corner.
[0094] In one embodiment, in the aspect of calculating the absolute value of the transformation error and selecting the optimal global motion vector from all the candidate global motion vectors, the processing module is specifically used for: Add all the candidate global motion vectors to the motion vector candidate list; Calculate the sum of the absolute values of the transformation errors between each of the candidate global motion vectors and the other candidate global motion vectors in the motion vector candidate list; The candidate global motion vector with the smallest absolute value of transformation error is selected as the optimal global motion vector.
[0095] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 5 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and databases. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media to run. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements an image encoding method.
[0096] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0097] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0098] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0099] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0100] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0101] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0102] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0103] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0104] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. An image encoding method, characterized in that, The method includes: Perform the following steps for each frame of the image: Divide the current frame image into multiple non-overlapping regions of preset size; For each region, feature extraction is performed, and based on the extracted regional feature representation information of each region, the hash value corresponding to each region is calculated; Obtain the hash table of the current frame image. The hash table is composed of the feature information of each region. The feature information of each region includes: the preset position coordinates of each region and the corresponding hash value. If the current frame image is a keyframe, save the hash table as a reference hash table; If the current frame image is a non-key frame, check whether there is a region with the same hash value in the hash table of the current frame image and the reference hash table. If so, calculate the corresponding motion vector according to the preset position coordinates of the region with the same hash value in the current frame image and the reference frame image. If the number of consecutive matching regions meets the preset region number threshold, and the motion vectors of the consecutive matching regions are all the same, the motion vectors of the consecutive matching regions are determined as candidate global motion vectors. For all the candidate global motion vectors, the optimal global motion vector is selected by calculating the absolute value of the transformation error.
2. The method according to claim 1, characterized in that, The method further includes: Detect whether there is keyboard and mouse activity; If there is keyboard and mouse operation, calculate the movement speed of the window drag area based on the optimal global motion vector; If the movement rate exceeds a preset threshold, the QP value of the window dragging area is increased; the window dragging area is the region between the window position in the reference frame image and the window position in the current frame image.
3. The method according to claim 2, characterized in that, The calculation of the movement rate of the window dragging area based on the optimal global motion vector includes: The movement rate is calculated based on the optimal global motion vector, the frame number of the current frame image, the frame number of the reference frame image, and the frame rate.
4. The method according to claim 2, characterized in that, Increasing the QP value of the window drag area includes: Add 1 to the original QP value.
5. The method according to any one of claims 1-4, characterized in that, The preset continuous brightness range consists of 8 groups, each group containing 32 consecutive pixel brightness values, and the pixel brightness value range is 0-255.
6. The method according to claim 5, characterized in that, The step of extracting features from each region, and calculating the hash value corresponding to each region based on the extracted regional feature representation information, includes: For the pixel brightness value of each region, the total number of pixels in each preset continuous brightness interval is counted to obtain the brightness interval statistics results for each region. The hash value corresponding to each region is calculated based on the number of intervals in the continuous brightness interval, the statistical results of each brightness interval, and the preset modulus.
7. The method according to claim 6, characterized in that, The preset position coordinates are the coordinates of the upper left corner.
8. The method according to claim 7, characterized in that, The step of calculating the absolute value of the transformation error and selecting the optimal global motion vector from all candidate global motion vectors includes: Add all the candidate global motion vectors to the motion vector candidate list; Calculate the sum of the absolute values of the transformation errors between each of the candidate global motion vectors and the other candidate global motion vectors in the motion vector candidate list; The candidate global motion vector with the smallest sum of absolute transformation errors is selected as the optimal global motion vector.
9. An image encoding device, characterized in that, The device includes: a processing module, The processing module is used to perform the following steps on each frame of image: Divide the current frame image into multiple non-overlapping regions of preset size; For each region, feature extraction is performed, and based on the extracted regional feature representation information of each region, the hash value corresponding to each region is calculated; Obtain the hash table of the current frame image. The hash table is composed of the feature information of each region. The feature information of each region includes: the preset position coordinates of each region and the corresponding hash value. If the current frame image is a keyframe image, save the hash table as a reference hash table; If the current frame image is a non-key frame image, detect whether there is a region with the same hash value in the hash table of the current frame image and the reference hash table. If so, calculate the corresponding motion vector based on the preset position coordinates of the region with the same hash value in the current frame image and the reference frame image. If the number of consecutive matching regions meets the preset region number threshold, and the motion vectors of the consecutive matching regions are all the same, the motion vectors of the consecutive matching regions are determined as candidate global motion vectors. For all the candidate global motion vectors, the optimal global motion vector is selected by calculating the absolute value of the transformation error.
10. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the image encoding method according to any one of claims 1-8.