Coding and decoding method, device, equipment, storage medium and computer program

By performing adaptive text alignment and encoding on the target image, and utilizing positional identifier data and flag bits to encode the positional relationship of the current block, the problem of low encoding efficiency for images containing text content is solved, and an efficient encoding method is achieved.

CN118612451APending Publication Date: 2024-09-06HUAWEI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310254388.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-06
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

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.

Method used

By performing adaptive text alignment on the target image, after determining the target region, the positional relationship of the current block is encoded using position identifier data and the first flag bit based on the target alignment size and position vector difference, thereby reducing the number of encoding bits and improving encoding efficiency.

Benefits of technology

While ensuring encoding accuracy, it effectively reduces the number of bits required to encode position vector differences, improves the encoding efficiency of images containing text content, and is compatible with standard video encoding methods, thus enhancing encoding efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118612451A
    Figure CN118612451A
Patent Text Reader

Abstract

The invention discloses a coding and decoding method and device, equipment, a storage medium and a computer program, and belongs to the field of image compression. The method comprises the steps of obtaining a target area, determining a position vector difference of a current block to be coded in the target area, determining position identification data and a first flag bit corresponding to the position vector difference based on a target alignment size and the position vector difference, and compiling the position identification data and the first flag bit into a code stream. As the position identification data can be the multiple of the position vector difference relative to the target alignment size, the bit cost for encoding the position identification data corresponding to the position vector difference and the first flag bit is generally smaller than the bit cost for directly encoding the position vector difference, and the position identification data and the first flag bit are encoded into the code stream, so that the bit cost is reduced. According to the invention, the number of bits required for coding the position vector difference can be effectively reduced, so that the coding efficiency of the image containing the text content is relatively high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] 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

[0002] A high efficiency video coding (HEVC) encoder can encode video frame images by using motion compensation or intra block copy (IBC).

[0003] Taking motion compensation as an example, for the current block to be encoded in the video frame image, 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 (motion vector, MV) between the current block and the reference block is determined, and the MV indicates the positional relationship between the current block and the reference block. The motion vector predictor (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 (motion vector difference, MVD), and then the MVD is encoded into the bitstream.

[0004] However, the above encoding method has a better encoding efficiency for natural images, but a lower encoding efficiency for images containing text content. Summary of the invention

[0005] The present application provides a coding and decoding method, apparatus, device, storage medium and computer program, which can solve the problem of low coding efficiency of images containing text content in related technologies. The technical solution is as follows:

[0006] In a first aspect, a coding method is provided, the method comprising: acquiring 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.

[0007] For a target image containing text content, after the target image is aligned according to the target alignment size to obtain the 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 the encoding accuracy, thereby ensuring a high encoding efficiency for images containing text content.

[0008] 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; 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.

[0009] 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, thereby ensuring the accuracy of the encoding and decoding of the horizontal component.

[0010] 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.

[0011] 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, and therefore the horizontal component is directly determined as horizontal identification data, thereby 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.

[0012] 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; determining the position identification data and the first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference includes: if the vertical component is an integer multiple of the vertical alignment size, 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 bit.

[0013] 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 vertical identification data, so that the vertical component can be accurately encoded into the bitstream, thereby ensuring the accuracy of encoding and decoding of the vertical component.

[0014] 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.

[0015] 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 alignment size into the bitstream, thereby ensuring the accuracy of the encoding and decoding of the vertical component.

[0016] 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 a first flag bit corresponding to the position vector difference based on the target alignment size and the position vector difference includes: determining a multiple of the horizontal component 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.

[0017] 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, 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 a 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.

[0018] 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, and 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, so that the horizontal component and the vertical component can be accurately encoded into the bitstream, thereby ensuring the accuracy of encoding and decoding of the horizontal component and the vertical component.

[0019] 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.

[0020] 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 multiples of the horizontal component relative to the horizontal alignment size can accurately represent the horizontal component, and the multiples of the vertical component relative to the vertical alignment size can also accurately represent the vertical component. Therefore, the multiples of the horizontal component relative to the horizontal alignment size can be determined as horizontal identification data, and the multiples 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, thereby ensuring the accuracy of encoding and decoding of the horizontal component and the vertical component.

[0021] 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.

[0022] 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 into the bitstream, and / or the situation where vertical component encoding errors are caused by encoding the multiple of the vertical alignment size into the bitstream, thereby ensuring the accuracy of encoding and decoding of the horizontal and vertical components.

[0023] 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.

[0024] 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 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 encoding and decoding of the horizontal component.

[0025] 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 also used to indicate the vertical component in combination with the 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 quotient obtained by dividing the vertical component by the vertical alignment size as the vertical identification data, and determining the remainder obtained by dividing the vertical component by the vertical alignment size as the value of the vertical flag bit.

[0026] 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, thereby ensuring the accuracy of the encoding and decoding of the vertical component.

[0027] 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.

[0028] 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 for encoding the position vector difference while ensuring the encoding accuracy, thereby ensuring a high encoding efficiency for images containing text content.

[0029] Optionally, the method further comprises: encoding residual information of the current block into a bitstream, the residual information indicating a prediction residual between the current block and the reference block.

[0030] When the residual information of the current block is encoded into the bitstream, the accuracy of encoding the current block can be effectively guaranteed.

[0031] 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 position 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; based on the target alignment size, the position identification data and the first flag bit, determining the position vector difference; and reconstructing the current block based on the position vector difference.

[0032] 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 bit 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 the decoding accuracy. In addition, the decoding method provided by 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 by the present application is highly portable and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.

[0033] 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 includes a horizontal flag, and the horizontal flag indicates a 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.

[0034] When the value of the horizontal flag is the first value, it means that the horizontal identification data is a multiple of the horizontal component relative to the horizontal alignment size, so the horizontal alignment size is multiplied by the horizontal identification data to obtain the horizontal component. And when the horizontal flag is the first value, the efficiency of decoding the horizontal identification data is higher than the efficiency of decoding the horizontal component, so that the decoding efficiency of the image containing text content can be improved while ensuring the decoding accuracy.

[0035] 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.

[0036] When the value of the horizontal flag bit 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.

[0037] 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 includes a vertical flag, and the vertical flag indicates a 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.

[0038] When the value of the vertical flag is the first value, it means that the vertical flag data is a multiple of the vertical component relative to the vertical alignment size, so the vertical alignment size is multiplied by the vertical flag data to obtain the vertical component. And when the vertical flag is the first value, the efficiency of decoding the vertical flag data is higher than the efficiency of decoding the vertical component, so that the decoding efficiency of the image containing text content can be improved while ensuring the decoding accuracy.

[0039] Optionally, the method further includes: if the value of the vertical flag bit is a second numerical value, determining the vertical identification data as the vertical component.

[0040] 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.

[0041] 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.

[0042] When the value of the first flag bit is the 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, since the coding bits required for the 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 value of the first flag bit is the first numerical value, the efficiency of decoding the position identification data is higher than the efficiency of decoding the position vector difference, thus, the decoding efficiency of images containing text content can be improved while ensuring the decoding accuracy.

[0043] 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.

[0044] 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 directly determined as the vertical component.

[0045] 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 includes a horizontal flag, which is also used in combination with the horizontal identification data to indicate the horizontal component; 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 value to the horizontal flag to obtain the horizontal component.

[0046] 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.

[0047] 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 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.

[0048] 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.

[0049] 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.

[0050] 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.

[0051] In a third aspect, a coding device is provided, wherein the coding device has the function of implementing the coding method in the first aspect. The coding device includes at least one module, and the at least one module is used to implement the coding method provided in the first aspect.

[0052] In a fourth aspect, a decoding device is provided, wherein the decoding device has the function of implementing the decoding method in the second aspect. The decoding device comprises at least one module, wherein the at least one module is used to implement the decoding method provided in the second aspect.

[0053] In a fifth aspect, a coding device is provided, the coding device comprising a processor and a memory, the memory being used to store a program for executing the coding method provided in the first aspect. The processor is configured to execute the program stored in the memory to implement the coding method provided in the first aspect.

[0054] Optionally, the encoding device may further include a communication bus, which is used to establish a connection between the processor and the memory.

[0055] In a sixth aspect, a decoding device is provided, the decoding device comprising a processor and a memory, the memory being used 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.

[0056] Optionally, the decoding device may further include a communication bus, and the communication bus is used to establish a connection between the processor and the memory.

[0057] In the seventh aspect, a computer-readable storage medium is provided, wherein the storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the steps of the encoding method described in the first aspect above, or executes the steps of the decoding method described in the second aspect above.

[0058] In an eighth aspect, a computer program product comprising instructions is provided, and when the instructions are executed on a computer, the computer executes the steps of the encoding method described in the first aspect, or executes the steps of the decoding method described in the second aspect. In other words, a computer program is provided, and when the computer program is executed on a computer, the computer executes the steps of the encoding method described in the first aspect, or executes the steps of the decoding method described in the second aspect.

[0059] In a ninth aspect, a coding and decoding system is provided, the coding and decoding system comprising 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.

[0060] 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

[0061] Figure 1 It is a schematic diagram of an implementation environment provided by an embodiment of the present application;

[0062] Figure 2 is a schematic diagram of another implementation environment provided by an embodiment of the present application;

[0063] Figure 3 is a structural diagram of a video encoding module provided in an embodiment of the present application;

[0064] Figure 4 is a structural diagram of a video decoding module provided in an embodiment of the present application;

[0065] Figure 5is a flowchart of the first encoding method provided in an embodiment of the present application;

[0066] Figure 6 is a schematic diagram of a target area provided in an embodiment of the present application;

[0067] Figure 7 is a schematic diagram of a filled text area provided in an embodiment of the present application;

[0068] Figure 8 is a flowchart of a first decoding method provided in an embodiment of the present application;

[0069] Fig. 9 is a schematic diagram of the structure of an encoding device provided in an embodiment of the present application;

[0070] Fig.10 It is a structural diagram of a decoding device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0071] 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 in conjunction with the accompanying drawings.

