CN113301339A - Data encoding and decoding method and device - Google Patents

Data encoding and decoding method and device Download PDF

Info

Publication number
CN113301339A
CN113301339A CN202110507913.2A CN202110507913A CN113301339A CN 113301339 A CN113301339 A CN 113301339A CN 202110507913 A CN202110507913 A CN 202110507913A CN 113301339 A CN113301339 A CN 113301339A
Authority
CN
China
Prior art keywords
macro block
format
code stream
image
rgb
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110507913.2A
Other languages
Chinese (zh)
Inventor
张路
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xian Wanxiang Electronics Technology Co Ltd
Original Assignee
Xian Wanxiang Electronics Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xian Wanxiang Electronics Technology Co Ltd filed Critical Xian Wanxiang Electronics Technology Co Ltd
Priority to CN202110507913.2A priority Critical patent/CN113301339A/en
Publication of CN113301339A publication Critical patent/CN113301339A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/154Measured or subjectively estimated visual quality after decoding, e.g. measurement of distortion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/222Studio circuitry; Studio devices; Studio equipment
    • H04N5/262Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
    • H04N5/268Signal distribution or switching

Abstract

The disclosure provides a data encoding and decoding method and device, relates to the technical field of electronic information, and can solve the problem of image distortion in the image encoding process. The specific technical scheme is as follows: when the image is coded and processed, the image is firstly converted one by one macro block, when the image conversion processing result indicates that the macro block is positioned in the image distortion range, the macro block is determined to be the macro block in the RGB format, otherwise, the macro block is determined to be the macro block in the YUV format, and the macro blocks in different formats are coded respectively. The present disclosure is used for encoding and decoding processes of images.

Description

