A method and device for decoding GIF files

By implementing the decompression function of GIF file compressed data and establishing code tables in FPGA hardware, the existing GIF decoder has been solved, and efficient and fast GIF decoding is achieved.

CN114022578BActive Publication Date: 2025-04-25SICHE TECH (CHONGQING) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111355294.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-16
Publication Date
2025-04-25
Estimated Expiration
2041-11-16

AI Technical Summary

Technical Problem

Existing GIF decoders are less efficient in executing instructions on general-purpose processors, resulting in lower decoding rates and throughput, and excessive hardware storage resources, affecting the decoding speed.

Method used

By implementing the decompression function of GIF file compressed data in FPGA hardware, it reduces CPU software processing time, reduces CPU memory usage, and establishes code tables through linked lists to improve decoding efficiency.

Benefits of technology

It improves the throughput and execution efficiency of GIF decoding, reduces the use of hardware storage resources, and ensures the accuracy and speed of GIF decoding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114022578B_ABST
    Figure CN114022578B_ABST
Patent Text Reader

Abstract

The invention belongs to the field of GIF image encoding and decoding, and relates to a method and device for decoding a GIF file; the device comprises a random access memory, a register, and a compressed data reading module, a file information parsing module, a color index list parsing module, a code table establishment module, a data decoding module, a color data acquisition module, and a decoded data writing module carried in a field programmable gate array FPGA; the invention uses a hardware implementation method to automatically read in compressed data and automatically write out decompressed data without relying on software participation, thereby improving the throughput and execution efficiency of GIF decoding; the invention can also automatically establish a decoding code table, and complete the establishment and search process of a linked list code table in a decoding and establishing manner, thereby saving hardware storage resources as much as possible; the invention can also complete data splicing according to the length information of the code table in conjunction with a linked list reverse table lookup method, thereby ensuring the accuracy and rapidity of GIF decoding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of GIF image encoding and decoding, and in particular relates to a method and equipment for decoding a GIF file. Background Art

[0002] Graphics Interchange Format (GIF) uses an improved Lempel-Ziv-Welch (LZW) algorithm, which is a lossless compression algorithm with high compression efficiency, usually around 50%. GIF supports storing multiple color images in one GIF file, and can read and display multiple images in a certain order and time interval, thus forming a simple looping animation.

[0003] In order to present the GIF image on the screen, a GIF decoder is required to decode the GIF file into a format that can be recognized by the screen. In the prior art, the GIF decoder is usually implemented in software and runs on a general-purpose processor. The GIF decoder instructions and GIF image data are stored in the DDR memory. The processor sequentially fetches each GIF decoder instruction and the corresponding GIF image data from the DDR memory, and executes each instruction sequentially in the order of instruction fetching to complete the decoding of the GIF image data. This method results in low efficiency in executing GIF decoder instructions on a general-purpose processor, low GIF decoding rate, and low GIF decoder throughput.

[0004] Based on the above problems, Chinese patent CN107705340A discloses a method and device for image decoding. This solution can improve the execution efficiency and throughput of the GIF decoder by utilizing the parallel characteristics and pipeline structure of the hardware circuit. However, this solution still requires a large amount of hardware storage resources, which will affect the speed of GIF decoding and result in low efficiency of GIF playback decoding. Summary of the invention

[0005] Based on the problems existing in the prior art, the present invention proposes a method and device for GIF file decoding. The present invention reduces the CPU software processing time through FPGA hardware implementation of the GIF file compressed data decompression function, thereby reducing CPU memory usage, accelerating GIF decoding speed, reducing resource usage, and improving the efficiency of GIF decoding and playback.

[0006] In a first aspect of the present invention, the present invention provides a method for decoding a GIF file, the method comprising:

[0007] Read the compressed data of the GIF file from the random access memory;

[0008] According to a standard format of a GIF file, the compressed data of the GIF file is parsed to obtain first information of the GIF file, and the first information is stored in a register;

[0009] According to the standard format of the GIF file, the compressed data of the GIF file is parsed to obtain a color index list, and the color index list is stored in a register;

[0010] According to the standard format of the GIF file, a code table is established for the compressed data of the GIF file in a linked list manner, and the code length information is stored in a random access memory;

[0011] Search the established code table and decompress the compressed data of the GIF file to obtain the character information;

[0012] Indexing the color index list through the decompressed character information to obtain corresponding color information;