[0072] 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.

[0073] High efficiency video coding (HEVC): is a video compression standard that uses a block-based hybrid video coding / compression structure. The block-based hybrid video coding / compression structure combines prediction, transform, quantization, block partition, in-loop filter, entropy coding and other technical means to compress the video to reduce redundant signals in the video. The encoder divides the input video frame image or video signal into coding tree units (CTUs) of similar size. For any CTU, the CTU is predicted and the prediction residual corresponding to the CTU is obtained. The prediction residual is transformed to obtain the frequency domain transform coefficient, and then the frequency domain transform coefficient is lossily compressed by quantization. The quantized frequency domain transform coefficient is encoded into the bitstream by entropy coding. Then, based on the bitstream, the CTU is reconstructed by inverse quantization, inverse transformation and in-loop filter, so as to obtain the reconstructed value of the video frame image, and other CTUs can be encoded based on the reconstructed value.

[0074] Among them, prediction and transformation refer to reducing the redundancy in the video signal by removing the correlation of the internal pixels of each CTU in the time domain, spatial domain and frequency domain. Prediction includes inter-frame prediction and intra-frame prediction. Quantization refers to reducing the number of bits representing the transform coefficient by reducing the precision of the transform coefficient. The purpose of quantization is to remove the imperceptible details in the video frame image, thereby effectively reducing the irrelevance of the data. The details of block division will be introduced later and will not be repeated here.

[0075] Hybrid video coding structures are usually 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. The screen content video exhibits colors and other signal characteristics that are different from natural videos. In order to meet the needs of efficient encoding of screen content videos, many screen content coding (SCC) tools have been specially 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 palette, which can improve the compression efficiency of screen content by 30% to 40%.

[0076] Block partition: The HEVC standard introduces a set of basic units based on quadtree recursive partitioning, including coding units (CU), prediction units (PU) and transform units (TU). In the HEVC encoder, the input image is first divided into multiple non-overlapping coding tree units (CTU) of the same size. The size of the CTU is determined by the encoder and can be up to 64×64. In the subsequent encoding process, a CTU can be used directly as a CU, or it can be further divided into multiple smaller CUs by quadtree recursive partitioning. The depth of CU partitioning is determined by the calculated rate-distortion cost (i.e., rate-distortion cost). The encoder will compare and weigh different partitioning modes and select the partitioning mode with the lowest rate-distortion cost for encoding. Finally, the CU at the quadtree leaf node is the basic unit for the encoder to perform subsequent predictive transform coding. Generally speaking, block partitioning will use 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 can make the processing of prediction, transformation, quantization and other modules more convenient and accurate, make the selection of encoding mode more in line with the image characteristics of the video content, and effectively improve the encoding efficiency.

[0077] PU is the basic unit for encoder prediction, which contains all prediction-related information and is obtained by further dividing CU. For 2N×2N CU, PU has 8 optional division modes, including 4 symmetric modes (i.e. 2N×2N, N×N, 2N×N, N×2N) and 4 asymmetric modes with a 1:3 or 3:1 ratio. The introduction of multiple division modes can make the prediction of complex images more accurate.

[0078] TU is the basic unit for encoder transformation and quantization. The size of TU depends on the CU to which it belongs. A CU can be further divided into TUs by quadtree division. The minimum size of TU is 4×4 and the maximum size is 32×32. According to the content characteristics, the encoder can flexibly select the best division mode for TU.

[0079] 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.

[0080] Motion vector (MV) prediction coding: Since the MV of the current block is usually related to the MV of the adjacent blocks in the current or adjacent image, the MV of the adjacent blocks in the current or adjacent image 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 prediction coding.

[0081] 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 / 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.

[0082] There are two MVP modes under the HEVC standard, advanced motion vector prediction (AMVP) mode and merge mode. The AMVP mode can cope with the flexible block structure of HEVC, and the merge mode can reduce block division redundancy.

[0083] 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.

[0084] The main difference between IBC and motion compensation is that the reference image of IBC is obtained from the current image (i.e. the reconstructed part), and there is a block vector (BV) similar to the motion vector to indicate the block matching relationship. IBC can better handle screen contents with multiple similar graphics or texts in the video frame, that is, the current block can refer to the block with similar graphics in the current image and obtain a prediction residual with a pixel value close to 0, which accounts for a very small bit rate in the bitstream. The rest of IBC, including the grammatical structure and the encoding process of related information, is almost the same as motion compensation.

[0085] The key to IBC technology is the encoding of BV. In the prior art, the encoding method of BV is similar to the MV prediction encoding method in the above inter-frame prediction, that is, in the IBC mode, BV is similar to the above MV, the block vector predictor (BVP) is similar to the MVP, and the block vector difference (BVD) is similar to the MVD. For the convenience 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.

[0086] Image compression refers to a technology that uses image data characteristics such as spatial redundancy, visual redundancy, and statistical redundancy to losslessly represent the original image pixel matrix with fewer bits, thereby achieving 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.