Data encoding and decoding method and device
Technical Field
The present disclosure relates to the field of electronic information technologies, and in particular, to a method and an apparatus for encoding and decoding data.
Background
The invention relates to an image coding and decoding method, in particular to a method for processing a computer composite image. As various scenes such as office work, games and the like need to be covered, a user has certain requirements on the frame rate, the code rate and the display effect. The current encoding and decoding scheme can be designed according to specific scenes, for example, aiming at game design, frame rate and fluency are usually ensured, and the requirement on display effect is not strict; for office work and design, the requirements on the display effect are relatively stricter. Thus, different products are applied to different scenarios. Aiming at different coding scenes, the same coding strategy is difficult to uniformly cope with all scenes.
Therefore, when encoding processing is performed, it is necessary to perform uniform format processing on images of different formats, and finally, encoding processing is performed on an image of one format. However, in the format conversion process, a problem of image distortion may occur, for example, when the encoding strategy is for the YUV format and the format of the acquired image is RGB, image conversion processing is required, and color is lost in the process of converting the image from the RGB format to the YUV format, which causes color difference.
Disclosure of Invention
The embodiment of the disclosure provides a data encoding method and device, and a data decoding method and device, which can solve the problem of image distortion in an image encoding process. The technical scheme is as follows:
according to a first aspect of embodiments of the present disclosure, there is provided a data encoding method, the method including:
collecting original image frames, and performing YUV format conversion processing on the original image frames block by block;
when the macro block after the conversion processing is positioned in the image distortion range, classifying the macro block into a macro block in an RGB format;
when the macro block after conversion processing is not in the image distortion range, classifying the macro block into a YUV format macro block, and classifying the YUV format macro block into a character type macro block and an image type macro block;
and coding the macro block in the RGB format according to a first coding rule, and coding the macro block in the YUV format according to a second coding rule, wherein the coding quality of the first coding rule is higher than that of the second coding rule, and the second coding rule comprises a macro block coding rule according to an image type and a character type.
In one embodiment, the method further comprises:
obtaining pixels in the transformed macroblock;
judging whether the pixels in the converted macro blocks are positioned in an image distortion range one by one, and acquiring the number of the pixels positioned in the preset image distortion range;
and when the number of the pixels in the preset image distortion range is larger than a preset threshold value, determining that the macro block is in the image distortion range.
In one embodiment, the method for encoding the macroblock in YUV format according to the second encoding rule includes:
according to a preset algorithm, determining an adjacent macro block adjacent to the RGB macro block in the YUV format macro block;
quantizing the adjacent macro block according to the first quantization value, and encoding the quantized macro block;
quantizing the non-adjacent macro blocks in the YUV format macro blocks according to the second quantized value, and encoding the quantized adjacent macro blocks;
wherein the first quantized value is greater than the second quantized value.
In one embodiment, the method for encoding the RGB-format macro block includes:
acquiring a reference frame corresponding to the original frame image;
according to a preset algorithm, carrying out XOR processing on the RGB-format macro block and a macro block corresponding to the RGB-format macro block in a reference frame, and obtaining the XOR processing result;
and carrying out coding processing on the result of the exclusive-or processing to finish the coding processing on the macro block in the RGB format.
In one embodiment, the method further comprises:
acquiring an encoding code stream of the macro block in the RGB format, wherein the encoding code stream comprises identification information corresponding to the code stream, and the identification information comprises an image format corresponding to the code stream;
acquiring a code stream of the macro block in the YUV format;
and generating a target code stream according to the coding code stream of the macro block in the RGB format and the coding code stream of the macro block in the YUV format.
According to a second aspect of the embodiments of the present disclosure, there is provided a data decoding method, including:
acquiring a target code stream, wherein the target code stream is a code stream obtained after the original frame image is coded, the target code stream comprises a code stream in an RGB format and a code stream in a YUV format, and the code stream in the YUV format comprises: an image type code stream and an RGB format code stream;
decoding the code stream in the RGB format according to a first decoding rule to obtain a macro block in the first RGB format, and decoding the code stream in the YUV format according to a second decoding rule to obtain the macro block in the YUV format, wherein the decoding quality of the first decoding rule is higher than that of the second decoding rule, and the second decoding rule comprises a decoding rule according to an image type code stream and a character type code stream;
performing RGB format conversion processing on the macro block in YUV format to generate a macro block in a second RGB format;
and fusing the first RGB-format macro block and the second RGB-format macro block to generate an original frame image.
In one embodiment, a target code stream in the method includes identification information of a macroblock, where the identification information includes an image format corresponding to the code stream, and the image format at least includes: RGB type and YUV type, the method further comprising:
determining an image format corresponding to the target code stream according to the identification information of the macro block;
and determining a decoding rule corresponding to the target code stream according to the image format corresponding to the target code stream.
In one embodiment, the method further comprises: acquiring a reference frame corresponding to the original frame image;
and according to a preset algorithm, carrying out XOR processing on the RGB-format macro block and the macro block in the reference frame to acquire first decoding data.
According to a third aspect of the embodiments of the present disclosure, there is provided a data encoding apparatus, the apparatus including an acquisition module, a conversion module, a classification module, and an encoding module,
the acquisition module is used for acquiring an original image frame;
the conversion module is used for carrying out YUV format conversion processing on the original frame image block by block;
the classification module is used for classifying the macro block into a macro block in an RGB format when the macro block after conversion processing is positioned in an image distortion range;
when the macro block after conversion processing is not in the image distortion range, classifying the macro block into a YUV format macro block, and classifying the YUV format macro block into a character type macro block and an image type macro block;
the encoding module is used for encoding the macro block in the RGB format according to a first encoding rule and encoding the macro block in the YUV format according to a second encoding rule, wherein the encoding quality of the first encoding rule is higher than that of the second encoding rule, and the second encoding rule comprises an image type macro block encoding rule and a character type macro block encoding rule.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a data decoding apparatus, characterized in that the apparatus includes a receiving module, a decoding module, a converting module, and a fusing module,
the receiving module is configured to obtain a target code stream, where the target code stream is a code stream obtained after encoding an original frame image, the target code stream includes a code stream in an RGB format and a code stream in a YUV format, and the code stream in the YUV format includes: an image type code stream and an RGB format code stream;
the decoding module is used for decoding the code stream in the RGB format according to a first decoding rule to obtain a macro block in the first RGB format, and decoding the code stream in the YUV format according to a second decoding rule to obtain a macro block in the YUV format, wherein the decoding quality of the first decoding rule is higher than that of the second decoding rule, and the second decoding rule comprises a decoding rule according to an image type code stream and a character type code stream;
the conversion module is used for performing RGB format conversion processing on the macro block in the YUV format to generate a macro block in a second RGB format;
the fusion module is used for fusing and processing the macro block in the first RGB format and the macro block in the second RGB format to generate an original frame image.
The utility model discloses a mixed encoding of image of RGB format and YUV format, the mode of decoding not only has utilized YUV space luminance and the different status of chroma and can compile the characteristics of less code stream, can prevent to change RGB into the distortion loss that the YUV format brought, still solved simultaneously and RGB and YUV the boundary effect that probably produces between the macro block, the final effect is that the image after the decoding has improved user's visual effect, and the code stream does not appear promoting to a great extent, belong to one kind and can compromise the encoding and decoding scheme of multiple image format.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
Fig. 1 is a flowchart of a data encoding method provided by an embodiment of the present disclosure;
fig. 1a is a schematic diagram of a processing result of a data encoding method according to an embodiment of the disclosure;
fig. 2 is a flowchart of a data encoding method provided by an embodiment of the present disclosure;
fig. 3 is a flowchart of a data decoding method provided by an embodiment of the present disclosure;
fig. 4 is a block diagram of a data encoding apparatus provided in an embodiment of the present disclosure;
FIG. 4a is a block diagram of a data encoding apparatus according to an embodiment of the present disclosure;
fig. 5 is a block diagram of a data decoding apparatus provided in an embodiment of the present disclosure;
fig. 5a is a block diagram 1 of a data decoding apparatus according to an embodiment of the present disclosure.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Example one
An embodiment of the present disclosure provides a data encoding method, as shown in fig. 1, the data encoding method includes the following steps:
101. collecting original image frames, and carrying out YUV format conversion processing on the original image frames block by block.
In the method provided by the present disclosure, after the acquired original frame image, the image may be stored as an RGB format and/or YUV format image, and a YUV format conversion process may be performed for the RGB format.
Here, the logical principles and problems of the prior art coding system are again described:
the conventional encoding/decoding system performs encoding based on a certain color space, for example, in a YUV space. The acquired computer images are basically in an RGB format, and the importance of R, G, B three components in the RGB format is basically equal. The importance of the brightness component in the YUV format is higher than that of the chrominance component, so that the code stream can be greatly compressed when the image in the YUV color space is coded, and excessive distortion is not brought to the original image. However, YUV is converted from RGB, and in the conversion process, color value loss is caused by accuracy problems, so that errors are introduced before encoding, and further errors are superimposed in the encoding process, thereby affecting the visual effect of a user. The errors caused by such color conversion cannot be solved at the encoding stage, even if the YUV is coded without loss.
Here, fig. 1a is listed to show the distortion phenomenon after the image format conversion processing:
specifically, the method comprises the following steps: in fig. 1a, the left image is an original image, the right image is a format conversion image, the left side is one component of the acquired RGB image, which shows a gradient effect with decreasing brightness from top to bottom, the right side is the effect after the image is converted into YUV and then into RGB, and the right side shows that there is horizontal ripples.
The right image clearly shows the distortion of a component of a gradient color after loss of color conversion after format conversion.
Therefore, the present disclosure deals with the distortion phenomenon occurring after the image format conversion processing, and improves the quality of image processing.
Specifically, the method comprises the steps of determining an image distortion range set of image conversion processing, if the number of colors of certain macro blocks in the distortion range set in the currently acquired RGB frame exceeds a threshold value, classifying the macro blocks into RGB macro blocks, and carrying out lossless coding by adopting LZ 4; to solve the problem of conversion distortion.
102. When the macro block after the conversion processing is in the image distortion range, the macro block is stored as the macro block in the RGB format.
The method provided by the present disclosure further includes determining whether the transformed macroblock conforms to an image distortion range.
In the method provided by the present disclosure, when format conversion processing is performed, there are several formulas for conversion between RGB and YUV formats, that is, there are different conversion methods, but under the condition that the bit depth is 8 bits, no matter what formula is used for conversion, there is a loss, and this enumerates a specific format conversion process to determine an image distortion range:
for example, the formula for converting the image format from RGB to YUV is as follows:
Y=0.257*R'+0.504*G'+0.098*B'+16
U=-0.148*R'-0.291*G'+0.439*B'+128
V=0.439*R'-0.368*G'-0.071*B'+128
the formula for converting YUV to RGB is as follows,
R=1.164(Y-16)+1.596(V-128)
G=1.164(Y-16)-0.813(V-128)-0.391(U-128)
B=1.164(Y-16)+2.018(U-128)
first, through experiments, the following information can be obtained:
if RGB is converted into YUV and then is converted back into RGB, the color value of each component may lose 0-3 values. Wherein, the color with the loss difference of 3 is about 1200, which is relatively obvious.
The 1200 pixel values are set as a set of image distortion ranges.
The method provided by the present disclosure, in determining whether a macroblock belongs to an image distortion range, may include:
obtaining pixels in the transformed macroblock;
judging whether the pixels in the converted macro blocks are positioned in an image distortion range one by one, and acquiring the number of the pixels positioned in the preset image distortion range;
and when the number of the pixels in the preset image distortion range is larger than a preset threshold value, determining that the macro block is in the image distortion range.
For example, when 50% of the pixels in the transformed macroblock are within the predetermined distortion range, the image distortion range of the transformed macroblock is considered as the distortion range of the transformed macroblock
103. And when the macro block after the conversion processing is not positioned in the image distortion range, classifying the macro block into a YUV format macro block, and classifying the YUV format macro block into a character type macro block and an image type macro block.
The method provided by the disclosure can be further directed to the classification of the macro blocks in the YUV format, for example, classifying macro blocks with mild color distribution into picture macro blocks; and macroblocks with more colors or more details are classified as text macroblocks.
104. And coding the macro block in the RGB format according to a first coding rule, and coding the macro block in the YUV format according to a second coding rule, wherein the coding quality of the first coding rule is higher than that of the second coding rule, and the second coding rule comprises a macro block coding rule according to an image type and a character type.
When the method provided by the present disclosure is used for image coding, the first coding rule can adopt LZ4 lossless coding to solve the problem of conversion distortion;
the second encoding rule can adopt YUV444 encoding, and particularly mainly adopts two encoding modes of a character block and a JPEG picture block so as to reduce code streams by utilizing the characteristics of YUV.
When the method provided by the present disclosure is used for encoding a macroblock in RGB format, in order to improve the encoding efficiency, the method may perform encoding through a reference frame, and specifically includes:
acquiring a reference frame corresponding to the original frame image;
according to a preset algorithm, carrying out XOR processing on the RGB-format macro block and the macro block in the reference frame to obtain a processing result;
and coding the processing result to finish the coding processing of the macro block in the RGB format.
Through the above processing, if the macro block contents of the original frame image and the reference frame are mostly the same, the result of the exclusive or is 0, that is, a large amount of 0 is generated, and the LZ4 compression compresses the code stream very little for the case of such a large amount of 0, which improves the compression ratio, and of course, if no reference frame exists currently, the macro block is directly compressed. Similarly, at the decoding end, if the reference frame exists, the code stream is decoded, and then the decoded code stream is subjected to exclusive or operation with the reference frame macro block, so that the really reconstructed macro block content is obtained.
When the method provided by the present disclosure is used for encoding a YUV-format macro block, in order to reduce the boundary effect, the method further performs encoding processing after quantizing the YUV macro block around the RGB macro block, and specifically includes:
according to a preset algorithm, determining an adjacent macro block adjacent to the RGB macro block in the YUV format macro block;
quantizing the adjacent macro block according to the first quantization value, and encoding the quantized adjacent macro block;
quantizing the non-adjacent macro blocks in the YUV format macro blocks according to the second quantization value, and encoding the quantized macro blocks;
wherein the first quantized value is greater than the second quantized value.
Specifically, when a character macro block is coded, the details of an image are saved by adopting palette quantization and Huffman coding; two sets of quantization parameters, namely high quality and common quality, are configured before encoding, and for high quality macro blocks marked as RGB adjacency, high quality quantization parameters are adopted for quantization, otherwise, common quantization parameters are used for quantization;
specifically, when an image macroblock is coded, a JPEG coding scheme is adopted, and two sets of quantization code tables with quantization levels are configured before coding, so that RGB adjacent macroblocks and non-adjacent macroblocks are quantized respectively.
After the macro blocks of different types are coded in sequence, the coded code stream is marked according to the identification information corresponding to different image types to generate a target code stream, so that a decoding end can decode the macro blocks of different types conveniently.
In the data encoding method provided by the embodiment of the disclosure, when an image is encoded and processed, image conversion processing is performed on the image macro blocks one by one, when the image conversion processing result indicates that the macro block is located in an image distortion range, the macro block is determined to be the macro block in the RGB format, otherwise, the macro block is determined to be the macro block in the YUV format, and the macro blocks in different formats are encoded respectively, so that the encoding efficiency is improved, and the image distortion is avoided.
The method not only utilizes the characteristic that a smaller code stream can be coded by utilizing different positions of brightness and chroma of a YUV space, but also can prevent distortion loss caused by converting RGB into the YUV format, and simultaneously solves the possible boundary effect between RGB and YUV macro blocks, and the final effect is that the decoded image improves the visual effect of a user, and the code stream is not improved to a greater extent; more importantly, the coding and decoding scheme provided by the disclosure gives consideration to multiple image formats, and improves the application scenes of image coding and decoding.
Based on the data encoding method provided by the embodiment corresponding to fig. 1, another embodiment of the present disclosure provides a data encoding method, which may be applied to an encoding device, for example, the encoding device may be a terminal device or a network server, and the present disclosure is not limited thereto. Referring to fig. 2, the data transmission method provided in this embodiment includes the following steps:
201. original frame images are collected.
The original frame image may be an image in RGB format or an image in YUV format.
202. And converting the original frame image into YUV format for processing, and storing the macro blocks in the original frame image into YUV format macro blocks and RGB format macro blocks according to the conversion processing result.
In the method provided by the present disclosure, when the original frame image is converted, distortion of the image is inevitably caused, and therefore, it is necessary to determine whether the image after conversion is in the image distortion range, and determine the storage format of the macro block according to the determination result;
when the macro block after the conversion processing is positioned in the image distortion range, classifying the macro block into a macro block in an RGB format;
when the macro block after conversion processing is not in the image distortion range, classifying the macro block into a YUV format macro block, and classifying the YUV format macro block into a character type macro block and an image type macro block;
specifically, if the pixels in the RGB format of the current macroblock are located in the distortion range set above a preset threshold, the macroblock is classified as an RGB macroblock; the rest are collectively called YUV macro blocks;
and, further dividing the macro block in YUV format according to the type of the macro block:
for example, classifying macro blocks with gentle color distribution into picture macro blocks; classifying the macro blocks with more colors or more details into character macro blocks;
finally, the original frame image is divided into a text type macro block, an image type macro block, and an RGB format macro block.
203. And determining a YUV-format macro block adjacent to the RGB-format macro block according to a macro block classification strategy, and marking the macro block as a high-quality macro block.
Further partitioning is here done for YUV formatted macroblocks adjacent to RGB formatted macroblocks,
since the adjacent to the macro block of the RGB format, it is possible to exhibit color difference due to the boundary effect. In order to reduce or even eliminate the situation, the adjacent YUV macro blocks are set to be quantized by using a higher quantization parameter, so that the display effect is improved.
204. And sequentially coding each macro block according to the coding strategies corresponding to different macro blocks.
The coding strategy provided by the present disclosure includes: carrying out lossless coding strategy aiming at the RGB format macro block; and carrying out a lossy coding strategy on the YUV format macro block.
Furthermore, when the YUV format macro block is coded, the coding is respectively carried out according to a character type coding strategy and an image type coding strategy.
And carrying out coding processing according to the macro block and the identification information corresponding to the coding strategy corresponding to the macro block to generate a coding code stream of the macro block.
205. And integrating the coding code stream corresponding to each macro block to generate a target code stream.
When the coding code stream corresponding to each macro block is provided by the present disclosure, the coding code stream corresponding to each macro block is marked according to the macro block type (RGB, text type, image type) corresponding to each macro block, so that the decoding end can decode according to macro blocks of different types.
According to the data encoding method provided by the embodiment of the disclosure, when an image is encoded and processed, the image is firstly subjected to image conversion processing, when the image conversion processing result does not conform to the image distortion range, the macro block is determined to be the macro block in the RGB format, otherwise, the macro block is determined to be the macro block in the YUV format, and different types of macro blocks are respectively encoded, so that the encoding efficiency is improved, and the image distortion is avoided.
Example two
An embodiment of the present disclosure provides a data decoding method, as shown in fig. 3, the data decoding method includes the following steps:
301. and acquiring a target code stream.
The target code stream in the method provided by the present disclosure is a code stream after the original frame image is encoded, the target code stream includes a code stream in RGB format and a code stream in YUV format, the code stream in YUV format includes: an image type code stream and an RGB format code stream;
the target code stream in the method provided by the present disclosure includes identification information of a macro block in an original frame image, and the method further includes:
the target code stream comprises identification information of the macro block, the identification information comprises an image format corresponding to the code stream, and the image format at least comprises: RGB format and YUV format, the method further comprising:
determining an image format corresponding to the target code stream according to the identification information of the macro block;
and determining a decoding rule corresponding to the target code stream according to the image format corresponding to the target code stream.
302. And decoding the code stream in the RGB format according to a first decoding rule to obtain a macro block in the first RGB format, and decoding the code stream in the YUV format according to a second decoding rule to obtain the macro block in the YUV format.
The decoding quality of the first decoding rule is higher than that of the second decoding rule, and the second decoding rule comprises a decoding rule according to an image type code stream and a character type code stream.
In an optional example, when the code stream in the RGB format is decoded, the reference frame image corresponding to the original frame image may be acquired;
performing XOR processing on the reference frame image and the code stream in the RGB format through XOR processing;
and acquiring the macro block in the first RGB format according to the result of the XOR processing.
303. And converting the YUV-format macro block into a RGB format to generate a second RGB-format macro block.
304. And fusing the first RGB-format macro block and the second RGB-format macro block to generate an original frame image.
Specifically, the original frame image may be generated by performing stitching processing according to a position corresponding to each macroblock obtained after decoding processing.
According to the data decoding method provided by the embodiment of the disclosure, when the coded code stream is decoded, the coded code streams in different types of RGB formats and YUV formats are decoded respectively to obtain the macro blocks in the RGB formats and the YUV formats, and the macro blocks in the YUV formats are subjected to RGB format conversion processing to uniformly generate images in the RGB formats, so that the decoding efficiency is improved, and the distortion of the images is avoided.
The method not only utilizes the characteristic that a smaller code stream can be coded by utilizing different positions of brightness and chroma of a YUV space, but also can prevent distortion loss caused by converting RGB into the YUV format, and simultaneously solves the possible boundary effect between RGB and YUV macro blocks, and the final effect is that the decoded image improves the visual effect of a user, and the code stream is not improved to a greater extent; more importantly, the coding and decoding scheme provided by the disclosure gives consideration to multiple image formats, and improves the application scenes of image coding and decoding.
EXAMPLE III
Based on the data encoding method described in the embodiments corresponding to fig. 1 and fig. 2, the following is an embodiment of the apparatus of the present disclosure, which can be used to execute an embodiment of the method of the present disclosure.
The disclosed embodiment provides a data encoding apparatus, and as shown in fig. 4, the data encoding apparatus 40 includes: an acquisition module 401, a conversion module 402, a classification module 403 and an encoding module 404,
the acquisition module 401 is configured to acquire an original image frame;
the conversion module 402 is configured to perform YUV format conversion processing on the original frame image block by block;
the classifying module 403 is configured to classify the macro block into a macro block in RGB format when the macro block after the conversion processing is in the image distortion range;
when the macro block after conversion processing accords with the image distortion range, classifying the macro block into a YUV format macro block, and classifying the YUV format macro block into a character type macro block and an image type macro block;
the encoding module 404 is configured to encode the RGB-formatted macro block according to a first encoding rule, and encode the YUV-formatted macro block according to a second encoding rule, where an encoding quality of the first encoding rule is higher than an encoding quality of the second encoding rule, and the second encoding rule includes an encoding rule according to an image-type macro block and a text-type macro block.
In one embodiment, as shown in fig. 4a, the data encoding apparatus may further include: an image acquisition module 401, a format conversion module 402, an RGB buffer 403, a YUV buffer 404, a macroblock classifier 405, a boundary processing module 406, a text macroblock encoder 407, an image macroblock encoder 408, an RGB encoder 409, and a code stream generation and transmission module 410;
an image acquisition module 401, configured to acquire an original frame image to be encoded, where the original image is usually in an RGB format;
a format conversion module 402, which converts the collected RGB format frame into YUV format;
an RGB buffer 403 for storing frames in the original RGB format;
a YUV buffer 404 for storing frames in YUV format;
a macro-block classifier 405, configured to classify the original frame image according to a preset classification rule:
the boundary processing module 406 is used to determine the macroblock in YUV macroblock type adjacent to the RGB macroblock, and set the macroblock in this module as a higher quantization level.
After the macroblock quantization processing is finished, the module carries out coding processing;
the text macroblock coder 407 mainly adopts palette quantization and Huffman coding to save details; there are two sets of quantization parameters, high quality and normal quality, for the high quality macroblock marked as RGB adjacency by the 206 module, the high quality quantization parameter quantization is used, otherwise the normal quantization parameter quantization is used;
the picture macroblock encoder 408 encodes the picture macroblock, adopts a JPEG encoding mode, and also has two sets of quantization code tables with quantization levels to quantize the RGB adjacent macroblock and the non-adjacent macroblock respectively;
the RGB encoder 409 is configured to encode the RGB-formatted macroblock, and specifically, the LZ4 compression algorithm may be used to perform lossless encoding on the macroblock;
and a code stream generating and transmitting module 410, configured to fuse the code streams of all the macro blocks, generate a full-frame code stream, and send the full-frame code stream to the decoding end.
The data encoding device provided by the embodiment of the disclosure performs image conversion processing on macro blocks of an image one by one when the image is encoded and processed, determines that the macro block is a macro block in an RGB format when an image conversion processing result indicates that the macro block is located in an image distortion range, otherwise determines that the macro block is a macro block in a YUV format, and performs encoding on the macro blocks of different types, thereby improving encoding efficiency and avoiding image distortion.
The utility model discloses a device for mixed coding and decoding of images in RGB format and YUV format, which not only utilizes the characteristics of the different positions of brightness and chroma in YUV space to code a smaller code stream, but also prevents the distortion loss caused by converting RGB into YUV format, and solves the possible boundary effect between RGB and YUV macro blocks, and the final effect is that the decoded image improves the visual effect of users, and the code stream is not improved to a greater extent; more importantly, the coding and decoding scheme provided by the disclosure gives consideration to multiple image formats, and improves the application scenes of image coding and decoding.
Example four
Based on the data decoding method described in the embodiment corresponding to fig. 3, the following is an embodiment of the apparatus of the present disclosure, which can be used to execute an embodiment of the method of the present disclosure.
An embodiment of the present disclosure provides a data decoding apparatus, as shown in fig. 5, the data decoding apparatus 50 includes: a receiving module 501, a decoding module 502, a converting module 503 and a fusing module 504,
the receiving module 501 is configured to obtain a target code stream, where the target code stream is a code stream obtained after encoding an original frame image, the target code stream includes a code stream in an RGB format and a code stream in a YUV format, and the code stream in the YUV format includes: an image type code stream and an RGB format code stream;
the decoding module 502 is configured to decode the code stream in the RGB format according to a first decoding rule, obtain a macro block in the first RGB format, and decode the code stream in the YUV format according to a second decoding rule, obtain a macro block in the YUV format, where the decoding quality of the first decoding rule is higher than that of the second decoding rule, and the second decoding rule includes a decoding rule according to an image type code stream and a decoding rule according to a text type code stream;
the conversion module 503 is configured to perform RGB format conversion processing on the YUV format macro block to generate a second RGB format macro block;
the merging module 504 is configured to merge and process the first RGB macro block and the second RGB macro block to generate an original frame image.
In an alternative embodiment, as shown in fig. 5a, the data decoding apparatus may further include: a receiving buffer module 501, a text macroblock decoder 502, an image macroblock decoder 503, an RGB decoder 504, and a macroblock fusion module 505.
The input/receive module 501 is configured to receive a code stream sent by an encoding end;
a text macro block decoder 502, configured to decode and process a text type code stream, and reconstruct the code stream into a YUV-format macro block;
a picture macroblock decoder 503, configured to decode a code stream of an image type, for example, decode the code stream by using the JPEG method, and reconstruct macroblocks in the YUV format;
an RGB decoder 504 for decoding RGB type macroblocks, for example, using LZ4, and performing an exclusive or operation with macroblocks of a reference frame, if any, to obtain RGB format macroblocks;
and a macroblock fusion module 505, configured to convert all macroblocks in the YUV format into macroblocks in the RGB format, and splice the macroblocks in the RGB format to form a final decoded frame.
The utility model discloses a device for mixed coding and decoding of images in RGB format and YUV format, which not only utilizes the characteristics of the different positions of brightness and chroma in YUV space to code a smaller code stream, but also prevents the distortion loss caused by converting RGB into YUV format, and solves the possible boundary effect between RGB and YUV macro blocks, and the final effect is that the decoded image improves the visual effect of users, and the code stream is not improved to a greater extent; more importantly, the coding and decoding scheme provided by the disclosure gives consideration to multiple image formats, and improves the application scenes of image coding and decoding.
Based on the data encoding method described in the embodiment corresponding to fig. 1 and fig. 2, an embodiment of the present disclosure further provides a computer-readable storage medium, for example, the non-transitory computer-readable storage medium may be a Read Only Memory (ROM), a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like. The storage medium stores computer instructions for executing the data transmission method described in the embodiment corresponding to fig. 1 and fig. 2, which is not described herein again.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