[0013] The storage location of each color information is determined according to the code length information, and the color information decompressed from the code word unit is output to the random access memory of the designated address in reverse order.

[0014] Furthermore, the method of establishing a code table for the compressed data of the GIF file in a linked list manner and recording code length information includes obtaining basic code word units in the GIF file, each of which includes a basic character and its corresponding link address; using the link address arrangement order of the basic code word units as the corresponding index address, and arranging them in order of the index addresses to form a basic character area; combining the basic code word units in the basic character area with the index addresses of other basic code word units to form a new code word unit, forming the code word information of the new code word unit, and then continuing to arrange the sorting order of the basic character area, using the arrangement order as the index address corresponding to the code word unit, and then arranging the basic character area in order to form an extended character area using the combination information as the index address of the new code word unit, and forming an extended character area in order of the index address; arranging the basic character area and the extended character area in order according to the index address, the arrangement order is the code word unit index address, using the index addresses corresponding to all code word units as the code table address, and forming a linked list code table of the GIF file, and recording the code length information of each code word unit in the code table.

[0015] Furthermore, the decompressing of the character information of the compressed data of the GIF file includes obtaining the index value of the linked list code table of the GIF file, and obtaining the corresponding code word unit according to the index value; if the obtained code word unit is a basic code word unit in the basic character area, the query decoding of the basic code word unit is directly completed; if the obtained code word unit is a code word unit in the extended character area, the basic code word part of the code word unit is taken out as the constituent element of the code word unit, and the index address information is taken out as the index address of the next basic code word unit; the index address is used as a new index value, and the new index value is used to obtain the next basic code word unit; until the remaining index address is the index address range of the basic code word unit, the query decoding of the new code word unit is completed.

[0016] Furthermore, the color index list is indexed by the decompressed character information to obtain the corresponding color information, including obtaining the last basic character of the code word unit from the linked list code table, and using this basic character to index the color index list to obtain the corresponding color information.

[0017] Furthermore, the storage location of each color information is determined according to each code length information, and the color information decompressed from the code word unit in reverse order is output to the random access memory of the specified address, that is, the color information decompressed from the last code word in the code word unit in reverse order is output according to each code word unit, including determining the number N of color information of the current code word unit and the storage location of each color information according to the code length information of each code word unit, obtaining the last basic character of the code word unit from the linked list code table, using this basic character to index the color index list to obtain the penultimate color information, and outputting it to the random access memory of the specified address; obtaining the second to last basic character of the code word unit through the linked list code table, using this basic character to index the color index list to obtain the second to last color information, and outputting it to the random access memory of the specified address; until N color information of the code word unit are obtained.

[0018] In a second aspect of the present invention, the present invention further provides a GIF file decoding device, comprising a random access memory, a register, and a compressed data reading module, a file information parsing module, a color index list parsing module, a code table building module, a data decoding module, a color data acquisition module, and a decoded data writing module mounted in a field programmable gate array FPGA;

[0019] Random access memory, used to store the compressed data of GIF files and the complete data after decompression and splicing;

[0020] A compressed data reading module is used to read the compressed data of the GIF file from the random access memory;

[0021] A file information parsing module, used for parsing the compressed data of the GIF file to obtain first information of the GIF file according to a standard format of the GIF file, and storing the first information in a register;

[0022] A color index list parsing module, used for parsing the compressed data of the GIF file to obtain a color index list according to a standard format of the GIF file, and storing the color index list in a register;

[0023] A code table establishment module, used for establishing a code table for the compressed data of the GIF file in a linked list manner according to the standard format of the GIF file, and storing the code length information in a random access memory;

[0024] The data decoding module is used to search the established code table and decompress the compressed data of the GIF file to obtain character information;

[0025] A color data acquisition module, used to index the color index list through the decompressed character information to obtain corresponding color information;

[0026] The decoded data writing module is used to determine the storage location of each color information according to the code length information, and output the color information decompressed from the code word unit in reverse order to the random access memory of the specified address.

[0027] Furthermore, the code table establishment module includes:

[0028] A first acquisition unit is used to acquire basic codeword units in the GIF file, each of which includes a basic character and a corresponding link address;

[0029] The first encoding unit uses the arrangement order of the basic codeword units as corresponding index addresses, and forms a basic character area according to the order of the index addresses;

[0030] The second encoding unit combines the basic code word unit of the basic character area with the index addresses of other code word units to form a new code word unit, and then continues to arrange the sorting order of the basic character area, using the arrangement order as the index address corresponding to the code word unit, and forming an extended character area;