[0087] At present, video compression standards such as HEVC have been formed. HEVC can divide a video into multiple video frame images, and the encoder can encode the video frame images using motion compensation or IBC. However, when the above encoding method is applied to images containing text content, the pixels of the same character may be divided into different CTUs or CUs. In this case, when performing subsequent operations such as prediction, transformation, and quantization, it will lead to poor encoding efficiency when compressing text content.

[0088] 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, the pixels of the same character can be avoided to the greatest extent from being divided into different CUs, thereby improving the accuracy and efficiency of compressing text content.

[0089] Although the above-mentioned text adaptive alignment encoding scheme solves the problem that the pixels of the same character are 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, thereby obtaining a position vector difference with a large value. In this case, the position vector difference needs to be encoded with a higher number of bits, resulting in a lower encoding efficiency of the target image. 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 smaller 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 smaller 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 for encoding the position vector difference while ensuring the encoding accuracy, thereby ensuring a high encoding efficiency for the target image.

[0090] Next, the implementation environment involved in the embodiments of the present application is introduced.

[0091] Please refer to Figure 1 , Figure 1 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. Among them, the source device 10 can generate an encoded video, that is, a code stream. Therefore, the source device 10 can also be called an encoding device. The destination device 20 can decode the code stream generated by the source device 10. Therefore, the destination device 20 can also be called a decoding device. The link 30 can receive the encoded video generated by the source device 10, and can transmit the encoded video to the destination device 20. The storage device 40 can receive the encoded video generated by the source device 10, and can store the encoded video. Under such conditions, the destination device 20 can directly obtain the encoded video from the storage device 40. Alternatively, the storage device 40 can correspond to a file server or another intermediate storage device that can store the encoded video generated by the source device 10. Under such conditions, the destination device 20 can stream or download the encoded video stored in the storage device 40.

[0092] 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, 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 that can be accessed by a computer, etc. For example, the source device 10 and the destination device 20 may each include a mobile phone, a smart phone, a personal digital assistant (PDA), a wearable device, a pocket PC (PPC), a tablet computer, a smart car, 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, a car computer, or the like.

[0093] The link 30 may include one or more media or devices capable of transmitting the encoded video from the source device 10 to the destination device 20. In one possible implementation, the link 30 may include one or more communication media that enable the source device 10 to send the encoded video directly to the destination device 20 in real time. In an embodiment of the present application, the source device 10 may modulate the encoded video based on a communication standard, which may be a wireless communication protocol, etc., and may send the modulated video to the destination device 20. The one or more communication media may include wireless and / or wired communication media, for example, the one or more communication media may include 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, which may be a local area network, a wide area network, or a global network (e.g., the Internet), etc. The one or more communication media may include routers, switches, base stations, or other devices that facilitate communication from the source device 10 to the destination device 20, etc., and the embodiment of the present application does not specifically limit this.

[0094] In a 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 multiple 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 code streams.

[0095] In one possible implementation, the storage device 40 may correspond to a file server or another intermediate storage device that can store the code stream generated by the source device 10, and the destination device 20 may stream or download the image stored in the storage device 40. The file server may be any type of server that can store the encoded video and send the encoded video to the 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, etc. The destination device 20 may obtain the encoded image through 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 the two suitable for obtaining the encoded video stored on the file server. The transmission of the encoded video from the storage device 40 may be streaming transmission, download transmission, or a combination of the two.

[0096] Figure 1 The implementation environment shown is only one possible implementation method, and the technology of the embodiment of the present application can be applied not only to Figure 1 The source device 10 that can encode images and the destination device 20 that can decode encoded videos can also be applicable to other devices that can encode videos and decode bitstreams, and the embodiments of the present application do not specifically limit this.

[0097] exist Figure 1 In the illustrated implementation, source device 10 includes data source 120, encoder 100, and output interface 140. In some embodiments, output interface 140 may include a modulator / demodulator (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, etc.), 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.

[0098] 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 obtain an encoded video. The encoder may send the encoded video to the 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 the destination device 20 to obtain and use for decoding and / or display later.

[0099] exist Figure 1 In the illustrated implementation environment, 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 the encoded video via the link 30 and / or from the storage device 40, and then send it to the decoder 200. The decoder 200 may decode the received encoded video to obtain a decoded video. The decoder may send 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. In general, 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.

[0100] although Figure 1 1 and 2. Although not shown in the drawings, in some aspects, encoder 100 and decoder 200 may be integrated with an encoder and decoder, respectively, and may 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, if applicable, the MUX-DEMUX units may conform to the ITU H.223 multiplexer protocol, or other protocols such as the user datagram protocol (UDP).

[0101] The encoder 100 and the decoder 200 may each be any of the following circuits: one or more microprocessors, digital signal processors (digital signal processing, DSP), application specific integrated circuits (application specific integrated circuits, ASIC), field programmable gate arrays (field-programmable gate array, FPGA), discrete logic, hardware or any combination thereof. If the technology of the embodiment of the present application is partially implemented in software, the device may store instructions for the software in a suitable non-volatile computer-readable storage medium, and may use one or more processors to execute the instructions in hardware to implement the technology of the embodiment of the present application. Any of the foregoing contents (including hardware, software, a combination of hardware and software, etc.) may be regarded as one or more processors. Each of the encoder 100 and the decoder 200 may be included in one or more encoders or decoders, and any of the encoders or decoders may be integrated as part of a combined encoder / decoder (encoder-decoder) in a corresponding device.

[0102] The 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 a period of time, such as when the syntax elements are stored in the encoded bitstream to a computer-readable storage medium at the time of encoding, and the decoding device may then retrieve the syntax elements at any time after the syntax elements are stored to this medium.

[0103] Figure 2 is a schematic diagram of another implementation environment provided by an embodiment of the present application. The 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 only an example. In actual applications, the decoding end may also include the channel transmission module, or the channel transmission module does not belong to the encoding end or the decoding end, but is an independent unit, and the embodiment of the present application does not limit this.

[0104] For each video frame image in the video to be encoded, the video frame image can be encoded by the video encoding module to obtain the code stream or encoding file of the video frame image, and then the encoding file is encapsulated by the video encapsulation module to convert the encoding file into a video format that is easy to transmit. The encapsulated encoding file is transmitted to the decoding end through the channel transmission module. The decoding end receives the transmitted encoding file, decapsulates the encoding file, and reconstructs it through the video decoding model to obtain a reconstructed video frame image.

[0105] 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 the 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, and the residual information indicates the prediction residual between the current block and the reference block, and the side information includes the target alignment size.

[0106] Optionally, the video frame image may also include a non-text area. For the 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.

[0107] Please refer 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 may parse the position identification data and the first flag bit corresponding to the position vector difference of the current block to be decoded in the text area from the bitstream, parse the residual information and the edge information of the current block from the bitstream through the standard video decoding submodule, and then determine the position vector difference of the current block based on the target alignment size and the position identification data and the first flag bit corresponding to the position vector difference of the current block through the text reconstruction submodule, and reconstruct the current block in the text area based on the residual information and the position vector difference.

[0108] Optionally, for non-text areas, the standard video decoding submodule parses the non-text areas from the bitstream in a standard video decoding manner, and then reconstructs the text in the non-text areas and text areas to obtain a reconstructed video frame image.

[0109] It should be noted that the above standard video coding and decoding method can be a video compression standard using a block-based hybrid video coding / compression structure, such as HEVC. Of course, other coding and decoding methods can also be used, and the embodiments of the present application do not limit this.

[0110] 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 conferences 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 Figure 1 and Figure 2 In the implementation environment shown in FIG. 1 , any of the following encoding methods may be executed by the encoder 100 in the source device 10, or may be executed by the encoder 100 in the source device 10. Figure 2 Any of the decoding methods below may be executed by the decoder 200 in the destination device 20, or may be executed by the video encoding module in the destination device 20. Figure 2 The video decoding module in is executed.

[0111] Next, the encoding and decoding method provided in the embodiments of the present application will be introduced in detail through multiple embodiments.

[0112] Figure 5 This is a flowchart of the first encoding method provided in the embodiment of the present application. Please refer to Figure 5 , the method comprises the following steps.

[0113] Step 501: Acquire a target area, where the target area is aligned according to a target alignment size.

[0114] 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.

[0115] That is, a text area in a target image may be determined, the text area including at least one character, and the text area is aligned according to a target alignment size to obtain a target area.

[0116] Optionally, the target image is subjected to text recognition through 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. The embodiments of the present application are not limited to this.

[0117] 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 through the text recognition network model, the position of the text region in the target image may also be determined.

[0118] 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.

[0119] 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.

[0120] Since the target image can be encoded by a related coding method, and in the related coding method, the target image is usually divided to obtain a CU, and subsequent processing is performed based on the CU, and the size of the CU can include one of 8, 16, 32 and 64, so the size set can include 8, 16, 32 and 64. Of course, the size set can also be determined based on the size of the CU, and the size in the size set is not less than the size of the CU and is equal to an integer multiple of the size of the CU. For example, the size of the CU is 8, and the size of the size set can include 8 and 16. For another example, the size of the CU is 32, and the size of the size set can include 32.

[0121] 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, that is, the horizontal alignment size and the vertical alignment size may 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.

[0122] In the case where 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. In the case where 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.

[0123] 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.

[0124] 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. In this way, the difference between the horizontal alignment size and the width of the text area can be determined as the horizontal padding size, and the difference between the vertical alignment size and the height of the text area can be determined as the vertical padding size.

[0125] Based on the filling size, the implementation method of filling the text area in the target image includes: in the horizontal direction outside the text area (for example, on the left and / or right side of the text area, not specifically limited), the filling height is the vertical alignment size, and the width is the preset pixel value of the horizontal filling size. In the vertical direction outside the text area (for example, on the upper side and / or lower side of the text area, not specifically limited), the filling height is the vertical filling size, and the width is the preset pixel value of the horizontal alignment size.

[0126] Among them, the preset pixel value can be the pixel value of the background pixel other than the character pixel in the text area, or it can be a default pixel value, such as 0 or 255, which is not limited in the embodiment of the present application.

[0127] It should be noted that if padding is performed on the left and right sides of the text area, the sum of the sizes of the padding on the left and right sides is the horizontal padding size. If padding is performed on the top and bottom sides of the text area, the sum of the sizes of the padding on the top and bottom sides is the vertical padding size.

[0128] 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 where the number of filled text regions is different, the implementation methods for determining the target region are different based on the filled text regions, which will be introduced below.

[0129] If the number of filled text regions is one, the filled text region is used as the target region.

[0130] If there are multiple filled text regions, the multiple filled text regions are sequentially spliced ​​in the order from left to right and from top to bottom in the target image to obtain the target region.

[0131] To facilitate understanding, the above process of determining the target area is described below with an example.

[0132] like Figure 6As shown in the figure, the target image contains four characters: "填", "报", "说", and "明". Through the text recognition network model, the text in the target image is recognized to obtain four text regions, which are the regions corresponding to the four characters "填", "报", "说", and "明" respectively. If the height and width of these four text regions are both 8, and the horizontal alignment dimension and the 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 padding dimension and the vertical padding dimension are both 16 - 8 = 8. A preset pixel value with a height of 16 and a width of 8 is padded on the right side outside the text region, and a preset pixel value with a height of 8 and a width of 16 is padded on the lower side outside the text region to obtain the padded text region. Then, in the order of the four characters "填", "报", "说", and "明" from left to right and from top to bottom in the target image, these multiple padded text regions are sequentially spliced to obtain Figure 6 the target region in

[0133] It should be noted that the target image can be an independent image or any video frame image in a video. The embodiments of the present application do not limit this.

[0134] The above is an introduction 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. The 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). The reference basic units corresponding to two adjacent basic units are usually not the same, and there are significant differences in the position vectors of these two adjacent basic units. In the embodiments of the present 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.

[0135] For example, if the target image contains multiple emoticons, the multiple emoticons meet the above-mentioned character attributes, that is, the position vector of the emoticon content points 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 usually not the same, and the position vectors of the two adjacent emoticons are quite different. In this case, the emoticon can be used as a basic unit, and the target area can be the emoticon area in the target image that is aligned according to the target alignment size, and the emoticon area includes at least one emoticon. For another example, if the target image contains multiple sub-images, the multiple sub-images meet the above-mentioned character attributes, that is, the position vector of the sub-image content points 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 usually not the same, and the position vectors of the two adjacent sub-images are quite different. In this case, the sub-image can be used as a basic unit, and the target area can be the sub-image sub-area in the target image that is aligned according to the target alignment size, and the sub-image area includes at least one sub-image.

[0136] It should be noted that the implementation method of aligning the region with character attributes in the target image to obtain the target region is similar to the implementation method of aligning the text region in the target image to obtain the target region, which will not be described here. And because the target region is obtained after aligning the region with character attributes in the target image, there are many possibilities for the region with character attributes in the target image. Therefore, for the convenience of description, the target region is introduced as the text region after alignment processing as an example.

[0137] 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.

[0138] Step 502: Determine a position vector difference of a current block to be encoded in a target area, wherein the position vector difference indicates a difference between a position vector of the current block and a reference position vector, wherein the position vector of the current block indicates a positional relationship between the current block and a reference block corresponding to the current block.

[0139] 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, and 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 the position vector of the current block minus the reference position vector is determined as the position vector difference of the current block.

[0140] 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 is the position vector difference, and the first flag bit indicates the category of the position identification data.

[0141] 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.

[0142] 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, and 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, 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.

[0143] 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, thereby ensuring the accuracy of the encoding and decoding of the horizontal component.

[0144] 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 numerical value is determined as the value of the horizontal flag bit.

[0145] 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, and therefore the horizontal component is directly determined as horizontal identification data, thereby 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.

[0146] In some embodiments, 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 includes a vertical flag, and 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 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.

[0147] 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 bitstream, ensuring the accuracy of the encoding and decoding of the vertical component.

[0148] 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 numerical value is determined as the value of the vertical flag bit.

[0149] 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 alignment size into the bitstream, thereby ensuring the accuracy of the encoding and decoding of the vertical component.

[0150] 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. In different situations, the value may be adjusted according to different requirements.

[0151] 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, that is, the horizontal component is an integer multiple of the horizontal alignment size, so 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, so the vertical identification data is 4, and the value of the vertical flag is 1.

[0152] 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, so 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, so the vertical identification data is 4, and the value of the vertical flag is 1.

[0153] 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.

[0154] Since the remainder of the position vector difference divided by the target alignment size must not be 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. And 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, the encoding efficiency of the image containing text content is improved. Of course, in the case where 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 methods, and the embodiments of the present application are not limited to this.

[0155] Step 504: Encode the position identification data and the first flag bit corresponding to the position vector difference into the bitstream.

[0156] 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.

[0157] 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.

[0158] 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. In this way, the number of bits required for encoding the side information can be effectively reduced, thereby effectively improving the encoding efficiency.

[0159] In some embodiments, the side information can be encoded into the bitstream by differential coding, the residual information of the current block can be encoded into the bitstream by entropy coding, the first flag bit can be encoded into the bitstream by binary coding, and the position identification data can be encoded into the bitstream by exponential Golomb coding. Optionally, when the target non-text area is determined, the target non-text area can also be encoded into the bitstream. Of course, in practical applications, other encoding methods can also be used to encode the above information into the bitstream. The embodiments of the present application are not limited to this.

[0160] 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.

[0161] Table 1

[0162]

[0163] As shown in Table 1, mvd_coding(x0, y0) indicates encoding the position vector difference of the current block with coordinates (x0, y0).

[0164] 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, and 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.

[0165] 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, and abs_mvd_greater1_flag[compIdx] can be 1 or 0. If the absolute value of the position identification data is greater than 1, abs_mv d_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.

[0166] 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.

[0167] The meaning of if(abs_mvd_greater0_flag[1])abs_mvd_greater1_flag[1] is similar to the meaning 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.

[0168] 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[compId x] is 1, and 1 is encoded into the bitstream, otherwise mvd_ada_precision_flag[compIdx] is 0, and 0 is encoded into the bitstream. 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 bitstream, otherwise 0 is encoded into the bitstream. 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 bitstream, otherwise 0 is encoded into the bitstream.

[0169] 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.

[0170] 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.

[0171] 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 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 the horizontal identification data, and when compIdx is 1, it indicates the vertical identification data. Therefore, mvd_sign_flag[0] indicates the positive or negative 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 a positive value, 0 is encoded into the bitstream, otherwise 1 is encoded into the bitstream.

[0172] The original syntax of abs_mvd_minus2[0] and abs_mvd_minus2[1] is abs_mvd_minus2[compIdx]. abs_mvd_minus2[compIdx] indicates 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 indicates the horizontal identification data, and when compIdx is 1, it indicates the 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.

[0173] 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.

[0174] 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]} in the above text. For details, please refer to the relevant content in the above text and will not be repeated here.

[0175] 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, therefore, 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.

[0176] 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 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. 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 ensuring the accuracy of the encoding of the position vector difference and improving the encoding efficiency of images containing text content.

[0177] 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 has strong portability and can improve the encoding efficiency of images containing text content without increasing additional hardware costs.

[0178] Figure 8 is a flowchart of the first decoding method provided in the embodiment of the present application. The decoding method corresponds to the above Figure 5 Please refer to the encoding method shown in Figure 8 , the method comprises the following steps.

[0179] Step 801: parse 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.

[0180] 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 is the position vector difference, and the first flag indicates the category of the position identification data.

[0181] Step 802: Determine the position vector difference based on the target alignment size, the position identification data and the first flag bit.

[0182] In some embodiments, when the side information includes the target alignment size and the side information is encoded into the bitstream, the side information may be parsed from the bitstream to obtain the target alignment size.

[0183] 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 of the bitstream, reducing the time required for decoding, and effectively improving decoding efficiency.

[0184] In some embodiments, the position vector difference may be determined based on the value of the first flag bit, through the target alignment size and the position identification data.

[0185] 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 numerical 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 numerical value, the horizontal identification data is determined as the horizontal component.

[0186] When the value of the horizontal flag is the first numerical value, it indicates that the horizontal identification data is a multiple of the horizontal component relative to the horizontal alignment size, and 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 numerical value, it indicates that the horizontal identification data is the horizontal component, and therefore, the horizontal identification data can be directly determined as the horizontal component.

[0187] In some other embodiments, 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. In this case, if the value of the vertical flag bit is a first numerical value, the vertical alignment size is multiplied by the vertical identification data to obtain the vertical component. If the value of the vertical flag bit is a second numerical value, the vertical identification data is determined as the vertical component.

[0188] Similarly to the above, when the value of the vertical flag is the first value, it means that the vertical identification data is a multiple of the vertical component relative to the vertical alignment size, so 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 means that the vertical identification data is the vertical component, so the vertical identification data can be directly determined as the vertical component.

[0189] 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, that is, 16. The vertical component is equal to the vertical flag data multiplied by the vertical alignment size, that is, 64.

[0190] 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.

[0191] 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 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 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.

[0192] Step 803: Reconstruct the current block based on the position vector difference of the current block.

[0193] In some embodiments, residual information of the current block may also be parsed from the bitstream, the residual information indicating a prediction residual between the current block and the reference block. In this case, the current block may be reconstructed based on the position vector difference and the residual information.

[0194] 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 the reconstruction of the target area.

[0195] 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.

[0196] Optionally, after the target area is reconstructed, a target image may be reconstructed based on the target area and the target non-text area.

[0197] 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.

[0198] 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 practical applications, the text area can also be determined by other methods. The embodiments of the present application are not limited to this.

[0199] Optionally, the side information also includes the position of the text area in the target image. In this case, the area in the target non-text area that is consistent with the position of the text area can be replaced with the text area to obtain a reconstructed target image. Of course, in practical applications, the target image can also be reconstructed in other ways. The embodiments of the present application are not limited to this.

[0200] 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.

[0201] Table 2

[0202]

[0203]

[0204] As shown in Table 2, mvd_decoding(x0, y0) indicates decoding the position vector difference of the current block with coordinates (x0, y0).

[0205] 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.

[0206] In the case where 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 of the target alignment size is encoded into the bitstream, so that when encoding the position vector difference, there is no need to encode the number of shift bits corresponding to the target alignment size.

[0207] The number of shift bits corresponding to the target alignment size is related to the number of binary bits of the target alignment size. Optionally, the number of shift bits corresponding to the target alignment size is equal to the number of binary bits 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 is not limited in the embodiments of the present application.

[0208] 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 relevant content in Table 1.

[0209] Next, the decoding process shown in Table 2 is introduced:

[0210] abs_mvd_greater0_flag[0] and abs_mvd_greater0_flag[1] indicate the values ​​of abs_mvd_greater0_flag[0] and abs_mvd_greater0_flag[1] parsed from the bitstream.

[0211] if(abs_mvd_greater0_flag[0])abs_mvd_greater1_flag[0] means 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 identification data is determined to be 0.

[0212] 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.

[0213] if(abs_mvd_greater0_flag[0])mvd_ada_precision_flag[0] means 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.

[0214] 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 bitstream. Otherwise, the vertical identification data is determined to be 0.

[0215] 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 after abs_mvd_minus2[0] plus 2 is determined, and the value after the binary value is shifted left by the number of shift bits corresponding to the horizontal alignment size is determined as abs_mvd_org[0]. If mvd_ada_precision_flag[0] is 0, the value after abs_mvd_minus2[0] plus 2 is determined as abs_mvd_org[0]. The value of mvd_sign_flag[0] is parsed from the bitstream.

[0216] The meanings of the syntax in lines 21 to 29 in Table 2 are similar to those in lines 12 to 20 in Table 2. For details, please refer to the relevant content above and will not be repeated here.

[0217] 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 the decoding process, the value of the position vector difference can be calculated by the following expression (1);

[0218] Mvd[compIdx]=abs_mvd_greater0_flag[compIdx]*abs_mvd_org[compIdx]*(1–2*mvd_sign_flag[compIdx])(1)

[0219] 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 bit stream, 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 bit stream.

[0220] Since 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, therefore, 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, so that the decoding efficiency of the image containing text content can be improved while ensuring the decoding accuracy. In addition, if during the encoding process, when 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. Since the coding bits required for the quotient and remainder of the position vector difference divided by the target alignment size are less than the coding bits required for the position vector difference of the current block, therefore, 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, so that the decoding efficiency of the image containing text content can be improved while ensuring the decoding accuracy.

[0221] 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 has strong portability and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.

[0222] The embodiment of the present application also provides a second encoding method, which includes the following steps.

[0223] Step 901: Acquire a target area, where the target area is obtained by aligning a target image according to a target alignment size.

[0224] 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.

[0225] 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.

[0226] 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.

[0227] Step 903: Based on the target alignment size and the position vector difference of the current block, determine the position identification data and the first flag bit corresponding to the position vector difference, 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 the category of the position identification data.

[0228] 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.

[0229] In some embodiments, the target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. In this case, a multiple of the horizontal component relative to the horizontal alignment size is determined as the horizontal identification data, 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.

[0230] 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.

[0231] 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 multiples of the horizontal component relative to the horizontal alignment size can accurately represent the horizontal component, and the multiples of the vertical component relative to the vertical alignment size can also accurately represent the vertical component. Therefore, the multiples of the horizontal component relative to the horizontal alignment size can be determined as horizontal identification data, and the multiples 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, thereby ensuring the accuracy of encoding and decoding of the horizontal component and the vertical component.

[0232] 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 numerical value is determined as the value of the first flag bit.

[0233] 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 into the bitstream, and / or the situation where vertical component encoding errors are caused by encoding the multiple of the vertical alignment size into the bitstream, thereby ensuring the accuracy of encoding and decoding of the horizontal and vertical components.

[0234] 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. In different situations, the value may be adjusted according to different requirements.

[0235] 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 identification data is 1, the vertical identification data is 4, and the value of the first flag bit is 1.

[0236] 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, so the horizontal identification data is 17, the vertical identification data is 64, and the value of the first flag bit is 0.

[0237] 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 ways of determining the position identification data.

[0238] 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, in the case where 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 the embodiments of the present application.

[0239] Step 904: Encode the position identification data and the first flag bit corresponding to the position vector difference into the bitstream.

[0240] For the implementation method of encoding the position identification data and the first flag bit corresponding to the position vector difference into the bit stream, please refer to the relevant content in the first encoding method above, which will not be repeated here.

[0241] 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.

[0242] Table 3

[0243]

[0244] In the above Table 3, 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.

[0245] 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 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 bitstream, otherwise mvd_ada_precision_flag is 0 and 0 is encoded into the bitstream.

[0246] The rest of the syntax in Table 3 that is similar to that in Table 1 will not be described in detail here. For details, please refer to the corresponding relevant content in Table 1.

[0247] For a target image containing text content, after the target image is aligned according to the target alignment size to obtain the 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 are respectively encoded into the bitstream as position identification data. Since 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, therefore, 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 a high encoding efficiency of the image containing text content.

[0248] 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.

[0249] 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 has strong portability and can improve the encoding efficiency of images containing text content without increasing additional hardware costs.

[0250] 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.

[0251] Step 1001: Parse 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.

[0252] 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 is the position vector difference, and the first flag indicates the category of the position identification data.

[0253] 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.

[0254] Optionally, the position vector difference may be determined based on the value of the first flag bit, through the target alignment size and the position identification data.

[0255] In some embodiments, the target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. In this case, if the value of the first flag 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. If the value of the first flag 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.

[0256] 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, and 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, and 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.

[0257] 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.

[0258] 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 numerical value 0. In this case, the horizontal component is the horizontal identification data, that is, 17, and the vertical component is the vertical identification data, that is, 64.

[0259] Based on the above description, if during the encoding process, when the horizontal component is not an integer multiple of the horizontal alignment size, and / or when the vertical component is not an integer multiple of the vertical alignment size, the quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size are determined as horizontal identification data, the quotient and remainder obtained by dividing the vertical component by the vertical alignment size are determined as vertical identification data, and the second value is determined as the value of the first flag. 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 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.

[0260] Step 1003: Reconstruct the current block based on the position vector difference.

[0261] 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.

[0262] 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.

[0263] Table 4

[0264]

[0265]

[0266] The syntax of the above Table 4 is similar to that of Tables 1 to 3, which will not be repeated here. For details, please refer to the corresponding relevant content of Tables 1 to 3.

[0267] 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).

[0268] Since the encoding bits required for the 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, therefore, when the value of the first flag bit is the first value, the efficiency of decoding the position identification data is higher than the efficiency of decoding the position vector difference, so that the decoding efficiency of the image containing text content can be improved while ensuring the decoding accuracy. In addition, if during the encoding process, 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 quotient and remainder obtained by dividing the horizontal component by the horizontal alignment size are determined as the horizontal identification data, the quotient and remainder obtained by dividing the vertical component by the vertical alignment size are determined as the vertical identification data, and the second value is determined as the value of the first flag bit. Since the number of bits required to encode the quotient and remainder is less than the number of bits required to directly encode the position vector difference, therefore, 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, so that the decoding efficiency of the image containing text content can be improved while ensuring the decoding accuracy.

[0269] 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 has strong portability and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.

[0270] The present application embodiment also provides a third encoding method, which includes the following steps.

[0271] Step 1101: Acquire a target area, where the target area is obtained by aligning a target image according to a target alignment size.

[0272] 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.

[0273] 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.

[0274] 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.

[0275] Step 1103: Based on the target alignment size and the position vector difference of the current block, determine the position identification data and the first flag bit corresponding to the position vector difference, 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 the category of the position identification data.

[0276] 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, and the horizontal flag bit is further used to indicate the horizontal component in combination with the horizontal identification data. In this case, the quotient obtained by dividing the horizontal component by the horizontal alignment size is determined as the horizontal identification data, and the remainder obtained by dividing the horizontal component by the horizontal alignment size is determined as the value of the horizontal flag bit.

[0277] 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 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 encoding and decoding of the horizontal component.

[0278] In some other embodiments, 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 includes a vertical flag, which is also used to indicate the vertical component in combination with the vertical identification data. In this case, the quotient obtained by dividing the vertical component by the vertical alignment size is determined as the vertical identification data, and the remainder obtained by dividing the vertical component by the vertical alignment size is determined as the value of the vertical flag.

[0279] 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, thereby ensuring the accuracy of the encoding and decoding of the vertical component.

[0280] As an example, 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, that is, the quotient obtained by dividing the horizontal component by the horizontal alignment size is 1, and the remainder is 0. For the vertical component, 64÷16=4, that is, the quotient obtained by dividing the vertical component by the vertical alignment size is 4, and the remainder is 0.

[0281] 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…1, that is, the quotient obtained by dividing the horizontal component by the horizontal alignment size is 1, and the remainder is 1. For the vertical component, 64÷16=4, that is, the quotient obtained by dividing the vertical component by the vertical alignment size is 4, and the remainder is 0.

[0282] Step 1104: Encode the position identification data and the first flag bit corresponding to the position vector difference into the bitstream.

[0283] For the implementation method of encoding the position identification data and the first flag bit corresponding to the position vector difference into the bit stream, please refer to the relevant content in the first encoding method above, which will not be repeated here.

[0284] 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.

[0285] Table 5

[0286]

[0287]

[0288] 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 the horizontal identification data, and when compIdx is 1, it represents the 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.

[0289] 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.

[0290] 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 relevant content in Table 1.

[0291] For a target image containing text content, after the target image is aligned according to the target alignment size to obtain the target area, 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. 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 of the current block, therefore, 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 a high encoding efficiency of the image containing text content.

[0292] 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 has strong portability and can improve the encoding efficiency of images containing text content without increasing additional hardware costs.

[0293] 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.

[0294] Step 1201: parse 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.