Claims (10)

1. A method of encoding data, the method comprising:
collecting original image frames, and performing YUV format conversion processing on the original image frames block by block;
when the macro block after the conversion processing is positioned in the image distortion range, classifying the macro block into a macro block in an RGB format;
when the macro block after conversion processing is not in the image distortion range, classifying the macro block into a YUV format macro block, and classifying the YUV format macro block into a character type macro block and an image type macro block;
and coding the macro block in the RGB format according to a first coding rule, and coding the macro block in the YUV format according to a second coding rule, wherein the coding quality of the first coding rule is higher than that of the second coding rule, and the second coding rule comprises a macro block coding rule according to an image type and a character type.
2. The method of claim 1, further comprising:
acquiring pixels in the converted macro block;
judging whether the pixels in the converted macro blocks are positioned in an image distortion range one by one, and acquiring the number of the pixels positioned in the preset image distortion range;
and when the number of the pixels in the preset image distortion range is larger than a preset threshold value, determining that the macro block is in the image distortion range.
3. The method of claim 2, wherein the encoding the macroblock in YUV format according to the second encoding rule comprises:
according to a preset algorithm, determining an adjacent macro block adjacent to the RGB macro block in the YUV format macro block;
quantizing the adjacent macro blocks according to a first quantization value, and encoding the quantized macro blocks;
quantizing non-adjacent macroblocks in the YUV-format macroblocks according to a second quantization value, and encoding the quantized adjacent macroblocks;
wherein the first quantized value is greater than the second quantized value.
4. The method according to claim 1, wherein said encoding the RGB-format macro block comprises:
acquiring a reference frame corresponding to the original frame image;
according to a preset algorithm, carrying out XOR processing on the RGB-format macro block and a macro block corresponding to the RGB-format macro block in a reference frame, and obtaining the XOR processing result;
and carrying out coding processing on the result of the XOR processing to finish the coding processing on the macro block in the RGB format.
5. The method of claim 1, further comprising:
acquiring a coding code stream of the RGB format macro block, wherein the coding code stream comprises identification information corresponding to the code stream, and the identification information comprises an image format corresponding to the code stream;
acquiring a code stream of the YUV format macro block;
and generating a target code stream according to the code stream of the RGB-format macro block and the code stream of the YUV-format macro block.
6. A method of decoding data, comprising:
acquiring a target code stream, wherein the target code stream is a code stream obtained after the original frame image is coded, the target code stream comprises a code stream in an RGB format and a code stream in a YUV format, and the code stream in the YUV format comprises: an image type code stream and an RGB format code stream;
decoding the code stream in the RGB format according to a first decoding rule to obtain a macro block in the first RGB format, and decoding the code stream in the YUV format according to a second decoding rule to obtain the macro block in the YUV format, wherein the decoding quality of the first decoding rule is higher than that of the second decoding rule, and the second decoding rule comprises a code stream decoding rule according to an image type and a character type;
performing RGB format conversion processing on the macro block in the YUV format to generate a macro block in a second RGB format;
and performing fusion processing on the macro blocks in the first RGB format and the macro blocks in the second RGB format to generate an original frame image.
7. The method according to claim 6, wherein the target code stream includes identification information of a macroblock, the identification information includes an image format corresponding to the code stream, and the image format at least includes: RGB format and YUV format, the method further comprising:
determining an image format corresponding to the target code stream according to the identification information of the macro block;
and determining a decoding rule corresponding to the target code stream according to the image format corresponding to the target code stream.
8. The method of claim 7, further comprising:
acquiring a reference frame corresponding to the original frame image;
according to a preset algorithm, carrying out XOR processing on the code stream in the RGB format and the macro block in the reference frame, and acquiring the XOR processing result;
and acquiring the macro block in the first RGB format according to the result of the XOR processing.
9. A data coding device is characterized by comprising an acquisition module, a conversion module, a classification module and a coding module,
the acquisition module is used for acquiring original image frames;
the conversion module is used for performing YUV format conversion processing on the original frame image block by block;
the classification module is used for classifying the macro block into a macro block in an RGB format when the macro block after conversion processing is positioned in an image distortion range;
when the macro block after conversion processing is not in the image distortion range, classifying the macro block into a YUV format macro block, and classifying the YUV format macro block into a character type macro block and an image type macro block;
the encoding module is used for encoding the macro block in the RGB format according to a first encoding rule and encoding the macro block in the YUV format according to a second encoding rule, wherein the encoding quality of the first encoding rule is higher than that of the second encoding rule, and the second encoding rule comprises an image type macro block encoding rule and a character type macro block encoding rule.
10. A data decoding device is characterized in that the device comprises a receiving module, a decoding module, a conversion module and a fusion module,
the receiving module is configured to obtain a target code stream, where the target code stream is a code stream obtained after encoding an original frame image, the target code stream includes a code stream in an RGB format and a code stream in a YUV format, and the code stream in the YUV format includes: an image type code stream and an RGB format code stream;
the decoding module is used for decoding the code stream in the RGB format according to a first decoding rule to obtain a macro block in the first RGB format, and decoding the code stream in the YUV format according to a second decoding rule to obtain a macro block in the YUV format, wherein the decoding quality of the first decoding rule is higher than that of the second decoding rule, and the second decoding rule comprises a decoding rule according to an image type code stream and a character type code stream;
the conversion module is used for performing RGB format conversion processing on the macro block in the YUV format to generate a macro block in a second RGB format;
the fusion module is configured to fuse and process the macro block in the first RGB format and the macro block in the second RGB format to generate an original frame image.
CN202110507913.2A 2021-05-10 2021-05-10 Data encoding and decoding method and device Pending CN113301339A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110507913.2A CN113301339A (en) 2021-05-10 2021-05-10 Data encoding and decoding method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110507913.2A CN113301339A (en) 2021-05-10 2021-05-10 Data encoding and decoding method and device