[0031] The code table embedding unit uses the index addresses corresponding to all code word units as code table addresses, and forms a linked list code table of the GIF file.

[0032] Furthermore, the data decoding module includes:

[0033] A second acquisition unit is used to obtain a linked list code table of a GIF file and an index value corresponding to its decoding, and obtain a corresponding code word unit according to the index value;

[0034] The first decoding unit directly completes the query decoding of the basic code word unit if the obtained code word unit is a basic code word unit in the basic character area;

[0035] The second decoding unit, if the obtained codeword unit is a codeword unit in the extended character area, then the basic codeword part of the codeword unit is taken out as the constituent element of the codeword unit, and the index address information is taken out as the index address of the next basic codeword unit character; if the obtained codeword unit is a new codeword unit after combination in the extended character area, then the last codeword of the codeword unit is taken out as the basic codeword unit, and the remaining codewords are used as the corresponding index addresses; the index address is used as a new index value, and the new index value is used to obtain the basic codeword unit of the next codeword unit; until the remaining index address is within the index address range of the basic codeword unit, the query decoding of the new codeword unit is completed.

[0036] Furthermore, the color data acquisition module is specifically used to obtain the last basic character of the code word unit from the linked list code table, and use this basic character to index the color index list to obtain the corresponding color information.

[0037] Furthermore, the decoded data writing module includes:

[0038] A code length information determination unit determines the number of times the color information is spliced ​​according to the recorded code length information;

[0039] The color information splicing unit determines the storage location of each color information according to the code length information, and outputs the color information decompressed from the code word unit in reverse order to the random access memory of the designated address.

[0040] Beneficial effects of the present invention:

[0041] The present invention uses hardware implementation to automatically read compressed data and automatically write decompressed data. This process does not require software participation, and can improve the throughput and execution efficiency of GIF decoding. The present invention can also automatically establish a decoding code table, and complete the establishment and search process of a linked list code table in a decoding and establishment manner. Compared with the method of directly establishing a code table, the code table established in a linked list manner can save hardware storage resources as much as possible. At the same time, the present invention can also complete data splicing according to the length information of the code table and cooperate with the linked list reverse table lookup method, thereby ensuring the accuracy and speed of GIF decoding. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 is a structural diagram of a device for decoding a GIF file in an embodiment of the present invention;

[0043] Figure 2is a structural diagram of a code table establishment module in an embodiment of the present invention;

[0044] Figure 3 is a structural diagram of a data decoding module in an embodiment of the present invention;

[0045] Figure 4 is a structural diagram of a decoded data writing module in an embodiment of the present invention;

[0046] Figure 5 It is a flow chart of a method for decoding a GIF file in an embodiment of the present invention. DETAILED DESCRIPTION

[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] Figure 1 : is a diagram of a device structure for decoding a GIF file in an embodiment of the present invention. Figure 1 As shown, the device includes a random access memory (RAM), a register, and a compressed data reading module, a file information parsing module, a color index list parsing module, a code table building module, a data decoding module, a color data acquisition module, and a decoded data writing module mounted in a field programmable gate array FPGA.

[0049] The register may be mounted in a module not shown in the field programmable gate array, or may be mounted in a file information parsing module and a color index list parsing module.

[0050] In the embodiment of the present invention, each module works in the following manner:

[0051] Random access memory, used to store the compressed data of GIF files and the complete data after decompression and splicing;

[0052] In the embodiment of the present invention, the random access memory (RAM) as a hardware structure is an internal memory that directly exchanges data with the CPU or MCU. It can be read and written at any time (except when refreshed), and the speed is very fast. It is usually used as a temporary data storage medium for the operating system or other running programs. When the RAM is working, information can be written (stored) or read (taken out) from any specified address at any time. The RAM is a hardware storage structure. Other hardware structures can directly obtain the compressed data of the GIF file and store the complete data after splicing through hardware transmission. The code length information is saved by the hardware structure. On the one hand, it can ensure that the software resource occupation is reduced. On the other hand, the code length information saved by the hardware is used to guide the splicing of color information, which can effectively improve the throughput and execution efficiency of GIF decoding. Due to the design of the chain code table, the data output of each code table unit is in reverse order, but the output of the color information is arranged in sequence. If the length information of the current code word unit is unknown, it must be output in sequence, and all the color data decoded from the current code word unit must be spliced ​​in reverse order and stored in sequence following the previous color data. The present invention directly records the code length information of the code table establishment process, and uses the known length information of the current code word unit to determine each color data, that is, the color information based on the relative address of the last color data in the previous code word unit, and directly writes the decoded color data to the corresponding storage address without caching and splicing the data before outputting it, saving resources and time.

[0053] A compressed data reading module is used to read the compressed data of the GIF file from the random access memory;

[0054] In the embodiment of the present invention, the compressed data reading module refers to reading the compressed data of the GIF file from the random access memory in a hardware reading manner, and then combining with other modules to parse and otherwise process the compressed data of the read GIF file.

[0055] A file information parsing module, used for parsing the compressed data of the GIF file to obtain first information of the GIF file according to a standard format of the GIF file, and storing the first information in a register;

[0056] The first information may include header information, playback information and extended information. The first message does not need to be obtained by decompression, but can be obtained by simply parsing it according to the standard format of the GIF file.

[0057] A color index list parsing module, used for parsing the compressed data of the GIF file to obtain a color index list according to a standard format of the GIF file, and storing the color index list in a register;

[0058] Among them, there is a color index list in the standard format of the GIF file. The present invention needs to continue to parse the compressed data of the GIF file to obtain the color index list therein. In the subsequent process, the image block data in the compressed data of the GIF file is decompressed through the code table to obtain the corresponding index value, and the specific color information is obtained from the color index list through this index value, and the final output is the specific color information.

[0059] A code table establishment module, used for establishing a code table for the compressed data of the GIF file in a linked list manner according to the standard format of the GIF file, and storing the code length information in a random access memory;

[0060] In the embodiment of the present invention, Figure 2 As shown, the code table establishment module includes:

[0061] A first acquisition unit 201 is used to acquire basic codeword units in a GIF file, each of which includes a basic character and a corresponding link address;

[0062] The first encoding unit 202 uses the arrangement order of the basic codeword units as corresponding index addresses, and forms a basic character area according to the order of the index addresses;

[0063] The second encoding unit 203 combines the basic codeword unit of the basic character area with the index addresses of other codeword units to form a new codeword unit, and then continues to arrange the sorting order of the basic character area, using the arrangement order as the index address corresponding to the codeword unit, and forming an extended character area;

[0064] The code table embedding unit 204 uses the index addresses corresponding to all the code word units as code table addresses, and forms a linked list code table of the GIF file.

[0065] The data decoding module is used to search the established code table and decompress the character information of the compressed data of the GIF file according to the compressed data information;

[0066] In the embodiment of the present invention, Figure 3 As shown, the code table establishment module includes: the data decoding module includes:

[0067] The second acquisition unit 301 is used to obtain a linked list code table of a GIF file and an index value corresponding to its decoding, and obtain a corresponding code word unit according to the index value;

[0068] The first decoding unit 302 directly completes the query decoding of the basic code word unit if the obtained code word unit is a basic code word unit in the basic character area;

[0069] The second decoding unit 303, if the obtained codeword unit is a codeword unit in the extended character area, then the basic codeword part of the codeword unit is taken out as the constituent element of the codeword unit, and the index address information is taken out as the index address of the next basic codeword unit character. If the obtained codeword unit is a new codeword unit after combination in the extended character area, then the last codeword of the codeword unit is taken out as the basic codeword unit, and the remaining codewords are used as the corresponding index addresses; the index address is used as a new index value, and the new index value is used to obtain the basic codeword unit of the next codeword unit; until the remaining index address is in the index address range of the basic codeword unit, the query decoding of the new codeword unit is completed.

[0070] A color data acquisition module, used to index the color index list through the decompressed character information to obtain corresponding color information;

[0071] The color data acquisition module is specifically used to obtain the last basic character of the code word unit from the linked list code table, and use this basic character to index the color index list to obtain the corresponding color information.

[0072] The decoded data writing module is used to determine the storage location of each color information according to the code length information, and output the color information decompressed from the code word unit in reverse order to the random access memory of the specified address.

[0073] In the embodiment of the present invention, Figure 4 As shown, the decoded data writing module includes:

[0074] The code length information determining unit 401 determines the number of times the color information is spliced ​​according to the recorded code length information;

[0075] The color information splicing unit 402 determines the storage location of each color information according to the code length information, and outputs the color information decompressed from the code word unit in reverse order to the random access memory at the designated address.

[0076] Figure 5 : is a flow chart of a method for decoding a GIF file in an embodiment of the present invention. Figure 5 As shown, the method includes:

[0077] 101. Read the compressed data of the GIF file from the random access memory;

[0078] In the embodiment of the present invention, random access memory (RAM), also called main memory, is an internal memory that directly exchanges data with the CPU. It can be read and written at any time (except when refreshed) and is very fast. It is usually used as a temporary data storage medium for operating systems or other running programs. When working, RAM can write (store) or read (retrieve) information from any specified address at any time; the present invention uses RAM to automatically read the compressed data of GIF files without the participation of software, and can quickly read the compressed data of GIF files, thereby ensuring the real-time and rapidity of the reading process and avoiding the occupation of software resources.

[0079] In the embodiment of the present invention, the compressed data of the GIF file is an image file compressed using the Lempel-Ziv-Welch (LZW) lossless data compression technology. The GIF image is based on a color list (the stored data is the index value of the color of the point corresponding to the color list), and only supports 8 bits (256 colors) at most. The GIF file is divided into many storage blocks to store multiple images or control blocks that determine the image performance behavior, so as to realize animation and interactive applications.

[0080] 102. According to a standard format of the GIF file, parse the compressed data of the GIF file to obtain first information of the GIF file, and store the first information in a register;

[0081] Among them, the standard format of a GIF file can be divided into three parts: File Header, GIF Data Stream and Trailer. The File Header contains the GIF file signature and version number; the GIF Data Stream consists of a control identifier, an image block and some other extension blocks; the file terminator has only one character (';') with a value of 0x3B to indicate the end of the file.

[0082] In the embodiment of the present invention, according to the above standard format, the file header information and part of the GIF data stream information are parsed from the compressed data of the GIF file, and the first information is stored in a register for being read by software.

[0083] In an embodiment of the present invention, since the GIF data stream contains many types of data blocks, these different types include image processing methods, color index tables, compressed data blocks, etc., each data block has its own function. Except for the compressed data block, that is, the image block, which requires a separate code table to be established for decoding, the others are some basic image information types, or special effects required for animation playback, etc. This type of information is part of the first information of the present invention. This type of information is decoded and stored in a register through parsing for software to obtain. The core of the present invention is to decompress the compressed data blocks. Therefore, it is necessary to perform hardware decoding processing on the compressed data blocks corresponding to the index values ​​assembled in a certain format and some information required to establish the code table.

[0084] 103. According to the standard format of the GIF file, parse the compressed data of the GIF file to obtain a color index list, and store the color index list in a register;

[0085] In an embodiment of the present invention, there is a color index list in the standard format of the GIF file. The present invention needs to continue to parse the compressed data of the GIF file, obtain the color index list therein, and store the color index list in a register for software to call.

[0086] 104. According to the standard format of the GIF file, a code table is established for the compressed data of the GIF file by means of a linked list, and code length information is recorded;

[0087] Obtain basic codeword units in a GIF file, each of which includes a basic character and its corresponding link address; use the link address arrangement order of the basic codeword units as the corresponding index address, and arrange them in the order of the index addresses to form a basic character area; combine the basic codeword units in the basic character area with the index addresses of other basic codeword units to form a new codeword unit, form the codeword information of the new codeword unit, and then continue to arrange the sorting order of the basic character area, use the arrangement order as the index address corresponding to the codeword unit, and then arrange the basic character area in sequence to form an extended character area, use the combination information as the index address of the new codeword unit, and form an extended character area in the order of the index address; arrange the basic character area and the extended character area in sequence according to the index address, the arrangement order is the codeword unit index address, use the index addresses corresponding to all codeword units as code table addresses, and form a linked list code table of the GIF file, and record the code length information of each codeword unit in the code table.

[0088] In the embodiment of the present invention, according to the above standard format, GIF data stream information is parsed from the compressed data of the GIF file, and a linked list code table is established from the GIF data stream information, and the code length information in the code table is also recorded.

[0089] 105. Search the established code table, and decompress the character information of the compressed data of the GIF file according to the compressed data information;

[0090] In an embodiment of the present invention, an index value of a linked list code table of a GIF file is obtained, and a corresponding codeword unit is obtained according to the index value; if the obtained codeword unit is a basic codeword unit in a basic character area, query decoding of the basic codeword unit is directly completed; if the obtained codeword unit is a codeword unit in an extended character area, the basic codeword part of the codeword unit is taken out as a constituent element of the codeword unit, and the index address information is taken out as the index address of the next basic codeword unit; the index address is used as a new index value, and the next basic codeword unit is obtained with this new index value; until the remaining index address is within the index address range of the basic codeword unit, query decoding of the new codeword unit is completed.

[0091] 106. Index the color index list using the decompressed character information to obtain corresponding color information;

[0092] In an embodiment of the present invention, indexing the color index list to obtain corresponding color information includes obtaining the last basic character of the codeword unit from a linked list code table, and using the basic character to index the color index list to obtain corresponding color information.

[0093] 107. Determine the storage location of each color information according to the code length information, and output the color information decompressed from the code word unit in reverse order to the random access memory of the designated address.

[0094] In an embodiment of the present invention, the number N of color information possessed by the current code word unit is determined based on the code length information of each code word unit, the last basic character of the code word unit is obtained from the linked list code table, the color index list is indexed with this basic character to obtain the penultimate color information, and the information is output to a random access memory at a specified address; the second-to-last basic character of the code word unit is obtained through the linked list code table, the color index list is indexed with this basic character to obtain the second-to-last color information, and the information is output to a random access memory at a specified address; until N color information of the code word unit is obtained.

[0095] For example, assuming that the code length information of the current codeword unit is 5, the storage position of the color information indexed by the first basic codeword unit obtained through the linked list code table should be the fifth storage position after the last color information decoded previously; the storage position of the color information indexed by the second basic codeword unit obtained through the linked list code table should be the fourth storage position after the last color information decoded previously, and so on. The last decoded color information is stored after the last color information decoded previously.

[0096] In the description of the present invention, it is necessary to understand that the terms "coaxial", "bottom", "one end", "top", "middle", "the other end", "upper", "one side", "top", "inside", "outside", "front", "center", "both ends" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.

[0097] In the present invention, unless otherwise clearly stipulated and limited, the terms such as "installation", "setting", "connection", "fixation" and "rotation" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral one; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium; it can be the internal connection of two elements or the interaction relationship between two elements. Unless otherwise clearly defined, ordinary technicians in this field can understand the specific meanings of the above terms in the present invention according to the specific circumstances.

[0098] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for decoding a GIF file, characterized in that: The method comprises: Read the compressed data of the GIF file from the random access memory; According to a standard format of a GIF file, the compressed data of the GIF file is parsed to obtain first information of the GIF file, and the first information is stored in a register; According to the standard format of the GIF file, the compressed data of the GIF file is parsed to obtain a color index list, and the color index list is stored in a register; According to the standard format of the GIF file, a code table is established for the compressed data of the GIF file in a linked list manner, the code length information is recorded, and the code length information is stored in a random access memory; The method of establishing a code table for the compressed data of the GIF file in a linked list manner, recording the code length information, and storing the code length information in a random access memory includes obtaining basic code word units in the GIF file, each of which includes a basic character and its corresponding link address; using the link address arrangement order of the basic code word units as the corresponding index address, and arranging them in the order of the index addresses to form a basic character area; combining the basic code word units in the basic character area with the index addresses of other basic code word units to form the code word information of a new code word unit, and then continuing to arrange the basic character area in the sorting order, and forming an extended character area in the order of the index address; arranging the basic character area and the extended character area in order according to the index address, the arrangement order is the code word unit index address, using the index addresses corresponding to all the code word units as the code table address, and forming a linked list code table of the GIF file, and recording the code length information of each code word unit in the code table; Search the established code table and decompress the compressed data of the GIF file to obtain the character information; Indexing the color index list through the decompressed character information to obtain corresponding color information; The storage location of each color information is determined according to each code length information, and the color information decompressed from the code word unit is output to the random access memory of the designated address in reverse order.

2. A method for decoding a GIF file according to claim 1, characterized in that: The character information of the compressed data of the decompressed GIF file includes obtaining the index value of the linked list code table of the GIF file, and obtaining the corresponding code word unit according to the index value; if the obtained code word unit is a code word unit in the extended character area, the basic code word part of the code word unit is taken out as the constituent element of the code word unit, and the index address information is taken out as the index address of the next basic code word unit; if the obtained code word unit is a new code word unit after combination in the extended character area, the last code word of the code word unit is taken out as the basic code word unit, and the remaining code words are used as the corresponding index address; the index address is used as a new index value, and the new index value is used to obtain the basic code word unit of the next code word unit.