[0295] 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 is the position vector difference, and the first flag indicates the category of the position identification data.

[0296] 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.

[0297] 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, and the horizontal flag bit is further used to indicate the horizontal component in combination with the horizontal identification data. In this case, the quotient included in 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.

[0298] In some other embodiments, 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 includes a vertical flag, which is also used to indicate the vertical component in combination with the vertical identification data. In this case, the quotient included in the vertical identification data is multiplied by the vertical alignment size and then added to the value of the vertical flag to obtain the vertical component.

[0299] Step 1203: Reconstruct the current block based on the position vector difference.

[0300] 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.

[0301] 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.

[0302] Table 6

[0303]

[0304] The syntax of the above Table 6 is similar to that of Table 1, Table 2 and Table 5, which will not be repeated here. For details, please refer to the corresponding relevant contents of Table 1, Table 2 and Table 5.

[0305] 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).

[0306] 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.

[0307] 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 has strong portability and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.

[0308] The present application embodiment also provides a fourth encoding method, which includes the following steps.

[0309] Step 1301: Acquire a target area, where the target area is obtained by aligning a target image according to a target alignment size.

[0310] 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.

[0311] 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.

[0312] In some embodiments, a first candidate position vector difference and a second candidate position vector difference of the current block are determined, the first candidate position vector difference is determined according to a first pixel precision, 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 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 a smaller rate-distortion cost among the first candidate position vector difference and the second candidate position vector difference is determined as the position vector difference of the current block.

[0313] 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 a first reference block, and 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 a second reference block, and the second reference block is a reference block corresponding to the current block determined based on the second pixel precision.

[0314] Based on the first position vector, according to the relevant prediction coding algorithm, a first reference position vector corresponding to the first position vector is determined, and the value of the first position vector minus the first reference position vector is determined as a first candidate position vector difference, and the first reference position vector is determined based on the first pixel precision. Based on the second position vector, according to the relevant prediction coding algorithm, a second reference position vector corresponding to the second position vector is determined, and the value of the second position vector minus the second reference position vector is determined as a second candidate position vector difference, and the second reference position vector is determined based on the second pixel precision.

[0315] 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.

[0316] 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 the embodiments of the present application.

[0317] Based on the above description, the encoder finds the reference block corresponding to the current block from the encoded reference image through a motion search algorithm. Since there are multiple coding units (i.e., multiple blocks) in the encoded reference image, the encoder can determine the reference block corresponding to the current block from the multiple blocks according to a certain pixel precision. For example, the second pixel precision is 16, and the coordinates of the current block are (50, 21). In this case, based on the coordinates of the current block, the second reference block is determined by the motion search algorithm with the second pixel precision (i.e., 16) as the step length, and the relative displacement between the current block and the second reference block is determined as the second position vector. Since the second reference block is obtained by searching with a step length of 16 based on the coordinates of the current block, the relative displacement between the current block and the second reference block must be a multiple of the second pixel precision, that is, 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 the second reference position vector 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.

[0318] 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 the embodiment of the present application does not limit this. 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 by a motion search algorithm based on the coordinates of the current block, with the horizontal pixel precision as the step length in the horizontal direction and the vertical pixel precision as the step length in the vertical direction.

[0319] Step 1303: Based on the target alignment size and the position vector difference of the current block, determine the position identification data and the first flag bit corresponding to the position vector difference, 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 the category of the position identification data.

[0320] 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.

[0321] 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.

[0322] 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.

[0323] 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, and 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, so that the horizontal component and the vertical component can be accurately encoded into the bitstream, ensuring the accuracy of encoding and decoding of the horizontal component and the vertical component.

[0324] 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 into the bitstream at a multiple of the horizontal alignment size, and the situation where vertical component encoding errors are caused by encoding the vertical component into the bitstream at a multiple of the vertical alignment size, thereby ensuring the accuracy of encoding and decoding of the horizontal and vertical components.

[0325] 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. In different situations, the value may be adjusted according to different requirements.

[0326] 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 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 ways of determining the position identification data.

[0327] 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 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 improving the encoding efficiency of images containing text content while ensuring the accuracy of the encoding of the position vector difference. Of course, in the case where 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 is not limited in the embodiments of the present application.

[0328] Step 1304: Encode the position identification data and the first flag bit corresponding to the position vector difference into the bitstream.

[0329] For the implementation method of encoding the position identification data and the first flag bit corresponding to the position vector difference into the bitstream, please refer to the relevant content in the first encoding method above.

[0330] As an example, when the position vector difference is MVD, during encoding, ammvd_flag may be used to indicate whether the first flag bit is equal to 1. ammvd_flag may 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.

[0331] For a target image containing text content, after the target image is aligned according to the target alignment size to obtain the target area, when the position vector difference of the current block is the 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 a high encoding efficiency of the image containing text content.

[0332] 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 be determined as vertical identification data, and the second numerical value can be determined as the value of the first flag. 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 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, while ensuring the accuracy of the encoding of the position vector difference, the encoding efficiency of the image containing text content is improved.

[0333] 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 has strong portability and can improve the encoding efficiency of images containing text content without increasing additional hardware costs.

[0334] 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.

[0335] Step 1401: parse 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.

[0336] 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 is the position vector difference, and the first flag indicates the category of the position identification data.

[0337] 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.

[0338] In some embodiments, the position vector difference may be determined based on the value of the first flag bit, through the target alignment size and the position identification data.

[0339] In some embodiments, the target alignment size includes a horizontal alignment size and a vertical alignment size, the position vector difference includes a horizontal component and a vertical component, and the position identification data includes horizontal identification data and vertical identification data. In this case, if the value of the first flag 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. If the value of the first flag 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.

[0340] The value of the first flag bit is the first numerical value, indicating 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 numerical value, indicating 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.

[0341] Based on the above description, 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 horizontal identification data, the quotient and remainder obtained by dividing the vertical component by the vertical alignment size are determined as vertical identification data, and the second value is determined as the value of the first flag. 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.

[0342] Step 1403: Reconstruct the current block based on the position vector difference.

[0343] 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.

[0344] As an example, in the case where 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 after the binary number of the position identification data is left-shifted by the number of shift bits corresponding to the target alignment size is determined as the position vector difference. That is, by left-shifting the binary number of the position identification data, the target alignment size is multiplied by the position identification data to obtain the position vector difference, or the position identification data is directly used as the position vector difference.

[0345] 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.

[0346] 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 of the binary horizontal identification data after being shifted left by the number of bits corresponding to the horizontal alignment size is determined as the horizontal component, and the value of the binary vertical identification data after being shifted left by the number of bits corresponding to the vertical alignment size is determined as the vertical component.

[0347] As an example, if ammvd_flag is 1 when parsed from the bitstream, the first flag bit is determined to be 1, that is, the first flag is the first value. If ammvd_flag is 0 when parsed from the bitstream, the first flag bit is determined not to be 1, that is, the first flag is the second value.

[0348] For example, AmmvdShift[compIdx] can be used to represent the number of shift bits corresponding to the target alignment size under the first pixel precision and the second pixel precision. The number of shift bits corresponding to the target alignment size under the first pixel precision is 0, and the number of shift bits corresponding to the target alignment size under the second pixel precision is related to the number of binary bits of the target alignment size. When the target alignment size includes the horizontal alignment size and the vertical alignment size, compIdx can be 0 or 1. When compIdx is 0, it indicates the horizontal alignment size, and when compIdx is 1, it indicates the vertical alignment size.

