Data processing method and device, computer device and readable storage medium
By identifying the RGB sub-pixel component values and encoding patterns of image data, and combining the flag bits with valid data bits, the problem of image data compression with high hardware resource consumption in existing technologies is solved, achieving low-cost data compression.
Patent Information
- Application Number
- CN202210647936.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-08
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2042-06-08
AI Technical Summary
Existing image data compression methods require a large amount of hardware resources and cannot achieve low-cost data compression when chip area resources are limited.
By identifying the RGB sub-pixel component values of image data, the encoding mode is determined, and the image data is encoded according to the encoding mode. The flag bits and valid data bits are combined to achieve image data compression.
While ensuring compression effectiveness, it reduces hardware resource consumption and achieves low-cost data compression.
Smart Images

Figure CN115103189B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular to a data processing method and device, computer equipment and a readable storage medium. BACKGROUND
[0002] At present, the main purpose of video coding is to compress data for video data. Since the pixel form representation of dynamic image will bring extremely huge data volume, which leads to the storage space and transmission bandwidth completely unable to meet the needs of saving and transmission. For example, each pixel of the image needs one byte to represent three color components RGB, so each pixel needs at least 3 bytes, and the size of the image with a resolution of 1280x720 is 2.76M bytes. If the frame rate of the video with the same resolution is 30 frames / s, the required code rate for transmission will reach 662.4Mb / s. And with the increase of screen refresh rate, the required bandwidth will also be larger and larger, which also means that more hardware resources need to be occupied. Therefore, how to compress video data becomes a necessary problem to be solved in the technical field of data processing.
[0003] In the process of research and practice of the prior art, the inventors of the present application found that at least the following problems exist: the existing image data compression method often requires a large amount of hardware resources, which is not suitable for the case where the chip area resource is limited, and cannot achieve the effect of low-cost data compression. Therefore, there is an urgent need for a method that can guarantee the effect of data compression while reducing the required resources.
[0004] The foregoing narrative is to provide general background information and does not necessarily constitute the prior art. SUMMARY
[0005] In view of the above technical problems, the present application provides a data processing method and device, computer equipment and a readable storage medium, which can solve the problem that the prior art requires a large amount of resources when compressing image data, and achieve the effect of low-cost data compression.
[0006] To solve the above technical problems, the present application provides a data processing method, comprising the following steps:
[0007] Obtain the compressed image data, identify the RGB sub-pixel component value of the compressed image data;
[0008] According to the RGB sub-pixel component value, determine the encoding mode corresponding to the compressed image data;
[0009] According to the encoding mode, encode the compressed image data to obtain the effective data bit;
[0010] Combining the flag bit corresponding to the coding mode and the effective data bit to form compressed image data.
[0011] Optionally, the obtaining the to-be-compressed image data and identifying the RGB sub-pixel component values of the to-be-compressed image data comprise:
[0012] Obtaining to-be-compressed image data in an original RGB color space, the to-be-compressed image data comprising a plurality of image data arranged in a first matrix;
[0013] Respectively identifying R sub-pixel component values, G sub-pixel component values and B sub-pixel component values of the to-be-compressed image data.
[0014] Optionally, the determining the coding mode corresponding to the to-be-compressed image data according to the RGB sub-pixel component values comprises:
[0015] According to a preset rule, judging a data mode and a type flag bit corresponding to the RGB sub-pixel component values;
[0016] According to the data mode, determining the coding mode corresponding to the to-be-compressed image data.
[0017] Optionally, before the obtaining the to-be-compressed image data, the method further comprises:
[0018] Obtaining a to-be-compressed image, and dividing the to-be-compressed image into a plurality of pixel blocks arranged in a first matrix, wherein each pixel block comprises a plurality of pixels arranged in a second matrix;
[0019] Converting the plurality of pixel blocks into to-be-compressed image data according to a preset RGB format.
[0020] Optionally, the data processing method further comprises:
[0021] Identifying a mode flag bit in the compressed image data;
[0022] According to the mode flag bit, determining a coding mode corresponding to the compressed image data;
[0023] According to the coding mode, performing decompression processing on the compressed image data to obtain original image data.
[0024] Optionally, the decompression processing on the compressed image data according to the coding mode to obtain original image data comprises:
[0025] Inputting the compressed image data into a first-in-first-out queue for synchronous processing, and synchronizing to a corresponding clock domain;
[0026] The image data in each clock domain is stored into the plurality of random access memories in a polling manner;
[0027] The image data in the plurality of random access memories is read and decompressed to output original image data.
[0028] Correspondingly, the application further provides a data processing device, comprising:
[0029] An acquisition module is configured to acquire image data to be compressed and identify RGB sub-pixel component values of the image data to be compressed.
[0030] A first identification module is configured to determine an encoding mode corresponding to the image data to be compressed according to the RGB sub-pixel component values.
[0031] An encoding module is configured to encode the image data to be compressed according to the encoding mode to obtain effective data bits.
[0032] A compression module is configured to combine flag bits corresponding to the encoding mode with the effective data bits to form compressed image data.
[0033] Optionally, the data processing device further comprises:
[0034] A second identification module is configured to identify mode flag bits in the compressed image data.
[0035] A third identification module is configured to determine an encoding mode corresponding to the compressed image data according to the mode flag bits.
[0036] A decompression module is configured to decompress the compressed image data according to the encoding mode to obtain original image data.
[0037] Embodiments of the application further provide a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements steps of the data processing method according to any one of the preceding embodiments when executing the computer program.
[0038] Embodiments of the application further provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement steps of the data processing method according to any one of the preceding embodiments.
[0039] The embodiments of the application have the following beneficial effects:
[0040] As described above, the data processing method, device, computer equipment and readable storage medium provided by the application, wherein the method comprises: obtaining image data to be compressed, and identifying RGB sub-pixel component values of the image data to be compressed; determining an encoding mode corresponding to the image data to be compressed according to the RGB sub-pixel component values; encoding the image data to be compressed according to the encoding mode to obtain effective data bits; and combining a flag bit corresponding to the encoding mode and the effective data bits to form compressed image data. The application provides a compression method for image data, which identifies the RGB sub-pixel component values of the image data to be compressed to determine the corresponding encoding mode, combines the encoded image data with the effective data bits after encoding the image data according to different encoding modes, thereby compressing the image data, reasonably and effectively compresses the image data in the RGB color space, reduces the required resources while ensuring the compression effect, and thus completes the data compression at low cost. BRIEF DESCRIPTION OF DRAWINGS
[0041] The accompanying drawings, which are incorporated into and form a part of the specification, illustrate an embodiment consistent with the present application and, together with the description, serve to explain the principles of the application. In order to more clearly illustrate the technical solutions of the embodiments of the application, the drawings needed to be used in the embodiment description will be briefly introduced as follows. Obviously, those skilled in the art can obtain other drawings according to these drawings without any creative effort.
[0042] Figure 1 is a flowchart of a first embodiment of the data processing method provided by the application;
[0043] Figure 2 is a flowchart of a second embodiment of the data processing method provided by the application;
[0044] Figure 3 is a flowchart of data decompression provided by the application;
[0045] Figure 4 is a structural diagram of a first embodiment of the data processing device provided by the application;
[0046] Figure 5 is a structural diagram of a second embodiment of the data processing device provided by the application;
[0047] Figure 6 is a structural diagram of a first embodiment of the computer equipment provided by the application;
[0048] Figure 7 is a structural diagram of a second embodiment of the computer equipment provided by the application.
[0049] The objectives, features and advantages of the present application will be further illustrated by the following embodiments and with reference to the accompanying drawings. The embodiments of the present application have been shown in the above-described drawings, and will be described in more detail hereinafter. These drawings and detailed description are not intended to limit the scope of the present application in any way, but to explain the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0050] The exemplary embodiments will be described in detail herein with reference to the attached drawings. In the following description, the same or similar components are designated by the same or similar reference numerals, and the description of the same or similar components will not be repeated. The embodiments described in the following exemplary embodiments do not represent all the embodiments consistent with the present application. Rather, they are merely examples in accordance with some aspects of the present application, as detailed in the appended claims.
[0051] It should be noted that, in this document, the terms "comprises", "comprising", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element preceded by "comprises a" does not, without more constraints, foreclose the existence of additional identical elements in the process, method, article, or apparatus that comprises the element. Also, the components having the same name in different embodiments of the present application can have the same meaning or different meanings, and the specific meaning thereof should be determined in the explanation of the specific embodiment or further in conjunction with the context of the specific embodiment.
[0052] It should be understood that, although terms, first, second, third, etc. can be used herein to describe various information, these terms are not intended to denote a particular order or hierarchy among the information. These terms are used only to distinguish one category of information from another category of information. For example, a first information can be termed a second information, and similarly, a second information can be termed a first information without departing from the scope hereof. As used herein, the term, if, can be interpreted to mean, at the time of, when, or in response to a determination, depending on the context. Also, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context indicates otherwise. It will be further understood that the terms "comprises", "comprising", "includes" and / or "including", when used herein, specify the presence of stated features, steps, operations, elements, components, items, and / or groups thereof, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, items, and / or groups thereof. As used herein, the term "or", "and / or", "at least one of", and the like are to be interpreted as inclusive or meaning any one or any combination. For example, "A, B or C" or "A, B, and / or C" means "any of the following: A; B; C; A and B; A and C; B and C; A, B and C". Only when a group of elements, functions, steps or operations are in some way inherently mutually exclusive is an exception to this definition.
[0053] It should be understood that, although various steps in the flowcharts of the embodiments herein can be illustrated as following a certain order, these steps are not necessarily performed in that order. Unless otherwise specified, the steps of the embodiments herein can be performed in any order. Furthermore, at least some of the steps can include multiple sub-steps or multiple stages, which can not necessarily be performed in the same time instant, but can be performed in different time instants, and can not necessarily be performed one after another, but can be performed in parallel or in an interleaved manner with at least some of the other steps or sub-steps or stages of other steps.
[0054] As used herein, the term "if' can be construed to mean "when" or "in response to a determination" or "in response to a detection," depending on the context. Similarly, the phrase "if determined" or "if detecting (a stated condition or event)" can be construed to mean "when determined" or "in response to a determination" or "when detecting (a stated condition or event)" or "in response to a detection (a stated condition or event)," depending on the context.
[0055] It should be noted that in the present document, step codes such as S1, S2, etc. are used for the purpose of more clearly and concisely expressing the corresponding content, and do not constitute substantial restrictions on the order, and those skilled in the art can perform S2 before S1, etc. in specific implementation, but these should be within the protection scope of the present application.
[0056] It should be understood that the specific embodiments described herein are merely intended to explain the present application and not to limit the present application.
[0057] In the following description, the suffixes such as "module", "part", or "unit" used to represent elements are merely for the purpose of facilitating the description of the present application, and have no specific meaning in themselves. Therefore, "module", "part", or "unit" can be used interchangeably.
[0058] In order to realize compression of video data or image data, the prior art proposes a display stream compression method, which is a visual lossless image compression technology. However, the hardware resources required by this technology are large, and it is not suitable in the case of limited chip area resources.
[0059] In order to solve the above problems, the present application provides a data processing method, device, computer equipment and readable storage medium, which reasonably and effectively compresses the image data of the RGB color space, reduces the required resources while ensuring the compression effect, so as to realize the technical effect of completing data compression at low cost.
[0060] Please refer to Figure 1 , Figure 1 is a flowchart of the data processing method provided by the embodiment of the present application. The data processing method can specifically include:
[0061] S1. Obtain the image data to be compressed, and identify the RGB sub-pixel component value of the image data to be compressed.
[0062] Specifically, for step S1, first obtain the image data to be compressed, and identify the RGB sub-pixel component value of the original RGB color space of the image data to be compressed.
[0063] Optionally, in some embodiments, step S1 can specifically include:
[0064] S11. Obtain the image data to be compressed of the original RGB color space, the image data to be compressed including a plurality of image data arranged according to a first matrix;
[0065] S12. Identify the R sub-pixel component value, the G sub-pixel component value and the B sub-pixel component value of the image data to be compressed, respectively.
[0066] Specifically, first, the original RGB color space of the compressed image data is obtained, which can include a plurality of image data arranged in a first matrix. Preferably, in a specific embodiment, 6 pixels of 2 rows and 3 columns of image data in the original RGB color space are obtained, because in commonly used picture resolutions, the picture column resolution is usually a multiple of 3, and the row resolution is usually a multiple of 2, so in this embodiment, the image data can be divided into 2 rows and 3 columns of pixel blocks, each containing 6 pixels. If in the RGB888 format, each pixel data is 24 bits, so the data amount corresponding to 2 rows and 3 columns of image data is 144 bits. After obtaining the original RGB color space of the compressed image data, the values of the R / G / B three components of the compressed image data are identified, i.e. the R sub-pixel component value, the G sub-pixel component value and the B sub-pixel component value.
[0067] Optionally, in some embodiments, before step S1, the method can further include:
[0068] Obtaining the compressed image, dividing the compressed image into a plurality of pixel blocks arranged in a first matrix, wherein each pixel block includes a plurality of pixels arranged in a second matrix;
[0069] Converting the plurality of pixel blocks into compressed image data according to a preset RGB format.
[0070] Specifically, the input compressed image is obtained, and the compressed image is divided into a plurality of pixel blocks arranged in a first matrix, preferably, the first matrix is 2 rows and 3 columns; each pixel block includes a plurality of pixels; and the plurality of pixel blocks are converted into compressed image data according to a preset RGB format.
[0071] S2. Determine the encoding mode corresponding to the compressed image data according to the RGB sub-pixel component value.
[0072] Specifically, for step S2, the encoding mode corresponding to the compressed image data is determined according to the identified RGB sub-pixel component value of the compressed image data, different types of compressed image data are encoded through different encoding modes, which can reduce the resources occupied in subsequent compression and ensure that the error of the compressed data is low.
[0073] Optionally, in some embodiments, step S2 can include:
[0074] S21. Determine the data mode and type flag bit corresponding to the RGB sub-pixel component value according to a preset rule;
[0075] S22. Determine the encoding mode corresponding to the compressed image data according to the data mode.
[0076] Specifically, according to the preset rule, a data mode to which the RGB sub-pixel component value in the to-be-compressed image data conforms is determined, and the type of the to-be-compressed image data is identified, so as to determine the type flag bit; after the data mode is determined, the encoding mode corresponding to the to-be-compressed image data is determined according to the data mode.
[0077] In a specific embodiment, for how to determine the encoding mode corresponding to the to-be-compressed image data, the embodiment provides five encoding modes, and different types can be divided in each encoding mode. The specific process is as follows: according to the characteristics of the R / G / B three sub-pixels, the corresponding encoding mode is selected. For example, if the input 6 pixels all satisfy R=G=B, that is, all the input data are gray data, it is mode 1. If one or two sub-pixel components in the input 6 pixels are the same, it is mode 2. If the difference between the maximum value and the minimum value of the R / G / B three components of the input 6 pixels is within a preset range, it is mode 3. If the above three conditions are not met, it is mode 4. The above four modes correspond to different mode flag bits, but considering that the information required by mode 3 is obviously more than that of mode 1, the effective data bits allocated should be as many as possible, so the number of mode flag bits is not fixed. For example, the mode flag bit of mode 1 is 1111, and the mode flag bit of mode 3 is 0.
[0078] In addition, there are different types in each encoding mode, and correspondingly, each type also corresponds to different type flag bits. For example, mode 3 is allocated 6-bit type flag bits, but it still cannot cover all cases, so mode 5 is added to cover the cases not covered by mode 3. After determining the determination rules of various encoding modes, the priority of various encoding modes needs to be set, and it is ensured that the encoding mode and type of the to-be-compressed image data will not be misjudged.
[0079] It should be noted that the encoding mode is related to the bit width of the compressed data. At the same time, the classification can also be adjusted according to the actual effect, which is not limited here.
[0080] S3. According to the encoding mode, the to-be-compressed image data is encoded to obtain the effective data bit.
[0081] Specifically, for step S3, the to-be-compressed image data is encoded according to the determined encoding mode, so as to obtain the effective data bit corresponding to the to-be-compressed image.
[0082] S4. The flag bit corresponding to the encoding mode is combined with the effective data bit to form the compressed image data.
[0083] Specifically, for step S4, the mode flag bit corresponding to the encoding mode, the type flag bit and the valid data bit obtained by encoding are combined to form the compressed image data. For example, the 144-bit image data in step S1 is compressed to obtain 48-bit data, and the compression ratio is 1 / 3. The 48-bit data obtained by compression includes the mode flag bit, the type flag bit and the valid data bit.
[0084] In a specific embodiment, mode 1 is taken as an example, the mode bit of which is 1111, and the remaining 44 bits. One sub-pixel occupies 8 bits, so the data of 5 sub-pixels can be further stored. Since R / G / B are all equal, the cases are discussed. If one of the 6 data is equal to one of the other 5 data, all the data can be stored in 40 bits, and the remaining 4 bits are used to represent which two data are the same, and there are 15 cases. The 4 bits are the type flag bit. If the 6 data are all different, part of the valid data is lost. At this time, the type flag bit is 0000, and the remaining 40 bits are evenly divided to store the valid data as much as possible. In this case, it is divided into 6, 6, 6, 7, 7, 7, a total of 39 bits, and the high 6 bits and the high 7 bits of the sub-pixels are stored respectively, and the maximum error is 3, 1, and the last invalid data bit is left.
[0085] Optionally, as shown in Figure 2 In some embodiments, the data processing method can further include:
[0086] S5. Identifying the mode flag bit in the compressed image data;
[0087] S6. Determining the encoding mode corresponding to the compressed image data according to the mode flag bit;
[0088] S7. Decompressing the compressed image data according to the encoding mode to obtain the original image data.
[0089] Specifically, the data processing method in the embodiments of the present application further provides a decompression method of image data, and the specific process includes: first, obtaining the compressed image data, and identifying the mode flag bit in the compressed image data; determining which encoding mode is used for the compressed image data according to the mode flag bit, so as to decompress the remaining data bit in the compressed image data according to the corresponding encoding mode, and finally obtain the decompressed image data.
[0090] Optionally, in some embodiments, step S7 can include:
[0091] S71. Inputting the compressed image data into a first-in-first-out queue for synchronous processing, and synchronizing to the corresponding clock domain;
[0092] S72. Store the image data in each clock domain to the plurality of random access memories in a polling manner;
[0093] S73. Read the image data in the plurality of random access memories and perform decompression processing, and output the original image data.
[0094] Specifically, as shown in Figure 3 To reduce the hardware resources required for decompression, the embodiment also provides a decompression implementation. Since the embodiment achieves 1 / 3 compression effect, the amount of decoded data is 3 times the amount of compressed data, so the compressed data is decoded and output in the same time, and the output clock is 3 times the input clock frequency. Since it involves cross-clock domain processing, the input compressed data needs to be synchronized to the output clock domain through the FIFO first-in-first-out queue. The compressed 48-bit data can be regarded as the smallest valid unit of the compressed data stream, which corresponds to two rows and three columns of pixel blocks after decompression. A compressed image is regarded as having the same row resolution as the original image and 1 / 3 of the column resolution of the original image. Therefore, the data of one row after compression is actually the first half or the second half of the adjacent two rows. The decoded image needs to be output row by row, so the second row of decoded data needs to be stored, otherwise it will be lost. Instead of storing the decoded data, it is better to store the compressed data, which requires less RAM.
[0095] According to the above analysis, to decode one complete row of data, two rows of compressed data need to be read, and the second row also needs the data of the two rows. Therefore, the decoding of the first row starts at the beginning of the second row of compressed data and ends at the end of the second row of compressed data. That is, the time for sending one row of decompressed data is the same as the time for receiving one row of compressed data. The decompression of the second row also needs the compressed data of the previous two rows, and at this time, the third row of compressed data starts to be sent, so the embodiment provides three line buffers for storing compressed data.
[0096] After FIFO processing, three rows of compressed data are stored in three RAMs in turn, that is, the RAM round-robin method is used. When decoding the first row, compressed data needs to be read from RAM1 and RAM2 in turn, and then decompressed according to the method mentioned in this paper to obtain two rows of compressed data and output the first row of decompressed data. Thus, two rows of data can be decoded at the same time, but since more RAM is required to save the second row of decoded data, the decoding of the second row uses a re-decoding method to save hardware resources. After the decoding of the second row is completed, the data in RAM1 and RAM2 is completed, the third row of compressed data is stored in RAM3, and the fourth row of compressed data can be stored in RAM1 to realize the RAM round-robin operation. Repeat the above steps until a frame of data is decoded.
[0097] From the above, the data processing method provided in the embodiment of the present application comprises: acquiring image data to be compressed, and identifying RGB sub-pixel component values of the image data to be compressed; determining an encoding mode corresponding to the image data to be compressed according to the RGB sub-pixel component values; encoding the image data to be compressed according to the encoding mode to obtain effective data bits; and combining a flag bit corresponding to the encoding mode with the effective data bits to form compressed image data. The embodiment of the present application provides a compression method for image data, which identifies RGB sub-pixel component values of image data to be compressed to determine a corresponding encoding mode, combines the image data encoded according to different encoding modes with effective data bits, thereby compressing the image data, and realizes reasonable and effective compression of image data in the RGB color space, reduces the required resources while ensuring the compression effect, and thus completes data compression at low cost.
[0098] Correspondingly, the present application also provides a data processing device, please refer to Figure 4 , Figure 4 is a structural schematic diagram of the data processing device provided in the present application, and specifically can comprise an acquisition module 100, a first identification module 200, an encoding module 300 and a compression module 400.
[0099] The acquisition module 100 is configured to acquire image data to be compressed, and identify RGB sub-pixel component values of the image data to be compressed.
[0100] Specifically, for the acquisition module 100, first, image data to be compressed is acquired, and RGB sub-pixel component values of the original RGB color space of the image data to be compressed are identified.
[0101] The first identification module 200 is configured to determine an encoding mode corresponding to the image data to be compressed according to the RGB sub-pixel component values.
[0102] Specifically, the first identification module 200 mainly determines the encoding mode corresponding to the image data to be compressed according to the identified RGB sub-pixel component values of the image data to be compressed, encodes different types of image data to be compressed through different encoding modes, can reduce the resources occupied in subsequent compression, and ensures that the error of the compressed data is low.
[0103] The encoding module 300 is configured to encode the image data to be compressed according to the encoding mode to obtain effective data bits.
[0104] Specifically, the encoding module 300 is configured to encode the image data to be compressed according to the determined encoding mode, thereby obtaining effective data bits corresponding to the image data to be compressed.
[0105] The compression module 400 is configured to combine the flag corresponding to the encoding mode and the valid data bits to form compressed image data.
[0106] Specifically, for the compression module 400, the mode flag corresponding to the encoding mode, the type flag and the valid data bits obtained by encoding are combined to form the compressed image data.
[0107] Optionally, as shown in some embodiments, the data processing apparatus can further include: Figure 5
[0108] The second identification module 500 is configured to identify the mode flag in the compressed image data.
[0109] The third identification module 600 is configured to determine the encoding mode corresponding to the compressed image data according to the mode flag.
[0110] The decompression module 700 is configured to decompress the compressed image data according to the encoding mode to obtain the original image data.
[0111] In summary, the data processing apparatus provided by the embodiments of the present application first acquires the image data to be compressed by the acquisition module 100, and identifies the RGB sub-pixel component value of the image data to be compressed; then the first identification module 200 determines the encoding mode corresponding to the image data to be compressed according to the RGB sub-pixel component value; then the encoding module 300 encodes the image data to be compressed according to the encoding mode to obtain the valid data bits; finally, the compression module 400 combines the flag corresponding to the encoding mode and the valid data bits to form the compressed image data. It can be seen that the data processing apparatus of the embodiments of the present application identifies the RGB sub-pixel component value of the image data to be compressed to determine the corresponding encoding mode, combines the valid data bits after encoding the image data according to different encoding modes, thereby compressing the image data, and realizes reasonable and effective compression of the image data in the RGB color space. While ensuring the compression effect, the required resources are reduced, thereby completing the data compression at low cost.
[0112] In the embodiments of the present application, a computer device is also provided. Please refer to Figure 6 , Figure 6 is a structural schematic diagram of a first embodiment of a computer device provided by the embodiment of the application. The computer device comprises a memory 10 and a processor 20, the memory 10 stores a computer program, and the processor 20 implements a data processing method when executing the computer program, which comprises: acquiring compressed image data, identifying the RGB sub-pixel component value of the compressed image data; determining the encoding mode corresponding to the compressed image data according to the RGB sub-pixel component value; encoding the compressed image data according to the encoding mode to obtain effective data bits; and combining the flag bit corresponding to the encoding mode and the effective data bits to form the compressed image data.
[0113] The embodiment of the application further provides a computer device, which can be a server. Please refer to Figure 7 , Figure 7 is a structural schematic diagram of a second embodiment of a computer device provided by the embodiment of the application. The computer device comprises a processor, a memory, a network interface and a database connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data processing methods and other data. The network interface of the computer device is used to communicate with external terminals through network connection.
[0114] The computer program is executed by the processor to implement a data processing method. The data processing method comprises: acquiring compressed image data, identifying the RGB sub-pixel component value of the compressed image data; determining the encoding mode corresponding to the compressed image data according to the RGB sub-pixel component value; encoding the compressed image data according to the encoding mode to obtain effective data bits; and combining the flag bit corresponding to the encoding mode and the effective data bits to form the compressed image data.
[0115] The embodiment of the application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by the processor to implement a data processing method, which comprises the steps of: acquiring compressed image data, identifying the RGB sub-pixel component value of the compressed image data; determining the encoding mode corresponding to the compressed image data according to the RGB sub-pixel component value; encoding the compressed image data according to the encoding mode to obtain effective data bits; and combining the flag bit corresponding to the encoding mode and the effective data bits to form the compressed image data.
[0116] The data processing method is executed, and the embodiment of the application determines the corresponding encoding mode by identifying the RGB sub-pixel component value of the image data to be compressed, encodes the image data according to different encoding modes, and then combines the effective data bits, so as to compress the image data, realize reasonable and effective compression of the image data in the RGB color space, reduce the required resources while ensuring the compression effect, and thus complete data compression at low cost.
[0117] It can be understood that the above scenarios are only examples and do not constitute a limitation on the application scenarios of the technical solutions provided by the embodiments of the application. The technical solutions of the application can also be applied to other scenarios. For example, those skilled in the art can know that, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided by the embodiments of the application are also applicable to similar technical problems.
[0118] The serial numbers of the above embodiments of the application are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0119] The steps in the method of the embodiments of the application can be adjusted, combined and deleted according to actual needs.
[0120] The units in the device of the embodiments of the application can be combined, divided and deleted according to actual needs.
[0121] In the present application, for the same or similar term concept, technical solution and / or application scenario description, generally only the first time is described in detail, and for the sake of brevity, the repeated description is not repeated, and for the understanding of the technical solutions of the application, the same or similar term concept, technical solution and / or application scenario description which is not described in detail can be referred to the related description before.
[0122] In the present application, the description of each embodiment has its own emphasis, and the parts not described or recorded in a certain embodiment can be referred to the related description of other embodiments.
[0123] The technical features of the technical solutions of the application can be combined arbitrarily, and in order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of these technical features does not exist contradictory, it should be considered as the range recorded in the application.
[0124] Those skilled in the art can clearly understand the above-mentioned embodiment method can be realized by means of software and the necessary general hardware platform, of course, can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as a ROM / RAM, a magnetic disk, an optical disk) and includes a plurality of instructions for making a terminal device (which can be a mobile phone, a computer, a server, a controlled terminal, or a network device) execute the method of each embodiment of the present application.
[0125] In the above embodiments, all or part can be realized by software, hardware, firmware or any combination thereof. When realized by software, all or part can be realized in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another, for example, the computer instructions can be transferred from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. containing one or more available media sets. The available media can be magnetic media (such as floppy disk, storage disk, magnetic tape), optical media (such as DVD), or semiconductor media (such as solid state disk (SSD)) and the like.
[0126] The above is only the preferred embodiment of the present application, and does not limit the patent scope of the present application, and any equivalent structure or equivalent process transformation using the content of the specification and drawings, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A data processing method, characterized in that, Includes the following steps: Obtain the image data to be compressed in the original RGB color space, wherein the image data to be compressed includes multiple image data arranged in a first matrix; The R sub-pixel component values, G sub-pixel component values, and B sub-pixel component values of the image data to be compressed are identified respectively; Based on preset rules, determine the data mode and type flag bits corresponding to the RGB sub-pixel component values; Based on the data pattern, the encoding mode corresponding to the image data to be compressed is determined, including: when all 6 pixels satisfy R=G=B, the encoding mode is determined to be mode 1; when one or two sub-pixel components of the 6 pixels are the same, the encoding mode is mode 2; when the difference between the maximum and minimum values of the R, G, and B sub-pixel components of the 6 pixels is within a preset range, the encoding mode is determined to be mode 3; when the 6 pixels do not satisfy the above three conditions, the encoding mode is mode 4. The image data to be compressed is encoded according to the encoding mode to obtain valid data bits; The flag bit corresponding to the encoding mode is combined with the valid data bits to form the compressed image data; wherein, the compressed image data is 48 bits; specifically, when the encoding mode is mode 1, the flag bit is "1111", and the remaining 44 bits are used to store valid data; since one sub-pixel occupies 8 bits, the remaining 44 bits are used to store the data of the other 5 sub-pixels; if one of the 6 sub-pixels is equal to one of the other 5, then 40 bits are used to store all sub-pixels, and the remaining 4 bits are used as a flag bit to indicate which two sub-pixels are the same; if the 6 sub-pixels are different from each other, then the flag bit is set to "0000", and the remaining 40 bits are evenly divided to store the higher-order valid bits of each sub-pixel, specifically, the remaining 40 bits are allocated to 6, 6, 6, 7, 7, 7, a total of 39 bits, to store the higher 6 bits or higher 7 bits of each sub-pixel respectively, and the maximum errors generated are 3 and 1 respectively, and the remaining 1 bit is an invalid data bit.
2. The data processing method according to claim 1, characterized in that, Before obtaining the image data to be compressed in the original RGB color space, the method further includes: Obtain the image to be compressed, and divide the image to be compressed into multiple pixel blocks arranged according to the first matrix, wherein each pixel block includes multiple pixels arranged according to the second matrix; The multiple pixel blocks are converted into image data to be compressed according to the preset RGB format.
3. The data processing method according to claim 1, characterized in that, The method further includes: Identify the mode flag bits in the compressed image data; The encoding mode corresponding to the compressed image data is determined based on the mode flag bit; The compressed image data is decompressed according to the encoding mode to obtain the original image data.
4. The data processing method according to claim 3, characterized in that, The step of decompressing the compressed image data according to the encoding mode to obtain the original image data includes: The compressed image data is input into a first-in-first-out queue for synchronization processing and synchronized to the corresponding clock domain; The image data in each clock domain is stored in multiple random access memories using a polling method. The image data in the plurality of random access memories is read and decompressed to output the original image data.
5. A data processing apparatus, characterized in that, include: The acquisition module is used to acquire the image data to be compressed in the original RGB color space, wherein the image data to be compressed includes multiple image data arranged in a first matrix; The R sub-pixel component values, G sub-pixel component values, and B sub-pixel component values of the image data to be compressed are identified respectively; The first identification module is used to determine the data mode and type flag bit corresponding to the RGB sub-pixel component value according to preset rules; Based on the data pattern, the encoding mode corresponding to the image data to be compressed is determined, including: when all 6 pixels satisfy R=G=B, the encoding mode is determined to be mode 1; when one or two sub-pixel components of the 6 pixels are the same, the encoding mode is mode 2; when the difference between the maximum and minimum values of the R, G, and B sub-pixel components of the 6 pixels is within a preset range, the encoding mode is determined to be mode 3; when the 6 pixels do not satisfy the above three conditions, the encoding mode is mode 4. The encoding module is used to encode the image data to be compressed according to the encoding mode to obtain valid data bits; The compression module is used to combine the flag bit corresponding to the encoding mode with the valid data bits to form compressed image data. The compressed image data is 48 bits. Specifically, when the encoding mode is mode 1, the flag bit is "1111", and the remaining 44 bits are used to store valid data. Since one sub-pixel occupies 8 bits, the remaining 44 bits are used to store the data of the other 5 sub-pixels. If one of the 6 sub-pixels is equal to one of the other 5, then 40 bits are used to store all sub-pixels, and the remaining 4 bits are used as a flag bit to indicate which two sub-pixels are the same. If the 6 sub-pixels are different, then the flag bit is set to "0000", and the remaining 40 bits are evenly divided to store the higher-order valid bits of each sub-pixel. Specifically, the remaining 40 bits are allocated to 6, 6, 6, 7, 7, 7, a total of 39 bits, to store the higher 6 bits or higher 7 bits of each sub-pixel, respectively. The maximum errors generated by this are 3 and 1, respectively, and the remaining 1 bit is an invalid data bit.
6. The data processing apparatus according to claim 5, characterized in that, Also includes: The second identification module is used to identify the mode flag bits in the compressed image data; The third identification module is used to determine the encoding mode corresponding to the compressed image data based on the mode flag bit; The decompression module is used to decompress the compressed image data according to the encoding mode to obtain the original image data.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the data processing method according to any one of claims 1 to 4.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the data processing method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Image compression method
CN1937748A
Image processing device, image processing method, program, and data
JP2017212601A