Encoding methods, apparatus and devices, decoding methods, apparatus and devices, storage media and computer programs
By aligning text regions in images and encoding position identification data and flag bits, the method enhances encoding efficiency and accuracy for text content in HEVC, addressing the inefficiencies of existing technologies.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-02-27
- Publication Date
- 2026-03-13
AI Technical Summary
Existing high-efficiency video coding (HEVC) technologies exhibit low encoding efficiency for images containing text content due to the large differences in position vectors between characters, requiring a large number of bits to encode these vectors accurately.
An encoding method that involves aligning text regions in an image based on a target alignment size, determining position identification data and a flag bit for the position vector difference, and encoding these into a bitstream, reducing the number of bits required for encoding by using multiples or specific components of the alignment size.
This method effectively reduces the number of bits needed for encoding position vectors in text-containing images, ensuring high encoding efficiency and accuracy without increasing hardware costs.
Smart Images

Figure 2026508897000001_ABST
Abstract
Description
Technical Field
[0001] [Cross - Reference to Related Applications] This application claims the priority of Chinese Patent Application No. 202310254388.7, titled "ENCODING METHOD, APPARATUS, AND DEVICE, DECODING METHOD, APPARATUS, AND DEVICE, STORAGE MEDIUM, AND COMPUTER PROGRAM", filed on March 6, 2023, the entire content of which is incorporated herein by reference.
[0002] [Technical Field] This application relates to the field of image compression, and particularly to an encoding method, apparatus and device, a decoding method, apparatus and device, a storage medium, and a computer program.
Background Art
[0003] A high - efficiency video coding (HEVC) encoder can encode video frames through motion compensation or intra block copy (IBC).
[0004] Motion compensation is used as an example. For a current block to be encoded within a video frame, a reference block corresponding to the current block may be determined, and the residual between the current block and the reference block is encoded into the bitstream. Then, a motion vector (MV) between the current block and the reference block is determined. The MV indicates the positional relationship between the current block and the reference block. A motion vector predictor (MVP) corresponding to the MV is determined, and the difference between the MV and the MVP is used as a motion vector difference (MVD), and the MVD is encoded into the bitstream.
[0005] The above encoding modes have relatively high encoding efficiency for natural images, but relatively low encoding efficiency for images containing text content. [Overview of the project]
[0006] This application provides an encoding method, apparatus and device, a decoding method, apparatus and device, a storage medium and a computer program to solve the problem of relatively low efficiency in encoding images containing text content in related technologies. The technical solution is as follows:
[0007] According to a first embodiment, an encoding method is provided. The method includes the steps of: acquiring a target region, which is acquired by performing an alignment process on a target image based on a target alignment size; determining the position vector difference of a current block to be encoded within the target region, wherein the position vector difference represents the difference between the position vector of the current block and a reference position vector, and the position vector of the current block represents the positional relationship between the current block and the reference block corresponding to the current block; determining position identification data and a first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference, wherein the position identification data is a multiple of the position vector difference with respect to the target alignment size or the position vector difference itself, and the first flag bit represents the category of the position identification data; and encoding the position identification data and the first flag bit into a bitstream.
[0008] For a target image containing text content, after alignment processing is performed on the target image based on the target alignment size to obtain the target region, the position identification data and first flag bit corresponding to the position vector difference of the current block to be encoded within the target region can be determined based on the target alignment size. The position identification data may also be a multiple of the position vector difference with respect to the target alignment size. In this case, encoding the position identification data and first flag bit corresponding to the position vector difference requires fewer bits than encoding the position vector difference itself. In other words, the bit cost for encoding the position identification data and first flag bit corresponding to the position vector difference is usually smaller than the bit cost for directly encoding the position vector difference. Therefore, encoding the position identification data and first flag bit corresponding to the position vector difference into a bitstream effectively reduces the number of bits required to encode the position vector difference while ensuring encoding accuracy, thereby ensuring relatively high efficiency in encoding images containing text content.
[0009] Optionally, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, the horizontal flag bit indicates the category of the horizontal identification data, and the step of determining the position identification data and the first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference includes, if the horizontal component is an integer multiple of the horizontal alignment size, determining the multiple of the horizontal component to the horizontal alignment size as the horizontal identification data and determining the first value as the value of the horizontal flag bit.
[0010] When the horizontal component is an integer multiple of the horizontal alignment size, the multiple of the horizontal component relative to the horizontal alignment size can accurately represent the horizontal component. Therefore, the multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data. In this way, the horizontal component can be accurately encoded into the bitstream, and the accuracy of encoding and decoding the horizontal component is ensured.
[0011] Optionally, the method further includes the step of determining the horizontal component as horizontal identification data and determining a second value as the value of the horizontal flag bit if the horizontal component is not an integer multiple of the horizontal alignment size.
[0012] When the horizontal component is not an integer multiple of the horizontal alignment size, the multiple of the horizontal component relative to the horizontal alignment size cannot accurately represent the horizontal component. Therefore, the horizontal component is directly determined as horizontal identification data to avoid horizontal component encoding errors caused by encoding the multiple of the horizontal component relative to the horizontal alignment size into a bitstream, thereby ensuring accuracy in encoding and decoding the horizontal component.
[0013] Optionally, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, the vertical flag bit indicates the category of the vertical identification data, and the step of determining the position identification data and the first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference includes, if the vertical component is an integer multiple of the vertical alignment size, determining the multiple of the vertical component to the vertical alignment size as the vertical identification data and determining the first value as the value of the vertical flag bit.
[0014] When the vertical component is an integer multiple of the vertical alignment size, the multiple of the vertical component relative to the vertical alignment size can accurately represent the vertical component. Therefore, the multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data. In this way, the vertical component can be accurately encoded into the bitstream, ensuring the accuracy of encoding and decoding the vertical component.
[0015] Optionally, the method further includes the step of determining the vertical component as vertical identification data and determining a second value as the value of the vertical flag bit if the vertical component is not an integer multiple of the vertical alignment size.
[0016] When the vertical component is not an integer multiple of the vertical alignment size, the multiple of the vertical component relative to the vertical alignment size cannot accurately represent the vertical component. Therefore, the vertical component is determined directly as vertical identification data to avoid vertical component encoding errors caused by encoding the multiple of the vertical component relative to the vertical alignment size into a bitstream, thereby ensuring accuracy in encoding and decoding the vertical component.
[0017] Optionally, the target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. The step of determining the position identification data and a first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference includes determining a multiple of the horizontal component to the horizontal alignment size as the horizontal identification data, determining a multiple of the vertical component to the vertical alignment size as the vertical identification data, and determining a first value as the value of the first flag bit.
[0018] Optionally, the step of determining the position vector difference of the current block to be encoded within the target region includes the steps of determining a first candidate position vector difference and a second candidate position vector difference of the current block, wherein the first candidate position vector difference is determined based on a first pixel precision, and the second candidate position vector difference is determined based on a second pixel precision, where the first pixel precision is an integer and the second pixel precision is a multiple of the target alignment size; determining the rate distortion cost of the first candidate position vector difference and the rate distortion cost of the second candidate position vector difference; and determining the candidate position vector difference having the smaller rate distortion cost among the first and second candidate position vector differences as the position vector difference of the current block.
[0019] The current block's position vector difference is the candidate position vector difference having a smaller rate distortion cost than the first candidate position vector difference and the second candidate position vector difference; therefore, the rate distortion cost of the current block's position vector difference is relatively small. Furthermore, when the current block's position vector difference is the second candidate position vector difference, a multiple of the horizontal component with respect to the horizontal alignment size may be directly determined as horizontal identification data, and a multiple of the vertical component with respect to the vertical alignment size may be determined as vertical identification data. In this way, the horizontal and vertical components can be accurately encoded into the bitstream, and the accuracy of encoding and decoding the horizontal and vertical components is ensured.
[0020] The optional step of determining a multiple of the horizontal component to the horizontal alignment size as horizontal identification data, determining a multiple of the vertical component to the vertical alignment size as vertical identification data, and determining a first value as the value of the first flag bit includes, if the horizontal component is an integer multiple of the horizontal alignment size and the vertical component is an integer multiple of the vertical alignment size, determining a multiple of the horizontal component to the horizontal alignment size as horizontal identification data, determining a multiple of the vertical component to the vertical alignment size as vertical identification data, and determining a first value as the value of the first flag bit.
[0021] When the horizontal component is an integer multiple of the horizontal alignment size and the vertical component is an integer multiple of the vertical alignment size, the multiple of the horizontal component relative to the horizontal alignment size can accurately represent the horizontal component, and the multiple of the vertical component relative to the vertical alignment size can accurately represent the vertical component. Therefore, the multiple of the horizontal component relative to the horizontal alignment size can be determined as horizontal identification data, and the multiple of the vertical component relative to the vertical alignment size can be determined as vertical identification data. In this way, the horizontal and vertical components can be accurately encoded into a bitstream, and the accuracy of encoding and decoding the horizontal and vertical components is ensured.
[0022] Optionally, the method further includes the step of determining the horizontal component as horizontal identification data, determining the vertical component as vertical identification data, and determining the second value as the value of the first flag bit, if the horizontal component is not an integer multiple of the horizontal alignment size and / or the vertical component is not an integer multiple of the vertical alignment size.
[0023] When the horizontal component is not an integer multiple of the horizontal alignment size, and / or when the vertical component is not an integer multiple of the vertical alignment size, the multiple of the horizontal component relative to the horizontal alignment size cannot accurately represent the horizontal component, and / or the multiple of the vertical component relative to the vertical alignment size cannot accurately represent the vertical component. Therefore, the horizontal component can be directly determined as horizontal identification data, and the vertical component can be determined as vertical identification data, thereby avoiding the horizontal component encoding error caused by encoding the multiple of the horizontal component relative to the horizontal alignment size into a bitstream, and / or the vertical component encoding error caused by encoding the multiple of the vertical component relative to the vertical alignment size into a bitstream, and thereby ensuring the accuracy of encoding and decoding the horizontal and vertical components.
[0024] Optionally, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, and the first flag bit includes the horizontal flag bit, which is further used in combination with the horizontal identification data to indicate the horizontal component. The step of determining the position identification data and the first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference includes determining the quotient obtained by dividing the horizontal component by the horizontal alignment size as the horizontal identification data, and determining the remainder obtained by dividing the horizontal component by the horizontal alignment size as the value of the horizontal flag bit.
[0025] The quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size can accurately represent the horizontal component. Therefore, the quotient obtained by dividing the horizontal component by the horizontal alignment size can be determined as horizontal identification data, and the remainder obtained by dividing the horizontal component by the horizontal alignment size can be determined as the value of the horizontal flag bit. In this way, the horizontal component can be accurately encoded into the bitstream, and the accuracy of encoding and decoding the horizontal component is ensured.
[0026] Optionally, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, and the first flag bit includes the vertical flag bit, which is further used in combination with the vertical identification data to indicate the vertical component. The step of determining the position identification data and the first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference includes determining the quotient obtained by dividing the vertical component by the vertical alignment size as the vertical identification data, and determining the remainder obtained by dividing the vertical component by the vertical alignment size as the value of the vertical flag bit.
[0027] The quotient and remainder obtained by dividing the vertical component by the vertical alignment size can accurately represent the vertical component. Therefore, the quotient obtained by dividing the vertical component by the vertical alignment size can be determined as vertical identification data, and the remainder obtained by dividing the vertical component by the vertical alignment size can be determined as the value of the vertical flag bit. Thus, the vertical component can be accurately encoded in the bit stream, ensuring the accuracy of encoding and decoding the vertical component.
[0028] Optionally, the target region is obtained by performing alignment processing on the text region in the target image based on the target alignment size, and the text region contains at least one character.
[0029] When the target region is obtained by performing alignment processing on the text region in the target image based on the target alignment size, encoding the position identification data and the first flag bit corresponding to the position vector difference into the bit stream can effectively reduce the number of bits required to encode the position vector difference while ensuring the encoding accuracy, thereby ensuring a relatively high efficiency in encoding an image containing text content.
[0030] Optionally, the method further includes the step of encoding the residual information of the current block into the bit stream, where the residual information indicates the prediction residual between the current block and the reference block.
[0031] Encoding the residual information of the current block into the bit stream can effectively ensure the accuracy of encoding the current block.
[0032] A decoding method is provided according to a second embodiment. The method includes the steps of: analyzing a bitstream to obtain location identification data and a first flag bit corresponding to the position vector difference of the current block to be decoded in a target region, wherein the position vector difference indicates the difference between the position vector of the current block and a reference position vector, the position vector of the current block indicates the positional relationship between the current block and the reference block corresponding to the current block, the location identification data is a multiple of the position vector difference with respect to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the location identification data; determining the position vector difference based on the target alignment size, the location identification data and the first flag bit; and reconstructing the current block based on the position vector difference.
[0033] The position identification data may be a multiple of the position vector difference relative to the target alignment size. Since encoding the position identification data and the first flag bit corresponding to the position vector difference requires fewer bits than encoding the position vector difference, when the position identification data is a multiple of the position vector difference relative to the target alignment size, the efficiency of decoding the position identification data is higher than the efficiency of decoding the position vector difference. In this way, the efficiency of decoding images containing text content is improved while ensuring decoding accuracy. Furthermore, the decoding method provided in this application can be combined with standard video decoding methods without affecting standard video decoding procedures. In other words, the decoding method provided in this application has relatively high portability and can improve the efficiency of decoding images containing text content without adding further hardware costs.
[0034] Optionally, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, the horizontal flag bit indicates the category of the horizontal identification data, and the step of determining the position vector difference based on the target alignment size, the position identification data and the first flag bit includes the step of multiplying the horizontal alignment size by the horizontal identification data to obtain the horizontal component if the value of the horizontal flag bit is the first value.
[0035] When the horizontal flag bit has a value of 1, it indicates that the horizontal identification data is a multiple of the horizontal component relative to the horizontal alignment size. Therefore, to obtain the horizontal component, the horizontal alignment size is multiplied by the horizontal identification data. Furthermore, when the horizontal flag bit has a value of 1, the efficiency of decoding the horizontal identification data is higher than the efficiency of decoding the horizontal component. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy.
[0036] Optionally, the method further includes the step of determining the horizontal identification data as a horizontal component if the value of the horizontal flag bit is a second value.
[0037] When the value of the horizontal flag bit is the second value, this indicates that the horizontal identification data is a horizontal component. Therefore, the horizontal identification data may be directly determined as a horizontal component.
[0038] Optionally, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, the vertical flag bit indicates the category of the vertical identification data, and the step of determining the position vector difference based on the target alignment size, the position identification data and the first flag bit includes the step of multiplying the vertical alignment size by the vertical identification data to obtain the vertical component if the value of the vertical flag bit is the first value.
[0039] When the value of the vertical flag bit is the first value, it indicates that the vertically identified data is a multiple of the vertical component relative to the vertical alignment size. Therefore, to obtain the vertical component, the vertical alignment size is multiplied by the vertically identified data. Furthermore, when the vertical flag bit is the first value, the efficiency of decoding the vertically identified data is higher than the efficiency of decoding the vertical component. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy.
[0040] Optionally, the method further includes the step of determining the vertical identification data as the vertical component if the value of the vertical flag bit is a second value.
[0041] When the value of the vertical flag bit is the second value, this indicates that the vertical identification data is a vertical component. Therefore, the vertical identification data may be determined directly as a vertical component.
[0042] Optionally, the target alignment size includes the horizontal alignment size and the vertical alignment size, the position vector difference includes the horizontal component and the vertical component, and the position identification data includes the horizontal identification data and the vertical identification data. The step of determining the position vector difference based on the target alignment size, the position identification data and the first flag bit includes, if the value of the first flag bit is a first value, multiplying the horizontal alignment size by the horizontal identification data to obtain the horizontal component, and multiplying the vertical alignment size by the vertical identification data to obtain the vertical component.
[0043] When the value of the first flag bit is the first value, this indicates that the location identification data is a multiple of the position vector difference relative to the target alignment size. Therefore, to obtain the horizontal component, the horizontal alignment size is multiplied by the horizontal identification data, and to obtain the vertical component, the vertical alignment size is multiplied by the vertical identification data. Furthermore, since encoding a multiple of the position vector difference relative to the target alignment size requires fewer bits than encoding the position vector difference of the current block, the efficiency of decoding the location identification data is higher than the efficiency of decoding the position vector difference when the value of the first flag bit is the first value. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy.
[0044] Optionally, the method further includes the step of determining horizontal identification data as a horizontal component and vertical identification data as a vertical component if the value of the first flag bit is the second value.
[0045] When the value of the first flag bit is the second value, this indicates that the position identification data is the position vector difference. Therefore, the horizontal identification data may be determined directly as the horizontal component, and the vertical identification data may be determined directly as the vertical component.
[0046] Optionally, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, the horizontal flag bit is further used in combination with the horizontal identification data to indicate the horizontal component, and the step of determining the position vector difference based on the target alignment size, the position identification data and the first flag bit includes the step of multiplying the horizontal identification data by the horizontal alignment size and then adding the value of the horizontal flag bit to obtain the horizontal component.
[0047] The horizontal identification data and horizontal flag bits corresponding to the horizontal component are the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size. Since the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the horizontal component, the efficiency of decoding the horizontal identification data and horizontal flag bits corresponding to the horizontal component in the decoding process is higher than the efficiency of decoding the horizontal component itself. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy.
[0048] Optionally, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, and the first flag bit includes the vertical flag bit, which is further used in combination with the vertical identification data to indicate the vertical component. The step of determining the position vector difference based on the target alignment size, the position identification data and the first flag bit includes multiplying the vertical identification data by the vertical alignment size and then adding the value of the vertical flag bit to obtain the vertical component.
[0049] The vertical identification data and vertical flag bits corresponding to the vertical component are the quotient and remainder obtained by dividing the vertical component by the vertical alignment size. Since the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the vertical component, the efficiency of decoding the vertical identification data and vertical flag bits corresponding to the vertical component in the decoding process is higher than the efficiency of decoding the vertical component itself. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy.
[0050] Optionally, the method further includes the step of analyzing a bitstream to obtain residual information of the current block, wherein the residual information indicates the predicted residual between the current block and a reference block, and the step of reconstructing the current block based on the position vector difference includes the step of reconstructing the current block based on the position vector difference and the residual information.
[0051] When residual information for the current block is obtained through analysis, the current block is reconstructed based on the position vector difference and residual information, and as a result, the accuracy of the reconstructed current block can be effectively ensured.
[0052] According to a third embodiment, an encoding device is provided. The encoding device has the function of realizing the behavior of the encoding method in the first embodiment. The encoding device includes at least one module. The at least one module is configured to realize the encoding method provided in the first embodiment.
[0053] According to a fourth aspect, a decoding device is provided. The decoding device has the function of realizing the behavior of the decoding method in the second aspect. The decoding device includes at least one module. The at least one module is configured to realize the decoding method provided in the second aspect.
[0054] According to a fifth aspect, an encoding device is provided. The encoding device includes a processor and memory. The memory is configured to store a program for performing the encoding method provided in the first aspect. The processor is configured to execute the program stored in memory to realize the encoding method provided in the first aspect.
[0055] Optionally, the encoding device may further include a communication bus, which is configured to establish a connection between the processor and memory.
[0056] According to a sixth aspect, a decoding device is provided. The decoding device includes a processor and memory. The memory is configured to store a program for performing the decoding method provided in a second aspect. The processor is configured to execute the program stored in memory to implement the decoding method provided in a second aspect.
[0057] Optionally, the decoding device may further include a communication bus, which is configured to establish a connection between the processor and memory.
[0058] According to the seventh aspect, a computer-readable storage medium is provided. The storage medium stores instructions. When the instructions are executed on a computer, the computer becomes capable of performing the steps of the encoding method according to the first aspect or the steps of the decoding method according to the second aspect.
[0059] According to the eighth aspect, a computer program product including instructions is provided. When the instructions are executed on a computer, the computer becomes capable of performing the steps of the encoding method according to the first aspect or the steps of the decoding method according to the second aspect. In other words, a computer program is provided. When the computer program is executed on a computer, the computer becomes capable of performing the steps of the encoding method according to the first aspect or the steps of the decoding method according to the second aspect.
[0060] According to the ninth aspect, an encoding and decoding system is provided. The encoding and decoding system includes an encoding device and a decoding device. The encoding device is configured to implement the steps of the encoding method according to the first aspect. The decoding device is configured to implement the steps of the decoding method according to the second aspect.
[0061] The technical effects achieved in the third to ninth embodiments are similar to those achieved by using the corresponding technical means in the first or second embodiment. Further details are not described herein. [Brief explanation of the drawing]
[0062] [Figure 1] This is a diagram of the implementation environment according to the embodiment of this application. [Figure 2] This is a diagram of another implementation environment according to the embodiment of this application. [Figure 3]This is a diagram showing the structure of a video encoding module according to an embodiment of this application. [Figure 4] This is a diagram showing the structure of a video decoding module according to an embodiment of this application. [Figure 5] This is a flowchart of the first encoding method according to an embodiment of this application. [Figure 6] This is a diagram of the target region according to an embodiment of this application. [Figure 7] This is a diagram of a filled-in text area according to an embodiment of this application. [Figure 8] This is a flowchart of the first decoding method according to an embodiment of this application. [Figure 9] This is a diagram showing the structure of an encoding device according to an embodiment of this application. [Figure 10] This is a diagram showing the structure of a decoding device according to an embodiment of this application. [Modes for carrying out the invention]
[0063] To further clarify the purpose, technical solutions, and advantages of the embodiments of this application, the implementation of this application will be described in more detail below with reference to the attached drawings.
[0064] To facilitate understanding, before describing in detail the encoding and decoding methods provided in embodiments of this application, we will first describe the terminology, application scenarios, and realization environments in embodiments of this application.
[0065] High-efficiency video coding (HEVC): HEVC is a video compression standard that uses a block-based hybrid video coding / compression structure. This structure combines technical means such as prediction, transformation, quantization, block partitioning, in-loop filtering, and entropy coding to compress video and reduce redundant signals within the video. The encoder partitions the input video frame or video signal into coding tree units (CTUs) of approximately equal size, performs a prediction on each CTU, and obtains the corresponding prediction residual. The prediction residual is converted into frequency-domain transformation coefficients, which are then quantized for lossy compression. The quantized frequency-domain transformation coefficients are then encoded into a bitstream through entropy coding. Furthermore, the CTU is reconstructed based on the bitstream using technical means such as inverse quantization, inverse transform, and in-loop filtering to obtain the reconstructed values of the video frames. Other CTUs can then encode based on these reconstructed values.
[0066] Prediction and transformation refer to reducing redundancy in a video signal by removing correlations between pixels within each CTU in the time, spatial, and frequency domains. Prediction includes inter-prediction and intra-prediction. Quantization refers to reducing the precision of the transformation coefficients and thus reducing the number of bits that represent the transformation coefficients. The purpose of quantization is to remove details that are difficult to perceive within a video frame, thereby effectively reducing data uncorrelatedness. Detailed information on block partitioning will be discussed later and will not be explained here.
[0067] Hybrid video coding structures are typically used to process natural video captured by cameras. However, in recent years, screen content video, which includes computer-generated text, graphics, and animations, has become widespread. Screen content video exhibits different color and other signal characteristics than natural video. To meet the requirements for efficiently encoding screen content video, many screen content coding (SCC) tools have been developed, significantly improving encoding efficiency. HEVC SCC is a coding standard that includes SCC functionality. HEVC SCC includes coding tools such as Intra Block Copy (IBC) and Palette, which can improve the compression efficiency of screen content by 30% to 40%.
[0068] Block Partitioning: The HEVC standard introduces a set of fundamental units based on recursive quadtree partitioning, including coding units (CUs), prediction units (PUs), and transform units (TUs). In an HEVC encoder, the input image is first partitioned into multiple non-overlapping coding tree units (CTUs) of the same size. The size of the CTUs is determined by the encoder, and the maximum size of a CTU may reach 64x64. In the subsequent encoding process, a single CTU may be used directly as a single CU, or it may be further divided into multiple smaller CUs in a recursive quadtree partitioning mode. The depth of the CU partitioning is determined based on the rate-distortion cost obtained through computation. The encoder compares different partitioning modes, trades off, and selects the partitioning mode with the lowest rate-distortion cost for encoding. Finally, the CUs at the leaf nodes of the quadtree are the fundamental units for which the encoder performs subsequent prediction, transformation, and encoding. Typically, during block partitioning, flat and smooth areas are given shallower partitioning depths and larger CUs, while areas with complex colors are given deeper partitioning depths and smaller CUs. In this way, the processing of prediction, transformation, quantization, and other modules becomes more convenient and accurate, and the selection of encoding modes better matches the image features of the video content, thereby effectively improving encoding efficiency.
[0069] The PU is the basic unit for which the encoder performs predictions. The PU contains all prediction-related information and is obtained by further partitioning the CU. For a 2N×2N CU, there are a total of eight optional partitioning modes for the PU, including four symmetric modes (i.e., 2N×2N, N×N, 2N×N, and N×2N) and four asymmetric modes with a 1:3 or 3:1 ratio for partitioning. The introduction of multiple partitioning modes can make predictions of complex images more accurate.
[0070] A TU (Turnover Unit) is the basic unit for which the encoder performs transformation and quantization. The size of a TU depends on the CU (Cumulative Unit) to which the TU belongs. A CU can be further partitioned in a quadtree partitioning mode to obtain a TU. The minimum size of a TU is 4x4, and the maximum size of a TU may reach 32x32. Depending on the content characteristics, the encoder can flexibly select the optimal partitioning mode for the TU.
[0071] Interpretation: Interpretation includes motion estimation (ME) units and motion compensation (MC) units. The basic idea of motion estimation is to partition a video frame into many non-overlapping macroblocks, and then find the block that is most similar to the current block, i.e., the reference block or matching block, according to matching rules. The relative displacement between the reference block and the current block is the motion vector (MV). The difference between the pixel values of the current block and the pixel values of the reference block is called the predicted residual between the current block and the reference block. The process of determining the MV is called motion estimation. Motion compensation means that the reference block corresponding to the current block is determined based on the MV, and then the current block is reconstructed based on the predicted residual between the current block and the reference block.
[0072] Motion vector (MV) prediction coding: Since the MV of the current block is generally related to the MVs of neighboring blocks in the current or nearby image, the MVs of neighboring blocks in the current or nearby image may be used as motion vector predictors (MVPs) to reduce the signal amplitude of the current block's MV. This is the concept of MV prediction coding.
[0073] In the evolutionary process of coding standards, MV prediction coding methods have been significantly optimized. MV prediction in the H.261 standard is simple differential coding. The H.265 / HEVC standard introduces a motion vector race scheme, where an MVP list is collected and the index of the optimal MVP is transmitted. Here, neighboring MVs in space and time are added to a candidate list, the MV with the optimal compression cost is selected from the list as the MVP, the index of the MV is transmitted, and the motion vector difference (MVD) is obtained by subtracting the MVP from the MV, i.e., MVD = MV - MVP. The MVD typically includes two components, namely a vertical component and a horizontal component, which need to be compressed and transmitted. On the decoder side, the MV of the current block may be calculated based on the index and MVD of the transmitted MVP in the list by establishing the same MVP list as on the encoder side.
[0074] In the HEVC standard, the MVP is determined in two modes: the advanced motion vector predictor (AMVP) mode and the merge mode. The AMVP mode can handle the flexible block structure in HEVC, while the merge mode can reduce redundancy in block partitioning.
[0075] Intra-block copy (IBC): IBC is a crucial tool for screen content coding in HEVC SCC. IBC is a block-based prediction technique, and its mechanism is similar to that of inter-prediction or motion compensation. Motion compensation means that for the current prediction unit, the encoder, based on a motion search algorithm, finds the best matching block in a previously encoded reference image as the reference block corresponding to the current block, and the motion vector (MV) indicates the matching relationship. The difference between the pixel value of the current block and the pixel value of the reference block is used as the prediction residual between the current block and the reference block. The prediction residual is processed by modules such as transformation, quantization, and entropy coding, and then output to the bitstream.
[0076] The main difference between IBC and motion compensation lies in the fact that in IBC, the reference image is obtained from within the current image (reconstructed portion), and a block vector (BV) similar to the motion vector exists to indicate block matching relationships. IBC can handle screen content containing multiple similar graphics or text within a video frame better; that is, the current block can reference a block containing similar graphics within the current image, and a predicted residual with pixel values close to zero may be obtained. This residual occupies a very low bitrate in the bitstream. The encoding process for the rest of IBC, including the syntax structure and related information, is almost the same as the encoding process for motion compensation.
[0077] The key to IBC technology is BV coding. In conventional technology, the BV coding method is the same as the MV prediction coding method in interpretation described above; that is, in IBC mode, BV is the same as MV, the block vector predictor (BVP) is the same as MVP, and the block vector difference (BVD) is the same as MVD. For the sake of simplicity, in the following explanation, BV and MV will be collectively referred to as position vectors, BVP and MVP will be collectively referred to as reference position vectors, and BVD and MVD will be collectively referred to as position vector differences.
[0078] Image compression is a technique that uses image data features such as spatial redundancy, visual redundancy, and statistical redundancy to represent the original image pixel matrix using fewer bits, either in a lossy or lossless manner. Image compression enables the efficient transmission and storage of image information and plays a crucial role in today's media era, where image information is increasingly diverse in type and in large amounts of data.
[0079] Currently, video compression standards such as HEVC are being developed. HEVC can divide video into multiple video frames, and the encoder may encode the video frames in motion-compensated mode or IBC mode. However, when the above encoding modes are applied to images containing text content, the pixels of the same character may be assigned to different CTUs or CUs. In this case, the encoding efficiency during text content compression is relatively low when subsequent operations such as prediction, transformation, and quantization are performed.
[0080] Based on the above problems, adaptive text alignment coding schemes have emerged. In this scheme, an image containing text content, i.e., a target image, can be processed to obtain text and non-text regions corresponding to the target image. Alignment processing is performed on the text regions within the target image based on the target alignment size, which is related to the size of the CU, in order to obtain the processed text regions, i.e., the target regions. The target alignment size is then related to the size of the CU. Because the target alignment size is related to the size of the CU, when block partitioning is performed on the target region, it is possible to prevent pixels of the same character from being assigned to different CUs as much as possible. In this way, the accuracy and efficiency of compressing text content are improved.
[0081] The adaptive text alignment coding scheme described above solves the problem of pixels of the same character being assigned to different CTUs or CUs. However, the position vector of text content typically points from one character (i.e., the current block or current character) to another character with similar content (i.e., the reference block or reference character), but characters are arranged based on semantics, and the same character does not appear in groups. Therefore, the reference characters corresponding to two neighboring characters are usually different, and there is a relatively large difference between the position vectors of two neighboring characters. As a result, when the position vector of a character is coded, the difference between the position vector of the character and the reference position vector is relatively large, and a position vector difference with a relatively large value is obtained. In this case, the position vector difference needs to be coded using a relatively large number of bits, and as a result, the efficiency of coding the target image is relatively low. Based on this, embodiments of this application provide coding and coding methods. In the coding process, based on the target alignment size and the position vector difference of the current block, position identification data corresponding to the position vector difference and a first flag bit can be coded into a bitstream. The position identification data may be a multiple of the position vector difference with respect to the target alignment size. In this case, encoding the position identification data and the first flag bit corresponding to the position vector difference requires fewer bits than encoding the position vector difference itself. In other words, the bit cost for encoding the position identification data and the first flag bit corresponding to the position vector difference is usually smaller than the bit cost for directly encoding the position vector difference. Therefore, the encoding method provided in the embodiments of this application effectively reduces the number of bits required to encode the position vector difference while ensuring encoding accuracy, thereby ensuring relatively high efficiency in encoding the target image.
[0082] The implementation environment in the embodiments of this application will be described below.
[0083] Figure 1 is a diagram of an implementation environment according to an embodiment of this application. The implementation environment includes a source device 10, a destination device 20, a link 30, and a storage device 40. The source device 10 may generate encoded video, i.e., a bitstream. Therefore, the source device 10 may also be called an encoder. The destination device 20 may decode the bitstream generated by the source device 10. Therefore, the destination device 20 may also be called a decoder. The link 30 may receive the encoded video generated by the source device 10 and transmit the encoded video to the destination device 20. The storage device 40 may receive the encoded video generated by the source device 10 and store the encoded video. In this case, the destination device 20 may directly obtain the encoded video from the storage device 40. Alternatively, the storage device 40 may correspond to a file server or other intermediate storage device capable of storing the encoded video generated by the source device 10. In this case, the destination device 20 may transmit the encoded video stored in the storage device 40 via streaming or download it.
[0084] The source device 10 and the destination device 20 may each include one or more processors and memory coupled to one or more processors. The memory may include random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory, or any other medium that can be configured to store the necessary program code in the form of computer-accessible instructions or data structures. For example, the source device 10 and the destination device 20 may each include mobile phones, smartphones, personal digital assistants (PDAs), wearable devices, palmtop computers (pocket PCs, PPCs), tablet computers, smart in-car infotainment systems, smart TVs, smart sound boxes, desktop computers, mobile computing devices, notebook (e.g., laptop) computers, tablet computers, set-top boxes, handheld phones such as "smartphones," televisions, cameras, display devices, digital media players, video game consoles, in-car computers, etc.
[0085] Link 30 may include one or more media or devices capable of transmitting encoded video from source device 10 to destination device 20. In possible implementations, Link 30 may include one or more communication media that enable source device 10 to directly transmit encoded video to destination device 20 in real time. In this embodiment of the application, source device 10 may modulate the encoded video according to a communication standard, the communication standard may be a wireless communication protocol, etc., and transmit the modulated video to destination device 20. One or more communication media may include wireless communication media and / or wired communication media. For example, one or more communication media may include a radio frequency (RF) spectrum or one or more physical transmission lines. One or more communication media may be part of a packet-based network. The packet-based network may be a local area network, a wide area network, a global network (e.g., the Internet), etc. One or more communication media may include routers, switches, base stations, other devices that facilitate communication from source device 10 to destination device 20, etc. This is not particularly limited to this embodiment of the application.
[0086] In possible embodiments, the storage device 40 may store the received encoded video transmitted by the source device 10, and the destination device 20 may directly retrieve the encoded video from the storage device 40. In this case, the storage device 40 may include one of several distributed or locally accessed data storage media. For example, one of several distributed or locally accessed data storage media may be a hard disk drive, a Blu-ray disc, a digital versatile disc (DVD), a compact disc read-only memory (CD-ROM), flash memory, volatile or non-volatile memory, or any other suitable digital storage medium configured to store a bitstream.
[0087] In possible implementations, the storage device 40 may correspond to a file server or other intermediate storage device capable of storing the bitstream generated by the source device 10, and the destination device 20 may transmit the image stored in the storage device 40 via streaming or download it. The file server may be any type of server capable of storing encoded video and transmitting the encoded video to the destination device 20. In possible implementations, the file server may include a network server, a file transfer protocol (FTP) server, a network attached storage (NAS) device, a local disk drive, etc. The destination device 20 may retrieve the encoded image via any standard data connection (including an internet connection). Any standard data connection may include a wireless channel (e.g., Wi-Fi connection), a wired connection (e.g., digital subscriber line (DSL) or cable modem), or a combination of a wireless channel and a wired connection, suitable for retrieving the encoded video stored in the file server. Transmission of the encoded video from the storage device 40 may be via streaming transmission, download transmission, or a combination thereof.
[0088] The implementation environment shown in Figure 1 is merely a possible implementation. Furthermore, the technology in the embodiments of this application is applicable not only to the source device 10 capable of encoding an image and the destination device 20 capable of decoding the encoded video in Figure 1, but also to other devices capable of encoding video and decoding a bitstream. This is not particularly limited to the embodiments of this application.
[0089] In the implementation environment shown in Figure 1, the source device 10 includes a data source 120, an encoder 100, and an output interface 140. In some embodiments, the output interface 140 may include a modulator / demodulator (modem) and / or a transmitter. The transmitter may also be called an emitter. The data source 120 may include a video capture device (e.g., a camera), an archive containing previously captured video, a feed interface for receiving video from a video content provider, and / or a computer graphics system for generating video, or a combination of these video sources.
[0090] The data source 120 may transmit video to the encoder 100. The encoder 100 may encode the received video transmitted by the data source 120 to obtain an encoded video. The encoder may transmit the encoded video to the output interface. In some embodiments, the source device 10 transmits the encoded video directly to the destination device 20 through the output interface 140. In other embodiments, the storage device 40 may, alternatively, store the encoded video that will later be retrieved, decoded and / or displayed by the destination device 20.
[0091] In the implementation environment shown in Figure 1, the destination device 20 includes an input interface 240, a decoder 200, and a display device 220. In some embodiments, the input interface 240 includes a receiver and / or a modem. The input interface 240 may receive encoded video via link 30 and / or from storage device 40, and then transmit the encoded video to the decoder 200. The decoder 200 may decode the received encoded video to obtain the decoded video. The decoder may transmit the decoded video to the display device 220. The display device 220 may be integrated with the destination device 20 or may be located outside the destination device 20. Generally, the display device 220 displays the decoded video. The display device 220 may be any one of several types of display devices. For example, the display device 220 may be a liquid crystal display (LCD), a plasma display, an organic light-emitting diode (OLED) display, or another type of display device.
[0092] Although not shown in Figure 1, in some embodiments, the encoder 100 and decoder 200 may be integrated with the encoder and decoder, respectively, and may include a suitable multiplexer-demultiplexer (MUX-DEMUX) unit or other hardware and software for encoding both audio and video in a shared data stream or separate data streams. In some embodiments, where applicable, the MUX-DEMUX unit may conform to the ITU H.223 multiplexer protocol or other protocols such as the user datagram protocol (UDP).
[0093] The encoder 100 and decoder 200 may each be one of the following circuits: one or more microprocessors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), discrete logic, hardware, or any combination thereof. If the technology in the embodiments of this application is partially implemented in software, the device may store instructions for the software in a suitable non-volatile computer-readable storage medium, and may implement the technology in the embodiments of this application by executing the instructions in hardware using one or more processors. Any one of the above (including hardware, software, and combinations of hardware and software) may be considered as one or more processors. The encoder 100 and decoder 200 may each be included in one or more encoders or decoders. Either the encoder or decoder may be integrated as part of a combined encoder / decoder (codec) in the corresponding device.
[0094] In this embodiment of the application, the encoder 100 may generally be referred to as "signaling" or "transmitting" some information to another device, for example, a decoder 200. The terms "signaling" or "transmitting" may generally refer to the transmission of syntax elements and / or other data used to decode compressed video. Such transmission may occur in real time or near real time. Alternatively, such communication may occur after a period of time, for example, when the syntax elements in the encoded bitstream are stored in a computer-readable storage medium during encoding, and the decoder may then retrieve the syntax elements at some point after they have been stored in the medium.
[0095] Figure 2 shows another implementation environment according to an embodiment of this application. The implementation environment includes an encoder side and a decoder side. The encoder side includes a video encoding module, a video encapsulation module, and a channel transmission module. The decoder side includes a video deencapsulation module and a video decoding module. It should be noted that the encoder side including the channel transmission module is merely an example. In actual applications, the decoder side may also include a channel transmission module. Alternatively, the channel transmission module may be used as an independent unit, not belonging to the encoder side or the decoder side. This is not limited to this embodiment of this application.
[0096] For each video frame in the video to be encoded, the video encoding module may encode the video frame to obtain a bitstream of the video frame or an encoded file. The video encapsulation module then performs video encapsulation on the encoded file to convert it into a video format suitable for transmission. The channel transmission module transmits the encapsulated encoded file to the decoder. The decoder receives the transmitted encoded file, decapsulates the encoded file, and reconstructs the encoded file using the video decoding module to obtain the reconstructed video frame.
[0097] Referring to Figure 3, the encoder-side video encoding module may include a text processing submodule, a position vector difference encoding submodule, and a standard video encoding submodule. For the video frame to be encoded, the text processing submodule may perform alignment processing on the text region within the video frame based on the target alignment size, where the text region contains at least one character. The position vector difference encoding submodule determines the position vector difference of the current block to be encoded within the aligned text region, determines position identification data and a first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference of the current block, and then encodes the position identification data and the first flag bit corresponding to the position vector difference into a bitstream to encode the position vector difference. The standard video encoding submodule also encodes residual information and edge information of the current block into a bitstream, where the residual information indicates the predicted residual between the current block and the reference block, and the edge information includes the target alignment size.
[0098] Optionally, video frames may further contain non-text regions. For non-text regions, the standard video encoding submodule may directly encode the non-text regions into the bitstream in standard video encoding mode.
[0099] Referring to Figure 4, the video decoding module on the decoder side may include a position vector difference decoding submodule, a standard video decoding submodule, and a text reconstruction submodule. The position vector difference decoding submodule may analyze the bitstream to obtain position identification data and a first flag bit corresponding to the position vector difference of the current block to be decoded in the text region, the standard video decoding submodule analyzes the bitstream to obtain residual information and edge information of the current block, and then the text reconstruction submodule determines the position vector difference of the current block based on the target alignment size and the position identification data and first flag bit corresponding to the position vector difference of the current block, and reconstructs the current block in the text region based on the residual information and position vector difference.
[0100] Optionally, for non-text regions, the standard video decoding submodule analyzes the bitstream in standard video decoding mode to obtain the non-text regions, and then performs text reconstruction on the non-text and text regions to obtain the reconstructed video frame.
[0101] It should be noted that the standard video coding / decoding mode may be a video compression standard that uses a block-based hybrid video coding / compression structure, such as HEVC. Obviously, other coding / decoding modes may be used. This is not limited to this embodiment of the application.
[0102] The encoding and decoding methods provided in embodiments of this application may be applied to multiple scenarios. For example, in video applications such as online meetings and online education, text content typically occupies a large portion of the video content, and people primarily focus on the text portion as well. Therefore, compression of images containing text content is important. The following describes methods for encoding / decoding images containing text content according to embodiments of this application. Referring to the implementation environment shown in Figures 1 and 2, it should be noted that any of the encoding methods in the following description may be performed by the encoder 100 in the source device 10, or by the video encoding module in Figure 2. Any of the decoding methods in the following description may be performed by the decoder 200 in the destination device 20, or by the video decoding module in Figure 2.
[0103] The encoding and decoding methods provided in the embodiments of this application will be described in detail below by using several embodiments.
[0104] Figure 5 is a flowchart of a first encoding method according to an embodiment of this application. Referring to Figure 5, the method includes the following steps:
[0105] Step 501: The target region is obtained by performing an alignment process based on the target alignment size.
[0106] In some embodiments, the target region is obtained by performing an alignment process on a text region within the target image based on the target alignment size, and the text region contains at least one character.
[0107] In other words, a text region within the target image may be determined, the text region may contain at least one character, and an alignment process is performed on the text region based on the target alignment size in order to obtain the target region.
[0108] Optionally, text recognition is performed on a target image by using a text recognition network model to obtain text regions within the target image. In other words, the target image is used as input to a text recognition network model, and the text recognition network model can output text regions within the target image based on the target image. Obviously, in practical applications, the text regions may be determined by other methods, such as projection or pixel color-based methods, as is not limited to this embodiment of this application.
[0109] In some embodiments, the location of text regions within the target image may also be determined. For example, when text regions within the target image are determined by using a text recognition network model, the location of text regions within the target image may also be determined.
[0110] The implementation process for performing alignment on text regions includes filling in text regions within the target image based on the target alignment size, obtaining the filled text regions, and determining the target region based on the filled text regions.
[0111] In some embodiments, the target alignment size is a positive integer multiple of any size in the size set, and the target alignment size is greater than or equal to the size of the text region in the target image.
[0112] The target image may be encoded by using the relevant encoding method. In the relevant encoding / decoding method, the target image is partitioned to obtain a CU, and subsequent processing is performed based on the CU. The size of the CU may include one of 8, 16, 32, and 64. Therefore, the size set may include 8, 16, 32, and 64. Obviously, the size set may, alternatively, be determined based on the size of the CU. The sizes in the size set are not less than the size of the CU and are equal to integer multiples of the size of the CU. For example, if the size of the CU is 8, the sizes in the size set may include 8 and 16. In another example, if the size of the CU is 32, the sizes in the size set may include 32.
[0113] The target alignment size includes a horizontal alignment size and a vertical alignment size. In this case, the horizontal alignment size is a positive integer multiple of any size in the size set, and the vertical alignment size is a positive integer multiple of any size in the size set. In other words, the horizontal alignment size may or may not be equal to the vertical alignment size. For example, the horizontal alignment size may be 16 and the vertical alignment size may be 16. This is not limited to this embodiment of the application.
[0114] When the target alignment size includes both the horizontal and vertical alignment sizes, the size of the text area within the target image includes both height and width. When the target alignment size is greater than or equal to the size of the text area within the target image, the horizontal alignment size may be considered to be greater than or equal to the width of the text area within the target image, and the vertical alignment size may be considered to be greater than or equal to the height of the text area within the target image.
[0115] An embodiment of obtaining a filled text region by filling a text region in a target image based on a target alignment size includes determining a fill size based on the target alignment size and the size of the text region in the target image, filling the text region in the target image based on the fill size so that the size of the filled text region matches the target alignment size, and obtaining the filled text region.
[0116] In some embodiments, the target alignment size includes a horizontal alignment size and a vertical alignment size, the size of the text area in the target image includes height and width, and the fill size includes a horizontal fill size and a vertical fill size. Thus, the difference between the horizontal alignment size and the width of the text area may be determined as the horizontal fill size, and the difference between the vertical alignment size and the height of the text area may be determined as the vertical fill size.
[0117] Embodiments of filling a text area within a target image based on a fill size include: horizontally outside the text area (e.g., to the left and / or right of the text area, this is not limited), the fill height is the vertical alignment size and the width is a preset pixel value of the horizontal fill size; vertically outside the text area (e.g., above and / or below the text area, this is not limited), the fill height is the vertical fill size and the width is a preset pixel value of the horizontal alignment size.
[0118] The pre-set pixel values may be the pixel values of background pixels other than character pixels within the text area, or they may be default pixel values, such as 0 or 255. This is not limited to this embodiment of the application.
[0119] It should be noted that when filling is applied to the left and right sides of a text area, the sum of the left and right fill sizes is the horizontal fill size. When filling is applied to the top and bottom sides of a text area, the sum of the top and bottom fill sizes is the vertical fill size.
[0120] Since the target image may contain one or more text regions, it may also contain one or more filled text regions. When the number of filled text regions differs, the implementation method for determining the target region based on the filled text regions will differ, and these will be explained separately below.
[0121] If a filled text area exists, that filled text area will be used as the target area.
[0122] If multiple filled text regions exist, these regions are sequentially concatenated from left to right and top to bottom in the order they appear in the target image to obtain the target region.
[0123] To facilitate understanding, the above process of determining the target area will be explained using an example.
[0124] As shown in Figure 6, the target image contains four characters: "fill", "report", "explanation", and "bright". Text recognition is performed on the target image using a text recognition network model to obtain four text regions. These four text regions correspond to the four characters: "fill", "report", "explanation", and "bright". When both the height and width of the four text regions are 8, both the horizontal and vertical alignment sizes are 16. In this case, the region corresponding to the character "fill" is used as an example. Referring to Figure 7, both the horizontal and vertical fill sizes are 16-8=8, and the right side outside the text region is filled with a preset pixel value having a height of 16 and a width of 8, and the bottom side outside the text region is filled with a preset pixel value having a height of 8 and a width of 16 to obtain a filled text region. The multiple filled text regions are then sequentially concatenated from left to right and top to bottom in the order of the four characters "fill", "report", "explanation", and "bright" in the target image to obtain the target region in Figure 6.
[0125] It should be noted that the target image may be a standalone image or any video frame within a video. This is not limited to this embodiment of the application.
[0126] The above description is based on the example that the target region is a text region obtained by performing an alignment process. In practical use, the target region is still obtained by performing an alignment process on other regions in the target image that have character attributes. Character attributes refer to other base units (i.e., reference blocks or reference base units) with similar content from a base unit (i.e., the current block or current base unit) where the position vector is different, the reference base units corresponding to two neighboring base units are usually different, and the position vectors of the two neighboring base units are significantly different. In this embodiment of the application, characters may be used as base units. In practical use, any region contained in the target image that satisfies the above character attributes may be used as a base unit.
[0127] For example, the target image contains multiple emojis, and the multiple emojis satisfy the above character attributes, i.e., the position vector of the emoji content points from one emoji (i.e., the current block or current emoji) to another emoji with similar content (i.e., the reference block or reference emoji), the reference emojis corresponding to two neighboring emojis are usually different, and the position vectors of two neighboring emojis are significantly different. In this case, emojis may be used as the base unit, and the target region may be obtained by performing an alignment process on the emoji region in the target image based on the target alignment size, and the emoji region contains at least one emoji. In another example, the target image contains multiple subimages, and the multiple subimages satisfy the above character attributes, i.e., the position vector of the subimage content points from one subimage (i.e., the current block or current subimage) to another subimage with similar content (i.e., the reference block or reference subimage), the reference subimages corresponding to two neighboring subimages are usually different, and the position vectors of two neighboring subimages are significantly different. In this case, subimages may be used as the basic unit, and the target region may be obtained by performing an alignment process on the subimage region within the target image based on the target alignment size, and the subimage region contains at least one subimage.
[0128] It should be noted that an embodiment in which alignment processing is performed on regions having character attributes within a target image in order to obtain a target region is similar to the embodiment in which alignment processing is performed on text regions within a target image in order to obtain a target region. Further details will not be described again herein. Furthermore, since the target region is obtained by performing alignment processing on regions having character attributes within a target image, there are multiple possibilities for regions having character attributes within the target image. Therefore, for the sake of clarity, the following description uses the example in which the target region is a text region obtained by performing alignment processing.
[0129] In some embodiments, target non-text regions may also be determined. In other words, text regions within the target image are filled with preset pixel values in order to obtain the target non-text regions.
[0130] Step 502: Determine the position vector difference of the current block to be encoded within the target region. The position vector difference represents the difference between the position vector of the current block and the reference position vector, and the position vector of the current block represents the positional relationship between the current block and the reference block corresponding to the current block.
[0131] Based on the current block to be coded within the target region, the corresponding reference block is determined based on the relevant algorithm. The relative displacement between the current block and the reference block is determined as the position vector of the current block. Based on the position vector of the current block and the relevant predictive coding algorithm, the corresponding reference position vector is determined. The difference between the position vector of the current block and the reference position vector is determined as the position vector difference of the current block.
[0132] Step 503: Based on the target alignment size and the position vector difference of the current block, determine the position identification data and the first flag bit corresponding to the position vector difference, where the position identification data is either a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data.
[0133] In some embodiments, the position identification data and the value of the first flag bit may be determined based on the target alignment size and the position vector difference.
[0134] In some embodiments, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit indicates the category of the horizontal identification data. In this case, if the horizontal component is an integer multiple of the horizontal alignment size, the multiple of the horizontal component to the horizontal alignment size is determined as the horizontal identification data, and the first value is determined as the value of the horizontal flag bit.
[0135] When the horizontal component is an integer multiple of the horizontal alignment size, the multiple of the horizontal component relative to the horizontal alignment size can accurately represent the horizontal component. Therefore, the multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data. In this way, the horizontal component can be accurately encoded into the bitstream, and the accuracy of encoding and decoding the horizontal component is ensured.
[0136] Furthermore, if the horizontal component is not an integer multiple of the horizontal alignment size, the horizontal component is determined as the horizontal identification data, and the second value is determined as the value of the horizontal flag bit.
[0137] When the horizontal component is not an integer multiple of the horizontal alignment size, the multiple of the horizontal component relative to the horizontal alignment size cannot accurately represent the horizontal component. Therefore, the horizontal component is directly determined as horizontal identification data to avoid horizontal component encoding errors caused by encoding the multiple of the horizontal component relative to the horizontal alignment size into a bitstream, thereby ensuring accuracy in encoding and decoding the horizontal component.
[0138] In some possible embodiments, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit indicates the category of the vertical identification data. In this case, if the vertical component is an integer multiple of the vertical alignment size, the multiple of the vertical component to the vertical alignment size is determined as the vertical identification data, and the first value is determined as the value of the vertical flag bit.
[0139] As explained above, when the vertical component is an integer multiple of the vertical alignment size, the multiple of the vertical component relative to the vertical alignment size can accurately represent the vertical component. Therefore, the multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data. In this way, the vertical component can be accurately encoded into the bitstream, ensuring the accuracy of encoding and decoding the vertical component.
[0140] Furthermore, if the vertical component is not an integer multiple of the vertical alignment size, the vertical component is determined as the vertical identification data, and the second value is determined as the value of the vertical flag bit.
[0141] When the vertical component is not an integer multiple of the vertical alignment size, the multiple of the vertical component relative to the vertical alignment size cannot accurately represent the vertical component. Therefore, the vertical component is determined directly as vertical identification data to avoid vertical component encoding errors caused by encoding the multiple of the vertical component relative to the vertical alignment size into a bitstream, thereby ensuring accuracy in encoding and decoding the vertical component.
[0142] The first and second values are predetermined, and the first value is different from the second value. For example, the first value may be 1 and the second value may be 0. Furthermore, if they are different, further adjustments may be made based on different requirements.
[0143] In one example, the first value is 1, the second value is 0, both the horizontal and vertical alignment sizes are 16, the horizontal component is 16, and the vertical component is 64. For the horizontal component, 16 ÷ 16 = 1, meaning the horizontal component is an integer multiple of the horizontal alignment size. Therefore, the horizontal identification data is 1, and the value of the horizontal flag bit is 1. For the vertical component, 64 ÷ 16 = 4, meaning the vertical component is an integer multiple of the vertical alignment size. Therefore, the vertical identification data is 4, and the value of the vertical flag bit is 1.
[0144] In another example, the first value is 1, the second value is 0, both the horizontal and vertical alignment sizes are 16, the horizontal component is 17, and the vertical component is 64. For the horizontal component, 17 ÷ 16 = 1.0625, meaning the horizontal component is not an integer multiple of the horizontal alignment size. Therefore, the horizontal identification data is 17, and the value of the horizontal flag bit is 0. For the vertical component, 64 ÷ 16 = 4, meaning the vertical component is an integer multiple of the vertical alignment size. Therefore, the vertical identification data is 4, and the value of the vertical flag bit is 1.
[0145] If the position vector difference is not an integer multiple of the target alignment size, it should be noted that, in addition to directly using the position vector difference as position identification data, the quotient obtained by dividing the position vector difference by the target alignment size may also be determined as position identification data, and the remainder obtained by dividing the position vector difference by the target alignment size may be determined as the first flag bit. In this case, the first value is 0.
[0146] When the position vector difference is not an integer multiple of the target alignment size, the remainder obtained by dividing the position vector difference by the target alignment size is obviously not zero. Therefore, the first value may be set to 0. Thus, the first flag bit can still indicate a category of position identification data. Furthermore, the position vector difference can be accurately represented by the quotient and remainder obtained by dividing the position vector difference by the target alignment size, and the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference. Therefore, even when the position vector difference is not an integer multiple of the target alignment size, accurate encoding of the position vector can be achieved using a relatively small number of bits, thereby improving the efficiency of encoding images containing text content while ensuring the accuracy of encoding the position vector difference. Obviously, when the position vector difference is not an integer multiple of the target alignment size, the position identification data and the first flag bit corresponding to the position vector difference may be determined by other means as an alternative. This is not limited to this embodiment of the application.
[0147] Step 504: Encode the position identification data corresponding to the position vector difference and the first flag bit into a bitstream.
[0148] In some embodiments, residual information of the current block may also be encoded into a bitstream, where the residual information represents the predicted residual between the current block and the reference block.
[0149] Optionally, edge information may also be encoded into the bitstream, and the edge information includes the target alignment size. Furthermore, the edge information further includes the location of the text region in the target image. For example, the location of the text region in the target image may be the horizontal and vertical coordinates of the pixels at the top-left, bottom-left, top-right, or bottom-right corners of the text region in the target image. Obviously, the location of the text region in the target image may also be other coordinates that are in the text region and can be used to determine the location of the text region in the target image. This is not limited to this embodiment of the application. During decoding, the text region can be reconstructed from the reconstructed image based on the location of the text region in the target image, thereby improving decoding efficiency.
[0150] When the target alignment size includes both horizontal and vertical alignment sizes, and the horizontal alignment size is equal to the vertical alignment size, it should be noted that when the target alignment size is encoded into a bitstream, it is not necessary to encode both the horizontal and vertical alignment sizes into the bitstream; only one of them needs to be encoded. In this way, the number of bits required to encode edge information can be effectively reduced, and encoding efficiency can be effectively improved.
[0151] In some embodiments, edge information may be encoded into the bitstream in differential coding mode, residual information for the current block may be encoded into the bitstream in entropy coding mode, a first flag bit may be encoded into the bitstream in binary coding mode, and location identification data may be encoded into the bitstream in exponential Golomb coding mode. Optionally, when a target nontext region is determined, the target nontext region may also be encoded into the bitstream. Obviously, in practical applications, the above information may be encoded into the bitstream in other coding modes as an alternative. This is not limited to this embodiment of the application.
[0152] For example, when the position vector difference is MVD, the coding syntax elements corresponding to the coding method are shown in Table 1.
[0153] [Table 1] As shown in Table 1, mvd_coding(x0,y0) indicates that the position vector difference of the current block with coordinates (x0,y0) is encoded.
[0154] The original syntax for abs_mvd_greater0_flag[0] and abs_mvd_greater0_flag[1] is abs_mvd_greater0_flag[compIdx]. abs_mvd_greater0_flag[compIdx] can indicate whether the absolute value of the location identification data is greater than 0, and abs_mvd_greater0_flag[compIdx] may be 1 or 0. If the absolute value of the location identification data is greater than 0, abs_mvd_greater0_flag[compIdx] is 1, and 1 is encoded in the bitstream; otherwise, abs_mvd_greater0_flag[compIdx] is 0, and 0 is encoded in the bitstream. When the location identification data includes horizontal identification data and vertical identification data, compIdx may be 0 or 1. When compIdx is 0, it indicates horizontally discriminant data, and when compIdx is 1, it indicates vertically discriminant data. Therefore, abs_mvd_greater0_flag[0] indicates whether the absolute value of the horizontally discriminant data is greater than 0. If the absolute value of the horizontally discriminant data is greater than 0, 1 is encoded in the bitstream; otherwise, 0 is encoded in the bitstream. abs_mvd_greater0_flag[1] indicates whether the absolute value of the vertically discriminant data is greater than 0. If the absolute value of the vertically discriminant data is greater than 0, 1 is encoded in the bitstream; otherwise, 0 is encoded in the bitstream.
[0155] The original syntax for abs_mvd_greater1_flag[0] and abs_mvd_greater1_flag[1] is abs_mvd_greater1_flag[compIdx]. abs_mvd_greater1_flag[compIdx] can indicate whether the absolute value of the location identifier data is greater than 1, and abs_mvd_greater1_flag[compIdx] may be 1 or 0. If the absolute value of the location identifier data is greater than 1, abs_mvd_greater1_flag[compIdx] is 1, and 1 is encoded in the bitstream; otherwise, abs_mvd_greater1_flag[compIdx] is 0, and 0 is encoded in the bitstream. When the location identifier data includes horizontal identifier data and vertical identifier data, compIdx may be 0 or 1. When compIdx is 0, it indicates horizontally discriminant data, and when compIdx is 1, it indicates vertically discriminant data. Therefore, abs_mvd_greater1_flag[0] indicates whether the absolute value of the horizontally discriminant data is greater than 0. If the absolute value of the horizontally discriminant data is greater than 0, 1 is encoded in the bitstream; otherwise, 0 is encoded in the bitstream. abs_mvd_greater1_flag[1] indicates whether the absolute value of the vertically discriminant data is greater than 1. If the absolute value of the vertically discriminant data is greater than 1, 1 is encoded in the bitstream; otherwise, 0 is encoded in the bitstream.
[0156] If (abs_mvd_greater0_flag[0]) abs_mvd_greater1_flag[0] is 1, then it is determined whether the absolute value of the horizontal identification data is greater than 1. If the absolute value of the horizontal identification data is greater than 1, then abs_mvd_greater1_flag[0] is 1, and 1 is encoded into the bitstream. Otherwise, abs_mvd_greater1_flag[0] is 0, and 0 is encoded into the bitstream.
[0157] The meaning of `if(abs_mvd_greater0_flag[1]) abs_mvd_greater1_flag[1]` is the same as the meaning of `if(abs_mvd_greater0_flag[0]) abs_mvd_greater1_flag[0]` above. For detailed information, please refer to the relevant content above. Further details will not be explained again in this specification.
[0158] The original syntax for mvd_ada_precision_flag[0] and mvd_ada_precision_flag[1] is mvd_ada_precision_flag[compIdx]. mvd_ada_precision_flag[compIdx] indicates whether the first flag bit is equal to 1. mvd_ada_precision_flag[compIdx] may be 1 or 0. If the first flag bit is equal to 1, mvd_ada_precision_flag[compIdx] is 1, and 1 is encoded in the bitstream; otherwise, mvd_ada_precision_flag[compIdx] is 0, and 0 is encoded in the bitstream. When the first flag bit includes a horizontal flag bit and a vertical flag bit, compIdx may be 0 or 1. When compIdx is 0, it indicates the horizontal flag bit, and when compIdx is 1, it indicates the vertical flag bit. Therefore, mvd_ada_precision_flag[0] indicates whether the horizontal flag bit is equal to 1. If the horizontal flag bit is equal to 1, 1 is encoded in the bitstream; otherwise, 0 is encoded in the bitstream. mvd_ada_precision_flag[1] indicates whether the vertical flag bit is equal to 1. If the vertical flag bit is equal to 1, 1 is encoded in the bitstream; otherwise, 0 is encoded in the bitstream.
[0159] If (abs_mvd_greater0_flag[0]) mvd_ada_precision_flag[0] is greater than 0 in absolute value of the horizontal identification data, i.e., when abs_mvd_greater0_flag[0] is 1, it is determined whether the horizontal flag bit is equal to 1 or not. If the horizontal flag bit is equal to 1, mvd_ada_precision_flag[0] is 1 and 1 is encoded in the bitstream; otherwise, mvd_ada_precision_flag[0] is 0 and 0 is encoded in the bitstream.
[0160] The meaning of `if(abs_mvd_greater0_flag[1]) mvd_ada_precision_flag[1]` is the same as the meaning of `if(abs_mvd_greater0_flag[0]) mvd_ada_precision_flag[0]` above. For details, please refer to the relevant content above. Further details will not be explained again in this specification.
[0161] The original syntax for mvd_sign_flag[0] and mvd_sign_flag[1] is mvd_sign_flag[compIdx]. mvd_sign_flag[compIdx] indicates whether the location identifier data is positive or negative. mvd_sign_flag[compIdx] can be 1 or 0. If the location identifier data is a positive value, mvd_sign_flag[compIdx] is determined to be equal to 0, and 0 is encoded in the bitstream. If the location identifier data is a negative value, mvd_sign_flag[compIdx] is determined to be equal to 1, and 1 is encoded in the bitstream. When the location identifier data includes horizontal identifier data and vertical identifier data, compIdx can be 0 or 1. When compIdx is 0, it indicates horizontal identifier data, or when compIdx is 1, it indicates vertical identifier data. Therefore, mvd_sign_flag[0] indicates whether the horizontal discriminant data is positive or negative. If the horizontal discriminant data is a positive value, 0 is encoded in the bitstream; otherwise, 1 is encoded in the bitstream. mvd_sign_flag[1] indicates whether the vertical discriminant data is positive or negative. If the vertical discriminant data is a positive value, 0 is encoded in the bitstream; otherwise, 1 is encoded in the bitstream.
[0162] The original syntax for abs_mvd_minus2[0] and abs_mvd_minus2[1] is abs_mvd_minus2[compIdx]. abs_mvd_minus2[compIdx] represents the value obtained by subtracting 2 from the absolute value of the location identifier data, i.e., the value obtained by subtracting 2 from the absolute value of the location identifier data is encoded into the bitstream. When the location identifier data includes horizontal identifier data and vertical identifier data, compIdx may be 0 or 1. When compIdx is 0, it represents the horizontal identifier data, or when compIdx is 1, it represents the vertical identifier data. Therefore, abs_mvd_minus2[0] represents the value obtained by subtracting 2 from the absolute value of the horizontal identifier data. abs_mvd_minus2[1] represents the value obtained by subtracting 2 from the absolute value of the vertical identifier data.
[0163] The statement `if(abs_mvd_greater0_flag[0]) {mvd_sign_flag[0] if(abs_mvd_greater1_flag[0]) abs_mvd_minus2[0]}` indicates that when the absolute value of the horizontal identifier is greater than 0, i.e., when `abs_mvd_greater0_flag[0]` is 1, it is determined whether the horizontal identifier is positive or negative. If the horizontal identifier is positive, 0 is encoded in the bitstream; otherwise, 1 is encoded in the bitstream. Furthermore, when the absolute value of the horizontal identifier is greater than 1, i.e., when `abs_mvd_greater1_flag[0]` is 1, it is determined that the value obtained by subtracting 2 from the absolute value of the horizontal identifier is determined, and the value obtained by subtracting 2 from the absolute value of the horizontal identifier is encoded in the bitstream.
[0164] The meaning of `if(abs_mvd_greater0_flag[1]) {mvd_sign_flag[1] if(abs_mvd_greater1_flag[1]) abs_mvd_minus2[1]}` is the same as the meaning of `if(abs_mvd_greater0_flag[0]) {mvd_sign_flag[0] if(abs_mvd_greater1_flag[0]) abs_mvd_minus2[0]}` above. For detailed information, please refer to the related content above. Further details will not be explained again in this specification.
[0165] For target images containing text content, alignment processing is performed on the text region within the target image based on the target alignment size to obtain the target region. After this, the vertical and horizontal components can be encoded separately based on the target alignment size. When the position vector difference is an integer multiple of the target alignment size, the multiple of the position vector difference relative to the target alignment size is used as position identification data and encoded into the bitstream. The multiple of the position vector difference relative to the target alignment size can accurately represent the position vector difference, and the number of bits required to encode the integer multiple is less than the number of bits required to directly encode the position vector difference of the current block. Therefore, encoding the multiple of the position vector difference relative to the target alignment size as position identification data into the bitstream effectively reduces the number of bits required to encode the position vector difference while ensuring the accuracy of encoding the position vector difference, thereby ensuring relatively high efficiency in encoding images containing text content.
[0166] In this embodiment of the application, if the position vector difference is not an integer multiple of the target alignment size, the quotient obtained by dividing the position vector difference by the target alignment size may also be determined as position identification data, and the remainder obtained by dividing the position vector difference by the target alignment size may be determined as the first flag bit. The position vector difference can be accurately represented by the quotient and remainder obtained by dividing the position vector difference by the target alignment size, and the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference. Therefore, even if the position vector difference is not an integer multiple of the target alignment size, accurate encoding of the position vector can be achieved using a relatively small number of bits, thereby improving the efficiency of encoding images containing text content while ensuring the accuracy of encoding the position vector difference.
[0167] Furthermore, the encoding method provided in this embodiment of the application can be combined with standard video encoding methods without affecting standard video encoding procedures. In other words, the encoding method provided in this embodiment of the application has relatively strong portability and can improve the efficiency of encoding images containing text content without adding further hardware costs.
[0168] Figure 8 is a flowchart of the first decoding method according to an embodiment of this application. The decoding method corresponds to the encoding method shown in Figure 5. Referring to Figure 8, the method includes the following steps.
[0169] Step 801: Analyze the bitstream to obtain position identification data and a first flag bit corresponding to the position vector difference of the current block to be decoded within the target region.
[0170] The position vector difference indicates the difference between the current block's position vector and the reference position vector, the current block's position vector indicates the positional relationship between the current block and the corresponding reference block, the position identification data is either a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data.
[0171] Step 802: Determine the position vector difference based on the target alignment size, position identification data, and the first flag bit.
[0172] In some embodiments, when the edge information includes the target alignment size and the edge information is encoded into a bitstream, the bitstream may be further parsed to obtain the edge information and the target alignment size.
[0173] In some other embodiments, the encoder and decoder store the target alignment size, i.e., the target alignment size is predetermined by the encoder and decoder. In this case, the decoder can directly obtain the target alignment size and does not need to encode the target alignment size into the bitstream, thereby effectively reducing the number of bits in the bitstream, lowering the required decoding time, and effectively improving decoding efficiency.
[0174] In some embodiments, the position vector difference may be determined based on the value of a first flag bit by using the target alignment size and position identification data.
[0175] In some embodiments, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit indicates the category of the horizontal identification data. In this case, if the value of the horizontal flag bit is the first value, the horizontal alignment size is multiplied by the horizontal identification data to obtain the horizontal component. If the value of the horizontal flag bit is the second value, the horizontal identification data is determined to be the horizontal component.
[0176] When the value of the horizontal flag bit is the first value, it indicates that the horizontal identification data is a multiple of the horizontal component relative to the horizontal alignment size. Therefore, to obtain the horizontal component, the horizontal alignment size is multiplied by the horizontal identification data. When the value of the horizontal flag bit is the second value, it indicates that the horizontal identification data is a horizontal component. Therefore, the horizontal identification data may be determined directly as a horizontal component.
[0177] In some other embodiments, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, and the first flag bit includes the vertical flag bit, which indicates the category of the vertical identification data. In this case, if the value of the vertical flag bit is the first value, the vertical alignment size is multiplied by the vertical identification data to obtain the vertical component. If the value of the vertical flag bit is the second value, the vertical identification data is determined to be the vertical component.
[0178] As explained above, when the value of the vertical flag bit is the first value, it indicates that the vertical identification data is a multiple of the vertical component relative to the vertical alignment size. Therefore, to obtain the vertical component, the vertical alignment size is multiplied by the vertical identification data. When the value of the vertical flag bit is the second value, it indicates that the vertical identification data is a vertical component. Therefore, the vertical identification data may be determined directly as a vertical component.
[0179] In one example, both the horizontal and vertical alignment sizes are 16, both the horizontal and vertical flag bits are 1, the horizontal identification data is 1, and the vertical identification data is 4. In this case, the horizontal component is equal to the horizontal identification data multiplied by the horizontal alignment size, i.e., 16. The vertical component is equal to the vertical identification data multiplied by the vertical alignment size, i.e., 64.
[0180] In another example, both the horizontal and vertical alignment sizes are 16, the horizontal flag bit is 0, the vertical flag bit is 1, the horizontal identification data is 17, and the vertical identification data is 4. In this case, the horizontal component is equal to the horizontal identification data, i.e., 17. The vertical component is equal to the vertical identification data multiplied by the vertical alignment size, i.e., 64.
[0181] Based on the above explanation, in the encoding process, if the position vector difference is not an integer multiple of the target alignment size, the quotient obtained by dividing the position vector difference by the target alignment size is determined as the position identification data, and the remainder obtained by dividing the position vector difference by the target alignment size is determined as the value of the first flag bit. Correspondingly, in the decoding process, if the first flag bit is not 0, the position identification data may be multiplied by the target alignment size and then added to the value of the first flag bit in order to obtain the position vector difference.
[0182] Step 803: Reconstruct the current block based on the position vector difference of the current block.
[0183] In some embodiments, the bitstream may be further analyzed to obtain residual information for the current block, which represents the predicted residual between the current block and the reference block. In this case, the current block may be reconstructed based on the position vector difference and the residual information.
[0184] The current block's position vector is determined based on the position vector difference and the associated algorithm. Based on the current block's position vector and residual information, and the associated algorithm, the current block is reconstructed to reconstruct the target region.
[0185] Optionally, when the target nontext region is encoded into a bitstream, the target nontext region may also be reconstructed based on the bitstream to obtain the reconstructed target nontext region.
[0186] Optionally, after the target region has been reconstructed, the target image may also be reconstructed based on the target region and the target non-text region.
[0187] An implementation process for reconstructing a target image based on target regions and target non-text regions includes determining text regions within the target image based on the target regions, and reconstructing the target image based on the text regions and target non-text regions within the target image.
[0188] Optionally, a target region may be recognized by using a text recognition network model to obtain text regions within the target image. In other words, the target region is used as input to a text recognition network model, and the text recognition network model can output text regions within the target region based on the target region. Obviously, in practical applications, the text regions may be reconstructed in other ways, as is not limited to this embodiment of this application.
[0189] Optionally, the edge information further includes the location of text regions within the target image. In this case, regions within the target non-text region that are in the same location as the text region may be replaced with the text region in order to obtain the reconstructed target image. Obviously, in practical applications, the target image may be determined by other means, as is not limited to this embodiment of this application.
[0190] For example, when the position vector difference is MVD, the decoding syntax elements corresponding to the decoding method are shown in Table 2. [Table 2]
[0191] As shown in Table 2, mvd_decoding(x0,y0) indicates that the position vector difference of the current block with coordinates (x0,y0) is decoded.
[0192] The original syntax for abs_mvd_org[0] and abs_mvd_org[1] is abs_mvd_org[compIdx]. abs_mvd_org[compIdx] represents the absolute value of the position vector difference. When the position identification data includes horizontal and vertical identification data, compIdx may be 0 or 1. When compIdx is 0, it represents the horizontal identification data, or when compIdx is 1, it represents the vertical identification data. Therefore, abs_mvd_org[0] represents the absolute value of the horizontal identification data, and abs_mvd_org[1] represents the absolute value of the vertical identification data.
[0193] When the target alignment size includes both horizontal and vertical alignment sizes, `align_shift_x` represents the number of shift bits corresponding to the horizontal alignment size, and `align_shift_y` represents the number of shift bits corresponding to the vertical alignment size. The target alignment size is encoded in the bitstream as edge information, and the number of shift bits corresponding to the target alignment size is related to the target alignment size. Therefore, when the target alignment size is encoded in the bitstream, it can be considered that the number of shift bits of the target alignment size is also encoded in the bitstream. Thus, when the position vector difference is encoded, the number of shift bits corresponding to the target alignment size does not need to be encoded.
[0194] The number of shift bits corresponding to the target alignment size is related to the number of binary bits in the target alignment size. Optionally, the number of shift bits corresponding to the target alignment size is equal to the number of binary bits in the target alignment size minus 1. Obviously, the number of shift bits corresponding to the target alignment size may be determined by other means, but is not limited to this embodiment of this application.
[0195] Other syntax, as shown in Table 2 and similar to that in Table 1, will not be described again in this specification. For details, refer to the relevant content corresponding to Table 1.
[0196] The decryption process shown in Table 2 is described below.
[0197] abs_mvd_greater0_flag[0] and abs_mvd_greater0_flag[1] indicate that the values of abs_mvd_greater0_flag[0] and abs_mvd_greater0_flag[1] are obtained by parsing the bitstream.
[0198] if(abs_mvd_greater0_flag[0]) abs_mvd_greater1_flag[0] indicates that if the value of abs_mvd_greater0_flag[0] is 1, the value of abs_mvd_greater1_flag[0] is obtained by parsing the bitstream, otherwise the horizontal identification data is determined to be 0.
[0199] if(abs_mvd_greater0_flag[1]) abs_mvd_greater1_flag[1] indicates that if the value of abs_mvd_greater0_flag[1] is 1, the value of abs_mvd_greater1_flag[1] is obtained by parsing the bitstream, otherwise the vertical identification data is determined to be 0.
[0200] If (abs_mvd_greater0_flag[0]) mvd_ada_precision_flag[0] is 1, then the value of mvd_ada_precision_flag[0] is obtained by parsing the bitstream; otherwise, the horizontal discrimination data is determined to be 0.
[0201] If (abs_mvd_greater0_flag[1]) mvd_ada_precision_flag[1] is 1, then the value of mvd_ada_precision_flag[1] is obtained by parsing the bitstream; otherwise, the vertical discriminant data is determined to be 0.
[0202] The syntax in rows 12-20 of Table 2 indicates that if the value of abs_mvd_greater0_flag[0] is 1 and the value of abs_mvd_greater1_flag[0] is 1, the value of abs_mvd_minus2[0] is obtained by parsing the bitstream. If mvd_ada_precision_flag[0] is 1, the binary value obtained by adding 2 to abs_mvd_minus2[0] is determined, and the value obtained by left-shifting the binary value by the number of shift bits corresponding to the horizontal alignment size is determined as abs_mvd_org[0]. If mvd_ada_precision_flag[0] is 0, the value obtained by adding 2 to abs_mvd_minus2[0] is determined as abs_mvd_org[0]. The value of mvd_sign_flag[0] is obtained by parsing the bitstream.
[0203] The meaning of the syntax in lines 21-29 of Table 2 is the same as the meaning of the syntax in lines 12-20 of Table 2. For detailed information, please refer to the relevant information above. Further details will not be explained again in this specification.
[0204] When the position identification data includes horizontal identification data and vertical identification data, the value of the position vector difference may be calculated in the decoding process using the following equation (1), based on the decoding syntax shown in Table 2. Mvd[compIdx]=abs_mvd_greater0_flag[compIdx]*abs_mvd_org[compIdx]*(1-2*mvd_sign_flag[compIdx]) (1)
[0205] In equation (1) above, Mvd[compIdx] represents the value of the horizontal component or the vertical component, abs_mvd_greater0_flag[compIdx] represents the value of abs_mvd_greater0_flag[compIdx] obtained by analyzing the bitstream, abs_mvd_org[compIdx] represents the absolute value of the horizontal identification data or the absolute value of the vertical identification data, and mvd_sign_flag[compIdx] represents the value corresponding to mvd_sign_flag[compIdx] obtained by analyzing the bitstream.
[0206] Encoding a multiple of the position vector difference relative to the target alignment size requires fewer bits than encoding the position vector difference of the current block. Therefore, when the first flag bit has a first value, the efficiency of decoding the position identification data is higher than the efficiency of decoding the position vector difference. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy. Furthermore, in the decoding process, if the position vector difference is not an integer multiple of the target alignment size, the quotient obtained by dividing the position vector difference by the target alignment size is determined as the position identification data, and the remainder obtained by dividing the position vector difference by the target alignment size is determined as the value of the first flag bit. Encoding the quotient and remainder obtained by dividing the position vector difference by the target alignment size requires fewer bits than encoding the position vector difference of the current block. Therefore, when the first flag bit does not have a first value, the efficiency of decoding the position identification data is also higher than the efficiency of decoding the position vector difference. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy.
[0207] The decoding method provided in this embodiment of the application can be combined with standard video decoding methods without affecting standard video decoding procedures. In other words, the decoding method provided in this embodiment of the application has relatively high portability and can improve the efficiency of decoding images containing text content without adding further hardware costs.
[0208] Embodiments of this application further provide a second encoding method, which includes the following steps:
[0209] Step 901: The target region is obtained by performing an alignment process on the target image based on the target alignment size.
[0210] For the implementation method for acquiring the target region, refer to the relevant content in the first encoding method described above. Further details will not be explained again in this specification.
[0211] Step 902: Determine the position vector difference of the current block to be encoded within the target region. The position vector difference represents the difference between the position vector of the current block and the reference position vector, and the position vector of the current block represents the positional relationship between the current block and the reference block corresponding to the current block.
[0212] For the implementation method for determining the position vector difference of the current block to be encoded within the target region, refer to the relevant content in the first encoding method described above. Further details will not be explained again in this specification.
[0213] Step 903: Based on the target alignment size and the position vector difference of the current block, determine the position identification data and the first flag bit corresponding to the position vector difference, where the position identification data is either a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data.
[0214] In some embodiments, the position identification data and the value of the first flag bit may be determined based on the target alignment size and the position vector difference.
[0215] In some embodiments, the target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. In this case, a multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, and a multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data, with the first value determined as the value of the first flag bit.
[0216] Furthermore, if the horizontal component is an integer multiple of the horizontal alignment size and the vertical component is an integer multiple of the vertical alignment size, the multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, and the multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data, and the first value is determined as the value of the first flag bit.
[0217] When the horizontal component is an integer multiple of the horizontal alignment size and the vertical component is an integer multiple of the vertical alignment size, the multiple of the horizontal component relative to the horizontal alignment size can accurately represent the horizontal component, and the multiple of the vertical component relative to the vertical alignment size can accurately represent the vertical component. Therefore, the multiple of the horizontal component relative to the horizontal alignment size can be determined as horizontal identification data, and the multiple of the vertical component relative to the vertical alignment size can be determined as vertical identification data. In this way, the horizontal and vertical components can be accurately encoded into a bitstream, and the accuracy of encoding and decoding the horizontal and vertical components is ensured.
[0218] Furthermore, if the horizontal component is not an integer multiple of the horizontal alignment size, and / or the vertical component is not an integer multiple of the vertical alignment size, the horizontal component is determined as the horizontal identification data, the vertical component is determined as the vertical identification data, and the second value is determined as the value of the first flag bit.
[0219] When the horizontal component is not an integer multiple of the horizontal alignment size, and / or when the vertical component is not an integer multiple of the vertical alignment size, the multiple of the horizontal component relative to the horizontal alignment size cannot accurately represent the horizontal component, and / or the multiple of the vertical component relative to the vertical alignment size cannot accurately represent the vertical component. Therefore, the horizontal component can be directly determined as horizontal identification data, and the vertical component can be determined as vertical identification data, thereby avoiding the horizontal component encoding error caused by encoding the multiple of the horizontal component relative to the horizontal alignment size into a bitstream, and / or the vertical component encoding error caused by encoding the multiple of the vertical component relative to the vertical alignment size into a bitstream, and thereby ensuring the accuracy of encoding and decoding the horizontal and vertical components.
[0220] The first and second values are predetermined, and the first value is different from the second value. For example, the first value may be 1 and the second value may be 0. Furthermore, if they are different, further adjustments may be made based on different requirements.
[0221] In one example, the first value is 1, the second value is 0, both the horizontal and vertical alignment sizes are 16, the horizontal component is 16, and the vertical component is 64. For the horizontal component, 16 ÷ 16 = 1, and for the vertical component, 64 ÷ 16 = 4. In other words, the horizontal component is an integer multiple of the horizontal alignment size, and the vertical component is an integer multiple of the vertical alignment size. Therefore, the horizontal identification data is 1, the vertical identification data is 4, and the value of the first flag bit is 1.
[0222] In one example, the first value is 1, the second value is 0, both the horizontal and vertical alignment sizes are 16, the horizontal component is 17, and the vertical component is 64. For the horizontal component, 17 ÷ 16 = 1.0625, and for the vertical component, 64 ÷ 16 = 4. In other words, the horizontal component is not an integer multiple of the horizontal alignment size. Therefore, the horizontal identification data is 17, the vertical identification data is 64, and the value of the first flag bit is 0.
[0223] If the horizontal component is not an integer multiple of the horizontal alignment size, and / or the vertical component is not an integer multiple of the vertical alignment size, in addition to directly determining the horizontal component as horizontal identification data and the vertical component as vertical identification data, the quotient obtained by dividing the horizontal component by the horizontal alignment size may also be determined as horizontal identification data. The quotient and remainder obtained by dividing the vertical component by the vertical alignment size are determined as vertical identification data, and the second value is determined as the value of the first flag bit. In this case, the first flag bit is used to distinguish between two different methods for determining the position identification data.
[0224] The position vector difference can be accurately represented by the quotient and remainder obtained by dividing the position vector difference by the target alignment size, and the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference. Therefore, even when the position vector difference is not an integer multiple of the target alignment size, accurate encoding of the position vector can be achieved using a relatively small number of bits, thereby improving the efficiency of encoding images containing text content while ensuring the accuracy of encoding the position vector difference. Obviously, when the horizontal component is not an integer multiple of the horizontal alignment size, and / or when the vertical component is not an integer multiple of the vertical alignment size, the position identification data and the first flag bit may be determined by other means as an alternative. This is not limited to this embodiment of the application.
[0225] Step 904: Encode the position identification data corresponding to the position vector difference and the first flag bit into a bitstream.
[0226] For an implementation method for encoding the position identification data corresponding to the position vector difference and the first flag bit into a bitstream, refer to the relevant content in the first encoding method described above. Details will not be explained again in this specification.
[0227] For example, when the position vector difference is MVD, the coding syntax elements corresponding to the second coding method are shown in Table 3. [Table 3]
[0228] In Table 3 above, mvd_ada_precision_flag indicates whether the first flag bit is equal to 1 or not. mvd_ada_precision_flag may be 1 or 0. If the first flag bit is equal to 1, mvd_ada_precision_flag is 1 and 1 is encoded in the bitstream; otherwise, mvd_ada_precision_flag is 0 and 0 is encoded in the bitstream.
[0229] If (abs_mvd_greater0_flag[0]||abs_mvd_greater0_flag[1]) mvd_ada_precision_flag is defined as being equal to 1 when the absolute value of the horizontal discriminant data is greater than 0 and the absolute values of the vertical and horizontal discriminant data are greater than 0, i.e., when abs_mvd_greater0_flag[0] is 1 and abs_mvd_greater0_flag[1] is 1, then it is determined whether the first flag bit is equal to 1. If the first flag bit is equal to 1, then mvd_ada_precision_flag is 1 and 1 is encoded in the bitstream; otherwise, mvd_ada_precision_flag is 0 and 0 is encoded in the bitstream.
[0230] Other syntaxes listed in Table 3 that are similar to those in Table 1 are not described again in this specification. For details, refer to the relevant content corresponding to Table 1.
[0231] For target images containing text content, after alignment processing is performed on the target image based on the target alignment size to obtain the target region, if the vertical component is an integer multiple of the vertical alignment size and the horizontal component is an integer multiple of the horizontal alignment size, the corresponding integer multiples of the horizontal and vertical components are used as position identification data and encoded into a bitstream. Multiples of the position vector difference relative to the target alignment size can accurately represent the position vector difference, and the number of bits required to encode multiples of the position vector difference relative to the target alignment size is less than the number of bits required to directly encode the position vector difference of the current block. Therefore, encoding position identification data corresponding to the position vector difference into a bitstream effectively reduces the number of bits required to encode the position vector difference while ensuring the accuracy of encoding the position vector difference, thereby ensuring relatively high efficiency in encoding images containing text content.
[0232] In this embodiment of the application, if the horizontal component is not an integer multiple of the horizontal alignment size, and / or if the vertical component is not an integer multiple of the vertical alignment size, the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size may also be determined as horizontal identification data. The quotient and remainder obtained by dividing the vertical component by the vertical alignment size are determined as vertical identification data, and the second value is determined as the value of the first flag bit. The position vector difference can be accurately represented by the quotient and remainder obtained by dividing the position vector difference by the target alignment size, and the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference. Therefore, even when the position vector difference is not an integer multiple of the target alignment size, accurate encoding of the position vector can be achieved using a relatively small number of bits, thereby improving the efficiency of encoding images containing text content while ensuring the accuracy of encoding the position vector difference.
[0233] Furthermore, the encoding method provided in this embodiment of the application can be combined with standard video encoding methods without affecting standard video encoding procedures. In other words, the encoding method provided in this embodiment of the application has relatively strong portability and can improve the efficiency of encoding images containing text content without adding further hardware costs.
[0234] Embodiments of this application further provide a second decoding method, which corresponds to the second encoding method described above. The method includes the following steps:
[0235] Step 1001: Analyze the bitstream to obtain position identification data and a first flag bit corresponding to the position vector difference of the current block to be decoded within the target region.
[0236] The position vector difference indicates the difference between the current block's position vector and the reference position vector, the current block's position vector indicates the positional relationship between the current block and the corresponding reference block, the position identification data is either a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data.
[0237] Step 1002: Determine the position vector difference of the current block based on the target alignment size, position identification data, and the first flag bit.
[0238] Optionally, the position vector difference may be determined based on the value of the first flag bit by using the target alignment size and position identification data.
[0239] In some embodiments, the target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. In this case, if the value of the first flag bit is a first value, the horizontal alignment size is multiplied by the horizontal identification data to obtain the horizontal component, and the vertical alignment size is multiplied by the vertical identification data to obtain the vertical component. If the value of the first flag bit is a second value, the horizontal identification data is determined as the horizontal component, and the vertical identification data is determined as the vertical component.
[0240] When the value of the first flag bit is the first value, this indicates that the position identification data is a multiple of the position vector difference relative to the target alignment size. Therefore, to obtain the horizontal component, the horizontal alignment size is multiplied by the horizontal identification data, and to obtain the vertical component, the vertical alignment size is multiplied by the vertical identification data. When the value of the first flag bit is the second value, this indicates that the position identification data is the position vector difference. Therefore, the horizontal identification data may be determined directly as the horizontal component, and the vertical identification data may be determined directly as the vertical component.
[0241] In one example, both the horizontal and vertical alignment sizes are 16, the horizontal identification data is 1, the vertical identification data is 4, and the value of the first flag bit is the first value, 1. In this case, the horizontal component is the horizontal identification data multiplied by the horizontal alignment size, i.e., 16. The vertical component is the vertical identification data multiplied by the vertical alignment size, i.e., 64.
[0242] In another example, both the horizontal and vertical alignment sizes are 16, the horizontal identification data is 17, the vertical identification data is 64, and the value of the first flag bit is the first value 0. In this case, the horizontal component is the horizontal identification data, i.e., 17. The vertical component is the vertical identification data, i.e., 64.
[0243] Based on the above description, in the encoding process, if the horizontal component is not an integer multiple of the horizontal alignment size and / or the vertical component is not an integer multiple of the vertical alignment size, the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size are determined as the horizontal identifier data, and the quotient and remainder obtained by dividing the vertical component by the vertical alignment size are determined as the vertical identifier data, and the second value is determined as the value of the first flag bit. Correspondingly, in the decoding process, if the first flag bit is the second value, in order to obtain the horizontal component, the quotient in the horizontal identifier data may be multiplied by the horizontal alignment size and then added to the remainder, and in order to obtain the vertical component, the quotient in the vertical identifier data may be multiplied by the vertical alignment size and then added to the remainder.
[0244] Step 1003: Reconstruct the current block based on the position vector difference.
[0245] For the implementation method for reconstructing the blocks, refer to the relevant content in the first encoding method. Further details will not be described again in this specification.
[0246] For example, when the position vector difference is MVD, the decoding syntax elements corresponding to the decoding method are shown in Table 4. [Table 4]
[0247] The syntax in Table 4 is the same as that in Tables 1 to 3, and will not be described again in this specification. For detailed information, please refer to the relevant content corresponding to Tables 1 to 3.
[0248] After the values of abs_mvd_greater0_flag[compIdx], abs_mvd_org[compIdx], and mvd_sign_flag[compIdx] are obtained, the position vector difference value may be calculated using the above equation (1).
[0249] Encoding a multiple of the position vector difference relative to the target alignment size requires fewer bits than encoding the position vector difference of the current block. Therefore, when the value of the first flag bit is the first value, the efficiency of decoding the position identification data is higher than the efficiency of decoding the position vector difference. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy. Furthermore, in the encoding process, if the horizontal component is not an integer multiple of the horizontal alignment size, and / or the vertical component is not an integer multiple of the vertical alignment size, the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size are determined as the horizontal identification data, and the quotient and remainder obtained by dividing the vertical component by the vertical alignment size are determined as the vertical identification data, and the second value is determined as the value of the first flag bit. Since the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference, when the first flag bit is the second value, the efficiency of decoding the position identification data is also higher than the efficiency of decoding the position vector difference. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy.
[0250] Furthermore, the decoding method provided in this embodiment of the application can be combined with standard video decoding methods without affecting standard video decoding procedures. In other words, the decoding method provided in this embodiment of the application has relatively high portability and can improve the efficiency of decoding images containing text content without adding further hardware costs.
[0251] Embodiments of this application further provide a third encoding method, which includes the following steps:
[0252] Step 1101: The target region is obtained by performing an alignment process on the target image based on the target alignment size.
[0253] For the implementation method for acquiring the target region, refer to the relevant content in the first encoding method described above. Further details will not be explained again in this specification.
[0254] Step 1102: Determine the position vector difference of the current block to be encoded within the target region. The position vector difference represents the difference between the position vector of the current block and the reference position vector, and the position vector of the current block represents the positional relationship between the current block and the reference block corresponding to the current block.
[0255] For the implementation method for determining the position vector difference of the current block to be encoded within the target region, refer to the relevant content in the first encoding method described above. Further details will not be explained again in this specification.
[0256] Step 1103: Based on the target alignment size and the position vector difference of the current block, determine the position identification data and the first flag bit corresponding to the position vector difference, where the position identification data is either a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data.
[0257] In some embodiments, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, and the first flag bit includes the horizontal flag bit, which is further used in combination with the horizontal identification data to indicate the horizontal component. In this case, the quotient obtained by dividing the horizontal component by the horizontal alignment size is determined as the horizontal identification data, and the remainder obtained by dividing the horizontal component by the horizontal alignment size is determined as the value of the horizontal flag bit.
[0258] The quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size can accurately represent the horizontal component. Therefore, the quotient obtained by dividing the horizontal component by the horizontal alignment size can be determined as horizontal identification data, and the remainder obtained by dividing the horizontal component by the horizontal alignment size can be determined as the value of the horizontal flag bit. In this way, the horizontal component can be accurately encoded into the bitstream, and the accuracy of encoding and decoding the horizontal component is ensured.
[0259] In some embodiments, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, and the first flag bit includes the vertical flag bit, which is further used in combination with the vertical identification data to indicate the vertical component. In this case, the quotient obtained by dividing the vertical component by the vertical alignment size is determined as the vertical identification data, and the remainder obtained by dividing the vertical component by the vertical alignment size is determined as the value of the vertical flag bit.
[0260] The quotient and remainder obtained by dividing the vertical component by the vertical alignment size can accurately represent the vertical component. Therefore, the quotient obtained by dividing the vertical component by the vertical alignment size can be determined as vertical identification data, and the remainder obtained by dividing the vertical component by the vertical alignment size can be determined as the value of the vertical flag bit. In this way, the vertical component can be accurately encoded into the bitstream, and the accuracy of encoding and decoding the vertical component is ensured.
[0261] In one example, both the horizontal and vertical alignment sizes are 16, the horizontal component is 16, and the vertical component is 64. For the horizontal component, 16 ÷ 16 = 1. In other words, the quotient obtained by dividing the horizontal component by the horizontal alignment size is 1, and the remainder is 0. For the vertical component, 64 ÷ 16 = 4. In other words, the quotient obtained by dividing the vertical component by the vertical alignment size is 4, and the remainder is 0.
[0262] In another example, the first value is 1, the second value is 0, both the horizontal and vertical alignment sizes are 16, the horizontal component is 17, and the vertical component is 64. For the horizontal component, 17 ÷ 16 = 1...1. In other words, the quotient obtained by dividing the horizontal component by the horizontal alignment size is 1, and the remainder is 1. For the vertical component, 64 ÷ 16 = 4. In other words, the quotient obtained by dividing the vertical component by the vertical alignment size is 4, and the remainder is 0.
[0263] Step 1104: Encode the position identification data corresponding to the position vector difference and the first flag bit into a bitstream.
[0264] For an implementation method for encoding the position identification data corresponding to the position vector difference and the first flag bit into a bitstream, refer to the relevant content in the first encoding method described above. Details will not be explained again in this specification.
[0265] For example, when the position vector difference is MVD, the coding syntax elements corresponding to the third coding method are shown in Table 5. [Table 5]
[0266] In Table 5 above, the original syntax for abs_mvd_mul_minus2[0] and abs_mvd_mul_minus2[1] is abs_mvd_mul_minus2[compIdx]. abs_mvd_mul_minus2[compIdx] represents the value obtained by subtracting 2 from the absolute value of the quotient contained in the location identification data; that is, the value obtained by subtracting 2 from the absolute value of the quotient contained in the location identification data is encoded in the bitstream. When the location identification data includes horizontal identification data and vertical identification data, compIdx may be 0 or 1. When compIdx is 0, it represents horizontal identification data, or when compIdx is 1, it represents vertical identification data. Therefore, abs_mvd_mul_minus2[0] represents the value obtained by subtracting 2 from the absolute value of the quotient contained in the horizontal identification data. abs_mvd_mul_minus2[1] represents the value obtained by subtracting 2 from the absolute value of the quotient contained in the vertical identification data.
[0267] The original syntax for abs_mvd_rem[0] and abs_mvd_rem[1] is abs_mvd_rem[compIdx]. abs_mvd_rem[compIdx] represents the remainder included in the location-identifier data, and this remainder is encoded into the bitstream. When the location-identifier data includes both horizontal and vertical identifier data, compIdx can be 0 or 1. When compIdx is 0, it represents the horizontal identifier data, or when compIdx is 1, it represents the vertical identifier data. Therefore, abs_mvd_rem[0] represents the remainder included in the horizontal identifier data, and abs_mvd_rem[1] represents the remainder included in the vertical identifier data.
[0268] Other syntaxes listed in Table 5 that are similar to those in Table 1 are not described again in this specification. For details, refer to the relevant content corresponding to Table 1.
[0269] For target images containing text content, after alignment processing is performed on the target image based on the target alignment size to obtain the target region, the quotient and remainder obtained by dividing the position vector difference by the target alignment size are directly determined as position identification data and the first flag bit, respectively. The quotient and remainder obtained by dividing the position vector difference by the target alignment size can accurately represent the position vector difference, and the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference of the current block. Therefore, encoding the quotient and remainder obtained by dividing the position vector difference by the target alignment size into a bitstream effectively reduces the number of bits required to encode the position vector difference while ensuring the accuracy of encoding the position vector difference, thereby ensuring relatively high efficiency in encoding images containing text content.
[0270] Furthermore, the encoding method provided in this embodiment of the application can be combined with standard video encoding methods without affecting standard video encoding procedures. In other words, the encoding method provided in this embodiment of the application has relatively strong portability and can improve the efficiency of encoding images containing text content without adding further hardware costs.
[0271] Embodiments of this application further provide a third decoding method, which corresponds to the third encoding method described above. The method includes the following steps:
[0272] Step 1201: Analyze the bitstream to obtain position identification data and a first flag bit corresponding to the position vector difference of the current block to be decoded within the target region.
[0273] The position vector difference indicates the difference between the current block's position vector and the reference position vector, the current block's position vector indicates the positional relationship between the current block and the corresponding reference block, the position identification data is either a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data.
[0274] Step 1202: Determine the position vector difference based on the target alignment size, position identification data corresponding to the position vector difference, and the first flag bit.
[0275] In some embodiments, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, and the first flag bit includes the horizontal flag bit, which is further used in combination with the horizontal identification data to indicate the horizontal component. In this case, to obtain the horizontal component, the quotient contained in the horizontal identification data is multiplied by the horizontal alignment size and then added to the value of the horizontal flag bit.
[0276] In some other embodiments, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, and the first flag bit includes the vertical flag bit, which is further used in combination with the vertical identification data to indicate the vertical component. In this case, to obtain the vertical component, the quotient contained in the vertical identification data is multiplied by the vertical alignment size and then added to the value of the vertical flag bit.
[0277] Step 1203: Reconstruct the current block based on the position vector difference.
[0278] For the implementation method for reconstructing the blocks, refer to the relevant content in the first encoding method. Further details will not be described again in this specification.
[0279] In one example, when the position vector difference is the MVD, the decoding syntax element corresponding to the above decoding method is as shown in Table 6. [Table 6]
[0280] The syntax in Table 6 is the same as the syntax in Tables 1, 2 and 5, and will not be described again in this specification. For detailed content, refer to the relevant content corresponding to Tables 1, 2 and 5.
[0281] After the values of abs_mvd_greater0_flag[compIdx], abs_mvd_org[compIdx] and mvd_sign_flag[compIdx] are obtained, the value of the position vector difference may be calculated by using the above formula (1).
[0282] The position identification data and the first flag bit corresponding to the position vector are the quotient and remainder obtained by dividing the position vector difference by the target alignment size. Since the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference of the current block, in the decoding process, the efficiency of decoding the position identification data and the first flag bit corresponding to the position vector difference is higher than the efficiency of decoding the position vector difference. In this way, while ensuring the decoding accuracy, the efficiency of decoding an image including text content can be improved.
[0283] Furthermore, the decoding method provided in this embodiment of this application can be combined with a standard video decoding method without affecting the standard video decoding procedure. In other words, the decoding method provided in this embodiment of this application has relatively high portability and can improve the efficiency of decoding an image including text content without adding further hardware costs.
[0284] Embodiments of this application further provide a fourth encoding method, which includes the following steps:
[0285] Step 1301: The target region is obtained by performing an alignment process on the target image based on the target alignment size.
[0286] For the implementation method for acquiring the target region, refer to the relevant content in the first encoding method described above. Further details will not be explained again in this specification.
[0287] Step 1302: Determine the position vector difference of the current block to be encoded within the target region. The position vector difference represents the difference between the position vector of the current block and the reference position vector, and the position vector of the current block represents the positional relationship between the current block and the reference block corresponding to the current block.
[0288] In some embodiments, a first candidate position vector difference and a second candidate position vector difference of the current block are determined, the first candidate position vector difference being determined based on a first pixel precision, and the second candidate position vector difference being determined based on a second pixel precision, where the first pixel precision is an integer and the second pixel precision is a multiple of the target alignment size. The rate distortion cost of the first candidate position vector difference and the rate distortion cost of the second candidate position vector difference are determined, and the candidate position vector difference having the smaller rate distortion cost among the first and second candidate position vector differences is determined as the position vector difference of the current block.
[0289] In some embodiments, based on the current block to be encoded in the target region, a first position vector and a second position vector are determined based on a relevant algorithm using a first pixel precision and a second pixel precision, respectively, wherein the first position vector is the relative displacement between the current block and a first reference block, the first reference block being a reference block determined based on a first pixel precision and corresponding to the current block, and the second position vector is the relative displacement between the current block and a second reference block, the second reference block being a reference block determined based on a second pixel precision and corresponding to the current block.
[0290] A first reference position vector corresponding to a first position vector is determined based on the first position vector and an associated predictive coding algorithm. The value obtained by subtracting the first reference position vector from the first position vector is determined as the first candidate position vector difference, and the first reference position vector is determined based on a first pixel precision. A second reference position vector corresponding to a second position vector is determined based on the second position vector and an associated predictive coding algorithm. The value obtained by subtracting the second reference position vector from the second position vector is determined as the second candidate position vector difference, and the second reference position vector is determined based on a second pixel precision.
[0291] The rate distortion cost of the first candidate position vector difference is determined based on the first candidate position vector difference and the associated algorithm. The rate distortion cost of the second candidate position vector difference is determined based on the second candidate position vector difference and the associated algorithm.
[0292] In some embodiments, the first and second position vectors may be determined based on a motion search algorithm. Clearly, the first and second position vectors may, alternatively, be determined based on other algorithms. This is not limited to these embodiments of the application.
[0293] Based on the above explanation, the encoder finds the reference block corresponding to the current block from the encoded reference image by using a motion search algorithm. Since the encoded reference image contains multiple coding units (i.e., multiple blocks), the encoder can determine the reference block corresponding to the current block from among the multiple blocks based on a specific pixel precision. For example, the second pixel precision is 16, and the coordinates of the current block are (50,21). In this case, the second reference block is determined by using a motion search algorithm based on the coordinates of the current block and using the second pixel precision (i.e., 16) as a step, and the relative displacement between the current block and the second reference block is determined as the second position vector. Since the second reference block is obtained by using 16 steps through a search based on the coordinates of the current block, the relative displacement between the current block and the second reference block is obviously a multiple of the second pixel precision. In other words, the second position vector is obviously a multiple of the second pixel precision. Similarly, the second reference position vector is also determined based on the second pixel precision, and the second reference position vector is also a multiple of the second pixel precision. Therefore, the difference of the second candidate position vector is also a multiple of the second pixel precision.
[0294] It should be noted that the second pixel precision may include horizontal pixel precision and vertical pixel precision. In this case, the horizontal pixel precision is a multiple of the target alignment size, and the vertical pixel precision is also a multiple of the target alignment size. The horizontal pixel precision and vertical pixel precision may be the same or different. This is not limited to this embodiment of the application. When the second pixel precision includes horizontal pixel precision and vertical pixel precision, in the process of determining the second reference block corresponding to the current block, the second reference block is determined based on the coordinates of the current block by using a motion search algorithm, by using horizontal pixel precision as the horizontal step and vertical pixel precision as the vertical step.
[0295] Step 1303: Based on the target alignment size and the position vector difference of the current block, determine the position identification data and the first flag bit corresponding to the position vector difference, where the position identification data is either a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data.
[0296] In some embodiments, the position identification data and the value of the first flag bit may be determined based on the target alignment size and the position vector difference.
[0297] In some embodiments, the target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. If the current block's position vector difference is a second candidate position vector difference, a multiple of the horizontal component to the horizontal alignment size is determined as the horizontal identification data, a multiple of the vertical component to the vertical alignment size is determined as the vertical identification data, and the first value is determined as the value of the first flag bit.
[0298] If the current block position vector difference is the first candidate position vector difference, the horizontal component is determined as the horizontal identification data, the vertical component is determined as the vertical identification data, and the second value is determined as the value of the first flag bit.
[0299] Based on the above explanation, the difference of the second candidate position vector is a multiple of the second pixel precision, and the second pixel precision is a multiple of the target alignment size. Based on this, the difference of the second candidate position vector is clearly a multiple of the target alignment size. A multiple of the horizontal component relative to the horizontal alignment size can accurately represent the horizontal component, and a multiple of the vertical component relative to the vertical alignment size can accurately represent the vertical component. Therefore, when the position vector difference of the current block is the difference of the second candidate position vector, a multiple of the horizontal component relative to the horizontal alignment size may be directly determined as horizontal identification data, and a multiple of the vertical component relative to the vertical alignment size may be determined as vertical identification data. In this way, the horizontal and vertical components can be accurately encoded in the bitstream, thereby ensuring the accuracy of encoding and decoding the horizontal and vertical components.
[0300] When the current block position vector difference is the first candidate position vector difference, it cannot be determined that the second candidate position vector difference is clearly a multiple of the target alignment size. Therefore, the horizontal component is determined as horizontal identification data, the vertical component is determined as vertical identification data, and the second value is determined as the value of the first flag bit, thereby avoiding horizontal component encoding errors caused by encoding multiples of the horizontal component relative to the horizontal alignment size into a bitstream, and vertical component encoding errors caused by encoding multiples of the vertical component relative to the vertical alignment size into a bitstream, and thereby ensuring the accuracy of encoding and decoding the horizontal and vertical components.
[0301] The first and second values are predetermined, and the first value is different from the second value. For example, the first value may be 1 and the second value may be 0. Furthermore, if they are different, further adjustments may be made based on different requirements.
[0302] When the position vector difference of the current block is the first candidate position vector difference, in addition to directly determining the horizontal component as horizontal identification data and determining the vertical component as vertical identification data, the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size may also be determined as horizontal identification data. It should be noted that the quotient and remainder obtained by dividing the vertical component by the vertical alignment size are determined as vertical identification data, and the second value is determined as the value of the first flag bit. In this case, the first flag bit is used to distinguish between two different methods of determining the position identification data.
[0303] The position vector difference can be accurately represented by the quotient and remainder obtained by dividing the position vector difference by the target alignment size, and the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference. Therefore, even when it cannot be determined whether the position vector difference is an integer multiple of the target alignment size, accurate encoding of the position vector can be achieved by using a relatively small number of bits, thereby ensuring the accuracy of encoding the position vector difference and improving the efficiency of encoding an image including text content. Obviously, when the position vector difference of the current block is the first candidate position vector difference, the position identification data and the first flag bit may alternatively be determined in other ways. This is not limited in this embodiment of this application.
[0304] Step 1304: Encode the position identification data and the first flag bit corresponding to the position vector difference into the bit stream.
[0305] For the implementation method of encoding the position identification data and the first flag bit corresponding to the position vector difference into the bit stream, refer to the related content in the above first encoding method.
[0306] For example, when the position vector difference is MVD, during encoding, ammvd_flag may indicate whether the first flag bit is equal to 1 or not. ammvd_flag may be 1 or 0. If the first flag bit is equal to 1, ammvd_flag is 1 and 1 is encoded in the bitstream; otherwise, ammvd_flag is 0 and 0 is encoded in the bitstream.
[0307] For target images containing text content, after alignment processing is performed on the target image based on the target alignment size to obtain the target region, if the position vector difference of the current block is the second candidate position vector difference, a multiple of the position vector difference relative to the target alignment size is used as position identification data and encoded into a bitstream. The position vector difference of the current block is also a multiple of the target alignment size, and this multiple of the position vector difference relative to the target alignment size can accurately represent the position vector difference. The number of bits required to encode this multiple of the position vector difference relative to the target alignment size is less than the number of bits required to directly encode the position vector difference of the current block. Therefore, encoding a multiple of the position vector difference relative to the target alignment size into a bitstream effectively reduces the number of bits required to encode the position vector difference while ensuring the accuracy of encoding the position vector difference, thereby ensuring relatively high efficiency in encoding images containing text content.
[0308] In this embodiment of the application, if the current block position vector difference is the first candidate position vector difference, the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size may also be determined as horizontal identification data, and the quotient and remainder obtained by dividing the vertical component by the vertical alignment size may also be determined as vertical identification data, and the second value may be determined as the value of the first flag bit. The position vector difference can be accurately represented by the quotient and remainder obtained by dividing the position vector difference by the target alignment size, and the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference. Therefore, even when it cannot be determined whether the position vector difference is an integer multiple of the target alignment size, accurate encoding of the position vector can be achieved by using a relatively small number of bits, thereby improving the efficiency of encoding images including text content while ensuring the accuracy of encoding the position vector difference.
[0309] Furthermore, the encoding method provided in this embodiment of the application can be combined with standard video encoding methods without affecting standard video encoding procedures. In other words, the encoding method provided in this embodiment of the application has relatively strong portability and can improve the efficiency of encoding images containing text content without adding further hardware costs.
[0310] Embodiments of this application further provide a fourth decoding method, which corresponds to the fourth encoding method described above. The method includes the following steps:
[0311] Step 1401: Analyze the bitstream to obtain position identification data and a first flag bit corresponding to the position vector difference of the current block to be decoded within the target region.
[0312] The position vector difference indicates the difference between the current block's position vector and the reference position vector, the current block's position vector indicates the positional relationship between the current block and the corresponding reference block, the position identification data is either a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data.
[0313] Step 1402: Determine the position vector difference based on the target alignment size, position identification data corresponding to the position vector difference, and the first flag bit.
[0314] In some embodiments, the position vector difference may be determined based on the value of a first flag bit by using the target alignment size and one identification data.
[0315] In some embodiments, the target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. In this case, if the value of the first flag bit is a first value, the horizontal alignment size is multiplied by the horizontal identification data to obtain the horizontal component, and the vertical alignment size is multiplied by the vertical identification data to obtain the vertical component. If the value of the first flag bit is a second value, the horizontal identification data is determined as the horizontal component, and the vertical identification data is determined as the vertical component.
[0316] If the value of the first flag bit is the first value, this indicates that the current block position vector difference is a multiple of the target alignment size. Therefore, to obtain the horizontal component, the horizontal alignment size is multiplied by the horizontal identification data, and to obtain the vertical component, the vertical alignment size is multiplied by the vertical identification data. If the value of the first flag bit is the second value, this indicates that the current block position vector difference is not necessarily a multiple of the target alignment size. Therefore, the horizontal identification data may be determined as the horizontal component, and the vertical identification data may be determined as the vertical component.
[0317] Based on the above explanation, in the encoding process, if the current block position vector difference is the first candidate position vector difference, the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size are determined as the horizontal identification data, and the quotient and remainder obtained by dividing the vertical component by the vertical alignment size are determined as the vertical identification data, and the second value is determined as the value of the first flag bit. Correspondingly, in the decoding process, if the first flag bit is the second value, in order to obtain the horizontal component, the quotient in the horizontal identification data may be multiplied by the horizontal alignment size and then added to the remainder, and in order to obtain the vertical component, the quotient in the vertical identification data may be multiplied by the vertical alignment size and then added to the remainder.
[0318] Step 1403: Reconstruct the current block based on the position vector difference.
[0319] For the implementation method for reconstructing the blocks, refer to the relevant content in the first encoding method. Further details will not be described again in this specification.
[0320] In one example, when the position vector difference is MVD, after the position identification data and the first flag bit have been obtained through decoding, the number of shift bits corresponding to the target alignment size may be determined based on the first flag bit, and the value obtained by left-shifting the binary of the position identification data by the number of shift bits corresponding to the target alignment size is determined as the position vector difference. In other words, the binary of the position identification data is left-shifted so that the position identification data is either multiplied by the target alignment size to obtain the position vector difference, or the position identification data is used directly as the position vector difference.
[0321] If the first flag bit has a first value, the number of shift bits corresponding to the target alignment size is the number of shift bits corresponding to the target alignment size at the second pixel precision. If the first flag bit has a second value, the number of shift bits corresponding to the target alignment size is the number of shift bits corresponding to the target alignment size at the first pixel precision.
[0322] If the position vector difference includes horizontal and vertical components, the position identification data includes horizontal and vertical identification data, and the target alignment size includes horizontal and vertical alignment sizes, the value obtained by left-shifting the binary horizontal identification data by the number of shift bits corresponding to the horizontal alignment size is determined as the horizontal component, and the value obtained by left-shifting the binary vertical identification data by the number of shift bits corresponding to the vertical alignment size is determined as the vertical component.
[0323] For example, if the ammvd_flag obtained by parsing the bitstream is 1, the first flag bit is equal to 1, meaning the first flag is determined to be the first value. If the ammvd_flag obtained by parsing the bitstream is 0, the first flag bit is not equal to 1, meaning the first flag is determined to be the second value.
[0324] For example, AmmbdShift[compIdx] may represent the number of shift bits corresponding to the target alignment size in the first and second pixel precisions. The number of shift bits corresponding to the target alignment size in the first pixel precision is 0, and the number of shift bits corresponding to the target alignment size in the second pixel precision is related to the number of binary bits in the target alignment size. When the target alignment size includes both a horizontal and a vertical alignment size, compIdx may be 0 or 1. When compIdx is 0, it represents the horizontal alignment size, or when compIdx is 1, it represents the vertical alignment size.
[0325] Optionally, the number of shift bits corresponding to the target alignment size in the second pixel precision is equal to the number of binary bits of the target alignment size minus 1. For example, if the target alignment size is 8, the number of shift bits corresponding to the target alignment size in the second pixel precision is 3. If the target alignment size is 16, the number of shift bits corresponding to the target alignment size in the second pixel precision is 4. If the target alignment size is 32, the number of shift bits corresponding to the target alignment size in the second pixel precision is 5. If the target alignment size is 64, the number of shift bits corresponding to the target alignment size in the second pixel precision is 6. Obviously, the number of shift bits corresponding to the target alignment size may be determined by other means, but is not limited to this embodiment of this application.
[0326] In practical applications, the encoding and decoding methods provided in this application need to allow the use of adaptive multiple integer pixel precision MVD (AMMVD) technology. In this case, sps_ammvd_enabled_flag may be used to identify whether the encoding and decoding network allows the use of AMMVD technology. 1 indicates that the use of AMMVD technology is permitted, and 0 indicates that the use of AMMVD technology is not permitted. When the use of AMMVD technology is permitted, the fourth encoding and decoding methods may be used for encoding and decoding.
[0327] Encoding a multiple of the position vector difference relative to the target alignment size requires fewer bits than encoding the position vector difference of the current block. Therefore, when the value of the first flag bit is the first value, the efficiency of decoding the position identification data is higher than the efficiency of decoding the position vector difference. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy. Furthermore, in the encoding process, when the position vector difference of the current block is the first candidate position vector difference, the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size are determined as the horizontal identification data. The quotient and remainder obtained by dividing the vertical component by the vertical alignment size are determined as the vertical identification data, and the second value is determined as the value of the first flag bit. Since the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference, when the first flag bit is the second value, the efficiency of decoding the position identification data is also higher than the efficiency of decoding the position vector difference. In this way, the efficiency of decoding images containing text content can be improved while ensuring decoding accuracy.
[0328] Furthermore, the decoding method provided in this embodiment of the application can be combined with standard video decoding methods without affecting standard video decoding procedures. In other words, the decoding method provided in this embodiment of the application has relatively high portability and can improve the efficiency of decoding images containing text content without adding further hardware costs.
[0329] Figure 9 is a diagram showing the structure of an encoding device according to an embodiment of this application. The encoding device may be implemented by software, hardware, or a combination thereof to constitute part or all of the encoder side. Furthermore, the encoding device may be the encoder 100 in Figure 1. Referring to Figure 9, the device includes an acquisition module 901, a first determination module 902, a second determination module 903, and a first encoding module 904.
[0330] The acquisition module 901 is configured to acquire a target region, which is acquired by performing an alignment process on the target image based on the target alignment size. For detailed implementation processes, refer to the corresponding content in the embodiments described above. Further details will not be described again herein.
[0331] The first determination module 902 is configured to determine the position vector difference of the current block to be encoded within the target region, where the position vector difference represents the difference between the position vector of the current block and the reference position vector, and the position vector of the current block represents the positional relationship between the current block and the reference block corresponding to the current block. For a detailed implementation process, refer to the corresponding content in the embodiments described above. Further details will not be described again herein.
[0332] The second determination module 903 is configured to determine position identification data and a first flag bit based on the target alignment size and the position vector difference, wherein the position identification data is either a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data. For a detailed implementation process, refer to the corresponding content in the embodiments described above. Further details will not be described again herein.
[0333] The first encoding module 904 is configured to encode the location identification data and the first flag bits into a bitstream. For a detailed implementation process, refer to the corresponding content in the embodiments described above. Further details will not be described again herein.
[0334] Optionally, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit indicates the category of the horizontal identification data. The second decision module 903 is: If the horizontal component is an integer multiple of the horizontal alignment size, the multiple of the horizontal component with respect to the horizontal alignment size is determined as horizontal identification data, and the first value is specifically configured to be determined as the value of the horizontal flag bit.
[0335] Optionally, the second decision module 903 is: If the horizontal component is not an integer multiple of the horizontal alignment size, the system is specifically configured to determine the horizontal component as horizontal identification data and the second value as the value of the horizontal flag bit.
[0336] Optionally, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit indicates the category of the vertical identification data. The second decision module 903 is: If the vertical component is an integer multiple of the vertical alignment size, the multiple of the vertical component relative to the vertical alignment size is determined as vertical identification data, and the first value is specifically configured to be determined as the value of the vertical flag bit.
[0337] Optionally, the second decision module 903 is: If the vertical component is not an integer multiple of the vertical alignment size, the vertical component is specifically configured to be determined as the vertical identification data, and the second value is determined as the value of the vertical flag bit.
[0338] Optionally, the target alignment size includes the horizontal alignment size and the vertical alignment size, the position vector difference includes the horizontal component and the vertical component, and the position identification data includes the horizontal identification data and the vertical identification data. The second decision module 903 is specifically configured to determine a multiple of the horizontal component to the horizontal alignment size as horizontal identification data, a multiple of the vertical component to the vertical alignment size as vertical identification data, and to determine a first value as the value of the first flag bit.
[0339] Optionally, the first decision module 902 is: Currently, the system is specifically configured to determine the first and second candidate position vector differences of a block, where the first candidate position vector difference is determined based on a first pixel precision, and the second candidate position vector difference is determined based on a second pixel precision, where the first pixel precision is an integer and the second pixel precision is a multiple of the target alignment size. Determine the rate distortion cost of the first candidate position vector difference and the rate distortion cost of the second candidate position vector difference. The system is specifically configured to determine the candidate position vector difference having a smaller rate distortion cost among the first candidate position vector difference and the second candidate position vector difference as the position vector difference of the current block.
[0340] Optionally, the second decision module 903 is: If the horizontal component is an integer multiple of the horizontal alignment size and the vertical component is an integer multiple of the vertical alignment size, the multiple of the horizontal component relative to the horizontal alignment size is determined as horizontal identification data, and the multiple of the vertical component relative to the vertical alignment size is determined as vertical identification data, and the first value is determined as the value of the first flag bit.
[0341] Optionally, the second decision module 903 is: If the horizontal component is not an integer multiple of the horizontal alignment size, and / or if the vertical component is not an integer multiple of the vertical alignment size, the system is specifically configured to determine the horizontal component as horizontal identification data, the vertical component as vertical identification data, and the second value as the value of the first flag bit.
[0342] Optionally, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit is further used in combination with the horizontal identification data to indicate the horizontal component. The second decision module 903 is: The system is specifically configured to determine the quotient obtained by dividing the horizontal component by the horizontal alignment size as the horizontal identification data, and to determine the remainder obtained by dividing the horizontal component by the horizontal alignment size as the value of the horizontal flag bit.
[0343] Optionally, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit is further used in combination with the vertical identification data to indicate the vertical component. The second decision module 903 is: The system is specifically configured to determine the quotient obtained by dividing the vertical component by the vertical alignment size as the vertical identification data, and to determine the remainder obtained by dividing the vertical component by the vertical alignment size as the value of the vertical flag bit.
[0344] Optionally, the target region is obtained by performing an alignment process on the text region within the target image based on the target alignment size, and the text region contains at least one character.
[0345] Optionally, the device is A second encoding module is configured to encode the residual information of the current block into a bitstream, further comprising a second encoding module whose residual information represents the predicted residual between the current block and the reference block.
[0346] For a target image containing text content, after alignment processing is performed on the target image based on the target alignment size to obtain the target region, the position identification data and first flag bit corresponding to the position vector difference of the current block to be encoded within the target region can be determined based on the target alignment size. The position identification data may also be a multiple of the position vector difference with respect to the target alignment size. In this case, encoding the position identification data and first flag bit corresponding to the position vector difference requires fewer bits than encoding the position vector difference itself. In other words, the bit cost for encoding the position identification data and first flag bit corresponding to the position vector difference is usually smaller than the bit cost for directly encoding the position vector difference. Therefore, encoding the position identification data and first flag bit corresponding to the position vector difference into a bitstream effectively reduces the number of bits required to encode the position vector difference while ensuring encoding accuracy, thereby ensuring relatively high efficiency in encoding images containing text content.
[0347] It should be noted that in the encoding by the encoding device provided in the above embodiments, the division of the functional modules described above is used merely as an illustrative example. In actual applications, the above functions may be assigned to different functional modules and implemented on a case-by-case basis. Specifically, the internal structure of the device is divided into different functional modules to implement all or some of the above functions. Furthermore, embodiments of the encoding device and encoding method provided in the above embodiments belong to the same concept. For details regarding the specific implementation process of the encoding device, refer to the embodiments of the method. Details are not described again herein.
[0348] Figure 10 shows the structure of a decoding device according to one embodiment of this application. The decoding device may be implemented by software, hardware, or a combination thereof to constitute part or all of the decoder side. Furthermore, the decoding device may be the decoder 200 in Figure 1. Referring to Figure 10, the device includes a first analysis module 1001, a determination module 1002, and a reconstruction module 1003.
[0349] The first analysis module 1001 is configured to analyze the bitstream and obtain position identification data and a first flag bit corresponding to the position vector difference of the current block to be decoded within the target region. The position vector difference indicates the difference between the current block's position vector and the reference position vector, the current block's position vector indicates the positional relationship between the current block and the corresponding reference block, the position identification data is a multiple of the position vector difference with respect to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data. For a detailed implementation process, refer to the corresponding content in the embodiments described above. Further details will not be described again in this specification.
[0350] The determination module 1002 is configured to determine the position vector difference based on the target alignment size, position identification data, and a first flag bit. For a detailed implementation process, refer to the corresponding content in the embodiments described above. Further details will not be described again in this specification.
[0351] The reconfiguration module 1003 is configured to reconfigure the current block based on the position vector difference. For a detailed implementation process, refer to the corresponding content in the embodiments described above. Further details will not be described again in this specification.
[0352] Optionally, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit indicates the category of the horizontal identification data.
[0353] The decision module 1002 is, If the value of the horizontal flag bit is the first value, the horizontal alignment size is specifically configured to be multiplied by the horizontal identification data to obtain the horizontal component.
[0354] Optionally, the decision module 1002 is: The system is specifically configured to determine the horizontal identification data as a horizontal component if the value of the horizontal flag bit is the second value.
[0355] Optionally, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit indicates the category of the vertical identification data. The decision module 1002 is, If the value of the vertical flag bit is the first value, the vertical alignment size is specifically configured to be multiplied by the vertical identification data to obtain the vertical component.
[0356] Optionally, the decision module 1002 is: If the value of the vertical flag bit is the second value, the vertical identification data is specifically configured to be determined as the vertical component.
[0357] Optionally, the target alignment size includes the horizontal alignment size and the vertical alignment size, the position vector difference includes the horizontal component and the vertical component, and the position identification data includes the horizontal identification data and the vertical identification data. The decision module 1002 is, Specifically, if the value of the first flag bit is the first value, the horizontal alignment size is multiplied by the horizontal identification data to obtain the horizontal component, and the vertical alignment size is multiplied by the vertical identification data to obtain the vertical component.
[0358] Optionally, the decision module 1002 is: Specifically, the system is configured to determine horizontal identification data as the horizontal component and vertical identification data as the vertical component when the value of the first flag bit is the second value.
[0359] Optionally, the target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit is further used in combination with the horizontal identification data to indicate the horizontal component. The decision module 1002 is, The horizontal identification data is specifically configured to be multiplied by the horizontal alignment size, and then the value of the horizontal flag bit is added to obtain the horizontal component.
[0360] Optionally, the target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit is further used in combination with the vertical identification data to indicate the vertical component. The decision module 1002 is, The vertical identification data is specifically configured to be multiplied by the vertical alignment size, and then the value of the vertical flag bit is added to obtain the vertical component.
[0361] Optionally, the device is A second analysis module configured to analyze a bitstream and obtain residual information for the current block, further comprising a second analysis module that shows the predicted residual between the current block and a reference block. Reconfiguration module 1003 is It is specifically configured to reconstruct the current block based on position vector difference and residual information.
[0362] The position identification data may be a multiple of the position vector difference relative to the target alignment size. Since encoding the position identification data and the first flag bit corresponding to the position vector difference requires fewer bits than encoding the position vector difference, when the position identification data is a multiple of the position vector difference relative to the target alignment size, the efficiency of decoding the position identification data is higher than the efficiency of decoding the position vector difference. In this way, the efficiency of decoding images containing text content is improved while ensuring decoding accuracy. Furthermore, the decoding method provided in this embodiment of the application can be combined with standard video decoding methods without affecting standard video decoding procedures. In other words, the decoding method provided in this embodiment of the application has relatively high portability and can improve the efficiency of decoding images containing text content without adding further hardware costs.
[0363] It should be noted that in the decoding performed by the decoding device provided in the above embodiments, the division of the functional modules described above is used merely as an illustrative example. In actual applications, the above functions may be assigned to different functional modules and implemented on a case-by-case basis. Specifically, the internal structure of the device is divided into different functional modules to implement all or some of the above functions. Furthermore, the embodiments of the decoding device and decoding method provided in the above embodiments belong to the same concept. For details regarding the specific implementation process of the decoding device, refer to the embodiments of the method. Details are not described again herein.
[0364] Embodiments of this application further provide a computer-readable storage medium. The storage medium stores instructions. When an instruction is executed on a computer, the computer can perform the steps of the encoding method in the above embodiment or the steps of the decoding method in the above embodiment.
[0365] Embodiments of this application further provide a computer program product including instructions. When the instructions are executed on a computer, the computer becomes capable of performing the steps of the encoding method in the above embodiments or the steps of the decoding method in the above embodiments. In other words, a computer program is provided. When the computer program is executed on a computer, the computer becomes capable of performing the steps of the encoding method in the above embodiments or the steps of the decoding method in the above embodiments.
[0366] Embodiments of this application further provide an encoding and decoding system. The encoding and decoding system includes an encoding device and a decoding device. The encoding device is configured to implement the steps of the encoding method in the above embodiment. The decoding device is configured to implement the steps of the decoding method in the above embodiment.
[0367] All or part of the embodiments described above may be implemented by software, hardware, firmware, or a combination thereof. When software is used to implement an embodiment, all or part of the embodiment may be implemented in the form of a computer program product. A computer program product includes one or more computer instructions. When the computer instructions are loaded onto a computer and executed, all or part of the procedures or functions according to the embodiments of this application are generated. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions may be transmitted by wired (e.g., coaxial cable, optical fiber, or digital subscriber line (DSL)) or wireless (e.g., infrared, radio, or microwave) from one website, computer, server, or data center to another. The computer-readable storage medium may be any available medium accessible by a computer, or a data storage device integrating one or more available media, such as a server or data center. The usable media may be magnetic media (e.g., floppy disks, hard disks, or magnetic tapes), optical media (e.g., digital versatile discs (DVDs)), semiconductor media (e.g., solid state disks (SSDs)), etc. It should be noted that the computer-readable storage media referred to in the embodiments of this application may also be non-volatile storage media, that is, non-temporary storage media.
[0368] It should be understood that “multiple” in this specification means two or more. In the description of embodiments of this application, unless otherwise specified, “ / ” means “or.” For example, A / B may indicate A or B. In this specification, “and / or” describes only the relationship between related objects and indicates that three relationships may exist. For example, A and / or B may indicate the following three cases: that only A exists, that both A and B exist, and that only B exists. Furthermore, in order to clearly describe the technical solutions in embodiments of this application, terms such as “first” and “second” are used in embodiments of this application to distinguish between the same or similar items that provide essentially the same function or purpose. Those skilled in the art will understand that terms such as “first” and “second” do not limit the number and order of execution, and that terms such as “first” and “second” do not indicate a clear distinction.
[0369] It should be noted that information (including, but not limited to, user device information, user personal information, etc.), data (including, but not limited to, data used for analysis, stored data, displayed data, etc.) and signals in the embodiments of this application are used with the permission of the user or with the full permission of all parties, and the capture, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions. For example, the target area in the embodiments of this application is obtained with full permission.
[0370] The above description is merely an embodiment of this application and is not intended to limit this application. Any modification, equivalent substitution or improvement made without departing from the spirit and principles of this application should fall within the scope of protection of this application.
Claims
1. An encoding method, The steps include: acquiring a target region, which is acquired by performing an alignment process on the target image based on the target alignment size; The step of determining the position vector difference of the current block to be encoded within the target region, wherein the position vector difference represents the difference between the position vector of the current block and a reference position vector, and the position vector of the current block represents the positional relationship between the current block and the reference block corresponding to the current block. A step of determining position identification data and a first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference, wherein the position identification data is a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data. The steps include encoding the position identification data and the first flag bit into a bitstream. A method that includes this.
2. The target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit indicates the category of the horizontal identification data. The step of determining the position identification data and the first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference is: The method according to claim 1, further comprising the step of determining the multiple of the horizontal component to the horizontal alignment size as the horizontal identification data, and determining the first value as the value of the horizontal flag bit, if the horizontal component is an integer multiple of the horizontal alignment size.
3. This method is The method according to claim 2, further comprising the step of determining the horizontal component as the horizontal identification data and determining a second value as the value of the horizontal flag bit if the horizontal component is not an integer multiple of the horizontal alignment size.
4. The target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit indicates the category of the vertical identification data. The step of determining position identification data and the first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference is: The method according to any one of claims 1 to 3, further comprising the step of determining the multiple of the vertical component to the vertical alignment size as the vertical identification data, and determining the first value as the value of the vertical flag bit, if the vertical component is an integer multiple of the vertical alignment size.
5. This method is The method according to claim 4, further comprising the step of determining the vertical component as the vertical identification data and determining a second value as the value of the vertical flag bit if the vertical component is not an integer multiple of the vertical alignment size.
6. The target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. The step of determining the position identification data and the first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference is: The method according to claim 1, comprising the steps of determining a multiple of the horizontal component with respect to the horizontal alignment size as the horizontal identification data, determining a multiple of the vertical component with respect to the vertical alignment size as the vertical identification data, and determining a first value as the value of the first flag bit.
7. The step of determining the position vector difference of the current block to be encoded within the target region is: The steps include determining a first candidate position vector difference and a second candidate position vector difference of the current block, wherein the first candidate position vector difference is determined based on a first pixel precision, the second candidate position vector difference is determined based on a second pixel precision, the first pixel precision is an integer, and the second pixel precision is a multiple of the target alignment size, and The steps include determining the rate distortion cost of the first candidate position vector difference and the rate distortion cost of the second candidate position vector difference, The steps include determining the candidate position vector difference having a smaller rate distortion cost among the first candidate position vector difference and the second candidate position vector difference as the position vector difference of the current block, and The method according to claim 6, including the method described in claim 6.
8. The steps of determining the multiple of the horizontal component to the horizontal alignment size as the horizontal identification data, determining the multiple of the vertical component to the vertical alignment size as the vertical identification data, and determining the first value as the value of the first flag bit are: The method according to claim 6, comprising the steps of determining the multiple of the horizontal component to the horizontal alignment size as the horizontal identification data, determining the multiple of the vertical component to the vertical alignment size as the vertical identification data, and determining the first value as the value of the first flag bit, if the horizontal component is an integer multiple of the horizontal alignment size and the vertical component is an integer multiple of the vertical alignment size.
9. This method is If the horizontal component is not an integer multiple of the horizontal alignment size, and / or if the vertical component is not an integer multiple of the vertical alignment size, The method according to claim 8, further comprising the steps of determining the horizontal component as the horizontal identification data, determining the vertical component as the vertical identification data, and determining the second value as the value of the first flag bit.
10. The target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit is further used in combination with the horizontal identification data to indicate the horizontal component. The step of determining the position identification data and the first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference is: The method according to claim 1, comprising the steps of determining the quotient obtained by dividing the horizontal component by the horizontal alignment size as the horizontal identification data, and determining the remainder obtained by dividing the horizontal component by the horizontal alignment size as the value of the horizontal flag bit.
11. The target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit is further used in combination with the vertical identification data to indicate the vertical component. The step of determining the position identification data and the first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference is: The method according to claim 1 or 10, comprising the steps of determining the quotient obtained by dividing the vertical component by the vertical alignment size as the vertical identification data, and determining the remainder obtained by dividing the vertical component by the vertical alignment size as the value of the vertical flag bit.
12. The method according to any one of claims 1 to 11, wherein the target region is obtained by performing an alignment process on a text region in the target image based on the target alignment size, and the text region includes at least one character.
13. This method is The method according to any one of claims 1 to 12, further comprising the step of encoding residual information of the current block into the bitstream, wherein the residual information indicates a predicted residual between the current block and the reference block.
14. A decoding method, The steps include: analyzing a bitstream to obtain position identification data and a first flag bit corresponding to the position vector difference of the current block to be decoded within the target region, wherein the position vector difference represents the difference between the position vector of the current block and a reference position vector, the position vector of the current block represents the positional relationship between the current block and the reference block corresponding to the current block, the position identification data is a multiple of the position vector difference with respect to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data; A step of determining the position vector difference based on the target alignment size, the position identification data, and the first flag bit, The steps of reconstructing the current block based on the position vector difference and A method that includes this.
15. The target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit indicates the category of the horizontal identification data. The step of determining the position vector difference based on the target alignment size, the position identification data, and the first flag bit is: The method according to claim 14, further comprising the step of obtaining the horizontal component by multiplying the horizontal alignment size by the horizontal identification data when the value of the horizontal flag bit is a first value.
16. This method is The method according to claim 15, further comprising the step of determining the horizontal identification data as the horizontal component if the value of the horizontal flag bit is a second value.
17. The target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit indicates the category of the vertical identification data. The step of determining the position vector difference based on the target alignment size, the position identification data, and the first flag bit is: The method according to any one of claims 14 to 16, further comprising the step of obtaining the vertical component by multiplying the vertical alignment size by the vertical identification data when the value of the vertical flag bit is a first value.
18. This method is The method according to claim 17, further comprising the step of determining the vertical identification data as the vertical component if the value of the vertical flag bit is a second value.
19. The target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. The step of determining the position vector difference based on the target alignment size, the position identification data, and the first flag bit is: The method according to claim 14, further comprising the steps of obtaining the horizontal component by multiplying the horizontal alignment size by the horizontal identification data when the value of the first flag bit is a first value, and obtaining the vertical component by multiplying the vertical alignment size by the vertical identification data.
20. This method is The method according to claim 19, further comprising the step of determining the horizontal identification data as the horizontal component and the vertical identification data as the vertical component if the value of the first flag bit is a second value.
21. The target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit is further used in combination with the horizontal identification data to indicate the horizontal component. The step of determining the position vector difference based on the target alignment size, the position identification data, and the first flag bit is: The method according to claim 14, comprising the step of multiplying the horizontal identification data by the horizontal alignment size, and then adding the value of the horizontal flag bit to obtain the horizontal component.
22. The target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit is further used in combination with the vertical identification data to indicate the vertical component. The step of determining the position vector difference based on the target alignment size, the position identification data, and the first flag bit is: The method according to claim 14 or 21, comprising the step of multiplying the vertical identification data by the vertical alignment size, and then adding the value of the vertical flag bit to obtain the vertical component.
23. This method is The step of analyzing the bitstream to obtain residual information of the current block, the residual information representing the predicted residual between the current block and the reference block, further comprising the step of The step of reconstructing the current block based on the position vector difference is: The method according to any one of claims 14 to 22, comprising the step of reconstructing the current block based on the position vector difference and the residual information.
24. An encoding device, An acquisition module configured to acquire a target region, wherein the target region is acquired by performing an alignment process on a target image based on the target alignment size, and A first determination module configured to determine the position vector difference of the current block to be encoded within the target region, wherein the position vector difference represents the difference between the position vector of the current block and a reference position vector, and the position vector of the current block represents the positional relationship between the current block and the reference block corresponding to the current block. A second determination module configured to determine position identification data and a first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference, wherein the position identification data is a multiple of the position vector difference relative to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data. A first encoding module configured to encode the position identification data and the first flag bit into a bitstream. A device that includes this.
25. The target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit indicates the category of the horizontal identification data. The aforementioned second decision module is, The apparatus according to claim 24, wherein, if the horizontal component is an integer multiple of the horizontal alignment size, the apparatus is specifically configured to determine the multiple of the horizontal component with respect to the horizontal alignment size as the horizontal identification data, and to determine the first value as the value of the horizontal flag bit.
26. The aforementioned second decision module is, The apparatus according to claim 25, wherein if the horizontal component is not an integer multiple of the horizontal alignment size, the apparatus is specifically configured to determine the horizontal component as the horizontal identification data and to determine the second value as the value of the horizontal flag bit.
27. The target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit indicates the category of the vertical identification data. The aforementioned second decision module is, The apparatus according to any one of claims 24 to 26, wherein, if the vertical component is an integer multiple of the vertical alignment size, the apparatus is specifically configured to determine the multiple of the vertical component with respect to the vertical alignment size as the vertical identification data, and to determine the first value as the value of the vertical flag bit.
28. The aforementioned second decision module is, The apparatus according to claim 27, wherein, if the vertical component is not an integer multiple of the vertical alignment size, the apparatus is specifically configured to determine the vertical component as the vertical identification data and to determine the second value as the value of the vertical flag bit.
29. The target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. The aforementioned second decision module is, The apparatus according to claim 24, further configured to determine a multiple of the horizontal component with respect to the horizontal alignment size as the horizontal identification data, determine a multiple of the vertical component with respect to the vertical alignment size as the vertical identification data, and determine a first value as the value of the first flag bit.
30. The first decision module described above is: The system is specifically configured to determine a first candidate position vector difference and a second candidate position vector difference of the current block, wherein the first candidate position vector difference is determined based on a first pixel precision, and the second candidate position vector difference is determined based on a second pixel precision, where the first pixel precision is an integer and the second pixel precision is a multiple of the target alignment size. The rate distortion cost of the first candidate position vector difference and the rate distortion cost of the second candidate position vector difference are determined. The apparatus according to claim 29, further configured to determine the candidate position vector difference having a smaller rate distortion cost among the first candidate position vector difference and the second candidate position vector difference as the position vector difference of the current block.
31. The aforementioned second decision module is, The apparatus according to claim 29, wherein, if the horizontal component is an integer multiple of the horizontal alignment size and the vertical component is an integer multiple of the vertical alignment size, the apparatus is specifically configured to determine the multiple of the horizontal component with respect to the horizontal alignment size as the horizontal identification data, determine the multiple of the vertical component with respect to the vertical alignment size as the vertical identification data, and determine the first value as the value of the first flag bit.
32. The aforementioned second decision module is, If the horizontal component is not an integer multiple of the horizontal alignment size, and / or if the vertical component is not an integer multiple of the vertical alignment size, The apparatus according to claim 31, further configured to determine the horizontal component as the horizontal identification data, determine the vertical component as the vertical identification data, and determine the second value as the value of the first flag bit.
33. The target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit is further used in combination with the horizontal identification data to indicate the horizontal component. The aforementioned second decision module is, The apparatus according to claim 24, further configured to determine the quotient obtained by dividing the horizontal component by the horizontal alignment size as the horizontal identification data, and to determine the remainder obtained by dividing the horizontal component by the horizontal alignment size as the value of the horizontal flag bit.
34. The target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit is further used in combination with the vertical identification data to indicate the vertical component. The aforementioned second decision module is, The apparatus according to claim 24 or 33, specifically configured to determine the quotient obtained by dividing the vertical component by the vertical alignment size as the vertical identification data, and to determine the remainder obtained by dividing the vertical component by the vertical alignment size as the value of the vertical flag bit.
35. The apparatus according to any one of claims 24 to 34, wherein the target region is obtained by performing an alignment process on a text region in the target image based on the target alignment size, and the text region includes at least one character.
36. The device is The apparatus according to any one of claims 24 to 35, further comprising a second encoding module configured to encode residual information of the current block into the bitstream, wherein the residual information indicates a predicted residual between the current block and the reference block.
37. A decoding device, A first analysis module configured to analyze a bitstream and obtain position identification data and a first flag bit corresponding to the position vector difference of the current block to be decoded within a target region, wherein the position vector difference represents the difference between the position vector of the current block and a reference position vector, the position vector of the current block represents the positional relationship between the current block and the reference block corresponding to the current block, the position identification data is a multiple of the position vector difference with respect to the target alignment size or the position vector difference itself, and the first flag bit indicates the category of the position identification data. A determination module configured to determine the position vector difference based on the target alignment size, the position identification data, and the first flag bit, A reconfiguration module configured to reconfigure the current block based on the position vector difference, A device that includes this.
38. The target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit indicates the category of the horizontal identification data. The aforementioned decision module is The apparatus according to claim 37, wherein, when the value of the horizontal flag bit is a first value, the apparatus is specifically configured to obtain the horizontal component by multiplying the horizontal alignment size by the horizontal identification data.
39. The aforementioned decision module is The apparatus according to claim 38, further configured to determine the horizontal identification data as the horizontal component when the value of the horizontal flag bit is a second value.
40. The target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit indicates the category of the vertical identification data. The aforementioned decision module is The apparatus according to any one of claims 37 to 39, wherein, when the value of the vertical flag bit is a first value, the vertical alignment size is specifically configured to be multiplied by the vertical identification data to obtain the vertical component.
41. The aforementioned decision module is The apparatus according to claim 40, wherein the apparatus is specifically configured to determine the vertical identification data as the vertical component when the value of the vertical flag bit is a second value.
42. The target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. The aforementioned decision module is The apparatus according to claim 37, specifically configured to obtain the horizontal component by multiplying the horizontal alignment size by the horizontal identification data when the value of the first flag bit is a first value, and to obtain the vertical component by multiplying the vertical alignment size by the vertical identification data.
43. The aforementioned decision module is The apparatus according to claim 42, wherein, when the value of the first flag bit is the second value, the horizontal identification data is determined as the horizontal component and the vertical identification data is determined as the vertical component.
44. The target alignment size includes the horizontal alignment size, the position vector difference includes the horizontal component, the position identification data includes the horizontal identification data, the first flag bit includes the horizontal flag bit, and the horizontal flag bit is further used in combination with the horizontal identification data to indicate the horizontal component. The aforementioned decision module is The apparatus according to claim 37, specifically configured to obtain the horizontal component by multiplying the horizontal identification data by the horizontal alignment size and then adding the value of the horizontal flag bit.
45. The target alignment size includes the vertical alignment size, the position vector difference includes the vertical component, the position identification data includes the vertical identification data, the first flag bit includes the vertical flag bit, and the vertical flag bit is further used in combination with the vertical identification data to indicate the vertical component. The aforementioned decision module is The apparatus according to claim 37 or 44, specifically configured to obtain the vertical component by multiplying the vertical identification data by the vertical alignment size and then adding the value of the vertical flag bit.
46. The device is A second analysis module configured to analyze the bitstream and obtain residual information of the current block, further comprising a second analysis module whose residual information indicates the predicted residual between the current block and the reference block, The aforementioned reconfiguration module is The apparatus according to any one of claims 37 to 45, specifically configured to reconstruct the current block based on the position vector difference and the residual information.
47. An encoding device, The encoding device includes memory and a processor, The memory is configured to store computer programs, The processor is configured to execute the computer program to realize the steps of the method according to any one of claims 1 to 13, in an encoding device.
48. A decoding device, The decoding device includes memory and a processor, The memory is configured to store computer programs, A decoding device wherein the processor is configured to execute the computer program to realize the steps of the method according to any one of claims 14 to 23.
49. A computer-readable storage medium, A storage medium that stores instructions, and when the instructions are executed on a computer, the computer is able to perform the steps of the method according to any one of claims 1 to 23.
50. A computer program product, The computer program product stores computer instructions, and when the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 23 are realized.
51. A computer-readable storage medium, The computer-readable storage medium stores a video bitstream obtained by performing the method described in any one of claims 1 to 23 using one or more processors.