[0349] Optionally, the number of moving 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, the number of moving bits corresponding to the target alignment size under the second pixel precision is 3. If the target alignment size is 16, the number of moving bits corresponding to the target alignment size under the second pixel precision is 4. If the target alignment size is 32, the number of moving bits corresponding to the target alignment size under the second pixel precision is 5. If the target alignment size is 64, the number of moving bits corresponding to the target alignment size under the second pixel precision is 6. Of course, the number of moving bits corresponding to the target alignment size can also be determined by other methods, and the embodiments of the present application are not limited to this.

[0350] In practical applications, the coding method provided by this application needs to allow the use of adaptive multiple integer pixel precision MVD prediction coding (aadaptive multiple integer pixel precision MVD, AMMVD) technology. In this case, sps_ammvd_enabled_flag can be used to indicate whether the coding network allows the use of AMMVD technology, 1 means allowed, and 0 means not allowed. In the case of allowing the use of AMMVD technology, the fourth coding method can be used for coding and decoding.

[0351] Since the encoding bits required for the 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 numerical value, the efficiency of decoding the position identification data is higher than the efficiency of decoding the position vector difference, so that the decoding efficiency of the image containing text content can be improved while ensuring the 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 numerical value is determined as the value of the first flag bit. Since the number of bits required for encoding the quotient and remainder is less than the number of bits required for directly encoding the position vector difference, when the first flag bit is the second numerical value, the efficiency of decoding the position identification data is also higher than the efficiency of decoding the position vector difference, thereby ensuring the decoding accuracy while improving the decoding efficiency of the image containing text content.

[0352] 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 has strong portability and can improve the decoding efficiency of images containing text content without increasing additional hardware costs.

[0353] Fig. 9 is a schematic diagram of the structure of a coding device provided in an embodiment of the present application. The coding device can be implemented by software, hardware or a combination of both to become part or all of the coding end, and the coding device can be Figure 1 The encoder 100 in FIG. Fig. 9 The device includes: an acquisition module 901, a first determination module 902, a second determination module 903 and a first encoding module 904.

[0354] The acquisition module 901 is used to acquire the target area, which is obtained after the target image is aligned according to the target alignment size. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.

[0355] The first determination module 902 is used to determine the position vector difference of the current block to be encoded in the target area, the position vector difference indicates the difference between the position vector of the current block and the reference position vector, and 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 detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.

[0356] The second determination module 903 is used to determine 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, wherein 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 the category of the position identification data. The detailed implementation process refers to the corresponding content in the above-mentioned embodiments, which will not be repeated here.

[0357] The first encoding module 904 is used to encode the position identification data and the first flag bit into the bit stream. The detailed implementation process refers to the corresponding content of each of the above embodiments, which will not be repeated here.

[0358] 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;

[0359] The second determining module 903 is specifically used for:

[0360] 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.

[0361] Optionally, the second determining module 903 is specifically configured to:

[0362] 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.

[0363] 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;

[0364] The second determining module 903 is specifically used for:

[0365] 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.

[0366] Optionally, the second determining module 903 is specifically configured to:

[0367] 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.

[0368] 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;

[0369] The second determining module 903 is specifically used for:

[0370] 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.

[0371] Optionally, the first determining module 902 is specifically configured to:

[0372] 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;

[0373] Determining a rate-distortion cost of the first candidate position vector difference and a rate-distortion cost of the second candidate position vector difference;

[0374] The candidate position vector difference with 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.

[0375] Optionally, the second determining module 903 is specifically configured to:

[0376] 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.

[0377] Optionally, the second determining module 903 is specifically configured to:

[0378] 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.

[0379] 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;

[0380] The second determining module 903 is specifically used for:

[0381] 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.

[0382] 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;

[0383] The second determining module 903 is specifically used for:

[0384] 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.

[0385] 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.

[0386] Optionally, the device further comprises:

[0387] 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 a reference block.

[0388] For a target image containing text content, after the target image is aligned according to the target alignment size to obtain the 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 the encoding accuracy, thereby ensuring a high encoding efficiency for images containing text content.

[0389] It should be noted that: when the encoding device provided in the above embodiment performs encoding, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is 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 belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0390] Fig.10 is a schematic diagram of a decoding device provided in an embodiment of the present application. The decoding device can be implemented by software, hardware or a combination of both to form part or all of a decoding end. Moreover, the decoding device can be Figure 1 Decoder 200 in . Fig.10 The device includes: a first parsing module 1001, a determining module 1002 and a reconstruction module 1003.

[0391] A first parsing module 1001 is used to parse 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;

[0392] 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 is the position vector difference, and the first flag indicates the category of the position identification data. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.

[0393] The determination module 1002 is used 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 refers to the corresponding content in the above embodiments, which will not be repeated here.

[0394] The reconstruction module 1003 is used to reconstruct the current block based on the position vector difference. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.

[0395] 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;

[0396] The determination module 1002 is specifically used for:

[0397] If the value of the horizontal flag bit is the first value, the horizontal alignment size is multiplied by the horizontal identification data to obtain the horizontal component.

[0398] Optionally, the determining module 1002 is specifically configured to:

[0399] If the value of the horizontal flag bit is the second numerical value, the horizontal identification data is determined as the horizontal component.

[0400] 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;

[0401] The determination module 1002 is specifically used for:

[0402] 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.

[0403] Optionally, the determining module 1002 is specifically configured to:

[0404] If the value of the vertical flag is the second numerical value, the vertical identification data is determined as the vertical component.

[0405] 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;

[0406] The determination module 1002 is specifically used for:

[0407] 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.

[0408] Optionally, the determining module 1002 is specifically configured to:

[0409] If the value of the first flag bit is the second numerical value, the horizontal identification data is determined as the horizontal component, and the vertical identification data is determined as the vertical component.

[0410] 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;

[0411] The determination module 1002 is specifically used for:

[0412] The horizontal component is obtained by multiplying the horizontal identification data by the horizontal alignment size and then adding it to the value of the horizontal flag.

[0413] 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;

[0414] The determination module 1002 is specifically used for:

[0415] 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.

[0416] Optionally, the device further comprises:

[0417] A second parsing module, used 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;

[0418] The reconstruction module 1003 is specifically used for:

[0419] The current block is reconstructed based on the position vector difference and the residual information.

[0420] 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 bit 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 the decoding accuracy. 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.

[0421] It should be noted that: when the decoding device provided in the above embodiment performs decoding, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is 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 belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0422] An embodiment of the present application further provides a computer-readable storage medium, 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 above embodiment, or executes the steps of the decoding method described in the above embodiment.

[0423] The embodiment of the present application also provides a computer program product containing instructions, which, when executed on a computer, enables the computer to execute the steps of the encoding method described in the above embodiment, or 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, enables the computer to execute the steps of the encoding method described in the above embodiment, or the steps of the decoding method described in the above embodiment.

[0424] 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.

[0425] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part 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, the process or function described in the embodiment of the present application is generated in whole or in part. 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 a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, 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 embodiment of the present application may be a non-volatile storage medium, in other words, a non-transient storage medium.

[0426] It should be understood that the "multiple" 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 only a description of the association relationship of the 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 the clear description of the technical solution of the embodiments of the present application, in the embodiments of the present application, the words "first", "second" and the like are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not limit them to be necessarily different.

[0427] 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 for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of the present 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 the present application is obtained with full authorization.

[0428] The above-mentioned embodiments are provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present 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, 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.

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

Cited By

  • Coding method, decoding method, apparatus, device, storage medium and computer program

    EP4668746A1

  • Coding method, decoding method, apparatus, device, storage medium and computer program

    WO2024183561A1