3. A method for decoding a GIF file according to claim 1, characterized in that: The color index list is indexed by the decompressed character information, and obtaining the corresponding color information includes obtaining a basic character of a codeword unit from a linked list code table, and using the basic character to index the color index list to obtain the corresponding color information.

4. A method for decoding a GIF file according to claim 1, characterized in that: The method of determining the storage location of each color information according to each code length information and outputting the color information decompressed from the code word unit in reverse order to the random access memory at the specified address includes determining the number N of color information possessed by the current code word unit according to the code length information of each code word unit, obtaining the last basic character of the code word unit from the linked list code table, and using this basic character to index the color index list to obtain the penultimate color information; obtaining the second-to-last basic character of the code word unit through the linked list code table, and using this basic character to index the color index list to obtain the second-to-last color information; until N color information of the code word unit is obtained, the N color information are spliced ​​in reverse order and output to the random access memory at the specified address.

5. A device for decoding GIF files, characterized in that: It includes a random access memory, a register, and a compressed data reading module, a file information parsing module, a color index list parsing module, a code table building module, a data decoding module, a color data acquisition module, and a decoded data writing module mounted in a field programmable gate array FPGA; Random access memory, used to store the compressed data of GIF files and the complete data after decompression and splicing; A compressed data reading module is used to read the compressed data of the GIF file from the random access memory; A file information parsing module, used for parsing the compressed data of the GIF file to obtain first information of the GIF file according to a standard format of the GIF file, and storing the first information in a register; A color index list parsing module, used for parsing the compressed data of the GIF file to obtain a color index list according to a standard format of the GIF file, and storing the color index list in a register; A code table establishment module, used for establishing a code table for the compressed data of the GIF file in a linked list manner according to the standard format of the GIF file, and storing the code length information in a random access memory; The code table establishment module includes: A first acquisition unit is used to acquire basic codeword units in the GIF file, each of which includes a basic character and a corresponding link address; The first encoding unit uses the link address arrangement order of the basic code word unit as the corresponding index address, and arranges the basic character area in the order of the index address; The second encoding unit combines the basic code word unit of the basic character area with the index address of other basic code word units to form a new code word unit, and then continues to arrange the sorting order of the basic character area, using the arrangement order as the index address corresponding to the code word unit, and forming an extended character area; A code table embedding unit arranges the basic character area and the extended character area in order according to the index address, the arrangement order is the code word unit index address, and the index addresses corresponding to all the code word units are used as code table addresses to form a linked list code table of the GIF file; The data decoding module is used to search the established code table and decompress the compressed data of the GIF file to obtain character information; A color data acquisition module, used to index the color index list through the decompressed character information to obtain corresponding color information; The decoded data writing module is used to determine the storage location of each color information according to the code length information, and output the color information decompressed from the code word unit in reverse order to the random access memory of the specified address.

6. The device for decoding a GIF file according to claim 5, characterized in that: The data decoding module comprises: A second acquisition unit is used to obtain a linked list code table of a GIF file and an index value corresponding to its decoding, and obtain a corresponding code word unit according to the index value; The first decoding unit directly completes the query decoding of the basic code word unit if the obtained code word unit is a basic code word unit in the basic character area; The second decoding unit, if the obtained codeword unit is a codeword unit in the extended character area, then the basic codeword part of the codeword unit is taken out as the constituent element of the codeword unit, and the index address information is taken out as the index address of the next basic codeword unit character; if the obtained codeword unit is a new codeword unit after combination in the extended character area, then the last codeword of the codeword unit is taken out as the basic codeword unit, and the remaining codewords are used as the corresponding index addresses; the index address is used as a new index value, and the new index value is used to obtain the basic codeword unit of the next codeword unit; until the remaining index address is within the index address range of the basic codeword unit, the query decoding of the new codeword unit is completed.

7. The device for decoding a GIF file according to claim 6, characterized in that: The color data acquisition module is specifically used to obtain a basic character of a code word unit from a linked list code table, and use this basic character to index the color index list to obtain corresponding color information.

8. The device for decoding a GIF file according to claim 6, characterized in that: The decoded data writing module comprises: A code length information determination unit determines the number of times the color information is spliced ​​according to the recorded code length information; The color information splicing unit determines the storage location of each color information according to the code length information, and outputs the color information decompressed from the code word unit in reverse order to the random access memory of the designated address.

Citation Information

Patent Citations

  • Image decoding method and device

    CN107705340A