Publications (1)

Publication Number Publication Date
CN113301339A true CN113301339A (en) 2021-08-24

Family

ID=77321475

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110507913.2A Pending CN113301339A (en) 2021-05-10 2021-05-10 Data encoding and decoding method and device

Country Status (1)

Country Link
CN (1) CN113301339A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117499665A (en) * 2023-12-29 2024-02-02 南京博润类脑智能技术有限公司 Image data embedding and extracting method and device based on gray value quantization

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117499665A (en) * 2023-12-29 2024-02-02 南京博润类脑智能技术有限公司 Image data embedding and extracting method and device based on gray value quantization
CN117499665B (en) * 2023-12-29 2024-03-19 南京博润类脑智能技术有限公司 Image data embedding and extracting method and device based on gray value quantization

Similar Documents

Publication Publication Date Title
CN110753223B (en) Video decoding method and device
CN106797457B (en) With the advanced screen content coding method for improving palette table and index graph code
US11785215B2 (en) Encoding method, decoding method, encoding/decoding system, encoder, and decoder
US8509310B2 (en) Method, medium, and system encoding and/or decoding an image
CN110401833B (en) Image transmission method and device
CN106797468A (en) Improved pallet mode in efficient video coding (HEVC) screen content coding (SCC)
CN104303506A (en) Method and apparatus for coding of sample adaptive offset information
CN104396245A (en) Method and device for encoding or decoding an image
JP6822122B2 (en) Image processing equipment, image processing methods and programs
JP6822123B2 (en) Image processing equipment, image processing methods and programs
CN103957412B (en) Base color and index map algorithm for correcting inter-frame residual errors of screen video
JP2013517723A (en) Image encoder and image decoder
CN105681812B (en) HEVC intraframe coding treating method and apparatus
CN113613008A (en) Video encoding and decoding method and device, electronic equipment and storage medium
EP3111642B1 (en) Method and apparatus of single sample mode for video coding
CN110234010A (en) Method for video coding/device and video encoding/decoding method/device
CN110149515B (en) Data transmission method and device
CN113301339A (en) Data encoding and decoding method and device
JP3462867B2 (en) Image compression method and apparatus, image compression program, and image processing apparatus
US7046387B1 (en) Efficient coding of color images including monochrome images
Kim et al. A sub-pixel gradient compression algorithm for text image display on a smart device
CN114205586A (en) Video processing method for carrying out rate distortion optimization based on multi-color space and application
JP3347488B2 (en) Image processing apparatus and method
JP2559726B2 (en) Color image processor
TWI581616B (en) Method for encoding, method for decoding, system for encoding and decoding, encoder and decoder

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination