Coding method, decoding method, apparatus, device, storage medium and computer program
By using adaptive text alignment and target alignment size processing, and employing position identifier data and flag bit encoding to address the low encoding efficiency of images containing text content, a more efficient encoding is achieved.
Patent Information
- Application Number
- PCT/CN2024/078771
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-06
- Filing Date
- 2024-02-27
- Publication Date
- 2024-09-12
AI Technical Summary
Existing efficient video coding methods are highly efficient at coding natural images, but less efficient at coding images containing text, especially when character pixels are divided into different coding units, which leads to a decrease in coding efficiency.
By performing adaptive text alignment on the target image, after determining the target region, the position vector difference of the current block is encoded using the target alignment size and position vector difference. The position identification data and the first flag bit are used instead of directly encoding the position vector difference, reducing the number of encoding bits.
While ensuring encoding accuracy, it effectively reduces the number of encoding bits for position vector differences, thereby improving the encoding efficiency of images containing text content.
Smart Images

Figure CN2024078771_12092024_PF_FP_ABST
Abstract
Description
Coding and decoding method, device, equipment, storage medium and computer program
[0001] This application claims priority to Chinese patent application No. 202310254388.7, filed on March 6, 2023, entitled “Encoding and decoding methods, devices, equipment, storage media and computer programs,” the entire contents of which are incorporated herein by reference. Technical Field
[0002] The present application relates to the field of image compression, and in particular to a coding and decoding method, apparatus, device, storage medium and computer program. Background Art
[0003] A high efficiency video coding (HEVC) encoder can encode video frame images using motion compensation or intra block copy (IBC).
[0004] Taking motion compensation as an example, for the current block to be encoded in a video frame, the reference block corresponding to the current block can be determined, and the residual between the current block and the reference block can be encoded into the bitstream. Then, the 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. The motion vector prediction (MVP) corresponding to the MV is determined, and the difference between the MV and the MVP is used as the motion vector difference (MVD), which is then encoded into the bitstream.
[0005] However, the above encoding method has a better encoding efficiency for natural images, but a lower encoding efficiency for images containing text content.
[0006] Summary of the Invention
[0007] This application provides a coding and decoding method, apparatus, device, storage medium, and computer program that can solve the problem of low coding efficiency for images containing text content in related technologies. The technical solution is as follows:
[0008] In a first aspect, a coding method is provided, the method comprising: obtaining a target area, the target area being obtained by aligning a target image according to a target alignment size, determining a position vector difference of a current block to be encoded in the target area, the position vector difference indicating a difference between a position vector of the current block and a reference position vector, the position vector of the current block indicating a positional relationship between the current block and a 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, the position identification data being a multiple of the position vector difference relative to the target alignment size or being the position vector difference, the first flag bit indicating a category of the position identification data, and encoding the position identification data and the first flag bit into a bitstream.
[0009] For a target image containing text content, after the target image is aligned according to the target alignment size to obtain a target area, the position identification data and the first flag bit corresponding to the position vector difference of the current block to be encoded in the target area can be determined based on the target alignment size. Since the position identification data can be a multiple of the position vector difference relative to the target alignment size, in this case, the encoding bits required for the position identification data and the first flag bit corresponding to the position vector difference are less than the encoding bits required for the position vector difference, that is, the bit cost of encoding the position identification data and the first flag bit corresponding to the position vector difference is usually less than the bit cost of directly encoding the position vector difference. Therefore, encoding the position identification data and the first flag bit corresponding to the position vector difference into the bitstream can effectively reduce the number of bits required for encoding the position vector difference while ensuring encoding accuracy, thereby ensuring high encoding efficiency of images containing text content.
[0010] Optionally, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, and the first flag bit includes a horizontal flag bit, and the horizontal flag bit indicates the category of the horizontal identification data; 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, then determining the multiple of the horizontal component relative to the horizontal alignment size as the horizontal identification data, and determining the first numerical value as the value of the horizontal flag bit.
[0011] 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, so that the horizontal component can be accurately encoded into the bitstream, ensuring the accuracy of the encoding and decoding of the horizontal component.
[0012] Optionally, the method further includes: if the horizontal component is not an integer multiple of the horizontal alignment size, determining the horizontal component as the horizontal identification data, and determining the second numerical value as the value of the horizontal flag bit.
[0013] 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, avoiding the situation where horizontal component encoding errors are caused by encoding the multiple of the horizontal component relative to the horizontal alignment size into the bitstream, thereby ensuring the accuracy of the encoding and decoding of the horizontal component.
[0014] Optionally, the target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag includes a vertical flag, and the vertical flag indicates the category of the vertical identification data; determining the position identification data and the first flag 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, then determining the multiple of the vertical component relative to the vertical alignment size as the vertical identification data, and determining the first numerical value as the value of the vertical flag.
[0015] 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, so that the vertical component can be accurately encoded into the code stream, ensuring the accuracy of the encoding and decoding of the vertical component.
[0016] Optionally, the method further includes: if the vertical component is not an integer multiple of the vertical alignment size, determining the vertical component as the vertical identification data, and determining the second numerical value as the value of the vertical flag bit.
[0017] 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 directly determined 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 the bitstream, thereby ensuring the accuracy of the encoding and decoding of the vertical component.
[0018] 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; 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 multiple of the horizontal component relative to the horizontal alignment size as the horizontal identification data, determining the multiple of the vertical component relative to the vertical alignment size as the vertical identification data, and determining the first numerical value as the value of the first flag bit.
[0019] Optionally, determining the position vector difference of the current block to be encoded in the target area includes: determining a first candidate position vector difference and a second candidate position vector difference of the current block, the first candidate position vector difference being determined according to a first pixel precision, and the second candidate position vector being determined according to a second pixel precision, the first pixel precision being an integer, and the second pixel precision being a multiple of the target alignment size; determining a rate-distortion cost of the first candidate position vector difference and a rate-distortion cost of the second candidate position vector difference; and determining the candidate position vector difference having the smaller rate-distortion cost between the first candidate position vector difference and the second candidate position vector difference as the position vector difference of the current block.
[0020] Since the position vector difference of the current block is the candidate position vector difference with the smaller rate-distortion cost between the first candidate position vector difference and the second candidate position vector difference, the rate-distortion cost of the position vector difference of the current block is smaller. In addition, when the position vector difference of the current block is the second candidate position vector difference, the multiple of the horizontal component relative to the horizontal alignment size can be directly determined as the horizontal identification data, and the multiple of the vertical component relative to the vertical alignment size can be directly determined as the vertical identification data. In this way, the horizontal component and the vertical component can be accurately encoded into the code stream, thereby ensuring the accuracy of encoding and decoding of the horizontal component and the vertical component.
[0021] Optionally, determining the multiple of the horizontal component relative to the horizontal alignment size as the horizontal identification data, determining the multiple of the vertical component relative to the vertical alignment size as the vertical identification data, and determining the first numerical 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, then determining the multiple of the horizontal component relative to the horizontal alignment size as the horizontal identification data, determining the multiple of the vertical component relative to the vertical alignment size as the vertical identification data, and determining the first numerical value as the value of the first flag bit.
[0022] 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 also 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 component and the vertical component can be accurately encoded into the bitstream, ensuring the accuracy of the encoding and decoding of the horizontal component and the vertical component.
[0023] Optionally, the method also includes: 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, then the horizontal component is determined as the horizontal identification data, the vertical component is determined as the vertical identification data, and the second numerical value is determined as the value of the first flag bit.
[0024] When 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 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. This can avoid the situation where horizontal component encoding errors are caused by encoding the multiple of the horizontal alignment size of the horizontal component into the code stream, and / or the situation where vertical component encoding errors are caused by encoding the multiple of the vertical alignment size of the vertical component into the code stream, thereby ensuring the accuracy of encoding and decoding of the horizontal and vertical components.
[0025] Optionally, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, and the first flag bit includes a horizontal flag bit, and the horizontal flag bit is also used to indicate the horizontal component in combination with the horizontal identification data; 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.
[0026] Since the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size can accurately represent the horizontal component, the quotient obtained by dividing the horizontal component by the horizontal alignment size can be determined as the 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, so that the horizontal component can be accurately encoded into the bitstream, thereby ensuring the accuracy of the encoding and decoding of the horizontal component.
[0027] Optionally, the target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag includes a vertical flag, and the vertical flag is also used to indicate the vertical component in combination with the vertical identification data; determining the position identification data and the first flag 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.
[0028] Since the quotient and remainder obtained by dividing the vertical component by the vertical alignment size can accurately represent the vertical component, the quotient obtained by dividing the vertical component by the vertical alignment size can be determined as the 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, so that the vertical component can be accurately encoded into the bitstream, ensuring the accuracy of the encoding and decoding of the vertical component.
[0029] Optionally, the target area is obtained by aligning a text area in the target image according to the target alignment size, and the text area includes at least one character.
[0030] If the target area is aligned with the text area in the target image according to the target alignment size, the position identification data and the first flag bit corresponding to the position vector difference are encoded into the bit stream. This can effectively reduce the number of bits required to encode the position vector difference while ensuring the encoding accuracy, thereby ensuring a high encoding efficiency for images containing text content.
[0031] Optionally, the method further includes: encoding residual information of the current block into a bitstream, where the residual information indicates a prediction residual between the current block and the reference block.
[0032] When the residual information of the current block is encoded into the bitstream, the accuracy of encoding the current block can be effectively guaranteed.
[0033] In a second aspect, a decoding method is provided, the method comprising: parsing from a code stream position identification data and a first flag bit corresponding to a position vector difference of a current block to be decoded in a target area; 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 a reference block corresponding to the current block, the position identification data is a multiple of the position vector difference relative to the target alignment size or is the position vector difference, and the first flag bit indicates a category of the position identification data; determining the position vector difference based on the target alignment size, the position identification data and the first flag bit; and reconstructing the current block based on the position vector difference.
[0034] Since the position identification data can be a multiple of the position vector difference relative to the target alignment size, the encoding bits required for the position identification data and the first flag corresponding to the position vector difference are less than the encoding bits required for the position vector difference. Therefore, 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 decoding efficiency of images containing text content can be improved while ensuring decoding accuracy. In addition, the decoding method provided by the present application can be combined with a standard video decoding method without affecting the standard video decoding process. In other words, the decoding provided by the present application is highly portable and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.
[0035] Optionally, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag includes a horizontal flag, and the horizontal flag indicates the category of the horizontal identification data; determining the position vector difference based on the target alignment size, the position identification data and the first flag includes: if the value of the horizontal flag is a first numerical value, multiplying the horizontal alignment size by the horizontal identification data to obtain the horizontal component.
[0036] When the horizontal flag bit has the first value, it indicates that the horizontal identification data is a multiple of the horizontal component relative to the horizontal alignment size. Therefore, the horizontal alignment size is multiplied by the horizontal identification data to obtain the horizontal component. Furthermore, when the horizontal flag bit has the first value, decoding the horizontal identification data is more efficient than decoding the horizontal component. This improves the decoding efficiency of images containing text while ensuring decoding accuracy.
[0037] Optionally, the method further includes: if the value of the horizontal flag bit is a second numerical value, determining the horizontal identification data as the horizontal component.
[0038] When the value of the horizontal flag is the second numerical value, it indicates that the horizontal identification data is the horizontal component. Therefore, the horizontal identification data can be directly determined as the horizontal component.
[0039] Optionally, the target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag includes a vertical flag, and the vertical flag indicates the category of the vertical identification data; determining the position vector difference based on the target alignment size, the position identification data and the first flag includes: if the value of the vertical flag is a first numerical value, multiplying the vertical alignment size by the vertical identification data to obtain the vertical component.
[0040] When the value of the vertical flag 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, the vertical alignment size is multiplied by the vertical identification data to obtain the vertical component. Furthermore, when the vertical flag is the first value, decoding the vertical identification data is more efficient than decoding the vertical component. This improves the decoding efficiency of images containing text while ensuring decoding accuracy.
[0041] Optionally, the method further includes: if the value of the vertical flag is a second numerical value, determining the vertical identification data as the vertical component.
[0042] When the value of the vertical flag is the second numerical value, it indicates that the vertical identification data is the vertical component. Therefore, the vertical identification data can be directly determined as the vertical component.
[0043] 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; 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 numerical 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.
[0044] When the value of the first flag bit is a first numerical value, it indicates that the position identification data is a multiple of the position vector difference relative to the target alignment size. Therefore, 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. Furthermore, because the coding bits required for the multiple of the position vector difference relative to the target alignment size are less than the coding bits required for the position vector difference of the current block, when the value of the first flag bit is the first numerical value, decoding the position identification data is more efficient than decoding the position vector difference. In this way, the decoding efficiency of images containing text content can be improved while ensuring decoding accuracy.
[0045] Optionally, the method further includes: if the value of the first flag bit is a second numerical value, determining the horizontal identification data as the horizontal component and determining the vertical identification data as the vertical component.
[0046] When the value of the horizontal flag is the second numerical value, it indicates that the position identification data is the position vector difference. Therefore, the horizontal identification data can be directly determined as the horizontal component, and the vertical identification data can be determined as the vertical component.
[0047] Optionally, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag includes a horizontal flag, and the horizontal flag is also used to indicate the horizontal component in combination with the horizontal identification data; determining the position vector difference based on the target alignment size, the position identification data and the first flag includes: multiplying the horizontal identification data by the horizontal alignment size and then adding the resultant to the value of the horizontal flag to obtain the horizontal component.
[0048] Since the horizontal identification data and horizontal flag bit corresponding to the horizontal component are the quotient and remainder of the horizontal component divided by the horizontal alignment size, 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. Therefore, during the decoding process, the efficiency of decoding the horizontal identification data and horizontal flag bit corresponding to the horizontal component is higher than the efficiency of decoding the horizontal component. In this way, the decoding efficiency of images containing text content can be improved while ensuring the decoding accuracy.
[0049] Optionally, the target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag includes a vertical flag, and the vertical flag is also used to indicate the vertical component in combination with the vertical identification data; determining the position vector difference based on the target alignment size, the position identification data and the first flag includes: multiplying the vertical identification data by the vertical alignment size and then adding the resultant value to the vertical flag to obtain the vertical component.
[0050] Since the vertical identification data and vertical flag bit corresponding to the vertical component are the quotient and remainder of the vertical component divided by the vertical alignment size, 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. Therefore, during the decoding process, the efficiency of decoding the vertical identification data and vertical flag bit corresponding to the vertical component is higher than the efficiency of decoding the vertical component. In this way, the decoding efficiency of images containing text content can be improved while ensuring the decoding accuracy.
[0051] Optionally, the method further includes: parsing residual information of the current block from the code stream, the residual information indicating a prediction residual between the current block and the reference block; and reconstructing the current block based on the position vector difference includes: reconstructing the current block based on the position vector difference and the residual information.
[0052] When the residual information of the current block is parsed, the current block is reconstructed based on the position vector difference and the residual information, which can effectively ensure the accuracy of the reconstructed current block.
[0053] In a third aspect, a coding device is provided, wherein the coding device has the function of implementing the coding method described in the first aspect. The coding device includes at least one module, wherein the at least one module is configured to implement the coding method described in the first aspect.
[0054] In a fourth aspect, a decoding device is provided, wherein the decoding device has the function of implementing the decoding method described in the second aspect. The decoding device includes at least one module, wherein the at least one module is used to implement the decoding method described in the second aspect.
[0055] In a fifth aspect, an encoding device is provided, comprising a processor and a memory, wherein the memory is configured to store a program for executing the encoding method provided in the first aspect. The processor is configured to execute the program stored in the memory to implement the encoding method provided in the first aspect.
[0056] Optionally, the encoding device may further include a communication bus, which is used to establish a connection between the processor and the memory.
[0057] In a sixth aspect, a decoding device is provided, comprising a processor and a memory, wherein the memory is configured to store a program for executing the decoding method provided in the second aspect. The processor is configured to execute the program stored in the memory to implement the decoding method provided in the second aspect.
[0058] Optionally, the decoding device may further include a communication bus, which is used to establish a connection between the processor and the memory.
[0059] In the seventh aspect, a computer-readable storage medium is provided, wherein the storage medium stores instructions. When the instructions are executed on a computer, the computer executes the steps of the encoding method described in the first aspect or the steps of the decoding method described in the second aspect.
[0060] In an eighth aspect, a computer program product comprising instructions is provided. When the instructions are executed on a computer, the computer is caused to execute the steps of the encoding method described in the first aspect, or the steps of the decoding method described in the second aspect. Alternatively, a computer program is provided. When the computer program is executed on a computer, the computer is caused to execute the steps of the encoding method described in the first aspect, or the steps of the decoding method described in the second aspect.
[0061] In the ninth aspect, a coding and decoding system is provided, which includes a coding device and a decoding device, the coding device is used to implement the steps of the coding method described in the first aspect above, and the decoding device is used to implement the steps of the decoding method described in the second aspect above.
[0062] The technical effects obtained in the above-mentioned third to ninth aspects are similar to the technical effects obtained by the corresponding technical means in the first or second aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] FIG1 is a schematic diagram of an implementation environment provided by an embodiment of the present application;
[0064] FIG2 is a schematic diagram of another implementation environment provided by an embodiment of the present application;
[0065] FIG3 is a schematic structural diagram of a video encoding module provided in an embodiment of the present application;
[0066] FIG4 is a schematic structural diagram of a video decoding module provided in an embodiment of the present application;
[0067] FIG5 is a flowchart of a first encoding method provided in an embodiment of the present application;
[0068] FIG6 is a schematic diagram of a target area provided in an embodiment of the present application;
[0069] FIG7 is a schematic diagram of a filled text area provided in an embodiment of the present application;
[0070] FIG8 is a flowchart of a first decoding method provided in an embodiment of the present application;
[0071] FIG9 is a schematic structural diagram of an encoding device provided in an embodiment of the present application;
[0072] FIG10 is a schematic structural diagram of a decoding device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0073] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0074] For ease of understanding, before explaining in detail the encoding and decoding method provided in the embodiment of the present application, the nouns, application scenarios and implementation environment involved in the embodiment of the present application are first introduced.
[0075] High-efficiency video coding (HEVC) is a video compression standard that uses a block-based hybrid video coding / compression architecture. This architecture combines prediction, transform, quantization, block partitioning, in-loop filtering, and entropy coding to compress video and reduce redundant signals. The encoder divides the input video frame or signal into coding tree units (CTUs) of similar size. For each CTU, a prediction is performed on that CTU and the corresponding prediction residual is obtained. This prediction residual is transformed to obtain frequency-domain transform coefficients, which are then lossily compressed through quantization. The quantized frequency-domain transform coefficients are then encoded into the bitstream using entropy coding. Based on the bitstream, the CTU is reconstructed using inverse quantization, inverse transform, and in-loop filtering to obtain the reconstructed value of the video frame. Subsequent encoding of other CTUs can then be based on this reconstructed value.
[0076] Prediction and transformation reduce redundancy in the video signal by removing correlation between pixels within each CTU in the temporal, spatial, and frequency domains. Prediction includes both inter-frame and intra-frame prediction. Quantization reduces the number of bits required to represent transform coefficients by reducing their precision. Quantization aims to remove subtle details from video frames, effectively reducing data irrelevance. Block partitioning is discussed in detail later and will not be elaborated on here.
[0077] Hybrid video coding structures are typically used to process natural videos captured by cameras. However, in recent years, screen content videos, including computer-generated text, graphics, and animations, have become popular. This screen content video exhibits color and other signal characteristics that are different from natural videos. In order to address the need for efficient encoding of screen content videos, many screen content coding (SCC) tools have been developed, and great progress has been made in coding efficiency. Among them, HEVC SCC is a coding standard that includes SCC functions. HEVC SCC includes coding tools such as Intra Block Copy (IBC) and color palette, which can improve the compression efficiency of screen content by 30% to 40%.
[0078] Block partitioning: The HEVC standard introduces a set of basic units based on quadtree recursive partitioning, including coding units (CUs), prediction units (PUs), and transform units (TUs). In the HEVC encoder, the input image is first divided into multiple non-overlapping coding tree units (CTUs) of equal size. The size of a CTU is determined by the encoder and can be up to 64×64. During the subsequent encoding process, a CTU can be used directly as a CU or further divided into multiple smaller CUs through quadtree recursive partitioning. The depth of the CU partition is determined by the calculated rate-distortion cost (i.e., the rate-distortion cost). The encoder compares and weighs different partitioning modes, selecting the partitioning mode with the lowest rate-distortion cost for encoding. The final CU at the quadtree leaf node becomes the basic unit for the encoder to perform subsequent predictive transform coding. Generally speaking, block partitioning uses a shallower partitioning depth and a larger CU for flat and smooth areas, and a deeper partitioning depth and a smaller CU for areas with complex colors. This makes the processing of modules such as prediction, transformation, and quantization more convenient and accurate, and makes the selection of encoding mode more in line with the image characteristics of the video content, effectively improving encoding efficiency.
[0079] The PU is the basic unit for encoder prediction and contains all prediction-related information. It is formed by further dividing the CU. For a 2N×2N CU, the PU has eight optional partitioning modes, including four symmetric modes (2N×2N, N×N, 2N×N, and N×2N) and four asymmetric modes with a 1:3 or 3:1 partition ratio. The introduction of multiple partitioning modes can ensure more accurate prediction of complex images.
[0080] A TU is the basic unit used by the encoder for transform and quantization. The size of a TU depends on the CU to which it belongs. Within a CU, further TUs can be created using a quadtree partitioning scheme. The minimum TU size is 4×4, and the maximum is 32×32. The encoder can flexibly select the optimal partitioning scheme for each TU based on content characteristics.
[0081] Inter-frame prediction: Inter-frame prediction includes motion estimation (ME) unit and motion compensation (MC) unit. The basic idea of motion estimation is to divide the video frame image into many non-overlapping macroblocks, and then find the block that is most similar to the current block for each macroblock according to certain matching criteria, that is, the reference block / matching block. The relative displacement between the reference block and the current block is the motion vector (MV). The difference between the pixel value of the current block and the pixel value of the reference block is called the prediction residual between the current block and the reference block. The process of determining the MV is called motion estimation. Motion compensation refers to determining the reference block corresponding to the current block based on the MV, and then restoring the current block based on the prediction residual between the current block and the reference block.
[0082] Motion vector (MV) predictive coding: Since the MV of the current block is usually related to the MV of the adjacent blocks in the current or adjacent images, the MV of the adjacent blocks in the current or adjacent images can be used as a motion vector predictor (MVP) to reduce the signal amplitude of the MV of the current block. This is the idea of MV predictive coding.
[0083] During the evolution of coding standards, MV prediction coding methods have been optimized a lot. The MV prediction of the H.261 standard is a relatively simple differential coding. The H.265 / HEVC standard introduces a list competition scheme, which is to collect a list of MVPs and transmit the index of the best MVP. Here, adjacent MVs in space and time are added to the candidate list, and the MV with the best compression cost is selected from the list as the MVP and its index is transmitted. The MV is subtracted from the MVP to obtain the motion vector difference (MVD), that is, MVD = MV-MVP. MVD usually has two components, vertical and horizontal, which need to be compressed and transmitted. At the decoding end, by establishing the same MVP list as the encoding end, the MV of the current block can be calculated based on the index of the transmitted MVP in the list and the MVD.
[0084] The HEVC standard has two MVP modes: Advanced Motion Vector Prediction (AMVP) and Merge. AMVP accommodates HEVC's flexible block structure, while Merge reduces block partitioning redundancy.
[0085] Intra block copy (IBC): IBC is an important tool for screen content coding in HEVC SCC. It is a block-based prediction technology, and its mechanism is similar to inter-frame prediction or motion compensation. Motion compensation means that for the current prediction unit, the encoder will use the motion search algorithm to find the best matching block in the previously encoded reference image as the reference block corresponding to the current block, and the motion vector (MV) indicates this 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 the transformation, quantization, entropy coding and other modules and then output to the bitstream.
[0086] The main difference between IBC and motion compensation is that IBC's reference image is obtained from within the current image (i.e., the reconstructed portion), and a block vector (BV), similar to a motion vector, is used to indicate block matching relationships. IBC effectively handles video frames containing multiple similar graphics or text. Specifically, the current block can reference blocks with similar graphics within the current image and generate a prediction residual with pixel values close to zero. This residual contributes very little to the bitrate of the bitstream. The rest of the IBC encoding process, including the syntax structure and related information, is virtually identical to motion compensation.
[0087] The key to IBC technology is the encoding of BV. In the existing technology, the encoding method of BV is similar to the MV prediction encoding method in the above-mentioned inter-frame prediction. That is, in IBC mode, BV is similar to the above-mentioned MV, the block vector predictor (BVP) is similar to the MVP, and the block vector difference (BVD) is similar to the MVD. For ease of description, in the following text, BV and MV are collectively referred to as position vectors, BVP and MVP are collectively referred to as reference position vectors, and BVD and MVD are collectively referred to as position vector differences.
[0088] Image compression refers to a technology that uses image data characteristics such as spatial redundancy, visual redundancy, and statistical redundancy to represent the original image pixel matrix with fewer bits, either losslessly or losslessly, to achieve effective transmission and storage of image information. It plays an important role in the current media era where the types and amounts of image information are increasing.
[0089] Currently, video compression standards such as HEVC have been established. HEVC can segment a video into multiple video frames, and encoders can encode the video frames using motion compensation or IBC. However, when these encoding methods are applied to images containing text, pixels of the same character may be divided into different CTUs or CUs. In this case, subsequent operations such as prediction, transformation, and quantization will lead to poor coding efficiency when compressing text content.
[0090] Based on the above problems, a text adaptive alignment coding scheme came into being. This scheme can process an image containing text content, that is, a target image, to obtain a text area and a non-text area corresponding to the target image. The text area in the target image is aligned according to the target alignment size to obtain a processed text area, that is, a target area. The target alignment size is related to the size of the CU. The target area and the non-text area are then encoded separately. Since the target alignment size is related to the size of the CU, when the target area is divided into blocks, it can avoid the pixels of the same character from being divided into different CUs to the greatest extent, thereby improving the accuracy and efficiency of compressing text content.
[0091] Although the above-mentioned text adaptive alignment encoding scheme solves the problem of pixels of the same character being divided into different CTUs or CUs, since the position vector of the text content is usually pointed by one character (i.e., the current block / current character) to another character with similar content (i.e., the reference block / reference character), and the characters are arranged according to semantics, the same characters will not appear in groups. Therefore, the reference characters corresponding to two adjacent characters are usually not the same, resulting in a large difference in the position vectors of the two adjacent characters. In this way, when encoding the position vector of a certain character, the difference between the position vector of the character and the reference position vector will be large, resulting in a position vector difference with a large numerical value. In this case, the position vector difference needs to be encoded with a higher number of bits, which makes the encoding efficiency of the target image low. Based on this, an embodiment of the present application provides a coding and decoding method, which can, during the encoding process, encode the position identification data and the first flag bit corresponding to the position vector difference into the bitstream based on the target alignment size and the position vector difference of the current block. Since the position identification data can be a multiple of the position vector difference relative to the target alignment size, in this case, the encoding bits required for the position identification data and the first flag bit corresponding to the position vector difference are less than the encoding bits required for the position vector difference, that is, the bit cost of encoding the position identification data and the first flag bit corresponding to the position vector difference is usually less than the bit cost of directly encoding the position vector difference. Therefore, the encoding method provided in the embodiment of the present application can effectively reduce the number of bits required to encode the position vector difference while ensuring encoding accuracy, thereby ensuring high encoding efficiency of the target image.
[0092] Next, the implementation environment involved in the embodiments of this application is introduced.
[0093] Please refer to Figure 1, which is a schematic diagram of an implementation environment provided by an embodiment of the present application. The implementation environment includes a source device 10, a destination device 20, a link 30, and a storage device 40. Source device 10 can generate encoded video, i.e., a bitstream. Therefore, source device 10 can also be referred to as an encoding device. Destination device 20 can decode the bitstream generated by source device 10. Therefore, destination device 20 can also be referred to as a decoding device. Link 30 can receive the encoded video generated by source device 10 and transmit it to destination device 20. Storage device 40 can receive the encoded video generated by source device 10 and store it. In this case, destination device 20 can directly obtain the encoded video from storage device 40. Alternatively, storage device 40 can correspond to a file server or another intermediate storage device that can store the encoded video generated by source device 10. In this case, destination device 20 can stream or download the encoded video stored by storage device 40.
[0094] The source device 10 and the destination device 20 may each include one or more processors and a memory coupled to the one or more processors, wherein the memory may include random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory, any other medium that can be used to store desired program code in the form of instructions or data structures accessible by a computer, etc. For example, the source device 10 and the destination device 20 may each include a mobile phone, a smartphone, a personal digital assistant (PDA), a wearable device, a pocket PC (PPC), a tablet computer, a smart car computer, a smart TV, a smart speaker, a desktop computer, a mobile computing device, a notebook (e.g., laptop) computer, a tablet computer, a set-top box, a telephone handset such as a so-called "smart" phone, a television, a camera, a display device, a digital media player, a video game console, an in-vehicle computer, or the like.
[0095] Link 30 may include one or more media or devices capable of transmitting the encoded video from source device 10 to destination device 20. In one possible implementation, link 30 may include one or more communication media that enable source device 10 to send the encoded video directly to destination device 20 in real time. In an embodiment of the present application, source device 10 may modulate the encoded video based on a communication standard, such as a wireless communication protocol, and may transmit the modulated video to destination device 20. The one or more communication media may include wireless and / or wired communication media, such as a radio frequency (RF) spectrum or one or more physical transmission lines. The one or more communication media may form part of a packet-based network, such as a local area network, a wide area network, or a global network (e.g., the Internet). The one or more communication media may include routers, switches, base stations, or other devices that facilitate communication from source device 10 to destination device 20, and the embodiments of the present application are not particularly limited in this regard.
[0096] In one possible implementation, the storage device 40 may store the received encoded video sent by the source device 10, and the destination device 20 may directly obtain the encoded video from the storage device 40. Under such conditions, the storage device 40 may include any of a variety of distributed or locally accessible data storage media, for example, any of the various distributed or locally accessible 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), a flash memory, a volatile or non-volatile memory, or any other suitable digital storage medium for storing a bitstream.
[0097] In one possible implementation, storage device 40 may correspond to a file server or another intermediate storage device that can store the codestream generated by source device 10. Destination device 20 can stream or download the images stored on storage device 40. The file server can be any type of server capable of storing and transmitting encoded video to destination device 20. In one possible implementation, the file server may include a network server, a file transfer protocol (FTP) server, a network attached storage (NAS) device, or a local disk drive. Destination device 20 can obtain the encoded images via any standard data connection, including an internet connection. Any standard data connection may include a wireless channel (e.g., a Wi-Fi connection), a wired connection (e.g., a digital subscriber line (DSL), a cable modem, etc.), or a combination of both suitable for obtaining encoded video stored on a file server. The encoded video can be transmitted from storage device 40 by streaming, downloading, or a combination of both.
[0098] The implementation environment shown in FIG1 is only one possible implementation method, and the technology of the embodiment of the present application is applicable not only to the source device 10 that can encode images and the destination device 20 that can decode encoded videos shown in FIG1 , but also to other devices that can encode videos and decode code streams, and the embodiment of the present application does not specifically limit this.
[0099] In the implementation shown in FIG1 , source device 10 includes a data source 120, an encoder 100, and an output interface 140. In some embodiments, output interface 140 may include a modem and / or a transmitter, where the transmitter may also be referred to as a transmitter. 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 sources of video.
[0100] The data source 120 may send a video to the encoder 100, and the encoder 100 may encode the video received from the data source 120 to generate an encoded video. The encoder may send the encoded video to an output interface. In some embodiments, the source device 10 directly sends the encoded video to the destination device 20 via the output interface 140. In other embodiments, the encoded video may also be stored on the storage device 40 for later retrieval by the destination device 20 for decoding and / or display.
[0101] In the implementation environment shown in FIG1 , 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 the link 30 and / or from the storage device 40, and then transmit the encoded video to the decoder 200. The decoder 200 may decode the received encoded video to obtain a 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 external to the destination device 20. Generally, the display device 220 displays the decoded video. The display device 220 may be any of a variety of 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 other types of display devices.
[0102] Although not shown in FIG1 , in some aspects, encoder 100 and decoder 200 can be integrated with an encoder and decoder, respectively, and can include appropriate multiplexer-demultiplexer (MUX-DEMUX) units or other hardware and software for encoding both audio and video in a common data stream or in separate data streams. In some embodiments, the MUX-DEMUX units can conform to the ITU H.223 multiplexer protocol, or other protocols such as the User Datagram Protocol (UDP), if applicable.
[0103] The encoder 100 and the decoder 200 can each be any 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 of the embodiments of the present application is implemented in part by software, the device can store instructions for the software in a suitable non-volatile computer-readable storage medium, and can use one or more processors to execute the instructions in hardware to implement the technology of the embodiments of the present application. Any of the foregoing (including hardware, software, a combination of hardware and software, etc.) can be regarded as one or more processors. Each of the encoder 100 and the decoder 200 can be included in one or more encoders or decoders, and any of the encoders or decoders can be integrated as part of a combined encoder / decoder (encoder / decoder) in the corresponding device.
[0104] Embodiments of the present application may generally refer to encoder 100 as "signaling" or "sending" certain information to another device, such as decoder 200. The term "signaling" or "sending" may generally refer to the transmission of syntax elements and / or other data used to decode the compressed video. This transmission may occur in real time or near real time. Alternatively, this communication may occur over time, such as when the syntax elements are stored in the encoded bitstream to a computer-readable storage medium during encoding, and the decoding device may then retrieve the syntax elements at any time after they are stored to this medium.
[0105] FIG2 is a schematic diagram of another implementation environment provided by an embodiment of the present application. This implementation environment includes an encoding end and a decoding end. The encoding end includes a video encoding module, a video encapsulation module, and a channel transmission module, and the decoding end includes a video decapsulation module and a video decoding module. It should be noted that the encoding end including the channel transmission module is merely an example. In actual applications, the decoding end may also include the channel transmission module, or the channel transmission module may not belong to the encoding end or the decoding end but be an independent unit. This embodiment of the present application does not limit this.
[0106] Each video frame image in the video to be encoded can be encoded by the video encoding module to obtain the video frame image's code stream or encoded file. The video encapsulation module then encapsulates the encoded file to convert it into a video format that is convenient for transmission. The encapsulated encoded file is then transmitted to the decoding end via the channel transmission module. The decoding end receives the transmitted encoded file, decapsulates it, and reconstructs it using the video decoding model to obtain a reconstructed video frame image.
[0107] Please refer to Figure 3. The video encoding module at the encoding end may include a text processing submodule, a position vector difference encoding submodule and a standard video encoding submodule. For the video frame image to be encoded, the text area in the video frame image can be aligned according to the target alignment size through the text processing submodule, and the text area includes at least one character. The position vector difference of the current block to be encoded in the aligned text area is determined by the position vector difference submodule, and then based on the target alignment size and the position vector difference of the current block, the position identification data and the first flag bit corresponding to the position vector difference are determined, and then the position identification data and the first flag bit corresponding to the position vector difference are encoded into the bitstream to achieve encoding of the position vector difference. The residual information and side information of the current block are also encoded into the bitstream through the standard video encoding submodule. The residual information indicates the prediction residual between the current block and the reference block, and the side information includes the target alignment size.
[0108] Optionally, the video frame image may also include a non-text area. The non-text area can be directly encoded into the bitstream through the standard video encoding submodule in a standard video encoding manner.
[0109] Referring to Figure 4 , the video decoding module at the decoding end may include a position vector difference decoding submodule, a standard video decoding submodule, and a text reconstruction submodule. The position vector difference decoding submodule can parse the bitstream to obtain the position identification data and first flag corresponding to the position vector difference of the current block to be decoded in the text region. The standard video decoding submodule can parse the bitstream to obtain the residual information and side information of the current block. Furthermore, based on the target alignment size and the position identification data and first flag corresponding to the position vector difference of the current block, the text reconstruction submodule can determine the position vector difference of the current block. Based on this residual information and the position vector difference, the current block in the text region can be reconstructed.
[0110] Optionally, for non-text areas, the standard video decoding submodule parses the non-text areas from the code stream in accordance with the standard video decoding method, and then reconstructs the text in the non-text areas and text areas to obtain a reconstructed video frame image.
[0111] It should be noted that the above-mentioned standard video codec method can be a video compression standard using a block-based hybrid video coding / compression structure, such as HEVC. Of course, other codec methods can also be used, and the embodiments of the present application do not limit this.
[0112] The encoding and decoding method provided in the embodiment of the present application can be applied to a variety of scenarios. For example, for video applications such as online conferencing and online education, text content often occupies a large part of the video content, and people's attention is also mainly focused on the text part. Therefore, it is very important to compress images containing text content. Next, the method for encoding and decoding images containing text content provided in the embodiment of the present application is introduced. It should be noted that, in combination with the implementation environment shown in Figures 1 and 2, any of the encoding methods below can be executed by the encoder 100 in the source device 10, or it can be executed by the video encoding module in Figure 2. Any of the decoding methods below can be executed by the decoder 200 in the destination device 20, or it can be executed by the video decoding module in Figure 2.
[0113] Next, the encoding and decoding method provided in the embodiments of the present application will be introduced in detail through multiple embodiments.
[0114] FIG5 is a flow chart of a first encoding method provided in an embodiment of the present application. Referring to FIG5 , the method includes the following steps.
[0115] Step 501: Acquire a target area, which is aligned according to a target alignment size.
[0116] In some embodiments, the target area is obtained by aligning a text area in the target image according to a target alignment size, and the text area includes at least one character.
[0117] That is, a text area in a target image may be determined, the text area including at least one character, and alignment processing is performed on the text area according to a target alignment size to obtain a target area.
[0118] Optionally, the target image is subjected to text recognition by a text recognition network model to obtain a text region in the target image. That is, the target image is used as the input of the text recognition network model, and the text recognition network model can output the text region in the target image based on the target image. Of course, in practical applications, the text region can also be determined by other means, for example, based on a projection image or pixel color. This embodiment of the present application is not limited to this.
[0119] In some embodiments, the position of the text region in the target image may also be determined. For example, while determining the text region in the target image using a text recognition network model, the position of the text region in the target image may also be determined.
[0120] The implementation process of aligning the text area includes: filling the text area in the target image based on the target alignment size to obtain a filled text area, and determining the target area based on the filled text area.
[0121] 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 area in the target image.
[0122] Since the target image can be encoded using related codecs, which typically divide the target image into CUs, and subsequent processing is performed based on the CUs, and the CU size can be one of 8, 16, 32, and 64, the size set can include 8, 16, 32, and 64. Of course, the size set can also be determined based on the CU size, with the sizes in the size set being no less than the CU size and being integer multiples of the CU size. For example, if the CU size is 8, the size set can include sizes 8 and 16. For another example, if the CU size is 32, the size set can include 32.
[0123] 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 and the vertical alignment size can be equal or unequal. For example, the horizontal alignment size is 16, and the vertical alignment size is 16. This embodiment of the present application is not limited to this.
[0124] When the target alignment size includes the horizontal alignment size and the vertical alignment size, the size of the text area in the target image includes the height and the width. When the target alignment size is greater than or equal to the size of the text area in the target image, it can be considered that the horizontal alignment size is greater than or equal to the width of the text area in the target image, and the vertical alignment size is greater than or equal to the height of the text area in the target image.
[0125] The implementation method of filling the text area in the target image based on the target alignment size to obtain the filled text area includes: determining the filling size based on the target alignment size and the size of the text area in the target image, and filling the text area in the target image based on the filling size so that the size of the filled text area is consistent with the target alignment size to obtain the filled text area.
[0126] 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 a height and a width, and the padding size includes a horizontal padding size and a vertical padding size. Thus, the horizontal padding size can be determined as the difference between the horizontal alignment size and the width of the text area, and the vertical padding size can be determined as the difference between the vertical alignment size and the height of the text area.
[0127] Based on the padding size, the text area in the target image is padded with the following methods: in the horizontal direction outside the text area (e.g., on the left and / or right side of the text area, not specifically limited), the padding height is equal to the vertical alignment size, and the width is equal to the preset pixel value of the horizontal padding size. In the vertical direction outside the text area (e.g., on the upper side and / or lower side of the text area, not specifically limited), the padding height is equal to the vertical padding size, and the width is equal to the preset pixel value of the horizontal alignment size.
[0128] Among them, the preset pixel value can be the pixel value of the background pixel in the text area except the character pixel, or it can be a default pixel value, such as 0 or 255, which is not limited in this embodiment of the present application.
[0129] It should be noted that if padding is applied to the left and right sides of the text area, the sum of the left and right padding sizes is the horizontal padding size. If padding is applied to the top and bottom sides of the text area, the sum of the top and bottom padding sizes is the vertical padding size.
[0130] Since the number of text regions in the target image can be one or more, the number of filled text regions can also be one or more. In the case of different numbers of filled text regions, the implementation methods for determining the target region based on the filled text regions are different, which will be introduced below.
[0131] If the number of filled text regions is one, then take this filled text region as the target region.
[0132] If the number of filled text regions is multiple, then in the order of these multiple filled text regions from left to right and from top to bottom in the target image, splice these multiple filled text regions in sequence to obtain the target region.
[0133] For ease of understanding, an example is given below to illustrate the above process of determining the target region.
[0134] As shown in Figure 6, the target image contains four characters "填", "报", "说", "明". Through the text recognition network model, perform text recognition on this target image to obtain four text regions, and these four text regions are respectively the regions corresponding to the four characters "填", "报", "说", "明". If the height and width of these four text regions are both 8, and the horizontal alignment dimension and vertical alignment dimension are both 16. In this case, taking the region corresponding to the character "填" as an example, please refer to Figure 7. The horizontal filling dimension and vertical filling dimension are both 16 - 8 = 8. Fill the right side outside this text region with a preset pixel value with a height of 16 and a width of 8, and fill the lower side outside the text region with a preset pixel value with a height of 8 and a width of 16 to obtain the filled text region. Then, in the order of the four characters "填", "报", "说", "明" from left to right and from top to bottom in the target image, splice these multiple filled text regions in sequence to obtain the target region in Figure 6.
[0135] It should be noted that the target image can be an independent image or any video frame image in a video, and the embodiments of this application do not limit this.
[0136] The above is introduced by taking the text region after alignment processing as the target region as an example. In practical applications, the target region is still obtained after alignment processing for other regions with character attributes in the target image. This character attribute means that the position vector points from one basic unit (i.e., the current block / current basic unit) to another basic unit with similar content (i.e., the reference block / reference basic unit). Usually, the reference basic units corresponding to two adjacent basic units are not the same, and there are significant differences in the position vectors of these two adjacent basic units. In the embodiments of this application, a character can be used as a basic unit. In practical applications, any region in the target image that conforms to the above character attributes can be used as a basic unit.
[0137] For example, if the target image contains multiple emoticons, these multiple emoticons meet the aforementioned character attributes. That is, the position vectors of the emoticon content point from one emoticon (i.e., the current block / current emoticon) to another emoticon with similar content (i.e., the reference block / reference emoticon), the reference emoticons corresponding to two adjacent emoticons are generally different, and the position vectors of the two adjacent emoticons differ significantly. In this case, the emoticons can be used as the basic unit, and the target area can be the result of aligning the emoticon area in the target image according to the target alignment size, where the emoticon area includes at least one emoticon. For another example, if the target image contains multiple sub-images, these multiple sub-images meet the aforementioned character attributes. That is, the position vectors of the sub-image content point from one sub-image (i.e., the current block / current sub-image) to another sub-image with similar content (i.e., the reference block / reference sub-image), the reference sub-images corresponding to two adjacent sub-images are generally different, and the position vectors of the two adjacent sub-images differ significantly. In this case, the sub-images can be used as the basic unit, and the target area can be the result of aligning sub-image sub-regions in the target image according to the target alignment size, where the sub-image area includes at least one sub-image.
[0138] It should be noted that the method for aligning the target image region with character attributes to obtain the target region is similar to the method for aligning the text region in the target image to obtain the target region described above, and will not be repeated here. Furthermore, since the target region is obtained after aligning the target image region with character attributes, there are many possible regions with character attributes in the target image. Therefore, for ease of description, the target region is described below using the aligned text region as an example.
[0139] In some embodiments, a target non-text area may also be determined, that is, the pixel values in the text area in the target image are filled with preset pixel values to obtain the target non-text area.
[0140] Step 502: Determine a position vector difference of a current block to be encoded in a target area, where the position vector difference indicates a difference between a position vector of the current block and a reference position vector, where the position vector of the current block indicates a positional relationship between the current block and a reference block corresponding to the current block.
[0141] Based on the current block to be encoded in the target area, according to the relevant algorithm, a reference block corresponding to the current block is determined, 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, according to the relevant prediction coding algorithm, a reference position vector corresponding to the position vector of the current block is determined, and the value of subtracting the reference position vector from the position vector of the current block is determined as the position vector difference of the current block.
[0142] Step 503: Based on the target alignment size and the position vector difference of the current block, determine the corresponding position identification data and the first flag bit of the position vector difference, the position identification data is a multiple of the position vector difference relative to the target alignment size or the position vector difference, and the first flag bit indicates the category of the position identification data.
[0143] 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.
[0144] In some embodiments, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, and the first flag bit includes a horizontal flag bit, where the horizontal flag bit indicates a category of the horizontal identification data. In this case, if the horizontal component is an integer multiple of the horizontal alignment size, then the multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, and the first numerical value is determined as the value of the horizontal flag bit.
[0145] 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, so that the horizontal component can be accurately encoded into the bitstream, ensuring the accuracy of the encoding and decoding of the horizontal component.
[0146] Further, if the horizontal component is not an integer multiple of the horizontal alignment size, the horizontal component is determined as horizontal identification data, and the second value is determined as the value of the horizontal flag bit.
[0147] 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, avoiding the situation where horizontal component encoding errors are caused by encoding the multiple of the horizontal component relative to the horizontal alignment size into the bitstream, thereby ensuring the accuracy of the encoding and decoding of the horizontal component.
[0148] In some embodiments, the target alignment dimension includes a vertical alignment dimension, the position vector difference includes a vertical component, the position identification data includes vertical identification data, and the first flag includes a vertical flag, where the vertical flag indicates a category of the vertical identification data. In this case, if the vertical component is an integer multiple of the vertical alignment dimension, the multiple of the vertical component relative to the vertical alignment dimension is determined as the vertical identification data, and the first numerical value is determined as the value of the vertical flag.
[0149] Similarly to the 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, so that the vertical component can be accurately encoded into the code stream, ensuring the accuracy of the encoding and decoding of the vertical component.
[0150] Further, if the vertical component is not an integer multiple of the vertical alignment size, the vertical component is determined as vertical identification data, and the second value is determined as the value of the vertical flag bit.
[0151] 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 directly determined 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 the bitstream, thereby ensuring the accuracy of the encoding and decoding of the vertical component.
[0152] The first value and the second value are pre-set, 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, the value may be adjusted according to different requirements in different situations.
[0153] As an example, the first value is 1, the second value is 0, and both the horizontal alignment size and the vertical alignment size are 16. The horizontal component is 16, and the vertical component is 64. For the horizontal component, 16 ÷ 16 = 1, that is, 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 is 1. For the vertical component, 64 ÷ 16 = 4, that is, 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 is 1.
[0154] As another example, the first value is 1, the second value is 0, the horizontal alignment size and the vertical alignment size are both 16, the horizontal component is 17, and the vertical component is 64. For the horizontal component, 17 ÷ 16 = 1.0625, that is, 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 is 0. For the vertical component, 64 ÷ 16 = 4, that is, 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 is 1.
[0155] It should be noted that if the position vector difference is not an integer multiple of the target alignment size, in addition to directly using the position vector difference as the position identification data, the quotient of the position vector difference divided by the target alignment size can also be determined as the position identification data, and the remainder of the position vector difference divided by the target alignment size can be determined as the first flag bit. In this case, the first value is 0.
[0156] Since the remainder of the position vector difference divided by the target alignment size is not necessarily 0 when the position vector difference is not an integer multiple of the target alignment size, the first value can be set to 0, so that the first flag can still indicate the category of the position identification data. Moreover, the quotient and remainder of the position vector difference divided 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. Therefore, even if the position vector difference is not an integer multiple of the target alignment size, the position vector can be accurately encoded with a smaller number of bits, while ensuring the encoding accuracy of the position vector difference and improving the encoding efficiency of images containing text content. Of course, when the position vector difference is not an integer multiple of the target alignment size, the position identification data and the first flag corresponding to the position vector difference can also be determined by other means, and the embodiments of the present application are not limited to this.
[0157] Step 504: Encode the position identification data and the first flag corresponding to the position vector difference into the bitstream.
[0158] In some embodiments, residual information of the current block may also be encoded into the bitstream, where the residual information indicates a prediction residual between the current block and a reference block.
[0159] Optionally, side information may also be encoded into the bitstream, and the side information includes the target alignment size. Furthermore, the side information also includes the position of the text area in the target image. For example, the position of the text area in the target image may be the horizontal and vertical coordinates of the upper left corner / lower left corner / upper right corner / lower right corner pixels of the text area in the target image. Of course, it may also be other coordinates in the text area that can determine the position of the text area in the target image, and the embodiments of the present application do not limit this. During decoding, the text area can be restored in the reconstructed image based on the position of the text area in the target image, thereby improving decoding efficiency.
[0160] It should be noted that when the target alignment size includes a horizontal alignment size and a vertical alignment size, if the horizontal alignment size is equal to the vertical alignment size, then when encoding the target alignment size into the bitstream, it is not necessary to encode both the horizontal alignment size and the vertical alignment size into the bitstream. Only one of the horizontal alignment size and the vertical alignment size needs to be encoded into the bitstream. This can effectively reduce the number of bits required to encode the side information and effectively improve coding efficiency.
[0161] In some embodiments, the side information can be encoded into the bitstream using differential coding, the residual information of the current block can be encoded into the bitstream using entropy coding, the first flag bit can be encoded into the bitstream using binary coding, and the position identification data can be encoded into the bitstream using exponential Golomb coding. Optionally, when a target non-text area is determined, the target non-text area can also be encoded into the bitstream. Of course, in actual applications, other encoding methods can also be used to encode the above information into the bitstream. This embodiment of the present application is not limited to this.
[0162] As an example, when the position vector difference is MVD, the coding syntax elements corresponding to the above coding method are shown in Table 1 below.
[0163] Table 1
[0164] As shown in Table 1, mvd_coding (x0, y0) indicates encoding the position vector difference of the current block with coordinates (x0, y0).
[0165] The original syntax of 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 position identification data is greater than 0. abs_mvd_greater0_flag[compIdx] can be 1 or 0. If the absolute value of the position identification data is greater than 0, abs_mvd_greater0_flag[compIdx] is 1 and 1 is encoded into the bitstream. Otherwise, abs_mvd_greater0_flag[compIdx] is 0 and 0 is encoded into the bitstream. In the case where the position identification data includes horizontal identification data and vertical identification data, compIdx can be 0 or 1. When compIdx is 0, it indicates horizontal identification data, and when compIdx is 1, it indicates vertical identification data. Therefore, abs_mvd_greater0_flag[0] indicates whether the absolute value of the horizontal identification data is greater than 0. If the absolute value of the horizontal identification data is greater than 0, 1 is encoded into the bitstream, otherwise 0 is encoded into the bitstream. abs_mvd_greater0_flag[1] indicates whether the absolute value of the vertical identification data is greater than 0. If the absolute value of the vertical identification data is greater than 0, 1 is encoded into the bitstream, otherwise 0 is encoded into the bitstream.
[0166] The original syntax of 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 position identification data is greater than 1. abs_mvd_greater1_flag[compIdx] can be 1 or 0. If the absolute value of the position identification data is greater than 1, abs_mvd_greater1_flag[compIdx] is 1 and 1 is encoded into the bitstream. Otherwise, abs_mvd_greater1_flag[compIdx] is 0 and 0 is encoded into the bitstream. In the case where the position identification data includes horizontal identification data and vertical identification data, compIdx can be 0 or 1. When compIdx is 0, it indicates horizontal identification data, and when compIdx is 1, it indicates vertical identification data. Therefore, abs_mvd_greater1_flag[0] indicates 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, 1 is encoded into the bitstream, otherwise 0 is encoded into the bitstream. abs_mvd_greater1_flag[1] indicates whether the absolute value of the vertical identification data is greater than 1. If the absolute value of the vertical identification data is greater than 1, 1 is encoded into the bitstream, otherwise 0 is encoded into the bitstream.
[0167] if(abs_mvd_greater0_flag[0])abs_mvd_greater1_flag[0] indicates that when the absolute value of the horizontal identification data is greater than 0, that is, when abs_mvd_greater0_flag[0] is 1, 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, 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.
[0168] The meaning of if(abs_mvd_greater0_flag[1])abs_mvd_greater1_flag[1] is similar to that of if(abs_mvd_greater0_flag[0])abs_mvd_greater1_flag[0] above. For details, please refer to the relevant content above and will not be repeated here.
[0169] The original syntax of 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] can be 1 or 0. If the first flag bit is equal to 1, mvd_ada_precision_flag[compIdx] is 1 and 1 is encoded into the codestream. Otherwise, mvd_ada_precision_flag[compIdx] is 0 and 0 is encoded into the codestream. In the case where the first flag bit includes a horizontal flag bit and a vertical flag bit, compIdx can 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 is equal to 1. If the horizontal flag is equal to 1, 1 is encoded into the code stream, otherwise 0 is encoded into the code stream. mvd_ada_precision_flag[1] indicates whether the vertical flag is equal to 1. If the vertical flag is equal to 1, 1 is encoded into the code stream, otherwise 0 is encoded into the code stream.
[0170] if(abs_mvd_greater0_flag[0])mvd_ada_precision_flag[0] indicates that when the absolute value of the horizontal identification data is greater than 0, that is, when abs_mvd_greater0_flag[0] is 1, it is determined whether the horizontal flag is equal to 1. If the horizontal flag is equal to 1, mvd_ada_precision_flag[0] is 1, and 1 is encoded into the bitstream. Otherwise, mvd_ada_precision_flag[0] is 0, and 0 is encoded into the bitstream.
[0171] The meaning of if(abs_mvd_greater0_flag[1])mvd_ada_precision_flag[1] is similar to that of if(abs_mvd_greater0_flag[0])mvd_ada_precision_flag[0] above. For details, please refer to the relevant content above and will not be repeated here.
[0172] The original syntax of mvd_sign_flag[0] and mvd_sign_flag[1] is mvd_sign_flag[compIdx]. mvd_sign_flag[compIdx] indicates the positive or negative sign of the position identification data. mvd_sign_flag[compIdx] can be 1 or 0. If the position identification data is a positive value, mvd_sign_flag[compIdx] is determined to be equal to 0, and 0 is encoded into the bitstream. If the position identification data is a negative value, mvd_sign_flag[compIdx] is determined to be equal to 1, and 1 is encoded into the bitstream. In the case where the position identification data includes horizontal identification data and vertical identification data, compIdx can be 0 or 1. When compIdx is 0, it indicates horizontal identification data, and when compIdx is 1, it indicates vertical identification data. Therefore, mvd_sign_flag[0] indicates the positive or negative sign of the horizontal identification data. When the horizontal identification data is a positive value, 0 is encoded into the bitstream, otherwise 1 is encoded into the bitstream. mvd_sign_flag[1] indicates the positive or negative value of the vertical identification data. If the vertical identification data is positive, 0 is encoded into the code stream; otherwise, 1 is encoded into the code stream.
[0173] The original syntax of abs_mvd_minus2[0] and abs_mvd_minus2[1] is abs_mvd_minus2[compIdx]. abs_mvd_minus2[compIdx] represents the value after the absolute value of the position identification data is subtracted by 2, that is, the value after the absolute value of the position identification data is subtracted by 2 is encoded into the bitstream. In the case where the position identification data includes horizontal identification data and vertical identification data, compIdx can be 0 or 1. When compIdx is 0, it represents horizontal identification data, and when compIdx is 1, it represents vertical identification data. Therefore, abs_mvd_minus2[0] indicates the value after the absolute value of the horizontal identification data is subtracted by 2. abs_mvd_minus2[0] indicates the value after the absolute value of the vertical identification data is subtracted by 2.
[0174] if(abs_mvd_greater0_flag[0]){mvd_sign_flag[0]if(abs_mvd_greater1_flag[0])abs_mvd_minus2[0]} means that when the absolute value of the horizontal identification data is greater than 0, that is, when abs_mvd_greater0_flag[0] is 1, the positive or negative sign of the horizontal identification data is determined, and when the horizontal identification data is positive, 0 is encoded into the bitstream, otherwise 1 is encoded into the bitstream, and when the absolute value of the horizontal identification data is greater than 1, that is, when abs_mvd_greater1_flag[0] is 1, the value obtained by subtracting 2 from the absolute value of the horizontal identification data is determined, and the value obtained by subtracting 2 from the absolute value of the horizontal identification data is encoded into the bitstream.
[0175] The meaning of if(abs_mvd_greater0_flag[1]){mvd_sign_flag[1]if(abs_mvd_greater1_flag[1])abs_mvd_minus2[1]} is similar to that of if(abs_mvd_greater0_flag[0]){mvd_sign_flag[0]if(abs_mvd_greater1_flag[0])abs_mvd_minus2[0]} above. For details, please refer to the relevant content above and will not be repeated here.
[0176] For a target image containing text content, after aligning the text area in the target image according to the target alignment size to obtain the target area, the vertical component and the horizontal component can be encoded separately based on the target alignment size. In the case where 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 encoded into the bitstream as position identification data. Since 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, encoding the multiple of the position vector difference relative to the target alignment size as position identification data into the bitstream can ensure the accuracy of the encoded position vector difference while effectively reducing the number of bits required to encode the position vector difference, thereby ensuring a high encoding efficiency for images containing text content.
[0177] In an embodiment of the present application, if the position vector difference is not an integer multiple of the target alignment size, the quotient of the position vector difference divided by the target alignment size may be determined as position identification data, and the remainder of the position vector difference divided by the target alignment size may be determined as the first flag bit. Because the quotient and remainder of the position vector difference divided 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, even if the position vector difference is not an integer multiple of the target alignment size, the position vector can be accurately encoded with a smaller number of bits, thereby improving the encoding efficiency of images containing text content while ensuring the accuracy of the encoding of the position vector difference.
[0178] In addition, the encoding method provided in the embodiment of the present application can be combined with the standard video encoding method without affecting the standard video encoding process. That is to say, the encoding provided in the embodiment of the present application is highly portable and can improve the encoding efficiency of images containing text content without increasing additional hardware costs.
[0179] FIG8 is a flowchart of a first decoding method provided in an embodiment of the present application. This decoding method corresponds to the encoding method shown in FIG5 above. Referring to FIG8 , this method includes the following steps.
[0180] Step 801: Parse the code stream 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 target area.
[0181] Among them, the position vector difference indicates the difference between the position vector of the current block and the reference position vector, the position vector of the current block indicates the position 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 relative to the target alignment size or the position vector difference, and the first flag indicates the category of the position identification data.
[0182] Step 802: Determine the position vector difference based on the target alignment size, the position identification data and the first flag bit.
[0183] In some embodiments, when the side information includes the target alignment size and the side information is encoded into the bitstream, the side information can also be parsed from the bitstream to obtain the target alignment size.
[0184] In other embodiments, the encoding side and the decoding side store the target alignment size, that is, the target alignment size is determined in advance by the encoding side and the decoding side. In this case, the decoding side can directly obtain the target alignment size without encoding the target alignment size into the bitstream, thereby effectively reducing the number of bits in the bitstream, reducing the time required for decoding, and effectively improving decoding efficiency.
[0185] In some embodiments, the position vector difference may be determined based on the value of the first flag bit, the target alignment size, and the position identification data.
[0186] In some embodiments, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag bit includes a horizontal flag bit, and the horizontal flag bit indicates a category of the horizontal identification data. In this case, if the value of the horizontal flag bit is a 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 a second value, the horizontal identification data is determined to be the horizontal component.
[0187] When the value of the horizontal flag 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, the horizontal alignment size is multiplied by the horizontal identification data to obtain the horizontal component. When the value of the horizontal flag is the second value, it indicates that the horizontal identification data is the horizontal component. Therefore, the horizontal identification data can be directly determined as the horizontal component.
[0188] In other embodiments, the target alignment dimension includes a vertical alignment dimension, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag includes a vertical flag, and the vertical flag indicates a category of the vertical identification data. In this case, if the value of the vertical flag is a first value, the vertical alignment dimension is multiplied by the vertical identification data to obtain the vertical component. If the value of the vertical flag is a second value, the vertical identification data is determined as the vertical component.
[0189] Similarly, when the value of the vertical flag 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, the vertical alignment size is multiplied by the vertical identification data to obtain the vertical component. When the value of the vertical flag is the second value, it indicates that the vertical identification data is the vertical component. Therefore, the vertical identification data can be directly determined as the vertical component.
[0190] As an example, if both the horizontal alignment size and the vertical alignment size are 16, the horizontal flag bit and the vertical flag bit are both 1, the horizontal flag data is 1, and the vertical flag data is 4. In this case, the horizontal component is equal to the horizontal flag data multiplied by the horizontal alignment size, which is 16. The vertical component is equal to the vertical flag data multiplied by the vertical alignment size, which is 64.
[0191] As another example, if both the horizontal alignment size and the vertical alignment size are 16, the horizontal flag bit is 0, the vertical flag bit is 1, the horizontal flag data is 17, and the vertical flag data is 4. In this case, the horizontal component is equal to the horizontal flag data, that is, 17. The vertical component is equal to the vertical flag data multiplied by the vertical alignment size, that is, 64.
[0192] Based on the above description, if during the encoding process, the position vector difference is not an integer multiple of the target alignment size, the quotient of dividing the position vector difference by the target alignment size is determined as the position identification data, and the remainder of dividing the position vector difference by the target alignment size is determined as the value of the first flag. Correspondingly, during the decoding process, if the first flag is not 0, the position identification data can be multiplied by the target alignment size and then added to the value of the first flag to obtain the position vector difference.
[0193] Step 803: Reconstruct the current block based on the position vector difference of the current block.
[0194] In some embodiments, residual information of the current block can also be parsed from the bitstream, where the residual information indicates a prediction residual between the current block and the reference block. In this case, the current block can be reconstructed based on the position vector difference and the residual information.
[0195] Based on the position vector difference, according to the relevant algorithm, the position vector of the current block is determined, and based on the position vector of the current block and the residual information of the current block, according to the relevant algorithm, the current block is reconstructed, thereby realizing reconstruction of the target area.
[0196] Optionally, when the target non-text area is encoded into the bitstream, the target non-text area may be reconstructed based on the bitstream to obtain a reconstructed target non-text area.
[0197] Optionally, after the target area is reconstructed, a target image may be reconstructed based on the target area and the target non-text area.
[0198] The implementation process of reconstructing the target image based on the target area and the target non-text area includes: determining the text area in the target image based on the target area, and reconstructing the target image based on the text area and the target non-text area in the target image.
[0199] Optionally, the target area can be identified by a text recognition network model to obtain the text area in the target image. That is, the target area is used as the input of the text recognition network model, and the text recognition network model can output the text area in the target area based on the target area. Of course, in actual applications, the text area can also be determined by other methods. The embodiments of the present application are not limited to this.
[0200] Optionally, the side information also includes the position of the text region in the target image. In this case, the region in the target non-text region that coincides with the position of the text region can be replaced with the text region to obtain a reconstructed target image. Of course, in practical applications, the target image can also be reconstructed using other methods. This embodiment of the present application is not limited to this.
[0201] As an example, when the position vector difference is MVD, the decoding syntax elements corresponding to the above decoding method are shown in Table 2 below.
[0202] Table 2
[0203] As shown in Table 2, mvd_decoding(x0, y0) indicates decoding the position vector difference of the current block with coordinates (x0, y0).
[0204] The original syntax of 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. In the case where the position identification data includes horizontal identification data and vertical identification data, compIdx can be 0 or 1. When compIdx is 0, it represents the horizontal identification data, and when compIdx is 1, it represents the vertical identification data. Therefore, abs_mvd_org[0] represents the absolute value of the horizontal identification data. abs_mvd_org[1] represents the absolute value of the vertical identification data.
[0205] When the target alignment size includes a horizontal alignment size and a vertical alignment size, 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. Since the target alignment size is encoded into the bitstream as side information, and the number of shift bits corresponding to the target alignment size is related to the target alignment size, when the target alignment size is encoded into the bitstream, it can be considered that the number of shift bits corresponding to the target alignment size is also encoded into the bitstream. Therefore, when encoding the position vector difference, it is not necessary to encode the number of shift bits corresponding to the target alignment size.
[0206] The number of shift bits corresponding to the target alignment size is related to the number of binary digits of the target alignment size. Optionally, the number of shift bits corresponding to the target alignment size is equal to the number of binary digits of the target alignment size minus 1. Of course, the number of shift bits corresponding to the target alignment size can also be determined by other methods, which are not limited in this embodiment of the present application.
[0207] The rest of the syntax in Table 2 that is similar to that in Table 1 will not be described here in detail. For details, please refer to the corresponding content in Table 1.
[0208] Next, the decoding process shown in Table 2 is introduced:
[0209] abs_mvd_greater0_flag[0] and abs_mvd_greater0_flag[1] represent the values of abs_mvd_greater0_flag[0] and abs_mvd_greater0_flag[1] parsed from the bitstream.
[0210] 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 parsed from the bitstream. Otherwise, the horizontal flag data is determined to be 0.
[0211] 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 parsed from the bitstream. Otherwise, the vertical flag data is determined to be 0.
[0212] if(abs_mvd_greater0_flag[0])mvd_ada_precision_flag[0] indicates that if the value of abs_mvd_greater0_flag[0] is 1, the value of mvd_ada_precision_flag[0] is parsed from the bitstream. Otherwise, the horizontal identification data is determined to be 0.
[0213] if(abs_mvd_greater0_flag[1])mvd_ada_precision_flag[1] indicates that if the value of abs_mvd_greater0_flag[1] is 1, the value of mvd_ada_precision_flag[1] is parsed from the code stream. Otherwise, the vertical identification data is determined to be 0.
[0214] The syntax of lines 12 to 20 in Table 2 above 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 parsed from the bitstream. If mvd_ada_precision_flag[0] is 1, the binary value of the value obtained by adding 2 to abs_mvd_minus2[0] is determined, and the value after the binary value is shifted left by the number of 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 parsed from the bitstream.
[0215] The syntax of lines 21 to 29 in Table 2 above has similar meanings to the syntax of lines 12 to 20 in Table 2. For details, please refer to the relevant content above and will not be repeated here.
[0216] In the case where the position identification data includes horizontal identification data and vertical identification data, based on the encoding syntax shown in Table 2 above, during decoding, the value of the position vector difference can be calculated by the following expression (1): Mvd[compIdx] = abs_mvd_greater0_flag[compIdx] * abs_mvd_org[compIdx] * (1–2*mvd_sign_flag[compIdx]) (1)
[0217] In the above expression (1), 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] parsed from 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] parsed from the bitstream.
[0218] Because the coding bits required for a multiple of the position vector difference relative to the target alignment size are smaller than the coding bits required for the position vector difference of the current block, when 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 decoding efficiency of images containing text content can be improved while ensuring decoding accuracy. In addition, if during the encoding process, the position vector difference is not an integer multiple of the target alignment size, the quotient of the position vector difference divided by the target alignment size is determined as the position identification data, and the remainder of the position vector difference divided by the target alignment size is determined as the value of the first flag bit. Because the coding bits required for the quotient and remainder of the position vector difference divided by the target alignment size are smaller than the coding bits required for the position vector difference of the current block, when the first flag bit is not the first value, the efficiency of decoding the position identification data is also higher than the efficiency of decoding the position vector difference. Therefore, the decoding efficiency of images containing text content can be improved while ensuring decoding accuracy.
[0219] The decoding method provided in the embodiment of the present application can be combined with the standard video decoding method without affecting the standard video decoding process. That is to say, the decoding provided in the embodiment of the present application is highly portable and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.
[0220] The embodiment of the present application also provides a second encoding method, which includes the following steps.
[0221] Step 901: Acquire a target area, which is obtained by aligning a target image according to a target alignment size.
[0222] For the implementation method of obtaining the target area, please refer to the relevant content in the first encoding method above, which will not be repeated here.
[0223] Step 902: Determine a position vector difference of a current block to be encoded in a target area, where the position vector difference indicates a difference between a position vector of the current block and a reference position vector, where the position vector of the current block indicates a positional relationship between the current block and a reference block corresponding to the current block.
[0224] For the implementation method of determining the position vector difference of the current block to be encoded in the target area, please refer to the relevant content in the first encoding method above, which will not be repeated here.
[0225] 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 corresponding to the position vector difference, the position identification data is a multiple of the position vector difference relative to the target alignment size or the position vector difference, and the first flag indicates the category of the position identification data.
[0226] 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.
[0227] In some embodiments, the target alignment dimension includes a horizontal alignment dimension and a vertical alignment dimension, 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 dimension is determined as the horizontal identification data, a multiple of the vertical component relative to the vertical alignment dimension is determined as the vertical identification data, and the first numerical value is determined as the value of the first flag bit.
[0228] 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, the multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data, and the first numerical value is determined as the value of the first flag bit.
[0229] 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 also 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 component and the vertical component can be accurately encoded into the bitstream, ensuring the accuracy of the encoding and decoding of the horizontal component and the vertical component.
[0230] Further, 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 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.
[0231] When 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 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. This can avoid the situation where horizontal component encoding errors are caused by encoding the multiple of the horizontal alignment size of the horizontal component into the code stream, and / or the situation where vertical component encoding errors are caused by encoding the multiple of the vertical alignment size of the vertical component into the code stream, thereby ensuring the accuracy of encoding and decoding of the horizontal and vertical components.
[0232] The first value and the second value are pre-set, 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, the value may be adjusted according to different requirements in different situations.
[0233] As an example, the first value is 1, the second value is 0, the horizontal alignment size and the vertical alignment size are both 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, that is, 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 flag data is 1, the vertical flag data is 4, and the value of the first flag bit is 1.
[0234] As an example, the first value is 1, the second value is 0, the horizontal alignment size and the vertical alignment size are both 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, that is, 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.
[0235] It should be noted that 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 the horizontal identification data and the vertical component as the vertical identification data, the quotient obtained by dividing the horizontal component by the horizontal alignment size can also be 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. In this case, the first flag bit is used to distinguish between two different methods of determining the position identification data.
[0236] Since the quotient and remainder of the position vector difference divided 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, even if the position vector difference is not an integer multiple of the target alignment size, the position vector can be accurately encoded with a smaller number of bits, thereby improving the encoding efficiency of images containing text content while ensuring the accuracy of the encoding of the position vector difference. Of course, when 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 position identification data and the first flag bit can also be determined by other means, which is not limited in this embodiment of the present application.
[0237] Step 904: Encode the position identification data and the first flag corresponding to the position vector difference into the bitstream.
[0238] For the implementation method of encoding the position identification data and the first flag corresponding to the position vector difference into the bitstream, please refer to the relevant content in the first encoding method above, which will not be repeated here.
[0239] As an example, when the position vector difference is MVD, the coding syntax elements corresponding to the second coding method are shown in Table 3.
[0240] Table 3
[0241] In Table 3 above, mvd_ada_precision_flag indicates whether the first flag bit is equal to 1. mvd_ada_precision_flag can be 1 or 0. If the first flag bit is equal to 1, mvd_ada_precision_flag is 1 and 1 is encoded into the bitstream; otherwise, mvd_ada_precision_flag is 0 and 0 is encoded into the bitstream.
[0242] if(abs_mvd_greater0_flag[0]||abs_mvd_greater0_flag[1])mvd_ada_precision_flag indicates that when the absolute value of the horizontal identification data is greater than 0 and the absolute value of the vertical horizontal identification data is greater than 0, that is, when abs_mvd_greater0_flag[0] is 1 and abs_mvd_greater0_flag[1] is 1, it is determined whether the first flag bit is equal to 1. If the first flag bit is equal to 1, mvd_ada_precision_flag is 1, and 1 is encoded into the code stream. Otherwise, mvd_ada_precision_flag is 0, and 0 is encoded into the code stream.
[0243] The rest of the syntax in Table 3 that is similar to that in Table 1 will not be described here in detail. For details, please refer to the corresponding content in Table 1.
[0244] For a target image containing textual content, after aligning the target image according to the target alignment size to obtain a target area, when 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 integer multiples of the horizontal component and the vertical component, respectively, are encoded into the bitstream as position identification data. Because the 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 the 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, encoding the position identification data corresponding to the position vector difference into the bitstream can effectively reduce the number of bits required to encode the position vector difference while ensuring the accuracy of the encoded position vector difference, thereby ensuring high encoding efficiency for images containing textual content.
[0245] In an embodiment of the present application, 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 can 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 numerical value is determined as the value of the first flag bit. Since the quotient and remainder of the position vector difference divided 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, even if the position vector difference is not an integer multiple of the target alignment size, the position vector can be accurately encoded with a smaller number of bits, while ensuring the accuracy of the encoding of the position vector difference, the encoding efficiency of the image containing text content is improved.
[0246] In addition, the encoding method provided in the embodiment of the present application can be combined with the standard video encoding method without affecting the standard video encoding process. That is to say, the encoding provided in the embodiment of the present application is highly portable and can improve the encoding efficiency of images containing text content without increasing additional hardware costs.
[0247] An embodiment of the present application also provides a second decoding method, which corresponds to the above-mentioned second encoding method and includes the following steps.
[0248] Step 1001: Parse the code stream 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 target area.
[0249] Among them, the position vector difference indicates the difference between the position vector of the current block and the reference position vector, the position vector of the current block indicates the position 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 relative to the target alignment size or the position vector difference, and the first flag indicates the category of the position identification data.
[0250] Step 1002: Determine the position vector difference of the current block based on the target alignment size, the position identification data and the first flag bit.
[0251] Optionally, the position vector difference may be determined based on the value of the first flag bit, using the target alignment size and the position identification data.
[0252] In some embodiments, the target alignment dimension includes a horizontal alignment dimension and a vertical alignment dimension, 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 is a first value, the horizontal alignment dimension is multiplied by the horizontal identification data to obtain the horizontal component, and the vertical alignment dimension is multiplied by the vertical identification data to obtain the vertical component. If the value of the first flag is a second value, the horizontal identification data is determined to be the horizontal component, and the vertical identification data is determined to be the vertical component.
[0253] When the value of the first flag is a first numerical value, it indicates that the position identification data is a multiple of the position vector difference relative to the target alignment size. Therefore, 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. When the value of the horizontal flag is a second numerical value, it indicates that the position identification data is the position vector difference. Therefore, the horizontal identification data can be directly determined as the horizontal component, and the vertical identification data can be directly determined as the vertical component.
[0254] As an example, the horizontal alignment size and the vertical alignment size are both 16, the horizontal identification data is 1, the vertical identification data is 4, and the value of the first flag bit is the first numerical value 1. In this case, the horizontal component is the horizontal identification data multiplied by the horizontal alignment size, that is, 16. The vertical component is the vertical identification data multiplied by the vertical alignment size, that is, 64.
[0255] As another example, the horizontal alignment size and the vertical alignment size are both 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, that is, 17. The vertical component is the vertical identification data, that is, 64.
[0256] Based on the above description, if during the encoding process, 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, 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. Accordingly, during the decoding process, if the first flag is the second value, the quotient included in the horizontal identification data can be multiplied by the horizontal alignment size and the remainder is added to obtain the horizontal component, and the quotient included in the vertical identification data can be multiplied by the vertical alignment size and the remainder is added to obtain the vertical component.
[0257] Step 1003: Reconstruct the current block based on the position vector difference.
[0258] For the implementation method of reconstructing the current block, please refer to the relevant content in the first encoding method, which will not be repeated here.
[0259] As an example, when the position vector difference is MVD, the decoding syntax elements corresponding to the above decoding method are shown in Table 4 below.
[0260] Table 4
[0261] The syntax of Table 4 above is similar to that of Tables 1-3, and will not be repeated here. For details, please refer to the corresponding relevant content of Tables 1-3.
[0262] After obtaining the values of abs_mvd_greater0_flag[compIdx], abs_mvd_org[compIdx], and mvd_sign_flag[compIdx], the value of the position vector difference can be calculated by the above expression (1).
[0263] Because the encoding bits required for a multiple of the position vector difference relative to the target alignment size are less than the encoding bits required for the position vector difference of the current block, 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 decoding efficiency of images containing text content can be improved while ensuring decoding accuracy. In addition, if during the encoding process, 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, 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. Because 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. Therefore, the decoding efficiency of images containing text content can be improved while ensuring decoding accuracy.
[0264] In addition, the decoding method provided in the embodiment of the present application can be combined with the standard video decoding method without affecting the standard video decoding process. That is to say, the decoding provided in the embodiment of the present application is highly portable and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.
[0265] The present application also provides a third encoding method, which includes the following steps.
[0266] Step 1101: Acquire a target area, which is obtained by aligning a target image according to a target alignment size.
[0267] For the implementation method of obtaining the target area, please refer to the relevant content in the first encoding method above, which will not be repeated here.
[0268] Step 1102: Determine a position vector difference of a current block to be encoded in a target area, where the position vector difference indicates a difference between a position vector of the current block and a reference position vector, where the position vector of the current block indicates a positional relationship between the current block and a reference block corresponding to the current block.
[0269] For the implementation method of determining the position vector difference of the current block to be encoded in the target area, please refer to the relevant content in the first encoding method above, which will not be repeated here.
[0270] 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 corresponding to the position vector difference, the position identification data is a multiple of the position vector difference relative to the target alignment size or the position vector difference, and the first flag indicates the category of the position identification data.
[0271] In some embodiments, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, and the first flag includes a horizontal flag, which is further used in conjunction 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.
[0272] Since the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size can accurately represent the horizontal component, the quotient obtained by dividing the horizontal component by the horizontal alignment size can be determined as the 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, so that the horizontal component can be accurately encoded into the bitstream, thereby ensuring the accuracy of the encoding and decoding of the horizontal component.
[0273] In other embodiments, the target alignment dimension includes a vertical alignment dimension, the position vector difference includes a vertical component, the position identification data includes vertical identification data, and the first flag includes a vertical flag, which is further used in conjunction 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 dimension is determined as the vertical identification data, and the remainder obtained by dividing the vertical component by the vertical alignment dimension is determined as the value of the vertical flag.
[0274] Since the quotient and remainder obtained by dividing the vertical component by the vertical alignment size can accurately represent the vertical component, the quotient obtained by dividing the vertical component by the vertical alignment size can be determined as the 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, so that the vertical component can be accurately encoded into the bitstream, ensuring the accuracy of the encoding and decoding of the vertical component.
[0275] As an example, if both the horizontal alignment size and the vertical alignment size are 16, the horizontal component is 16 and the vertical component is 64. For the horizontal component, 16 ÷ 16 = 1, that is, the quotient of the horizontal component divided by the horizontal alignment size is 1, and the remainder is 0. For the vertical component, 64 ÷ 16 = 4, that is, the quotient of the vertical component divided by the vertical alignment size is 4, and the remainder is 0.
[0276] As another example, the first value is 1, the second value is 0, and both the horizontal alignment size and the vertical alignment size are 16. The horizontal component is 17, and the vertical component is 64. For the horizontal component, 17 ÷ 16 = 1…1, that is, the quotient of the horizontal component divided by the horizontal alignment size is 1, and the remainder is 1. For the vertical component, 64 ÷ 16 = 4, that is, the quotient of the vertical component divided by the vertical alignment size is 4, and the remainder is 0.
[0277] Step 1104: Encode the position identification data and the first flag corresponding to the position vector difference into the bitstream.
[0278] For the implementation method of encoding the position identification data and the first flag corresponding to the position vector difference into the bitstream, please refer to the relevant content in the first encoding method above, which will not be repeated here.
[0279] As an example, when the position vector difference is MVD, the coding syntax elements corresponding to the third coding method are shown in Table 5.
[0280] Table 5
[0281] Among them, in the above Table 5, the original syntax of 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 after the absolute value of the quotient included in the position identification data is subtracted by 2, that is, the value after the absolute value of the quotient included in the position identification data is subtracted by 2 is encoded into the bitstream. In the case where the position identification data includes horizontal identification data and vertical identification data, compIdx can be 0 or 1. When compIdx is 0, it represents horizontal identification data, and when compIdx is 1, it represents vertical identification data. Therefore, abs_mvd_mul_minus2[0] represents the value after the absolute value of the quotient included in the horizontal identification data is subtracted by 2. abs_mvd_mul_minus2[1] represents the value after the absolute value of the quotient included in the vertical identification data is subtracted by 2.
[0282] The original syntax of abs_mvd_rem[0] and abs_mvd_rem[1] is abs_mvd_rem[compIdx]. abs_mvd_rem[compIdx] represents the remainder included in the position identification data, and the remainder included in the position identification data is encoded into the bitstream. In the case where the position identification data includes horizontal identification data and vertical identification data, compIdx can be 0 or 1. When compIdx is 0, it represents the horizontal identification data, and when compIdx is 1, it represents the vertical identification data. Therefore, abs_mvd_rem[0] represents the remainder included in the horizontal identification data. abs_mvd_rem[1] represents the remainder included in the vertical identification data.
[0283] The rest of the syntax in Table 5 that is similar to that in Table 1 will not be described here in detail. For details, please refer to the corresponding content in Table 1.
[0284] For a target image containing textual content, after aligning the target image according to the target alignment size to obtain the target region, the quotient and remainder of the position vector difference divided by the target alignment size are directly determined as the position identification data and the first flag bit, respectively. Because the quotient and remainder of the position vector difference divided 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, encoding the quotient and remainder of the position vector difference divided by the target alignment size into the bitstream can effectively reduce the number of bits required to encode the position vector difference while ensuring the accuracy of the encoded position vector difference, thereby ensuring high encoding efficiency for images containing textual content.
[0285] In addition, the encoding method provided in the embodiment of the present application can be combined with the standard video encoding method without affecting the standard video encoding process. That is to say, the encoding provided in the embodiment of the present application is highly portable and can improve the encoding efficiency of images containing text content without increasing additional hardware costs.
[0286] An embodiment of the present application also provides a third decoding method, which corresponds to the third encoding method mentioned above and includes the following steps.
[0287] Step 1201: Parse the code stream 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 target area.
[0288] Among them, the position vector difference indicates the difference between the position vector of the current block and the reference position vector, the position vector of the current block indicates the position 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 relative to the target alignment size or the position vector difference, and the first flag indicates the category of the position identification data.
[0289] Step 1202: Determine the position vector difference based on the target alignment size, the position identification data corresponding to the position vector difference, and the first flag bit.
[0290] In some embodiments, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, and the first flag includes a horizontal flag, which is further used in conjunction with the horizontal identification data to indicate the horizontal component. In this case, the horizontal component is obtained by multiplying a quotient included in the horizontal identification data by the horizontal alignment size and then adding the quotient to the value of the horizontal flag.
[0291] In other embodiments, the target alignment dimension includes a vertical alignment dimension, the position vector difference includes a vertical component, the position identification data includes vertical identification data, and the first flag includes a vertical flag, which is further used in conjunction with the vertical identification data to indicate the vertical component. In this case, the vertical component is obtained by multiplying the quotient of the vertical identification data by the vertical alignment dimension and then adding the resultant quotient to the value of the vertical flag.
[0292] Step 1203: Reconstruct the current block based on the position vector difference.
[0293] For the implementation method of reconstructing the current block, please refer to the relevant content in the first encoding method, which will not be repeated here.
[0294] As an example, when the position vector difference is MVD, the decoding syntax elements corresponding to the above decoding method are shown in Table 6 below.
[0295] Table 6
[0296] The syntax of Table 6 is similar to that of Table 1, Table 2, and Table 5, and is not repeated here. For details, please refer to the corresponding content of Table 1, Table 2, and Table 5.
[0297] After obtaining the values of abs_mvd_greater0_flag[compIdx], abs_mvd_org[compIdx], and mvd_sign_flag[compIdx], the value of the position vector difference can be calculated by the above expression (1).
[0298] Since the position identification data and the first flag bit corresponding to the position vector difference are the quotient and remainder of the position vector difference divided by the target alignment size, 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, during 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, the decoding efficiency of images containing text content can be improved while ensuring the decoding accuracy.
[0299] In addition, the decoding method provided in the embodiment of the present application can be combined with the standard video decoding method without affecting the standard video decoding process. That is to say, the decoding provided in the embodiment of the present application is highly portable and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.
[0300] The present application also provides a fourth encoding method, which includes the following steps.
[0301] Step 1301: Acquire a target area, which is obtained by aligning a target image according to a target alignment size.
[0302] For the implementation method of obtaining the target area, please refer to the relevant content in the first encoding method above, which will not be repeated here.
[0303] Step 1302: Determine a position vector difference of a current block to be encoded in a target area, where the position vector difference indicates a difference between a position vector of the current block and a reference position vector, where the position vector of the current block indicates a positional relationship between the current block and a reference block corresponding to the current block.
[0304] In some embodiments, a first candidate position vector difference and a second candidate position vector difference are determined for the current block, the first candidate position vector difference being determined according to a first pixel precision, and the second candidate position vector being determined according to a second pixel precision, the first pixel precision being an integer, and the second pixel precision being a multiple of a target alignment size. A rate-distortion cost of the first candidate position vector difference and a rate-distortion cost of the second candidate position vector difference are determined, and the candidate position vector difference with the lower rate-distortion cost of the first candidate position vector difference and the second candidate position vector difference is determined as the position vector difference for the current block.
[0305] In some embodiments, based on the current block to be encoded in the target area, a first position vector and a second position vector are determined according to a relevant algorithm with a first pixel precision and a second pixel precision, respectively. The first position vector refers to the relative displacement between the current block and the first reference block. The first reference block is a reference block corresponding to the current block determined based on the first pixel precision. The second position vector refers to the relative displacement between the current block and the second reference block. The second reference block is a reference block corresponding to the current block determined based on the second pixel precision.
[0306] Based on the first position vector, a first reference position vector corresponding to the first position vector is determined according to a correlation prediction coding algorithm, and a value obtained by subtracting the first reference position vector from the first position vector is determined as a first candidate position vector difference, where the first reference position vector is determined based on a first pixel precision. Based on the second position vector, a second reference position vector corresponding to the second position vector is determined according to a correlation prediction coding algorithm, and a value obtained by subtracting the second reference position vector from the second position vector is determined as a second candidate position vector difference, where the second reference position vector is determined based on a second pixel precision.
[0307] Based on the first candidate position vector difference, a rate-distortion cost of the first position vector difference is determined according to a related algorithm. Based on the second candidate position vector difference, a rate-distortion cost of the second position vector difference is determined according to a related algorithm.
[0308] In some embodiments, the first position vector and the second position vector may be determined according to a motion search algorithm. Of course, the first position vector and the second position vector may also be determined according to other algorithms, which are not limited in this embodiment of the present application.
[0309] Based on the above description, the encoder uses a motion search algorithm to find a reference block corresponding to the current block from the encoded reference image. 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 these multiple blocks according to a certain pixel precision. For example, if the second pixel precision is 16 and the coordinates of the current block are (50, 21), the motion search algorithm is used based on the coordinates of the current block and with a step size of 16 to determine the second reference block. The relative displacement between the current block and the second reference block is determined as a second position vector. Since the second reference block is found by searching based on the coordinates of the current block with a step size of 16, the relative displacement between the current block and the second reference block must be a multiple of the second pixel precision. In other words, the second position vector must be a multiple of the second pixel precision. Similarly, the second reference position vector is also determined based on the second pixel precision and is also a multiple of the second pixel precision. Therefore, the second candidate position vector difference is also a multiple of the second pixel precision.
[0310] 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 the vertical pixel precision may be the same or different, and this is not limited in this embodiment of the present application. If 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, with the horizontal pixel precision as the step size in the horizontal direction and the vertical pixel precision as the step size in the vertical direction, using a motion search algorithm.
[0311] 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 corresponding to the position vector difference, the position identification data is a multiple of the position vector difference relative to the target alignment size or the position vector difference, and the first flag indicates the category of the position identification data.
[0312] 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.
[0313] 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 position vector difference of the current block is the second candidate position vector difference, a multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, a multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data, and the first numerical value is determined as the value of the first flag bit.
[0314] If the position vector difference of the current block 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.
[0315] Based on the above description, the second candidate position vector difference is a multiple of the second pixel precision, and the second pixel precision is a multiple of the target alignment size. On this basis, the second candidate position vector difference must be a multiple of the target 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 also accurately represent the vertical component. Therefore, when the position vector difference of the current block is the second candidate position vector difference, the multiple of the horizontal component relative to the horizontal alignment size can be directly determined as the horizontal identification data, and the multiple of the vertical component relative to the vertical alignment size can be determined as the vertical identification data. In this way, the horizontal and vertical components can be accurately encoded into the bitstream, ensuring the accuracy of the encoding and decoding of the horizontal and vertical components.
[0316] When the position vector difference of the current block is the first candidate position vector difference, it is impossible to determine that the second candidate position vector difference must be 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 numerical value is determined as the value of the first flag bit. This can avoid the situation where horizontal component encoding errors are caused by encoding the horizontal component relative to the multiple of the horizontal alignment size into the code stream, and the situation where vertical component encoding errors are caused by encoding the vertical component relative to the multiple of the vertical alignment size into the code stream, thereby ensuring the accuracy of encoding and decoding of the horizontal and vertical components.
[0317] The first value and the second value are pre-set, 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, the value may be adjusted according to different requirements in different situations.
[0318] It should be noted that if the position vector difference of the current block is the first candidate position vector difference, in addition to directly determining the horizontal component as the horizontal identification data and the vertical component as the vertical identification data, the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size can also be determined as the horizontal identification data. The quotient and remainder obtained by dividing the vertical component by the vertical alignment size can also be determined as the vertical identification data, and the second value can be 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.
[0319] Because the quotient and remainder of the position vector difference divided 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, even if it is impossible to determine whether the position vector difference is an integer multiple of the target alignment size, the position vector can be accurately encoded with a smaller number of bits, thereby ensuring the accuracy of the encoding of the position vector difference while improving the encoding efficiency of images containing text content. Of course, 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 can also be determined by other means, which are not limited in this embodiment of the present application.
[0320] Step 1304: Encode the position identification data and the first flag corresponding to the position vector difference into the bitstream.
[0321] For the implementation method of encoding the position identification data and the first flag corresponding to the position vector difference into the bitstream, please refer to the relevant content in the first encoding method above.
[0322] As an example, when the position vector difference is MVD, during encoding, ammvd_flag can be used to indicate whether the first flag bit is equal to 1. ammvd_flag can be 1 or 0. If the first flag bit is equal to 1, ammvd_flag is 1 and 1 is encoded into the bitstream; otherwise, ammvd_flag is 0 and 0 is encoded into the bitstream.
[0323] For a target image containing textual content, after aligning the target image according to the target alignment size to obtain a target region, if the position vector difference of the current block is a second candidate position vector difference, the multiple of the position vector difference relative to the target alignment size is encoded into the bitstream as position identification data. Since the position vector difference of the current block is also a multiple of the target alignment size, 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 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 the multiple of the position vector difference relative to the target alignment size into the bitstream can effectively reduce the number of bits required to encode the position vector difference while ensuring the accuracy of the encoded position vector difference, thereby ensuring high encoding efficiency for images containing textual content.
[0324] In an embodiment of the present application, if 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 can also be determined as horizontal identification data, the quotient and remainder obtained by dividing the vertical component by the vertical alignment size can also be determined as vertical identification data, and the second numerical value can be determined as the value of the first flag bit. Because the quotient and remainder of the position vector difference divided 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, even if it is impossible to determine whether the position vector difference is an integer multiple of the target alignment size, the position vector can be accurately encoded with a smaller number of bits, thereby ensuring the accuracy of the encoding of the position vector difference while improving the encoding efficiency of images containing text content.
[0325] In addition, the encoding method provided in the embodiment of the present application can be combined with the standard video encoding method without affecting the standard video encoding process. That is to say, the encoding provided in the embodiment of the present application is highly portable and can improve the encoding efficiency of images containing text content without increasing additional hardware costs.
[0326] An embodiment of the present application also provides a fourth decoding method, which corresponds to the fourth encoding method mentioned above and includes the following steps.
[0327] Step 1401: Parse the code stream 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 target area.
[0328] Among them, the position vector difference indicates the difference between the position vector of the current block and the reference position vector, the position vector of the current block indicates the position 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 relative to the target alignment size or the position vector difference, and the first flag indicates the category of the position identification data.
[0329] Step 1402: Determine the position vector difference based on the target alignment size, the position identification data corresponding to the position vector difference, and the first flag bit.
[0330] In some embodiments, the position vector difference may be determined based on the value of the first flag bit, the target alignment size, and the position identification data.
[0331] In some embodiments, the target alignment dimension includes a horizontal alignment dimension and a vertical alignment dimension, 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 is a first value, the horizontal alignment dimension is multiplied by the horizontal identification data to obtain the horizontal component, and the vertical alignment dimension is multiplied by the vertical identification data to obtain the vertical component. If the value of the first flag is a second value, the horizontal identification data is determined to be the horizontal component, and the vertical identification data is determined to be the vertical component.
[0332] If the value of the first flag bit is the first value, it indicates that the position vector difference of the current block is a multiple of the target alignment size. Therefore, the horizontal alignment size can be multiplied by the horizontal identification data to obtain the horizontal component, and the vertical alignment size can be multiplied by the vertical identification data to obtain the vertical component. If the value of the first flag bit is the second value, it indicates that the position vector difference of the current block is not necessarily a multiple of the target alignment size. Therefore, the horizontal identification data can be determined as the horizontal component, and the vertical identification data can be determined as the vertical component.
[0333] Based on the above description, if during the encoding process, 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. Correspondingly, during the decoding process, if the first flag is the second value, the quotient included in the horizontal identification data can be multiplied by the horizontal alignment size and then added to the remainder to obtain the horizontal component, and the quotient included in the vertical identification data can be multiplied by the vertical alignment size and then added to the remainder to obtain the vertical component.
[0334] Step 1403: Reconstruct the current block based on the position vector difference.
[0335] For the implementation method of reconstructing the current block, please refer to the relevant content in the first encoding method, which will not be repeated here.
[0336] As an example, when the position vector difference is MVD, after decoding the position identification data and the first flag bit, the number of shift bits corresponding to the target alignment size can be determined based on the first flag bit, and the value obtained by left-shifting the binary number 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, by left-shifting the binary number of the position identification data, the target alignment size and the position identification data are multiplied to obtain the position vector difference, or the position identification data can be directly used as the position vector difference.
[0337] If the first flag bit is the 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 is the 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.
[0338] If the position vector difference includes a horizontal component and a vertical component, the position identification data includes a horizontal identification data and a vertical identification data, and the target alignment size includes a horizontal alignment size and a vertical alignment size, then the value after the binary horizontal identification data is shifted left by the number of shift bits corresponding to the horizontal alignment size is determined as the horizontal component, and the value after the binary vertical identification data is shifted left by the number of shift bits corresponding to the vertical alignment size is determined as the vertical component.
[0339] As an example, if ammvd_flag is 1 as parsed from the code stream, the first flag is determined to be 1, that is, the first flag is the first value. If ammvd_flag is 0 as parsed from the code stream, the first flag is determined not to be 1, that is, the first flag is the second value.
[0340] For example, AmmvdShift[compIdx] can be used to represent the number of shift bits corresponding to the target alignment size at the first pixel precision and the second pixel precision. The number of shift bits corresponding to the target alignment size at the first pixel precision is 0, while the number of shift bits corresponding to the target alignment size at the second pixel precision is related to the number of binary bits of the target alignment size. If the target alignment size includes a horizontal alignment size and a vertical alignment size, compIdx can be 0 or 1. If compIdx is 0, it indicates the horizontal alignment size, and if compIdx is 1, it indicates the vertical alignment size.
[0341] Optionally, the number of shift bits corresponding to the target alignment size under 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, then the number of shift bits corresponding to the target alignment size under the second pixel precision is 3. If the target alignment size is 16, then the number of shift bits corresponding to the target alignment size under the second pixel precision is 4. If the target alignment size is 32, then the number of shift bits corresponding to the target alignment size under the second pixel precision is 5. If the target alignment size is 64, then the number of shift bits corresponding to the target alignment size under the second pixel precision is 6. Of course, the number of shift bits corresponding to the target alignment size can also be determined by other methods, and this embodiment of the present application is not limited to this.
[0342] In practical applications, the codec method provided by this application needs to allow the use of adaptive multiple integer pixel precision MVD (AMMVD) technology. In this case, the sps_ammvd_enabled_flag can be used to indicate whether the codec network allows the use of AMMVD technology, with 1 indicating that it allows it and 0 indicating that it does not. If the use of AMMVD technology is allowed, the fourth codec method can be used for encoding and decoding.
[0343] Because the encoding bits required for a multiple of the position vector difference relative to the target alignment size are smaller than the encoding bits required for the position vector difference of the current block, 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 decoding efficiency of images containing text content can be improved while ensuring decoding accuracy. In addition, if during 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. Because the number of bits required to encode the quotient and remainder is smaller 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. Therefore, while ensuring decoding accuracy, the decoding efficiency of images containing text content is improved.
[0344] In addition, the decoding method provided in the embodiment of the present application can be combined with the standard video decoding method without affecting the standard video decoding process. That is to say, the decoding provided in the embodiment of the present application is highly portable and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.
[0345] FIG9 is a schematic diagram of the structure of an encoding device provided in an embodiment of the present application. The encoding device can be implemented as part or all of an encoding end by software, hardware, or a combination of both. Moreover, the encoding device can be encoder 100 in FIG1 . Referring to FIG9 , the device includes: an acquisition module 901, a first determination module 902, a second determination module 903, and a first encoding module 904.
[0346] The acquisition module 901 is used to acquire the target area, which is obtained by aligning the target image according to the target alignment size. The detailed implementation process is referred to the corresponding content of each embodiment above, which will not be repeated here.
[0347] The first determination module 902 is configured to determine a position vector difference of a current block to be encoded in a target region. 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 a reference block corresponding to the current block. The detailed implementation process is described in the corresponding embodiments above and will not be repeated here.
[0348] The second determination module 903 is configured to determine, based on the target alignment size and the position vector difference, position identification data corresponding to the position vector difference and a first flag bit. The position identification data is a multiple of the position vector difference relative to the target alignment size or the position vector difference itself. The first flag bit indicates the type of the position identification data. The detailed implementation process is described in the corresponding content of the above embodiments and is not repeated here.
[0349] The first encoding module 904 is used to encode the position identification data and the first flag bit into the code stream. The detailed implementation process is referred to the corresponding content of each embodiment above and will not be repeated here.
[0350] Optionally, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag bit includes a horizontal flag bit, and the horizontal flag bit indicates a category of the horizontal identification data;
[0351] The second determining module 903 is specifically configured to:
[0352] If the horizontal component is an integer multiple of the horizontal alignment size, the multiple of the horizontal component relative 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.
[0353] Optionally, the second determining module 903 is specifically configured to:
[0354] If the horizontal component is not an integer multiple of the horizontal alignment size, the horizontal component is determined as horizontal identification data, and the second value is determined as the value of the horizontal flag bit.
[0355] Optionally, the target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag bit includes a vertical flag bit, and the vertical flag bit indicates a category of the vertical identification data;
[0356] The second determining module 903 is specifically configured to:
[0357] 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 the vertical identification data, and the first value is determined as the value of the vertical flag bit.
[0358] Optionally, the second determining module 903 is specifically configured to:
[0359] If the vertical component is not an integer multiple of the vertical alignment size, the vertical component is determined as vertical identification data, and the second value is determined as the value of the vertical flag bit.
[0360] 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;
[0361] The second determining module 903 is specifically configured to:
[0362] The multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, the multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data, and the first numerical value is determined as the value of the first flag bit.
[0363] Optionally, the first determining module 902 is specifically configured to:
[0364] Determine a first candidate position vector difference and a second candidate position vector difference of the current block, where the first candidate position vector difference is determined according to a first pixel precision, and the second candidate position vector is determined according to a second pixel precision, where the first pixel precision is an integer and the second pixel precision is a multiple of a target alignment size;
[0365] Determining a rate-distortion cost of the first candidate position vector difference and a rate-distortion cost of the second candidate position vector difference;
[0366] The candidate position vector difference with the smaller rate-distortion cost between the first candidate position vector difference and the second candidate position vector difference is determined as the position vector difference of the current block.
[0367] Optionally, the second determining module 903 is specifically configured to:
[0368] 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, then the multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, the multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data, and the first numerical value is determined as the value of the first flag bit.
[0369] Optionally, the second determining module 903 is specifically configured to:
[0370] 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 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.
[0371] Optionally, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, and the first flag bit includes a horizontal flag bit, and the horizontal flag bit is further used to indicate the horizontal component in combination with the horizontal identification data;
[0372] The second determining module 903 is specifically configured to:
[0373] 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.
[0374] Optionally, the target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, and the first flag bit includes a vertical flag bit, and the vertical flag bit is further used to indicate the vertical component in combination with the vertical identification data;
[0375] The second determining module 903 is specifically configured to:
[0376] 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.
[0377] Optionally, the target area is obtained by aligning a text area in the target image according to a target alignment size, and the text area includes at least one character.
[0378] Optionally, the device further comprises:
[0379] The second encoding module is configured to encode residual information of the current block into a bitstream, where the residual information indicates a prediction residual between the current block and a reference block.
[0380] For a target image containing text content, after the target image is aligned according to the target alignment size to obtain a target area, the position identification data and the first flag bit corresponding to the position vector difference of the current block to be encoded in the target area can be determined based on the target alignment size. Since the position identification data can be a multiple of the position vector difference relative to the target alignment size, in this case, the encoding bits required for the position identification data and the first flag bit corresponding to the position vector difference are less than the encoding bits required for the position vector difference, that is, the bit cost of encoding the position identification data and the first flag bit corresponding to the position vector difference is usually less than the bit cost of directly encoding the position vector difference. Therefore, encoding the position identification data and the first flag bit corresponding to the position vector difference into the bitstream can effectively reduce the number of bits required for encoding the position vector difference while ensuring encoding accuracy, thereby ensuring high encoding efficiency of images containing text content.
[0381] It should be noted that the encoding device provided in the above embodiment is merely illustrated by the division of the above functional modules during encoding. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the encoding device provided in the above embodiment and the encoding method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0382] FIG10 is a schematic diagram of the structure of a decoding device provided in an embodiment of the present application. The decoding device can be implemented as part or all of a decoding end by software, hardware, or a combination of both. Furthermore, the decoding device can be decoder 200 in FIG1 . Referring to FIG10 , the device includes: a first parsing module 1001, a determination module 1002, and a reconstruction module 1003.
[0383] A first parsing module 1001 is configured to parse the bitstream to obtain position identification data and a first flag bit corresponding to a position vector difference of a current block to be decoded in a target area;
[0384] The position vector difference indicates the difference between the position vector of the current block and the 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 position identification data is a multiple of the position vector difference relative to the target alignment size or the position vector difference, and the first flag bit indicates the type of the position identification data. The detailed implementation process refers to the corresponding content in the above embodiments and is not repeated here.
[0385] The determination module 1002 is configured to determine the position vector difference based on the target alignment size, the position identification data and the first flag bit. The detailed implementation process is referred to the corresponding content in the above embodiments and will not be repeated here.
[0386] The reconstruction module 1003 is used to reconstruct the current block based on the position vector difference. The detailed implementation process is referred to the corresponding content of each embodiment above, which will not be repeated here.
[0387] Optionally, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, and the first flag bit includes a horizontal flag bit, and the horizontal flag bit indicates a category of the horizontal identification data;
[0388] The determination module 1002 is specifically configured to:
[0389] If the value of the horizontal flag is the first value, the horizontal alignment size is multiplied by the horizontal identification data to obtain a horizontal component.
[0390] Optionally, the determining module 1002 is specifically configured to:
[0391] If the value of the horizontal flag is the second value, the horizontal identification data is determined to be the horizontal component.
[0392] Optionally, the target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, and the first flag bit includes a vertical flag bit, and the vertical flag bit indicates a category of the vertical identification data;
[0393] The determination module 1002 is specifically configured to:
[0394] If the value of the vertical flag is the first value, the vertical alignment size is multiplied by the vertical identification data to obtain a vertical component.
[0395] Optionally, the determining module 1002 is specifically configured to:
[0396] If the value of the vertical flag is the second value, the vertical identification data is determined as the vertical component.
[0397] 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;
[0398] The determination module 1002 is specifically configured to:
[0399] If the value of the first flag bit is the first numerical value, the horizontal alignment size is multiplied by the horizontal identification data to obtain a horizontal component, and the vertical alignment size is multiplied by the vertical identification data to obtain a vertical component.
[0400] Optionally, the determining module 1002 is specifically configured to:
[0401] If 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.
[0402] Optionally, the target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, and the first flag bit includes a horizontal flag bit, and the horizontal flag bit is further used to indicate the horizontal component in combination with the horizontal identification data;
[0403] The determination module 1002 is specifically configured to:
[0404] Multiply the horizontal identification data by the horizontal alignment size and add it to the value of the horizontal flag to obtain the horizontal component.
[0405] Optionally, the target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, and the first flag bit includes a vertical flag bit, and the vertical flag bit is further used to indicate the vertical component in combination with the vertical identification data;
[0406] The determination module 1002 is specifically configured to:
[0407] Multiply the vertical identification data by the vertical alignment size and add it to the value of the vertical flag to obtain the vertical component.
[0408] Optionally, the device further comprises:
[0409] A second parsing module is configured to parse the bitstream to obtain residual information of the current block, where the residual information indicates a prediction residual between the current block and a reference block;
[0410] The reconstruction module 1003 is specifically used for:
[0411] The current block is reconstructed based on the position vector difference and the residual information.
[0412] Since the position identification data can be a multiple of the position vector difference relative to the target alignment size, the encoding bits required for the position identification data and the first flag corresponding to the position vector difference are less than the encoding bits required for the position vector difference. Therefore, 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, while ensuring decoding accuracy, the decoding efficiency of images containing text content can be improved. In addition, the decoding method provided in the embodiment of the present application can be combined with the standard video decoding method without affecting the standard video decoding process. In other words, the decoding provided in the embodiment of the present application is highly portable and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.
[0413] It should be noted that the decoding device provided in the above embodiment is merely illustrated by the division of the above functional modules during decoding. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the decoding device provided in the above embodiment and the decoding method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0414] An embodiment of the present application also provides a computer-readable storage medium, which stores instructions. When the instructions are executed on a computer, the computer executes the steps of the encoding method described in the above embodiment, or executes the steps of the decoding method described in the above embodiment.
[0415] The present application also provides a computer program product comprising instructions, which, when executed on a computer, causes the computer to execute the steps of the encoding method described in the above embodiment, or to execute the steps of the decoding method described in the above embodiment. In other words, a computer program is provided, which, when executed on a computer, causes the computer to execute the steps of the encoding method described in the above embodiment, or to execute the steps of the decoding method described in the above embodiment.
[0416] An embodiment of the present application also provides a coding and decoding system, which includes a coding device and a decoding device. The coding device is used to implement the steps of the coding method described in the above embodiment, and the decoding device is used to implement the steps of the decoding method described in the above embodiment.
[0417] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, or a magnetic tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)). It is worth noting that the computer-readable storage medium mentioned in the embodiments of the present application may be a non-volatile storage medium, in other words, a non-transient storage medium.
[0418] It should be understood that the "plurality" mentioned herein refers to two or more. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is merely a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate a clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.
[0419] It should be noted that the 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 involved in the embodiments of this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions. For example, the target area involved in the embodiments of this application is obtained with full authorization.
[0420] The above description is an embodiment provided for this application and is not intended to limit this application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application should be included in the scope of protection of this application.
Claims
1. A coding method, It is characterized in that The method comprises: Acquire a target area, where the target area is obtained by aligning the target image according to the target alignment size; Determine a position vector difference of a current block to be encoded in the target area, the position vector difference indicating a difference between a position vector of the current block and a reference position vector, the position vector of the current block indicating a positional relationship between the current block and a reference block corresponding to the current block; Based on the target alignment size and the position vector difference, determine position identification data and a first flag bit corresponding to the position vector difference, the position identification data being a multiple of the position vector difference relative to the target alignment size or being the position vector difference, and the first flag bit indicating a category of the position identification data; The position identification data and the first flag bit are encoded into a bit stream.
2. The method according to claim 1, It is characterized in that The target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag bit includes a horizontal flag bit, and the horizontal flag bit indicates a category of the horizontal identification data; The determining, based on the target alignment size and the position vector difference, the position identification data and the first flag bit corresponding to the position vector difference comprises: If the horizontal component is an integer multiple of the horizontal alignment size, the multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, and the first numerical value is determined as the value of the horizontal flag bit.
3. The method according to claim 2, It is characterized in that The method further comprises: 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 numerical value is determined as the value of the horizontal flag bit.
4. The method according to any one of claims 1 to 3, It is characterized in that The target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag bit includes a vertical flag bit, and the vertical flag bit indicates a category of the vertical identification data; The determining, based on the target alignment size and the position vector difference, the position identification data and the first flag bit corresponding to the position vector difference comprises: 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 the vertical identification data, and the first numerical value is determined as the value of the vertical flag bit.
5. The method according to claim 4, It is characterized in that The method further comprises: 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 numerical value is determined as the value of the vertical flag bit.
6. The method according to claim 1, It is characterized in that 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 determining, based on the target alignment size and the position vector difference, the position identification data and the first flag bit corresponding to the position vector difference comprises: The multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, the multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data, and the first numerical value is determined as the value of the first flag bit.
7. The method according to claim 6, It is characterized in that The determining the position vector difference of the current block to be encoded in the target area includes: 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 according to a first pixel precision, and the second candidate position vector is determined according to a second pixel precision, wherein the first pixel precision is an integer, and the The two-pixel precision is a multiple of the target alignment size; Determining a rate-distortion cost of the first candidate position vector difference and a rate-distortion cost of the second candidate position vector difference; The candidate position vector difference having a smaller rate-distortion cost between the first candidate position vector difference and the second candidate position vector difference is determined as the position vector difference of the current block.
8. The method according to claim 6, It is characterized in that The step of determining a multiple of the horizontal component relative to the horizontal alignment size as the horizontal identification data, determining a multiple of the vertical component relative to the vertical alignment size as the vertical identification data, and determining a first numerical 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, then the multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, the multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data, and the first numerical value is determined as the value of the first flag bit.
9. The method according to claim 8, It is characterized in that The method further comprises: 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 numerical value is determined as the value of the first flag bit.
10. The method according to claim 1, It is characterized in that The target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag bit includes a horizontal flag bit, and the horizontal flag bit is further used to indicate the horizontal component in combination with the horizontal identification data; The determining, based on the target alignment size and the position vector difference, the position identification data and the first flag bit corresponding to the position vector difference comprises: 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.
11. The method according to claim 1 or 10, It is characterized in that The target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag bit includes a vertical flag bit, and the vertical flag bit is further used to indicate the vertical component in combination with the vertical identification data; The determining, based on the target alignment size and the position vector difference, the position identification data and the first flag bit corresponding to the position vector difference comprises: 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.
12. The method according to any one of claims 1 to 11, It is characterized in that The target area is obtained by aligning a text area in the target image according to the target alignment size, and the text area includes at least one character.
13. The method according to any one of claims 1 to 12, It is characterized in that The method further comprises: The residual information of the current block is encoded into a bitstream, where the residual information indicates a prediction residual between the current block and the reference block.
14. A decoding method, It is characterized in that The method comprises: Parsing 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 target area; The position vector difference indicates a difference between a position vector of the current block and a reference position vector, the position vector of the current block indicates a positional relationship between the current block and a reference block corresponding to the current block, the position identification data is a multiple of the position vector difference relative to the target alignment size or is the position vector difference, and the first flag bit indicates a category of the position identification data; Determining the position vector difference based on the target alignment size, the position identification data and the first flag bit; The current block is reconstructed based on the position vector difference.
15. The method of claim 14, It is characterized in that The target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag bit includes a horizontal flag bit, and the horizontal flag bit indicates a category of the horizontal identification data; The 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 horizontal flag bit is a first value, the horizontal alignment size is multiplied by the horizontal identification data to obtain the horizontal component.
16. The method of claim 15, It is characterized in that The method further comprises: If the value of the horizontal flag bit is a second numerical value, the horizontal identification data is determined as the horizontal component.
17. The method according to any one of claims 14 to 16, It is characterized in that The target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag bit includes a vertical flag bit, and the vertical flag bit indicates a category of the vertical identification data; The 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 vertical flag is a first value, the vertical alignment size is multiplied by the vertical identification data to obtain the vertical component.
18. The method of claim 17, It is characterized in that The method further comprises: If the value of the vertical flag is the second value, the vertical identification data is determined as the vertical component.
19. The method of claim 14, It is characterized in that 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 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 numerical 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.
20. The method of claim 19, It is characterized in that The method further comprises: If the value of the first flag bit is a second numerical value, the horizontal identification data is determined as the horizontal component, and the vertical identification data is determined as the vertical component.
21. The method of claim 14, It is characterized in that The target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag bit includes a horizontal flag bit, and the horizontal flag bit is further used to indicate the horizontal component in combination with the horizontal identification data; The determining the position vector difference based on the target alignment size, the position identification data and the first flag bit includes: The horizontal identification data is multiplied by the horizontal alignment size and then added to the value of the horizontal flag bit to obtain the horizontal component.
22. The method of claim 14 or 21, It is characterized in that The target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag bit includes a vertical flag bit, and the vertical flag bit is further used to indicate the vertical component in combination with the vertical identification data; The determining the position vector difference based on the target alignment size, the position identification data and the first flag bit includes: The vertical identification data is multiplied by the vertical alignment size and then added to the value of the vertical flag bit to obtain the vertical component.
23. The method according to any one of claims 14 to 22, It is characterized in that The method further comprises: Parsing residual information of the current block from the bitstream, the residual information indicating a prediction residual between the current block and the reference block; The step of reconstructing the current block based on the position vector difference comprises: The current block is reconstructed based on the position vector difference and the residual information.
24. An encoding device, It is characterized in that The device comprises: An acquisition module, used for acquiring a target area, wherein the target area is obtained by aligning the target image according to the target alignment size; A first determination module is used to determine a position vector difference of a current block to be encoded in the target area, wherein the position vector difference indicates a difference between a position vector of the current block and a reference position vector, and the position vector of the current block indicates a position relationship between the current block and a reference block corresponding to the current block; A second determination module is used to determine, based on the target alignment size and the position vector difference, position identification data and a first flag bit corresponding to the position vector difference, the position identification data being a multiple of the position vector difference relative to the target alignment size or being the position vector difference, and the first flag bit indicating a category of the position identification data; The first encoding module is used to encode the position identification data and the first flag bit into a bit stream.
25. The device according to claim 24, It is characterized in that The target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag bit includes a horizontal flag bit, and the horizontal flag bit indicates a category of the horizontal identification data; The second determining module is specifically used for: If the horizontal component is an integer multiple of the horizontal alignment size, the multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, and the first numerical value is determined as the value of the horizontal flag bit.
26. The device according to claim 25, It is characterized in that The second determining module is specifically used for: 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 numerical value is determined as the value of the horizontal flag bit.
27. The device according to any one of claims 24 to 26, It is characterized in that The target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag bit includes a vertical flag bit, and the vertical flag bit indicates a category of the vertical identification data; The second determining module is specifically used for: 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 the vertical identification data, and the first numerical value is determined as the value of the vertical flag bit.
28. The device according to claim 27, It is characterized in that The second determining module is specifically used for: 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 numerical value is determined as the value of the vertical flag bit.
29. The device of claim 24, It is characterized in that 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 second determining module is specifically used for: The multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, the multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data, and the first numerical value is determined as the value of the first flag bit.
30. The device of claim 29, It is characterized in that The first determining module is specifically used for: 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 according to a first pixel precision, and the second candidate position vector is determined according to a second pixel precision, the first pixel precision is an integer, and the second pixel precision is a multiple of the target alignment size; Determining a rate-distortion cost of the first candidate position vector difference and a rate-distortion cost of the second candidate position vector difference; The candidate position vector difference having a smaller rate-distortion cost between the first candidate position vector difference and the second candidate position vector difference is determined as the position vector difference of the current block.
31. The device of claim 29, It is characterized in that The second determining module is specifically used for: 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, then the multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, the multiple of the vertical component relative to the vertical alignment size is determined as the vertical identification data, and the first numerical value is determined as the value of the first flag bit.
32. The device of claim 31, It is characterized in that The second determining module is specifically used for: 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 numerical value is determined as the value of the first flag bit.
33. The device of claim 24, It is characterized in that The target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag bit includes a horizontal flag bit, and the horizontal flag bit is further used to indicate the horizontal component in combination with the horizontal identification data; The second determining module is specifically used for: 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.
34. The device of claim 24 or 33, It is characterized in that The target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag bit includes a vertical flag bit, and the vertical flag bit is further used to indicate the vertical component in combination with the vertical identification data; The second determining module is specifically used for: 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.
35. The device according to any one of claims 24 to 34, It is characterized in that The target area is obtained by aligning a text area in the target image according to the target alignment size, and the text area includes at least one character.
36. The device according to any one of claims 24 to 35, It is characterized in that The device also includes: The second encoding module is used to encode residual information of the current block into a bitstream, where the residual information indicates a prediction residual between the current block and the reference block.
37. A decoding device, It is characterized in that The device comprises: A first parsing module, used for parsing 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 target area; The position vector difference indicates a difference between a position vector of the current block and a reference position vector, the position vector of the current block indicates a positional relationship between the current block and a reference block corresponding to the current block, the position identification data is a multiple of the position vector difference relative to the target alignment size or is the position vector difference, and the first flag bit indicates a 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 reconstruction module is used to reconstruct the current block based on the position vector difference.
38. The device of claim 37, It is characterized in that The target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag bit includes a horizontal flag bit, and the horizontal flag bit indicates a category of the horizontal identification data; The determination module is specifically used for: If the value of the horizontal flag bit is a first value, the horizontal alignment size is multiplied by the horizontal identification data to obtain the horizontal component.
39. The device of claim 38, It is characterized in that The determination module is specifically used for: If the value of the horizontal flag bit is a second numerical value, the horizontal identification data is determined as the horizontal component.
40. The device according to any one of claims 37 to 39, It is characterized in that The target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag bit includes a vertical flag bit, and the vertical flag bit indicates a category of the vertical identification data; The determination module is specifically used for: If the value of the vertical flag is a first value, the vertical alignment size is multiplied by the vertical identification data to obtain the vertical component.
41. The device of claim 40, It is characterized in that The determination module is specifically used for: If the value of the vertical flag is the second value, the vertical identification data is determined as the vertical component.
42. The device of claim 37, It is characterized in that 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 determination module is specifically used for: If the value of the first flag bit is a first numerical 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.
43. The device of claim 42, It is characterized in that The determination module is specifically used for: If the value of the first flag bit is a second numerical value, the horizontal identification data is determined as the horizontal component, and the vertical identification data is determined as the vertical component.
44. The device of claim 37, It is characterized in that The target alignment size includes a horizontal alignment size, the position vector difference includes a horizontal component, the position identification data includes horizontal identification data, the first flag bit includes a horizontal flag bit, and the horizontal flag bit is further used to indicate the horizontal component in combination with the horizontal identification data; The determination module is specifically used for: The horizontal identification data is multiplied by the horizontal alignment size and then added to the value of the horizontal flag bit to obtain the horizontal component.
45. The device of claim 37 or 44, It is characterized in that The target alignment size includes a vertical alignment size, the position vector difference includes a vertical component, the position identification data includes vertical identification data, the first flag bit includes a vertical flag bit, and the vertical flag bit is further used to indicate the vertical component in combination with the vertical identification data; The determination module is specifically used for: The vertical identification data is multiplied by the vertical alignment size and then added to the value of the vertical flag bit to obtain the vertical component.
46. The device according to any one of claims 37 to 45, It is characterized in that The device also includes: A second parsing module, configured to parse the bitstream to obtain residual information of the current block, where the residual information indicates a prediction residual between the current block and the reference block; The reconstruction module is specifically used for: The current block is reconstructed based on the position vector difference and the residual information.
47. A coding device, It is characterized in that The encoding device includes a memory and a processor; The memory is used to store computer programs; The processor is used to execute the computer program to implement the steps of any method described in claims 1-13.
48. A decoding device, It is characterized in that The decoding device includes a memory and a processor; The memory is used to store computer programs; The processor is used to execute the computer program to implement the steps of any method described in claims 14-23.
49. A computer readable storage medium, It is characterized in that The storage medium stores instructions, and when the instructions are executed on the computer, the computer executes the steps of any one of the methods described in claims 1-23.
50. A computer program product, It is characterized in that The computer program product stores computer instructions, and when the computer instructions are executed by a processor, the steps of any one of the methods of claims 1-23 are implemented.
51. A computer readable storage medium, It is characterized in that The computer-readable storage medium stores a video code stream obtained by the method according to any one of claims 1 to 23 executed by one or more processors.
Citation Information
Patent Citations
Coding and decoding method, device, equipment, storage medium and computer program
CN118612451A
Information compression / decompression method and device
CN111918065A
Video signal transmitting equipment
JP1991129986A
The circuit for generating reference moving vector and reference address for motion compensation of brightness data
KR1019970009402A
Variable length coding / decoding method for motion vectors
US5428396A
