WO2018184465A1 - Image file processing method, apparatus, and storage medium - Google Patents
Image file processing method, apparatus, and storage medium Download PDFInfo
- Publication number
- WO2018184465A1 WO2018184465A1 PCT/CN2018/079463 CN2018079463W WO2018184465A1 WO 2018184465 A1 WO2018184465 A1 WO 2018184465A1 CN 2018079463 W CN2018079463 W CN 2018079463W WO 2018184465 A1 WO2018184465 A1 WO 2018184465A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- color
- rgb
- color table
- table information
- Prior art date
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 20
- 238000012545 processing Methods 0.000 claims abstract description 252
- 238000000034 method Methods 0.000 claims abstract description 172
- 238000006243 chemical reaction Methods 0.000 claims abstract description 85
- 238000012549 training Methods 0.000 claims description 281
- 238000012986 modification Methods 0.000 claims description 78
- 230000004048 modification Effects 0.000 claims description 78
- 238000013139 quantization Methods 0.000 claims description 11
- 230000005540 biological transmission Effects 0.000 abstract description 10
- 238000010586 diagram Methods 0.000 description 57
- 238000004891 communication Methods 0.000 description 20
- 230000006835 compression Effects 0.000 description 10
- 238000007906 compression Methods 0.000 description 10
- 238000004364 calculation method Methods 0.000 description 8
- 239000011159 matrix material Substances 0.000 description 8
- 230000001174 ascending effect Effects 0.000 description 6
- NUHSROFQTUXZQQ-UHFFFAOYSA-N isopentenyl diphosphate Chemical compound CC(=C)CCO[P@](O)(=O)OP(O)(O)=O NUHSROFQTUXZQQ-UHFFFAOYSA-N 0.000 description 5
- 230000006870 function Effects 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 2
- 239000003086 colorant Substances 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000000717 retained effect Effects 0.000 description 2
- 238000004590 computer program Methods 0.000 description 1
- 230000006837 decompression Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005538 encapsulation Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000005070 sampling Methods 0.000 description 1
- 230000035939 shock Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/20—Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
- H04N21/23—Processing of content or additional data; Elementary server operations; Server middleware
- H04N21/234—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
- H04N21/2343—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
- H04N21/234318—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by decomposing into objects, e.g. MPEG-4 objects
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/20—Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
- H04N21/23—Processing of content or additional data; Elementary server operations; Server middleware
- H04N21/234—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
- H04N21/2343—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
- H04N21/234336—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by media transcoding, e.g. video is transformed into a slideshow of still pictures or audio is converted into text
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/43—Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
- H04N21/44—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
- H04N21/4402—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
- H04N21/440218—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/43—Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
- H04N21/44—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
- H04N21/4402—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
- H04N21/440236—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by media transcoding, e.g. video is transformed into a slideshow of still pictures, audio is converted into text
Definitions
- the present application relates to the field of computer technologies, and in particular, to a picture file processing method, apparatus, and storage medium.
- Image files are animated images composed of continuous multi-frame images.
- image files have been widely used due to their dynamic display effects, such as instant messaging, web page display, etc.
- the content of the file is relatively complicated, resulting in a large amount of file data of the image file, requiring a large bandwidth for transmission, and increasing the bandwidth cost.
- the embodiment of the present invention provides a method for processing a picture file and a device thereof, which can reduce the amount of file data in the transmission process of the picture file and reduce the bandwidth cost.
- An embodiment of the present application provides a method for processing a picture file, which is applied to a computing device, and may include:
- the code stream data is information generated by the sending device to encode first color data of each pixel in the original picture file
- the code stream data is decoded to generate second color data, and the second color data is processed based on the color table to generate a second picture file.
- the embodiment of the present application further provides a method for processing a picture file, which is applied to a computing device, and may include:
- each color value in the initial color table is arranged according to a preset sorting manner of values of one color component
- the updated color data is image encoded to generate the second picture file.
- the embodiment of the present application further provides a method for processing a picture file, which is applied to a computing device, and may include:
- a transcoded code stream sent by the sending end for the original picture file parsing the transcoded code stream to obtain a picture header information data segment and code stream data of the picture file, where the code stream data is the transmitting end to the YUV ( Y is a luminance component, UV is a chrominance component, YUV is a video data format) data is encoded and generated, and the YUV data is data generated by the transmitting end to convert each frame image in the image file;
- the embodiment of the present application further provides a method for processing a picture file, which may include:
- transcoded code stream includes the picture header information data segment and the code stream data
- the embodiment of the present application further provides a method for processing a picture file, which is applied to a computing device, and may include:
- RGB Red Green Blue
- the initial color table information of the RGB data is trained by using the RGB values of the respective pixels to generate local color table information of the RGB data;
- the RGB values of the respective pixels are updated using the local color table information of the RGB data.
- the embodiment of the present application further provides a picture file processing apparatus, which may include a processor and a memory, where the memory stores computer readable instructions, and the processor may be:
- Obtaining a transcoded code stream for the original picture file parsing the transcoded code stream to obtain a picture header information data segment and code stream data, where the picture header information data segment includes a color table of the original picture file, the code
- the stream data is information generated by the sending device to encode the first color data of each pixel in the original picture file;
- the embodiment of the present application further provides a picture file processing apparatus, which may include: a processor and a memory, where the memory stores computer readable instructions, and the processor may be:
- each color value in the initial color table is arranged according to a preset sorting manner of values of one color component
- the updated color data is image encoded to generate the second picture file.
- the embodiment of the present application further provides a computer readable storage medium storing computer readable instructions, which may cause a processor to execute the methods of the embodiments.
- the second color data when the transcoded stream is received, the second color data may be generated according to the code stream data, and the second color data is processed according to the color table to generate a second image file.
- the time for generating and displaying the second picture file can be shortened, and the complexity of generating the second picture file can be reduced.
- the search time of the color table can be shortened, and the processing efficiency can be improved.
- FIG. 1A is a schematic flowchart of a method for processing a picture file according to an embodiment of the present application.
- FIG. 1B is a schematic flowchart of a method for processing a picture file according to an embodiment of the present application
- FIG. 2 is a sequence diagram of a process of a picture file processing method according to an embodiment of the present application
- FIG. 3 is a schematic diagram of an example of processing a picture file provided by an embodiment of the present application.
- FIG. 4 is a schematic diagram of another example of image file processing provided by an embodiment of the present application.
- FIG. 5 is a schematic diagram of another example of image file processing provided by an embodiment of the present application.
- FIG. 6 is a schematic diagram of another example of image file processing provided by an embodiment of the present application.
- FIG. 7 is a sequence diagram of a process of another image file processing method provided by an embodiment of the present application.
- FIG. 8 is a schematic flowchart diagram of another method for processing a picture file according to an embodiment of the present application.
- FIG. 9 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- FIG. 10 is a schematic diagram of an example of generating compressed image data according to an embodiment of the present application.
- FIG. 11 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- FIG. 12 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- FIG. 13 is a schematic diagram showing an example of generating a picture file according to an embodiment of the present application.
- FIG. 14 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- FIG. 15 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- FIG. 16 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- FIG. 17 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- FIG. 18 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- FIG. 19 is a schematic diagram showing an example of a primary chrominance component of a YUV420 mode according to an embodiment of the present application.
- FIG. 20 is a schematic diagram showing an example of a target chrominance component of a YUV420 mode according to an embodiment of the present application
- 21A is a schematic flowchart of still another method for processing a picture file according to an embodiment of the present application.
- 21B is a schematic flowchart of still another method for processing a picture file according to an embodiment of the present application.
- FIG. 22 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- FIG. 23 is a schematic structural diagram of a picture file processing apparatus according to an embodiment of the present disclosure.
- FIG. 24 is a schematic structural diagram of an image conversion unit according to an embodiment of the present disclosure.
- FIG. 25 is a schematic structural diagram of another picture file processing apparatus according to an embodiment of the present disclosure.
- FIG. 26 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present disclosure.
- FIG. 27 is a schematic structural diagram of an image coding unit according to an embodiment of the present disclosure.
- 29 is a schematic structural diagram of an image processing system according to an embodiment of the present application.
- FIG. 30 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application.
- FIG. 31 is a schematic structural diagram of another image conversion unit according to an embodiment of the present disclosure.
- FIG. 32 is a schematic structural diagram of another image coding unit according to an embodiment of the present application.
- FIG. 33 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application.
- FIG. 34 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present disclosure.
- FIG. 35 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application.
- FIG. 1A is a schematic flowchart of still another method for processing a picture file according to an embodiment of the present application.
- the method can be performed by a computing device.
- the method can include the following steps.
- S101A Receive a transcoded code stream of the original picture file sent by the sending device, parse the transcoded code stream to obtain a picture header information data segment and code stream data, where the picture header information data segment includes the color of the original picture file.
- the code stream data is information generated by the sending device to encode first color data of each pixel in the original picture file.
- the first color data may be RGB data, or YUV data, or HSV data or the like.
- the color table may be a color table corresponding to the picture.
- the color table may be a global color table of the picture file or a partial color table of a frame image in the picture file.
- the picture header information data segment further includes delay information, a total number of frames.
- the computing device may perform image encoding on the updated second color data by using the delay time and the total number of frames to generate the second picture file.
- the computing device may generate a local color table corresponding to the second color data by using a color value of each pixel in the second color data and the color table, and use the local color table to The color value of each pixel is updated.
- the computing device may use the second color data to train an initial color table of the first frame image, Obtaining a partial color table corresponding to the first frame image, wherein the initial color table of the first frame image is the color table.
- the computing device may use the second color data to train the initial color table corresponding to the Nth frame image to obtain a A partial color table corresponding to the image of the Nth frame.
- the initial color table corresponding to the Nth frame image is a local color table corresponding to the N-1th frame image of the original picture file, and N is an integer greater than 1.
- the computing device can sort the color values in the initial color table in a predetermined ordering of one color component to generate a training color table. Obtaining a first color value of the color component closest to the color component of the pixel point in the training color table for each pixel in the second color data, and acquiring a first color value The first color index. Obtaining, in a preset range centered on the first color index in the training color table, a second color value having a smallest error with a color value of the pixel point, and acquiring a second color index of the second color value .
- a pre-position of the second color index in the training color table Set a number of color values within the range to modify.
- the modified training color table is determined as the partial color table.
- the color component described above may be any one of a plurality of parameters representing a color.
- the above color component may be an R component, a G component, or a B component.
- the above color component may be a Y component, a U component, or a V component.
- the transcoded stream of the original picture file may be sent by the sending end, and the computing device may receive the transcoded code stream sent by the second computing device.
- the transmitting device may generate the picture header information data segment and the first color data according to the original picture file. The first color data is encoded to generate the code stream data. And storing the transcoded code stream, where the transcoded code stream includes the picture header information data segment and the code stream data. The transmitting device can read the stored transcoded stream and transmit the transcoded stream to the receiving device as needed.
- the picture file processing method in the embodiment of the present application can be applied to a scene in which a picture file is encoded, decoded, and transmitted, for example, instant messaging, web page display, and the like.
- the transmitting end generates a picture header information data segment of the picture file according to the original picture file, and converts each frame image in the picture file into YUV data, and the transmitting end encodes the YUV data to generate code stream data.
- the transmitting end generates compressed image data, and sends the compressed image data to a receiving end, where the compressed image data includes the picture header information data segment and the code stream data.
- the receiving end receives the compressed image data sent by the sending end, and parses the compressed image data to obtain the picture header information data segment and the code stream data.
- the receiving end generates the YUV data according to the code stream data, and performs encoding processing on the YUV data based on the picture header information data segment to generate a scene of the picture file and the like.
- the transmitting end of the embodiment of the present application may be a terminal device or a background service device having functions such as decoding, encoding, and the like, or may be an image processing module in the terminal device or the service device.
- the receiving end may be a terminal device or a background service device having a function of encoding a picture file, a video decompression, or the like, or may be an image processing module in the terminal device or the service device.
- the above terminal devices may include computers, tablets, smart phones, notebook computers, palmtop computers, and mobile internet devices (MIDs).
- MIDs mobile internet devices
- the sending end may be a terminal device that sends a picture file
- the receiving end may be a background service device that receives an instant messaging application of the picture file.
- the sending end is a background service device of an instant messaging application that forwards a picture file
- the receiving end is a terminal device that receives a picture file, and the like.
- the transmitting end may be a terminal device that sends a picture file
- the receiving end may be a terminal device that receives a picture file.
- the above scenario is only an example. The type of the sender and the receiver can be determined according to the actual running scenario.
- the image file may be a graphics exchange format.
- GIF Graphics Interchange Format Any of an image, an Audio Video Interleaved (AVI) image, a SWF (Shock Wave Flash), and an Animated Portable Network Graphics (APNG).
- An image used to represent a frame of a picture file An image used to represent a frame of a picture file.
- a component that represents a single matrix in a matrix or matrix of three sample matrices of an image A component that represents a single matrix in a matrix or matrix of three sample matrices of an image.
- Brightness used to represent a matrix of samples of the luminance signal Y or a single sample.
- Chromaticity used to represent the sample matrix and single sample of either of the Cr and Cb color difference signals.
- the code stream data is used to represent the data obtained after encoding, and may also be described by using a name such as video frame data.
- the image feature information segment is used to represent information such as delay information, total number of frames, and global color table information of the image file.
- a user-defined information segment that indicates information such as configuration parameters, encoder complexity, and the like when encoding three primary colors (Red Green Blue, RGB) data or YUV data.
- the picture header information data segment is used to indicate the beginning end of the compressed image data, and may include an image feature information segment and a user-defined information segment.
- the compressed image data is used to represent the data generated by the image format encapsulation of the code stream data and the image header information data segment, and may also be described by using a name such as an image sequence or a compressed code stream.
- FIG. 1B is a schematic flowchart of a method for processing a picture file according to an embodiment of the present application.
- the embodiment of the present application jointly illustrates a specific process of the image file processing method from the sending end and the receiving end, and the method may include the following steps.
- S101B The sending end generates a picture header information data segment of the picture file according to the original picture file, and converts each frame image in the picture file into YUV data.
- the sender may decode the original picture file to generate a picture header information data segment of the picture file.
- the image file may be an image input by the developer after the image is created, or may be an image received from the other end.
- the picture header information data segment may include delay information of the picture file, a total number of frames, and the like. The delay information records a play interval between each frame of the picture file. The total number of frames is the number of image frames in the picture file.
- the picture header information data segment may further include global color table information of the picture file.
- the global color table information contains RGB values for each pixel of each frame of image. For some image files, all images contained in it share a global color table information. For some other image files, each frame image has its own local color table information.
- the transmitting end further converts each frame image in the picture file into YUV data.
- the transmitting end encodes the YUV data to generate code stream data.
- the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
- the encoding may include predictive coding, transform coding, quantization coding, and entropy coding.
- the transmitting end may compress the YUV data by using an IPPP mode.
- the first frame YUV data is an I frame
- the I frame is an intra prediction frame
- the remaining frame YUV data is a P frame
- the P frame is an interframe.
- the prediction frame can effectively compress the file data amount of the picture file, and can also use a fixed quantization parameter (QP) to stabilize the quality between different frames.
- QP fixed quantization parameter
- the entropy coding may include Huffman coding, arithmetic coding, and the like.
- S103B The transmitting end sends the compressed image data to the receiving end.
- the transmitting end may generate compressed image data, and the transmitting end may store the compressed image data.
- the transmitting end sends the compressed image data to the receiving end. For example: when the sender detects that the webpage containing the image file is open.
- the transmitting end may also directly send the compressed image data to the receiving end. For example, when a client in an instant messaging application needs to send the image file to another client, the application service device needs to forward the image file, and the compressed image data includes the image header information data segment. And the code stream data.
- the receiving end receives the compressed image data sent by the sending end, and parses the compressed image data to obtain the picture header information data segment and the code stream data.
- the receiving end receives the compressed image data sent by the sending end, and the receiving end may perform parsing processing on the compressed image data to obtain the picture header information in the compressed image data. Data segment and the code stream data.
- the receiving end generates the YUV data according to the code stream data, and processes the YUV data according to the picture header information data segment to generate the picture file.
- the receiving end decodes the code stream data to generate the YUV data, and encodes the YUV data based on delay information, total frame number, global color table information, and the like in a picture header information data segment. Processing to generate the picture file.
- the picture header information data segment of the picture file is generated according to the original picture file, and each frame image in the picture file is converted into YUV data, and then the code stream data and the picture header information obtained by encoding according to the YUV data are obtained.
- the data segment generates compressed image data, and transmits the compressed image data.
- YUV data may be generated according to the code stream data, and the YUV data is processed based on the image header information data segment to generate a picture file.
- FIG. 2 a flow chart of a method for processing a picture file is provided in an embodiment of the present application.
- the specific process of the image file processing method is jointly illustrated by the sending end side and the receiving end side, and the method may include the following steps.
- the sending end decodes a picture header information data segment of the original picture file to generate a picture file and RGB data corresponding to each frame image in the picture file.
- the transmitting end may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
- the transmitting end converts the RGB data into YUV data by using a color space conversion formula.
- the transmitting end may convert the RGB data into YUV data using a color space conversion formula.
- the range of the luminance component can be selected as [16, 235], and the range of the chrominance component is in the range of [16, 240]. Due to the reduction of the range of values, the amount of data of the converted YUV data can be greatly reduced. It is also possible to select the range of the luminance component and the chrominance component to be the [0, 255] color space conversion formula, which can reduce the distortion of the converted YUV data.
- the color space conversion formula for the range of luminance components and chrominance components with the range of [0, 255] is:
- V 0.5R - 0.4187G - 0.0813B + 128.
- YUV is a video data format
- Y is the luminance component
- UV is the chrominance component.
- the color space conversion formula can perform raster scan processing on the pixels of each frame of image, and convert each frame of RGB data into corresponding YUV data. .
- the transmitting end encodes the YUV data to generate code stream data.
- the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
- the user may be configured to add a configuration parameter, where the configuration parameter may be a parameter that encodes the YUV data, and the configuration parameter may include an SD mode parameter and a HD mode.
- the configuration parameter may be a parameter that encodes the YUV data
- the configuration parameter may include an SD mode parameter and a HD mode.
- the SD mode parameters for example: YUV420 mode parameters
- HD mode parameters for example: YUV444 mode parameters.
- the transmitting end may encode the YUV data by using configuration parameters to generate code stream data.
- the user may be added to add encoder complexity during encoding of the YUV data.
- the encoder complexity may be a fineness parameter of the encoding determined according to the hardware performance of the transmitting end.
- the encoder complexity may include any of the first complexity, the second complexity, and the third complexity.
- the first complexity is higher than the second complexity, and the second complexity is higher than the third complexity.
- the hardware performance of the sender can be detected to generate a performance value. For example: testing the calculation rate of the central processing unit of the transmitting end, and the like. When the performance value is within the first preset value range, it may be determined that the hardware performance of the transmitting end is high, and the encoding method of the first complexity may be recommended.
- the performance value When the performance value is within the second preset value range, it may be determined that the hardware performance of the transmitting end is medium, and the encoding method of the second complexity may be recommended.
- the performance value When the performance value is within the third preset value range, it may be determined that the hardware performance of the transmitting end is poor, or the current real-time transcoding is required, and the encoding method of the third complexity may be recommended.
- the transmitting end may configure an encoder complexity to encode the YUV data to generate code stream data.
- the foregoing two coding modes may be parallel coding modes, that is, the transmitting end may simultaneously encode the YUV data to generate code stream data by using configuration parameters and configured encoder complexity.
- the above performance value, the first preset value range, the second pass preset value range, and the third preset value range may be specifically set according to the developer's human experience.
- the transmitting end sends the compressed image data to the receiving end.
- the receiving end receives the compressed image data sent by the sending end, and parses the compressed image data to obtain the picture header information data segment and the code stream data.
- the receiving end decodes the code stream data to generate the YUV data, and converts the YUV data into RGB data by using a color space conversion formula.
- the receiving end decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data by using a color space conversion formula.
- the receiving end needs to be based on a luminance component.
- the range of values determines the color space conversion formula used. It can be understood that for the YUV data in the YUV444 mode, the range of the luminance component can be selected as [16, 235], and the range of the chrominance component is [ 16,240] color space conversion formula, you can also select the range of the luminance component and the chrominance component are all [0, 255] color space conversion formula, specifically according to the above embodiment in the conversion of RGB data to YUV data The color space conversion formula selected at the time corresponds.
- the chromaticity includes a sample matrix and a single sample of any one of Cb and Cr color difference signals.
- the two color difference signals need to be separately subjected to upsampling processing, and the two methods of performing upsampling processing are the same, wherein Cb corresponds to U in YUV, and Cr corresponds to V in YUV.
- the color space conversion formula is:
- the color space conversion formula can perform raster scan processing on the pixels of each frame of image, and convert each frame of YUV data into corresponding RGB data.
- the receiving end updates the RGB values of each pixel in the RGB data by using the global color table information.
- the RGB data converted by the YUV data is distorted, and the receiving end may use the global color table information in the RGB data.
- the RGB values of each pixel are updated.
- the RGB data may include one or more pixel points, and when only one pixel point exists in the RGB data, the RGB value of the pixel point may be updated by using the global color table information, when the RGB When there are multiple pixels in the data, the RGB values of the pixels in the plurality of pixels may be updated by using the global color table information, and the receiving end needs to re-train the global color table information to generate Corresponding to the local color table information of the RGB data, and in the case where there is no global color table information, the receiving end may generate initial color table information, and perform training by initializing the color table information to generate the Local color table information for RGB data.
- the receiving end may adopt each pixel in the RGB data.
- the RGB values of the points train the global color table information to generate local color table information of the RGB data, and update the RGB values of the respective pixel points by using local color table information of the RGB data.
- the receiving end may use the global color table information.
- the at least one source RGB value is sorted according to a preset ordering of the G components (eg, ascending, descending, etc.) to generate training color table information. As shown in FIG.
- the global color table information includes a color index and a source RGB value, for example: 5, (8, 1, 10), 6, (8, 9, 8), 7, (1, 7, 6), 8, (10,8,6), 9, (5,8,5), 10, (9,10,1), according to the ascending order of the G component can generate training color table information, for example: 5, (8,1,10), 6, (1,7,6), 7, (5,8,5), 8, (10,8,6), 9, (8,9,8), 10, (9,10,1).
- the receiving end acquires, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquires a first color index of the first source RGB value. .
- the receiving end may traverse the source RGB value in the training color table information by using the G component of the current pixel point, and acquire the first source RGB value that is closest to the G component. As shown in FIG. 4, it is assumed that there are four pixel points in the first frame RGB data, and the current pixel point is the first pixel point in the RGB data, and the RGB value of the current pixel point is (9, 9, 9).
- the G component of (8, 9, 8) is closest to the G component of the RGB values of the current pixel point, and (8, 9, 8) is determined as the first Source RGB values, and a first color index "9" of the first source RGB value is obtained.
- the receiving end And acquiring, by the receiving end, a second source RGB value having the smallest error of the RGB value of the current pixel point in the preset range centered on the first color index in the training color table information, and acquiring the A second color index of the second source RGB value.
- the receiving end may be centered on the first color index, acquire a plurality of source RGB values in a preset range before and after the first color index, and calculate the first source RGB value and the multiple The error of the source RGB value and the RGB value of the current pixel point, and the source RGB value that minimizes the error among the plurality of source RGB values is determined as the second source RGB value.
- the two source RGB values of (10, 8, 6) and (9, 10, 1) are obtained centered on “9” and calculated separately (10) Error values of (8,9,8), (8,9,8) and (9,10,1) and (9,9,9).
- the error value of the color index "8" is
- 5
- the error value of the color index "9” is
- 2
- the error value of the color index "10” is
- 9
- the source RGB value is determined (8, 9, 8) Is the second source RGB value, and acquires a second color index "9" of the second source RGB value.
- the first source RGB value and the first color index obtained are the same as the second source RGB value and the second color index, and may also be different, which is specifically determined by the actual execution process.
- the receiving end replaces the second source RGB value with the RGB value of the current pixel point, and adopts a preset weight value and an RGB value of the current pixel point, and the training color table information is
- the second color index is modified for a plurality of source RGB values within a preset range of the center. Referring to FIG. 5, according to the above example, when the second source RGB value is (8, 9, 8), (8, 9, 8) is replaced with the RGB value (9, 9, 9) of the current pixel point, and A plurality of source RGB values within a preset range centered on the second color index may be modified according to a preset weight value and an RGB value of the current pixel point.
- the preset weight value may be a dynamic weight value, and the closer the source RGB value is to the second color index, the greater the influence of the RGB value of the current pixel point.
- the (9, 8, 9) pair (10, 8, 6) is modified.
- the source RGB value of the color index "8" is modified from (10, 8, 6) to (9, 9, 8).
- the source RGB value of the color index "10" is modified from (9, 10, 1) to (9, 9, 7).
- the receiving end acquires Modifying the training color table information, using the next pixel point of the current pixel as the current pixel point, and transferring to perform acquiring the G component and the current pixel in the RGB data in the training color table information
- the G component of the point is closest to the first source RGB value.
- the second pixel point in the RGB data is used as the current pixel point, and the training color table information obtained after the modification is once again trained.
- the training process can be referred to the description of the above training process, and details are not described herein.
- the receiving end acquires the modification.
- the training color table information obtained later is determined, and the training color table information is determined as local color table information of the RGB data.
- the receiving end may update the RGB values of the pixel points by using local color table information of the RGB data.
- the receiving end may sequentially acquire, in the local color table information of the RGB data, source RGB values that are the same as the pixel points or have the smallest error, and replace the RGB values of the respective pixel points.
- the receiving end may replace the RGB values of the respective pixel points with color indexes corresponding to the source RGB values that are the same or the smallest error of the respective pixel points. Referring to FIG. 6, according to the above example, the RGB value of the first pixel of the RGB data is (9, 9, 9), and the error with the (9, 9, 9) in the partial color table information is the smallest.
- the color index "8" corresponding to (9, 9, 8) is replaced by the RGB value of the first pixel.
- the color index of the second pixel is "10”.
- the color index of the third pixel is "9”
- the color index of the fourth pixel is "6".
- the receiving end may adopt the RGB data.
- the RGB values of the respective pixels are trained to initialize the color table information to generate local color table information of the RGB data, and the RGB values of the respective pixel points are updated using the local color table information of the RGB data.
- the receiving end may generate an initialization color table information, For example: (0,0,0), (1,1,1), (2,2,2), ..., (255,255,255).
- the receiving end acquires a third source RGB value of the G component closest to the G component of the current pixel point in the RGB data in the initialization color table information, and acquires a third color index of the third source RGB value.
- a fourth source RGB value having the smallest error of the RGB value of the current pixel point in the preset range centered on the third color index in the initialization color table information and acquiring the A fourth color index of the fourth source RGB value.
- the receiving end replaces the fourth source RGB value with the RGB value of the current pixel point, and adopts a preset weight value and an RGB value of the current pixel point, and the initial color table information is The fourth color index is modified by a plurality of source RGB values within a preset range of the center.
- the receiving end acquires the initialized color table information obtained after the modification, and uses the next pixel point of the current pixel point as the current pixel.
- Pointing and transferring to perform a third source RGB value that obtains the G component closest to the G component of the current pixel point in the RGB data in the initialization color table information When the current pixel point is the last pixel point in the RGB data, the receiving end acquires the modified color table information obtained after the modification, and determines the initialization color table information as the RGB data.
- the local color table information the receiving end may use the local color table information of the RGB data to update the RGB values of the respective pixel points.
- the RGB data is not the first frame image in the picture file, that is, the RGB data is the Nth frame image in the picture file, where N is greater than 1 and less than or A positive integer equal to the total number of frames.
- the receiving end may train the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate local color table information of the RGB data, and adopt the RGB The local color table information of the data updates the RGB values of the respective pixel points.
- the receiving end may use at least one source RGB value in the local color table information of the N-1th frame RGB data according to the G component. Sort the presets to generate training color table information.
- the receiving end acquires, in the training color table information, a fifth source RGB value whose G component is closest to the G component of the current pixel point in the RGB data, and acquires a fifth color index of the fifth source RGB value. .
- the receiving end replaces the sixth source RGB value with the RGB value of the current pixel point, and adopts a preset weight value and an RGB value of the current pixel point, and the training color table information is
- the sixth color index is modified by a plurality of source RGB values within a preset range of the center.
- the receiving end acquires the modified color table information obtained by the modification, and uses the next pixel of the current pixel as the current pixel. Pointing, and transferring to a fifth source RGB value that performs the closest acquisition of the G component in the training color table information to the G component of the current pixel point in the RGB data.
- the receiving end acquires the modified color table information obtained after the modification, and determines the training color table information as the RGB data. Local color table information.
- the receiving end may update the RGB values of the pixel points by using local color table information of the RGB data. It should be noted that, in this example, the process of training the training color table information and updating the RGB values of each pixel by using the local color table information of the RGB data can be referred to the execution process of the foregoing manner, and details are not described herein.
- the G component as the training for training the color table information is only an example.
- the R component or the B component can also be used as the guidance for training the color table information.
- the description in the content is not described here.
- the index, the fourth color index, the fifth color index, and the sixth color index may all represent the same source RGB value and the meaning of the color index.
- the naming in this manner is only to distinguish different execution scenarios, for example: when the RGB data And being the first frame image in the picture file, and the global color table information is present in the picture header information data segment. When the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment. When the RGB data is the Nth frame image in the picture file, the above three execution scenarios.
- the receiving end performs image coding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
- the receiving end performs image encoding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
- the receiving end may use the Lempel-Ziv-Welch Encoding (LZW) pair in the RGB data based on the delay time and the total number of frames.
- LZW Lempel-Ziv-Welch Encoding
- the color index of each pixel is image-encoded to generate the image file, and the receiving end may store or display the image file.
- the manner of the image encoding is specifically determined by the image format of the image file. For example, if the image file to be generated is a GIF image, the image encoding may be GIF encoding or the like.
- FIG. 7 a flow chart of another method for processing a picture file is provided in the embodiment of the present application.
- the specific process of the image file processing method is jointly illustrated by the sending end side, the transiting device side, and the receiving end side, and the method includes the following steps.
- the sending end decodes the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
- the transmitting end may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
- the transmitting end converts the RGB data into YUV data by using a color space conversion formula.
- the transmitting end may convert the RGB data into YUV data using a color space conversion formula.
- the transmitting end encodes the YUV data to generate code stream data.
- the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
- a user may be added to add configuration parameters, which may be parameters that encode the YUV data.
- the transmitting end may encode the YUV data by using configuration parameters to generate code stream data.
- a user may also be added to add encoder complexity, which may be a fineness parameter of the encoding determined according to hardware performance of the transmitting end.
- the transmitting end may configure an encoder complexity to encode the YUV data to generate code stream data.
- the sending end sends the compressed image data to the relay device.
- the transmitting end may generate compressed image data, and the transmitting end may store the compressed image data, and when detecting the request of the receiving end for the picture file, the sending end performs the The compressed image data is sent to the receiving end.
- the relay device receives the compressed image data sent by the sending end, and sends the compressed image data to a receiving end.
- the relay device may be a connection device between the sending end and the receiving end, and if the sending end and the receiving end cannot directly connect, the relay device performs compressed image data.
- the transit processing for example, for two clients in an instant messaging application, the relay device may be a background service device of an instant messaging application or the like.
- the relay device receives the compressed image data sent by the sending end, and may send the compressed image data to the receiving end according to the application identifier of the receiving end indicated by the sending end.
- the receiving end receives the compressed image data sent by the relay device, and parses the compressed image data to obtain the picture header information data segment and the code stream data.
- the receiving end receives the compressed image data sent by the relay device, and the receiving end may perform parsing processing on the compressed image data to obtain the picture header information in the compressed image data. Data segment and the code stream data.
- the receiving end decodes the code stream data to generate the YUV data, and converts the YUV data into RGB data by using a color space conversion formula.
- the receiving end decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data using a color space conversion formula. In some examples, the receiving end needs to determine the color space conversion formula used according to the range of values of the luminance component.
- the receiving end updates the RGB values of each pixel in the RGB data by using the global color table information.
- the receiving end performs image coding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
- FIG. 8 is a schematic flowchart diagram of another method for processing a picture file according to an embodiment of the present application.
- the embodiment of the present application describes a specific process of the image file processing method from the sending end side, and the method may include the following steps S301-S303.
- the sender may decode the original picture file to generate a picture header information data segment of the picture file.
- the transmitting end further converts each frame image in the picture file into YUV data.
- the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
- the receiving end decodes the code stream data to generate the YUV data, and performs encoding processing on the YUV data based on delay information, total frame number, global color table information, and the like in a picture header information data segment to generate a Said picture file.
- the picture header information data segment of the picture file is obtained, and each frame image in the picture file is converted into YUV data, and then the code stream data obtained by encoding based on the YUV data is obtained. And the picture header information data segment generates compressed image data, and the compressed image data is transmitted.
- the code stream data can be decoded to generate YUV data, and then the YUV data is encoded and processed based on the picture header information data segment.
- Image file
- FIG. 9 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- the embodiment of the present application describes a specific process of the image file processing method from the sending end side, and the method may include the following steps S401-S404.
- the transmitting end may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
- the transmitting end may convert the RGB data into YUV data using a color space conversion formula.
- the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
- FIG. 10 is a schematic diagram of an example of generating compressed image data according to an embodiment of the present application.
- delay information total number of frames, global color table information, and the like of the picture file may be acquired, and the delay information is recorded in each frame of the picture file.
- the interval between the playback time and the total number of frames is the number of image frames in the picture file.
- the picture header information data segment may further include global color table information of the picture file,
- the global color table information contains the RGB values of each pixel of each frame of image. For some image files, all the images contained in it share a global color table information, and for other image files, each frame image has its own The local color table information is obtained.
- the global color table information exists in the image file, the global color table information is acquired. If only the local color table information exists in the image file, the local color table information is not acquired.
- the delay information, the total number of frames, the global color table information, and the like of the picture file may be encapsulated to generate a picture header information data segment of the picture file.
- Simultaneously decoding the picture file can also obtain RGB data corresponding to each frame image in the picture file.
- the RGB data can be converted into YUV data by using a color space conversion formula, and the pixel of each frame image can be rastered by a color space conversion formula.
- the scanning process converts each frame of RGB data into corresponding YUV data.
- the YUV data may be further subjected to encoding processing to generate code stream data, which may include predictive coding, transform coding, quantization coding, and entropy coding.
- code stream data which may include predictive coding, transform coding, quantization coding, and entropy coding.
- the user can be added to add configuration parameters, and the user can also add encoder complexity.
- compressed image data can be generated.
- FIG. 11 a flow chart of still another method for processing a picture file is provided in the embodiment of the present application.
- the embodiment of the present application describes a specific process of the image file processing method from the receiving end side, and the method may include the following steps S501 and S502.
- the sender may decode the original picture file to generate a picture header information data segment of the picture file.
- the transmitting end further converts each frame image in the picture file into YUV data.
- the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
- FIG. 12 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- the embodiment of the present application describes a specific process of the image file processing method from the receiving end side, and the method may include the following steps S601-S604.
- the transmitting end may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
- the transmitting end may convert the RGB data into YUV data by using a color space conversion formula.
- the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
- S602. Decode the code stream data to generate the YUV data, and convert the YUV data into RGB data by using a color space conversion formula.
- the receiving end decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data using a color space conversion formula. In some examples, the receiving end needs to determine the color space conversion formula used according to the range of values of the luminance component.
- the receiving end performs image encoding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
- the receiving end may perform image coding on a color index of each pixel in the RGB data by using an LZW based on the delay time and the total number of frames to generate the picture file.
- the receiving end may store or display the picture file.
- FIG. 13 is a schematic diagram of an example of generating a picture file according to an embodiment of the present application.
- the compressed image data may be parsed to obtain a picture header information data segment and code stream data in the compressed image data, where the picture header information data segment may include extension Time information, total number of frames, global color table information, etc., the delay information records a play interval between each frame of the picture file, and the total number of frames is the number of image frames in the picture file .
- the global color table information contains RGB values for each pixel of each frame of image. For some image files, all the images it contains share a global color table information. For other picture files, each frame image has its own local color table information.
- the global color table information exists in the picture header information data segment. If only the local color table information exists in the picture file, the local color table information does not exist in the picture header information data segment.
- the code stream data may be decoded to generate the YUV data, and the YUV data is converted to RGB data using a color space conversion formula. If the currently processed RGB data is the first frame RGB data in the picture file, it is determined whether there is global color table information in the picture header information data segment. If present, the global color table information is trained to generate local color table information of the RGB data by using RGB values of each pixel in the RGB data, and the local color table information of the RGB data is used. The RGB values of the respective pixel points are updated.
- the initialization color table information may be generated, and the initialization color table information is trained by using the RGB values of the pixels in the RGB data to generate local color table information of the RGB data, and adopted
- the local color table information of the RGB data updates the RGB values of the respective pixel points.
- the currently processed RGB data is the Nth frame RGB data in the picture file, where N is a positive integer greater than 1, the RGB value of each pixel in the RGB data may be used to the RGB frame of the N-1th frame.
- the local color table information of the data is trained to generate local color table information of the RGB data, and the RGB values of the respective pixel points are updated using local color table information of the RGB data.
- the updated RGB data is image-encoded by using the delay time and the total number of frames to generate the picture file.
- FIG. 14 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- the picture file processing device in the embodiment of the present application may be a distributed service device, or may be an image processing module in a distributed service device.
- the method in this embodiment may include the following step S701- Step S705.
- the picture file processing device can decode the original picture file to generate a picture header information data segment of the picture file.
- the picture file processing device further converts each frame image in the picture file into YUV data.
- the picture file processing apparatus may further perform encoding processing on the YUV data to generate code stream data, where the encoding may include predictive coding, transform coding, quantization coding, and entropy coding, for example, the picture file processing.
- the device may compress the YUV data by using an IPPP mode.
- the YUV data of the first frame is an I frame
- the I frame is an intra prediction frame
- the remaining frame YUV data is a P frame
- the P frame is an inter prediction frame, which can be effective.
- the amount of file data in the compressed image file can also be fixed in a QP manner to stabilize the quality between different frames.
- the entropy coding may include Huffman coding, arithmetic coding, and the like.
- the picture file processing device may generate compressed image data, and the picture file processing device may store the compressed image data, the compressed image data including the picture header information data segment and the code stream data.
- the picture file processing device may perform parsing processing on the compressed image data to obtain the picture header information data segment and the code stream data in the compressed image data.
- the picture file processing device decodes the code stream data to generate the YUV data, and based on the delay information, the total number of frames, the global color table information, and the like in the picture header information data segment, the YUV data. An encoding process is performed to generate the picture file.
- the picture header information data segment of the picture file is generated according to the original picture file, and each frame image in the picture file is converted into YUV data, and then the code stream data and the picture header information obtained by encoding according to the YUV data are obtained.
- the data segment generates compressed image data, and stores the compressed image data.
- YUV data may be generated according to the code stream data, and the YUV data is processed based on the image header information data segment to generate a picture file.
- FIG. 15 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- the picture file processing device in the embodiment of the present application may be a distributed service device, or may be an image processing module in a distributed service device.
- the embodiment of the present application specifically describes compressing a picture file into a compressed image.
- the process of data, the method may include the following steps S801 to S807.
- the picture file processing device may decode the original picture file. It may be understood that the global color table information includes RGB values of each pixel of each frame image in the picture file, for some picture files, All the images contained in the image share a global color table information, and for other image files, each frame image has its own local color table information, and the image file processing device can further determine the color table in the image file. Whether the information is the global color table information of the picture file, and if yes, proceeds to step S803. If no, the process proceeds to step S804.
- the picture file processing device may generate a picture including delay information, total number of frames, global color table information, and the like. a header information data segment, wherein the delay information records a play interval between each frame of the image file, where the total number of frames is an image frame number in the image file, and the image file is also generated The RGB data corresponding to each frame of the image.
- the picture file processing device may generate a picture header information data segment including delay information, total number of frames, and the like.
- the delay information is recorded with a play interval time between each frame image in the picture file, where the total number of frames is the number of image frames in the picture file, and each frame image in the picture file is also generated.
- Corresponding RGB data may be generated.
- the picture file processing device may convert the RGB data into YUV data using a color space conversion formula.
- a user may be added to add configuration parameters, which may be parameters that encode the YUV data.
- the picture file processing device may encode the YUV data using configuration parameters to generate code stream data.
- the user may also support adding encoder complexity, and the encoder complexity may be the fineness of the encoding determined according to the hardware performance of the picture file processing device. parameter.
- the picture file processing device may configure encoder complexity to encode the YUV data to generate code stream data.
- the picture header information data segment of the picture file is generated according to the original picture file, and each frame image in the picture file is converted into YUV data, and then the code stream data and the picture header information obtained by encoding according to the YUV data are obtained.
- the data segment generates compressed image data and stores the compressed image data.
- FIG. 16 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- the picture file processing device in the embodiment of the present application may be a distributed service device, or may be an image processing module in a distributed service device.
- the embodiment of the present application specifically decompresses compressed image data into a picture.
- the process of the file, the method may include the following steps S901 to S907.
- the picture file processing device decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data by using a color space conversion formula.
- the receiving end needs to be based on The range of values of the luminance component determines the color space conversion formula used.
- the picture file processing device determines whether the global color table information of the picture file is included in the picture header information data segment, and if yes, proceeds to step S904. If no, the process proceeds to step S905.
- the picture file processing apparatus may use the global color table information for each of the RGB data.
- the RGB values of the pixels are updated.
- the global color table information is trained by using RGB values of each pixel in the RGB data to generate local color table information of the RGB data, and adopting The local color table information of the RGB data updates the RGB values of the respective pixels.
- the picture file processing device may adopt the RGB data.
- the RGB values of the respective pixels train the global color table information to generate local color table information of the RGB data, and update the RGB values of the respective pixel points by using the local color table information of the RGB data.
- the picture file processing device may use the global color table. At least one source RGB value in the information is sorted according to a preset ordering of the G components (eg, ascending, descending, etc.) to generate training color table information.
- the picture file processing device acquires, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquires the first value of the first source RGB value. Color index.
- the image file processing device acquires, in a preset range centered on the first color index in the training color table information, a second source RGB value that has the smallest error with the RGB value of the current pixel point, and acquires The second color index of the second source RGB value, it may be understood that the picture file processing device may be centered on the first color index, and acquire multiple times in a preset range before and after the first color index.
- Source RGB values and respectively calculating the first source RGB value and the error of the plurality of source RGB values and the RGB value of the current pixel point, and determining the source RGB value that minimizes the error among the plurality of source RGB values Is the second source RGB value.
- the picture file processing device replaces the second source RGB value with the RGB value of the current pixel point, and adopts a preset weight value and an RGB value of the current pixel point, and the training color table information is
- the second color index is modified by a plurality of source RGB values within a preset range of the center.
- the picture file processing Obtaining, by the device, the training color table information obtained by the modification, using a next pixel point of the current pixel point as a current pixel point, and transferring to performing acquiring the G component and the RGB data in the training color table information
- the first source RGB value of the G component of the current pixel is closest to the first pixel RGB value, for example, the second pixel point in the RGB data is used as the current pixel point, and the training color table information obtained after the modification is trained again.
- the training process in some examples can be referred to the description of the above training process, and will not be described here.
- the picture file processing device Obtaining the training color table information obtained after the modification, and determining the training color table information as local color table information of the RGB data.
- the picture file processing device may update the RGB values of the pixel points by using local color table information of the RGB data.
- the picture file processing device may have local color table information of the RGB data.
- the source RGB values obtained in the same manner as the respective pixel points or the smallest error are sequentially replaced with the RGB values of the respective pixel points, and in some examples, the picture file processing device may be the same as or different from the pixel points.
- the color index corresponding to the smallest source RGB value replaces the RGB values of the respective pixel points respectively. Please refer to FIG. 6 .
- the RGB value of the first pixel of the RGB data is (9, 9, 9)
- the error with (9, 9, 9) is (9, 9, 8)
- the color index "8" corresponding to (9, 9, 8) is replaced by The RGB value of the first pixel, the same reason, the color index of the second pixel is "10", the color index of the third pixel is "9", and the color index of the fourth pixel is "6". .
- the initial color table information is trained by using the RGB values of each pixel in the RGB data to generate local color table information of the RGB data, and the RGB data is used.
- the local color table information updates the RGB values of the respective pixels.
- the picture file processing device may adopt the RGB data.
- the RGB values of the respective pixels are trained to initialize the color table information to generate local color table information of the RGB data, and the RGB values of the respective pixel points are updated by using the local color table information of the RGB data.
- the picture file processing device may generate an initialization color table.
- Information such as: (0, 0, 0), (1, 1, 1), (2, 2, 2), ..., (255, 255, 255), the picture file processing device initializes the color table information Obtaining a third source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value, where the picture file processing device is Obtaining, in a preset range centered on the third color index in the color table information, obtaining a fourth source RGB value having the smallest error with the RGB value of the current pixel point, and acquiring the fourth source RGB value fourth.
- the picture file processing device replacing the fourth source RGB value with an RGB value of the current pixel point, and using the preset weight value and the RGB value of the current pixel point, the initialization color table a preset in the information centered on the fourth color index
- the plurality of source RGB values in the range are modified.
- the picture file processing device acquires the initialized color table information obtained after the modification, and The next pixel point of the current pixel point is used as the current pixel point, and is transferred to a third source RGB value that performs the closest acquisition of the G component in the initialization color table information to the G component of the current pixel point in the RGB data.
- the picture file processing device acquires the modified color table information obtained by the modification, and determines the initialization color table information as the The local color table information of the RGB data, the picture file processing device may update the RGB values of the respective pixel points by using the local color table information of the RGB data. It should be noted that the process of training the initialization color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data can refer to the execution process of the foregoing manner, and details are not described herein.
- the local color table information of the N-1 frame RGB data is trained to generate the local part of the RGB data by using the RGB values of the pixels in the RGB data.
- the color table information is updated with the RGB values of the respective pixels using the local color table information of the RGB data.
- the picture file processing device may set at least one source RGB value in the partial color table information of the N-1th frame RGB data according to Sorting the preset order of the G components to generate training color table information, wherein the picture file processing device acquires the G component in the training color table information that is closest to the G component of the current pixel point in the RGB data.
- the picture file processing device acquires in the preset range centered on the fifth color index in the training color table information a sixth source RGB value having a smallest error from an RGB value of the current pixel point, and acquiring a sixth color index of the sixth source RGB value, the picture file processing device replacing the sixth source RGB value with Determining an RGB value of the current pixel, and using a preset weight value and an RGB value of the current pixel, a plurality of sources in the preset range of the training color table information centered on the sixth color index RGB values are modified
- the picture file processing device acquires the modified color table information obtained after the modification, and uses the next pixel point of the current pixel point as a current pixel point, and proceeds to perform a fifth source RGB value that is obtained in the training color table information to obtain a G component closest to a G component of a current pixel point in the RGB data
- S907 Perform image coding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
- the picture file processing device performs image encoding on the updated RGB data using the delay time and the total number of frames to generate the picture file.
- the picture file processing device may perform image coding on a color index of each pixel in the RGB data by using an LZW based on the delay time and the total number of frames, to generate the picture file.
- the picture file processing device may store or display the picture file.
- FIG. 17 a flowchart of still another method for processing a picture file is provided in the embodiment of the present application.
- the image file processing method provided by the embodiment of the present application is further described with reference to the embodiment shown in FIG. 15, and the method includes the following steps S1001 to S1009.
- S1002 Determine whether the color table information of the picture file is global color table information of the picture file.
- S1003 Generate a picture header information data segment including delay information, a total number of frames, and global color table information, and RGB data corresponding to each frame image in the picture file.
- S1004 Generate a picture header information data segment including delay information, a total number of frames, and RGB data corresponding to each frame image in the picture file.
- the picture file processing device may obtain a user-defined information data segment, where the user-defined information data segment may include configuration parameters and encoder complexity, etc., and the configuration parameter may be performed on the YUV data. Encoded parameters. If the obtained configuration parameter is a lossless mode parameter, the RGB data may be directly encoded to generate code stream data. If the acquired configuration parameter is an SD mode parameter or a HD mode parameter, the RGB data needs to be converted into YUV data, and then The YUV data is encoded to generate codestream data. In some examples, the picture file processing device may determine whether the configuration parameter used in the user-defined information data segment is a lossless mode parameter, and if yes, proceed to step S1006. If no, the process proceeds to steps S1007-S1008.
- the encoder complexity may be a fineness parameter of the encoding determined according to hardware performance of the picture file processing device.
- the picture file processing device may encode the RGB data to generate code stream data.
- the encoding may include predictive coding, transform coding, quantization coding, and entropy coding.
- the picture file processing apparatus may compress the RGB data by using an IPPP mode, where the first frame of RGB data is an I frame, and the I frame is a frame.
- the intra prediction frame, the remaining frame RGB data is a P frame, and the P frame is an inter prediction frame, which can effectively compress the file data amount of the picture file, and can also use a fixed QP method to stabilize the quality between different frames.
- the entropy coding may include Huffman coding, arithmetic coding, and the like.
- the picture file processing device may convert the RGB data into a YUV by using a color space conversion formula. data.
- the picture file processing device may add the configuration parameter to a picture header information data segment. In some examples, the picture file processing device may add the user-defined information data segment to the picture. Header data segment.
- the steps S1001 to S1004 of the embodiment of the present application may refer to the detailed description of the steps S801 to S804 of the embodiment shown in FIG. 15 respectively, and details are not described herein.
- the picture header information data segment of the picture file is generated according to the original picture file, and each frame image in the picture file is converted into YUV data, and then the code stream data and the picture header information obtained by encoding according to the YUV data are obtained.
- the data segment generates compressed image data and stores the compressed image data.
- FIG. 18 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application. As shown in FIG. 18, the picture file processing method provided by the embodiment of the present application is further described with reference to the embodiment shown in FIG. 16, and the method includes the following steps S1101-step S1112.
- S1101 Parse the compressed image data to obtain the picture header information data segment and the code stream data.
- the picture header information data segment may further include a user-defined information data segment, where the user-defined information data segment may include a configuration parameter, an encoder complexity, and the like, and the configuration parameter may be a previous
- the parameters for encoding the YUV data, the configuration parameters may include any one of an SD mode parameter, a HD mode parameter, and a lossless mode parameter.
- the encoder complexity may be a fineness parameter of the encoding determined according to hardware performance of the transmitting end, and the encoder complexity may include any one of a first complexity, a second complexity, and a third complexity. The first complexity is higher than the second complexity, and the second complexity is higher than the third complexity.
- the above performance value, the first preset value range, the second pass preset value range, and the third preset value range may be specifically set according to the developer's human experience.
- S1102 Determine whether the configuration parameter in the data segment of the picture header information is a lossless mode parameter.
- the picture file processing device may determine whether the configuration parameter in the picture header information data segment is a lossless mode parameter, and if yes, proceed to step S1103. If no, the process proceeds to steps S1104-S1107.
- the picture file processing device can decode the code stream data generated by directly encoding the RGB data in the lossless mode.
- the code stream data directly generates RGB data.
- S1104 Determine whether the configuration parameter is a YUV444 mode parameter.
- the configuration parameter in the data segment of the picture header information is not a lossless mode parameter, that is, the configuration parameter in the data segment of the picture header information is an SD mode parameter or a HD mode parameter
- the The standard definition mode parameter is preferably a YUV420 mode parameter
- the high definition mode parameter is preferably a YUV444 mode parameter.
- the picture file processing device may further determine whether the configuration parameter is a YUV444 mode parameter, and if yes, proceed to step S1105. If no, the process proceeds to steps S1106-S1107.
- S1105 Decode the code stream data to generate the YUV data, and convert the YUV data into RGB data by using a color space conversion formula.
- the picture file processing device determines that the configuration parameter is a YUV444 mode parameter, that is, when encoding the YUV data, the luminance component and the chrominance component of each pixel in the YUV data are completely retained, so The picture file processing device decodes the code stream data to directly generate the YUV data.
- the chrominance includes a sample matrix and a single sample of any one of Cb and Cr color difference signals. The two color difference signals need to be separately upsampled, and the two methods of upsampling are the same. Among them, Cb corresponds to U in YUV, Cr corresponds to V in YUV, and YUV data consists of Y image, Cb image and Cr image. .
- the picture file processing device converts the YUV data into RGB data using a color space conversion formula.
- the picture file processing device determines that the configuration parameter is not a YUV444 mode parameter, that is, when encoding the YUV data, only the luminance component of each pixel in the YUV data is retained, but for each of the YUV data.
- the chrominance component of the pixel is compressed. For example, in the process of encoding the YUV data by using the YUV420 mode parameter, the chrominance components of the four pixels adjacent to each other in the YUV data can be compressed into one color. Degree component.
- the picture file processing apparatus needs to decode the code stream data to generate the YUV data, and perform chroma component upsampling processing on the YUV data, that is, restore one chroma component to a chroma component of four pixel points. Processing.
- the chromaticity includes a sample matrix and a single sample of any one of Cb and Cr color difference signals.
- the two color difference signals need to be separately upsampled, and the two methods of upsampling are the same.
- Cb corresponds to U in YUV
- Cr corresponds to V in YUV
- YUV data consists of Y image, Cb image and Cr image. .
- the following description will be made in conjunction with the Cb image in the YUV420 mode.
- the compressed Cb image that is, the source Cb image
- the Cb value of each upsampled non-boundary pixel is determined by the Cb value of four adjacent pixels of the corresponding position of the source Cb image.
- Dst(2x,2y) Clip3(0,255,(src(x-1,y-1)+3*src(x,y-1)+3*src(x-1,y)+9*src (x, y) + 8) >> 4).
- Dst(2x-1,2y) Clip3(0,255,(3*src(x-1,y-1)+src(x,y-1)+9*src(x-1,y)+3 *src(x,y)+8)>>4).
- Dst(2x,2y-1) Clip3(0,255,(3*src(x-1,y-1)+9*src(x,y-1)+src(x-1,y)+3 *src(x,y)+8)>>4).
- Dst(2x-1,2y-1) Clip3(0,255,(9*src(x-1,y-1)+3*src(x,y-1)+3*src(x-1, y) + src(x, y) + 8) >> 4).
- the Cb value of the corner point in the target Cb image is determined by the Cb value of the corner point in the source Cb image.
- the Cb value is determined by the Cb value of the two adjacent pixels in the first row and the last row in the source Cb image.
- Dst(2x, 2H-1) Clip3(0,255,(src(x-1,2H-1)+3*src(x,2H-1)+2)>>2).
- Dst(2x-1,2H-1) Clip3(0,255,(3*src(x-1,2H-1)+src(x,2H-1)>>2)>>2 ⁇ ;
- the Cb value is determined by the Cb value of two pixel points adjacent in the first column and the last column in the source Cb image.
- Dst(0,2y-1) Clip3(0,255,(src(0,y-1)+3*src(0,y)+2)>>2).
- Dst(0, 2y) Clip3 (0, 255, (3 * src (0, y) + src (0, y-1) + 2) >> 2).
- Dst(2W-1, 2y-1) Clip3(0,255,(src(2W-1,y-1)+3*src(2W-1,y)+2)>>2).
- Dst(2W-1, 2y) Clip3(0,255,(3*src(2W-1,y)+src(2W-1, y-1)+2)>>2).
- the Cb value of all the pixel points in the target Cb image can be obtained by the above calculation rule. It can be understood that the weight value in the above formula can be determined according to the empirical value. Similarly, the Cr value of all pixel points in the target Cr image can be obtained by using the above calculation rule. This completes the processing of the chroma component upsampling process.
- the picture file processing device may convert the YUV data into RGB data by using a color space conversion formula. In some examples, the picture file processing device needs to determine the color space used according to the range of values of the brightness component. Conversion formula.
- the global color table information is trained by using RGB values of each pixel in the RGB data to generate local color table information of the RGB data, and adopting The local color table information of the RGB data updates the RGB values of the respective pixels.
- the initial color table information is trained by using the RGB values of each pixel in the RGB data to generate local color table information of the RGB data, and the RGB data is used.
- the local color table information updates the RGB values of the respective pixels.
- the local color table information of the N-1 frame RGB data is trained to generate a partial part of the RGB data by using the RGB values of the pixels in the RGB data.
- the color table information is updated with the RGB values of the respective pixels using the local color table information of the RGB data.
- S1112 Perform image coding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
- the steps S1108 to S1112 of the embodiment of the present application may refer to the detailed description of the steps S903 to S907 of the embodiment shown in FIG. 16 respectively, and details are not described herein.
- FIG. 21A is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- the method can be performed by a computing device. As shown in FIG. 21A, the method may include the following steps.
- S1201A Acquire color data of the first picture file, where the color data includes color values of each pixel point.
- the color data may be RGB data, or YUV data, or the like.
- the computing device can obtain RGB data generated by decoding the first picture file, the RGB data including RGB values of the respective pixel points.
- S1202A Acquire an initial color table, wherein each color value in the initial color table is arranged according to a preset sorting manner of values of one color component.
- the computing device can obtain a global color table in the first picture file.
- the color values in the global color table are sorted according to the value of one color component to obtain the initial color table.
- the computing device can arrange the preset plurality of color values in a predetermined order by the values of one color component to generate the initial color table.
- the initial color table may be (0, 0, 0), (1, 1, 1), ... (255, 255, 255).
- S1203A Search, in the initial color table, a corresponding initial color value of each pixel in the initial color table according to the value of the color component in the color value of each pixel, and use the initial color value pair The color values of the respective pixel points are updated.
- the computing device can obtain a first color value of the color component that is closest to the color component of the pixel point in the initial color table, and obtain a first color index of the first color value.
- a second color value having the smallest error in color value of the pixel point is obtained as the initial color value in a preset range centered on the first color index in the initial color table.
- the computing device may modify the initial color table by using the color value of each pixel in the color data and the initial color value to obtain a partial color table corresponding to the color data, and adopt the The local color table updates the color values of the respective pixel points.
- the computing device can obtain a second color index of the initial color value. Substituting the initial color value with a color value of the pixel point, and using a preset weight value and a color value of the pixel point, a preset centered on the second color index in the training color table Multiple color values within the range are modified.
- the modified initial color table is determined as the partial color table.
- the computing device may use the color data to train an initial color table of the first frame image to obtain the first a partial color table corresponding to the frame image, the initial color table of the first frame image being the initial color table.
- the computing device may use the second color data to train the initial color table corresponding to the Nth frame image to obtain the A partial color table corresponding to the N frame image.
- the initial color table corresponding to the Nth frame image is a local color table corresponding to the N-1th frame image of the original picture file, and N is an integer greater than 1.
- the color data is RGB data
- the RGB data is an example for decoding the first image file.
- FIG. 21B a flow chart of another method for processing a picture file is provided in the embodiment of the present application. As shown in FIG. 21B, the embodiment of the present application specifically describes a process of training color table information and updating RGB values of pixel points, and the method may include the following steps S1201B-S1203B.
- S1201B Acquire RGB data generated by decoding the original image file, and obtain RGB values of each pixel in the RGB data.
- the picture file processing device may obtain the RGB data generated by decoding the original picture file, and it may be understood that decoding the picture file may generate a picture header information data segment of the picture file and the picture file.
- the RGB data corresponding to each frame of image.
- the RGB data may be converted into YUV data, and the YUV data is encoded to generate code stream data, and further generated compressed image data including code stream data and picture header information data segments, the compressed image data may be used for storage or transmission.
- the picture file processing device acquires the compressed image data, may parse the compressed image data to obtain the picture header information data segment and the code stream data, and decode the code stream data to generate a YUV. Data, further converting YUV data into RGB data, the picture file processing device acquiring the RGB data, and acquiring RGB values of respective pixels in the RGB data.
- the initial color table information of the RGB data is trained by using the RGB values of the respective pixels to generate local color table information of the RGB data.
- the picture file processing device may determine whether the picture header information data segment includes global color table information of the picture file, and if yes, determine the global color table information as the picture file.
- Initial color table information of the first frame of RGB data if not, generating initial color table information, and determining initial color table information of the first frame of RGB data in the picture file.
- the initial color table information is trained by using the RGB values of the pixels in the first frame of RGB data to generate local color table information of the first frame of RGB data, and for the Nth frame of RGB data, the N-1th frame of RGB data may be used.
- the local color table information is used as the initial color table information of the Nth frame RGB data, and the initial color table information of the Nth frame RGB data is trained by using the RGB values of the pixels in the Nth frame RGB data to generate the Nth Local color table information for frame RGB data, where N is a positive integer greater than one.
- S1203B updates the RGB values of each pixel point by using local color table information of RGB data.
- the picture file processing device may update the RGB values of the pixels by using local color table information of the RGB data, and the picture file processing device adopts the delay time and the total frame.
- the number of the updated RGB data is image encoded to generate the picture file.
- the local color table information of the RGB data is generated by training the global color table information or the initialization color table information, thereby effectively reducing the distortion of the image.
- FIG. 22 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application.
- the embodiment of the present application specifically describes a process of training color table information and updating RGB values of pixel points, and the method may include the following steps S1301 - step S1306.
- S1301 Acquire RGB data generated by decoding the original image file, and obtain RGB values of each pixel in the RGB data.
- the picture file processing device may acquire RGB data generated by decoding the original picture file.
- the RGB data may be converted into YUV data, and the YUV data is encoded to generate code stream data, and further generated compressed image data including code stream data and picture header information data segments, the compressed image data may be used for storage or transmission. Restore the image file to the image file processing device.
- S1302 Determine whether the global color table information of the picture file is included in the picture header information data segment generated by the decoded picture file.
- the picture file processing device determines whether the global color table information of the picture file is included in the picture header information data segment, and if yes, proceeds to step S1103. If no, go to step 1104.
- the initialization color table information is trained by using the RGB values of the pixels in the RGB data to generate local color table information of the RGB data.
- the local color table information of the N-1th frame RGB data is trained to generate a local part of the RGB data by using the RGB values of the pixels in the RGB data. Color table information.
- the picture file processing device may update the RGB values of each pixel in the RGB data by using local color table information of the RGB data, and the picture file processing device adopts the delay time and the The total number of frames encodes the updated RGB data to generate the picture file.
- the local color table information of the RGB data is generated by training the global color table information or the initialization color table information, thereby effectively reducing the distortion of the image.
- the G component By using the G component to obtain the closest source RGB value and performing a small range of color index search in the color table information, it is not necessary to traverse the entire color table information, thereby reducing the complexity of training the local color table information, and further improving the image file. The coding efficiency.
- the picture file processing device provided by the embodiment of the present application will be described in detail below with reference to FIG. 23 to FIG. It should be noted that the picture file processing device shown in FIG. 23 to FIG. 24 is used to execute the method of the embodiment shown in FIG. 8 and FIG. 9 of the present application, and is specifically the transmitting end in the foregoing embodiment, for convenience. It is to be noted that only the parts related to the embodiments of the present application are shown, and the specific technical details are not disclosed. Please refer to the embodiments shown in FIG. 8 and FIG. 9 of the present application.
- FIG. 23 is a schematic structural diagram of a picture file processing apparatus according to an embodiment of the present application.
- the picture file processing apparatus 1 of the embodiment of the present application may include an image converting unit 11, an image compressing unit 12, and a code stream transmitting unit 13.
- the image conversion unit 11 is configured to generate a picture header information data segment of the picture file according to the original picture file, and convert each frame image in the picture file into YUV data.
- the image conversion unit 11 may decode the original picture file to generate a picture header information data segment of the picture file.
- the image conversion unit 11 further converts each frame image in the picture file into YUV data.
- FIG. 24 is a schematic structural diagram of an image conversion unit according to an embodiment of the present application.
- the image conversion unit 11 may include:
- the image decoding sub-unit 111 is configured to decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
- the image decoding sub-unit 111 may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
- the image conversion sub-unit 112 is configured to convert the RGB data into YUV data by using a color space conversion formula.
- the image conversion sub-unit 112 may convert the RGB data into YUV data using a color space conversion formula.
- the image compression unit 12 is configured to encode the YUV data to generate code stream data.
- the image compression unit 12 may further perform encoding processing on the YUV data to generate code stream data, where the encoding may include predictive coding, transform coding, quantization coding, and entropy coding, for example, the image compression unit.
- the YUV data may be compressed by using the IPPP mode.
- the YUV data of the first frame is an I frame
- the I frame is an intra prediction frame
- the remaining frame YUV data is a P frame
- the P frame is an inter prediction frame, which can be effective.
- the amount of file data in the compressed image file can also be fixed in a QP manner to stabilize the quality between different frames.
- the entropy coding may include Huffman coding, arithmetic coding, and the like.
- a user may be added to add configuration parameters, which may be parameters that encode the YUV data.
- the image compression unit 12 may encode the YUV data using configuration parameters to generate codestream data.
- the user may also be allowed to add an encoder complexity, which may be a fine code determined according to the hardware performance of the picture file processing device 1.
- the encoder complexity may include any one of a first complexity, a second complexity, and a third complexity, the first complexity being higher than the second complexity, the second The complexity is higher than the third complexity, for example, the hardware performance of the picture file processing device 1 can be detected to generate a performance value, for example, the calculation rate of the central processing unit of the picture file processing device 1 is tested, etc.
- the performance value is within the first preset value range, it may be determined that the hardware performance of the picture file processing device 1 is high, and the coding mode of the first complexity may be recommended.
- the image compression unit 12 may configure the encoder complexity to encode the YUV data to generate codestream data.
- the code stream sending unit 13 is configured to send the compressed image data to the receiving end.
- the code stream sending unit 13 may generate compressed image data, and the picture file processing device 1 may store the compressed image data, when detecting a request of the receiving end for the picture file, The code stream transmitting unit 13 transmits the compressed image data to the receiving end again, for example, when the picture file processing apparatus 1 detects that the web page including the picture file is turned on.
- the code stream sending unit 13 may also directly send the compressed image data to the receiving end, for example, when a client in the instant messaging application needs to send the picture file to another client, the application service device The picture file needs to be forwarded or the like, and the compressed image data includes the picture header information data segment and the code stream data.
- the receiving end receives the compressed image data sent by the picture file processing device 1, and the receiving end may perform parsing processing on the compressed image data to obtain the picture header information data in the compressed image data. Segment and the code stream data.
- the picture file processing apparatus 1000 may include at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002.
- the communication bus 1002 is used to implement connection communication between these components.
- the user interface 1003 can include a display and a keyboard.
- the optional user interface 1003 can also include a standard wired interface and a wireless interface.
- Some examples of the network interface 1004 may include a standard wired interface, a wireless interface (such as a WI-FI interface).
- the memory 1005 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory.
- the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001 in some instances. As shown in FIG. 25, an operating system, a network communication module, a user interface module, and an image processing application may be included in the memory 1005 as a computer storage medium.
- the network interface 1004 is mainly used to connect to the receiving end and perform data communication with the receiving end.
- the user interface 1003 is mainly used to provide an input interface for the user, and obtain data input by the user.
- the processor 1001 can be used to call the image processing application stored in the memory 1005, and specifically perform the following steps:
- the YUV data is encoded to generate codestream data.
- the compressed image data comprising the picture header information data segment and the code stream data
- the receiving end parses the compressed image data to obtain the picture header information data segment
- generating, by the code stream data, the YUV data according to the code stream data so that the receiving end processes the YUV data based on the picture header information data segment to generate the picture file.
- the processor 1001 performs the following steps when performing a picture header information data segment for generating a picture file according to the original picture file and converting each frame image in the picture file into YUV data:
- the original picture file is decoded to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file, and the picture header information data segment includes delay information, total frame number, and global color table information.
- the RGB data is converted to YUV data using a color space conversion formula.
- the encoding includes predictive coding, transform coding, quantization coding, and entropy coding.
- the processor 1001 performs the following steps when performing the encoding of the YUV data to generate code stream data:
- the YUV data is encoded by using configuration parameters to generate code stream data
- the configuration parameter is a parameter for encoding the YUV data
- the configuration parameter includes any one of an SD mode parameter, a HD mode parameter, and a lossless mode parameter.
- the processor 1001 performs the following steps when performing the encoding of the YUV data to generate code stream data:
- the encoder complexity is configured to encode the YUV data to generate codestream data, the encoder complexity being a fineness parameter of the encoding determined according to hardware capabilities.
- the picture file is a GIF image.
- FIG. 26 to FIG. 27 is used to perform the method of the embodiment shown in FIG. 11 and FIG. 12 of the present application, and is specifically the receiving end in the above embodiment, for convenience. It is to be noted that only the parts related to the embodiments of the present application are shown, and the specific technical details are not disclosed. Please refer to the embodiment shown in FIG. 11 and FIG. 12 of the present application.
- FIG. 26 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application.
- the picture file processing apparatus 2 of the embodiment of the present application may include an information acquiring unit 21 and an image encoding unit 22.
- the information acquiring unit 21 is configured to receive compressed image data for the original picture file sent by the sending end, and parse the compressed image data to obtain a picture header information data segment and code stream data of the picture file.
- the transmitting end may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
- the transmitting end may convert the RGB data into YUV data by using a color space conversion formula.
- the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
- the transmitting end may generate compressed image data, and the sending end may store the compressed image data, and when detecting the request of the picture file processing device 2 for the picture file, the sending end performs the compression Image data is sent to the picture file processing device 2.
- the information acquiring unit 21 receives the compressed image data sent by the sending end, and the information acquiring unit 21 may perform parsing processing on the compressed image data to obtain the picture header information in the compressed image data. Data segment and the code stream data.
- the image encoding unit 22 is configured to generate the YUV data according to the code stream data, and process the YUV data based on the picture header information data segment to generate the picture file.
- the image encoding unit 22 decodes the code stream data to generate the YUV data, and compares the YUV data based on delay information, total frame number, global color table information, and the like in a picture header information data segment. An encoding process is performed to generate the picture file.
- FIG. 27 is a schematic structural diagram of an image coding unit according to an embodiment of the present application.
- the image encoding unit 22 may include:
- the image conversion sub-unit 221 is configured to decode the code stream data to generate the YUV data, and convert the YUV data into RGB data by using a color space conversion formula.
- the image conversion sub-unit 221 decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data using a color space conversion formula, in some examples, the image converter The unit 221 needs to determine the color space conversion formula adopted according to the range of values of the luminance component.
- the pixel point updating sub-unit 222 is configured to update the RGB values of each pixel point in the RGB data by using the global color table information.
- the pixel update subunit 222 may adopt the global color table information pair. The RGB values of the respective pixel points in the RGB data are updated.
- the pixel point update subunit 222 may adopt the RGB data.
- the RGB values of the pixels in the image are trained to generate the local color table information of the RGB data, and the RGB values of the pixels are performed by using the local color table information of the RGB data. Update.
- the pixel point update subunit 222 may At least one source RGB value in the color table information is sorted according to a preset ordering of the G components (eg, ascending, descending, etc.) to generate training color table information.
- the pixel point update sub-unit 222 acquires, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquires the first source RGB value.
- the first color index is a first color index that is closest to the G component of the current pixel point in the RGB data.
- the pixel point update sub-unit 222 acquires, in a preset range centered on the first color index in the training color table information, a second source RGB value that has the smallest error with the RGB value of the current pixel point. Obtaining a second color index of the second source RGB value, it may be understood that the pixel point update subunit 222 may be centered on the first color index and preset before and after the first color index. Acquiring a plurality of source RGB values in a range, and respectively calculating an error of the first source RGB value and the RGB values of the plurality of source RGB values and the current pixel point, and minimizing an error among the plurality of source RGB values The source RGB value is determined to be the second source RGB value.
- the pixel point update sub-unit 222 replaces the second source RGB value with the RGB value of the current pixel point, and uses the preset weight value and the RGB value of the current pixel point to the training color table information. A plurality of source RGB values within a preset range centered on the second color index are modified.
- the pixel point update The sub-unit 222 obtains the training color table information obtained after the modification, takes the next pixel point of the current pixel point as the current pixel point, and transfers to perform the acquisition of the G component and the RGB in the training color table information.
- the first source RGB value of the G component of the current pixel in the data is the closest, for example, the second pixel point in the RGB data is used as the current pixel point, and the training color table information obtained after the modification is performed again. training.
- the training process in some examples can be referred to the description of the above training process, and will not be described here.
- the pixel point updater obtains the training color table information obtained after the modification, and determines the training color table information as the local color table information of the RGB data.
- the pixel point update sub-unit 222 may update the RGB values of the pixel points by using local color table information of the RGB data.
- the pixel point update sub-unit 222 may be in the RGB data.
- the source RGB values in the local color table information are sequentially obtained with the same or the smallest error as the pixel points respectively replacing the RGB values of the respective pixel points, and in some examples, the pixel point update sub-unit 222 may The color index corresponding to the source RGB values of the same or the smallest error is replaced by the RGB values of the respective pixels.
- the pixel point update subunit 222 may adopt the RGB.
- the RGB values of the pixels in the data are trained to initialize the color table information to generate local color table information of the RGB data, and the RGB values of the pixels are updated by the local color table information of the RGB data. .
- the pixel point update subunit 222 may generate an initialization.
- Color table information for example: (0, 0, 0), (1, 1, 1), (2, 2, 2), ..., (255, 255, 255)
- the pixel point update subunit 222 is Acquiring, in the initialization color table information, a third source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value
- the picture file processing device 2 acquiring, in a preset range centered on the third color index in the initialization color table information, a fourth source RGB value having a smallest error from an RGB value of the current pixel point, and acquiring the fourth source a fourth color index of the RGB value
- the pixel point update sub-unit 222 replacing the fourth source RGB value with the RGB value of the current pixel point, and adopting a preset weight value and an RGB value
- the pixel point update subunit 222 acquires the initialization color obtained after the modification.
- the table information, the next pixel point of the current pixel point is taken as the current pixel point, and is transferred to perform the first step of acquiring the G component in the initialization color table information and the G component of the current pixel point in the RGB data.
- the pixel update sub-unit 222 acquires the modified color table information obtained after the modification, and initializes the color
- the table information is determined as local color table information of the RGB data, and the pixel point updating sub-unit 222 may update the RGB values of the respective pixel points by using local color table information of the RGB data. It should be noted that the process of training the initialization color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data can refer to the execution process of the foregoing manner, and details are not described herein.
- the pixel point update subunit 222 may train the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate the The local color table information of the RGB data, and the RGB values of the respective pixel points are updated by using the local color table information of the RGB data.
- the pixel point update subunit 222 may at least one source RGB of the partial color table information of the N-1th frame RGB data.
- the values are sorted according to a preset sorting manner of the G component to generate training color table information, and the pixel point updating sub-unit 222 acquires the G component and the G component of the current pixel point in the RGB data in the training color table information.
- the pixel point update subunit 222 being centered on the fifth color index in the training color table information And within a preset range, acquiring a sixth source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a sixth color index of the sixth source RGB value, where the pixel point update subunit 222 is to The sixth source RGB value is replaced by the RGB value of the current pixel point, and the preset weight value and the RGB value of the current pixel point are used, and the training color table information is centered on the sixth color index.
- the pixel update subunit 222 obtains the modified color table information obtained after the modification, and the current pixel point The next pixel is taken as the current pixel, and is transferred to a fifth source RGB value that performs the closest acquisition of the G component in the training color table information to the G component of the current pixel in the RGB data, when the current pixel
- the pixel point update subunit 222 acquires the modified color table information obtained by the modification, and determines the training color table information as a part of the RGB data.
- the color point information sub-unit 222 may update the RGB values of the respective pixel points by using local color table information of the RGB data. It should be noted that the process of training the training color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data may refer to the execution process of the foregoing manner, and details are not described herein.
- the image encoding sub-unit 223 is configured to image-encode the updated RGB data by using the delay time and the total number of frames to generate the picture file.
- the image encoding sub-unit 223 performs image encoding on the updated RGB data using the delay time and the total number of frames to generate the picture file.
- FIG. 28 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application.
- the picture file processing apparatus 2000 may include at least one processor 2001, such as a CPU, at least one network interface 2004, a user interface 2003, a memory 2005, and at least one communication bus 2002.
- the communication bus 2002 is used to implement connection communication between these components.
- the user interface 2003 may include a display and a keyboard.
- the optional user interface 2003 may further include a standard wired interface and a wireless interface.
- Some examples of the network interface 2004 may include a standard wired interface, a wireless interface (such as a WI-FI interface).
- the memory 2005 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory.
- the memory 2005 may also be at least one storage device located remotely from the aforementioned processor 2001.
- an operating system, a network communication module, a user interface module, and an image processing application may be included in the memory 2005 as a computer storage medium.
- the network interface 2004 is mainly used to connect to the transmitting end and perform data communication with the transmitting end.
- the user interface 2003 is mainly used to provide an input interface for the user, and obtain data input by the user.
- the processor 2001 can be used to call the image processing application stored in the memory 2005, and specifically perform the following steps:
- Receiving compressed image data for the original picture file sent by the sending end parsing the compressed image data to obtain a picture header information data segment and code stream data of the picture file, where the code stream data is converted for each frame image in the picture file.
- YUV data is encoded to generate information.
- the picture header information data segment includes delay information, a total number of frames, and global color table information.
- the processor 2001 performs the following steps when the YUV data is generated according to the code stream data, and the YUV data is processed based on the picture header information data segment to generate the picture file:
- the code stream data is decoded to generate the YUV data, and the YUV data is converted to RGB data using a color space conversion formula.
- the RGB values of the respective pixel points in the RGB data are updated using the global color table information.
- the updated RGB data is image encoded using the delay time and the total number of frames to generate the picture file.
- the processor 2001 when the processor 2001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
- the RGB data is the first frame image in the picture file
- the global color table information exists in the picture header information data segment
- the color table information is trained to generate local color table information of the RGB data, and the RGB values of the respective pixel points are updated using local color table information of the RGB data.
- the processor 2001 performs specific execution when training the global color table information by using RGB values of respective pixels in the RGB data to generate local color table information of the RGB data. The following steps:
- At least one source RGB value in the global color table information is sorted according to a preset sorting manner of the G component to generate training color table information.
- the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is rotated.
- the first source RGB value that obtains the G component closest to the G component of the current pixel point in the RGB data in the training color table information is executed.
- the processor 2001 when the processor 2001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
- the RGB value pair of each pixel point in the RGB data is used to initialize the color.
- the table information is trained to generate local color table information of the RGB data, and the RGB values of the respective pixel points are updated using local color table information of the RGB data.
- the processor 2001 performs the following steps when performing the training of the initialization color table information by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data. :
- a third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the initialization color table information, and a third color index of the third source RGB value is acquired.
- the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is rotated.
- the third source RGB value that obtains the G component closest to the G component of the current pixel point in the RGB data in the initialization color table information is executed.
- the processor 2001 when the processor 2001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
- the RGB data is the Nth frame image in the picture file
- training the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate the The local color table information of the RGB data, and the RGB values of the respective pixel points are updated by the local color table information of the RGB data, where N is a positive integer greater than 1 and less than or equal to the total number of frames.
- the processor 2001 performs training on local color table information of the N-1th frame RGB data using RGB values of respective pixels in the RGB data to generate a partial color of the RGB data. For the table information, perform the following steps:
- At least one source RGB value in the partial color table information of the N-1th frame RGB data is sorted according to a preset sorting manner of the G component to generate training color table information.
- the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is rotated.
- the fifth source RGB value that obtains the G component closest to the G component of the current pixel point in the RGB data in the training color table information is executed.
- the picture file is a GIF image.
- FIG. 29 is a schematic structural diagram of an image processing system according to an embodiment of the present application.
- the system may include a transmitting end 1 and a receiving end 2, and the transmitting end 1 and the receiving end 2 may be connected to each other through a network, wherein the transmitting end 1 is specifically a picture file processing of the embodiment shown in FIG.
- the device 1, the receiving end 2 is specifically the picture file processing device 2 of the embodiment shown in FIG.
- the transmitting end 1 is specifically the picture file processing device 1000 of the embodiment shown in FIG. 25
- the receiving end 2 is specifically the picture file processing device 2000 of the embodiment shown in FIG.
- the sending end 1 is configured to generate a picture header information data segment of the picture file according to the original picture file, convert each frame image in the picture file into YUV data, and encode the YUV data to generate code stream data, and
- the compressed image data is transmitted to the receiving end 2, and the compressed image data includes the picture header information data segment and the code stream data.
- the receiving end 2 is configured to receive the compressed image data sent by the sending end 1, and parse the compressed image data to obtain the picture header information data segment and the code stream data, according to the code stream data. Generating the YUV data and processing the YUV data based on the picture header information data segment to generate the picture file.
- the sending end 1 is configured to generate a picture header information data segment of the picture file according to the original picture file, and convert each frame image in the picture file into YUV data, specifically for:
- the original picture file is decoded to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file, and the picture header information data segment includes delay information, total frame number, and global color table information.
- the RGB data is converted to YUV data using a color space conversion formula.
- the encoding includes predictive coding, transform coding, quantization coding, and entropy coding.
- the sending end 1 when the sending end 1 is used to encode the YUV data to generate code stream data, it is specifically used to:
- the YUV data is encoded by using configuration parameters to generate code stream data
- the configuration parameter is a parameter for encoding the YUV data
- the configuration parameter includes any one of an SD mode parameter, a HD mode parameter, and a lossless mode parameter.
- the sending end 1 when the sending end 1 is used to encode the YUV data to generate code stream data, it is specifically used to:
- the encoder complexity is configured to encode the YUV data to generate codestream data, the encoder complexity being a fineness parameter of the encoding determined according to the hardware performance of the transmitting end 1.
- the receiving end 2 is configured to generate the YUV data according to the code stream data, and process the YUV data according to the picture header information data segment to generate the picture file, specifically Used for:
- the code stream data is decoded to generate the YUV data, and the YUV data is converted to RGB data using a color space conversion formula.
- the RGB values of the respective pixels in the RGB data are updated using the global color table information.
- the updated RGB data is image encoded using the delay time and the total number of frames to generate the picture file.
- the receiving end 2 when the receiving end 2 is used to update the RGB values of each pixel in the RGB data by using the global color table information, specifically, the receiving end 2 is used to:
- the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the RGB value of each pixel in the RGB data is used to the global color table.
- the information is trained to generate local color table information of the RGB data, and the RGB values of the respective pixels are updated using the local color table information of the RGB data.
- the receiving end 2 when the receiving end 2 is used to train the global color table information to generate local color table information of RGB data by using RGB values of respective pixels in the RGB data, specifically, the receiving end 2 is used to:
- At least one source RGB value in the global color table information is sorted according to a preset sorting manner of the G component to generate training color table information.
- a first source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the training color table information, and a first color index of the first source RGB value is acquired.
- a second source RGB value having the smallest error with the RGB value of the current pixel point is acquired, and a second color index of the second source RGB value is obtained.
- the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center.
- the first source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
- the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- the receiving end 2 when the receiving end 2 is used to update the RGB values of each pixel in the RGB data by using the global color table information, specifically, the receiving end 2 is used to:
- the RGB value of each pixel in the RGB data is used to train the initialization color table information.
- the RGB values of the respective pixels are updated by generating local color table information of the RGB data and using local color table information of the RGB data.
- the receiving end 2 is configured to: when the initial color table information is trained to generate the local color table information of the RGB data by using the RGB values of the pixels in the RGB data, specifically for:
- a third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the initialization color table information, and a third color index of the third source RGB value is acquired.
- a fourth source RGB value having the smallest error from the RGB value of the current pixel point is acquired, and a fourth color index of the fourth source RGB value is obtained.
- the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center.
- the third source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained in the initialization color table information.
- the training color table information obtained after the modification is acquired, and the initialization color table information is determined as the local color table information of the RGB data.
- the receiving end 2 when the receiving end 2 is used to update the RGB values of each pixel in the RGB data by using the global color table information, specifically, the receiving end 2 is used to:
- the local color table information of the N-1th frame RGB data is trained to generate a partial color table of the RGB data by using the RGB values of the pixels in the RGB data.
- Information, and the RGB values of the respective pixels are updated using the local color table information of the RGB data, and N is a positive integer greater than 1 and less than or equal to the total number of frames.
- the receiving end 2 is configured to use the RGB values of the pixels in the RGB data to train the local color table information of the N-1th frame RGB data to generate the local color table information of the RGB data. Specifically used for:
- At least one source RGB value in the partial color table information of the N-1th frame RGB data is sorted according to a preset sorting manner of the G component to generate training color table information.
- a fifth source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the training color table information, and a fifth color index of the fifth source RGB value is acquired.
- a sixth source RGB value having the smallest error with the RGB value of the current pixel point is acquired, and a sixth color index of the sixth source RGB value is obtained.
- the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center.
- the fifth source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
- the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- the picture file is a GIF image.
- FIG. 30 to FIG. 32 The picture file processing device provided by the embodiment of the present application will be described in detail below with reference to FIG. 30 to FIG. It should be noted that the picture file processing device shown in FIG. 30 to FIG. 32 is used to perform the method of the embodiment shown in FIG. 14 to FIG. 16 . For the convenience of description, only the embodiment of the present application is shown. For related parts, the specific technical details are not disclosed, please refer to the embodiment shown in FIG. 14 to FIG. 16 of the present application.
- FIG. 30 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application.
- the picture file processing apparatus 3 of the embodiment of the present application may include an image conversion unit 31, an image compression unit 32, a code stream generation unit 33, an information acquisition unit 34, and an image coding unit 35.
- the image conversion unit 31 is configured to generate a picture header information data segment of the picture file according to the original picture file, and convert each frame image in the picture file into YUV data.
- the image conversion unit 31 may decode the original picture file to generate a picture header information data segment of the picture file, and the image conversion unit 31 further converts each frame image in the picture file into YUV data.
- FIG. 31 is a schematic structural diagram of another image conversion unit according to an embodiment of the present application.
- the image conversion unit 31 may include:
- the image decoding sub-unit 311 is configured to decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
- the image decoding sub-unit 311 can decode the original picture file.
- the image decoding sub-unit 311 can determine whether the color table information in the picture file is global color table information of the picture file.
- the image decoding sub-unit 311 may generate picture header information data including delay information, total number of frames, global color table information, and the like. And the delay information is recorded with a play interval between each frame image in the picture file, where the total number of frames is the number of image frames in the picture file, and each frame in the picture file is also generated.
- the RGB data corresponding to the image is also generated.
- the image decoding sub-unit 311 may generate a picture header information data segment including delay information, a total number of frames, and the like, The delay information is recorded with a play interval between each frame of the image file, where the total number of frames is the number of image frames in the picture file, and the RGB corresponding to each frame image in the picture file is also generated. data.
- the image conversion sub-unit 312 is configured to convert the RGB data into YUV data by using a color space conversion formula.
- the image conversion sub-unit 312 can convert the RGB data into YUV data using a color space conversion formula.
- the image compression unit 32 is configured to encode the YUV data to generate code stream data.
- the image compression unit 32 may further perform encoding processing on the YUV data to generate code stream data, where the encoding may include predictive coding, transform coding, quantization coding, and entropy coding, for example, the image compression unit. 32.
- the YUV data may be compressed by using an IPPP mode.
- the YUV data of the first frame is an I frame
- the I frame is an intra prediction frame
- the remaining frame YUV data is a P frame
- the P frame is an inter prediction frame, which can be effective.
- the amount of file data in the compressed image file can also be fixed in a QP manner to stabilize the quality between different frames.
- the entropy coding may include Huffman coding, arithmetic coding, and the like.
- the code stream generating unit 33 is configured to store compressed image data.
- the code stream generating unit 33 may generate compressed image data, and the code stream generating unit 33 may store the compressed image data, the compressed image data including the picture header information data segment and the Code stream data.
- the information acquiring unit 34 is configured to parse the compressed image data to obtain the picture header information data segment and the code stream data.
- the information acquiring unit 34 may perform parsing processing on the compressed image data to acquire the picture header information data segment and the code stream data in the compressed image data.
- the image encoding unit 35 is configured to generate the YUV data according to the code stream data, and process the YUV data based on the picture header information data segment to generate the picture file.
- the image encoding unit 35 decodes the code stream data to generate the YUV data, and compares the YUV data based on delay information, total frame number, global color table information, and the like in a picture header information data segment. An encoding process is performed to generate the picture file.
- FIG. 32 is a schematic structural diagram of another image coding unit according to an embodiment of the present application.
- the image encoding unit 35 may include:
- the image conversion sub-unit 351 is configured to decode the code stream data to generate the YUV data, and convert the YUV data into RGB data by using a color space conversion formula.
- the image conversion sub-unit 351 decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data using a color space conversion formula, in some examples, the image converter Unit 351 needs to determine the color space conversion formula employed based on the range of values of the luminance component.
- the pixel update subunit 352 is configured to update the RGB values of each pixel in the RGB data by using the global color table information.
- the pixel point update sub-unit 352 determines whether the global color table information of the picture file is included in the picture header information data segment, because the YUV data is previously encoded, thereby causing the In the case where the RGB data of the YUV data conversion is distorted, the picture file processing device 3 may update the RGB values of the respective pixel points in the RGB data by using the global color table information.
- the pixel point update subunit 352 may adopt the RGB data.
- the RGB values of the pixels in the image are trained to generate the local color table information of the RGB data, and the RGB values of the pixels are performed by using the local color table information of the RGB data. Update.
- the pixel point update subunit 352 may use the global At least one source RGB value in the color table information is sorted according to a preset ordering of the G components (eg, ascending, descending, etc.) to generate training color table information.
- the pixel point update sub-unit 352 acquires, in the training color table information, a first source RGB value whose G component is closest to the G component of the current pixel point in the RGB data, and acquires the first source RGB value.
- the first color index is a first color index.
- the pixel point update sub-unit 352 acquires, in a preset range centered on the first color index in the training color table information, a second source RGB value that has the smallest error with the RGB value of the current pixel point. Obtaining a second color index of the second source RGB value, it may be understood that the pixel point update subunit 352 may be centered on the first color index and preset before and after the first color index. Acquiring a plurality of source RGB values in a range, and respectively calculating an error of the first source RGB value and the RGB values of the plurality of source RGB values and the current pixel point, and minimizing an error among the plurality of source RGB values The source RGB value is determined to be the second source RGB value.
- the pixel point update sub-unit 352 replaces the second source RGB value with the RGB value of the current pixel point, and uses the preset weight value and the RGB value of the current pixel point to the training color table information. A plurality of source RGB values within a preset range centered on the second color index are modified.
- the picture file processing The device 3 obtains the training color table information obtained after the modification, takes the next pixel point of the current pixel point as the current pixel point, and transfers to perform the acquisition of the G component and the RGB data in the training color table information.
- the first source RGB value of the G component of the current pixel is closest to the first source RGB value, for example, the second pixel point in the RGB data is used as the current pixel point, and the training color table information obtained after the modification is trained again.
- the training process in some examples can be referred to the description of the above training process, and will not be described here.
- the pixel point updater The unit 352 obtains the training color table information obtained after the modification, and determines the training color table information as the local color table information of the RGB data.
- the pixel point update sub-unit 352 may update the RGB values of the pixel points by using local color table information of the RGB data.
- the pixel point update sub-unit 352 may be in the RGB data.
- the local color table information sequentially acquires the source RGB values that are the same as the respective pixel points or have the smallest error, and replace the RGB values of the respective pixel points.
- the pixel point update sub-unit 352 can replace the RGB values of the respective pixel points with color indices corresponding to the source RGB values that are the same or the smallest error of the respective pixel points.
- the pixel point update subunit 352 may adopt the RGB.
- the RGB values of the pixels in the data are trained to initialize the color table information to generate local color table information of the RGB data, and the RGB values of the pixels are updated by the local color table information of the RGB data. .
- the pixel point update sub-unit 352 may generate an initialization.
- Color table information for example: (0, 0, 0), (1, 1, 1), (2, 2, 2), ..., (255, 255, 255), the picture file processing device 3 is initializing Obtaining, in the color table information, a third source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value, the pixel point update subunit 352: in a preset range centered on the third color index in the initialization color table information, acquire a fourth source RGB value that has the smallest error with the RGB value of the current pixel point, and acquire the fourth source a fourth color index of the RGB value, the pixel point update sub-unit 352 replacing the fourth source RGB value with the RGB value of the current pixel point, and adopting a preset weight value and an RGB value of
- the pixel update sub-unit 352 acquires the modified color table information obtained after the modification, and initializes the color
- the table information is determined as local color table information of the RGB data, and the pixel point update sub-unit 352 may update the RGB values of the respective pixel points by using local color table information of the RGB data. It should be noted that the process of training the initialization color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data can refer to the execution process of the foregoing manner, and details are not described herein.
- the pixel point update subunit 352 may at least one source RGB of the partial color table information of the N-1th frame RGB data.
- the values are sorted according to a preset sorting manner of the G component to generate training color table information, and the pixel point updating sub-unit 352 acquires the G component and the G component of the current pixel point in the RGB data in the training color table information.
- the pixel point update subunit 352 being centered on the fifth color index in the training color table information
- the pixel update sub-unit 352 obtains the modified color table information obtained after the modification, and the current pixel point The next pixel is taken as the current pixel, and is transferred to a fifth source RGB value that performs the closest acquisition of the G component in the training color table information to the G component of the current pixel in the RGB data, when the current pixel
- the pixel point update sub-unit 352 obtains the modified color table information obtained by the modification, and determines the training color table information as a part of the RGB data.
- the color point information sub-unit 352 may update the RGB values of the respective pixel points by using local color table information of the RGB data. It should be noted that the process of training the training color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data can be referred to the execution process of the foregoing method, and details are not described herein.
- the image encoding sub-unit 353 is configured to image-encode the updated RGB data by using the delay time and the total number of frames to generate the picture file.
- the image encoding sub-unit 353 performs image encoding on the updated RGB data using the delay time and the total number of frames to generate the picture file, and in some examples, the image encoding The sub-unit 353 may perform image coding on the color index of each pixel in the RGB data by using LZW to generate the picture file, and the picture file processing device 3 may be configured according to the delay time and the total number of frames.
- the image file is stored or displayed.
- FIG. 33 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application.
- the picture file processing apparatus 3000 may include at least one processor 3001, such as a CPU, at least one network interface 3004, a user interface 3003, a memory 3005, and at least one communication bus 3002.
- the communication bus 3002 is used to implement connection communication between these components.
- the user interface 3003 can include a display and a keyboard.
- the optional user interface 3003 can also include a standard wired interface and a wireless interface.
- Some examples of the network interface 3004 may include a standard wired interface, a wireless interface (such as a WI-FI interface).
- the memory 3005 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory.
- the memory 3005 may also be at least one storage device located remotely from the aforementioned processor 3001. As shown in FIG. 33, an operating system, a network communication module, a user interface module, and an image processing application may be included in the memory 3005 as a computer storage medium.
- the network interface 3004 is mainly used for function module connection in a distributed service device, and performs data communication with the function module.
- the user interface 3003 is mainly used to provide an input interface for the user, and obtain data input by the user.
- the processor 3001 can be used to call the image processing application stored in the memory 3005, and specifically perform the following steps:
- the YUV data is encoded to generate codestream data.
- the compressed image data is stored, the compressed image data including the picture header information data segment and the code stream data.
- the code stream data is decoded to generate the YUV data, and the YUV data is encoded based on the picture header information data segment to generate the picture file.
- the processor 3001 performs the following steps when performing the generation of the picture header information data segment of the picture file according to the original picture file and converting each frame image in the picture file into YUV data:
- the original picture file is decoded to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file, and the picture header information data segment includes delay information, total frame number, and global color table information.
- the RGB data is converted to YUV data using a color space conversion formula.
- the encoding includes predictive coding, transform coding, quantization coding, and entropy coding.
- the processor 3001 performs the following steps when performing the encoding of the YUV data to generate code stream data:
- the YUV data is encoded by using configuration parameters to generate code stream data
- the configuration parameter is a parameter for encoding the YUV data
- the configuration parameter includes any one of an SD mode parameter, a HD mode parameter, and a lossless mode parameter.
- the processor 3001 performs the following steps when performing the encoding of the YUV data to generate code stream data:
- the encoder complexity is configured to encode the YUV data to generate codestream data, the encoder complexity being a fineness parameter of the encoding determined according to hardware performance of the transmitting end.
- the processor 3001 performs decoding of the code stream data to generate the YUV data, and performs encoding processing on the YUV data based on the picture header information data segment to generate the picture file. , specifically perform the following steps:
- the code stream data is decoded to generate the YUV data, and the YUV data is converted to RGB data using a color space conversion formula.
- the RGB values of the respective pixel points in the RGB data are updated using the global color table information.
- the updated RGB data is image encoded using the delay time and the total number of frames to generate the picture file.
- the processor 3001 when the processor 3001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
- the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the RGB value of each pixel in the RGB data is used to the global color table.
- the information is trained to generate local color table information of the RGB data, and the RGB values of the respective pixels are updated using the local color table information of the RGB data.
- the processor 3001 performs the following steps when performing the training of the global color table information by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data:
- At least one source RGB value in the global color table information is sorted according to a preset sorting manner of the G component to generate training color table information.
- the receiving end acquires a second source RGB value with a minimum error of the RGB value of the current pixel point in the preset range centered on the first color index in the training color table information, and acquires a second source RGB value second. Color index.
- the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center.
- the first source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
- the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- the processor 3001 when the processor 3001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
- the RGB value of each pixel in the RGB data is used to train the initialization color table information.
- the RGB values of the respective pixels are updated by generating local color table information of the RGB data and using local color table information of the RGB data.
- the processor 3001 when the processor 3001 performs the training of initializing the color table information by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data, the following steps are specifically performed:
- a third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the initialization color table information, and a third color index of the third source RGB value is acquired.
- a fourth source RGB value having the smallest error from the RGB value of the current pixel point is acquired, and a fourth color index of the fourth source RGB value is obtained.
- the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center.
- the third source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained in the initialization color table information.
- the training color table information obtained after the modification is acquired, and the initialization color table information is determined as the local color table information of the RGB data.
- the processor 3001 when the processor 3001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
- the local color table information of the N-1th frame RGB data is trained to generate a partial color table of the RGB data by using the RGB values of the pixels in the RGB data.
- Information, and the RGB values of the respective pixels are updated using the local color table information of the RGB data, and N is a positive integer greater than 1 and less than or equal to the total number of frames.
- the processor 3001 performs training on the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data. Specifically perform the following steps:
- At least one source RGB value in the partial color table information of the N-1th frame RGB data is sorted according to a preset sorting manner of the G component to generate training color table information.
- a fifth source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the training color table information, and a fifth color index of the fifth source RGB value is acquired.
- a sixth source RGB value having the smallest error with the RGB value of the current pixel point is acquired, and a sixth color index of the sixth source RGB value is obtained.
- the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center.
- the fifth source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
- the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- the compressed image data includes the picture header information data segment and the code stream data.
- FIG. 34 to FIG. 35 is used to perform the method of the embodiment shown in FIG. 17 to FIG. 20 of the present application.
- FIGS. 17-20 of the present application please refer to the embodiment shown in FIGS. 17-20 of the present application.
- FIG. 34 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application.
- the picture file processing apparatus 4 of the embodiment of the present application may include a pixel value acquisition unit 41, a color table generation unit 42, and a pixel value update unit 43.
- the pixel value obtaining unit 41 is configured to acquire RGB data generated by processing the original image file, and acquire RGB values of each pixel in the RGB data.
- the pixel value acquisition unit 41 may acquire RGB data generated by decoding the original picture file.
- the RGB data may be converted into YUV data, and the YUV data is encoded to generate code stream data, and further generated compressed image data including code stream data and picture header information data segments, the compressed image data may be used for storage or transmission.
- the pixel value acquisition unit 41 acquires the compressed image data, and the compressed image data may be parsed to obtain the picture header information data segment and the Code stream data, and decoding the code stream data to generate YUV data, further converting YUV data into RGB data, the pixel value obtaining unit 41 acquiring the RGB data, and acquiring RGB of each pixel point in the RGB data value.
- the color table generating unit 42 is configured to train the initial color table information of the RGB data by using the RGB values of the respective pixels to generate local color table information of the RGB data.
- the color table generating unit 42 determines whether the global color table information of the picture file is included in the picture header information data segment, and the YUV is previously encoded by the YUV data, thereby causing the YUV to be
- the RGB data of the data conversion may be distorted.
- the color table generating unit 42 may update the RGB values of each pixel in the RGB data by using the global color table information. It can be understood that the RGB data is One or more pixels may be included. When there is only one pixel in the RGB data, the initial color table information may be trained by using the RGB values of the pixel, when there are many RGB data.
- the initial color table information may be trained by using RGB values of each of the plurality of pixels, and the color table generating unit 42 needs to retrain the global color table information to generate a match.
- the local color table information of the RGB data and for the case where there is no global color table information, the color table generating unit 42 may generate an initialization color Table information, and by training of the color table initialization information to generate comply with local color table information of the RGB data.
- the color table generating unit 42 may adopt the RGB data.
- the RGB values of the respective pixels train the global color table information to generate local color table information of the RGB data.
- the color table generating unit 42 may use the global color At least one source RGB value in the table information is sorted according to a preset ordering of the G components (eg, ascending, descending, etc.) to generate training color table information.
- the color table generating unit 42 acquires, in the training color table information, a first source RGB value whose G component is closest to the G component of the current pixel point in the RGB data, and acquires the first source RGB value. A color index.
- the color table generating unit 42 acquires, in a preset range centered on the first color index in the training color table information, a second source RGB value that has the smallest error with the RGB value of the current pixel point, and Obtaining a second color index of the second source RGB value, it may be understood that the color table generating unit 42 may be centered on the first color index, within a preset range before and after the first color index Obtaining a plurality of source RGB values, and separately calculating the first source RGB value and the error of the plurality of source RGB values and the RGB value of the current pixel point, and the source RGB having the smallest error among the plurality of source RGB values The value is determined to be the second source RGB value.
- the color table generating unit 42 replaces the second source RGB value with the RGB value of the current pixel point, and uses the preset weight value and the RGB value of the current pixel point in the training color table information. A plurality of source RGB values within a preset range centered on the second color index are modified.
- the color table generation The unit 42 obtains the training color table information obtained after the modification, takes the next pixel point of the current pixel point as the current pixel point, and transfers to perform the acquisition of the G component and the RGB data in the training color table information.
- the first source RGB value of the G component of the current pixel is closest to the first source RGB value, for example, the second pixel point in the RGB data is used as the current pixel point, and the training color table information obtained after the modification is trained again. .
- the training process in some examples can be referred to the description of the above training process, and will not be described here.
- the color table generating unit 42 obtaining the training color table information obtained after the modification, and determining the training color table information as local color table information of the RGB data.
- the color table generating unit 42 may adopt the RGB data.
- the RGB values of the respective pixels in the pair are trained to initialize the color table information to generate local color table information of the RGB data.
- the color table generating unit 42 may generate an initialization color.
- Table information for example: (0, 0, 0), (1, 1, 1), (2, 2, 2), ..., (255, 255, 255), the color table generating unit 42 initializes colors Obtaining, in the table information, a third source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value, where the color table generating unit 42 is And acquiring, in a preset range centered on the third color index, the fourth source RGB value having the smallest error with the RGB value of the current pixel point, and acquiring the fourth source RGB value.
- the color table generating unit 42 replacing the fourth source RGB value with the RGB value of the current pixel point, and adopting a preset weight value and an RGB value of the current pixel point, a preset range centered on the fourth color index in the initialization color table information
- the plurality of source RGB values are modified, and when the current pixel point is not the last pixel point in the RGB data, the color table generating unit 42 acquires the initialized color table information obtained after the modification, and The next pixel point of the current pixel point is used as the current pixel point, and is transferred to a third source RGB value that performs the closest acquisition of the G component in the initialization color table information to the G component of the current pixel point in the RGB data.
- the color table generating unit 42 acquires the training color table information obtained after the modification, and determines the initialization color table information as The local color table information of the RGB data. It should be noted that the process of training the initialization color table information in each instance may refer to the execution process of the foregoing manner, and details are not described herein.
- the color table generating unit 42 may train the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate the RGB Local color table information for the data.
- the color table generating unit 42 may set at least one source RGB value in the local color table information of the N-1th frame RGB data. Sorting according to a preset sorting manner of the G component to generate training color table information, wherein the color table generating unit 42 acquires the G component in the training color table information and is closest to the G component of the current pixel point in the RGB data.
- the color table generating unit 42 has a preset range centered on the fifth color index in the training color table information a sixth source RGB value having the smallest error in the RGB value of the current pixel point, and acquiring a sixth color index of the sixth source RGB value, the color table generating unit 42 to the sixth source RGB
- the value is replaced by the RGB value of the current pixel point, and the preset weight value and the RGB value of the current pixel point are used, and the training color table information is within a preset range centered on the sixth color index.
- the color table generating unit 42 acquires the training color table information obtained after the modification, and uses the next pixel point of the current pixel point as a current pixel point, and proceeds to perform a fifth source RGB value that is obtained in the training color table information to obtain a G component closest to a G component of a current pixel point in the RGB data, when the current pixel point is the RGB
- the color table generating unit 42 acquires the training color table information obtained after the modification, and determines the training color table information as the local color table information of the RGB data. It should be noted that the training of the training color table information in each instance can be referred to the execution process of the foregoing manner, and details are not described herein.
- the pixel value updating unit 43 is configured to update the RGB values of the respective pixel points by using the local color table information of the RGB data.
- the pixel value updating unit 43 may update the RGB values of each pixel in the RGB data by using local color table information of the RGB data, and the picture file processing device 4 adopts the delay time.
- the updated RGB data is image-encoded with the total number of frames to generate the picture file.
- the local color table information of the RGB data is generated by training the global color table information or the initialization color table information, thereby effectively reducing the distortion of the image.
- the G component By using the G component to obtain the closest source RGB value and performing a small range of color index search in the color table information, it is not necessary to traverse the entire color table information, thereby reducing the complexity of training the local color table information, and further improving the image file. The coding efficiency.
- FIG. 35 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application.
- the picture file processing apparatus 4000 may include at least one processor 4001, such as a CPU, at least one network interface 4004, a user interface 4003, a memory 4005, and at least one communication bus 4002.
- the communication bus 4002 is used to implement connection communication between these components.
- the user interface 4003 can include a display and a keyboard.
- the optional user interface 4003 can also include a standard wired interface and a wireless interface.
- Some examples of the network interface 4004 may include a standard wired interface, a wireless interface (such as a WI-FI interface).
- the memory 4005 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory.
- the memory 4005 may also be at least one storage device located remotely from the aforementioned processor 4001 in some examples.
- an operating system, a network communication module, a user interface module, and an image processing application may be included in the memory 4005 as a computer storage medium.
- the network interface 4004 is mainly used to connect to the transmitting end and perform data communication with the transmitting end.
- the user interface 4003 is mainly used to provide an input interface for the user, and obtain data input by the user.
- the processor 4001 can be used to call the image processing application stored in the memory 4005, and specifically perform the following steps:
- RGB data generated by processing the original image file, and obtain RGB values of each pixel in the RGB data.
- the initial color table information of the RGB data is trained using the RGB values of the respective pixels to generate local color table information of the RGB data.
- the RGB values of the respective pixels are updated using the local color table information of the RGB data.
- the processor 4001 when the processor 4001 performs the training of the initial color table information of the RGB data by using the RGB values of the respective pixels to generate the local color table information of the RGB data, the following steps are specifically performed:
- the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment generated by decoding the picture file, the RGB value of each pixel in the RGB data is used.
- the global color table information is trained to generate local color table information for the RGB data.
- the processor 4001 when the processor 4001 performs the training of the global color table information by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data, the following steps are specifically performed:
- At least one source RGB value in the global color table information is sorted according to a preset sorting manner of the G component to generate training color table information.
- a first source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the training color table information, and a first color index of the first source RGB value is acquired.
- a second source RGB value having the smallest error with the RGB value of the current pixel point is acquired, and a second color index of the second source RGB value is obtained.
- the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center.
- the first source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
- the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- the processor 4001 when the processor 4001 performs the training of the initial color table information of the RGB data by using the RGB values of the respective pixels to generate the local color table information of the RGB data, the following steps are specifically performed:
- the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment generated by decoding the picture file, the RGB value pair of each pixel in the RGB data is initialized.
- the color table information is trained to generate local color table information of the RGB data.
- the processor 4001 when the processor 4001 performs the training of initializing the color table information by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data, the following steps are specifically performed:
- a third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the initialization color table information, and a third color index of the third source RGB value is acquired.
- a fourth source RGB value having the smallest error from the RGB value of the current pixel point is acquired, and a fourth color index of the fourth source RGB value is obtained.
- the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center.
- the third source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained in the initialization color table information.
- the training color table information obtained after the modification is acquired, and the initialization color table information is determined as the local color table information of the RGB data.
- the processor 4001 when the processor 4001 performs the training of the initial color table information of the RGB data by using the RGB values of the respective pixels to generate the local color table information of the RGB data, the following steps are specifically performed:
- the local color table information of the N-1th frame RGB data is trained to generate a partial color table of the RGB data by using the RGB values of the pixels in the RGB data.
- N is a positive integer greater than 1 and less than or equal to the total number of frames.
- the processor 4001 performs training on the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data. Specifically perform the following steps:
- At least one source RGB value in the partial color table information of the N-1th frame RGB data is sorted according to a preset sorting manner of the G component to generate training color table information.
- a fifth source RGB value whose G component is closest to the G component of the current pixel point in the RGB data and a fifth color index of the fifth source RGB value are acquired in the training color table information.
- a sixth source RGB value having the smallest error with the RGB value of the current pixel point is acquired, and a sixth color index of the sixth source RGB value is obtained.
- the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center.
- the fifth source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
- the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- the picture file is a GIF image.
- the local color table information of the RGB data is generated by training the global color table information or the initialization color table information, thereby effectively reducing the distortion of the image.
- the G component By using the G component to obtain the closest source RGB value and performing a small range of color index search in the color table information, it is not necessary to traverse the entire color table information, thereby reducing the complexity of training the local color table information, and further improving the image file. The coding efficiency.
- the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Image Processing (AREA)
- Color Image Communication Systems (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
- Compression Of Band Width Or Redundancy In Fax (AREA)
Abstract
Disclosed in the embodiments of the present application are an image file processing method and device, the method comprising the following steps: receiving a transcoded code stream of an original image file sent by a sending terminal, and parsing the transcoded code stream to acquire an image header information data segment and code stream data of the image file, the code stream data being information generated by the sending terminal encoding YUV data, the YUV data being data generated by the sending terminal performing conversion of each image frame in the image file; on the basis of the code stream data, generating the YUV data and, on the basis of the image header information data segment, processing the YUV data to generate the image file. Using the present application and reduce the amount of file data of the image file in the transmission process, reducing bandwidth costs.
Description
本申请要求于2017年04月08日提交中国专利局、申请号为201710225916.0、名称为“一种图片文件处理方法及其设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. JP-A No. No. No. No. No. No. No. No. No. No. No. No. No. No. No. No. No. in.
本申请涉及计算机技术领域,尤其涉及一种图片文件处理方法、装置及存储介质。The present application relates to the field of computer technologies, and in particular, to a picture file processing method, apparatus, and storage medium.
背景background
图片文件是由连续多帧图像组成的动画图像,随着计算机技术的不断发展,图片文件由于其具备动态展示的效果,得到了广泛的运用,例如:即时通信、网页展示等,然而由于图片文件的内容较为复杂,导致图片文件的文件数据量较大,需要耗费较大的带宽进行传输,增加了带宽成本。Image files are animated images composed of continuous multi-frame images. With the continuous development of computer technology, image files have been widely used due to their dynamic display effects, such as instant messaging, web page display, etc. The content of the file is relatively complicated, resulting in a large amount of file data of the image file, requiring a large bandwidth for transmission, and increasing the bandwidth cost.
技术内容Technical content
本申请实施例提供一种图片文件处理方法及其设备,可以缩小图片文件在传输过程中的文件数据量,降低带宽成本。The embodiment of the present invention provides a method for processing a picture file and a device thereof, which can reduce the amount of file data in the transmission process of the picture file and reduce the bandwidth cost.
本申请实施例提供了一种图片文件处理方法,应用于计算设备,可包括:An embodiment of the present application provides a method for processing a picture file, which is applied to a computing device, and may include:
接收发送设备发送的针对原始图片文件的转码码流,解析所述转码码流以获取图片头信息数据段和码流数据,所述图片头信息数据段包括所述原始图片文件的颜色表,所述码流数据为所述发送设备对所述原始图片文件中各像素的第一色彩数据进行编码生成的信息;Receiving, by the sending device, a transcoded code stream for the original picture file, parsing the transcoded code stream to obtain a picture header information data segment and code stream data, where the picture header information data segment includes a color table of the original picture file The code stream data is information generated by the sending device to encode first color data of each pixel in the original picture file;
解码所述码流数据以生成第二色彩数据,并基于所述颜色表对所述第二色彩数据进行处理以生成第二图片文件。The code stream data is decoded to generate second color data, and the second color data is processed based on the color table to generate a second picture file.
本申请实施例还提供了一种图片文件处理方法,应用于计算设备,可包括:The embodiment of the present application further provides a method for processing a picture file, which is applied to a computing device, and may include:
获取第一图片文件的色彩数据,所述色彩数据包括各像素点的色彩值;Obtaining color data of the first picture file, where the color data includes color values of each pixel point;
获取初始颜色表,所述初始颜色表中各色彩值按照一个色彩分量的值的预设排序方式排列;Obtaining an initial color table, wherein each color value in the initial color table is arranged according to a preset sorting manner of values of one color component;
根据所述各像素点的色彩值中所述色彩分量的值在所述初始颜色表中搜索各像素点在所述初始颜色表中对应的初始色彩值,利用所述初始色彩值对所述各像素点的所述色彩值进行更新;Searching, in the initial color table, a corresponding initial color value of each pixel in the initial color table according to the value of the color component in the color value of each pixel point, using the initial color value pair The color value of the pixel is updated;
将更新后的所述色彩数据进行图像编码以生成所述第二图片文件。The updated color data is image encoded to generate the second picture file.
本申请实施例还提供了一种图片文件处理方法,应用于计算设备,可包括:The embodiment of the present application further provides a method for processing a picture file, which is applied to a computing device, and may include:
接收发送端发送的针对原始图片文件的转码码流,解析所述转码码流以获取图片文件的图片头信息数据段和码流数据,所述码流数据为所述发送端对YUV(Y为亮度分量,UV为色度分量,YUV为一种视频数据格式)数据进行编码生成的信息,所述YUV数据为所述发送端对图片文件中每帧图像进行转换生成的数据;Receiving a transcoded code stream sent by the sending end for the original picture file, parsing the transcoded code stream to obtain a picture header information data segment and code stream data of the picture file, where the code stream data is the transmitting end to the YUV ( Y is a luminance component, UV is a chrominance component, YUV is a video data format) data is encoded and generated, and the YUV data is data generated by the transmitting end to convert each frame image in the image file;
根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。Generating the YUV data according to the code stream data, and processing the YUV data based on the picture header information data segment to generate the picture file.
本申请实施例还提供了一种图片文件处理方法,可包括:The embodiment of the present application further provides a method for processing a picture file, which may include:
根据原始图片文件生成图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据;Generating a picture header information data segment of the picture file according to the original picture file, and converting each frame image in the picture file into YUV data;
对所述YUV数据进行编码以生成码流数据;Encoding the YUV data to generate code stream data;
存储转码码流,所述转码码流包含所述图片头信息数据段和所述码流数据;Storing a transcoded code stream, where the transcoded code stream includes the picture header information data segment and the code stream data;
解析所述转码码流以获取所述图片头信息数据段和所述码流数据;Parsing the transcoded code stream to obtain the picture header information data segment and the code stream data;
根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。Generating the YUV data according to the code stream data, and processing the YUV data based on the picture header information data segment to generate the picture file.
本申请实施例还提供了一种图片文件处理方法,应用于计算设备,可包括:The embodiment of the present application further provides a method for processing a picture file, which is applied to a computing device, and may include:
获取对原始图片文件解码生成的三原色(Red Green Blue,RGB)数据,获取RGB数据中的各像素点的RGB值;Obtaining three primary color (Red Green Blue, RGB) data generated by decoding the original image file, and acquiring RGB values of each pixel in the RGB data;
采用各像素点的RGB值对RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息;The initial color table information of the RGB data is trained by using the RGB values of the respective pixels to generate local color table information of the RGB data;
采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。The RGB values of the respective pixels are updated using the local color table information of the RGB data.
本申请实施例还提供了一种图片文件处理装置,可包括处理器和存储器,所述存储器中存储有计算机可读指令,可以使所述处理器:The embodiment of the present application further provides a picture file processing apparatus, which may include a processor and a memory, where the memory stores computer readable instructions, and the processor may be:
获取针对原始图片文件的转码码流,解析所述转码码流以获取图片头信息数据段和码流数据,所述图片头信息数据段包括所述原始图片文件的颜色表,所述码流数据为所述发送设备对所述原始图片文件中各像素的第一色彩数据进行编码生成的信息;Obtaining a transcoded code stream for the original picture file, parsing the transcoded code stream to obtain a picture header information data segment and code stream data, where the picture header information data segment includes a color table of the original picture file, the code The stream data is information generated by the sending device to encode the first color data of each pixel in the original picture file;
解码所述码流数据生成第二色彩数据,并基于所述颜色表对所述第二色彩数据进行处理以生成第二图片文件。Decoding the code stream data to generate second color data, and processing the second color data based on the color table to generate a second picture file.
本申请实施例还提供了一种图片文件处理装置,可包括:处理器和存储器,所述存储器中存储有计算机可读指令,可以使所述处理器:The embodiment of the present application further provides a picture file processing apparatus, which may include: a processor and a memory, where the memory stores computer readable instructions, and the processor may be:
获取第一图片文件的色彩数据,所述色彩数据包括各像素点的色彩值;Obtaining color data of the first picture file, where the color data includes color values of each pixel point;
获取初始颜色表,所述初始颜色表中各色彩值按照一个色彩分量的 值的预设排序方式排列;Obtaining an initial color table, wherein each color value in the initial color table is arranged according to a preset sorting manner of values of one color component;
根据所述各像素点的色彩值中所述色彩分量的值在所述初始颜色表中搜索各像素点在所述初始颜色表中对应的初始色彩值,利用所述初始色彩值对所述各像素点的所述色彩值进行更新;Searching, in the initial color table, a corresponding initial color value of each pixel in the initial color table according to the value of the color component in the color value of each pixel point, using the initial color value pair The color value of the pixel is updated;
将更新后的所述色彩数据进行图像编码以生成所述第二图片文件。The updated color data is image encoded to generate the second picture file.
本申请实施例还提供了一种计算机可读存储介质,存储有计算机可读指令,可以使处理器执行各实施例的方法。The embodiment of the present application further provides a computer readable storage medium storing computer readable instructions, which may cause a processor to execute the methods of the embodiments.
在本申请实施例中,在接收到转码码流时,可以根据码流数据生成第二色彩数据,再基于颜色表对所述第二色彩数据进行处理生成第二图片文件。通过在所述码流中附有颜色表,可以缩短生成及显示所述第二图片文件的时间,并且降低生成所述第二图片文件的复杂度。通过使用按照一色彩分量进行排序的颜色表对图片文件的色彩数据进行处理,可以缩短颜色表的搜索时间,提高处理效率。In the embodiment of the present application, when the transcoded stream is received, the second color data may be generated according to the code stream data, and the second color data is processed according to the color table to generate a second image file. By attaching a color table to the code stream, the time for generating and displaying the second picture file can be shortened, and the complexity of generating the second picture file can be reduced. By processing the color data of the image file by using a color table sorted according to a color component, the search time of the color table can be shortened, and the processing efficiency can be improved.
附图简要说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings to be used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description are only It is a certain embodiment of the present application, and other drawings can be obtained according to the drawings without any creative work for those skilled in the art.
图1A是本申请实施例提供的一种图片文件处理方法的流程示意图。FIG. 1A is a schematic flowchart of a method for processing a picture file according to an embodiment of the present application.
图1B是本申请实施例提供的一种图片文件处理方法的流程示意图;1B is a schematic flowchart of a method for processing a picture file according to an embodiment of the present application;
图2是本申请实施例提供的一种图片文件处理方法的流程时序图;2 is a sequence diagram of a process of a picture file processing method according to an embodiment of the present application;
图3是本申请实施例提供的一种图片文件处理的举例示意图;3 is a schematic diagram of an example of processing a picture file provided by an embodiment of the present application;
图4是本申请实施例提供的另一种图片文件处理的举例示意图;4 is a schematic diagram of another example of image file processing provided by an embodiment of the present application;
图5是本申请实施例提供的又一种图片文件处理的举例示意图;FIG. 5 is a schematic diagram of another example of image file processing provided by an embodiment of the present application; FIG.
图6是本申请实施例提供的又一种图片文件处理的举例示意图;FIG. 6 is a schematic diagram of another example of image file processing provided by an embodiment of the present application; FIG.
图7是本申请实施例提供的另一种图片文件处理方法的流程时序图;7 is a sequence diagram of a process of another image file processing method provided by an embodiment of the present application;
图8是本申请实施例提供的另一种图片文件处理方法的流程示意图;FIG. 8 is a schematic flowchart diagram of another method for processing a picture file according to an embodiment of the present application;
图9是本申请实施例提供的又一种图片文件处理方法的流程示意图;FIG. 9 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application;
图10是本申请实施例提供的一种压缩图像数据生成的举例示意图;FIG. 10 is a schematic diagram of an example of generating compressed image data according to an embodiment of the present application; FIG.
图11是本申请实施例提供的又一种图片文件处理方法的流程示意图;FIG. 11 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application;
图12是本申请实施例提供的又一种图片文件处理方法的流程示意图;FIG. 12 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application;
图13是本申请实施例提供的一种图片文件生成的举例示意图;FIG. 13 is a schematic diagram showing an example of generating a picture file according to an embodiment of the present application;
图14是本申请实施例提供的又一种图片文件处理方法的流程示意图;FIG. 14 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application;
图15是本申请实施例提供的又一种图片文件处理方法的流程示意图;FIG. 15 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application;
图16是本申请实施例提供的又一种图片文件处理方法的流程示意图;FIG. 16 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application;
图17是本申请实施例提供的又一种图片文件处理方法的流程示意图;FIG. 17 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application;
图18是本申请实施例提供的又一种图片文件处理方法的流程示意图;FIG. 18 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application;
图19是本申请实施例提供的一种YUV420模式的原始色度分量的举例示意图;19 is a schematic diagram showing an example of a primary chrominance component of a YUV420 mode according to an embodiment of the present application;
图20是本申请实施例提供的一种YUV420模式的目标色度分量的举例示意图;20 is a schematic diagram showing an example of a target chrominance component of a YUV420 mode according to an embodiment of the present application;
图21A是本申请实施例提供的又一种图片文件处理方法的流程示意图;21A is a schematic flowchart of still another method for processing a picture file according to an embodiment of the present application;
图21B是本申请实施例提供的又一种图片文件处理方法的流程示意图;21B is a schematic flowchart of still another method for processing a picture file according to an embodiment of the present application;
图22是本申请实施例提供的又一种图片文件处理方法的流程示意图;FIG. 22 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application;
图23是本申请实施例提供的一种图片文件处理设备的结构示意图;FIG. 23 is a schematic structural diagram of a picture file processing apparatus according to an embodiment of the present disclosure;
图24是本申请实施例提供的一种图像转换单元的结构示意图;FIG. 24 is a schematic structural diagram of an image conversion unit according to an embodiment of the present disclosure;
图25是本申请实施例提供的另一种图片文件处理设备的结构示意图;FIG. 25 is a schematic structural diagram of another picture file processing apparatus according to an embodiment of the present disclosure;
图26是本申请实施例提供的又一种图片文件处理设备的结构示意图;FIG. 26 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present disclosure;
图27是本申请实施例提供的一种图像编码单元的结构示意图;FIG. 27 is a schematic structural diagram of an image coding unit according to an embodiment of the present disclosure;
图28是本申请实施例提供的又一种图片文件处理设备的结构示意图;28 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application;
图29是本申请实施例提供的一种图像处理系统的结构示意图;29 is a schematic structural diagram of an image processing system according to an embodiment of the present application;
图30是本申请实施例提供的又一种图片文件处理设备的结构示意图;FIG. 30 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application;
图31是本申请实施例提供的另一种图像转换单元的结构示意图;FIG. 31 is a schematic structural diagram of another image conversion unit according to an embodiment of the present disclosure;
图32是本申请实施例提供的另一种图像编码单元的结构示意图;32 is a schematic structural diagram of another image coding unit according to an embodiment of the present application;
图33是本申请实施例提供的又一种图片文件处理设备的结构示意 图;FIG. 33 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application; FIG.
图34是本申请实施例提供的又一种图片文件处理设备的结构示意图;FIG. 34 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present disclosure;
图35是本申请实施例提供的又一种图片文件处理设备的结构示意图。FIG. 35 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application.
实施方式Implementation
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following with reference to the drawings in the embodiments of the present application. It is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without departing from the inventive scope are the scope of the present application.
请参见图1A,为本申请实施例提供了又一种图片文件处理方法的流程示意图。该方法可以由一计算设备执行。该方法可以包括以下步骤。1A is a schematic flowchart of still another method for processing a picture file according to an embodiment of the present application. The method can be performed by a computing device. The method can include the following steps.
S101A,接收发送设备发送的原始图片文件的转码码流,解析所述转码码流以获取图片头信息数据段和码流数据,所述图片头信息数据段包括所述原始图片文件的颜色表,所述码流数据为所述发送设备对所述原始图片文件中各像素的第一色彩数据进行编码生成的信息。S101A: Receive a transcoded code stream of the original picture file sent by the sending device, parse the transcoded code stream to obtain a picture header information data segment and code stream data, where the picture header information data segment includes the color of the original picture file. The code stream data is information generated by the sending device to encode first color data of each pixel in the original picture file.
所述第一色彩数据可以是RGB数据,或YUV数据,或HSV数据等。The first color data may be RGB data, or YUV data, or HSV data or the like.
这里,当所述原始图片文件仅包括一幅图像时,所述颜色表可以为该张图片对应的颜色表。当所述原始图片文件为具有多帧的图片文件时,所述颜色表可以为所述图片文件的全局颜色表,或者所述图片文件中某帧图像的局部颜色表。Here, when the original picture file includes only one image, the color table may be a color table corresponding to the picture. When the original picture file is a picture file having multiple frames, the color table may be a global color table of the picture file or a partial color table of a frame image in the picture file.
S102A,解码所述码流数据以生成第二色彩数据,并基于所述颜色 表对所述第二色彩数据进行处理以生成第二图片文件。S102A, decoding the code stream data to generate second color data, and processing the second color data based on the color table to generate a second picture file.
在一些实例中,所述图片头信息数据段进一步包括延时信息、总帧数。计算设备可以采用所述延时时间和所述总帧数将更新后的所述第二色彩数据进行图像编码以生成所述第二图片文件。In some examples, the picture header information data segment further includes delay information, a total number of frames. The computing device may perform image encoding on the updated second color data by using the delay time and the total number of frames to generate the second picture file.
在一些实例中,计算设备可以利用所述第二色彩数据中各像素点的色彩值和所述颜色表生成所述第二色彩数据对应的局部颜色表,并采用所述局部颜色表对所述各像素点的色彩值进行更新。In some examples, the computing device may generate a local color table corresponding to the second color data by using a color value of each pixel in the second color data and the color table, and use the local color table to The color value of each pixel is updated.
在一些实例中,当所述第二色彩数据为所述原始图片文件的首帧图像的色彩数据时,计算设备可以利用所述第二色彩数据对所述首帧图像的初始颜色表进行训练,得到所述首帧图像对应的局部颜色表,所述首帧图像的所述初始颜色表为所述颜色表。当所述第二色彩数据为所述原始图片文件的第N帧图像的色彩数据时,计算设备可以利用所述第二色彩数据对所述第N帧图像对应的初始颜色表进行训练,得到所述第N帧图像对应的局部颜色表。其中,所述第N帧图像对应的初始颜色表为所述原始图片文件的第N-1帧图像对应的局部颜色表,N为大于1的整数。In some examples, when the second color data is color data of a first frame image of the original picture file, the computing device may use the second color data to train an initial color table of the first frame image, Obtaining a partial color table corresponding to the first frame image, wherein the initial color table of the first frame image is the color table. When the second color data is the color data of the Nth frame image of the original picture file, the computing device may use the second color data to train the initial color table corresponding to the Nth frame image to obtain a A partial color table corresponding to the image of the Nth frame. The initial color table corresponding to the Nth frame image is a local color table corresponding to the N-1th frame image of the original picture file, and N is an integer greater than 1.
在一些实例中,计算设备可以将所述初始颜色表中的色彩值按照一个色彩分量的预设排序方式进行排序,以生成训练颜色表。针对所述第二色彩数据中的各像素点,在所述训练颜色表中获取所述色彩分量与所述像素点的所述色彩分量最接近的第一色彩值,并获取第一色彩值的第一颜色索引。在所述训练颜色表中以所述第一颜色索引为中心的预设范围内,获取与所述像素点的色彩值误差最小的第二色彩值,并获取第二色彩值的第二颜色索引。将所述第二色彩值替换为所述像素点的色彩值,并采用预设权重值和所述像素点的色彩值,对所述训练颜色表中以所述第二颜色索引为中心的预设范围内的多个色彩值进行修改。将修改后的所述训练颜色表确定为所述局部颜色表。In some examples, the computing device can sort the color values in the initial color table in a predetermined ordering of one color component to generate a training color table. Obtaining a first color value of the color component closest to the color component of the pixel point in the training color table for each pixel in the second color data, and acquiring a first color value The first color index. Obtaining, in a preset range centered on the first color index in the training color table, a second color value having a smallest error with a color value of the pixel point, and acquiring a second color index of the second color value . Substituting the second color value with a color value of the pixel point, and using a preset weight value and a color value of the pixel point, a pre-position of the second color index in the training color table Set a number of color values within the range to modify. The modified training color table is determined as the partial color table.
上述色彩分量可以为表示色彩的多个参数中的任一个参数。例如,当色彩数据为RGB数据,上述色彩分量可以是R分量、G分量、或B分量。当色彩数据为YUV数据时,上述色彩分量可以是Y分量、U分量、或V分量。The color component described above may be any one of a plurality of parameters representing a color. For example, when the color data is RGB data, the above color component may be an R component, a G component, or a B component. When the color data is YUV data, the above color component may be a Y component, a U component, or a V component.
在一些实例中,所述原始图片文件的转码码流可以是发送端发送的,该计算设备可以接收第二计算设备发送的所述转码码流。在一些实例中,发送设备可以根据所述原始图片文件生成所述图片头信息数据段和所述第一色彩数据。对所述第一色彩数据进行编码以生成所述码流数据。存储所述转码码流,所述转码码流包含所述图片头信息数据段和所述码流数据。需要时,发送设备可以读取存储的转码码流并将所述转码码流发送给接收设备。In some examples, the transcoded stream of the original picture file may be sent by the sending end, and the computing device may receive the transcoded code stream sent by the second computing device. In some examples, the transmitting device may generate the picture header information data segment and the first color data according to the original picture file. The first color data is encoded to generate the code stream data. And storing the transcoded code stream, where the transcoded code stream includes the picture header information data segment and the code stream data. The transmitting device can read the stored transcoded stream and transmit the transcoded stream to the receiving device as needed.
本申请实施例的图片文件处理方法可以应用于对图片文件进行编解码及传输的场景,例如:即时通信、网页展示等。例如:发送端根据原始图片文件生成图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据,所述发送端对所述YUV数据进行编码以生成码流数据。所述发送端生成压缩图像数据,并将所述压缩图像数据发送至接收端,所述压缩图像数据包含所述图片头信息数据段和所述码流数据。所述接收端接收所述发送端发送的所述压缩图像数据,解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据。所述接收端根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行编码处理以生成所述图片文件的场景等。通过将文件数据量较大的图片文件中每帧图像转换为数据量较小的YUV数据,再对YUV数据编码得到码流数据,极大的缩小了图片文件在传输过程中的文件数据量,降低了带宽成本。The picture file processing method in the embodiment of the present application can be applied to a scene in which a picture file is encoded, decoded, and transmitted, for example, instant messaging, web page display, and the like. For example, the transmitting end generates a picture header information data segment of the picture file according to the original picture file, and converts each frame image in the picture file into YUV data, and the transmitting end encodes the YUV data to generate code stream data. The transmitting end generates compressed image data, and sends the compressed image data to a receiving end, where the compressed image data includes the picture header information data segment and the code stream data. The receiving end receives the compressed image data sent by the sending end, and parses the compressed image data to obtain the picture header information data segment and the code stream data. The receiving end generates the YUV data according to the code stream data, and performs encoding processing on the YUV data based on the picture header information data segment to generate a scene of the picture file and the like. By converting each image of the image file with a large amount of file data into YUV data with a small amount of data, and then encoding the YUV data to obtain the code stream data, the amount of file data in the transmission process of the image file is greatly reduced. Reduced bandwidth costs.
本申请实施例涉及的发送端可以为具备对图片文件解码、编码等功 能在内的终端设备或者后台服务设备,或者可以为终端设备或者服务设备中的图像处理模块。所述接收端可以为具备对图片文件编码、视频解压等功能在内的终端设备或者后台服务设备,或者可以为终端设备或者服务设备中的图像处理模块。上述终端设备可以包括计算机、平板电脑、智能手机、笔记本电脑、掌上电脑以及移动互联网设备(MID)等。所述发送端和所述接收端可以应用到多种场景中的两端。例如:在即时通信场景中,所述发送端可以为发送图片文件的终端设备,所述接收端可以为接收所述图片文件的即时通信应用的后台服务设备。也可以是,所述发送端为转发图片文件的即时通信应用的后台服务设备,所述接收端为接收图片文件的终端设备等。在利用蓝牙、红外、数据线进行数据传输的场景中,所述发送端可以为发送图片文件的终端设备,所述接收端可以为接收图片文件的终端设备。以上场景仅为举例说明,可以根据实际的运行场景确定发送端和接收端的类型,所有包含图片文件编解码及传输的场景均属于本申请实施例的保护范畴,所述图片文件可以为图形交换格式(Graphics Interchange Format,GIF)图像、音频视频交错格式(Audio Video Interleaved,AVI)图像、SWF(Shock Wave Flash)、位图动画格式(Animated Portable Network Graphics,APNG)中的任一种。The transmitting end of the embodiment of the present application may be a terminal device or a background service device having functions such as decoding, encoding, and the like, or may be an image processing module in the terminal device or the service device. The receiving end may be a terminal device or a background service device having a function of encoding a picture file, a video decompression, or the like, or may be an image processing module in the terminal device or the service device. The above terminal devices may include computers, tablets, smart phones, notebook computers, palmtop computers, and mobile internet devices (MIDs). The transmitting end and the receiving end can be applied to both ends of multiple scenarios. For example, in an instant messaging scenario, the sending end may be a terminal device that sends a picture file, and the receiving end may be a background service device that receives an instant messaging application of the picture file. The sending end is a background service device of an instant messaging application that forwards a picture file, and the receiving end is a terminal device that receives a picture file, and the like. In a scenario in which data is transmitted by using a Bluetooth, an infrared, or a data line, the transmitting end may be a terminal device that sends a picture file, and the receiving end may be a terminal device that receives a picture file. The above scenario is only an example. The type of the sender and the receiver can be determined according to the actual running scenario. All the scenarios including the encoding and decoding of the image file are in the protection scope of the embodiment of the present application, and the image file may be a graphics exchange format. (Graphics Interchange Format, GIF) Any of an image, an Audio Video Interleaved (AVI) image, a SWF (Shock Wave Flash), and an Animated Portable Network Graphics (APNG).
以下将对本申请实施例中将使用到的常用词语进行介绍:The common words that will be used in the embodiments of the present application will be introduced below:
图像,用于表示图片文件中的一帧画面。An image used to represent a frame of a picture file.
图片,用于表示一个完整的图像文件,可以包含一幅或多幅图像。A picture that represents a complete image file that can contain one or more images.
分量,用于表示图像的三个样值矩阵中的一个矩阵或矩阵中的单个样值。A component that represents a single matrix in a matrix or matrix of three sample matrices of an image.
亮度,用于表示亮度信号Y的样值矩阵或单个样值。Brightness, used to represent a matrix of samples of the luminance signal Y or a single sample.
色度,用于表示Cr和Cb两种色差信号中的任一种的样值矩阵和单个样值。Chromaticity, used to represent the sample matrix and single sample of either of the Cr and Cb color difference signals.
码流数据,用于表示编码后得到的数据,也可以采用视频帧数据等名称进行描述。The code stream data is used to represent the data obtained after encoding, and may also be described by using a name such as video frame data.
图像特征信息段,用于表示图片文件的延时信息、总帧数、全局颜色表信息等信息。The image feature information segment is used to represent information such as delay information, total number of frames, and global color table information of the image file.
用户自定义信息段,用于表示在对三原色(Red Green Blue,RGB)数据或YUV数据进行编码时,所输入的配置参数、编码器复杂度等信息。A user-defined information segment that indicates information such as configuration parameters, encoder complexity, and the like when encoding three primary colors (Red Green Blue, RGB) data or YUV data.
图片头信息数据段,用于表示压缩图像数据的起始端,可以包含图像特征信息段以及用户自定义信息段。The picture header information data segment is used to indicate the beginning end of the compressed image data, and may include an image feature information segment and a user-defined information segment.
压缩图像数据,用于表示对码流数据和图像头信息数据段进行图片格式封装生成的数据,也可以采用图像序列、压缩码流等名称进行描述。The compressed image data is used to represent the data generated by the image format encapsulation of the code stream data and the image header information data segment, and may also be described by using a name such as an image sequence or a compressed code stream.
图1B为本申请实施例提供了一种图片文件处理方法的流程示意图。本申请实施例从发送端和接收端共同阐述图片文件处理方法的具体流程,该方法可以包括以下步骤。FIG. 1B is a schematic flowchart of a method for processing a picture file according to an embodiment of the present application. The embodiment of the present application jointly illustrates a specific process of the image file processing method from the sending end and the receiving end, and the method may include the following steps.
S101B,发送端根据原始图片文件生成图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据。S101B: The sending end generates a picture header information data segment of the picture file according to the original picture file, and converts each frame image in the picture file into YUV data.
一些实例中,发送端可以解码原始图片文件以生成所述图片文件的图片头信息数据段。所述图片文件可以是由开发人员完成对图像制作后所输入的图像,也可以是从其它端接收的图像。所述图片头信息数据段可以包括所述图片文件的延时信息、总帧数等。所述延时信息记录有所述图片文件中每帧图像之间的播放间隔时间。所述总帧数为所述图片文件中的图像帧数。所述图片头信息数据段中还可以包括所述图片文件的全局颜色表信息。所述全局颜色表信息包含每帧图像的每个像素点的RGB值。针对一些图片文件,其包含的所有图像均共用一个全局颜色表 信息。而对于另外一些图片文件,其每帧图像都存在各自的局部颜色表信息,因此若所述图片文件中存在全局颜色表信息,则获取该全局颜色表信息。若所述图片文件中仅存在局部颜色表信息,则可以对局部颜色表信息进行获取,也可以不获取。所述发送端进一步将所述图片文件中每帧图像转换为YUV数据。In some examples, the sender may decode the original picture file to generate a picture header information data segment of the picture file. The image file may be an image input by the developer after the image is created, or may be an image received from the other end. The picture header information data segment may include delay information of the picture file, a total number of frames, and the like. The delay information records a play interval between each frame of the picture file. The total number of frames is the number of image frames in the picture file. The picture header information data segment may further include global color table information of the picture file. The global color table information contains RGB values for each pixel of each frame of image. For some image files, all images contained in it share a global color table information. For some other image files, each frame image has its own local color table information. Therefore, if the global color table information exists in the image file, the global color table information is acquired. If only partial color table information exists in the picture file, the local color table information may or may not be acquired. The transmitting end further converts each frame image in the picture file into YUV data.
S102B,所述发送端对所述YUV数据进行编码以生成码流数据。S102B. The transmitting end encodes the YUV data to generate code stream data.
一些实例中,所述发送端可以进一步对所述YUV数据进行编码处理,生成码流数据。所述编码可以包括预测编码、变换编码、量化编码和熵编码。例如:所述发送端可以采用IPPP模式对所述YUV数据进行压缩,第一帧YUV数据为I帧,I帧即为帧内预测帧,其余帧YUV数据为P帧,P帧即为帧间预测帧,可以有效的压缩图片文件的文件数据量,还可以采用固定量化参数(Quantization Parameter,QP)的方式来稳定不同帧之间的质量等。熵编码则可以包括哈夫曼编码、算数编码等。In some examples, the transmitting end may further perform encoding processing on the YUV data to generate code stream data. The encoding may include predictive coding, transform coding, quantization coding, and entropy coding. For example, the transmitting end may compress the YUV data by using an IPPP mode. The first frame YUV data is an I frame, the I frame is an intra prediction frame, and the remaining frame YUV data is a P frame, and the P frame is an interframe. The prediction frame can effectively compress the file data amount of the picture file, and can also use a fixed quantization parameter (QP) to stabilize the quality between different frames. The entropy coding may include Huffman coding, arithmetic coding, and the like.
S103B,所述发送端将压缩图像数据发送至接收端。S103B: The transmitting end sends the compressed image data to the receiving end.
一些实例中,所述发送端可以生成压缩图像数据,所述发送端可以对所述压缩图像数据进行存储。当检测到接收端对所述图片文件的请求时,所述发送端再将所述压缩图像数据发送至所述接收端。例如:当发送端检测到包含所述图片文件的网页开启时。所述发送端也可以直接将所述压缩图像数据发送至所述接收端。例如:即时通信应用中的一个客户端需要将所述图片文件发送至另一个客户端时,应用服务设备需要将所述图片文件进行转发等,所述压缩图像数据包含所述图片头信息数据段和所述码流数据。In some examples, the transmitting end may generate compressed image data, and the transmitting end may store the compressed image data. When detecting the request of the receiving end for the picture file, the transmitting end sends the compressed image data to the receiving end. For example: when the sender detects that the webpage containing the image file is open. The transmitting end may also directly send the compressed image data to the receiving end. For example, when a client in an instant messaging application needs to send the image file to another client, the application service device needs to forward the image file, and the compressed image data includes the image header information data segment. And the code stream data.
S104B,所述接收端接收所述发送端发送的所述压缩图像数据,解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据。S104B: The receiving end receives the compressed image data sent by the sending end, and parses the compressed image data to obtain the picture header information data segment and the code stream data.
一些实例中,所述接收端接收所述发送端发送的所述压缩图像数 据,所述接收端可以对所述压缩图像数据进行解析处理,以获取所述压缩图像数据中的所述图片头信息数据段和所述码流数据。In some examples, the receiving end receives the compressed image data sent by the sending end, and the receiving end may perform parsing processing on the compressed image data to obtain the picture header information in the compressed image data. Data segment and the code stream data.
S105B,所述接收端根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。S105B. The receiving end generates the YUV data according to the code stream data, and processes the YUV data according to the picture header information data segment to generate the picture file.
一些实例中,所述接收端解码所述码流数据以生成所述YUV数据,并基于图片头信息数据段中的时延信息、总帧数、全局颜色表信息等对所述YUV数据进行编码处理以生成所述图片文件。In some examples, the receiving end decodes the code stream data to generate the YUV data, and encodes the YUV data based on delay information, total frame number, global color table information, and the like in a picture header information data segment. Processing to generate the picture file.
在本申请实施例中,根据原始的图片文件生成图片文件的图片头信息数据段,将图片文件中每帧图像转换为YUV数据,再基于YUV数据进行编码后得到的码流数据以及图片头信息数据段生成压缩图像数据,并将压缩图像数据进行传输,在接收到压缩图像数据时,可以根据码流数据生成YUV数据,再基于图片头信息数据段对YUV数据进行处理生成图片文件。通过将文件数据量较大的图片文件中每帧图像转换为数据量较小的YUV数据,再对YUV数据编码得到码流数据,极大的缩小了图片文件在传输过程中的文件数据量,降低了带宽成本。In the embodiment of the present application, the picture header information data segment of the picture file is generated according to the original picture file, and each frame image in the picture file is converted into YUV data, and then the code stream data and the picture header information obtained by encoding according to the YUV data are obtained. The data segment generates compressed image data, and transmits the compressed image data. When the compressed image data is received, YUV data may be generated according to the code stream data, and the YUV data is processed based on the image header information data segment to generate a picture file. By converting each image of the image file with a large amount of file data into YUV data with a small amount of data, and then encoding the YUV data to obtain the code stream data, the amount of file data in the transmission process of the image file is greatly reduced. Reduced bandwidth costs.
请参见图2,为本申请实施例提供了一种图片文件处理方法的流程时序图。本申请实施例从发送端侧和接收端侧共同阐述图片文件处理方法的具体流程,该方法可以包括以下步骤。Referring to FIG. 2, a flow chart of a method for processing a picture file is provided in an embodiment of the present application. The specific process of the image file processing method is jointly illustrated by the sending end side and the receiving end side, and the method may include the following steps.
S201,所述发送端解码原始图片文件生成图片文件的图片头信息数据段以及图片文件中每帧图像对应的RGB数据。S201. The sending end decodes a picture header information data segment of the original picture file to generate a picture file and RGB data corresponding to each frame image in the picture file.
一些实例中,所述发送端可以解码原始图片文件以生成所述图片文件的图片头信息数据段以及所述图片文件中每帧图像对应的RGB数据。In some examples, the transmitting end may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
S202,所述发送端采用颜色空间转换公式将所述RGB数据转换为YUV数据。S202. The transmitting end converts the RGB data into YUV data by using a color space conversion formula.
一些实例中,所述发送端可以采用颜色空间转换公式将所述RGB数据转换为YUV数据。在将RGB数据转换为YUV数据的过程中,可以选择亮度分量的值域范围为[16,235],色度分量的值域范围为[16,240]的颜色空间转换公式。由于值域范围的缩减,可以极大的减小转换后YUV数据的数据量。还可以选择亮度分量和色度分量的值域范围均为[0,255]颜色空间转换公式,可以减小转换后YUV数据的失真。亮度分量和色度分量的值域范围均为[0,255]的颜色空间转换公式为:In some examples, the transmitting end may convert the RGB data into YUV data using a color space conversion formula. In the process of converting RGB data into YUV data, the range of the luminance component can be selected as [16, 235], and the range of the chrominance component is in the range of [16, 240]. Due to the reduction of the range of values, the amount of data of the converted YUV data can be greatly reduced. It is also possible to select the range of the luminance component and the chrominance component to be the [0, 255] color space conversion formula, which can reduce the distortion of the converted YUV data. The color space conversion formula for the range of luminance components and chrominance components with the range of [0, 255] is:
Y=0.299R+0.587G+0.114B。 (1)Y = 0.299R + 0.587G + 0.114B. (1)
U=-0.1687R-0.3313G+0.5B+128。 (2)U=-0.1687R-0.3313G+0.5B+128. (2)
V=0.5R-0.4187G-0.0813B+128。 (3)V = 0.5R - 0.4187G - 0.0813B + 128. (3)
其中,YUV是一种视频数据格式,Y为亮度分量,UV为色度分量,通过颜色空间转换公式可以对每帧图像的像素点进行光栅扫描处理,将每帧RGB数据转换为对应的YUV数据。Among them, YUV is a video data format, Y is the luminance component, and UV is the chrominance component. The color space conversion formula can perform raster scan processing on the pixels of each frame of image, and convert each frame of RGB data into corresponding YUV data. .
S203,所述发送端对所述YUV数据进行编码以生成码流数据。S203. The transmitting end encodes the YUV data to generate code stream data.
一些实例中,所述发送端可以进一步对所述YUV数据进行编码处理,生成码流数据。In some examples, the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
一些实例中,在对所述YUV数据进行编码过程中,可以支持用户添加配置参数,所述配置参数可以为对所述YUV数据进行编码的参数,所述配置参数可以包括标清模式参数、高清模式参数和无损模式参数中的任一种,要求减少带宽,则可以选择标清模式参数(例如:YUV420模式参数)。要求图像质量,则可以选择高清模式参数(例如:YUV444模式参数)等。所述发送端可以采用配置参数对所述YUV数据进行编码以生成码流数据。In some examples, during the encoding of the YUV data, the user may be configured to add a configuration parameter, where the configuration parameter may be a parameter that encodes the YUV data, and the configuration parameter may include an SD mode parameter and a HD mode. For any of the parameters and lossless mode parameters, if you want to reduce the bandwidth, you can select the SD mode parameters (for example: YUV420 mode parameters). For image quality, you can select HD mode parameters (for example: YUV444 mode parameters). The transmitting end may encode the YUV data by using configuration parameters to generate code stream data.
一些实例中,在对所述YUV数据进行编码过程中,还可以支持用户添加编码器复杂度。所述编码器复杂度可以为根据所述发送端的硬件 性能所决定的编码的精细度参数。所述编码器复杂度可以包括第一复杂度、第二复杂度和第三复杂度中的任一种。所述第一复杂度高于所述第二复杂度,所述第二复杂度高于所述第三复杂度。例如:可以对所述发送端的硬件性能进行检测以生成性能数值。例如:测试所述发送端的中央处理器的计算速率等。当所述性能数值位于第一预设数值范围内时,可以确定发送端硬件性能很高,则可以推荐使用第一复杂度的编码方式。当所述性能数值位于第二预设数值范围内时,可以确定发送端硬件性能中等,则可以推荐使用第二复杂度的编码方式。当所述性能数值位于第三预设数值范围内时,可以确定发送端硬件性能较差,或者当前要求实时转码等,则可以推荐使用第三复杂度的编码方式等。所述发送端可以配置编码器复杂度对所述YUV数据进行编码以生成码流数据。In some instances, the user may be added to add encoder complexity during encoding of the YUV data. The encoder complexity may be a fineness parameter of the encoding determined according to the hardware performance of the transmitting end. The encoder complexity may include any of the first complexity, the second complexity, and the third complexity. The first complexity is higher than the second complexity, and the second complexity is higher than the third complexity. For example, the hardware performance of the sender can be detected to generate a performance value. For example: testing the calculation rate of the central processing unit of the transmitting end, and the like. When the performance value is within the first preset value range, it may be determined that the hardware performance of the transmitting end is high, and the encoding method of the first complexity may be recommended. When the performance value is within the second preset value range, it may be determined that the hardware performance of the transmitting end is medium, and the encoding method of the second complexity may be recommended. When the performance value is within the third preset value range, it may be determined that the hardware performance of the transmitting end is poor, or the current real-time transcoding is required, and the encoding method of the third complexity may be recommended. The transmitting end may configure an encoder complexity to encode the YUV data to generate code stream data.
需要说明的是,上述两种编码方式可以为并行的编码方式,即所述发送端可以同时采用配置参数和配置的编码器复杂度对所述YUV数据进行编码以生成码流数据。上述的性能数值、第一预设数值范围、第二通预设数值范围以及第三预设数值范围具体可以根据开发人员的人为经验进行设定。It should be noted that the foregoing two coding modes may be parallel coding modes, that is, the transmitting end may simultaneously encode the YUV data to generate code stream data by using configuration parameters and configured encoder complexity. The above performance value, the first preset value range, the second pass preset value range, and the third preset value range may be specifically set according to the developer's human experience.
S204,所述发送端将压缩图像数据发送至接收端。S204. The transmitting end sends the compressed image data to the receiving end.
S205,所述接收端接收所述发送端发送的所述压缩图像数据,解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据。S205. The receiving end receives the compressed image data sent by the sending end, and parses the compressed image data to obtain the picture header information data segment and the code stream data.
S206,所述接收端解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。S206. The receiving end decodes the code stream data to generate the YUV data, and converts the YUV data into RGB data by using a color space conversion formula.
一些实例中,所述接收端解码所述码流数据以生成所述YUV数据,并可以采用颜色空间转换公式将所述YUV数据转换为RGB数据,一些实例中,所述接收端需要依据亮度分量的值域范围确定所采用的颜色空间转换公式,可以理解的是,针对YUV444模式下的YUV数据,可以 选择亮度分量的值域范围为[16,235],色度分量的值域范围为[16,240]的颜色空间转换公式,也可以选择亮度分量和色度分量的值域范围均为[0,255]颜色空间转换公式,具体可以依据上述实施例中在将RGB数据转换为YUV数据时选择的颜色空间转换公式对应。需要说明的是,色度包括Cb和Cr两种色差信号中的任一种的样值矩阵和单个样值。两种色差信号需要分别进行上采样处理,两者进行上采样处理的方式均相同,其中,Cb对应YUV中的U,Cr对应YUV中的V。In some examples, the receiving end decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data by using a color space conversion formula. In some examples, the receiving end needs to be based on a luminance component. The range of values determines the color space conversion formula used. It can be understood that for the YUV data in the YUV444 mode, the range of the luminance component can be selected as [16, 235], and the range of the chrominance component is [ 16,240] color space conversion formula, you can also select the range of the luminance component and the chrominance component are all [0, 255] color space conversion formula, specifically according to the above embodiment in the conversion of RGB data to YUV data The color space conversion formula selected at the time corresponds. It should be noted that the chromaticity includes a sample matrix and a single sample of any one of Cb and Cr color difference signals. The two color difference signals need to be separately subjected to upsampling processing, and the two methods of performing upsampling processing are the same, wherein Cb corresponds to U in YUV, and Cr corresponds to V in YUV.
若亮度分量的值域范围为[16,235],色度分量的值域范围为[16,240],则颜色空间转换公式为:If the range of the luminance component is [16, 235] and the range of the chrominance component is [16, 240], the color space conversion formula is:
R=Clip3(0,255,(298*Y+409*(Cr–128)+128)>>8)。(4)R = Clip3 (0, 255, (298 * Y + 409 * (Cr - 128) + 128) >> 8). (4)
G=Clip3(0,255,(298*Y–100*(Cb-128)+208*(Cr-128)+128)>>8)。 (5)G = Clip3 (0, 255, (298 * Y - 100 * (Cb - 128) + 208 * (Cr - 128) + 128) >> 8). (5)
B=Clip3(0,255,(298*Y+516*(Cb-128)+128)>>8)。(6)B = Clip3 (0, 255, (298 * Y + 516 * (Cb - 128) + 128) >> 8). (6)
其中,“+128”用于对R值、B值、G值进行四舍五入,“>>8”表示除以2的8次方。Among them, "+128" is used to round off the R value, B value, and G value, and ">>8" means dividing by the 8th power of 2.
若亮度分量和色度分量的值域范围均为[0,255],则颜色空间转换公式为:If the range of the luminance component and the chrominance component are both [0, 255], the color space conversion formula is:
R=Clip3(0,255,Y+(359*(Cr–128)+128)>>8)。(7)R = Clip3 (0, 255, Y + (359 * (Cr - 128) + 128) >> 8). (7)
G=Clip3(0,255,Y–(88*(Cb-128)+183*(Cr-128)+128)>>8)。 (8)G = Clip3 (0, 255, Y - (88 * (Cb - 128) + 183 * (Cr - 128) + 128) >> 8). (8)
B=Clip3(0,255,Y+(454*(Cb-128)+128)>>8)。(9)B = Clip3 (0, 255, Y + (454 * (Cb - 128) + 128) >> 8). (9)
其中,“+128”用于对R值、B值、G值进行四舍五入,“>>8”表示除以2的8次方。Among them, "+128" is used to round off the R value, B value, and G value, and ">>8" means dividing by the 8th power of 2.
通过颜色空间转换公式可以对每帧图像的像素点进行光栅扫描处理,将每帧YUV数据转换为对应的RGB数据。The color space conversion formula can perform raster scan processing on the pixels of each frame of image, and convert each frame of YUV data into corresponding RGB data.
S207,所述接收端采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新。S207. The receiving end updates the RGB values of each pixel in the RGB data by using the global color table information.
一些实例中,由于之前对所述YUV数据进行过编码处理,因此导致由所述YUV数据转换的RGB数据存在失真的情况,所述接收端可以采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新。所述RGB数据中可以包含一个或多个像素点,当所述RGB数据中仅存在一个像素点时,可以采用所述全局颜色表信息对所述像素点的RGB值进行更新,当所述RGB数据中存在多个像素点时,可以采用所述全局颜色表信息对多个像素点中各像素点的RGB值进行更新,所述接收端需要重新对所述全局颜色表信息进行训练,以生成符合所述RGB数据的局部颜色表信息,而对于不存在全局颜色表信息的情况,所述接收端可以生成初始化颜色表信息,并通过对所述初始化颜色表信息进行训练,以生成符合所述RGB数据的局部颜色表信息。In some examples, since the YUV data is previously subjected to an encoding process, the RGB data converted by the YUV data is distorted, and the receiving end may use the global color table information in the RGB data. The RGB values of each pixel are updated. The RGB data may include one or more pixel points, and when only one pixel point exists in the RGB data, the RGB value of the pixel point may be updated by using the global color table information, when the RGB When there are multiple pixels in the data, the RGB values of the pixels in the plurality of pixels may be updated by using the global color table information, and the receiving end needs to re-train the global color table information to generate Corresponding to the local color table information of the RGB data, and in the case where there is no global color table information, the receiving end may generate initial color table information, and perform training by initializing the color table information to generate the Local color table information for RGB data.
一些实例中,针对图片头信息数据段中存在全局颜色表信息的情况,当所述RGB数据为所述图片文件中的第一帧图像,所述接收端可以采用所述RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。In some examples, for the case where the global color table information exists in the data header data segment, when the RGB data is the first frame image in the image file, the receiving end may adopt each pixel in the RGB data. The RGB values of the points train the global color table information to generate local color table information of the RGB data, and update the RGB values of the respective pixel points by using local color table information of the RGB data.
一些实例中,当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,所述接收端可以将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式(例如:升序、降序等)进行排序,以生成训练颜色表信息。如图3所示,所述全局颜色表信息中包括颜色索引和源RGB值,例如:5,(8,1,10)、6,(8,9,8)、7,(1,7,6)、8,(10,8,6)、9,(5,8,5)、10,(9,10,1),按照G分量的升序排序可以生成训练颜色表信息,例 如:5,(8,1,10)、6,(1,7,6)、7,(5,8,5)、8,(10,8,6)、9,(8,9,8)、10,(9,10,1)。In some examples, when the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the receiving end may use the global color table information. The at least one source RGB value is sorted according to a preset ordering of the G components (eg, ascending, descending, etc.) to generate training color table information. As shown in FIG. 3, the global color table information includes a color index and a source RGB value, for example: 5, (8, 1, 10), 6, (8, 9, 8), 7, (1, 7, 6), 8, (10,8,6), 9, (5,8,5), 10, (9,10,1), according to the ascending order of the G component can generate training color table information, for example: 5, (8,1,10), 6, (1,7,6), 7, (5,8,5), 8, (10,8,6), 9, (8,9,8), 10, (9,10,1).
所述接收端在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取所述第一源RGB值的第一颜色索引。所述接收端可以采用所述当前像素点的G分量遍历所述训练颜色表信息中的源RGB值,获取G分量最为接近的第一源RGB值。如图4所示,假设第一帧RGB数据中有四个像素点,当前像素点为所述RGB数据中的第一个像素点,所述当前像素点的RGB值为(9,9,9),可以在所述训练颜色表信息中查找到(8,9,8)的G分量与当前像素点的RGB值中的G分量最接近,则将(8,9,8)确定为第一源RGB值,并获取所述第一源RGB值的第一颜色索引“9”。The receiving end acquires, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquires a first color index of the first source RGB value. . The receiving end may traverse the source RGB value in the training color table information by using the G component of the current pixel point, and acquire the first source RGB value that is closest to the G component. As shown in FIG. 4, it is assumed that there are four pixel points in the first frame RGB data, and the current pixel point is the first pixel point in the RGB data, and the RGB value of the current pixel point is (9, 9, 9). And, in the training color table information, it can be found that the G component of (8, 9, 8) is closest to the G component of the RGB values of the current pixel point, and (8, 9, 8) is determined as the first Source RGB values, and a first color index "9" of the first source RGB value is obtained.
所述接收端在所述训练颜色表信息中以所述第一颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第二源RGB值,并获取所述第二源RGB值的第二颜色索引。所述接收端可以以所述第一颜色索引为中心,在所述第一颜色索引的前后预设范围内获取多个源RGB值,并分别计算所述第一源RGB值以及所述多个源RGB值与所述当前像素点的RGB值的误差,并将多个源RGB值中误差最小的源RGB值确定为第二源RGB值。依据上述举例,假设预设范围为正负1的范围,则以“9”为中心,获取(10,8,6)和(9,10,1)两个源RGB值,并分别计算(10,8,6)、(8,9,8)和(9,10,1)三者与(9,9,9)的误差值。其中颜色索引“8”的误差值为|9-10|+|9-8|+|9-6|=5,颜色索引“9”的误差值为|9-8|+|9-9|+|9-8|=2,颜色索引“10”的误差值为|9-9|+|9-10|+|9-1|=9,则确定源RGB值(8,9,8)为所述第二源RGB值,并获取第二源RGB值的第二颜色索引“9”。上述获取的第一源RGB值和第一颜色索引存在与第二源RGB值和第二颜色索引相同的情况, 也可以存在不相同的情况,具体由实际执行过程确定。And acquiring, by the receiving end, a second source RGB value having the smallest error of the RGB value of the current pixel point in the preset range centered on the first color index in the training color table information, and acquiring the A second color index of the second source RGB value. The receiving end may be centered on the first color index, acquire a plurality of source RGB values in a preset range before and after the first color index, and calculate the first source RGB value and the multiple The error of the source RGB value and the RGB value of the current pixel point, and the source RGB value that minimizes the error among the plurality of source RGB values is determined as the second source RGB value. According to the above example, if the preset range is positive or negative range 1, the two source RGB values of (10, 8, 6) and (9, 10, 1) are obtained centered on "9" and calculated separately (10) Error values of (8,9,8), (8,9,8) and (9,10,1) and (9,9,9). The error value of the color index "8" is |9-10|+|9-8|+|9-6|=5, and the error value of the color index "9" is |9-8|+|9-9| +|9-8|=2, the error value of the color index "10" is |9-9|+|9-10|+|9-1|=9, then the source RGB value is determined (8, 9, 8) Is the second source RGB value, and acquires a second color index "9" of the second source RGB value. The first source RGB value and the first color index obtained are the same as the second source RGB value and the second color index, and may also be different, which is specifically determined by the actual execution process.
所述接收端将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第二颜色索引为中心的预设范围内的多个源RGB值进行修改。参见图5,依据上述举例,所述第二源RGB值为(8,9,8),则将(8,9,8)替换为当前像素点的RGB值(9,9,9),同时可以依据预设权重值以及当前像素点的RGB值对以所述第二颜色索引为中心的预设范围内的多个源RGB值进行修改。假设预设范围为正负1,则需要对(10,8,6)和(9,10,1)两个源RGB值进行修改。所述预设权重值可以为动态的权重值,对于距离所述第二颜色索引越近源RGB值,其受到当前像素点的RGB值的影响越大。假设当前权重值的分配为2:8,则采用(9,9,9)对(10,8,6)进行修改。例如,R分量=9*0.8+10*0.2=9.2,G分量=9*0.8+8*0.2=8.8,B分量=9*0.8+6*0.2=8.4,对以上结果采用四舍五入的方式,确定颜色索引“8”的源RGB值由(10,8,6)修改为(9,9,8)。同理,颜色索引“10”的源RGB值由(9,10,1)修改为(9,9,7)。The receiving end replaces the second source RGB value with the RGB value of the current pixel point, and adopts a preset weight value and an RGB value of the current pixel point, and the training color table information is The second color index is modified for a plurality of source RGB values within a preset range of the center. Referring to FIG. 5, according to the above example, when the second source RGB value is (8, 9, 8), (8, 9, 8) is replaced with the RGB value (9, 9, 9) of the current pixel point, and A plurality of source RGB values within a preset range centered on the second color index may be modified according to a preset weight value and an RGB value of the current pixel point. Assuming the preset range is plus or minus 1, you need to modify the two source RGB values (10, 8, 6) and (9, 10, 1). The preset weight value may be a dynamic weight value, and the closer the source RGB value is to the second color index, the greater the influence of the RGB value of the current pixel point. Assuming that the current weight value is assigned 2:8, the (9, 8, 9) pair (10, 8, 6) is modified. For example, R component = 9 * 0.8 + 10 * 0.2 = 9.2, G component = 9 * 0.8 + 8 * 0.2 = 8.8, B component = 9 * 0.8 + 6 * 0.2 = 8.4, the above results are rounded off, determined The source RGB value of the color index "8" is modified from (10, 8, 6) to (9, 9, 8). Similarly, the source RGB value of the color index "10" is modified from (9, 10, 1) to (9, 9, 7).
当所述当前像素点不为所述RGB数据中的最后一个像素点时,例如当前像素点为图4或图5中所示的RGB数据中的第一个像素点时,所述接收端获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值。例如:将所述RGB数据中的第二个像素点作为当前像素点,对修改后得到的所述训练颜色表信息再一次进行训练。一些实例中,训练过程可以参见上述训练过程的描述,在此不进行赘述。When the current pixel point is not the last pixel point in the RGB data, for example, when the current pixel point is the first pixel point in the RGB data shown in FIG. 4 or FIG. 5, the receiving end acquires Modifying the training color table information, using the next pixel point of the current pixel as the current pixel point, and transferring to perform acquiring the G component and the current pixel in the RGB data in the training color table information The G component of the point is closest to the first source RGB value. For example, the second pixel point in the RGB data is used as the current pixel point, and the training color table information obtained after the modification is once again trained. In some examples, the training process can be referred to the description of the above training process, and details are not described herein.
当所述当前像素点为所述RGB数据中的最后一个像素点时,例如 当前像素点为图4或图5中所示的RGB数据中的第四个像素点时,所述接收端获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, for example, when the current pixel point is the fourth pixel point in the RGB data shown in FIG. 4 or FIG. 5, the receiving end acquires the modification. The training color table information obtained later is determined, and the training color table information is determined as local color table information of the RGB data.
所述接收端可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。一些实例中,所述接收端可以在所述RGB数据的局部颜色表信息中依次获取与所述各像素点相同或误差最小的源RGB值分别替换所述各像素点的RGB值。在一些实例中,所述接收端可以将与所述各像素点相同或误差最小的源RGB值对应的颜色索引分别替换所述各像素点的RGB值。参见图6,依据上述举例,所述RGB数据的第一个像素点的RGB值为(9,9,9),在所述局部颜色表信息中与(9,9,9)误差最小的为(9,9,8),则将(9,9,8)对应的颜色索引“8”替换所述第一个像素点的RGB值,同理,第二个像素点的颜色索引为“10”,第三个像素点的颜色索引为“9”,第四个像素点的颜色索引为“6”。The receiving end may update the RGB values of the pixel points by using local color table information of the RGB data. In some examples, the receiving end may sequentially acquire, in the local color table information of the RGB data, source RGB values that are the same as the pixel points or have the smallest error, and replace the RGB values of the respective pixel points. In some examples, the receiving end may replace the RGB values of the respective pixel points with color indexes corresponding to the source RGB values that are the same or the smallest error of the respective pixel points. Referring to FIG. 6, according to the above example, the RGB value of the first pixel of the RGB data is (9, 9, 9), and the error with the (9, 9, 9) in the partial color table information is the smallest. (9, 9, 8), the color index "8" corresponding to (9, 9, 8) is replaced by the RGB value of the first pixel. Similarly, the color index of the second pixel is "10". The color index of the third pixel is "9", and the color index of the fourth pixel is "6".
在一些实例中,针对图片头信息数据段中不存在全局颜色表信息的情况,当所述RGB数据为所述图片文件中的第一帧图像,所述接收端可以采用所述RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。In some examples, for the case where there is no global color table information in the picture header information data segment, when the RGB data is the first frame image in the picture file, the receiving end may adopt the RGB data. The RGB values of the respective pixels are trained to initialize the color table information to generate local color table information of the RGB data, and the RGB values of the respective pixel points are updated using the local color table information of the RGB data.
一些实例中,当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,所述接收端可以生成一个初始化颜色表信息,例如:(0,0,0)、(1,1,1)、(2,2,2)、……、(255,255,255)。所述接收端在初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取所述第三源RGB值的第三颜色索引。所述接收端在所述初始化 颜色表信息中以所述第三颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第四源RGB值,并获取所述第四源RGB值的第四颜色索引。所述接收端将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述初始化颜色表信息中以所述第四颜色索引为中心的预设范围内的多个源RGB值进行修改。当所述当前像素点不为所述RGB数据中的最后一个像素点时,所述接收端获取修改后得到的所述初始化颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值。当所述当前像素点为所述RGB数据中的最后一个像素点时,所述接收端获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为所述RGB数据的局部颜色表信息,所述接收端可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。对初始化颜色表信息进行训练以及采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新的过程均可以参见前述方式的执行过程,在此不进行赘述。In some examples, when the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the receiving end may generate an initialization color table information, For example: (0,0,0), (1,1,1), (2,2,2), ..., (255,255,255). The receiving end acquires a third source RGB value of the G component closest to the G component of the current pixel point in the RGB data in the initialization color table information, and acquires a third color index of the third source RGB value. And acquiring, by the receiving end, a fourth source RGB value having the smallest error of the RGB value of the current pixel point in the preset range centered on the third color index in the initialization color table information, and acquiring the A fourth color index of the fourth source RGB value. The receiving end replaces the fourth source RGB value with the RGB value of the current pixel point, and adopts a preset weight value and an RGB value of the current pixel point, and the initial color table information is The fourth color index is modified by a plurality of source RGB values within a preset range of the center. When the current pixel point is not the last pixel point in the RGB data, the receiving end acquires the initialized color table information obtained after the modification, and uses the next pixel point of the current pixel point as the current pixel. Pointing and transferring to perform a third source RGB value that obtains the G component closest to the G component of the current pixel point in the RGB data in the initialization color table information. When the current pixel point is the last pixel point in the RGB data, the receiving end acquires the modified color table information obtained after the modification, and determines the initialization color table information as the RGB data. The local color table information, the receiving end may use the local color table information of the RGB data to update the RGB values of the respective pixel points. For the process of training the initialization color table information and updating the RGB values of the pixels by using the local color table information of the RGB data, refer to the execution process of the foregoing method, and no further details are provided herein.
在一些实例中,针对所述RGB数据不为所述图片文件中的第一帧图像,即所述RGB数据为所述图片文件中的第N帧图像时,其中,N为大于1且小于或等于所述总帧数的正整数。所述接收端可以采用所述RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。In some examples, the RGB data is not the first frame image in the picture file, that is, the RGB data is the Nth frame image in the picture file, where N is greater than 1 and less than or A positive integer equal to the total number of frames. The receiving end may train the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate local color table information of the RGB data, and adopt the RGB The local color table information of the data updates the RGB values of the respective pixel points.
一些实例中,当所述RGB数据为所述图片文件中的第N帧图像时,所述接收端可以将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信 息。所述接收端在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取所述第五源RGB值的第五颜色索引。所述接收端在所述训练颜色表信息中以所述第五颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第六源RGB值,并获取所述第六源RGB值的第六颜色索引。所述接收端将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第六颜色索引为中心的预设范围内的多个源RGB值进行修改。当所述当前像素点不为所述RGB数据中的最后一个像素点时,所述接收端获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值。当所述当前像素点为所述RGB数据中的最后一个像素点时,所述接收端获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息。所述接收端可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。需要说明的是,本例中对训练颜色表信息进行训练以及采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新的过程均可以参见前述方式的执行过程,在此不进行赘述。In some examples, when the RGB data is the Nth frame image in the picture file, the receiving end may use at least one source RGB value in the local color table information of the N-1th frame RGB data according to the G component. Sort the presets to generate training color table information. The receiving end acquires, in the training color table information, a fifth source RGB value whose G component is closest to the G component of the current pixel point in the RGB data, and acquires a fifth color index of the fifth source RGB value. . And acquiring, by the receiving end, a sixth source RGB value having the smallest error of the RGB value of the current pixel point in the preset range centered on the fifth color index in the training color table information, and acquiring the The sixth color index of the sixth source RGB value. The receiving end replaces the sixth source RGB value with the RGB value of the current pixel point, and adopts a preset weight value and an RGB value of the current pixel point, and the training color table information is The sixth color index is modified by a plurality of source RGB values within a preset range of the center. When the current pixel is not the last pixel in the RGB data, the receiving end acquires the modified color table information obtained by the modification, and uses the next pixel of the current pixel as the current pixel. Pointing, and transferring to a fifth source RGB value that performs the closest acquisition of the G component in the training color table information to the G component of the current pixel point in the RGB data. When the current pixel is the last pixel in the RGB data, the receiving end acquires the modified color table information obtained after the modification, and determines the training color table information as the RGB data. Local color table information. The receiving end may update the RGB values of the pixel points by using local color table information of the RGB data. It should be noted that, in this example, the process of training the training color table information and updating the RGB values of each pixel by using the local color table information of the RGB data can be referred to the execution process of the foregoing manner, and details are not described herein.
需要说明的是,上述采用G分量作为对颜色表信息进行训练的引导仅为举例,本申请实施例同样可以采用R分量或者B分量作为对颜色表信息进行训练的引导,执行过程均可以参见上述内容中的描述,在此不进行赘述。上述第一源RGB值、第二源RGB值、第三源RGB值、第四源RGB值、第五源RGB值、第六源RGB值以及第一颜色索引、第二颜色索引、第三颜色索引、第四颜色索引、第五颜色索引、第六颜色 索引均可以表示相同的源RGB值和颜色索引的含义,采用此方式进行命名仅为了区分不同的执行场景,例如:当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时。当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时。当所述RGB数据为所述图片文件中的第N帧图像时,以上三种执行场景。It should be noted that the use of the G component as the training for training the color table information is only an example. The R component or the B component can also be used as the guidance for training the color table information. The description in the content is not described here. The first source RGB value, the second source RGB value, the third source RGB value, the fourth source RGB value, the fifth source RGB value, the sixth source RGB value, and the first color index, the second color index, and the third color The index, the fourth color index, the fifth color index, and the sixth color index may all represent the same source RGB value and the meaning of the color index. The naming in this manner is only to distinguish different execution scenarios, for example: when the RGB data And being the first frame image in the picture file, and the global color table information is present in the picture header information data segment. When the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment. When the RGB data is the Nth frame image in the picture file, the above three execution scenarios.
S208,所述接收端采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。S208. The receiving end performs image coding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
一些实例中,所述接收端采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。在一些实例中,所述接收端可以基于所述延时时间和所述总帧数,并采用兰博-立夫-卫曲编码法(Lempel-Ziv-Welch Encoding,LZW)对所述RGB数据中各像素点的颜色索引进行图像编码,生成所述图片文件,所述接收端可以对所述图片文件进行存储或者展示。可以理解的是,所述图像编码的方式具体由图片文件的图像格式决定,例如:若需要生成的图片文件为GIF图像,则所述图像编码可以为GIF编码等。In some examples, the receiving end performs image encoding on the updated RGB data by using the delay time and the total number of frames to generate the picture file. In some examples, the receiving end may use the Lempel-Ziv-Welch Encoding (LZW) pair in the RGB data based on the delay time and the total number of frames. The color index of each pixel is image-encoded to generate the image file, and the receiving end may store or display the image file. It can be understood that the manner of the image encoding is specifically determined by the image format of the image file. For example, if the image file to be generated is a GIF image, the image encoding may be GIF encoding or the like.
请参见图7,为本申请实施例提供了另一种图片文件处理方法的流程时序图。本申请实施例从发送端侧、中转设备侧和接收端侧共同阐述图片文件处理方法的具体流程,该方法包括以下步骤。Referring to FIG. 7, a flow chart of another method for processing a picture file is provided in the embodiment of the present application. The specific process of the image file processing method is jointly illustrated by the sending end side, the transiting device side, and the receiving end side, and the method includes the following steps.
S2001,所述发送端解码原始图片文件以生成图片文件的图片头信息数据段以及图片文件中每帧图像对应的RGB数据。S2001, the sending end decodes the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
一些实例中,所述发送端可以解码原始图片文件以生成所述图片文件的图片头信息数据段以及所述图片文件中每帧图像对应的RGB数据。In some examples, the transmitting end may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
S2002,所述发送端采用颜色空间转换公式将所述RGB数据转换为YUV数据。S2002, the transmitting end converts the RGB data into YUV data by using a color space conversion formula.
一些实例中,所述发送端可以采用颜色空间转换公式将所述RGB数据转换为YUV数据。In some examples, the transmitting end may convert the RGB data into YUV data using a color space conversion formula.
S2003,所述发送端对所述YUV数据进行编码以生成码流数据。S2003, the transmitting end encodes the YUV data to generate code stream data.
一些实例中,所述发送端可以进一步对所述YUV数据进行编码处理,生成码流数据。In some examples, the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
一些实例中,在对所述YUV数据进行编码过程中,可以支持用户添加配置参数,所述配置参数可以为对所述YUV数据进行编码的参数。所述发送端可以采用配置参数对所述YUV数据进行编码以生成码流数据。In some examples, during encoding of the YUV data, a user may be added to add configuration parameters, which may be parameters that encode the YUV data. The transmitting end may encode the YUV data by using configuration parameters to generate code stream data.
一些实例中,在对所述YUV数据进行编码过程中,还可以支持用户添加编码器复杂度,所述编码器复杂度可以为根据所述发送端的硬件性能所决定的编码的精细度参数。所述发送端可以配置编码器复杂度对所述YUV数据进行编码以生成码流数据。In some examples, during encoding of the YUV data, a user may also be added to add encoder complexity, which may be a fineness parameter of the encoding determined according to hardware performance of the transmitting end. The transmitting end may configure an encoder complexity to encode the YUV data to generate code stream data.
S2004,所述发送端将压缩图像数据发送至中转设备。S2004, the sending end sends the compressed image data to the relay device.
一些实例中,所述发送端可以生成压缩图像数据,所述发送端可以对所述压缩图像数据进行存储,当检测到接收端对所述图片文件的请求时,所述发送端再将所述压缩图像数据发送至所述接收端。In some examples, the transmitting end may generate compressed image data, and the transmitting end may store the compressed image data, and when detecting the request of the receiving end for the picture file, the sending end performs the The compressed image data is sent to the receiving end.
S2005,所述中转设备接收所述发送端发送的所述压缩图像数据,并将所述压缩图像数据发送至接收端。S2005: The relay device receives the compressed image data sent by the sending end, and sends the compressed image data to a receiving end.
一些实例中,所述中转设备可以为所述发送端及所述接收端间的连接设备,在所述发送端和所述接收端无法直接进行连接的情况下,由中转设备进行压缩图像数据的中转处理,例如:针对即时通信应用中的两个客户端,所述中转设备可以为即时通信应用的后台服务设备等。所述中转设备接收所述发送端发送的所述压缩图像数据,可以将所述压缩图像数据按照所述发送端指示的接收端的应用标识发送至所述接收端。In some examples, the relay device may be a connection device between the sending end and the receiving end, and if the sending end and the receiving end cannot directly connect, the relay device performs compressed image data. The transit processing, for example, for two clients in an instant messaging application, the relay device may be a background service device of an instant messaging application or the like. The relay device receives the compressed image data sent by the sending end, and may send the compressed image data to the receiving end according to the application identifier of the receiving end indicated by the sending end.
S2006,所述接收端接收所述中转设备发送的所述压缩图像数据,解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据。S2006, the receiving end receives the compressed image data sent by the relay device, and parses the compressed image data to obtain the picture header information data segment and the code stream data.
一些实例中,所述接收端接收所述中转设备发送的所述压缩图像数据,所述接收端可以对所述压缩图像数据进行解析处理,以获取所述压缩图像数据中的所述图片头信息数据段和所述码流数据。In some examples, the receiving end receives the compressed image data sent by the relay device, and the receiving end may perform parsing processing on the compressed image data to obtain the picture header information in the compressed image data. Data segment and the code stream data.
S2007,所述接收端解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。S2007, the receiving end decodes the code stream data to generate the YUV data, and converts the YUV data into RGB data by using a color space conversion formula.
一些实例中,所述接收端解码所述码流数据以生成所述YUV数据,并可以采用颜色空间转换公式将所述YUV数据转换为RGB数据。一些实例中,所述接收端需要依据亮度分量的值域范围确定所采用的颜色空间转换公式。In some examples, the receiving end decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data using a color space conversion formula. In some examples, the receiving end needs to determine the color space conversion formula used according to the range of values of the luminance component.
S2008,所述接收端采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新。S2008, the receiving end updates the RGB values of each pixel in the RGB data by using the global color table information.
S2009,所述接收端采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。S2009, the receiving end performs image coding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
请参见图8,为本申请实施例提供了另一种图片文件处理方法的流程示意图。本申请实施例从发送端侧阐述图片文件处理方法的具体流程,该方法可以包括以下步骤S301-步骤S303。FIG. 8 is a schematic flowchart diagram of another method for processing a picture file according to an embodiment of the present application. The embodiment of the present application describes a specific process of the image file processing method from the sending end side, and the method may include the following steps S301-S303.
S301,根据原始图片文件生成所述图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据。S301. Generate a picture header information data segment of the picture file according to the original picture file, and convert each frame image in the picture file into YUV data.
一些实例中,发送端可以解码原始图片文件以生成所述图片文件的图片头信息数据段。所述发送端进一步将所述图片文件中每帧图像转换为YUV数据。In some examples, the sender may decode the original picture file to generate a picture header information data segment of the picture file. The transmitting end further converts each frame image in the picture file into YUV data.
S302,对所述YUV数据进行编码以生成码流数据。S302. Encode the YUV data to generate code stream data.
一些实例中,所述发送端可以进一步对所述YUV数据进行编码处 理,生成码流数据。In some examples, the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
S303,将压缩图像数据发送至接收端。S303. Send compressed image data to the receiving end.
所述接收端解码所述码流数据以生成所述YUV数据,并基于图片头信息数据段中的时延信息、总帧数、全局颜色表信息等对所述YUV数据进行编码处理以生成所述图片文件。The receiving end decodes the code stream data to generate the YUV data, and performs encoding processing on the YUV data based on delay information, total frame number, global color table information, and the like in a picture header information data segment to generate a Said picture file.
在本申请实施例中,在对原始的图片文件进行解码后获得图片文件的图片头信息数据段,将图片文件中每帧图像转换为YUV数据,再基于YUV数据进行编码后得到的码流数据以及图片头信息数据段生成压缩图像数据,并将压缩图像数据进行传输,在接收到压缩图像数据时,可以解码码流数据生成YUV数据,再基于图片头信息数据段对YUV数据进行编码处理生成图片文件。通过将文件数据量较大的图片文件中每帧图像转换为数据量较小的YUV数据,再对YUV数据编码得到码流数据,极大的缩小了图片文件在传输过程中的文件数据量,降低了带宽成本。In the embodiment of the present application, after the original picture file is decoded, the picture header information data segment of the picture file is obtained, and each frame image in the picture file is converted into YUV data, and then the code stream data obtained by encoding based on the YUV data is obtained. And the picture header information data segment generates compressed image data, and the compressed image data is transmitted. When the compressed image data is received, the code stream data can be decoded to generate YUV data, and then the YUV data is encoded and processed based on the picture header information data segment. Image file. By converting each image of the image file with a large amount of file data into YUV data with a small amount of data, and then encoding the YUV data to obtain the code stream data, the amount of file data in the transmission process of the image file is greatly reduced. Reduced bandwidth costs.
请参见图9,为本申请实施例提供了又一种图片文件处理方法的流程示意图。本申请实施例从发送端侧阐述图片文件处理方法的具体流程,该方法可以包括以下步骤S401-步骤S404。FIG. 9 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application. The embodiment of the present application describes a specific process of the image file processing method from the sending end side, and the method may include the following steps S401-S404.
S401,解码原始图片文件以生成图片文件的图片头信息数据段以及图片文件中每帧图像对应的RGB数据。S401. Decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
一些实例中,所述发送端可以解码原始图片文件以生成所述图片文件的图片头信息数据段以及所述图片文件中每帧图像对应的RGB数据。In some examples, the transmitting end may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
S402,采用颜色空间转换公式将所述RGB数据转换为YUV数据。S402, converting the RGB data into YUV data by using a color space conversion formula.
一些实例中,所述发送端可以采用颜色空间转换公式将所述RGB数据转换为YUV数据。In some examples, the transmitting end may convert the RGB data into YUV data using a color space conversion formula.
S403,对所述YUV数据进行编码以生成码流数据。S403. Encode the YUV data to generate code stream data.
一些实例中,所述发送端可以进一步对所述YUV数据进行编码处理,生成码流数据。In some examples, the transmitting end may further perform encoding processing on the YUV data to generate code stream data.
S404,将压缩图像数据发送至接收端。S404. Send compressed image data to the receiving end.
请参见图10,为本申请实施例提供了一种压缩图像数据生成的举例示意图。如图10所示,在解码原始图片文件时,可以获取所述图片文件的延时信息、总帧数、全局颜色表信息等,所述延时信息记录有所述图片文件中每帧图像之间的播放间隔时间,所述总帧数为所述图片文件中的图像帧数,可以理解的是,所述图片头信息数据段中还可以包括所述图片文件的全局颜色表信息,所述全局颜色表信息包含每帧图像的每个像素点的RGB值,针对一些图片文件,其包含的所有图像均共用一个全局颜色表信息,而对于另外一些图片文件,其每帧图像都存在各自的局部颜色表信息,因此若所述图片文件中存在全局颜色表信息,则获取该全局颜色表信息,若所述图片文件中仅存在局部颜色表信息,则不对局部颜色表信息进行获取。可以对所述图片文件的延时信息、总帧数、全局颜色表信息等进行封装,以生成所述图片文件的图片头信息数据段。同时解码所述图片文件还可以获取图片文件中每帧图像对应的RGB数据可以采用颜色空间转换公式将所述RGB数据转换为YUV数据,通过颜色空间转换公式可以对每帧图像的像素点进行光栅扫描处理,将每帧RGB数据转换为对应的YUV数据。可以进一步对所述YUV数据进行编码处理,生成码流数据,所述编码可以包括预测编码、变换编码、量化编码和熵编码。在对所述YUV数据进行编码过程中,可以支持用户添加配置参数,还可以支持用户添加编码器复杂度。最终可以生成压缩图像数据。FIG. 10 is a schematic diagram of an example of generating compressed image data according to an embodiment of the present application. As shown in FIG. 10, when the original picture file is decoded, delay information, total number of frames, global color table information, and the like of the picture file may be acquired, and the delay information is recorded in each frame of the picture file. The interval between the playback time and the total number of frames is the number of image frames in the picture file. It can be understood that the picture header information data segment may further include global color table information of the picture file, The global color table information contains the RGB values of each pixel of each frame of image. For some image files, all the images contained in it share a global color table information, and for other image files, each frame image has its own The local color table information is obtained. Therefore, if the global color table information exists in the image file, the global color table information is acquired. If only the local color table information exists in the image file, the local color table information is not acquired. The delay information, the total number of frames, the global color table information, and the like of the picture file may be encapsulated to generate a picture header information data segment of the picture file. Simultaneously decoding the picture file can also obtain RGB data corresponding to each frame image in the picture file. The RGB data can be converted into YUV data by using a color space conversion formula, and the pixel of each frame image can be rastered by a color space conversion formula. The scanning process converts each frame of RGB data into corresponding YUV data. The YUV data may be further subjected to encoding processing to generate code stream data, which may include predictive coding, transform coding, quantization coding, and entropy coding. In the process of encoding the YUV data, the user can be added to add configuration parameters, and the user can also add encoder complexity. Finally, compressed image data can be generated.
请参见图11,为本申请实施例提供了又一种图片文件处理方法的流 程示意图。本申请实施例从接收端侧阐述图片文件处理方法的具体流程,该方法可以包括以下步骤S501和步骤S502。Referring to FIG. 11, a flow chart of still another method for processing a picture file is provided in the embodiment of the present application. The embodiment of the present application describes a specific process of the image file processing method from the receiving end side, and the method may include the following steps S501 and S502.
S501,接收发送端发送的针对原始图片文件的压缩图像数据,解析所述压缩图像数据以获取图片文件的图片头信息数据段和码流数据。S501. Receive compressed image data for the original picture file sent by the sending end, and parse the compressed image data to obtain a picture header information data segment and code stream data of the picture file.
一些实例中,发送端可以解码原始图片文件以生成所述图片文件的图片头信息数据段。所述发送端进一步将所述图片文件中每帧图像转换为YUV数据。In some examples, the sender may decode the original picture file to generate a picture header information data segment of the picture file. The transmitting end further converts each frame image in the picture file into YUV data.
所述发送端可以进一步对所述YUV数据进行编码处理,生成码流数据。The transmitting end may further perform encoding processing on the YUV data to generate code stream data.
S502,根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。S502. Generate the YUV data according to the code stream data, and process the YUV data according to the picture header information data segment to generate the picture file.
请参见图12,为本申请实施例提供了又一种图片文件处理方法的流程示意图。本申请实施例从接收端侧阐述图片文件处理方法的具体流程,该方法可以包括以下步骤S601-步骤S604。FIG. 12 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application. The embodiment of the present application describes a specific process of the image file processing method from the receiving end side, and the method may include the following steps S601-S604.
S601,接收发送端发送的针对原始图片文件的压缩图像数据,解析所述压缩图像数据以获取图片文件的图片头信息数据段和码流数据。S601. Receive compressed image data sent by the sending end for the original picture file, and parse the compressed image data to obtain a picture header information data segment and code stream data of the picture file.
一些实例中,所述发送端可以解码原始图片文件以生成所述图片文件的图片头信息数据段以及所述图片文件中每帧图像对应的RGB数据。In some examples, the transmitting end may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
所述发送端可以采用颜色空间转换公式将所述RGB数据转换为YUV数据。The transmitting end may convert the RGB data into YUV data by using a color space conversion formula.
所述发送端可以进一步对所述YUV数据进行编码处理,生成码流数据。The transmitting end may further perform encoding processing on the YUV data to generate code stream data.
S602,解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。S602. Decode the code stream data to generate the YUV data, and convert the YUV data into RGB data by using a color space conversion formula.
一些实例中,所述接收端解码所述码流数据以生成所述YUV数据, 并可以采用颜色空间转换公式将所述YUV数据转换为RGB数据。一些实例中,所述接收端需要依据亮度分量的值域范围确定所采用的颜色空间转换公式。In some examples, the receiving end decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data using a color space conversion formula. In some examples, the receiving end needs to determine the color space conversion formula used according to the range of values of the luminance component.
S603,采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新。S603, using the global color table information to update the RGB values of each pixel in the RGB data.
S604,采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。S604. Perform image coding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
一些实例中,所述接收端采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。在一些实例中,所述接收端可以基于所述延时时间和所述总帧数,并采用LZW对所述RGB数据中各像素点的颜色索引进行图像编码,生成所述图片文件,所述接收端可以对所述图片文件进行存储或者展示。In some examples, the receiving end performs image encoding on the updated RGB data by using the delay time and the total number of frames to generate the picture file. In some examples, the receiving end may perform image coding on a color index of each pixel in the RGB data by using an LZW based on the delay time and the total number of frames to generate the picture file. The receiving end may store or display the picture file.
请参见图13,为本申请实施例提供了一种图片文件生成的举例示意图。如图13所示,在获取压缩图像数据时,可以解析所述压缩图像数据,获取所述压缩图像数据中的图片头信息数据段和码流数据,所述图片头信息数据段中可以包含延时信息、总帧数、全局颜色表信息等,所述延时信息记录有所述图片文件中每帧图像之间的播放间隔时间,所述总帧数为所述图片文件中的图像帧数。所述全局颜色表信息包含每帧图像的每个像素点的RGB值。针对一些图片文件,其包含的所有图像均共用一个全局颜色表信息。而对于另外一些图片文件,其每帧图像都存在各自的局部颜色表信息,因此若所述图片文件中存在全局颜色表信息,则图片头信息数据段中存在全局颜色表信息。若所述图片文件中仅存在局部颜色表信息,则图片头信息数据段中不存在局部颜色表信息。可以解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。若当前处理的RGB数据为所述 图片文件中的第一帧RGB数据,则判断图片头信息数据段中是否存在全局颜色表信息。若存在,则采用所述RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。若不存在全局颜色表信息,则可以生成初始化颜色表信息,采用所述RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。若当前处理的RGB数据为所述图片文件中的第N帧RGB数据,其中N为大于1的正整数,则可以采用所述RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。最终采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。FIG. 13 is a schematic diagram of an example of generating a picture file according to an embodiment of the present application. As shown in FIG. 13, when the compressed image data is acquired, the compressed image data may be parsed to obtain a picture header information data segment and code stream data in the compressed image data, where the picture header information data segment may include extension Time information, total number of frames, global color table information, etc., the delay information records a play interval between each frame of the picture file, and the total number of frames is the number of image frames in the picture file . The global color table information contains RGB values for each pixel of each frame of image. For some image files, all the images it contains share a global color table information. For other picture files, each frame image has its own local color table information. Therefore, if there is global color table information in the picture file, the global color table information exists in the picture header information data segment. If only the local color table information exists in the picture file, the local color table information does not exist in the picture header information data segment. The code stream data may be decoded to generate the YUV data, and the YUV data is converted to RGB data using a color space conversion formula. If the currently processed RGB data is the first frame RGB data in the picture file, it is determined whether there is global color table information in the picture header information data segment. If present, the global color table information is trained to generate local color table information of the RGB data by using RGB values of each pixel in the RGB data, and the local color table information of the RGB data is used. The RGB values of the respective pixel points are updated. If there is no global color table information, the initialization color table information may be generated, and the initialization color table information is trained by using the RGB values of the pixels in the RGB data to generate local color table information of the RGB data, and adopted The local color table information of the RGB data updates the RGB values of the respective pixel points. If the currently processed RGB data is the Nth frame RGB data in the picture file, where N is a positive integer greater than 1, the RGB value of each pixel in the RGB data may be used to the RGB frame of the N-1th frame. The local color table information of the data is trained to generate local color table information of the RGB data, and the RGB values of the respective pixel points are updated using local color table information of the RGB data. Finally, the updated RGB data is image-encoded by using the delay time and the total number of frames to generate the picture file.
请参见图14,为本申请实施例提供了又一种图片文件处理方法的流程示意图。如图14所示,本申请实施例中的图片文件处理设备可以为分布式服务设备,或者可以为分布式服务设备中的图像处理模块,本申请实施例的所述方法可以包括以下步骤S701-步骤S705。FIG. 14 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application. As shown in FIG. 14 , the picture file processing device in the embodiment of the present application may be a distributed service device, or may be an image processing module in a distributed service device. The method in this embodiment may include the following step S701- Step S705.
S701,根据原始图片文件生成图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据。S701. Generate a picture header information data segment of the picture file according to the original picture file, and convert each frame image in the picture file into YUV data.
一些实例中,图片文件处理设备可以解码原始图片文件以生成所述图片文件的图片头信息数据段。所述图片文件处理设备进一步将所述图片文件中每帧图像转换为YUV数据。In some examples, the picture file processing device can decode the original picture file to generate a picture header information data segment of the picture file. The picture file processing device further converts each frame image in the picture file into YUV data.
S702,对所述YUV数据进行编码以生成码流数据。S702. Encode the YUV data to generate code stream data.
一些实例中,所述图片文件处理设备可以进一步对所述YUV数据进行编码处理,生成码流数据,所述编码可以包括预测编码、变换编码、量化编码和熵编码,例如:所述图片文件处理设备可以采用IPPP模式对所述YUV数据进行压缩,第一帧YUV数据为I帧,I帧即为帧内预测帧,其余帧YUV数据为P帧,P帧即为帧间预测帧,可以有效的压缩图片文件的文件数据量,还可以采用固定QP的方式来稳定不同帧之间的质量等。熵编码则可以包括哈夫曼编码、算数编码等。In some examples, the picture file processing apparatus may further perform encoding processing on the YUV data to generate code stream data, where the encoding may include predictive coding, transform coding, quantization coding, and entropy coding, for example, the picture file processing. The device may compress the YUV data by using an IPPP mode. The YUV data of the first frame is an I frame, the I frame is an intra prediction frame, and the remaining frame YUV data is a P frame, and the P frame is an inter prediction frame, which can be effective. The amount of file data in the compressed image file can also be fixed in a QP manner to stabilize the quality between different frames. The entropy coding may include Huffman coding, arithmetic coding, and the like.
S703,存储压缩图像数据。S703, storing compressed image data.
一些实例中,所述图片文件处理设备可以生成压缩图像数据,所述图片文件处理设备可以对所述压缩图像数据进行存储,所述压缩图像数据包含所述图片头信息数据段和所述码流数据。In some examples, the picture file processing device may generate compressed image data, and the picture file processing device may store the compressed image data, the compressed image data including the picture header information data segment and the code stream data.
S704,解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据。S704. Parse the compressed image data to obtain the picture header information data segment and the code stream data.
一些实例中,所述图片文件处理设备可以对所述压缩图像数据进行解析处理,以获取所述压缩图像数据中的所述图片头信息数据段和所述码流数据。In some examples, the picture file processing device may perform parsing processing on the compressed image data to obtain the picture header information data segment and the code stream data in the compressed image data.
S705,根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行编码处理以生成所述图片文件。S705. Generate the YUV data according to the code stream data, and perform encoding processing on the YUV data based on the picture header information data segment to generate the picture file.
一些实例中,所述图片文件处理设备解码所述码流数据以生成所述YUV数据,并基于图片头信息数据段中的时延信息、总帧数、全局颜色表信息等对所述YUV数据进行编码处理以生成所述图片文件。In some examples, the picture file processing device decodes the code stream data to generate the YUV data, and based on the delay information, the total number of frames, the global color table information, and the like in the picture header information data segment, the YUV data. An encoding process is performed to generate the picture file.
在本申请实施例中,根据原始的图片文件生成图片文件的图片头信息数据段,将图片文件中每帧图像转换为YUV数据,再基于YUV数据进行编码后得到的码流数据以及图片头信息数据段生成压缩图像数据,并将压缩图像数据进行存储,在获取到压缩图像数据时,可以根据码流 数据生成YUV数据,再基于图片头信息数据段对YUV数据进行处理生成图片文件。通过将文件数据量较大的图片文件中每帧图像转换为数据量较小的YUV数据,再对YUV数据编码得到码流数据,极大的缩小了图片文件在传输过程中的文件数据量,降低了存储成本。In the embodiment of the present application, the picture header information data segment of the picture file is generated according to the original picture file, and each frame image in the picture file is converted into YUV data, and then the code stream data and the picture header information obtained by encoding according to the YUV data are obtained. The data segment generates compressed image data, and stores the compressed image data. When the compressed image data is acquired, YUV data may be generated according to the code stream data, and the YUV data is processed based on the image header information data segment to generate a picture file. By converting each image of the image file with a large amount of file data into YUV data with a small amount of data, and then encoding the YUV data to obtain the code stream data, the amount of file data in the transmission process of the image file is greatly reduced. Reduced storage costs.
请参见图15,为本申请实施例提供了又一种图片文件处理方法的流程示意图。如图15所示,本申请实施例中的图片文件处理设备可以为分布式服务设备,或者可以为分布式服务设备中的图像处理模块,本申请实施例具体阐述了将图片文件压缩为压缩图像数据的过程,所述方法可以包括以下步骤S801-步骤S807。FIG. 15 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application. As shown in FIG. 15 , the picture file processing device in the embodiment of the present application may be a distributed service device, or may be an image processing module in a distributed service device. The embodiment of the present application specifically describes compressing a picture file into a compressed image. The process of data, the method may include the following steps S801 to S807.
S801,解码原始图片文件。S801. Decode the original picture file.
S802,判断所述图片文件的颜色表信息是否为所述图片文件的全局颜色表信息。S802. Determine whether the color table information of the picture file is global color table information of the picture file.
一些实例中,所述图片文件处理设备可以解码原始图片文件,可以理解的是,所述全局颜色表信息包含所述图片文件中每帧图像的每个像素点的RGB值,针对一些图片文件,其包含的所有图像均共用一个全局颜色表信息,而对于另外一些图片文件,其每帧图像都存在各自的局部颜色表信息,所述图片文件处理设备可以进一步判断所述图片文件中的颜色表信息是否为所述图片文件的全局颜色表信息,若是,则转入执行步骤S803。若否,则转入执行步骤S804。In some examples, the picture file processing device may decode the original picture file. It may be understood that the global color table information includes RGB values of each pixel of each frame image in the picture file, for some picture files, All the images contained in the image share a global color table information, and for other image files, each frame image has its own local color table information, and the image file processing device can further determine the color table in the image file. Whether the information is the global color table information of the picture file, and if yes, proceeds to step S803. If no, the process proceeds to step S804.
S803,生成包含延时信息、总帧数、全局颜色表信息的图片头信息数据段以及图片文件中每帧图像对应的RGB数据。S803. Generate a picture header information data segment including delay information, a total number of frames, and global color table information, and RGB data corresponding to each frame image in the picture file.
一些实例中,当判断所述图片文件的颜色表信息为所述图片文件的全局颜色表信息时,所述图片文件处理设备可以生成包含延时信息、总帧数、全局颜色表信息等的图片头信息数据段,所述延时信息记录有所 述图片文件中每帧图像之间的播放间隔时间,所述总帧数为所述图片文件中的图像帧数,同时还生成所述图片文件中每帧图像对应的RGB数据。In some examples, when it is determined that the color table information of the picture file is global color table information of the picture file, the picture file processing device may generate a picture including delay information, total number of frames, global color table information, and the like. a header information data segment, wherein the delay information records a play interval between each frame of the image file, where the total number of frames is an image frame number in the image file, and the image file is also generated The RGB data corresponding to each frame of the image.
S804,生成包含延时信息、总帧数的图片头信息数据段以及图片文件中每帧图像对应的RGB数据。S804. Generate a picture header information data segment including delay information, a total number of frames, and RGB data corresponding to each frame image in the picture file.
一些实例中,当判断所述图片文件的颜色表信息不为所述图片文件的全局颜色表信息时,所述图片文件处理设备可以生成包含延时信息、总帧数等的图片头信息数据段,所述延时信息记录有所述图片文件中每帧图像之间的播放间隔时间,所述总帧数为所述图片文件中的图像帧数,同时还生成所述图片文件中每帧图像对应的RGB数据。In some examples, when it is determined that the color table information of the picture file is not the global color table information of the picture file, the picture file processing device may generate a picture header information data segment including delay information, total number of frames, and the like. The delay information is recorded with a play interval time between each frame image in the picture file, where the total number of frames is the number of image frames in the picture file, and each frame image in the picture file is also generated. Corresponding RGB data.
S805,采用颜色空间转换公式将所述RGB数据转换为YUV数据。S805, converting the RGB data into YUV data by using a color space conversion formula.
一些实例中,所述图片文件处理设备可以采用颜色空间转换公式将所述RGB数据转换为YUV数据。In some examples, the picture file processing device may convert the RGB data into YUV data using a color space conversion formula.
S806,对所述YUV数据进行编码以生成码流数据。S806. Encode the YUV data to generate code stream data.
一些实例中,在对所述YUV数据进行编码过程中,可以支持用户添加配置参数,所述配置参数可以为对所述YUV数据进行编码的参数。所述图片文件处理设备可以采用配置参数对所述YUV数据进行编码以生成码流数据。In some examples, during encoding of the YUV data, a user may be added to add configuration parameters, which may be parameters that encode the YUV data. The picture file processing device may encode the YUV data using configuration parameters to generate code stream data.
一些实例中,在对所述YUV数据进行编码过程中,还可以支持用户添加编码器复杂度,所述编码器复杂度可以为根据所述图片文件处理设备的硬件性能所决定的编码的精细度参数。所述图片文件处理设备可以配置编码器复杂度对所述YUV数据进行编码以生成码流数据。In some examples, in encoding the YUV data, the user may also support adding encoder complexity, and the encoder complexity may be the fineness of the encoding determined according to the hardware performance of the picture file processing device. parameter. The picture file processing device may configure encoder complexity to encode the YUV data to generate code stream data.
S807,存储压缩图像数据。S807, storing compressed image data.
在本申请实施例中,根据原始的图片文件生成图片文件的图片头信息数据段,将图片文件中每帧图像转换为YUV数据,再基于YUV数据 进行编码后得到的码流数据以及图片头信息数据段生成压缩图像数据,并将压缩图像数据进行存储。通过将文件数据量较大的图片文件中每帧图像转换为数据量较小的YUV数据,再对YUV数据编码得到码流数据,极大的缩小了图片文件在存储过程中的文件数据量,降低了存储成本。In the embodiment of the present application, the picture header information data segment of the picture file is generated according to the original picture file, and each frame image in the picture file is converted into YUV data, and then the code stream data and the picture header information obtained by encoding according to the YUV data are obtained. The data segment generates compressed image data and stores the compressed image data. By converting each image in the image file with a large amount of file data into YUV data with a small amount of data, and then encoding the YUV data to obtain the code stream data, the amount of file data in the storage process of the image file is greatly reduced. Reduced storage costs.
请参见图16,为本申请实施例提供了又一种图片文件处理方法的流程示意图。如图16所示,本申请实施例中的图片文件处理设备可以为分布式服务设备,或者可以为分布式服务设备中的图像处理模块,本申请实施例具体阐述了将压缩图像数据解压为图片文件的过程,所述方法可以包括以下步骤S901-步骤S907。FIG. 16 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application. As shown in FIG. 16 , the picture file processing device in the embodiment of the present application may be a distributed service device, or may be an image processing module in a distributed service device. The embodiment of the present application specifically decompresses compressed image data into a picture. The process of the file, the method may include the following steps S901 to S907.
S901,解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据。S901. Parse the compressed image data to obtain the picture header information data segment and the code stream data.
S902,解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。S902. Decode the code stream data to generate the YUV data, and convert the YUV data into RGB data by using a color space conversion formula.
一些实例中,所述图片文件处理设备解码所述码流数据以生成所述YUV数据,并可以采用颜色空间转换公式将所述YUV数据转换为RGB数据,一些实例中,所述接收端需要依据亮度分量的值域范围确定所采用的颜色空间转换公式。In some examples, the picture file processing device decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data by using a color space conversion formula. In some examples, the receiving end needs to be based on The range of values of the luminance component determines the color space conversion formula used.
S903,判断所述图片头信息数据段中是否包含所述图片文件的全局颜色表信息。S903. Determine whether the global color table information of the picture file is included in the picture header information data segment.
一些实例中,所述图片文件处理设备判断所述图片头信息数据段中是否包含所述图片文件的全局颜色表信息,若是,则转入执行步骤S904。若否,则转入执行步骤S905。In some examples, the picture file processing device determines whether the global color table information of the picture file is included in the picture header information data segment, and if yes, proceeds to step S904. If no, the process proceeds to step S905.
由于之前对所述YUV数据进行过编码处理,因此导致由所述YUV数据转换的RGB数据存在失真的情况,所述图片文件处理设备可以采 用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新。Since the YUV data has been previously subjected to encoding processing, resulting in distortion of the RGB data converted by the YUV data, the picture file processing apparatus may use the global color table information for each of the RGB data. The RGB values of the pixels are updated.
S904,当所述RGB数据为图片文件中的第一帧图像时,采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。S904, when the RGB data is the first frame image in the picture file, the global color table information is trained by using RGB values of each pixel in the RGB data to generate local color table information of the RGB data, and adopting The local color table information of the RGB data updates the RGB values of the respective pixels.
一些实例中,针对图片头信息数据段中存在全局颜色表信息的情况,当所述RGB数据为所述图片文件中的第一帧图像,所述图片文件处理设备可以采用所述RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。In some examples, for the case where the global color table information exists in the picture header information data segment, when the RGB data is the first frame image in the picture file, the picture file processing device may adopt the RGB data. The RGB values of the respective pixels train the global color table information to generate local color table information of the RGB data, and update the RGB values of the respective pixel points by using the local color table information of the RGB data.
一些实例中,当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,所述图片文件处理设备可以将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式(例如:升序、降序等)进行排序,以生成训练颜色表信息。In some examples, when the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the picture file processing device may use the global color table. At least one source RGB value in the information is sorted according to a preset ordering of the G components (eg, ascending, descending, etc.) to generate training color table information.
所述图片文件处理设备在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取所述第一源RGB值的第一颜色索引。The picture file processing device acquires, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquires the first value of the first source RGB value. Color index.
所述图片文件处理设备在所述训练颜色表信息中以所述第一颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第二源RGB值,并获取所述第二源RGB值的第二颜色索引,可以理解的是,所述图片文件处理设备可以以所述第一颜色索引为中心,在所述第一颜色索引的前后预设范围内获取多个源RGB值,并分别计算所述第一源RGB值以及所述多个源RGB值与所述当前像素点的RGB值 的误差,并将多个源RGB值中误差最小的源RGB值确定为第二源RGB值。The image file processing device acquires, in a preset range centered on the first color index in the training color table information, a second source RGB value that has the smallest error with the RGB value of the current pixel point, and acquires The second color index of the second source RGB value, it may be understood that the picture file processing device may be centered on the first color index, and acquire multiple times in a preset range before and after the first color index. Source RGB values, and respectively calculating the first source RGB value and the error of the plurality of source RGB values and the RGB value of the current pixel point, and determining the source RGB value that minimizes the error among the plurality of source RGB values Is the second source RGB value.
所述图片文件处理设备将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第二颜色索引为中心的预设范围内的多个源RGB值进行修改。The picture file processing device replaces the second source RGB value with the RGB value of the current pixel point, and adopts a preset weight value and an RGB value of the current pixel point, and the training color table information is The second color index is modified by a plurality of source RGB values within a preset range of the center.
当所述当前像素点不为所述RGB数据中的最后一个像素点时,例如当前像素点为图4或图5中所示的RGB数据中的第一个像素点时,所述图片文件处理设备获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,例如:将所述RGB数据中的第二个像素点作为当前像素点,对修改后得到的所述训练颜色表信息再一次进行训练。一些实例中训练过程可以参见上述训练过程的描述,在此不进行赘述。When the current pixel point is not the last pixel point in the RGB data, for example, the current pixel point is the first pixel point in the RGB data shown in FIG. 4 or FIG. 5, the picture file processing Obtaining, by the device, the training color table information obtained by the modification, using a next pixel point of the current pixel point as a current pixel point, and transferring to performing acquiring the G component and the RGB data in the training color table information The first source RGB value of the G component of the current pixel is closest to the first pixel RGB value, for example, the second pixel point in the RGB data is used as the current pixel point, and the training color table information obtained after the modification is trained again. The training process in some examples can be referred to the description of the above training process, and will not be described here.
当所述当前像素点为所述RGB数据中的最后一个像素点时,例如当前像素点为图4或图5中所示的RGB数据中的第四个像素点时,所述图片文件处理设备获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, for example, when the current pixel point is the fourth pixel point in the RGB data shown in FIG. 4 or FIG. 5, the picture file processing device Obtaining the training color table information obtained after the modification, and determining the training color table information as local color table information of the RGB data.
所述图片文件处理设备可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新,一些实例中,所述图片文件处理设备可以在所述RGB数据的局部颜色表信息中依次获取与所述各像素点相同或误差最小的源RGB值分别替换所述各像素点的RGB值,在一些实例中,所述图片文件处理设备可以将与所述各像素点相同或误差最小的源RGB值对应的颜色索引分别替换所述各像素点的RGB值,请一并参见图6,依据上述举例,所述RGB数据的第一个像素点的RGB值 为(9,9,9),在所述局部颜色表信息中与(9,9,9)误差最小的为(9,9,8),则将(9,9,8)对应的颜色索引“8”替换所述第一个像素点的RGB值,同理,第二个像素点的颜色索引为“10”,第三个像素点的颜色索引为“9”,第四个像素点的颜色索引为“6”。The picture file processing device may update the RGB values of the pixel points by using local color table information of the RGB data. In some examples, the picture file processing device may have local color table information of the RGB data. The source RGB values obtained in the same manner as the respective pixel points or the smallest error are sequentially replaced with the RGB values of the respective pixel points, and in some examples, the picture file processing device may be the same as or different from the pixel points. The color index corresponding to the smallest source RGB value replaces the RGB values of the respective pixel points respectively. Please refer to FIG. 6 . According to the above example, the RGB value of the first pixel of the RGB data is (9, 9, 9), in the partial color table information, the error with (9, 9, 9) is (9, 9, 8), and the color index "8" corresponding to (9, 9, 8) is replaced by The RGB value of the first pixel, the same reason, the color index of the second pixel is "10", the color index of the third pixel is "9", and the color index of the fourth pixel is "6". .
S905,当所述RGB数据为图片文件中的第一帧图像时,采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。S905, when the RGB data is the first frame image in the picture file, the initial color table information is trained by using the RGB values of each pixel in the RGB data to generate local color table information of the RGB data, and the RGB data is used. The local color table information updates the RGB values of the respective pixels.
一些实例中,针对图片头信息数据段中不存在全局颜色表信息的情况,当所述RGB数据为所述图片文件中的第一帧图像,所述图片文件处理设备可以采用所述RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。In some examples, for the case where there is no global color table information in the picture header information data segment, when the RGB data is the first frame image in the picture file, the picture file processing device may adopt the RGB data. The RGB values of the respective pixels are trained to initialize the color table information to generate local color table information of the RGB data, and the RGB values of the respective pixel points are updated by using the local color table information of the RGB data.
一些实例中,当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,所述图片文件处理设备可以生成一个初始化颜色表信息,例如:(0,0,0)、(1,1,1)、(2,2,2)、……、(255,255,255),所述图片文件处理设备在初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取所述第三源RGB值的第三颜色索引,所述图片文件处理设备在所述初始化颜色表信息中以所述第三颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第四源RGB值,并获取所述第四源RGB值的第四颜色索引,所述图片文件处理设备将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述初始化颜色表信息中以所述第四颜色索引为中心的预设范围内的多个源RGB值进行修 改,当所述当前像素点不为所述RGB数据中的最后一个像素点时,所述图片文件处理设备获取修改后得到的所述初始化颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值,当所述当前像素点为所述RGB数据中的最后一个像素点时,所述图片文件处理设备获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为所述RGB数据的局部颜色表信息,所述图片文件处理设备可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。需要说明的是,各实例中对初始化颜色表信息进行训练以及采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新的过程均可以参见前述方式的执行过程,在此不进行赘述。In some examples, when the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the picture file processing device may generate an initialization color table. Information such as: (0, 0, 0), (1, 1, 1), (2, 2, 2), ..., (255, 255, 255), the picture file processing device initializes the color table information Obtaining a third source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value, where the picture file processing device is Obtaining, in a preset range centered on the third color index in the color table information, obtaining a fourth source RGB value having the smallest error with the RGB value of the current pixel point, and acquiring the fourth source RGB value fourth. a color index, the picture file processing device replacing the fourth source RGB value with an RGB value of the current pixel point, and using the preset weight value and the RGB value of the current pixel point, the initialization color table a preset in the information centered on the fourth color index The plurality of source RGB values in the range are modified. When the current pixel point is not the last pixel point in the RGB data, the picture file processing device acquires the initialized color table information obtained after the modification, and The next pixel point of the current pixel point is used as the current pixel point, and is transferred to a third source RGB value that performs the closest acquisition of the G component in the initialization color table information to the G component of the current pixel point in the RGB data. And when the current pixel is the last one of the RGB data, the picture file processing device acquires the modified color table information obtained by the modification, and determines the initialization color table information as the The local color table information of the RGB data, the picture file processing device may update the RGB values of the respective pixel points by using the local color table information of the RGB data. It should be noted that the process of training the initialization color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data can refer to the execution process of the foregoing manner, and details are not described herein.
S906,当所述RGB数据为图片文件中的第N帧图像时,采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。S906, when the RGB data is the Nth frame image in the picture file, the local color table information of the N-1 frame RGB data is trained to generate the local part of the RGB data by using the RGB values of the pixels in the RGB data. The color table information is updated with the RGB values of the respective pixels using the local color table information of the RGB data.
一些实例中,当所述RGB数据为所述图片文件中的第N帧图像时,所述图片文件处理设备可以将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息,所述图片文件处理设备在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取所述第五源RGB值的第五颜色索引,所述图片文件处理设备在所述训练颜色表信息中以所述第五颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第六源RGB值,并获取所述第六源RGB值的第六颜色索引,所述图片文件处理设备将所述第六源 RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第六颜色索引为中心的预设范围内的多个源RGB值进行修改,当所述当前像素点不为所述RGB数据中的最后一个像素点时,所述图片文件处理设备获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,当所述当前像素点为所述RGB数据中的最后一个像素点时,所述图片文件处理设备获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息,所述图片文件处理设备可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。需要说明的是,各实例中对训练颜色表信息进行训练以及采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新的过程均可以参见前述方式的执行过程,在此不进行赘述。In some examples, when the RGB data is the Nth frame image in the picture file, the picture file processing device may set at least one source RGB value in the partial color table information of the N-1th frame RGB data according to Sorting the preset order of the G components to generate training color table information, wherein the picture file processing device acquires the G component in the training color table information that is closest to the G component of the current pixel point in the RGB data. a five-source RGB value, and acquiring a fifth color index of the fifth source RGB value, where the picture file processing device acquires in the preset range centered on the fifth color index in the training color table information a sixth source RGB value having a smallest error from an RGB value of the current pixel point, and acquiring a sixth color index of the sixth source RGB value, the picture file processing device replacing the sixth source RGB value with Determining an RGB value of the current pixel, and using a preset weight value and an RGB value of the current pixel, a plurality of sources in the preset range of the training color table information centered on the sixth color index RGB values are modified When the current pixel point is not the last pixel point in the RGB data, the picture file processing device acquires the modified color table information obtained after the modification, and uses the next pixel point of the current pixel point as a current pixel point, and proceeds to perform a fifth source RGB value that is obtained in the training color table information to obtain a G component closest to a G component of a current pixel point in the RGB data, when the current pixel point is the RGB When the last pixel in the data, the picture file processing device acquires the modified color table information obtained by the modification, and determines the training color table information as local color table information of the RGB data, the picture The file processing device may update the RGB values of the respective pixel points by using local color table information of the RGB data. It should be noted that the process of training the training color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data may refer to the execution process of the foregoing manner, and details are not described herein.
S907,采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。S907: Perform image coding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
一些实例中,所述图片文件处理设备采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。在一些实例中,所述图片文件处理设备可以基于所述延时时间和所述总帧数,并采用LZW对所述RGB数据中各像素点的颜色索引进行图像编码,生成所述图片文件,所述图片文件处理设备可以对所述图片文件进行存储或者展示。In some examples, the picture file processing device performs image encoding on the updated RGB data using the delay time and the total number of frames to generate the picture file. In some examples, the picture file processing device may perform image coding on a color index of each pixel in the RGB data by using an LZW based on the delay time and the total number of frames, to generate the picture file. The picture file processing device may store or display the picture file.
请参见图17,为本申请实施例提供了又一种图片文件处理方法的流程示意图。如图17所示,本申请实施例提供的图片文件处理方法为对图15所示实施例的进一步描述,所述方法包括以下步骤S1001-步骤 S1009。Referring to FIG. 17, a flowchart of still another method for processing a picture file is provided in the embodiment of the present application. As shown in FIG. 17, the image file processing method provided by the embodiment of the present application is further described with reference to the embodiment shown in FIG. 15, and the method includes the following steps S1001 to S1009.
S1001,解码原始图片文件。S1001, decoding the original picture file.
S1002,判断所述图片文件的颜色表信息是否为所述图片文件的全局颜色表信息。S1002: Determine whether the color table information of the picture file is global color table information of the picture file.
S1003,生成包含延时信息、总帧数、全局颜色表信息的图片头信息数据段以及图片文件中每帧图像对应的RGB数据。S1003: Generate a picture header information data segment including delay information, a total number of frames, and global color table information, and RGB data corresponding to each frame image in the picture file.
S1004,生成包含延时信息、总帧数的图片头信息数据段以及图片文件中每帧图像对应的RGB数据。S1004: Generate a picture header information data segment including delay information, a total number of frames, and RGB data corresponding to each frame image in the picture file.
S1005,判断所采用的配置参数是否为无损模式参数。S1005: Determine whether the adopted configuration parameter is a lossless mode parameter.
一些实例中,所述图片文件处理设备可以获取用户自定义信息数据段,所述用户自定义信息数据段可以包括配置参数及编码器复杂度等,所述配置参数可以为对所述YUV数据进行编码的参数。若获取的配置参数为无损模式参数,则可以直接对所述RGB数据进行编码生成码流数据,若获取的配置参数为标清模式参数或者高清模式参数,则需要将RGB数据转换为YUV数据,再对所述YUV数据进行编码以生成码流数据。一些实例中,所述图片文件处理设备可以判断用户自定义信息数据段中所采用的配置参数是否为无损模式参数,若是,则转入执行步骤S1006。若否,则转入执行步骤S1007-S1008。In some examples, the picture file processing device may obtain a user-defined information data segment, where the user-defined information data segment may include configuration parameters and encoder complexity, etc., and the configuration parameter may be performed on the YUV data. Encoded parameters. If the obtained configuration parameter is a lossless mode parameter, the RGB data may be directly encoded to generate code stream data. If the acquired configuration parameter is an SD mode parameter or a HD mode parameter, the RGB data needs to be converted into YUV data, and then The YUV data is encoded to generate codestream data. In some examples, the picture file processing device may determine whether the configuration parameter used in the user-defined information data segment is a lossless mode parameter, and if yes, proceed to step S1006. If no, the process proceeds to steps S1007-S1008.
所述编码器复杂度可以为根据所述图片文件处理设备的硬件性能所决定的编码的精细度参数。The encoder complexity may be a fineness parameter of the encoding determined according to hardware performance of the picture file processing device.
S1006,对所述RGB数据进行编码生成码流数据。S1006: Encode the RGB data to generate code stream data.
一些实例中,若所述图片文件处理设备判断用户自定义信息数据段中所采用的配置参数为无损模式参数,则所述图片文件处理设备可以对所述RGB数据进行编码生成码流数据,所述编码可以包括预测编码、变换编码、量化编码和熵编码,例如:所述图片文件处理设备可以采用 IPPP模式对所述RGB数据进行压缩,第一帧RGB数据为I帧,I帧即为帧内预测帧,其余帧RGB数据为P帧,P帧即为帧间预测帧,可以有效的压缩图片文件的文件数据量,还可以采用固定QP的方式来稳定不同帧之间的质量等。熵编码则可以包括哈夫曼编码、算数编码等。In some examples, if the picture file processing device determines that the configuration parameter used in the user-defined information data segment is a lossless mode parameter, the picture file processing device may encode the RGB data to generate code stream data. The encoding may include predictive coding, transform coding, quantization coding, and entropy coding. For example, the picture file processing apparatus may compress the RGB data by using an IPPP mode, where the first frame of RGB data is an I frame, and the I frame is a frame. The intra prediction frame, the remaining frame RGB data is a P frame, and the P frame is an inter prediction frame, which can effectively compress the file data amount of the picture file, and can also use a fixed QP method to stabilize the quality between different frames. The entropy coding may include Huffman coding, arithmetic coding, and the like.
S1007,采用颜色域转换公式将所述RGB数据转换为YUV数据。S1007, converting the RGB data into YUV data by using a color domain conversion formula.
一些实例中,若所述图片文件处理设备判断用户自定义信息数据段中所采用的配置参数为无损模式参数,则所述图片文件处理设备可以采用颜色空间转换公式将所述RGB数据转换为YUV数据。In some examples, if the picture file processing device determines that the configuration parameter used in the user-defined information data segment is a lossless mode parameter, the picture file processing device may convert the RGB data into a YUV by using a color space conversion formula. data.
S1008,对所述YUV数据进行编码以生成码流数据。S1008, encoding the YUV data to generate code stream data.
S1009,将配置参数添加至图片头信息数据段中,存储压缩图像数据。S1009: Add configuration parameters to the picture header information data segment to store compressed image data.
一些实例中,所述图片文件处理设备可以将所述配置参数添加至图片头信息数据段中,一些实例中,所述图片文件处理设备可以将所述用户自定义信息数据段添加至所述图片头信息数据段中。In some examples, the picture file processing device may add the configuration parameter to a picture header information data segment. In some examples, the picture file processing device may add the user-defined information data segment to the picture. Header data segment.
其中,本申请实施例的步骤S1001-步骤S1004可以分别参见图15所示实施例的步骤S801-步骤S804的具体描述,在此不进行赘述。The steps S1001 to S1004 of the embodiment of the present application may refer to the detailed description of the steps S801 to S804 of the embodiment shown in FIG. 15 respectively, and details are not described herein.
在本申请实施例中,根据原始的图片文件生成图片文件的图片头信息数据段,将图片文件中每帧图像转换为YUV数据,再基于YUV数据进行编码后得到的码流数据以及图片头信息数据段生成压缩图像数据,并将压缩图像数据进行存储。通过将文件数据量较大的图片文件中每帧图像转换为数据量较小的YUV数据,再对YUV数据编码得到码流数据,极大的缩小了图片文件在存储过程中的文件数据量,降低了存储成本。通过加入用户自定义的配置参数,可以依据不同的配置参数实现不同清晰程度的编码过程,提升了用户体验。In the embodiment of the present application, the picture header information data segment of the picture file is generated according to the original picture file, and each frame image in the picture file is converted into YUV data, and then the code stream data and the picture header information obtained by encoding according to the YUV data are obtained. The data segment generates compressed image data and stores the compressed image data. By converting each image in the image file with a large amount of file data into YUV data with a small amount of data, and then encoding the YUV data to obtain the code stream data, the amount of file data in the storage process of the image file is greatly reduced. Reduced storage costs. By adding user-defined configuration parameters, different coding levels can be achieved according to different configuration parameters, which improves the user experience.
请参见图18,为本申请实施例提供了又一种图片文件处理方法的流程示意图。如图18所示,本申请实施例提供的图片文件处理方法为对图16所示实施例的进一步描述,所述方法包括以下步骤S1101-步骤S1112。FIG. 18 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application. As shown in FIG. 18, the picture file processing method provided by the embodiment of the present application is further described with reference to the embodiment shown in FIG. 16, and the method includes the following steps S1101-step S1112.
S1101,解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据。S1101: Parse the compressed image data to obtain the picture header information data segment and the code stream data.
在一些实例中,所述图片头信息数据段还可以包括用户自定义信息数据段,所述用户自定义信息数据段可以包括配置参数及编码器复杂度等,所述配置参数可以为先前对所述YUV数据进行编码的参数,所述配置参数可以包括标清模式参数、高清模式参数和无损模式参数中的任一种。所述编码器复杂度可以为根据发送端的硬件性能所决定的编码的精细度参数,所述编码器复杂度可以包括第一复杂度、第二复杂度和第三复杂度中的任一种,所述第一复杂度高于所述第二复杂度,所述第二复杂度高于所述第三复杂度。In some examples, the picture header information data segment may further include a user-defined information data segment, where the user-defined information data segment may include a configuration parameter, an encoder complexity, and the like, and the configuration parameter may be a previous The parameters for encoding the YUV data, the configuration parameters may include any one of an SD mode parameter, a HD mode parameter, and a lossless mode parameter. The encoder complexity may be a fineness parameter of the encoding determined according to hardware performance of the transmitting end, and the encoder complexity may include any one of a first complexity, a second complexity, and a third complexity. The first complexity is higher than the second complexity, and the second complexity is higher than the third complexity.
需要说明的是,上述的性能数值、第一预设数值范围、第二通预设数值范围以及第三预设数值范围具体可以根据开发人员的人为经验进行设定。It should be noted that the above performance value, the first preset value range, the second pass preset value range, and the third preset value range may be specifically set according to the developer's human experience.
S1102,判断图片头信息数据段中的配置参数是否为无损模式参数。S1102: Determine whether the configuration parameter in the data segment of the picture header information is a lossless mode parameter.
一些实例中,所述图片文件处理设备可以判断图片头信息数据段中的配置参数是否为无损模式参数,若是,则转入执行步骤S1103。若否,则转入执行步骤S1104-S1107。In some examples, the picture file processing device may determine whether the configuration parameter in the picture header information data segment is a lossless mode parameter, and if yes, proceed to step S1103. If no, the process proceeds to steps S1104-S1107.
S1103,解码所述码流数据以生成RGB数据。S1103. Decode the code stream data to generate RGB data.
一些实例中,若所述图片头信息数据段中的配置参数为无损模式参数,由于在无损模式下,是直接对RGB数据进行编码生成的码流数据,因此所述图片文件处理设备可以解码所述码流数据直接生成RGB数据。In some examples, if the configuration parameter in the data segment of the picture header information is a lossless mode parameter, the picture file processing device can decode the code stream data generated by directly encoding the RGB data in the lossless mode. The code stream data directly generates RGB data.
S1104,判断配置参数是否为YUV444模式参数。S1104: Determine whether the configuration parameter is a YUV444 mode parameter.
一些实例中,若所述图片头信息数据段中的配置参数不为无损模式参数,即所述图片头信息数据段中的配置参数为标清模式参数或者高清模式参数,可以理解的是,所述标清模式参数优选为YUV420模式参数,所述高清模式参数优选为YUV444模式参数。所述图片文件处理设备可以进一步判断所述配置参数是否为YUV444模式参数,若是,则转入执行步骤S1105。若否,则转入执行步骤S1106-S1107。In some examples, if the configuration parameter in the data segment of the picture header information is not a lossless mode parameter, that is, the configuration parameter in the data segment of the picture header information is an SD mode parameter or a HD mode parameter, it can be understood that the The standard definition mode parameter is preferably a YUV420 mode parameter, and the high definition mode parameter is preferably a YUV444 mode parameter. The picture file processing device may further determine whether the configuration parameter is a YUV444 mode parameter, and if yes, proceed to step S1105. If no, the process proceeds to steps S1106-S1107.
S1105,解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。S1105: Decode the code stream data to generate the YUV data, and convert the YUV data into RGB data by using a color space conversion formula.
一些实例中,若所述图片文件处理设备判断所述配置参数为YUV444模式参数,即在对YUV数据进行编码时,完整保留了YUV数据中各像素点的亮度分量及色度分量,因此所述图片文件处理设备解码所述码流数据直接生成所述YUV数据,需要说明的是,色度包括Cb和Cr两种色差信号中的任一种的样值矩阵和单个样值。两种色差信号需要分别进行上采样处理,两者进行上采样处理的方式均相同,其中,Cb对应YUV中的U,Cr对应YUV中的V,YUV数据由Y图像、Cb图像和Cr图像组成。所述图片文件处理设备采用颜色空间转换公式将所述YUV数据转换为RGB数据。In some examples, if the picture file processing device determines that the configuration parameter is a YUV444 mode parameter, that is, when encoding the YUV data, the luminance component and the chrominance component of each pixel in the YUV data are completely retained, so The picture file processing device decodes the code stream data to directly generate the YUV data. It should be noted that the chrominance includes a sample matrix and a single sample of any one of Cb and Cr color difference signals. The two color difference signals need to be separately upsampled, and the two methods of upsampling are the same. Among them, Cb corresponds to U in YUV, Cr corresponds to V in YUV, and YUV data consists of Y image, Cb image and Cr image. . The picture file processing device converts the YUV data into RGB data using a color space conversion formula.
S1106,执行色度分量上采样处理。S1106, performing chroma component upsampling processing.
一些实例中,若所述图片文件处理设备判断所述配置参数不为YUV444模式参数,即在对YUV数据进行编码时,仅保留了YUV数据中各像素点的亮度分量,但对YUV数据中各像素点的色度分量进行了压缩,例如:在采用YUV420模式参数对所述YUV数据进行编码的过程中,可以将YUV数据中上下左右相邻的四个像素点的色度分量压缩为一个色度分量。因此所述图片文件处理设备需要解码所述码流数据以 生成所述YUV数据,并对所述YUV数据执行色度分量上采样处理,即将一个色度分量还原为四个像素点的色度分量的处理。需要说明的是,色度包括Cb和Cr两种色差信号中的任一种的样值矩阵和单个样值。两种色差信号需要分别进行上采样处理,两者进行上采样处理的方式均相同,其中,Cb对应YUV中的U,Cr对应YUV中的V,YUV数据由Y图像、Cb图像和Cr图像组成。下面将结合YUV420模式中的Cb图像进行说明。In some examples, if the picture file processing device determines that the configuration parameter is not a YUV444 mode parameter, that is, when encoding the YUV data, only the luminance component of each pixel in the YUV data is retained, but for each of the YUV data. The chrominance component of the pixel is compressed. For example, in the process of encoding the YUV data by using the YUV420 mode parameter, the chrominance components of the four pixels adjacent to each other in the YUV data can be compressed into one color. Degree component. Therefore, the picture file processing apparatus needs to decode the code stream data to generate the YUV data, and perform chroma component upsampling processing on the YUV data, that is, restore one chroma component to a chroma component of four pixel points. Processing. It should be noted that the chromaticity includes a sample matrix and a single sample of any one of Cb and Cr color difference signals. The two color difference signals need to be separately upsampled, and the two methods of upsampling are the same. Among them, Cb corresponds to U in YUV, Cr corresponds to V in YUV, and YUV data consists of Y image, Cb image and Cr image. . The following description will be made in conjunction with the Cb image in the YUV420 mode.
请一并参见图19和图20,如图19所示,为压缩后的Cb图像,即源Cb图像,包含(H*K)个像素点,由于配置参数为YUV420模式参数,因此需要采用上采样算法将包含(H*K)个像素点的源Cb图像还原为如图20所示的包含(2H*2K)个像素点的目标Cb图像,其中src(x,y)表示源Cb图像中的像素点,dst(x,y)表示目标Cb图像中的像素点,所述上采样算法可以包括:Please refer to FIG. 19 and FIG. 20 together. As shown in FIG. 19, the compressed Cb image, that is, the source Cb image, contains (H*K) pixels. Since the configuration parameter is the YUV420 mode parameter, it is necessary to adopt The sampling algorithm restores the source Cb image containing (H*K) pixels to a target Cb image containing (2H*2K) pixels as shown in FIG. 20, where src(x, y) represents the source Cb image. a pixel, dst(x, y) represents a pixel in the target Cb image, and the upsampling algorithm may include:
(1)针对dst(x,y)属于目标Cb图像中非边界像素点,非边界像素点每个上采样的Cb值由源Cb图像对应位置相邻四个像素点的Cb值共同决定。具体计算规则如下:(1) For dst(x, y) belonging to a non-boundary pixel in the target Cb image, the Cb value of each upsampled non-boundary pixel is determined by the Cb value of four adjacent pixels of the corresponding position of the source Cb image. The specific calculation rules are as follows:
dst(2x,2y)=Clip3(0,255,(src(x-1,y-1)+3*src(x,y-1)+3*src(x-1,y)+9*src(x,y)+8)>>4)。Dst(2x,2y)=Clip3(0,255,(src(x-1,y-1)+3*src(x,y-1)+3*src(x-1,y)+9*src (x, y) + 8) >> 4).
dst(2x-1,2y)=Clip3(0,255,(3*src(x-1,y-1)+src(x,y-1)+9*src(x-1,y)+3*src(x,y)+8)>>4)。Dst(2x-1,2y)=Clip3(0,255,(3*src(x-1,y-1)+src(x,y-1)+9*src(x-1,y)+3 *src(x,y)+8)>>4).
dst(2x,2y-1)=Clip3(0,255,(3*src(x-1,y-1)+9*src(x,y-1)+src(x-1,y)+3*src(x,y)+8)>>4)。Dst(2x,2y-1)=Clip3(0,255,(3*src(x-1,y-1)+9*src(x,y-1)+src(x-1,y)+3 *src(x,y)+8)>>4).
dst(2x-1,2y-1)=Clip3(0,255,(9*src(x-1,y-1)+3*src(x,y-1)+3*src(x-1,y)+src(x,y)+8)>>4)。Dst(2x-1,2y-1)=Clip3(0,255,(9*src(x-1,y-1)+3*src(x,y-1)+3*src(x-1, y) + src(x, y) + 8) >> 4).
其中,0<x<W,0<y<H,“+8”用于对Cb值进行四舍五入, “>>4”用于对公式中的加权值(1+3+3+9)进行清除,即表示除以2的4次方。Where 0<x<W, 0<y<H, “+8” is used to round off the Cb value, and “>>4” is used to clear the weighted value (1+3+3+9) in the formula. That means dividing by the 4th power of 2.
(2)针对dst(x,y)属于目标Cb图像中的角点,目标Cb图像中的角点的Cb值由源Cb图像中的角点的Cb值决定。具体计算规则如下:(2) For dst(x, y) belonging to a corner point in the target Cb image, the Cb value of the corner point in the target Cb image is determined by the Cb value of the corner point in the source Cb image. The specific calculation rules are as follows:
dst(0,0)=src(0,0)。Dst(0,0)=src(0,0).
dst(0,2H-1)=src(0,H-1)。Dst(0,2H-1)=src(0, H-1).
dst(2W-1,0)=src(W-1,0)。Dst(2W-1,0)=src(W-1,0).
dst(2W-1,2H-1)=src(W-1,H-1)。Dst(2W-1, 2H-1) = src(W-1, H-1).
(3)针对dst(x,y)属于目标Cb图像的第一行中和最后一行中除角点外的像素点,目标Cb图像的第一行中和最后一行中除角点外的像素点的Cb值,由源Cb图像中的第一行中和最后一行中左右相邻的两个像素点的Cb值决定。具体计算规则如下:(3) For dst(x, y) belonging to the pixel in the first row and the last row of the target Cb image except for the corner point, the pixel in the first row and the last row of the target Cb image except the corner point The Cb value is determined by the Cb value of the two adjacent pixels in the first row and the last row in the source Cb image. The specific calculation rules are as follows:
dst(2x,0)=Clip3(0,255,(src(x-1,0)+3*src(x,0)+2)>>2)。Dst(2x,0)=Clip3(0,255,(src(x-1,0)+3*src(x,0)+2)>>2).
dst(2x-1,0)=Clip3(0,255,(3*src(x-1,0)+src(x,0)+2)>>2)。Dst(2x-1,0)=Clip3(0,255,(3*src(x-1,0)+src(x,0)+2)>>2).
dst(2x,2H-1)=Clip3(0,255,(src(x-1,2H-1)+3*src(x,2H-1)+2)>>2)。Dst(2x, 2H-1)=Clip3(0,255,(src(x-1,2H-1)+3*src(x,2H-1)+2)>>2).
dst(2x-1,2H-1)=Clip3(0,255,(3*src(x-1,2H-1)+src(x,2H-1)>>2)>>2};Dst(2x-1,2H-1)=Clip3(0,255,(3*src(x-1,2H-1)+src(x,2H-1)>>2)>>2};
其中,0<x<W,“+2”用于对Cb值进行四舍五入,“>>2”用于对公式中的加权值(1+3)进行清除,即表示除以2的2次方。Where 0<x<W, "+2" is used to round off the Cb value, and ">>2" is used to clear the weighting value (1+3) in the formula, that is, divide by 2 to the power of 2 .
(4)针对dst(x,y)属于目标Cb图像的第一列中和最后一列中除角点外的像素点,目标Cb图像的第一列中和最后一列中除角点外的像素点的Cb值,由源Cb图像中的第一列中和最后一列中上下相邻的两个像素点的Cb值决定。具体计算规则如下:(4) For dst(x, y) belonging to the pixel in the first column and the last column of the target Cb image except for the corner point, the pixel in the first column and the last column of the target Cb image except the corner point The Cb value is determined by the Cb value of two pixel points adjacent in the first column and the last column in the source Cb image. The specific calculation rules are as follows:
dst(0,2y-1)=Clip3(0,255,(src(0,y-1)+3*src(0,y)+2)>>2)。Dst(0,2y-1)=Clip3(0,255,(src(0,y-1)+3*src(0,y)+2)>>2).
dst(0,2y)=Clip3(0,255,(3*src(0,y)+src(0,y-1)+2)>>2)。Dst(0, 2y) = Clip3 (0, 255, (3 * src (0, y) + src (0, y-1) + 2) >> 2).
dst(2W-1,2y-1)=Clip3(0,255,(src(2W-1,y-1)+3*src(2W-1,y)+2)>>2)。Dst(2W-1, 2y-1)=Clip3(0,255,(src(2W-1,y-1)+3*src(2W-1,y)+2)>>2).
dst(2W-1,2y)=Clip3(0,255,(3*src(2W-1,y)+src(2W-1,y-1)+2)>>2)。Dst(2W-1, 2y)=Clip3(0,255,(3*src(2W-1,y)+src(2W-1, y-1)+2)>>2).
其中,0<y<H,“+2”用于对Cb值进行四舍五入,“>>2”用于对公式中的加权值(1+3)进行清除,即表示除以2的2次方。Where 0<y<H, "+2" is used to round off the Cb value, and ">>2" is used to clear the weighting value (1+3) in the formula, that is, divide by 2 to the power of 2 .
通过上述计算规则可以得到目标Cb图像中所有像素点的Cb值,可以理解的是,上述公式中的加权值可以依据经验值进行确定。同理,可以采用上述计算规则得到目标Cr图像中所有像素点的Cr值。以此完成对色度分量上采样处理的处理过程。The Cb value of all the pixel points in the target Cb image can be obtained by the above calculation rule. It can be understood that the weight value in the above formula can be determined according to the empirical value. Similarly, the Cr value of all pixel points in the target Cr image can be obtained by using the above calculation rule. This completes the processing of the chroma component upsampling process.
S1107,采用颜色空间转换公式将所述YUV数据转换为RGB数据。S1107: Convert the YUV data into RGB data by using a color space conversion formula.
一些实例中,所述图片文件处理设备可以采用颜色空间转换公式将所述YUV数据转换为RGB数据,一些实例中,所述图片文件处理设备需要依据亮度分量的值域范围确定所采用的颜色空间转换公式。In some examples, the picture file processing device may convert the YUV data into RGB data by using a color space conversion formula. In some examples, the picture file processing device needs to determine the color space used according to the range of values of the brightness component. Conversion formula.
S1108,判断所述图片头信息数据段中是否包含所述图片文件的全局颜色表信息。S1108. Determine whether the global color table information of the picture file is included in the picture header information data segment.
S1109,当所述RGB数据为图片文件中的第一帧图像时,采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。S1109, when the RGB data is the first frame image in the picture file, the global color table information is trained by using RGB values of each pixel in the RGB data to generate local color table information of the RGB data, and adopting The local color table information of the RGB data updates the RGB values of the respective pixels.
S1110,当所述RGB数据为图片文件中的第一帧图像时,采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。S1110, when the RGB data is the first frame image in the picture file, the initial color table information is trained by using the RGB values of each pixel in the RGB data to generate local color table information of the RGB data, and the RGB data is used. The local color table information updates the RGB values of the respective pixels.
S1111,当所述RGB数据为图片文件中的第N帧图像时,采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。S1111, when the RGB data is the Nth frame image in the picture file, the local color table information of the N-1 frame RGB data is trained to generate a partial part of the RGB data by using the RGB values of the pixels in the RGB data. The color table information is updated with the RGB values of the respective pixels using the local color table information of the RGB data.
S1112,采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。S1112: Perform image coding on the updated RGB data by using the delay time and the total number of frames to generate the picture file.
其中,本申请实施例的步骤S1108-步骤S1112可以分别参见图16所示实施例的步骤S903-步骤S907的具体描述,在此不进行赘述。The steps S1108 to S1112 of the embodiment of the present application may refer to the detailed description of the steps S903 to S907 of the embodiment shown in FIG. 16 respectively, and details are not described herein.
请参见图21A,为本申请实施例提供了又一种图片文件处理方法的流程示意图。该方法可以由计算设备执行。如图21A所示,所述方法可以包括以下步骤。FIG. 21A is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application. The method can be performed by a computing device. As shown in FIG. 21A, the method may include the following steps.
S1201A,获取第一图片文件的色彩数据,所述色彩数据包括各像素点的色彩值。S1201A: Acquire color data of the first picture file, where the color data includes color values of each pixel point.
其中,所述色彩数据可以为RGB数据、或YUV数据等。计算设备可以通过获取对第一图片文件解码生成的RGB数据,所述RGB数据包括各像素点的RGB值。The color data may be RGB data, or YUV data, or the like. The computing device can obtain RGB data generated by decoding the first picture file, the RGB data including RGB values of the respective pixel points.
S1202A,获取初始颜色表,所述初始颜色表中各色彩值按照一个色彩分量的值的预设排序方式排列。S1202A: Acquire an initial color table, wherein each color value in the initial color table is arranged according to a preset sorting manner of values of one color component.
在一些实例中,计算设备可以获取所述第一图片文件中的全局颜色表。将所述全局颜色表中的色彩值按照一个色彩分量的值进行排序,得到所述初始颜色表。In some examples, the computing device can obtain a global color table in the first picture file. The color values in the global color table are sorted according to the value of one color component to obtain the initial color table.
在一些实例中,计算设备可以将预设的多个色彩值按照一个色彩分量的值以预设排序方式排列,以生成所述初始颜色表。In some examples, the computing device can arrange the preset plurality of color values in a predetermined order by the values of one color component to generate the initial color table.
例如,所述初始颜色表可以为(0,0,0),(1,1,1),……(255,255,255)。For example, the initial color table may be (0, 0, 0), (1, 1, 1), ... (255, 255, 255).
S1203A,根据所述各像素点的色彩值中所述色彩分量的值在所述初 始颜色表中搜索各像素点在所述初始颜色表中对应的初始色彩值,利用所述初始色彩值对所述各像素点的所述色彩值进行更新。S1203A: Search, in the initial color table, a corresponding initial color value of each pixel in the initial color table according to the value of the color component in the color value of each pixel, and use the initial color value pair The color values of the respective pixel points are updated.
在一些实例中,计算设备可以在所述初始颜色表中获取所述色彩分量与所述像素点的所述色彩分量最接近的第一色彩值,并获取第一色彩值的第一颜色索引。在所述初始颜色表中以所述第一颜色索引为中心的预设范围内,获取与所述像素点的色彩值误差最小的第二色彩值作为所述初始色彩值。In some examples, the computing device can obtain a first color value of the color component that is closest to the color component of the pixel point in the initial color table, and obtain a first color index of the first color value. A second color value having the smallest error in color value of the pixel point is obtained as the initial color value in a preset range centered on the first color index in the initial color table.
在一些实例中,计算设备可以利用所述色彩数据中各像素点的色彩值和所述初始色彩值对所述初始颜色表进行修改,得到所述色彩数据对应的局部颜色表,并采用所述局部颜色表对所述各像素点的色彩值进行更新。In some examples, the computing device may modify the initial color table by using the color value of each pixel in the color data and the initial color value to obtain a partial color table corresponding to the color data, and adopt the The local color table updates the color values of the respective pixel points.
在一些实例中,计算设备可以获取所述初始色彩值的第二颜色索引。将所述初始色彩值替换为所述像素点的色彩值,并采用预设权重值和所述像素点的色彩值,对所述训练颜色表中以所述第二颜色索引为中心的预设范围内的多个色彩值进行修改。将修改后的所述初始颜色表确定为所述局部颜色表。In some examples, the computing device can obtain a second color index of the initial color value. Substituting the initial color value with a color value of the pixel point, and using a preset weight value and a color value of the pixel point, a preset centered on the second color index in the training color table Multiple color values within the range are modified. The modified initial color table is determined as the partial color table.
S1204A,将修改后的所述初始颜色表确定为所述局部颜色表。S1204A, determining the modified initial color table as the local color table.
在一些实例中,当所述色彩数据为所述原始图片文件的首帧图像的色彩数据时,计算设备可以利用所述色彩数据对所述首帧图像的初始颜色表进行训练,得到所述首帧图像对应的局部颜色表,所述首帧图像的所述初始颜色表为所述初始颜色表。当所述色彩数据为所述原始图片文件的第N帧图像的色彩数据时,计算设备可以利用所述第二色彩数据对所述第N帧图像对应的初始颜色表进行训练,得到所述第N帧图像对应的局部颜色表。其中,所述第N帧图像对应的初始颜色表为所述原始图片文件的第N-1帧图像对应的局部颜色表,N为大于1的整数。In some examples, when the color data is color data of a first frame image of the original picture file, the computing device may use the color data to train an initial color table of the first frame image to obtain the first a partial color table corresponding to the frame image, the initial color table of the first frame image being the initial color table. When the color data is the color data of the Nth frame image of the original picture file, the computing device may use the second color data to train the initial color table corresponding to the Nth frame image to obtain the A partial color table corresponding to the N frame image. The initial color table corresponding to the Nth frame image is a local color table corresponding to the N-1th frame image of the original picture file, and N is an integer greater than 1.
下面以所述色彩数据为RGB数据,所述RGB数据为对第一图片文件解码生成的举例说明,请参见图21B,为本申请实施例提供了又一种图片文件处理方法的流程示意图。如图21B所示,本申请实施例具体阐述了对颜色表信息进行训练以及像素点的RGB值更新的过程,所述方法可以包括以下步骤S1201B-步骤S1203B。The color data is RGB data, and the RGB data is an example for decoding the first image file. Referring to FIG. 21B, a flow chart of another method for processing a picture file is provided in the embodiment of the present application. As shown in FIG. 21B, the embodiment of the present application specifically describes a process of training color table information and updating RGB values of pixel points, and the method may include the following steps S1201B-S1203B.
S1201B,获取对原始图片文件解码生成的RGB数据,获取RGB数据中的各像素点的RGB值。S1201B: Acquire RGB data generated by decoding the original image file, and obtain RGB values of each pixel in the RGB data.
一些实例中,图片文件处理设备可以获取对原始图片文件解码生成的RGB数据,可以理解的是,对所述图片文件进行解码可以生成所述图片文件的图片头信息数据段以及所述图片文件中每帧图像对应的RGB数据。所述RGB数据可以转换为YUV数据,并将YUV数据进行编码生成码流数据,进一步生成包含码流数据和图片头信息数据段的压缩图像数据,所述压缩图像数据可以用于存储,或者传输至图片文件处理设备进行图片文件的还原。在一些实例中,所述图片文件处理设备获取所述压缩图像数据,可以解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据,并解码所述码流数据生成YUV数据,进一步将YUV数据转换为RGB数据,所述图片文件处理设备获取所述RGB数据,并获取所述RGB数据中的各像素点的RGB值。In some examples, the picture file processing device may obtain the RGB data generated by decoding the original picture file, and it may be understood that decoding the picture file may generate a picture header information data segment of the picture file and the picture file. The RGB data corresponding to each frame of image. The RGB data may be converted into YUV data, and the YUV data is encoded to generate code stream data, and further generated compressed image data including code stream data and picture header information data segments, the compressed image data may be used for storage or transmission. Restore the image file to the image file processing device. In some examples, the picture file processing device acquires the compressed image data, may parse the compressed image data to obtain the picture header information data segment and the code stream data, and decode the code stream data to generate a YUV. Data, further converting YUV data into RGB data, the picture file processing device acquiring the RGB data, and acquiring RGB values of respective pixels in the RGB data.
S1202B,采用各像素点的RGB值对RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息。S1202B, the initial color table information of the RGB data is trained by using the RGB values of the respective pixels to generate local color table information of the RGB data.
一些实例中,所述图片文件处理设备可以判断所述图片头信息数据段中是否包含所述图片文件的全局颜色表信息,若是,则将所述全局颜色表信息确定为所述图片文件中的第一帧RGB数据的初始颜色表信息,若否,则生成初始化颜色表信息,确定为所述图片文件中的第一帧RGB 数据的初始颜色表信息。采用第一帧RGB数据中各像素点的RGB值对初始颜色表信息进行训练,生成第一帧RGB数据的局部颜色表信息,而对于第N帧RGB数据,可以将第N-1帧RGB数据的局部颜色表信息作为所述第N帧RGB数据的初始颜色表信息,并采用第N帧RGB数据中各像素点的RGB值对第N帧RGB数据的初始颜色表信息进行训练,生成第N帧RGB数据的局部颜色表信息,其中N为大于1的正整数。In some examples, the picture file processing device may determine whether the picture header information data segment includes global color table information of the picture file, and if yes, determine the global color table information as the picture file. Initial color table information of the first frame of RGB data, if not, generating initial color table information, and determining initial color table information of the first frame of RGB data in the picture file. The initial color table information is trained by using the RGB values of the pixels in the first frame of RGB data to generate local color table information of the first frame of RGB data, and for the Nth frame of RGB data, the N-1th frame of RGB data may be used. The local color table information is used as the initial color table information of the Nth frame RGB data, and the initial color table information of the Nth frame RGB data is trained by using the RGB values of the pixels in the Nth frame RGB data to generate the Nth Local color table information for frame RGB data, where N is a positive integer greater than one.
S1203B,采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。S1203B updates the RGB values of each pixel point by using local color table information of RGB data.
一些实例中,所述图片文件处理设备可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新,所述图片文件处理设备采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。In some examples, the picture file processing device may update the RGB values of the pixels by using local color table information of the RGB data, and the picture file processing device adopts the delay time and the total frame. The number of the updated RGB data is image encoded to generate the picture file.
在本申请实施例中,通过对全局颜色表信息或初始化颜色表信息进行训练,生成RGB数据的局部颜色表信息,有效的减少了图像的失真。In the embodiment of the present application, the local color table information of the RGB data is generated by training the global color table information or the initialization color table information, thereby effectively reducing the distortion of the image.
请参见图22,为本申请实施例提供了又一种图片文件处理方法的流程示意图。如图22所示,本申请实施例具体阐述了对颜色表信息进行训练以及像素点的RGB值更新的过程,所述方法可以包括以下步骤S1301-步骤S1306。FIG. 22 is a schematic flowchart diagram of still another method for processing a picture file according to an embodiment of the present application. As shown in FIG. 22, the embodiment of the present application specifically describes a process of training color table information and updating RGB values of pixel points, and the method may include the following steps S1301 - step S1306.
S1301,获取对原始图片文件解码生成的RGB数据,获取RGB数据中的各像素点的RGB值。S1301: Acquire RGB data generated by decoding the original image file, and obtain RGB values of each pixel in the RGB data.
一些实例中,图片文件处理设备可以获取对原始图片文件解码生成的RGB数据。所述RGB数据可以转换为YUV数据,并将YUV数据进行编码生成码流数据,进一步生成包含码流数据和图片头信息数据段的 压缩图像数据,所述压缩图像数据可以用于存储,或者传输至图片文件处理设备进行图片文件的还原。In some examples, the picture file processing device may acquire RGB data generated by decoding the original picture file. The RGB data may be converted into YUV data, and the YUV data is encoded to generate code stream data, and further generated compressed image data including code stream data and picture header information data segments, the compressed image data may be used for storage or transmission. Restore the image file to the image file processing device.
S1302,判断解码图片文件生成的图片头信息数据段中是否包含图片文件的全局颜色表信息。S1302: Determine whether the global color table information of the picture file is included in the picture header information data segment generated by the decoded picture file.
一些实例中,所述图片文件处理设备判断所述图片头信息数据段中是否包含所述图片文件的全局颜色表信息,若是,则转入执行步骤S1103。若否,则转入执行步骤1104。In some examples, the picture file processing device determines whether the global color table information of the picture file is included in the picture header information data segment, and if yes, proceeds to step S1103. If no, go to step 1104.
S1303,当所述RGB数据为图片文件中的第一帧图像时,采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息。S1303: When the RGB data is the first frame image in the picture file, the global color table information is trained by using RGB values of each pixel in the RGB data to generate local color table information of the RGB data.
S1304,当所述RGB数据为图片文件中的第一帧图像时,采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息。S1304: When the RGB data is the first frame image in the picture file, the initialization color table information is trained by using the RGB values of the pixels in the RGB data to generate local color table information of the RGB data.
S1305,当所述RGB数据为图片文件中的第N帧图像时,采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息。S1305, when the RGB data is the Nth frame image in the picture file, the local color table information of the N-1th frame RGB data is trained to generate a local part of the RGB data by using the RGB values of the pixels in the RGB data. Color table information.
S1306,采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。S1306: The RGB values of each pixel point are updated by using local color table information of RGB data.
一些实例中,所述图片文件处理设备可以采用所述RGB数据的局部颜色表信息对所述RGB数据中各像素点的RGB值进行更新,所述图片文件处理设备采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。In some examples, the picture file processing device may update the RGB values of each pixel in the RGB data by using local color table information of the RGB data, and the picture file processing device adopts the delay time and the The total number of frames encodes the updated RGB data to generate the picture file.
在本申请实施例中,通过对全局颜色表信息或初始化颜色表信息进行训练,生成RGB数据的局部颜色表信息,有效的减少了图像的失真。通过采用G分量获取最接近的源RGB值,并在颜色表信息中进行小范 围的颜色索引搜索,无需遍历整个颜色表信息,降低了对局部颜色表信息训练的复杂度,进一步提升了图片文件的编码效率。In the embodiment of the present application, the local color table information of the RGB data is generated by training the global color table information or the initialization color table information, thereby effectively reducing the distortion of the image. By using the G component to obtain the closest source RGB value and performing a small range of color index search in the color table information, it is not necessary to traverse the entire color table information, thereby reducing the complexity of training the local color table information, and further improving the image file. The coding efficiency.
下面将结合附图23-附图24,对本申请实施例提供的图片文件处理设备进行详细介绍。需要说明的是,附图23-附图24所示的图片文件处理设备,用于执行本申请图8和图9所示实施例的方法,并且具体为上述实施例中的发送端,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请图8和图9所示的实施例。The picture file processing device provided by the embodiment of the present application will be described in detail below with reference to FIG. 23 to FIG. It should be noted that the picture file processing device shown in FIG. 23 to FIG. 24 is used to execute the method of the embodiment shown in FIG. 8 and FIG. 9 of the present application, and is specifically the transmitting end in the foregoing embodiment, for convenience. It is to be noted that only the parts related to the embodiments of the present application are shown, and the specific technical details are not disclosed. Please refer to the embodiments shown in FIG. 8 and FIG. 9 of the present application.
请参见图23,为本申请实施例提供了一种图片文件处理设备的结构示意图。如图23所示,本申请实施例的所述图片文件处理设备1可以包括:图像转换单元11、图像压缩单元12和码流发送单元13。FIG. 23 is a schematic structural diagram of a picture file processing apparatus according to an embodiment of the present application. As shown in FIG. 23, the picture file processing apparatus 1 of the embodiment of the present application may include an image converting unit 11, an image compressing unit 12, and a code stream transmitting unit 13.
图像转换单元11,用于根据原始图片文件生成图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据。The image conversion unit 11 is configured to generate a picture header information data segment of the picture file according to the original picture file, and convert each frame image in the picture file into YUV data.
一些实例中,所述图像转换单元11可以解码原始图片文件以生成所述图片文件的图片头信息数据段。所述图像转换单元11进一步将所述图片文件中每帧图像转换为YUV数据。In some examples, the image conversion unit 11 may decode the original picture file to generate a picture header information data segment of the picture file. The image conversion unit 11 further converts each frame image in the picture file into YUV data.
一些实例中,请一并参见图24,为本申请实施例提供了一种图像转换单元的结构示意图。如图24所示,所述图像转换单元11可以包括:In some examples, please refer to FIG. 24, which is a schematic structural diagram of an image conversion unit according to an embodiment of the present application. As shown in FIG. 24, the image conversion unit 11 may include:
图像解码子单元111,用于解码原始图片文件以生成图片文件的图片头信息数据段以及图片文件中每帧图像对应的RGB数据。The image decoding sub-unit 111 is configured to decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
一些实例中,所述图像解码子单元111可以解码原始图片文件以生成所述图片文件的图片头信息数据段以及所述图片文件中每帧图像对应的RGB数据。In some examples, the image decoding sub-unit 111 may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
图像转换子单元112,用于采用颜色空间转换公式将所述RGB数据转换为YUV数据。The image conversion sub-unit 112 is configured to convert the RGB data into YUV data by using a color space conversion formula.
一些实例中,所述图像转换子单元112可以采用颜色空间转换公式将所述RGB数据转换为YUV数据。In some examples, the image conversion sub-unit 112 may convert the RGB data into YUV data using a color space conversion formula.
图像压缩单元12,用于对所述YUV数据进行编码以生成码流数据。The image compression unit 12 is configured to encode the YUV data to generate code stream data.
一些实例中,所述图像压缩单元12可以进一步对所述YUV数据进行编码处理,生成码流数据,所述编码可以包括预测编码、变换编码、量化编码和熵编码,例如:所述图像压缩单元12可以采用IPPP模式对所述YUV数据进行压缩,第一帧YUV数据为I帧,I帧即为帧内预测帧,其余帧YUV数据为P帧,P帧即为帧间预测帧,可以有效的压缩图片文件的文件数据量,还可以采用固定QP的方式来稳定不同帧之间的质量等。熵编码则可以包括哈夫曼编码、算数编码等。In some examples, the image compression unit 12 may further perform encoding processing on the YUV data to generate code stream data, where the encoding may include predictive coding, transform coding, quantization coding, and entropy coding, for example, the image compression unit. The YUV data may be compressed by using the IPPP mode. The YUV data of the first frame is an I frame, the I frame is an intra prediction frame, and the remaining frame YUV data is a P frame, and the P frame is an inter prediction frame, which can be effective. The amount of file data in the compressed image file can also be fixed in a QP manner to stabilize the quality between different frames. The entropy coding may include Huffman coding, arithmetic coding, and the like.
一些实例中,在对所述YUV数据进行编码过程中,可以支持用户添加配置参数,所述配置参数可以为对所述YUV数据进行编码的参数。所述图像压缩单元12可以采用配置参数对所述YUV数据进行编码以生成码流数据。In some examples, during encoding of the YUV data, a user may be added to add configuration parameters, which may be parameters that encode the YUV data. The image compression unit 12 may encode the YUV data using configuration parameters to generate codestream data.
一些实例中,在对所述YUV数据进行编码过程中,还可以支持用户添加编码器复杂度,所述编码器复杂度可以为根据所述图片文件处理设备1的硬件性能所决定的编码的精细度参数,所述编码器复杂度可以包括第一复杂度、第二复杂度和第三复杂度中的任一种,所述第一复杂度高于所述第二复杂度,所述第二复杂度高于所述第三复杂度,例如:可以对所述图片文件处理设备1的硬件性能进行检测以生成性能数值,例如:测试所述图片文件处理设备1的中央处理器的计算速率等,当所述性能数值位于第一预设数值范围内时,可以确定图片文件处理设备1硬件性能很高,则可以推荐使用第一复杂度的编码方式。当所述性能数值位于第二预设数值范围内时,可以确定图片文件处理设备1硬件性能中等,则可以推荐使用第二复杂度的编码方式。当所述性能数值位于第 三预设数值范围内时,可以确定图片文件处理设备1硬件性能较差,或者当前要求实时转码等,则可以推荐使用第三复杂度的编码方式等。所述图像压缩单元12可以配置编码器复杂度对所述YUV数据进行编码以生成码流数据。In some examples, during encoding of the YUV data, the user may also be allowed to add an encoder complexity, which may be a fine code determined according to the hardware performance of the picture file processing device 1. a degree parameter, the encoder complexity may include any one of a first complexity, a second complexity, and a third complexity, the first complexity being higher than the second complexity, the second The complexity is higher than the third complexity, for example, the hardware performance of the picture file processing device 1 can be detected to generate a performance value, for example, the calculation rate of the central processing unit of the picture file processing device 1 is tested, etc. When the performance value is within the first preset value range, it may be determined that the hardware performance of the picture file processing device 1 is high, and the coding mode of the first complexity may be recommended. When the performance value is within the second preset value range, it may be determined that the hardware performance of the picture file processing device 1 is medium, and the second complexity coding mode may be recommended. When the performance value is within the third preset value range, it may be determined that the hardware performance of the picture file processing device 1 is poor, or the current real-time transcoding is required, and the coding mode of the third complexity may be recommended. The image compression unit 12 may configure the encoder complexity to encode the YUV data to generate codestream data.
码流发送单元13,用于将所述压缩图像数据发送至接收端。The code stream sending unit 13 is configured to send the compressed image data to the receiving end.
一些实例中,所述码流发送单元13可以生成压缩图像数据,所述图片文件处理设备1可以对所述压缩图像数据进行存储,当检测到接收端对所述图片文件的请求时,所述码流发送单元13再将所述压缩图像数据发送至所述接收端,例如:当图片文件处理设备1检测到包含所述图片文件的网页开启时。所述码流发送单元13也可以直接将所述压缩图像数据发送至所述接收端,例如:即时通信应用中的一个客户端需要将所述图片文件发送至另一个客户端时,应用服务设备需要将所述图片文件进行转发等,所述压缩图像数据包含所述图片头信息数据段和所述码流数据。In some examples, the code stream sending unit 13 may generate compressed image data, and the picture file processing device 1 may store the compressed image data, when detecting a request of the receiving end for the picture file, The code stream transmitting unit 13 transmits the compressed image data to the receiving end again, for example, when the picture file processing apparatus 1 detects that the web page including the picture file is turned on. The code stream sending unit 13 may also directly send the compressed image data to the receiving end, for example, when a client in the instant messaging application needs to send the picture file to another client, the application service device The picture file needs to be forwarded or the like, and the compressed image data includes the picture header information data segment and the code stream data.
所述接收端接收所述图片文件处理设备1发送的所述压缩图像数据,所述接收端可以对所述压缩图像数据进行解析处理,以获取所述压缩图像数据中的所述图片头信息数据段和所述码流数据。The receiving end receives the compressed image data sent by the picture file processing device 1, and the receiving end may perform parsing processing on the compressed image data to obtain the picture header information data in the compressed image data. Segment and the code stream data.
请参见图25,为本申请实施例提供了另一种图片文件处理设备的结构示意图。如图25所示,所述图片文件处理设备1000可以包括:至少一个处理器1001,例如CPU,至少一个网络接口1004,用户接口1003,存储器1005,至少一个通信总线1002。其中,通信总线1002用于实现这些组件之间的连接通信。其中,用户接口1003可以包括显示屏(Display)、键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004一些实例中可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1005可以是高速RAM存储 器,也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。存储器1005一些实例中还可以是至少一个位于远离前述处理器1001的存储装置。如图25所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及图像处理应用程序。Referring to FIG. 25, a schematic structural diagram of another picture file processing apparatus according to an embodiment of the present application is provided. As shown in FIG. 25, the picture file processing apparatus 1000 may include at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002. Among them, the communication bus 1002 is used to implement connection communication between these components. The user interface 1003 can include a display and a keyboard. The optional user interface 1003 can also include a standard wired interface and a wireless interface. Some examples of the network interface 1004 may include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 1005 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory. The memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001 in some instances. As shown in FIG. 25, an operating system, a network communication module, a user interface module, and an image processing application may be included in the memory 1005 as a computer storage medium.
在图25所示的图片文件处理设备1000中,网络接口1004主要用于连接接收端,与所述接收端进行数据通信。而用户接口1003主要用于为用户提供输入的接口,获取用户输入的数据。而处理器1001可以用于调用存储器1005中存储的图像处理应用程序,并具体执行以下步骤:In the picture file processing device 1000 shown in FIG. 25, the network interface 1004 is mainly used to connect to the receiving end and perform data communication with the receiving end. The user interface 1003 is mainly used to provide an input interface for the user, and obtain data input by the user. The processor 1001 can be used to call the image processing application stored in the memory 1005, and specifically perform the following steps:
根据原始图片文件生成所述图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据。Generating a picture header information data segment of the picture file according to the original picture file, and converting each frame image in the picture file into YUV data.
对所述YUV数据进行编码以生成码流数据。The YUV data is encoded to generate codestream data.
将压缩图像数据发送至接收端,所述压缩图像数据包含所述图片头信息数据段和所述码流数据,以使所述接收端解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据,根据所述码流数据生成所述YUV数据,使所述接收端基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。Transmitting the compressed image data to the receiving end, the compressed image data comprising the picture header information data segment and the code stream data, so that the receiving end parses the compressed image data to obtain the picture header information data segment And generating, by the code stream data, the YUV data according to the code stream data, so that the receiving end processes the YUV data based on the picture header information data segment to generate the picture file.
在一个实施例中,所述处理器1001在执行根据原始图片文件生成图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据时,具体执行以下步骤:In one embodiment, the processor 1001 performs the following steps when performing a picture header information data segment for generating a picture file according to the original picture file and converting each frame image in the picture file into YUV data:
解码原始图片文件以生成图片文件的图片头信息数据段以及图片文件中每帧图像对应的RGB数据,所述图片头信息数据段包括延时信息、总帧数、全局颜色表信息。The original picture file is decoded to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file, and the picture header information data segment includes delay information, total frame number, and global color table information.
采用颜色空间转换公式将所述RGB数据转换为YUV数据。The RGB data is converted to YUV data using a color space conversion formula.
在一个实施例中,所述编码包括预测编码、变换编码、量化编码和熵编码。In one embodiment, the encoding includes predictive coding, transform coding, quantization coding, and entropy coding.
在一个实施例中,所述处理器1001在执行对所述YUV数据进行编码以生成码流数据时,具体执行以下步骤:In one embodiment, the processor 1001 performs the following steps when performing the encoding of the YUV data to generate code stream data:
采用配置参数对所述YUV数据进行编码以生成码流数据,所述配置参数为对所述YUV数据进行编码的参数,所述配置参数包括标清模式参数、高清模式参数和无损模式参数中的任一种。The YUV data is encoded by using configuration parameters to generate code stream data, the configuration parameter is a parameter for encoding the YUV data, and the configuration parameter includes any one of an SD mode parameter, a HD mode parameter, and a lossless mode parameter. One.
在一个实施例中,所述处理器1001在执行对所述YUV数据进行编码以生成码流数据时,具体执行以下步骤:In one embodiment, the processor 1001 performs the following steps when performing the encoding of the YUV data to generate code stream data:
配置编码器复杂度对所述YUV数据进行编码以生成码流数据,所述编码器复杂度为根据硬件性能所决定的编码的精细度参数。The encoder complexity is configured to encode the YUV data to generate codestream data, the encoder complexity being a fineness parameter of the encoding determined according to hardware capabilities.
在一个实施例中,所述图片文件为GIF图像。In one embodiment, the picture file is a GIF image.
下面将结合附图26-附图27,对本申请实施例提供的图片文件处理设备进行详细介绍。需要说明的是,附图26-附图27所示的图片文件处理设备,用于执行本申请图11和图12所示实施例的方法,并且具体为上述实施例中的接收端,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请图11和图12所示的实施例。The picture file processing device provided by the embodiment of the present application will be described in detail below with reference to FIG. 26 to FIG. It should be noted that the picture file processing device shown in FIG. 26 to FIG. 27 is used to perform the method of the embodiment shown in FIG. 11 and FIG. 12 of the present application, and is specifically the receiving end in the above embodiment, for convenience. It is to be noted that only the parts related to the embodiments of the present application are shown, and the specific technical details are not disclosed. Please refer to the embodiment shown in FIG. 11 and FIG. 12 of the present application.
请参见图26,为本申请实施例提供了又一种图片文件处理设备的结构示意图。如图26所示,本申请实施例的所述图片文件处理设备2可以包括:信息获取单元21和图像编码单元22。FIG. 26 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application. As shown in FIG. 26, the picture file processing apparatus 2 of the embodiment of the present application may include an information acquiring unit 21 and an image encoding unit 22.
信息获取单元21,用于接收发送端发送的针对原始图片文件的压缩图像数据,解析所述压缩图像数据以获取图片文件的图片头信息数据段和码流数据。The information acquiring unit 21 is configured to receive compressed image data for the original picture file sent by the sending end, and parse the compressed image data to obtain a picture header information data segment and code stream data of the picture file.
一些实例中,发送端可以解码原始图片文件以生成所述图片文件的 图片头信息数据段以及所述图片文件中每帧图像对应的RGB数据。In some examples, the transmitting end may decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
所述发送端可以采用颜色空间转换公式将所述RGB数据转换为YUV数据。The transmitting end may convert the RGB data into YUV data by using a color space conversion formula.
所述发送端可以进一步对所述YUV数据进行编码处理,生成码流数据。The transmitting end may further perform encoding processing on the YUV data to generate code stream data.
所述发送端可以生成压缩图像数据,所述发送端可以对所述压缩图像数据进行存储,当检测到图片文件处理设备2对所述图片文件的请求时,所述发送端再将所述压缩图像数据发送至所述图片文件处理设备2。The transmitting end may generate compressed image data, and the sending end may store the compressed image data, and when detecting the request of the picture file processing device 2 for the picture file, the sending end performs the compression Image data is sent to the picture file processing device 2.
所述信息获取单元21接收所述发送端发送的所述压缩图像数据,所述信息获取单元21可以对所述压缩图像数据进行解析处理,以获取所述压缩图像数据中的所述图片头信息数据段和所述码流数据。The information acquiring unit 21 receives the compressed image data sent by the sending end, and the information acquiring unit 21 may perform parsing processing on the compressed image data to obtain the picture header information in the compressed image data. Data segment and the code stream data.
图像编码单元22,用于根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。The image encoding unit 22 is configured to generate the YUV data according to the code stream data, and process the YUV data based on the picture header information data segment to generate the picture file.
一些实例中,所述图像编码单元22解码所述码流数据以生成所述YUV数据,并基于图片头信息数据段中的时延信息、总帧数、全局颜色表信息等对所述YUV数据进行编码处理以生成所述图片文件。In some examples, the image encoding unit 22 decodes the code stream data to generate the YUV data, and compares the YUV data based on delay information, total frame number, global color table information, and the like in a picture header information data segment. An encoding process is performed to generate the picture file.
一些实例中,请一并参见图27,为本申请实施例提供了一种图像编码单元的结构示意图。如图27所示,所述图像编码单元22可以包括:In some examples, please refer to FIG. 27, which is a schematic structural diagram of an image coding unit according to an embodiment of the present application. As shown in FIG. 27, the image encoding unit 22 may include:
图像转换子单元221,用于解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。The image conversion sub-unit 221 is configured to decode the code stream data to generate the YUV data, and convert the YUV data into RGB data by using a color space conversion formula.
一些实例中,所述图像转换子单元221解码所述码流数据以生成所述YUV数据,并可以采用颜色空间转换公式将所述YUV数据转换为RGB数据,一些实例中,所述图像转换子单元221需要依据亮度分量的值域范围确定所采用的颜色空间转换公式,In some examples, the image conversion sub-unit 221 decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data using a color space conversion formula, in some examples, the image converter The unit 221 needs to determine the color space conversion formula adopted according to the range of values of the luminance component.
像素点更新子单元222,用于采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新。The pixel point updating sub-unit 222 is configured to update the RGB values of each pixel point in the RGB data by using the global color table information.
一些实例中,由于之前对所述YUV数据进行过编码处理,因此导致由所述YUV数据转换的RGB数据存在失真的情况,所述像素点更新子单元222可以采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新。In some examples, since the YUV data has been previously encoded, resulting in distortion of the RGB data converted by the YUV data, the pixel update subunit 222 may adopt the global color table information pair. The RGB values of the respective pixel points in the RGB data are updated.
一些实例中,针对图片头信息数据段中存在全局颜色表信息的情况,当所述RGB数据为所述图片文件中的第一帧图像,所述像素点更新子单元222可以采用所述RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。In some examples, for the case where the global color table information exists in the picture header information data segment, when the RGB data is the first frame image in the picture file, the pixel point update subunit 222 may adopt the RGB data. The RGB values of the pixels in the image are trained to generate the local color table information of the RGB data, and the RGB values of the pixels are performed by using the local color table information of the RGB data. Update.
一些实例中,当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,所述像素点更新子单元222可以将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式(例如:升序、降序等)进行排序,以生成训练颜色表信息。In some examples, when the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the pixel point update subunit 222 may At least one source RGB value in the color table information is sorted according to a preset ordering of the G components (eg, ascending, descending, etc.) to generate training color table information.
所述像素点更新子单元222在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取所述第一源RGB值的第一颜色索引。The pixel point update sub-unit 222 acquires, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquires the first source RGB value. The first color index.
所述像素点更新子单元222在所述训练颜色表信息中以所述第一颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第二源RGB值,并获取所述第二源RGB值的第二颜色索引,可以理解的是,所述像素点更新子单元222可以以所述第一颜色索引为中心,在所述第一颜色索引的前后预设范围内获取多个源RGB值,并分别计 算所述第一源RGB值以及所述多个源RGB值与所述当前像素点的RGB值的误差,并将多个源RGB值中误差最小的源RGB值确定为第二源RGB值。The pixel point update sub-unit 222 acquires, in a preset range centered on the first color index in the training color table information, a second source RGB value that has the smallest error with the RGB value of the current pixel point. Obtaining a second color index of the second source RGB value, it may be understood that the pixel point update subunit 222 may be centered on the first color index and preset before and after the first color index. Acquiring a plurality of source RGB values in a range, and respectively calculating an error of the first source RGB value and the RGB values of the plurality of source RGB values and the current pixel point, and minimizing an error among the plurality of source RGB values The source RGB value is determined to be the second source RGB value.
所述像素点更新子单元222将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第二颜色索引为中心的预设范围内的多个源RGB值进行修改。The pixel point update sub-unit 222 replaces the second source RGB value with the RGB value of the current pixel point, and uses the preset weight value and the RGB value of the current pixel point to the training color table information. A plurality of source RGB values within a preset range centered on the second color index are modified.
当所述当前像素点不为所述RGB数据中的最后一个像素点时,例如当前像素点为图4或图5中所示的RGB数据中的第一个像素点时,所述像素点更新子单元222获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,例如:将所述RGB数据中的第二个像素点作为当前像素点,对修改后得到的所述训练颜色表信息再一次进行训练。一些实例中训练过程可以参见上述训练过程的描述,在此不进行赘述。When the current pixel point is not the last pixel point in the RGB data, for example, when the current pixel point is the first pixel point in the RGB data shown in FIG. 4 or FIG. 5, the pixel point update The sub-unit 222 obtains the training color table information obtained after the modification, takes the next pixel point of the current pixel point as the current pixel point, and transfers to perform the acquisition of the G component and the RGB in the training color table information. The first source RGB value of the G component of the current pixel in the data is the closest, for example, the second pixel point in the RGB data is used as the current pixel point, and the training color table information obtained after the modification is performed again. training. The training process in some examples can be referred to the description of the above training process, and will not be described here.
当所述当前像素点为所述RGB数据中的最后一个像素点时,例如当前像素点为图4或图5中所示的RGB数据中的第四个像素点时,所述像素点更新子单元222获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, for example, when the current pixel point is the fourth pixel point in the RGB data shown in FIG. 4 or FIG. 5, the pixel point updater The unit 222 obtains the training color table information obtained after the modification, and determines the training color table information as the local color table information of the RGB data.
所述像素点更新子单元222可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新,一些实例中,所述像素点更新子单元222可以在所述RGB数据的局部颜色表信息中依次获取与所述各像素点相同或误差最小的源RGB值分别替换所述各像素点的RGB值,在一些实例中,所述像素点更新子单元222可以将与所述各像素点相同或误差最小的源RGB值对应的颜色索引分别替换所述各像素点的 RGB值。The pixel point update sub-unit 222 may update the RGB values of the pixel points by using local color table information of the RGB data. In some examples, the pixel point update sub-unit 222 may be in the RGB data. The source RGB values in the local color table information are sequentially obtained with the same or the smallest error as the pixel points respectively replacing the RGB values of the respective pixel points, and in some examples, the pixel point update sub-unit 222 may The color index corresponding to the source RGB values of the same or the smallest error is replaced by the RGB values of the respective pixels.
一些实例中,针对图片头信息数据段中不存在全局颜色表信息的情况,当所述RGB数据为所述图片文件中的第一帧图像,所述像素点更新子单元222可以采用所述RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。In some examples, for the case where the global color table information does not exist in the picture header information data segment, when the RGB data is the first frame image in the picture file, the pixel point update subunit 222 may adopt the RGB. The RGB values of the pixels in the data are trained to initialize the color table information to generate local color table information of the RGB data, and the RGB values of the pixels are updated by the local color table information of the RGB data. .
一些实例中,当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,所述像素点更新子单元222可以生成一个初始化颜色表信息,例如:(0,0,0)、(1,1,1)、(2,2,2)、……、(255,255,255),所述像素点更新子单元222在初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取所述第三源RGB值的第三颜色索引,所述图片文件处理设备2在所述初始化颜色表信息中以所述第三颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第四源RGB值,并获取所述第四源RGB值的第四颜色索引,所述像素点更新子单元222将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述初始化颜色表信息中以所述第四颜色索引为中心的预设范围内的多个源RGB值进行修改,当所述当前像素点不为所述RGB数据中的最后一个像素点时,所述像素点更新子单元222获取修改后得到的所述初始化颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值,当所述当前像素点为所述RGB数据中的最后一个像素点时,所述像素点更新子单元222获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为所述RGB 数据的局部颜色表信息,所述像素点更新子单元222可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。需要说明的是,各实例中对初始化颜色表信息进行训练以及采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新的过程均可以参见前述方式的执行过程,在此不进行赘述。In some examples, when the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the pixel point update subunit 222 may generate an initialization. Color table information, for example: (0, 0, 0), (1, 1, 1), (2, 2, 2), ..., (255, 255, 255), the pixel point update subunit 222 is Acquiring, in the initialization color table information, a third source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value, the picture file processing device 2 acquiring, in a preset range centered on the third color index in the initialization color table information, a fourth source RGB value having a smallest error from an RGB value of the current pixel point, and acquiring the fourth source a fourth color index of the RGB value, the pixel point update sub-unit 222 replacing the fourth source RGB value with the RGB value of the current pixel point, and adopting a preset weight value and an RGB value of the current pixel point Centering on the fourth color index in the initialization color table information The plurality of source RGB values in the preset range are modified. When the current pixel point is not the last pixel point in the RGB data, the pixel point update subunit 222 acquires the initialization color obtained after the modification. The table information, the next pixel point of the current pixel point is taken as the current pixel point, and is transferred to perform the first step of acquiring the G component in the initialization color table information and the G component of the current pixel point in the RGB data. a three-source RGB value, when the current pixel is the last pixel in the RGB data, the pixel update sub-unit 222 acquires the modified color table information obtained after the modification, and initializes the color The table information is determined as local color table information of the RGB data, and the pixel point updating sub-unit 222 may update the RGB values of the respective pixel points by using local color table information of the RGB data. It should be noted that the process of training the initialization color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data can refer to the execution process of the foregoing manner, and details are not described herein.
一些实例中,针对所述RGB数据不为所述图片文件中的第一帧图像,即所述RGB数据为所述图片文件中的第N帧图像时,其中,N为大于1且小于或等于所述总帧数的正整数,所述像素点更新子单元222可以采用所述RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。In some examples, when the RGB data is not the first frame image in the picture file, that is, the RGB data is the Nth frame image in the picture file, where N is greater than 1 and less than or equal to a positive integer of the total number of frames, the pixel point update subunit 222 may train the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate the The local color table information of the RGB data, and the RGB values of the respective pixel points are updated by using the local color table information of the RGB data.
一些实例中,当所述RGB数据为所述图片文件中的第N帧图像时,所述像素点更新子单元222可以将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息,所述像素点更新子单元222在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取所述第五源RGB值的第五颜色索引,所述像素点更新子单元222在所述训练颜色表信息中以所述第五颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第六源RGB值,并获取所述第六源RGB值的第六颜色索引,所述像素点更新子单元222将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第六颜色索引为中心的预设范围内的多个源RGB值进行修改,当所述当前像素点不为所述RGB数据中的最后一个像素点时,所述像素点更新 子单元222获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,当所述当前像素点为所述RGB数据中的最后一个像素点时,所述像素点更新子单元222获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息,所述像素点更新子单元222可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。需要说明的是,各实例中对训练颜色表信息进行训练以及采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新的过程均可以参见前述方式的执行过程,在此不进行赘述。In some examples, when the RGB data is the Nth frame image in the picture file, the pixel point update subunit 222 may at least one source RGB of the partial color table information of the N-1th frame RGB data. The values are sorted according to a preset sorting manner of the G component to generate training color table information, and the pixel point updating sub-unit 222 acquires the G component and the G component of the current pixel point in the RGB data in the training color table information. a fifth source RGB value that is closest to the fifth color index of the fifth source RGB value, the pixel point update subunit 222 being centered on the fifth color index in the training color table information And within a preset range, acquiring a sixth source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a sixth color index of the sixth source RGB value, where the pixel point update subunit 222 is to The sixth source RGB value is replaced by the RGB value of the current pixel point, and the preset weight value and the RGB value of the current pixel point are used, and the training color table information is centered on the sixth color index. Multiple source RGB values in the preset range The row modification, when the current pixel is not the last pixel in the RGB data, the pixel update subunit 222 obtains the modified color table information obtained after the modification, and the current pixel point The next pixel is taken as the current pixel, and is transferred to a fifth source RGB value that performs the closest acquisition of the G component in the training color table information to the G component of the current pixel in the RGB data, when the current pixel When the point is the last pixel in the RGB data, the pixel point update subunit 222 acquires the modified color table information obtained by the modification, and determines the training color table information as a part of the RGB data. The color point information sub-unit 222 may update the RGB values of the respective pixel points by using local color table information of the RGB data. It should be noted that the process of training the training color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data may refer to the execution process of the foregoing manner, and details are not described herein.
图像编码子单元223,用于采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。The image encoding sub-unit 223 is configured to image-encode the updated RGB data by using the delay time and the total number of frames to generate the picture file.
一些实例中,所述图像编码子单元223采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。In some examples, the image encoding sub-unit 223 performs image encoding on the updated RGB data using the delay time and the total number of frames to generate the picture file.
请参见图28,为本申请实施例提供了又一种图片文件处理设备的结构示意图。如图28所示,所述图片文件处理设备2000可以包括:至少一个处理器2001,例如CPU,至少一个网络接口2004,用户接口2003,存储器2005,至少一个通信总线2002。其中,通信总线2002用于实现这些组件之间的连接通信。其中,用户接口2003可以包括显示屏(Display)、键盘(Keyboard),可选用户接口2003还可以包括标准的有线接口、无线接口。网络接口2004一些实例中可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器2005可以是高速RAM存储器,也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。存储器2005一些实例中还可以是至少一个位于远离前述 处理器2001的存储装置。如图28所示,作为一种计算机存储介质的存储器2005中可以包括操作系统、网络通信模块、用户接口模块以及图像处理应用程序。FIG. 28 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application. As shown in FIG. 28, the picture file processing apparatus 2000 may include at least one processor 2001, such as a CPU, at least one network interface 2004, a user interface 2003, a memory 2005, and at least one communication bus 2002. Among them, the communication bus 2002 is used to implement connection communication between these components. The user interface 2003 may include a display and a keyboard. The optional user interface 2003 may further include a standard wired interface and a wireless interface. Some examples of the network interface 2004 may include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 2005 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory. The memory 2005 may also be at least one storage device located remotely from the aforementioned processor 2001. As shown in FIG. 28, an operating system, a network communication module, a user interface module, and an image processing application may be included in the memory 2005 as a computer storage medium.
在图28所示的图片文件处理设备2000中,网络接口2004主要用于连接发送端,与所述发送端进行数据通信。而用户接口2003主要用于为用户提供输入的接口,获取用户输入的数据。而处理器2001可以用于调用存储器2005中存储的图像处理应用程序,并具体执行以下步骤:In the picture file processing device 2000 shown in FIG. 28, the network interface 2004 is mainly used to connect to the transmitting end and perform data communication with the transmitting end. The user interface 2003 is mainly used to provide an input interface for the user, and obtain data input by the user. The processor 2001 can be used to call the image processing application stored in the memory 2005, and specifically perform the following steps:
接收发送端发送的针对原始图片文件的压缩图像数据,解析所述压缩图像数据以获取图片文件的图片头信息数据段和码流数据,所述码流数据为对图片文件中每帧图像转换的YUV数据进行编码生成的信息。Receiving compressed image data for the original picture file sent by the sending end, parsing the compressed image data to obtain a picture header information data segment and code stream data of the picture file, where the code stream data is converted for each frame image in the picture file. YUV data is encoded to generate information.
根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。Generating the YUV data according to the code stream data, and processing the YUV data based on the picture header information data segment to generate the picture file.
在一个实施例中,所述图片头信息数据段包括延时信息、总帧数、全局颜色表信息。In an embodiment, the picture header information data segment includes delay information, a total number of frames, and global color table information.
所述处理器2001在执行根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件时,具体执行以下步骤:The processor 2001 performs the following steps when the YUV data is generated according to the code stream data, and the YUV data is processed based on the picture header information data segment to generate the picture file:
解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。The code stream data is decoded to generate the YUV data, and the YUV data is converted to RGB data using a color space conversion formula.
采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新。The RGB values of the respective pixel points in the RGB data are updated using the global color table information.
采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。The updated RGB data is image encoded using the delay time and the total number of frames to generate the picture file.
在一个实施例中,所述处理器2001在执行采用所述全局颜色表信 息对所述RGB数据中的各像素点的RGB值进行更新时,具体执行以下步骤:In one embodiment, when the processor 2001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,采用所述RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。When the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, adopting the RGB value of each pixel point in the RGB data to the global The color table information is trained to generate local color table information of the RGB data, and the RGB values of the respective pixel points are updated using local color table information of the RGB data.
在一个实施例中,所述处理器2001在执行采用所述RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成所述RGB数据的局部颜色表信息时,具体执行以下步骤:In one embodiment, the processor 2001 performs specific execution when training the global color table information by using RGB values of respective pixels in the RGB data to generate local color table information of the RGB data. The following steps:
将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息。At least one source RGB value in the global color table information is sorted according to a preset sorting manner of the G component to generate training color table information.
在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取所述第一源RGB值的第一颜色索引。And acquiring, in the training color table information, a first source RGB value whose G component is closest to a G component of a current pixel point in the RGB data, and acquiring a first color index of the first source RGB value.
在所述训练颜色表信息中以所述第一颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第二源RGB值,并获取所述第二源RGB值的第二颜色索引。Obtaining, in a preset range centered on the first color index in the training color table information, a second source RGB value having a smallest error from an RGB value of the current pixel point, and acquiring the second source RGB The second color index of the value.
将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第二颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the second source RGB value with the RGB value of the current pixel point, and using the preset weight value and the RGB value of the current pixel point, indexing the second color in the training color table information Modify multiple source RGB values within the preset range of the center.
当所述当前像素点不为所述RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值。When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is rotated. The first source RGB value that obtains the G component closest to the G component of the current pixel point in the RGB data in the training color table information is executed.
当所述当前像素点为所述RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息。And acquiring, when the current pixel point is the last pixel point in the RGB data, the training color table information obtained by the modification, and determining the training color table information as the local color table information of the RGB data. .
在一个实施例中,所述处理器2001在执行采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新时,具体执行以下步骤:In an embodiment, when the processor 2001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,采用所述RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。When the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the RGB value pair of each pixel point in the RGB data is used to initialize the color. The table information is trained to generate local color table information of the RGB data, and the RGB values of the respective pixel points are updated using local color table information of the RGB data.
在一个实施例中,所述处理器2001在执行采用所述RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成所述RGB数据的局部颜色表信息时,具体执行以下步骤:In one embodiment, the processor 2001 performs the following steps when performing the training of the initialization color table information by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data. :
在初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取所述第三源RGB值的第三颜色索引。A third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the initialization color table information, and a third color index of the third source RGB value is acquired.
在所述初始化颜色表信息中以所述第三颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第四源RGB值,并获取所述第四源RGB值的第四颜色索引。Obtaining, in a preset range centered on the third color index in the initialization color table information, a fourth source RGB value having a smallest error with an RGB value of the current pixel point, and acquiring the fourth source RGB The fourth color index of the value.
将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述初始化颜色表信息中以所述第四颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the fourth source RGB value with the RGB value of the current pixel point, and using the preset weight value and the RGB value of the current pixel point, indexing the fourth color into the initialization color table information Modify multiple source RGB values within the preset range of the center.
当所述当前像素点不为所述RGB数据中的最后一个像素点时,获取修改后得到的所述初始化颜色表信息,将所述当前像素点的下一个像 素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值。When the current pixel point is not the last pixel point in the RGB data, the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is rotated. The third source RGB value that obtains the G component closest to the G component of the current pixel point in the RGB data in the initialization color table information is executed.
当所述当前像素点为所述RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为所述RGB数据的局部颜色表信息。And acquiring, when the current pixel point is the last pixel point in the RGB data, the modified color table information obtained by the modification, and determining the initialization color table information as local color table information of the RGB data. .
在一个实施例中,所述处理器2001在执行采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新时,具体执行以下步骤:In an embodiment, when the processor 2001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
当所述RGB数据为所述图片文件中的第N帧图像时,采用所述RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新,N为大于1且小于或等于所述总帧数的正整数。When the RGB data is the Nth frame image in the picture file, training the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate the The local color table information of the RGB data, and the RGB values of the respective pixel points are updated by the local color table information of the RGB data, where N is a positive integer greater than 1 and less than or equal to the total number of frames.
在一个实施例中,所述处理器2001在执行采用所述RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成所述RGB数据的局部颜色表信息时,具体执行以下步骤:In one embodiment, the processor 2001 performs training on local color table information of the N-1th frame RGB data using RGB values of respective pixels in the RGB data to generate a partial color of the RGB data. For the table information, perform the following steps:
将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息。At least one source RGB value in the partial color table information of the N-1th frame RGB data is sorted according to a preset sorting manner of the G component to generate training color table information.
在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取所述第五源RGB值的第五颜色索引。And acquiring, in the training color table information, a fifth source RGB value whose G component is closest to the G component of the current pixel point in the RGB data, and acquiring a fifth color index of the fifth source RGB value.
在所述训练颜色表信息中以所述第五颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第六源RGB值,并获取所述第六源RGB值的第六颜色索引。And acquiring, in a preset range centered on the fifth color index in the training color table information, a sixth source RGB value having a smallest error with an RGB value of the current pixel point, and acquiring the sixth source RGB The sixth color index of the value.
将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预 设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第六颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the sixth source RGB value with the RGB value of the current pixel point, and using the preset weight value and the RGB value of the current pixel point, indexing the sixth color in the training color table information Modify multiple source RGB values within the preset range of the center.
当所述当前像素点不为所述RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值。When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is rotated. The fifth source RGB value that obtains the G component closest to the G component of the current pixel point in the RGB data in the training color table information is executed.
当所述当前像素点为所述RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息。And acquiring, when the current pixel point is the last pixel point in the RGB data, the training color table information obtained by the modification, and determining the training color table information as the local color table information of the RGB data. .
在一个实施例中,所述图片文件为GIF图像。In one embodiment, the picture file is a GIF image.
请参见图29,为本申请实施例提供了一种图像处理系统的结构示意图。如图29所示,该系统可以包括发送端1和接收端2,发送端1与接收端2可以通过网络相互连接,其中,所述发送端1具体为图23所示实施例的图片文件处理设备1,所述接收端2具体为图26所示实施例的图片文件处理设备2。或者,所述发送端1具体为图25所示实施例的图片文件处理设备1000,所述接收端2具体为图28所示实施例的图片文件处理设备2000。FIG. 29 is a schematic structural diagram of an image processing system according to an embodiment of the present application. As shown in FIG. 29, the system may include a transmitting end 1 and a receiving end 2, and the transmitting end 1 and the receiving end 2 may be connected to each other through a network, wherein the transmitting end 1 is specifically a picture file processing of the embodiment shown in FIG. The device 1, the receiving end 2 is specifically the picture file processing device 2 of the embodiment shown in FIG. Alternatively, the transmitting end 1 is specifically the picture file processing device 1000 of the embodiment shown in FIG. 25, and the receiving end 2 is specifically the picture file processing device 2000 of the embodiment shown in FIG.
所述发送端1,用于根据原始图片文件生成所述图片文件的图片头信息数据段,将图片文件中每帧图像转换为YUV数据,对所述YUV数据进行编码以生成码流数据,将所述压缩图像数据发送至接收端2,所述压缩图像数据包含所述图片头信息数据段和所述码流数据。The sending end 1 is configured to generate a picture header information data segment of the picture file according to the original picture file, convert each frame image in the picture file into YUV data, and encode the YUV data to generate code stream data, and The compressed image data is transmitted to the receiving end 2, and the compressed image data includes the picture header information data segment and the code stream data.
所述接收端2,用于接收所述发送端1发送的所述压缩图像数据,解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据,根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。The receiving end 2 is configured to receive the compressed image data sent by the sending end 1, and parse the compressed image data to obtain the picture header information data segment and the code stream data, according to the code stream data. Generating the YUV data and processing the YUV data based on the picture header information data segment to generate the picture file.
在一个实施例中,所述发送端1用于根据原始图片文件生成图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据时,具体用于:In an embodiment, the sending end 1 is configured to generate a picture header information data segment of the picture file according to the original picture file, and convert each frame image in the picture file into YUV data, specifically for:
解码原始图片文件以生成图片文件的图片头信息数据段以及图片文件中每帧图像对应的RGB数据,所述图片头信息数据段包括延时信息、总帧数、全局颜色表信息。The original picture file is decoded to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file, and the picture header information data segment includes delay information, total frame number, and global color table information.
采用颜色空间转换公式将所述RGB数据转换为YUV数据。The RGB data is converted to YUV data using a color space conversion formula.
在一个实施例中,所述编码包括预测编码、变换编码、量化编码和熵编码。In one embodiment, the encoding includes predictive coding, transform coding, quantization coding, and entropy coding.
在一个实施例中,所述发送端1用于对所述YUV数据进行编码以生成码流数据时,具体用于:In an embodiment, when the sending end 1 is used to encode the YUV data to generate code stream data, it is specifically used to:
采用配置参数对所述YUV数据进行编码以生成码流数据,所述配置参数为对所述YUV数据进行编码的参数,所述配置参数包括标清模式参数、高清模式参数和无损模式参数中的任一种。The YUV data is encoded by using configuration parameters to generate code stream data, the configuration parameter is a parameter for encoding the YUV data, and the configuration parameter includes any one of an SD mode parameter, a HD mode parameter, and a lossless mode parameter. One.
在一个实施例中,所述发送端1用于对所述YUV数据进行编码以生成码流数据时,具体用于:In an embodiment, when the sending end 1 is used to encode the YUV data to generate code stream data, it is specifically used to:
配置编码器复杂度对所述YUV数据进行编码以生成码流数据,所述编码器复杂度为根据所述发送端1的硬件性能所决定的编码的精细度参数。The encoder complexity is configured to encode the YUV data to generate codestream data, the encoder complexity being a fineness parameter of the encoding determined according to the hardware performance of the transmitting end 1.
在一个实施例中,所述接收端2用于根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件时,具体用于:In an embodiment, the receiving end 2 is configured to generate the YUV data according to the code stream data, and process the YUV data according to the picture header information data segment to generate the picture file, specifically Used for:
解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。The code stream data is decoded to generate the YUV data, and the YUV data is converted to RGB data using a color space conversion formula.
采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行 更新。The RGB values of the respective pixels in the RGB data are updated using the global color table information.
采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。The updated RGB data is image encoded using the delay time and the total number of frames to generate the picture file.
在一个实施例中,所述接收端2用于采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新时,具体用于:In an embodiment, when the receiving end 2 is used to update the RGB values of each pixel in the RGB data by using the global color table information, specifically, the receiving end 2 is used to:
当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。When the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the RGB value of each pixel in the RGB data is used to the global color table. The information is trained to generate local color table information of the RGB data, and the RGB values of the respective pixels are updated using the local color table information of the RGB data.
在一个实施例中,所述接收端2用于采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体用于:In an embodiment, when the receiving end 2 is used to train the global color table information to generate local color table information of RGB data by using RGB values of respective pixels in the RGB data, specifically, the receiving end 2 is used to:
将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息。At least one source RGB value in the global color table information is sorted according to a preset sorting manner of the G component to generate training color table information.
在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取第一源RGB值的第一颜色索引。A first source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the training color table information, and a first color index of the first source RGB value is acquired.
在训练颜色表信息中以第一颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第二源RGB值,并获取第二源RGB值的第二颜色索引。In the preset range centered on the first color index in the training color table information, a second source RGB value having the smallest error with the RGB value of the current pixel point is acquired, and a second color index of the second source RGB value is obtained.
将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对训练颜色表信息中以第二颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the second source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, a pre-position of the second color index in the training color table information Set multiple source RGB values in the range to modify.
当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当 前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值。When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. The first source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
在一个实施例中,所述接收端2用于采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新时,具体用于:In an embodiment, when the receiving end 2 is used to update the RGB values of each pixel in the RGB data by using the global color table information, specifically, the receiving end 2 is used to:
当所述RGB数据为图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。When the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the RGB value of each pixel in the RGB data is used to train the initialization color table information. The RGB values of the respective pixels are updated by generating local color table information of the RGB data and using local color table information of the RGB data.
在一个实施例中,所述接收端2用于采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体用于:In one embodiment, the receiving end 2 is configured to: when the initial color table information is trained to generate the local color table information of the RGB data by using the RGB values of the pixels in the RGB data, specifically for:
在初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取第三源RGB值的第三颜色索引。A third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the initialization color table information, and a third color index of the third source RGB value is acquired.
在初始化颜色表信息中以第三颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第四源RGB值,并获取第四源RGB值的第四颜色索引。In the preset range centered on the third color index in the initialization color table information, a fourth source RGB value having the smallest error from the RGB value of the current pixel point is acquired, and a fourth color index of the fourth source RGB value is obtained.
将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对初始化颜色表信息中以第四颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the fourth source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, to pre-populate the fourth color index in the initialization color table information Set multiple source RGB values in the range to modify.
当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述初始化颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与RGB 数据中当前像素点的G分量最接近的第三源RGB值。When the current pixel point is not the last pixel point in the RGB data, the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. The third source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained in the initialization color table information.
当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the initialization color table information is determined as the local color table information of the RGB data.
在一个实施例中,所述接收端2用于采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新时,具体用于:In an embodiment, when the receiving end 2 is used to update the RGB values of each pixel in the RGB data by using the global color table information, specifically, the receiving end 2 is used to:
当所述RGB数据为图片文件中的第N帧图像时,采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新,N为大于1且小于或等于总帧数的正整数。When the RGB data is the Nth frame image in the picture file, the local color table information of the N-1th frame RGB data is trained to generate a partial color table of the RGB data by using the RGB values of the pixels in the RGB data. Information, and the RGB values of the respective pixels are updated using the local color table information of the RGB data, and N is a positive integer greater than 1 and less than or equal to the total number of frames.
在一个实施例中,所述接收端2用于采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体用于:In an embodiment, the receiving end 2 is configured to use the RGB values of the pixels in the RGB data to train the local color table information of the N-1th frame RGB data to generate the local color table information of the RGB data. Specifically used for:
将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息。At least one source RGB value in the partial color table information of the N-1th frame RGB data is sorted according to a preset sorting manner of the G component to generate training color table information.
在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取第五源RGB值的第五颜色索引。A fifth source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the training color table information, and a fifth color index of the fifth source RGB value is acquired.
在训练颜色表信息中以第五颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第六源RGB值,并获取第六源RGB值的第六颜色索引。In the preset range centered on the fifth color index in the training color table information, a sixth source RGB value having the smallest error with the RGB value of the current pixel point is acquired, and a sixth color index of the sixth source RGB value is obtained.
将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以第六颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the sixth source RGB value with the RGB value of the current pixel point, and adopting a preset weight value and an RGB value of the current pixel point, centering on the sixth color index in the training color table information Multiple source RGB values within the preset range are modified.
当所述当前像素点不为RGB数据中的最后一个像素点时,获取修 改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值。When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. The fifth source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
在一个实施例中,所述图片文件为GIF图像。In one embodiment, the picture file is a GIF image.
下面将结合附图30-附图32,对本申请实施例提供的图片文件处理设备进行详细介绍。需要说明的是,附图30-附图32所示的图片文件处理设备,用于执行本申请图14-图16所示实施例的方法,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请图14-图16所示的实施例。The picture file processing device provided by the embodiment of the present application will be described in detail below with reference to FIG. 30 to FIG. It should be noted that the picture file processing device shown in FIG. 30 to FIG. 32 is used to perform the method of the embodiment shown in FIG. 14 to FIG. 16 . For the convenience of description, only the embodiment of the present application is shown. For related parts, the specific technical details are not disclosed, please refer to the embodiment shown in FIG. 14 to FIG. 16 of the present application.
请参见图30,为本申请实施例提供了又一种图片文件处理设备的结构示意图。如图30所示,本申请实施例的所述图片文件处理设备3可以包括:图像转换单元31、图像压缩单元32、码流生成单元33、信息获取单元34和图像编码单元35。FIG. 30 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application. As shown in FIG. 30, the picture file processing apparatus 3 of the embodiment of the present application may include an image conversion unit 31, an image compression unit 32, a code stream generation unit 33, an information acquisition unit 34, and an image coding unit 35.
图像转换单元31,用于根据原始图片文件生成图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据。The image conversion unit 31 is configured to generate a picture header information data segment of the picture file according to the original picture file, and convert each frame image in the picture file into YUV data.
一些实例中,所述图像转换单元31可以解码原始图片文件以生成所述图片文件的图片头信息数据段,所述图像转换单元31进一步将所述图片文件中每帧图像转换为YUV数据。In some examples, the image conversion unit 31 may decode the original picture file to generate a picture header information data segment of the picture file, and the image conversion unit 31 further converts each frame image in the picture file into YUV data.
一些实例中,请一并参见图31,为本申请实施例提供了另一种图像转换单元的结构示意图。如图31所示,所述图像转换单元31可以包括:In some examples, please refer to FIG. 31, which is a schematic structural diagram of another image conversion unit according to an embodiment of the present application. As shown in FIG. 31, the image conversion unit 31 may include:
图像解码子单元311,用于解码原始图片文件以生成图片文件的图片头信息数据段以及图片文件中每帧图像对应的RGB数据。The image decoding sub-unit 311 is configured to decode the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file.
一些实例中,所述图像解码子单元311可以解码原始图片文件。所述图像解码子单元311可以判断所述图片文件中的颜色表信息是否为所述图片文件的全局颜色表信息。In some examples, the image decoding sub-unit 311 can decode the original picture file. The image decoding sub-unit 311 can determine whether the color table information in the picture file is global color table information of the picture file.
当判断所述图片文件的颜色表信息为所述图片文件的全局颜色表信息时,所述图像解码子单元311可以生成包含延时信息、总帧数、全局颜色表信息等的图片头信息数据段,所述延时信息记录有所述图片文件中每帧图像之间的播放间隔时间,所述总帧数为所述图片文件中的图像帧数,同时还生成所述图片文件中每帧图像对应的RGB数据。When it is determined that the color table information of the picture file is global color table information of the picture file, the image decoding sub-unit 311 may generate picture header information data including delay information, total number of frames, global color table information, and the like. And the delay information is recorded with a play interval between each frame image in the picture file, where the total number of frames is the number of image frames in the picture file, and each frame in the picture file is also generated. The RGB data corresponding to the image.
当判断所述图片文件的颜色表信息不为所述图片文件的全局颜色表信息时,所述图像解码子单元311可以生成包含延时信息、总帧数等的图片头信息数据段,所述延时信息记录有所述图片文件中每帧图像之间的播放间隔时间,所述总帧数为所述图片文件中的图像帧数,同时还生成所述图片文件中每帧图像对应的RGB数据。When it is determined that the color table information of the picture file is not the global color table information of the picture file, the image decoding sub-unit 311 may generate a picture header information data segment including delay information, a total number of frames, and the like, The delay information is recorded with a play interval between each frame of the image file, where the total number of frames is the number of image frames in the picture file, and the RGB corresponding to each frame image in the picture file is also generated. data.
图像转换子单元312,用于采用颜色空间转换公式将所述RGB数据转换为YUV数据。The image conversion sub-unit 312 is configured to convert the RGB data into YUV data by using a color space conversion formula.
一些实例中,所述图像转换子单元312可以采用颜色空间转换公式将所述RGB数据转换为YUV数据。In some examples, the image conversion sub-unit 312 can convert the RGB data into YUV data using a color space conversion formula.
图像压缩单元32,用于对所述YUV数据进行编码以生成码流数据。The image compression unit 32 is configured to encode the YUV data to generate code stream data.
一些实例中,所述图像压缩单元32可以进一步对所述YUV数据进行编码处理,生成码流数据,所述编码可以包括预测编码、变换编码、量化编码和熵编码,例如:所述图像压缩单元32可以采用IPPP模式对所述YUV数据进行压缩,第一帧YUV数据为I帧,I帧即为帧内预测帧,其余帧YUV数据为P帧,P帧即为帧间预测帧,可以有效的压缩图片文件的文件数据量,还可以采用固定QP的方式来稳定不同帧之间的质量等。熵编码则可以包括哈夫曼编码、算数编码等。In some examples, the image compression unit 32 may further perform encoding processing on the YUV data to generate code stream data, where the encoding may include predictive coding, transform coding, quantization coding, and entropy coding, for example, the image compression unit. 32. The YUV data may be compressed by using an IPPP mode. The YUV data of the first frame is an I frame, the I frame is an intra prediction frame, and the remaining frame YUV data is a P frame, and the P frame is an inter prediction frame, which can be effective. The amount of file data in the compressed image file can also be fixed in a QP manner to stabilize the quality between different frames. The entropy coding may include Huffman coding, arithmetic coding, and the like.
码流生成单元33,用于存储压缩图像数据。The code stream generating unit 33 is configured to store compressed image data.
一些实例中,所述码流生成单元33可以生成压缩图像数据,所述码流生成单元33可以对所述压缩图像数据进行存储,所述压缩图像数据包含所述图片头信息数据段和所述码流数据。In some examples, the code stream generating unit 33 may generate compressed image data, and the code stream generating unit 33 may store the compressed image data, the compressed image data including the picture header information data segment and the Code stream data.
信息获取单元34,用于解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据。The information acquiring unit 34 is configured to parse the compressed image data to obtain the picture header information data segment and the code stream data.
一些实例中,所述信息获取单元34可以对所述压缩图像数据进行解析处理,以获取所述压缩图像数据中的所述图片头信息数据段和所述码流数据。In some examples, the information acquiring unit 34 may perform parsing processing on the compressed image data to acquire the picture header information data segment and the code stream data in the compressed image data.
图像编码单元35,用于根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。The image encoding unit 35 is configured to generate the YUV data according to the code stream data, and process the YUV data based on the picture header information data segment to generate the picture file.
一些实例中,所述图像编码单元35解码所述码流数据以生成所述YUV数据,并基于图片头信息数据段中的时延信息、总帧数、全局颜色表信息等对所述YUV数据进行编码处理以生成所述图片文件。In some examples, the image encoding unit 35 decodes the code stream data to generate the YUV data, and compares the YUV data based on delay information, total frame number, global color table information, and the like in a picture header information data segment. An encoding process is performed to generate the picture file.
一些实例中,请一并参见图32,为本申请实施例提供了另一种图像编码单元的结构示意图。如图32所示,所述图像编码单元35可以包括:In some examples, please refer to FIG. 32, which is a schematic structural diagram of another image coding unit according to an embodiment of the present application. As shown in FIG. 32, the image encoding unit 35 may include:
图像转换子单元351,用于解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。The image conversion sub-unit 351 is configured to decode the code stream data to generate the YUV data, and convert the YUV data into RGB data by using a color space conversion formula.
一些实例中,所述图像转换子单元351解码所述码流数据以生成所述YUV数据,并可以采用颜色空间转换公式将所述YUV数据转换为RGB数据,一些实例中,所述图像转换子单元351需要依据亮度分量的值域范围确定所采用的颜色空间转换公式。In some examples, the image conversion sub-unit 351 decodes the code stream data to generate the YUV data, and may convert the YUV data into RGB data using a color space conversion formula, in some examples, the image converter Unit 351 needs to determine the color space conversion formula employed based on the range of values of the luminance component.
像素点更新子单元352,用于采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新。The pixel update subunit 352 is configured to update the RGB values of each pixel in the RGB data by using the global color table information.
一些实例中,所述像素点更新子单元352判断所述图片头信息数据段中是否包含所述图片文件的全局颜色表信息,由于之前对所述YUV数据进行过编码处理,因此导致由所述YUV数据转换的RGB数据存在失真的情况,所述图片文件处理设备3可以采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新。In some examples, the pixel point update sub-unit 352 determines whether the global color table information of the picture file is included in the picture header information data segment, because the YUV data is previously encoded, thereby causing the In the case where the RGB data of the YUV data conversion is distorted, the picture file processing device 3 may update the RGB values of the respective pixel points in the RGB data by using the global color table information.
一些实例中,针对图片头信息数据段中存在全局颜色表信息的情况,当所述RGB数据为所述图片文件中的第一帧图像,所述像素点更新子单元352可以采用所述RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。In some examples, for the case where the global color table information exists in the picture header information data segment, when the RGB data is the first frame image in the picture file, the pixel point update subunit 352 may adopt the RGB data. The RGB values of the pixels in the image are trained to generate the local color table information of the RGB data, and the RGB values of the pixels are performed by using the local color table information of the RGB data. Update.
一些实例中,当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,所述像素点更新子单元352可以将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式(例如:升序、降序等)进行排序,以生成训练颜色表信息。In some examples, when the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the pixel point update subunit 352 may use the global At least one source RGB value in the color table information is sorted according to a preset ordering of the G components (eg, ascending, descending, etc.) to generate training color table information.
所述像素点更新子单元352在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取所述第一源RGB值的第一颜色索引。The pixel point update sub-unit 352 acquires, in the training color table information, a first source RGB value whose G component is closest to the G component of the current pixel point in the RGB data, and acquires the first source RGB value. The first color index.
所述像素点更新子单元352在所述训练颜色表信息中以所述第一颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第二源RGB值,并获取所述第二源RGB值的第二颜色索引,可以理解的是,所述像素点更新子单元352可以以所述第一颜色索引为中心,在所述第一颜色索引的前后预设范围内获取多个源RGB值,并分别计算所述第一源RGB值以及所述多个源RGB值与所述当前像素点的RGB 值的误差,并将多个源RGB值中误差最小的源RGB值确定为第二源RGB值。The pixel point update sub-unit 352 acquires, in a preset range centered on the first color index in the training color table information, a second source RGB value that has the smallest error with the RGB value of the current pixel point. Obtaining a second color index of the second source RGB value, it may be understood that the pixel point update subunit 352 may be centered on the first color index and preset before and after the first color index. Acquiring a plurality of source RGB values in a range, and respectively calculating an error of the first source RGB value and the RGB values of the plurality of source RGB values and the current pixel point, and minimizing an error among the plurality of source RGB values The source RGB value is determined to be the second source RGB value.
所述像素点更新子单元352将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第二颜色索引为中心的预设范围内的多个源RGB值进行修改。The pixel point update sub-unit 352 replaces the second source RGB value with the RGB value of the current pixel point, and uses the preset weight value and the RGB value of the current pixel point to the training color table information. A plurality of source RGB values within a preset range centered on the second color index are modified.
当所述当前像素点不为所述RGB数据中的最后一个像素点时,例如当前像素点为图4或图5中所示的RGB数据中的第一个像素点时,所述图片文件处理设备3获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,例如:将所述RGB数据中的第二个像素点作为当前像素点,对修改后得到的所述训练颜色表信息再一次进行训练。一些实例中训练过程可以参见上述训练过程的描述,在此不进行赘述。When the current pixel point is not the last pixel point in the RGB data, for example, the current pixel point is the first pixel point in the RGB data shown in FIG. 4 or FIG. 5, the picture file processing The device 3 obtains the training color table information obtained after the modification, takes the next pixel point of the current pixel point as the current pixel point, and transfers to perform the acquisition of the G component and the RGB data in the training color table information. The first source RGB value of the G component of the current pixel is closest to the first source RGB value, for example, the second pixel point in the RGB data is used as the current pixel point, and the training color table information obtained after the modification is trained again. . The training process in some examples can be referred to the description of the above training process, and will not be described here.
当所述当前像素点为所述RGB数据中的最后一个像素点时,例如当前像素点为图4或图5中所示的RGB数据中的第四个像素点时,所述像素点更新子单元352获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, for example, when the current pixel point is the fourth pixel point in the RGB data shown in FIG. 4 or FIG. 5, the pixel point updater The unit 352 obtains the training color table information obtained after the modification, and determines the training color table information as the local color table information of the RGB data.
所述像素点更新子单元352可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新,一些实例中,所述像素点更新子单元352可以在所述RGB数据的局部颜色表信息中依次获取与所述各像素点相同或误差最小的源RGB值分别替换所述各像素点的RGB值。在一些实例中,所述像素点更新子单元352可以将与所述各像素点相同或误差最小的源RGB值对应的颜色索引分别替换所述各像素点的RGB值。The pixel point update sub-unit 352 may update the RGB values of the pixel points by using local color table information of the RGB data. In some examples, the pixel point update sub-unit 352 may be in the RGB data. The local color table information sequentially acquires the source RGB values that are the same as the respective pixel points or have the smallest error, and replace the RGB values of the respective pixel points. In some examples, the pixel point update sub-unit 352 can replace the RGB values of the respective pixel points with color indices corresponding to the source RGB values that are the same or the smallest error of the respective pixel points.
一些实例中,针对图片头信息数据段中不存在全局颜色表信息的情况,当所述RGB数据为所述图片文件中的第一帧图像,所述像素点更新子单元352可以采用所述RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成所述RGB数据的局部颜色表信息,并采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。In some examples, for the case where there is no global color table information in the picture header information data segment, when the RGB data is the first frame image in the picture file, the pixel point update subunit 352 may adopt the RGB. The RGB values of the pixels in the data are trained to initialize the color table information to generate local color table information of the RGB data, and the RGB values of the pixels are updated by the local color table information of the RGB data. .
一些实例中,当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,所述像素点更新子单元352可以生成一个初始化颜色表信息,例如:(0,0,0)、(1,1,1)、(2,2,2)、……、(255,255,255),所述图片文件处理设备3在初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取所述第三源RGB值的第三颜色索引,所述像素点更新子单元352在所述初始化颜色表信息中以所述第三颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第四源RGB值,并获取所述第四源RGB值的第四颜色索引,所述像素点更新子单元352将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述初始化颜色表信息中以所述第四颜色索引为中心的预设范围内的多个源RGB值进行修改,当所述当前像素点不为所述RGB数据中的最后一个像素点时,所述像素点更新子单元352获取修改后得到的所述初始化颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值,当所述当前像素点为所述RGB数据中的最后一个像素点时,所述像素点更新子单元352获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为所述RGB数据的局部颜色表信息,所述像素点更新子单元352可以采用所述RGB 数据的局部颜色表信息对所述各像素点的RGB值进行更新。需要说明的是,各实例中对初始化颜色表信息进行训练以及采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新的过程均可以参见前述方式的执行过程,在此不进行赘述。In some examples, when the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the pixel point update sub-unit 352 may generate an initialization. Color table information, for example: (0, 0, 0), (1, 1, 1), (2, 2, 2), ..., (255, 255, 255), the picture file processing device 3 is initializing Obtaining, in the color table information, a third source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value, the pixel point update subunit 352: in a preset range centered on the third color index in the initialization color table information, acquire a fourth source RGB value that has the smallest error with the RGB value of the current pixel point, and acquire the fourth source a fourth color index of the RGB value, the pixel point update sub-unit 352 replacing the fourth source RGB value with the RGB value of the current pixel point, and adopting a preset weight value and an RGB value of the current pixel point Centering on the fourth color index in the initialization color table information Modifying a plurality of source RGB values within a preset range, and when the current pixel point is not the last pixel point in the RGB data, the pixel point update subunit 352 acquires the initialization color obtained after the modification The table information, the next pixel point of the current pixel point is taken as the current pixel point, and is transferred to perform the first step of acquiring the G component in the initialization color table information and the G component of the current pixel point in the RGB data. a three-source RGB value, when the current pixel is the last pixel in the RGB data, the pixel update sub-unit 352 acquires the modified color table information obtained after the modification, and initializes the color The table information is determined as local color table information of the RGB data, and the pixel point update sub-unit 352 may update the RGB values of the respective pixel points by using local color table information of the RGB data. It should be noted that the process of training the initialization color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data can refer to the execution process of the foregoing manner, and details are not described herein.
一些实例中,当所述RGB数据为所述图片文件中的第N帧图像时,所述像素点更新子单元352可以将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息,所述像素点更新子单元352在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取所述第五源RGB值的第五颜色索引,所述像素点更新子单元352在所述训练颜色表信息中以所述第五颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第六源RGB值,并获取所述第六源RGB值的第六颜色索引,所述像素点更新子单元352将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第六颜色索引为中心的预设范围内的多个源RGB值进行修改,当所述当前像素点不为所述RGB数据中的最后一个像素点时,所述像素点更新子单元352获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,当所述当前像素点为所述RGB数据中的最后一个像素点时,所述像素点更新子单元352获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息,所述像素点更新子单元352可以采用所述RGB数据的局部颜色表信息对所述各像素点的RGB值进行更新。需要说明的是,各实例中对训练颜色 表信息进行训练以及采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新的过程均可以参见前述方式的执行过程,在此不进行赘述。In some examples, when the RGB data is the Nth frame image in the picture file, the pixel point update subunit 352 may at least one source RGB of the partial color table information of the N-1th frame RGB data. The values are sorted according to a preset sorting manner of the G component to generate training color table information, and the pixel point updating sub-unit 352 acquires the G component and the G component of the current pixel point in the RGB data in the training color table information. a fifth source RGB value that is closest to the fifth color index of the fifth source RGB value, the pixel point update subunit 352 being centered on the fifth color index in the training color table information Within a preset range, acquiring a sixth source RGB value having the smallest error from the RGB value of the current pixel point, and acquiring a sixth color index of the sixth source RGB value, the pixel point update subunit 352 to The sixth source RGB value is replaced by the RGB value of the current pixel point, and the preset weight value and the RGB value of the current pixel point are used, and the training color table information is centered on the sixth color index. Multiple source RGB values in the preset range The row modification, when the current pixel is not the last pixel in the RGB data, the pixel update sub-unit 352 obtains the modified color table information obtained after the modification, and the current pixel point The next pixel is taken as the current pixel, and is transferred to a fifth source RGB value that performs the closest acquisition of the G component in the training color table information to the G component of the current pixel in the RGB data, when the current pixel When the point is the last pixel in the RGB data, the pixel point update sub-unit 352 obtains the modified color table information obtained by the modification, and determines the training color table information as a part of the RGB data. The color point information sub-unit 352 may update the RGB values of the respective pixel points by using local color table information of the RGB data. It should be noted that the process of training the training color table information in each instance and updating the RGB values of each pixel by using the local color table information of the RGB data can be referred to the execution process of the foregoing method, and details are not described herein.
图像编码子单元353,用于采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。The image encoding sub-unit 353 is configured to image-encode the updated RGB data by using the delay time and the total number of frames to generate the picture file.
一些实例中,所述图像编码子单元353采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件,在一些实例中,所述图像编码子单元353可以基于所述延时时间和所述总帧数,并采用LZW对所述RGB数据中各像素点的颜色索引进行图像编码,生成所述图片文件,所述图片文件处理设备3可以对所述图片文件进行存储或者展示。In some examples, the image encoding sub-unit 353 performs image encoding on the updated RGB data using the delay time and the total number of frames to generate the picture file, and in some examples, the image encoding The sub-unit 353 may perform image coding on the color index of each pixel in the RGB data by using LZW to generate the picture file, and the picture file processing device 3 may be configured according to the delay time and the total number of frames. The image file is stored or displayed.
请参见图33,为本申请实施例提供了又一种图片文件处理设备的结构示意图。如图33所示,所述图片文件处理设备3000可以包括:至少一个处理器3001,例如CPU,至少一个网络接口3004,用户接口3003,存储器3005,至少一个通信总线3002。其中,通信总线3002用于实现这些组件之间的连接通信。其中,用户接口3003可以包括显示屏(Display)、键盘(Keyboard),可选用户接口3003还可以包括标准的有线接口、无线接口。网络接口3004一些实例中可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器3005可以是高速RAM存储器,也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。存储器3005一些实例中还可以是至少一个位于远离前述处理器3001的存储装置。如图33所示,作为一种计算机存储介质的存储器3005中可以包括操作系统、网络通信模块、用户接口模块以及图像处理应用程序。FIG. 33 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application. As shown in FIG. 33, the picture file processing apparatus 3000 may include at least one processor 3001, such as a CPU, at least one network interface 3004, a user interface 3003, a memory 3005, and at least one communication bus 3002. Among them, the communication bus 3002 is used to implement connection communication between these components. The user interface 3003 can include a display and a keyboard. The optional user interface 3003 can also include a standard wired interface and a wireless interface. Some examples of the network interface 3004 may include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 3005 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory. The memory 3005 may also be at least one storage device located remotely from the aforementioned processor 3001. As shown in FIG. 33, an operating system, a network communication module, a user interface module, and an image processing application may be included in the memory 3005 as a computer storage medium.
在图33所示的图片文件处理设备3000中,网络接口3004主要用 于分布式服务设备中的功能模块连接,与所述功能模块进行数据通信。而用户接口3003主要用于为用户提供输入的接口,获取用户输入的数据。而处理器3001可以用于调用存储器3005中存储的图像处理应用程序,并具体执行以下步骤:In the picture file processing device 3000 shown in Fig. 33, the network interface 3004 is mainly used for function module connection in a distributed service device, and performs data communication with the function module. The user interface 3003 is mainly used to provide an input interface for the user, and obtain data input by the user. The processor 3001 can be used to call the image processing application stored in the memory 3005, and specifically perform the following steps:
根据原始图片文件生成所述图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据。Generating a picture header information data segment of the picture file according to the original picture file, and converting each frame image in the picture file into YUV data.
对所述YUV数据进行编码以生成码流数据。The YUV data is encoded to generate codestream data.
存储压缩图像数据,所述压缩图像数据包含所述图片头信息数据段和所述码流数据。The compressed image data is stored, the compressed image data including the picture header information data segment and the code stream data.
解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据。Parsing the compressed image data to obtain the picture header information data segment and the code stream data.
解码所述码流数据以生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行编码处理以生成所述图片文件。The code stream data is decoded to generate the YUV data, and the YUV data is encoded based on the picture header information data segment to generate the picture file.
在一个实施例中,所述处理器3001在执行根据原始图片文件生成所述图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据时,具体执行以下步骤:In one embodiment, the processor 3001 performs the following steps when performing the generation of the picture header information data segment of the picture file according to the original picture file and converting each frame image in the picture file into YUV data:
解码原始图片文件以生成图片文件的图片头信息数据段以及图片文件中每帧图像对应的RGB数据,所述图片头信息数据段包括延时信息、总帧数、全局颜色表信息。The original picture file is decoded to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file, and the picture header information data segment includes delay information, total frame number, and global color table information.
采用颜色空间转换公式将所述RGB数据转换为YUV数据。The RGB data is converted to YUV data using a color space conversion formula.
在一个实施例中,所述编码包括预测编码、变换编码、量化编码和熵编码。In one embodiment, the encoding includes predictive coding, transform coding, quantization coding, and entropy coding.
在一个实施例中,所述处理器3001在执行对所述YUV数据进行编码以生成码流数据时,具体执行以下步骤:In one embodiment, the processor 3001 performs the following steps when performing the encoding of the YUV data to generate code stream data:
采用配置参数对所述YUV数据进行编码以生成码流数据,所述配 置参数为对所述YUV数据进行编码的参数,所述配置参数包括标清模式参数、高清模式参数和无损模式参数中的任一种。The YUV data is encoded by using configuration parameters to generate code stream data, the configuration parameter is a parameter for encoding the YUV data, and the configuration parameter includes any one of an SD mode parameter, a HD mode parameter, and a lossless mode parameter. One.
在一个实施例中,所述处理器3001在执行对所述YUV数据进行编码以生成码流数据时,具体执行以下步骤:In one embodiment, the processor 3001 performs the following steps when performing the encoding of the YUV data to generate code stream data:
配置编码器复杂度对所述YUV数据进行编码以生成码流数据,所述编码器复杂度为根据所述发送端的硬件性能所决定的编码的精细度参数。The encoder complexity is configured to encode the YUV data to generate codestream data, the encoder complexity being a fineness parameter of the encoding determined according to hardware performance of the transmitting end.
在一个实施例中,所述处理器3001在执行解码所述码流数据以生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行编码处理以生成所述图片文件时,具体执行以下步骤:In one embodiment, the processor 3001 performs decoding of the code stream data to generate the YUV data, and performs encoding processing on the YUV data based on the picture header information data segment to generate the picture file. , specifically perform the following steps:
解码所述码流数据以生成所述YUV数据,并采用颜色空间转换公式将所述YUV数据转换为RGB数据。The code stream data is decoded to generate the YUV data, and the YUV data is converted to RGB data using a color space conversion formula.
采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新。The RGB values of the respective pixel points in the RGB data are updated using the global color table information.
采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。The updated RGB data is image encoded using the delay time and the total number of frames to generate the picture file.
在一个实施例中,所述处理器3001在执行采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新时,具体执行以下步骤:In an embodiment, when the processor 3001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。When the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the RGB value of each pixel in the RGB data is used to the global color table. The information is trained to generate local color table information of the RGB data, and the RGB values of the respective pixels are updated using the local color table information of the RGB data.
在一个实施例中,所述处理器3001在执行采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部 颜色表信息时,具体执行以下步骤:In one embodiment, the processor 3001 performs the following steps when performing the training of the global color table information by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data:
将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息。At least one source RGB value in the global color table information is sorted according to a preset sorting manner of the G component to generate training color table information.
在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,并所述第一源RGB值的第一颜色索引。And acquiring, in the training color table information, a first source RGB value whose G component is closest to a G component of a current pixel point in the RGB data, and a first color index of the first source RGB value.
所述接收端在训练颜色表信息中以第一颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第二源RGB值,并获取第二源RGB值的第二颜色索引。The receiving end acquires a second source RGB value with a minimum error of the RGB value of the current pixel point in the preset range centered on the first color index in the training color table information, and acquires a second source RGB value second. Color index.
将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对训练颜色表信息中以第二颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the second source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, a pre-position of the second color index in the training color table information Set multiple source RGB values in the range to modify.
当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值。When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. The first source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
在一个实施例中,所述处理器3001在执行采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新时,具体执行以下步骤:In an embodiment, when the processor 3001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
当所述RGB数据为图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。When the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the RGB value of each pixel in the RGB data is used to train the initialization color table information. The RGB values of the respective pixels are updated by generating local color table information of the RGB data and using local color table information of the RGB data.
在一个实施例中,所述处理器3001在执行采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体执行以下步骤:In one embodiment, when the processor 3001 performs the training of initializing the color table information by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data, the following steps are specifically performed:
在初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取第三源RGB值的第三颜色索引。A third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the initialization color table information, and a third color index of the third source RGB value is acquired.
在初始化颜色表信息中以第三颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第四源RGB值,并获取第四源RGB值的第四颜色索引。In the preset range centered on the third color index in the initialization color table information, a fourth source RGB value having the smallest error from the RGB value of the current pixel point is acquired, and a fourth color index of the fourth source RGB value is obtained.
将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对初始化颜色表信息中以第四颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the fourth source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, to pre-populate the fourth color index in the initialization color table information Set multiple source RGB values in the range to modify.
当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述初始化颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值。When the current pixel point is not the last pixel point in the RGB data, the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. The third source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained in the initialization color table information.
当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the initialization color table information is determined as the local color table information of the RGB data.
在一个实施例中,所述处理器3001在执行采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新时,具体执行以下步骤:In an embodiment, when the processor 3001 performs the update of the RGB values of each pixel in the RGB data by using the global color table information, the following steps are specifically performed:
当所述RGB数据为图片文件中的第N帧图像时,采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新,N为大于1且小于或等于总帧数的 正整数。When the RGB data is the Nth frame image in the picture file, the local color table information of the N-1th frame RGB data is trained to generate a partial color table of the RGB data by using the RGB values of the pixels in the RGB data. Information, and the RGB values of the respective pixels are updated using the local color table information of the RGB data, and N is a positive integer greater than 1 and less than or equal to the total number of frames.
在一个实施例中,所述处理器3001在执行采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体执行以下步骤:In one embodiment, the processor 3001 performs training on the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data. Specifically perform the following steps:
将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息。At least one source RGB value in the partial color table information of the N-1th frame RGB data is sorted according to a preset sorting manner of the G component to generate training color table information.
在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取第五源RGB值的第五颜色索引。A fifth source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the training color table information, and a fifth color index of the fifth source RGB value is acquired.
在训练颜色表信息中以第五颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第六源RGB值,并获取第六源RGB值的第六颜色索引。In the preset range centered on the fifth color index in the training color table information, a sixth source RGB value having the smallest error with the RGB value of the current pixel point is acquired, and a sixth color index of the sixth source RGB value is obtained.
将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对训练颜色表信息中以第六颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the sixth source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, a pre-focus on the sixth color index in the training color table information Set multiple source RGB values in the range to modify.
当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值。When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. The fifth source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
在一个实施例中,所述压缩图像数据包含所述图片头信息数据段和所述码流数据。In one embodiment, the compressed image data includes the picture header information data segment and the code stream data.
下面将结合附图34-附图35,对本申请实施例提供的图片文件处理 设备进行详细介绍。需要说明的是,附图34-附图35所示的图片文件处理设备,用于执行本申请图17-图20所示实施例的方法,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请图17-图20所示的实施例。The picture file processing device provided by the embodiment of the present application will be described in detail below with reference to FIG. 34 to FIG. It should be noted that the image file processing device shown in FIG. 34 to FIG. 35 is used to perform the method of the embodiment shown in FIG. 17 to FIG. 20 of the present application. For the convenience of description, only the embodiment of the present application is shown. For related parts, the specific technical details are not disclosed, please refer to the embodiment shown in FIGS. 17-20 of the present application.
请参见图34,为本申请实施例提供了又一种图片文件处理设备的结构示意图。如图34所示,本申请实施例的所述图片文件处理设备4可以包括:像素值获取单元41、颜色表生成单元42和像素值更新单元43。FIG. 34 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application. As shown in FIG. 34, the picture file processing apparatus 4 of the embodiment of the present application may include a pixel value acquisition unit 41, a color table generation unit 42, and a pixel value update unit 43.
像素值获取单元41,用于获取对原始图片文件处理生成的RGB数据,获取RGB数据中的各像素点的RGB值。The pixel value obtaining unit 41 is configured to acquire RGB data generated by processing the original image file, and acquire RGB values of each pixel in the RGB data.
一些实例中,所述像素值获取单元41可以获取对原始图片文件解码生成的RGB数据。所述RGB数据可以转换为YUV数据,并将YUV数据进行编码生成码流数据,进一步生成包含码流数据和图片头信息数据段的压缩图像数据,所述压缩图像数据可以用于存储,或者传输至图片文件处理设备4进行图片文件的还原,在一些实例中,所述像素值获取单元41获取所述压缩图像数据,可以解析所述压缩图像数据以获取所述图片头信息数据段和所述码流数据,并解码所述码流数据生成YUV数据,进一步将YUV数据转换为RGB数据,所述像素值获取单元41获取所述RGB数据,并获取所述RGB数据中的各像素点的RGB值。In some examples, the pixel value acquisition unit 41 may acquire RGB data generated by decoding the original picture file. The RGB data may be converted into YUV data, and the YUV data is encoded to generate code stream data, and further generated compressed image data including code stream data and picture header information data segments, the compressed image data may be used for storage or transmission. To the picture file processing device 4 to perform restoration of the picture file, in some examples, the pixel value acquisition unit 41 acquires the compressed image data, and the compressed image data may be parsed to obtain the picture header information data segment and the Code stream data, and decoding the code stream data to generate YUV data, further converting YUV data into RGB data, the pixel value obtaining unit 41 acquiring the RGB data, and acquiring RGB of each pixel point in the RGB data value.
颜色表生成单元42,用于采用各像素点的RGB值对RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息。The color table generating unit 42 is configured to train the initial color table information of the RGB data by using the RGB values of the respective pixels to generate local color table information of the RGB data.
一些实例中,所述颜色表生成单元42判断所述图片头信息数据段中是否包含所述图片文件的全局颜色表信息,由于之前对所述YUV数据进行过编码处理,因此导致由所述YUV数据转换的RGB数据存在失真的情况,所述颜色表生成单元42可以采用所述全局颜色表信息对所述RGB数据中的各像素点的RGB值进行更新,可以理解的是,所述 RGB数据中可以包含一个或多个像素点,当所述RGB数据中仅存在一个像素点时,可以采用所述像素点的RGB值对所述初始颜色表信息进行训练,当所述RGB数据中存在多个像素点时,可以采用多个像素点中各像素点的RGB值对所述初始颜色表信息进行训练,所述颜色表生成单元42需要重新对所述全局颜色表信息进行训练,以生成符合所述RGB数据的局部颜色表信息,而对于不存在全局颜色表信息的情况,所述颜色表生成单元42可以生成初始化颜色表信息,并通过对所述初始化颜色表信息进行训练,以生成符合所述RGB数据的局部颜色表信息。In some examples, the color table generating unit 42 determines whether the global color table information of the picture file is included in the picture header information data segment, and the YUV is previously encoded by the YUV data, thereby causing the YUV to be The RGB data of the data conversion may be distorted. The color table generating unit 42 may update the RGB values of each pixel in the RGB data by using the global color table information. It can be understood that the RGB data is One or more pixels may be included. When there is only one pixel in the RGB data, the initial color table information may be trained by using the RGB values of the pixel, when there are many RGB data. For each pixel, the initial color table information may be trained by using RGB values of each of the plurality of pixels, and the color table generating unit 42 needs to retrain the global color table information to generate a match. The local color table information of the RGB data, and for the case where there is no global color table information, the color table generating unit 42 may generate an initialization color Table information, and by training of the color table initialization information to generate comply with local color table information of the RGB data.
一些实例中,针对图片头信息数据段中存在全局颜色表信息的情况,当所述RGB数据为所述图片文件中的第一帧图像,所述颜色表生成单元42可以采用所述RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成所述RGB数据的局部颜色表信息。In some examples, for the case where the global color table information exists in the picture header information data segment, when the RGB data is the first frame image in the picture file, the color table generating unit 42 may adopt the RGB data. The RGB values of the respective pixels train the global color table information to generate local color table information of the RGB data.
一些实例中,当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,所述颜色表生成单元42可以将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式(例如:升序、降序等)进行排序,以生成训练颜色表信息。In some examples, when the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the color table generating unit 42 may use the global color At least one source RGB value in the table information is sorted according to a preset ordering of the G components (eg, ascending, descending, etc.) to generate training color table information.
所述颜色表生成单元42在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取所述第一源RGB值的第一颜色索引。The color table generating unit 42 acquires, in the training color table information, a first source RGB value whose G component is closest to the G component of the current pixel point in the RGB data, and acquires the first source RGB value. A color index.
所述颜色表生成单元42在所述训练颜色表信息中以所述第一颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第二源RGB值,并获取所述第二源RGB值的第二颜色索引,可以理解的是,所述颜色表生成单元42可以以所述第一颜色索引为中心,在所述第一颜色索引的前后预设范围内获取多个源RGB值,并分别计算 所述第一源RGB值以及所述多个源RGB值与所述当前像素点的RGB值的误差,并将多个源RGB值中误差最小的源RGB值确定为第二源RGB值。The color table generating unit 42 acquires, in a preset range centered on the first color index in the training color table information, a second source RGB value that has the smallest error with the RGB value of the current pixel point, and Obtaining a second color index of the second source RGB value, it may be understood that the color table generating unit 42 may be centered on the first color index, within a preset range before and after the first color index Obtaining a plurality of source RGB values, and separately calculating the first source RGB value and the error of the plurality of source RGB values and the RGB value of the current pixel point, and the source RGB having the smallest error among the plurality of source RGB values The value is determined to be the second source RGB value.
所述颜色表生成单元42将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第二颜色索引为中心的预设范围内的多个源RGB值进行修改。The color table generating unit 42 replaces the second source RGB value with the RGB value of the current pixel point, and uses the preset weight value and the RGB value of the current pixel point in the training color table information. A plurality of source RGB values within a preset range centered on the second color index are modified.
当所述当前像素点不为所述RGB数据中的最后一个像素点时,例如当前像素点为图4或图5中所示的RGB数据中的第一个像素点时,所述颜色表生成单元42获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第一源RGB值,例如:将所述RGB数据中的第二个像素点作为当前像素点,对修改后得到的所述训练颜色表信息再一次进行训练。一些实例中训练过程可以参见上述训练过程的描述,在此不进行赘述。When the current pixel point is not the last pixel point in the RGB data, for example, when the current pixel point is the first pixel point in the RGB data shown in FIG. 4 or FIG. 5, the color table generation The unit 42 obtains the training color table information obtained after the modification, takes the next pixel point of the current pixel point as the current pixel point, and transfers to perform the acquisition of the G component and the RGB data in the training color table information. The first source RGB value of the G component of the current pixel is closest to the first source RGB value, for example, the second pixel point in the RGB data is used as the current pixel point, and the training color table information obtained after the modification is trained again. . The training process in some examples can be referred to the description of the above training process, and will not be described here.
当所述当前像素点为所述RGB数据中的最后一个像素点时,例如当前像素点为图4或图5中所示的RGB数据中的第四个像素点时,所述颜色表生成单元42获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, for example, when the current pixel point is the fourth pixel point in the RGB data shown in FIG. 4 or FIG. 5, the color table generating unit 42: obtaining the training color table information obtained after the modification, and determining the training color table information as local color table information of the RGB data.
一些实例中,针对图片头信息数据段中不存在全局颜色表信息的情况,当所述RGB数据为所述图片文件中的第一帧图像,所述颜色表生成单元42可以采用所述RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成所述RGB数据的局部颜色表信息。In some examples, for the case where there is no global color table information in the picture header information data segment, when the RGB data is the first frame image in the picture file, the color table generating unit 42 may adopt the RGB data. The RGB values of the respective pixels in the pair are trained to initialize the color table information to generate local color table information of the RGB data.
一些实例中,当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,所述颜色表生成 单元42可以生成一个初始化颜色表信息,例如:(0,0,0)、(1,1,1)、(2,2,2)、……、(255,255,255),所述颜色表生成单元42在初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取所述第三源RGB值的第三颜色索引,所述颜色表生成单元42在所述初始化颜色表信息中以所述第三颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第四源RGB值,并获取所述第四源RGB值的第四颜色索引,所述颜色表生成单元42将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述初始化颜色表信息中以所述第四颜色索引为中心的预设范围内的多个源RGB值进行修改,当所述当前像素点不为所述RGB数据中的最后一个像素点时,所述颜色表生成单元42获取修改后得到的所述初始化颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第三源RGB值,当所述当前像素点为所述RGB数据中的最后一个像素点时,所述颜色表生成单元42获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为所述RGB数据的局部颜色表信息。需要说明的是,各实例中对初始化颜色表信息进行训练的过程可以参见前述方式的执行过程,在此不进行赘述。In some examples, when the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the color table generating unit 42 may generate an initialization color. Table information, for example: (0, 0, 0), (1, 1, 1), (2, 2, 2), ..., (255, 255, 255), the color table generating unit 42 initializes colors Obtaining, in the table information, a third source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value, where the color table generating unit 42 is And acquiring, in a preset range centered on the third color index, the fourth source RGB value having the smallest error with the RGB value of the current pixel point, and acquiring the fourth source RGB value. a fourth color index, the color table generating unit 42 replacing the fourth source RGB value with the RGB value of the current pixel point, and adopting a preset weight value and an RGB value of the current pixel point, a preset range centered on the fourth color index in the initialization color table information The plurality of source RGB values are modified, and when the current pixel point is not the last pixel point in the RGB data, the color table generating unit 42 acquires the initialized color table information obtained after the modification, and The next pixel point of the current pixel point is used as the current pixel point, and is transferred to a third source RGB value that performs the closest acquisition of the G component in the initialization color table information to the G component of the current pixel point in the RGB data. When the current pixel point is the last pixel point in the RGB data, the color table generating unit 42 acquires the training color table information obtained after the modification, and determines the initialization color table information as The local color table information of the RGB data. It should be noted that the process of training the initialization color table information in each instance may refer to the execution process of the foregoing manner, and details are not described herein.
一些实例中,针对所述RGB数据不为所述图片文件中的第一帧图像,即所述RGB数据为所述图片文件中的第N帧图像时,其中,N为大于1且小于或等于所述总帧数的正整数,所述颜色表生成单元42可以采用所述RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成所述RGB数据的局部颜色表信息。In some examples, when the RGB data is not the first frame image in the picture file, that is, the RGB data is the Nth frame image in the picture file, where N is greater than 1 and less than or equal to a positive integer of the total number of frames, the color table generating unit 42 may train the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate the RGB Local color table information for the data.
一些实例中,当所述RGB数据为所述图片文件中的第N帧图像时, 所述颜色表生成单元42可以将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息,所述颜色表生成单元42在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取所述第五源RGB值的第五颜色索引,所述颜色表生成单元42在所述训练颜色表信息中以所述第五颜色索引为中心的预设范围内,获取与所述当前像素点的RGB值误差最小的第六源RGB值,并获取所述第六源RGB值的第六颜色索引,所述颜色表生成单元42将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以所述第六颜色索引为中心的预设范围内的多个源RGB值进行修改,当所述当前像素点不为所述RGB数据中的最后一个像素点时,所述颜色表生成单元42获取修改后得到的所述训练颜色表信息,将所述当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与所述RGB数据中当前像素点的G分量最接近的第五源RGB值,当所述当前像素点为所述RGB数据中的最后一个像素点时,所述颜色表生成单元42获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为所述RGB数据的局部颜色表信息。需要说明的是,各实例中对训练颜色表信息进行训练可以参见前述方式的执行过程,在此不进行赘述。In some examples, when the RGB data is the Nth frame image in the picture file, the color table generating unit 42 may set at least one source RGB value in the local color table information of the N-1th frame RGB data. Sorting according to a preset sorting manner of the G component to generate training color table information, wherein the color table generating unit 42 acquires the G component in the training color table information and is closest to the G component of the current pixel point in the RGB data. a fifth source RGB value, and acquiring a fifth color index of the fifth source RGB value, wherein the color table generating unit 42 has a preset range centered on the fifth color index in the training color table information a sixth source RGB value having the smallest error in the RGB value of the current pixel point, and acquiring a sixth color index of the sixth source RGB value, the color table generating unit 42 to the sixth source RGB The value is replaced by the RGB value of the current pixel point, and the preset weight value and the RGB value of the current pixel point are used, and the training color table information is within a preset range centered on the sixth color index. Multiple source RGB values are modified when When the current pixel point is not the last pixel point in the RGB data, the color table generating unit 42 acquires the training color table information obtained after the modification, and uses the next pixel point of the current pixel point as a current pixel point, and proceeds to perform a fifth source RGB value that is obtained in the training color table information to obtain a G component closest to a G component of a current pixel point in the RGB data, when the current pixel point is the RGB When the last pixel in the data, the color table generating unit 42 acquires the training color table information obtained after the modification, and determines the training color table information as the local color table information of the RGB data. It should be noted that the training of the training color table information in each instance can be referred to the execution process of the foregoing manner, and details are not described herein.
像素值更新单元43,用于采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。The pixel value updating unit 43 is configured to update the RGB values of the respective pixel points by using the local color table information of the RGB data.
一些实例中,所述像素值更新单元43可以采用所述RGB数据的局部颜色表信息对所述RGB数据中各像素点的RGB值进行更新,所述图片文件处理设备4采用所述延时时间和所述总帧数将更新后的所述RGB 数据进行图像编码以生成所述图片文件。In some examples, the pixel value updating unit 43 may update the RGB values of each pixel in the RGB data by using local color table information of the RGB data, and the picture file processing device 4 adopts the delay time. The updated RGB data is image-encoded with the total number of frames to generate the picture file.
在本申请实施例中,通过对全局颜色表信息或初始化颜色表信息进行训练,生成RGB数据的局部颜色表信息,有效的减少了图像的失真。通过采用G分量获取最接近的源RGB值,并在颜色表信息中进行小范围的颜色索引搜索,无需遍历整个颜色表信息,降低了对局部颜色表信息训练的复杂度,进一步提升了图片文件的编码效率。In the embodiment of the present application, the local color table information of the RGB data is generated by training the global color table information or the initialization color table information, thereby effectively reducing the distortion of the image. By using the G component to obtain the closest source RGB value and performing a small range of color index search in the color table information, it is not necessary to traverse the entire color table information, thereby reducing the complexity of training the local color table information, and further improving the image file. The coding efficiency.
请参见图35,为本申请实施例提供了又一种图片文件处理设备的结构示意图。如图35所示,所述图片文件处理设备4000可以包括:至少一个处理器4001,例如CPU,至少一个网络接口4004,用户接口4003,存储器4005,至少一个通信总线4002。其中,通信总线4002用于实现这些组件之间的连接通信。其中,用户接口4003可以包括显示屏(Display)、键盘(Keyboard),可选用户接口4003还可以包括标准的有线接口、无线接口。网络接口4004一些实例中可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器4005可以是高速RAM存储器,也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。存储器4005一些实例中还可以是至少一个位于远离前述处理器4001的存储装置。如图35所示,作为一种计算机存储介质的存储器4005中可以包括操作系统、网络通信模块、用户接口模块以及图像处理应用程序。FIG. 35 is a schematic structural diagram of still another picture file processing apparatus according to an embodiment of the present application. As shown in FIG. 35, the picture file processing apparatus 4000 may include at least one processor 4001, such as a CPU, at least one network interface 4004, a user interface 4003, a memory 4005, and at least one communication bus 4002. Among them, the communication bus 4002 is used to implement connection communication between these components. The user interface 4003 can include a display and a keyboard. The optional user interface 4003 can also include a standard wired interface and a wireless interface. Some examples of the network interface 4004 may include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 4005 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory. The memory 4005 may also be at least one storage device located remotely from the aforementioned processor 4001 in some examples. As shown in FIG. 35, an operating system, a network communication module, a user interface module, and an image processing application may be included in the memory 4005 as a computer storage medium.
在图35所示的图片文件处理设备4000中,网络接口4004主要用于连接发送端,与所述发送端进行数据通信。而用户接口4003主要用于为用户提供输入的接口,获取用户输入的数据。而处理器4001可以用于调用存储器4005中存储的图像处理应用程序,并具体执行以下步骤:In the picture file processing device 4000 shown in FIG. 35, the network interface 4004 is mainly used to connect to the transmitting end and perform data communication with the transmitting end. The user interface 4003 is mainly used to provide an input interface for the user, and obtain data input by the user. The processor 4001 can be used to call the image processing application stored in the memory 4005, and specifically perform the following steps:
获取对原始图片文件处理生成的RGB数据,获取RGB数据中的各像素点的RGB值。Obtain RGB data generated by processing the original image file, and obtain RGB values of each pixel in the RGB data.
采用各像素点的RGB值对RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息。The initial color table information of the RGB data is trained using the RGB values of the respective pixels to generate local color table information of the RGB data.
采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。The RGB values of the respective pixels are updated using the local color table information of the RGB data.
在一个实施例中,所述处理器4001在执行采用各像素点的RGB值对RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体执行以下步骤:In an embodiment, when the processor 4001 performs the training of the initial color table information of the RGB data by using the RGB values of the respective pixels to generate the local color table information of the RGB data, the following steps are specifically performed:
当所述RGB数据为图片文件中的第一帧图像,且解码所述图片文件生成的图片头信息数据段中存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息。When the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment generated by decoding the picture file, the RGB value of each pixel in the RGB data is used. The global color table information is trained to generate local color table information for the RGB data.
在一个实施例中,所述处理器4001在执行采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体执行以下步骤:In one embodiment, when the processor 4001 performs the training of the global color table information by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data, the following steps are specifically performed:
将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息。At least one source RGB value in the global color table information is sorted according to a preset sorting manner of the G component to generate training color table information.
在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取第一源RGB值的第一颜色索引。A first source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the training color table information, and a first color index of the first source RGB value is acquired.
在训练颜色表信息中以第一颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第二源RGB值,并获取第二源RGB值的第二颜色索引。In the preset range centered on the first color index in the training color table information, a second source RGB value having the smallest error with the RGB value of the current pixel point is acquired, and a second color index of the second source RGB value is obtained.
将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对训练颜色表信息中以第二颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the second source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, a pre-position of the second color index in the training color table information Set multiple source RGB values in the range to modify.
当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值。When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. The first source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
在一个实施例中,所述处理器4001在执行采用各像素点的RGB值对所述RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体执行以下步骤:In an embodiment, when the processor 4001 performs the training of the initial color table information of the RGB data by using the RGB values of the respective pixels to generate the local color table information of the RGB data, the following steps are specifically performed:
当所述RGB数据为图片文件中的第一帧图像,且解码所述图片文件生成的图片头信息数据段中不存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息。When the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment generated by decoding the picture file, the RGB value pair of each pixel in the RGB data is initialized. The color table information is trained to generate local color table information of the RGB data.
在一个实施例中,所述处理器4001在执行采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体执行以下步骤:In one embodiment, when the processor 4001 performs the training of initializing the color table information by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data, the following steps are specifically performed:
在初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取第三源RGB值的第三颜色索引。A third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data is acquired in the initialization color table information, and a third color index of the third source RGB value is acquired.
在初始化颜色表信息中以第三颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第四源RGB值,并获取第四源RGB值的第四颜色索引。In the preset range centered on the third color index in the initialization color table information, a fourth source RGB value having the smallest error from the RGB value of the current pixel point is acquired, and a fourth color index of the fourth source RGB value is obtained.
将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对初始化颜色表信息中以第四颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the fourth source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, to pre-populate the fourth color index in the initialization color table information Set multiple source RGB values in the range to modify.
当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述初始化颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值。When the current pixel point is not the last pixel point in the RGB data, the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. The third source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained in the initialization color table information.
当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the initialization color table information is determined as the local color table information of the RGB data.
在一个实施例中,所述处理器4001在执行采用各像素点的RGB值对RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体执行以下步骤:In an embodiment, when the processor 4001 performs the training of the initial color table information of the RGB data by using the RGB values of the respective pixels to generate the local color table information of the RGB data, the following steps are specifically performed:
当所述RGB数据为图片文件中的第N帧图像时,采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,N为大于1且小于或等于总帧数的正整数。When the RGB data is the Nth frame image in the picture file, the local color table information of the N-1th frame RGB data is trained to generate a partial color table of the RGB data by using the RGB values of the pixels in the RGB data. Information, N is a positive integer greater than 1 and less than or equal to the total number of frames.
在一个实施例中,所述处理器4001在执行采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息时,具体执行以下步骤:In one embodiment, the processor 4001 performs training on the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate the local color table information of the RGB data. Specifically perform the following steps:
将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息。At least one source RGB value in the partial color table information of the N-1th frame RGB data is sorted according to a preset sorting manner of the G component to generate training color table information.
在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值,并所述第五源RGB值的第五颜色索引。A fifth source RGB value whose G component is closest to the G component of the current pixel point in the RGB data and a fifth color index of the fifth source RGB value are acquired in the training color table information.
在训练颜色表信息中以第五颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第六源RGB值,并获取第六源RGB值的第六颜色索引。In the preset range centered on the fifth color index in the training color table information, a sixth source RGB value having the smallest error with the RGB value of the current pixel point is acquired, and a sixth color index of the sixth source RGB value is obtained.
将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预 设权重值和所述当前像素点的RGB值,对训练颜色表信息中以第六颜色索引为中心的预设范围内的多个源RGB值进行修改。Substituting the sixth source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, a pre-focus on the sixth color index in the training color table information Set multiple source RGB values in the range to modify.
当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值。When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. The fifth source RGB value that is closest to the G component of the current pixel point in the RGB data is obtained from the training color table information.
当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
在一个实施例中,所述图片文件为GIF图像。In one embodiment, the picture file is a GIF image.
在本申请实施例中,通过对全局颜色表信息或初始化颜色表信息进行训练,生成RGB数据的局部颜色表信息,有效的减少了图像的失真。通过采用G分量获取最接近的源RGB值,并在颜色表信息中进行小范围的颜色索引搜索,无需遍历整个颜色表信息,降低了对局部颜色表信息训练的复杂度,进一步提升了图片文件的编码效率。In the embodiment of the present application, the local color table information of the RGB data is generated by training the global color table information or the initialization color table information, thereby effectively reducing the distortion of the image. By using the G component to obtain the closest source RGB value and performing a small range of color index search in the color table information, it is not necessary to traverse the entire color table information, thereby reducing the complexity of training the local color table information, and further improving the image file. The coding efficiency.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。One of ordinary skill in the art can understand that all or part of the process of implementing the foregoing embodiments can be completed by a computer program to instruct related hardware, and the program can be stored in a computer readable storage medium. When executed, the flow of an embodiment of the methods as described above may be included. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
以上所揭露的仅为本申请较佳实施例而已,当然不能以此来限定本申请之权利范围,因此依本申请权利要求所作的等同变化,仍属本申请所涵盖的范围。The above is only the preferred embodiment of the present application, and the scope of the application is not limited thereto, and the equivalent changes made in the claims of the present application are still within the scope of the present application.
Claims (46)
- 一种图片文件处理方法,应用于计算设备,包括:A picture file processing method, applied to a computing device, comprising:接收发送设备发送的针对原始图片文件的转码码流,解析所述转码码流以获取图片头信息数据段和码流数据,所述图片头信息数据段包括所述原始图片文件的颜色表,所述码流数据为所述发送设备对所述原始图片文件中各像素的第一色彩数据进行编码生成的信息;Receiving, by the sending device, a transcoded code stream for the original picture file, parsing the transcoded code stream to obtain a picture header information data segment and code stream data, where the picture header information data segment includes a color table of the original picture file The code stream data is information generated by the sending device to encode first color data of each pixel in the original picture file;解码所述码流数据以生成第二色彩数据,并基于所述颜色表对所述第二色彩数据进行处理以生成第二图片文件。The code stream data is decoded to generate second color data, and the second color data is processed based on the color table to generate a second picture file.
- 根据权利要求1所述的方法,其中,所述基于所述颜色表对所述第二色彩数据进行处理以生成第二图片文件包括:The method of claim 1, wherein the processing the second color data based on the color table to generate a second picture file comprises:利用所述第二色彩数据中各像素点的色彩值和所述颜色表生成所述第二色彩数据对应的局部颜色表,并采用所述局部颜色表对所述各像素点的色彩值进行更新。Generating a partial color table corresponding to the second color data by using the color value of each pixel in the second color data and the color table, and updating the color value of each pixel point by using the local color table .
- 根据权利要求2所述的方法,其中,利用所述第二色彩数据中各像素点的色彩值和所述颜色表生成所述第二色彩数据对应的局部颜色表包括:The method according to claim 2, wherein generating a partial color table corresponding to the second color data by using a color value of each pixel in the second color data and the color table comprises:将所述颜色表中的色彩值按照一个色彩分量的预设排序方式进行排序,以生成训练颜色表;Sorting the color values in the color table according to a preset ordering manner of one color component to generate a training color table;针对所述第二色彩数据中的各像素点,For each pixel point in the second color data,在所述训练颜色表中获取所述色彩分量与所述像素点的所述色彩分量最接近的第一色彩值,并获取第一色彩值的第一颜色索引;Obtaining a first color value of the color component closest to the color component of the pixel point in the training color table, and acquiring a first color index of the first color value;在所述训练颜色表中以所述第一颜色索引为中心的预设范围内,获 取与所述像素点的色彩值误差最小的第二色彩值,并获取第二色彩值的第二颜色索引;Obtaining, in a preset range centered on the first color index in the training color table, a second color value having a smallest error with a color value of the pixel point, and acquiring a second color index of the second color value ;将所述第二色彩值替换为所述像素点的色彩值,并采用预设权重值和所述像素点的色彩值,对所述训练颜色表中以所述第二颜色索引为中心的预设范围内的多个色彩值进行修改;Substituting the second color value with a color value of the pixel point, and using a preset weight value and a color value of the pixel point, a pre-position of the second color index in the training color table Set a number of color values within the range to modify;将修改后的所述训练颜色表确定为所述局部颜色表。The modified training color table is determined as the partial color table.
- 根据权利要求2所述的方法,其中,The method of claim 2, wherein当所述第二色彩数据为所述原始图片文件的首帧图像的色彩数据时,利用所述第二色彩数据中各像素点的色彩值和所述颜色表生成所述第二色彩数据对应的局部颜色表包括:利用所述第二色彩数据对所述首帧图像的初始颜色表进行训练,得到所述首帧图像对应的局部颜色表,所述首帧图像的所述初始颜色表为所述颜色表;When the second color data is the color data of the first frame image of the original picture file, generating the second color data by using the color value of each pixel in the second color data and the color table. The local color table includes: training the initial color table of the first frame image by using the second color data to obtain a local color table corresponding to the first frame image, where the initial color table of the first frame image is Color table当所述第二色彩数据为所述原始图片文件的第N帧图像的色彩数据时,利用所述第二色彩数据中各像素点的色彩值和所述颜色表生成所述第二色彩数据对应的局部颜色表包括:利用所述第二色彩数据对所述第N帧图像对应的初始颜色表进行训练,得到所述第N帧图像对应的局部颜色表;其中,所述第N帧图像对应的初始颜色表为所述原始图片文件的第N-1帧图像对应的局部颜色表,N为大于1的整数。When the second color data is the color data of the Nth frame image of the original picture file, the second color data is generated by using the color value of each pixel in the second color data and the color table. The local color table includes: training, by using the second color data, an initial color table corresponding to the Nth frame image to obtain a local color table corresponding to the Nth frame image; wherein the Nth frame image corresponds to The initial color table is a partial color table corresponding to the N-1th frame image of the original picture file, and N is an integer greater than 1.
- 根据权利要求4所述的方法,其中,利用所述第二色彩数据对所述初始颜色表进行训练得到所述局部颜色表包括:The method of claim 4, wherein the training the initial color table with the second color data to obtain the local color table comprises:将所述初始颜色表中的色彩值按照一个色彩分量的预设排序方式进行排序,以生成训练颜色表;Sorting the color values in the initial color table according to a preset ordering manner of one color component to generate a training color table;针对所述第二色彩数据中的各像素点,For each pixel point in the second color data,在所述训练颜色表中获取所述色彩分量与所述像素点的所述色彩分量最接近的第一色彩值,并获取第一色彩值的第一颜色索引;Obtaining a first color value of the color component closest to the color component of the pixel point in the training color table, and acquiring a first color index of the first color value;在所述训练颜色表中以所述第一颜色索引为中心的预设范围内,获取与所述像素点的色彩值误差最小的第二色彩值,并获取第二色彩值的第二颜色索引;Obtaining, in a preset range centered on the first color index in the training color table, a second color value having a smallest error with a color value of the pixel point, and acquiring a second color index of the second color value ;将所述第二色彩值替换为所述像素点的色彩值,并采用预设权重值和所述像素点的色彩值,对所述训练颜色表中以所述第二颜色索引为中心的预设范围内的多个色彩值进行修改;Substituting the second color value with a color value of the pixel point, and using a preset weight value and a color value of the pixel point, a pre-position of the second color index in the training color table Set a number of color values within the range to modify;将修改后的所述训练颜色表确定为所述局部颜色表。The modified training color table is determined as the partial color table.
- 根据权利要求1所述的方法,其中,所述图片头信息数据段进一步包括延时信息、总帧数;The method according to claim 1, wherein the picture header information data segment further comprises delay information and a total number of frames;其中,基于所述颜色表对所述第二色彩数据进行处理以生成所述第二图片文件包括:The processing, by the color table, the second color data to generate the second image file includes:采用所述延时时间和所述总帧数将更新后的所述第二色彩数据进行图像编码以生成所述第二图片文件。And updating the updated second color data by using the delay time and the total number of frames to generate the second picture file.
- 一种图片文件处理方法,应用于计算设备,包括:A picture file processing method, applied to a computing device, comprising:获取第一图片文件的色彩数据,所述色彩数据包括各像素点的色彩值;Obtaining color data of the first picture file, where the color data includes color values of each pixel point;获取初始颜色表,所述初始颜色表中各色彩值按照一个色彩分量的值的预设排序方式排列;Obtaining an initial color table, wherein each color value in the initial color table is arranged according to a preset sorting manner of values of one color component;根据所述各像素点的色彩值中所述色彩分量的值在所述初始颜色表中搜索各像素点在所述初始颜色表中对应的初始色彩值,利用所述初始色彩值对所述各像素点的所述色彩值进行更新;Searching, in the initial color table, a corresponding initial color value of each pixel in the initial color table according to the value of the color component in the color value of each pixel point, using the initial color value pair The color value of the pixel is updated;将更新后的所述色彩数据进行图像编码以生成所述第二图片文件。The updated color data is image encoded to generate the second picture file.
- 根据权利要求7所述的方法,其中,根据所述各像素点的色彩值中所述色彩分量的值在所述初始颜色表中搜索各像素点在所述初始颜色表中对应的初始色彩值包括:The method according to claim 7, wherein the initial color value corresponding to each pixel in the initial color table is searched for in the initial color table according to the value of the color component in the color value of each pixel point. include:在所述初始颜色表中获取所述色彩分量与所述像素点的所述色彩分量最接近的第一色彩值,并获取第一色彩值的第一颜色索引;Obtaining a first color value of the color component closest to the color component of the pixel point in the initial color table, and acquiring a first color index of the first color value;在所述初始颜色表中以所述第一颜色索引为中心的预设范围内,获取与所述像素点的色彩值误差最小的第二色彩值作为所述初始色彩值。A second color value having the smallest error in color value of the pixel point is obtained as the initial color value in a preset range centered on the first color index in the initial color table.
- 根据权利要求7所述的方法,其中,利用所述初始色彩值对所述各像素点的所述色彩值进行更新包括:The method of claim 7, wherein updating the color values of the respective pixel points with the initial color value comprises:利用所述色彩数据中各像素点的色彩值和所述初始色彩值对所述初始颜色表进行修改,得到所述色彩数据对应的局部颜色表,并采用所述局部颜色表对所述各像素点的色彩值进行更新。And modifying the initial color table by using a color value of each pixel in the color data and the initial color value to obtain a partial color table corresponding to the color data, and using the local color table to each pixel The color value of the point is updated.
- 根据权利要求9所述的方法,其中,利用所述色彩数据中各像素点的色彩值和所述初始色彩值对所述初始颜色表进行修改包括:The method of claim 9, wherein modifying the initial color table with a color value of each pixel in the color data and the initial color value comprises:获取所述初始色彩值的第二颜色索引;Obtaining a second color index of the initial color value;将所述初始色彩值替换为所述像素点的色彩值,并采用预设权重值和所述像素点的色彩值,对所述训练颜色表中以所述第二颜色索引为中心的预设范围内的多个色彩值进行修改;Substituting the initial color value with a color value of the pixel point, and using a preset weight value and a color value of the pixel point, a preset centered on the second color index in the training color table Modifying multiple color values within the range;将修改后的所述初始颜色表确定为所述局部颜色表。The modified initial color table is determined as the partial color table.
- 根据权利要求9所述的方法,其中,The method of claim 9 wherein当所述色彩数据为所述原始图片文件的首帧图像的色彩数据时,利用所述色彩数据中各像素点的色彩值和所述初始色彩值对所述初始颜色表进行修改得到所述色彩数据对应的局部颜色表包括:利用所述色彩数据对所述首帧图像的初始颜色表进行训练,得到所述首帧图像对应的局部颜色表,所述首帧图像的所述初始颜色表为所述初始颜色表;When the color data is the color data of the first frame image of the original picture file, the initial color table is modified by using the color value of each pixel in the color data and the initial color value to obtain the color. The local color table corresponding to the data includes: training the initial color table of the first frame image by using the color data, and obtaining a local color table corresponding to the first frame image, where the initial color table of the first frame image is The initial color table;当所述色彩数据为所述原始图片文件的第N帧图像的色彩数据时,利用所述色彩数据中各像素点的色彩值生成所述色彩数据对应的局部颜色表包括:利用所述第二色彩数据对所述第N帧图像对应的初始颜色表进行训练,得到所述第N帧图像对应的局部颜色表;其中,所述第N帧图像对应的初始颜色表为所述原始图片文件的第N-1帧图像对应的局部颜色表,N为大于1的整数。When the color data is the color data of the Nth frame image of the original picture file, generating a partial color table corresponding to the color data by using the color value of each pixel in the color data includes: using the second The color data is used to train the initial color table corresponding to the image of the Nth frame to obtain a local color table corresponding to the image of the Nth frame; wherein the initial color table corresponding to the image of the Nth frame is the original image file. A partial color table corresponding to the image of the N-1th frame, where N is an integer greater than one.
- 根据权利要求7所述的方法,其中,获取所述初始颜色表包括:The method of claim 7 wherein obtaining the initial color table comprises:获取所述第一图片文件中的全局颜色表;Obtaining a global color table in the first picture file;将所述全局颜色表中的色彩值按照一个色彩分量的值进行排序,得到所述初始颜色表。The color values in the global color table are sorted according to the value of one color component to obtain the initial color table.
- 根据权利要求7所述的方法,其中,获取所述初始颜色表包括:The method of claim 7 wherein obtaining the initial color table comprises:将预设的多个色彩值按照一个色彩分量的值预设排序方式排列,以生成所述初始颜色表。The preset plurality of color values are arranged in a preset order of values of one color component to generate the initial color table.
- 一种图片文件处理方法,应用于计算设备,包括:A picture file processing method, applied to a computing device, comprising:接收发送端发送的针对原始图片文件的转码码流,解析所述转码码流以获取图片文件的图片头信息数据段和码流数据,所述码流数据为所述发送端对YUV数据进行编码生成的信息,所述YUV数据为所述发送 端对图片文件中每帧图像进行转换生成的数据;Receiving, by the sending end, a transcoded code stream for the original picture file, parsing the transcoded code stream to obtain a picture header information data segment and code stream data of the picture file, where the code stream data is the sender end to the YUV data Performing code generation information, where the YUV data is data generated by the transmitting end to convert each frame image in the picture file;根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。Generating the YUV data according to the code stream data, and processing the YUV data based on the picture header information data segment to generate the picture file.
- 根据权利要求14所述的方法,其特征在于,所述图片头信息数据段包括延时信息、总帧数、全局颜色表信息;The method according to claim 14, wherein the picture header information data segment comprises delay information, a total number of frames, and global color table information;所述根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件,包括:Generating the YUV data according to the code stream data, and processing the YUV data based on the picture header information data segment to generate the picture file, including:解码所述码流数据以生成所述YUV数据,并采用颜色域转换公式将所述YUV数据转换为三原色RGB数据;Decoding the code stream data to generate the YUV data, and converting the YUV data into three primary color RGB data by using a color field conversion formula;采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新;Updating, by using the global color table information, RGB values of each pixel in the RGB data;采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。The updated RGB data is image encoded using the delay time and the total number of frames to generate the picture file.
- 根据权利要求15所述的方法,其特征在于,所述采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新,包括:The method according to claim 15, wherein the updating the RGB values of each pixel in the RGB data by using the global color table information comprises:当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。When the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the RGB value of each pixel in the RGB data is used to the global color table. The information is trained to generate local color table information of the RGB data, and the RGB values of the respective pixels are updated using the local color table information of the RGB data.
- 根据权利要求16所述的方法,其特征在于,所述采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB 数据的局部颜色表信息,包括:The method according to claim 16, wherein the training of the global color table information by using RGB values of respective pixels in the RGB data to generate local color table information of the RGB data comprises:将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息;Sorting at least one source RGB value in the global color table information according to a preset sorting manner of the G component to generate training color table information;在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取第一源RGB值的第一颜色索引;Obtaining, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a first color index of the first source RGB value;在训练颜色表信息中以第一颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第二源RGB值,并获取第二源RGB值的第二颜色索引;Obtaining, in a preset range centered on the first color index in the training color table information, obtaining a second source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a second color index of the second source RGB value;将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对训练颜色表信息中以第二颜色索引为中心的预设范围内的多个源RGB值进行修改;Substituting the second source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, a pre-position of the second color index in the training color table information Set a plurality of source RGB values in the range to be modified;当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值;When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. Obtaining, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data;当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- 根据权利要求15所述的方法,其特征在于,所述采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新,包括:The method according to claim 15, wherein the updating the RGB values of each pixel in the RGB data by using the global color table information comprises:当所述RGB数据为图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。When the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the RGB value of each pixel in the RGB data is used to train the initialization color table information. The RGB values of the respective pixels are updated by generating local color table information of the RGB data and using local color table information of the RGB data.
- 根据权利要求18所述的方法,其特征在于,所述采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 18, wherein the RGB value of each pixel in the RGB data is used to train the initialization color table information to generate local color table information of the RGB data, including:在初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取第三源RGB值的第三颜色索引;Obtaining, in the initialization color table information, a third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value;在初始化颜色表信息中以第三颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第四源RGB值,并获取第四源RGB值的第四颜色索引;And acquiring, in a preset range centered on the third color index in the initialization color table information, a fourth source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a fourth color index of the fourth source RGB value;将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对初始化颜色表信息中以第四颜色索引为中心的预设范围内的多个源RGB值进行修改;Substituting the fourth source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, to pre-populate the fourth color index in the initialization color table information Set a plurality of source RGB values in the range to be modified;当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述初始化颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值;When the current pixel point is not the last pixel point in the RGB data, the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. Obtaining, in the initialization color table information, a third source RGB value that is closest to the G component of the current pixel point in the RGB data;当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the initialization color table information is determined as the local color table information of the RGB data.
- 根据权利要求15所述的方法,其特征在于,所述采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新,包括:The method according to claim 15, wherein the updating the RGB values of each pixel in the RGB data by using the global color table information comprises:当所述RGB数据为图片文件中的第N帧图像时,所述接收端采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的 局部颜色表信息对各像素点的RGB值进行更新,N为大于1且小于或等于总帧数的正整数。When the RGB data is the Nth frame image in the picture file, the receiving end trains the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate RGB data. The local color table information is updated with the RGB values of the respective pixels using the local color table information of the RGB data, and N is a positive integer greater than 1 and less than or equal to the total number of frames.
- 根据权利要求20所述的方法,其特征在于,所述采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 20, wherein said RGB value of each pixel in the RGB data is used to train the local color table information of the N-1th frame RGB data to generate local color table information of the RGB data. ,include:将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息;And sorting at least one source RGB value in the partial color table information of the N-1th frame RGB data according to a preset sorting manner of the G component to generate training color table information;在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取第五源RGB值的第五颜色索引;Obtaining, in the training color table information, a fifth source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a fifth color index of the fifth source RGB value;在训练颜色表信息中以第五颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第六源RGB值,并获取第六源RGB值的第六颜色索引;And acquiring, in a preset range centered on the fifth color index in the training color table information, a sixth source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a sixth color index of the sixth source RGB value;将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以第六颜色索引为中心的预设范围内的多个源RGB值进行修改;Substituting the sixth source RGB value with the RGB value of the current pixel point, and adopting a preset weight value and an RGB value of the current pixel point, centering on the sixth color index in the training color table information Modifying multiple source RGB values within the preset range;当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值;When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. Obtaining, in the training color table information, a fifth source RGB value that is closest to the G component of the current pixel point in the RGB data;当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- 一种图片文件处理方法,应用于计算设备,包括:A picture file processing method, applied to a computing device, comprising:根据原始图片文件生成图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据;Generating a picture header information data segment of the picture file according to the original picture file, and converting each frame image in the picture file into YUV data;对所述YUV数据进行编码以生成码流数据;Encoding the YUV data to generate code stream data;存储转码码流,所述转码码流包含所述图片头信息数据段和所述码流数据;Storing a transcoded code stream, where the transcoded code stream includes the picture header information data segment and the code stream data;解析所述转码码流以获取所述图片头信息数据段和所述码流数据;Parsing the transcoded code stream to obtain the picture header information data segment and the code stream data;根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件。Generating the YUV data according to the code stream data, and processing the YUV data based on the picture header information data segment to generate the picture file.
- 根据权利要求22所述的方法,其特征在于,所述根据原始图片文件生成图片文件的图片头信息数据段,并将图片文件中每帧图像转换为YUV数据,包括:The method according to claim 22, wherein the generating a picture header information data segment of the picture file according to the original picture file and converting each frame image in the picture file into YUV data comprises:解码原始图片文件以生成所述图片文件的图片头信息数据段以及所述图片文件中每帧图像对应的RGB数据,所述图片头信息数据段包括延时信息、总帧数、全局颜色表信息;Decoding the original picture file to generate a picture header information data segment of the picture file and RGB data corresponding to each frame image in the picture file, where the picture header information data segment includes delay information, total frame number, and global color table information. ;采用颜色域转换公式将所述RGB数据转换为YUV数据。The RGB data is converted to YUV data using a color field conversion formula.
- 根据权利要求22所述的方法,其特征在于,所述编码包括预测编码、变换编码、量化编码和熵编码。The method of claim 22 wherein said encoding comprises predictive coding, transform coding, quantization coding, and entropy coding.
- 根据权利要求22所述的方法,其特征在于,所述对所述YUV数据进行编码以生成码流数据,包括:The method according to claim 22, wherein said encoding said YUV data to generate code stream data comprises:采用配置参数对所述YUV数据进行编码以生成码流数据,所述配置参数为对所述YUV数据进行编码的参数,所述配置参数包括标清模式参数、高清模式参数和无损模式参数中的任一种。The YUV data is encoded by using configuration parameters to generate code stream data, the configuration parameter is a parameter for encoding the YUV data, and the configuration parameter includes any one of an SD mode parameter, a HD mode parameter, and a lossless mode parameter. One.
- 根据权利要求22所述的方法,其特征在于,所述对所述YUV数据进行编码以生成码流数据,包括:The method according to claim 22, wherein said encoding said YUV data to generate code stream data comprises:配置编码器复杂度对所述YUV数据进行编码以生成码流数据,所述编码器复杂度为根据所述发送端的硬件性能所决定的编码的精细度参数。The encoder complexity is configured to encode the YUV data to generate codestream data, the encoder complexity being a fineness parameter of the encoding determined according to hardware performance of the transmitting end.
- 根据权利要求23所述的方法,其特征在于,所述根据所述码流数据生成所述YUV数据,并基于所述图片头信息数据段对所述YUV数据进行处理以生成所述图片文件,包括:The method according to claim 23, wherein said generating said YUV data based on said code stream data, and processing said YUV data based on said picture header information data segment to generate said picture file, include:解码所述码流数据以生成所述YUV数据,并采用颜色域转换公式将所述YUV数据转换为RGB数据;Decoding the code stream data to generate the YUV data, and converting the YUV data into RGB data using a color field conversion formula;采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新;Updating, by using the global color table information, RGB values of each pixel in the RGB data;采用所述延时时间和所述总帧数将更新后的所述RGB数据进行图像编码以生成所述图片文件。The updated RGB data is image encoded using the delay time and the total number of frames to generate the picture file.
- 根据权利要求27所述的方法,其特征在于,所述采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新,包括:The method according to claim 27, wherein the updating the RGB values of each pixel in the RGB data by using the global color table information comprises:当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。When the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the RGB value of each pixel in the RGB data is used to the global color table. The information is trained to generate local color table information of the RGB data, and the RGB values of the respective pixels are updated using the local color table information of the RGB data.
- 根据权利要求28所述的方法,其特征在于,所述采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 28, wherein the training the global color table information by using RGB values of respective pixels in the RGB data to generate local color table information of the RGB data comprises:将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息;Sorting at least one source RGB value in the global color table information according to a preset sorting manner of the G component to generate training color table information;在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取第一源RGB值的第一颜色索引;Obtaining, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a first color index of the first source RGB value;在训练颜色表信息中以第一颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第二源RGB值,并获取第二源RGB值的第二颜色索引;Obtaining, in a preset range centered on the first color index in the training color table information, obtaining a second source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a second color index of the second source RGB value;将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对训练颜色表信息中以第二颜色索引为中心的预设范围内的多个源RGB值进行修改;Substituting the second source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, a pre-position of the second color index in the training color table information Set a plurality of source RGB values in the range to be modified;当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值;When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. Obtaining, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data;当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- 根据权利要求27所述的方法,其特征在于,所述采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新,包括:The method according to claim 27, wherein the updating the RGB values of each pixel in the RGB data by using the global color table information comprises:当所述RGB数据为图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,采用RGB数据中的各像素点的 RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。When the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the RGB value of each pixel in the RGB data is used to train the initialization color table information. The RGB values of the respective pixels are updated by generating local color table information of the RGB data and using local color table information of the RGB data.
- 根据权利要求30所述的方法,其特征在于,所述采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 30, wherein the RGB values of the pixels in the RGB data are used to train the initialization color table information to generate local color table information of the RGB data, including:在初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取第三源RGB值的第三颜色索引;Obtaining, in the initialization color table information, a third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value;在初始化颜色表信息中以第三颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第四源RGB值,并获取第四源RGB值的第四颜色索引;And acquiring, in a preset range centered on the third color index in the initialization color table information, a fourth source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a fourth color index of the fourth source RGB value;将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对初始化颜色表信息中以第四颜色索引为中心的预设范围内的多个源RGB值进行修改;Substituting the fourth source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, to pre-populate the fourth color index in the initialization color table information Set a plurality of source RGB values in the range to be modified;当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述初始化颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值;When the current pixel point is not the last pixel point in the RGB data, the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. Obtaining, in the initialization color table information, a third source RGB value that is closest to the G component of the current pixel point in the RGB data;当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the initialization color table information is determined as the local color table information of the RGB data.
- 根据权利要求27所述的方法,其特征在于,所述采用所述全局颜色表信息对RGB数据中的各像素点的RGB值进行更新,包括:The method according to claim 27, wherein the updating the RGB values of each pixel in the RGB data by using the global color table information comprises:当所述RGB数据为图片文件中的第N帧图像时,所述接收端采用 RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,并采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新,N为大于1且小于或等于总帧数的正整数。When the RGB data is the Nth frame image in the picture file, the receiving end trains the local color table information of the N-1th frame RGB data by using the RGB values of the pixels in the RGB data to generate RGB data. The local color table information is updated with the RGB values of the respective pixels using the local color table information of the RGB data, and N is a positive integer greater than 1 and less than or equal to the total number of frames.
- 根据权利要求32所述的方法,其特征在于,所述采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 32, wherein said RGB values of respective pixels in the RGB data are used to train local color table information of the N-1th frame RGB data to generate local color table information of the RGB data. ,include:将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息;And sorting at least one source RGB value in the partial color table information of the N-1th frame RGB data according to a preset sorting manner of the G component to generate training color table information;在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取第五源RGB值的第五颜色索引;Obtaining, in the training color table information, a fifth source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a fifth color index of the fifth source RGB value;在训练颜色表信息中以第五颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第六源RGB值,并获取第六源RGB值的第六颜色索引;And acquiring, in a preset range centered on the fifth color index in the training color table information, a sixth source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a sixth color index of the sixth source RGB value;将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以第六颜色索引为中心的预设范围内的多个源RGB值进行修改;Substituting the sixth source RGB value with the RGB value of the current pixel point, and adopting a preset weight value and an RGB value of the current pixel point, centering on the sixth color index in the training color table information Modifying multiple source RGB values within the preset range;当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值;When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. Obtaining, in the training color table information, a fifth source RGB value that is closest to the G component of the current pixel point in the RGB data;当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- 一种图片文件处理方法,应用于计算设备,包括:A picture file processing method, applied to a computing device, comprising:获取对原始图片文件解码生成的RGB数据,获取RGB数据中的各像素点的RGB值;Obtaining RGB data generated by decoding the original image file, and acquiring RGB values of each pixel in the RGB data;采用各像素点的RGB值对RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息;The initial color table information of the RGB data is trained by using the RGB values of the respective pixels to generate local color table information of the RGB data;采用RGB数据的局部颜色表信息对各像素点的RGB值进行更新。The RGB values of the respective pixels are updated using the local color table information of the RGB data.
- 根据权利要求34所述的方法,其特征在于,所述采用各像素点的RGB值对RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 34, wherein the initial color table information of the RGB data is trained by using the RGB values of the respective pixels to generate local color table information of the RGB data, including:当所述RGB数据为所述图片文件中的第一帧图像,且所述图片头信息数据段中存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息。When the RGB data is the first frame image in the picture file, and the global color table information exists in the picture header information data segment, the RGB value of each pixel in the RGB data is used to the global color table. The information is trained to generate local color table information for the RGB data.
- 根据权利要求35所述的方法,其特征在于,所述采用RGB数据中的各像素点的RGB值对所述全局颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 35, wherein the training the global color table information by using RGB values of respective pixels in the RGB data to generate local color table information of the RGB data comprises:将所述全局颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息;Sorting at least one source RGB value in the global color table information according to a preset sorting manner of the G component to generate training color table information;在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值,并获取第一源RGB值的第一颜色索引;Obtaining, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a first color index of the first source RGB value;在训练颜色表信息中以第一颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第二源RGB值,并获取第二源RGB 值的第二颜色索引;Obtaining, in a preset range centered on the first color index in the training color table information, obtaining a second source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a second color index of the second source RGB value;将所述第二源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对训练颜色表信息中以第二颜色索引为中心的预设范围内的多个源RGB值进行修改;Substituting the second source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, a pre-position of the second color index in the training color table information Set a plurality of source RGB values in the range to be modified;当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第一源RGB值;When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. Obtaining, in the training color table information, a first source RGB value that is closest to the G component of the current pixel point in the RGB data;当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- 根据权利要求34所述的方法,其特征在于,所述采用各像素点的RGB值对RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 34, wherein the initial color table information of the RGB data is trained by using the RGB values of the respective pixels to generate local color table information of the RGB data, including:当所述RGB数据为图片文件中的第一帧图像,且所述图片头信息数据段中不存在全局颜色表信息时,采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息。When the RGB data is the first frame image in the picture file, and the global color table information does not exist in the picture header information data segment, the RGB value of each pixel in the RGB data is used to train the initialization color table information. To generate local color table information of RGB data.
- 根据权利要求37所述的方法,其特征在于,所述采用RGB数据中的各像素点的RGB值对初始化颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 37, wherein the RGB values of the pixels in the RGB data are used to train the initialization color table information to generate local color table information of the RGB data, including:在初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值,并获取第三源RGB值的第三颜色索引;Obtaining, in the initialization color table information, a third source RGB value whose G component is closest to the G component of the current pixel point in the RGB data, and acquiring a third color index of the third source RGB value;在初始化颜色表信息中以第三颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第四源RGB值,并获取第四源RGB值的第四颜色索引;And acquiring, in a preset range centered on the third color index in the initialization color table information, a fourth source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a fourth color index of the fourth source RGB value;将所述第四源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对初始化颜色表信息中以第四颜色索引为中心的预设范围内的多个源RGB值进行修改;Substituting the fourth source RGB value with the RGB value of the current pixel point, and using a preset weight value and an RGB value of the current pixel point, to pre-populate the fourth color index in the initialization color table information Set a plurality of source RGB values in the range to be modified;当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述初始化颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述初始化颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第三源RGB值;When the current pixel point is not the last pixel point in the RGB data, the initialization color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. Obtaining, in the initialization color table information, a third source RGB value that is closest to the G component of the current pixel point in the RGB data;当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述初始化颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the initialization color table information is determined as the local color table information of the RGB data.
- 根据权利要求34所述的方法,其特征在于,所述采用各像素点的RGB值对RGB数据的初始颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 34, wherein the initial color table information of the RGB data is trained by using the RGB values of the respective pixels to generate local color table information of the RGB data, including:当所述RGB数据为图片文件中的第N帧图像时,采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,N为大于1且小于或等于总帧数的正整数。When the RGB data is the Nth frame image in the picture file, the local color table information of the N-1th frame RGB data is trained to generate a partial color table of the RGB data by using the RGB values of the pixels in the RGB data. Information, N is a positive integer greater than 1 and less than or equal to the total number of frames.
- 根据权利要求39所述的方法,其特征在于,所述采用RGB数据中的各像素点的RGB值对第N-1帧RGB数据的局部颜色表信息进行训练以生成RGB数据的局部颜色表信息,包括:The method according to claim 39, wherein said RGB value of each pixel in the RGB data is used to train the local color table information of the N-1th frame RGB data to generate local color table information of the RGB data. ,include:将第N-1帧RGB数据的局部颜色表信息中的至少一个源RGB值按照G分量的预设排序方式进行排序,以生成训练颜色表信息;And sorting at least one source RGB value in the partial color table information of the N-1th frame RGB data according to a preset sorting manner of the G component to generate training color table information;在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值,并获取第五源RGB值的第五颜色索引;Obtaining, in the training color table information, a fifth source RGB value that is closest to the G component of the current pixel point in the RGB data, and acquiring a fifth color index of the fifth source RGB value;在训练颜色表信息中以第五颜色索引为中心的预设范围内,获取与当前像素点的RGB值误差最小的第六源RGB值,并获取第六源RGB值的第六颜色索引;And acquiring, in a preset range centered on the fifth color index in the training color table information, a sixth source RGB value having the smallest error of the RGB value of the current pixel point, and acquiring a sixth color index of the sixth source RGB value;将所述第六源RGB值替换为所述当前像素点的RGB值,并采用预设权重值和所述当前像素点的RGB值,对所述训练颜色表信息中以第六颜色索引为中心的预设范围内的多个源RGB值进行修改;Substituting the sixth source RGB value with the RGB value of the current pixel point, and adopting a preset weight value and an RGB value of the current pixel point, centering on the sixth color index in the training color table information Modifying multiple source RGB values within the preset range;当所述当前像素点不为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,将当前像素点的下一个像素点作为当前像素点,并转入执行在所述训练颜色表信息中获取G分量与RGB数据中当前像素点的G分量最接近的第五源RGB值;When the current pixel point is not the last pixel point in the RGB data, the training color table information obtained after the modification is obtained, and the next pixel point of the current pixel point is used as the current pixel point, and is transferred to the execution center. Obtaining, in the training color table information, a fifth source RGB value that is closest to the G component of the current pixel point in the RGB data;当所述当前像素点为RGB数据中的最后一个像素点时,获取修改后得到的所述训练颜色表信息,并将所述训练颜色表信息确定为RGB数据的局部颜色表信息。When the current pixel point is the last pixel point in the RGB data, the training color table information obtained after the modification is acquired, and the training color table information is determined as the local color table information of the RGB data.
- 一种图片文件处理装置,包括:处理器和存储器,所述存储器中存储有计算机可读指令,可以使所述处理器:A picture file processing apparatus includes: a processor and a memory, wherein the memory stores computer readable instructions that enable the processor to:获取原始图片文件的转码码流,解析所述转码码流以获取图片头信息数据段和码流数据,所述图片头信息数据段包括所述原始图片文件的颜色表,所述码流数据为所述发送设备对所述原始图片文件中各像素的第一色彩数据进行编码生成的信息;Obtaining a transcoded code stream of the original picture file, parsing the transcoded code stream to obtain a picture header information data segment and code stream data, where the picture header information data segment includes a color table of the original picture file, the code stream Data is information generated by the sending device to encode first color data of each pixel in the original picture file;解码所述码流数据以生成第二色彩数据,并基于所述颜色表对所述 第二色彩数据进行处理以生成第二图片文件。The code stream data is decoded to generate second color data, and the second color data is processed based on the color table to generate a second picture file.
- 根据权利要求41所述的装置,其中,所述计算机可读指令可以使所述处理器:The apparatus of claim 41 wherein said computer readable instructions are to cause said processor to:利用所述第二色彩数据中各像素点的色彩值和所述颜色表生成所述第二色彩数据对应的局部颜色表,并采用所述局部颜色表对所述各像素点的色彩值进行更新。Generating a partial color table corresponding to the second color data by using the color value of each pixel in the second color data and the color table, and updating the color value of each pixel point by using the local color table .
- 根据权利要求42所述的装置,其中,所述计算机可读指令可以使所述处理器:The apparatus of claim 42 wherein said computer readable instructions are to cause said processor to:将所述颜色表中的色彩值按照一个色彩分量的预设排序方式进行排序,以生成训练颜色表;Sorting the color values in the color table according to a preset ordering manner of one color component to generate a training color table;针对所述第二色彩数据中的各像素点,For each pixel point in the second color data,在所述训练颜色表中获取所述色彩分量与所述像素点的所述色彩分量最接近的第一色彩值,并获取第一色彩值的第一颜色索引;Obtaining a first color value of the color component closest to the color component of the pixel point in the training color table, and acquiring a first color index of the first color value;在所述训练颜色表中以所述第一颜色索引为中心的预设范围内,获取与所述像素点的色彩值误差最小的第二色彩值,并获取第二色彩值的第二颜色索引;Obtaining, in a preset range centered on the first color index in the training color table, a second color value having a smallest error with a color value of the pixel point, and acquiring a second color index of the second color value ;将所述第二色彩值替换为所述像素点的色彩值,并采用预设权重值和所述像素点的色彩值,对所述训练颜色表中以所述第二颜色索引为中心的预设范围内的多个色彩值进行修改;Substituting the second color value with a color value of the pixel point, and using a preset weight value and a color value of the pixel point, a pre-position of the second color index in the training color table Set a number of color values within the range to modify;将修改后的所述训练颜色表确定为所述局部颜色表。The modified training color table is determined as the partial color table.
- 一种图片文件处理装置,包括:处理器和存储器,所述存储器中存储有计算机可读指令,可以使所述处理器:A picture file processing apparatus includes: a processor and a memory, wherein the memory stores computer readable instructions that enable the processor to:获取第一图片文件的色彩数据,所述色彩数据包括各像素点的色彩值;Obtaining color data of the first picture file, where the color data includes color values of each pixel point;获取初始颜色表,所述初始颜色表中各色彩值按照一个色彩分量的值的预设排序方式排列;Obtaining an initial color table, wherein each color value in the initial color table is arranged according to a preset sorting manner of values of one color component;根据所述各像素点的色彩值中所述色彩分量的值在所述初始颜色表中搜索各像素点在所述初始颜色表中对应的初始色彩值,利用所述初始色彩值对所述各像素点的所述色彩值进行更新;Searching, in the initial color table, a corresponding initial color value of each pixel in the initial color table according to the value of the color component in the color value of each pixel point, using the initial color value pair The color value of the pixel is updated;将更新后的所述色彩数据进行图像编码以生成所述第二图片文件。The updated color data is image encoded to generate the second picture file.
- 根据权利要求44所述的装置,其中,所述计算机可读指令可以使所述处理器:The apparatus of claim 44 wherein said computer readable instructions are to cause said processor to:利用所述色彩数据中各像素点的色彩值和所述初始色彩值对所述初始颜色表进行修改,得到所述色彩数据对应的局部颜色表,并采用所述局部颜色表对所述各像素点的色彩值进行更新。And modifying the initial color table by using a color value of each pixel in the color data and the initial color value to obtain a partial color table corresponding to the color data, and using the local color table to each pixel The color value of the point is updated.
- 一种非易失性计算机可读存储介质,存储有计算机可读指令,可以使至少一个处理器执行如权利要求1至40任一项所述的方法。A non-transitory computer readable storage medium storing computer readable instructions for causing at least one processor to perform the method of any one of claims 1 to 40.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710225916.0A CN106921869B (en) | 2017-04-08 | 2017-04-08 | A kind of photograph document handling method and its equipment |
CN201710225916.0 | 2017-04-08 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2018184465A1 true WO2018184465A1 (en) | 2018-10-11 |
Family
ID=59568640
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/079463 WO2018184465A1 (en) | 2017-04-08 | 2018-03-19 | Image file processing method, apparatus, and storage medium |
Country Status (3)
Country | Link |
---|---|
CN (2) | CN109151503B (en) |
TW (1) | TWI672942B (en) |
WO (1) | WO2018184465A1 (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109151503B (en) * | 2017-04-08 | 2022-03-15 | 腾讯科技(深圳)有限公司 | Picture file processing method and equipment |
CN110069728B (en) * | 2017-10-30 | 2022-08-12 | 北京京东尚科信息技术有限公司 | Method and device for displaying pictures |
US10841458B2 (en) * | 2018-03-02 | 2020-11-17 | Canon Kabushiki Kaisha | Image processing apparatus, image processing method, and storage medium |
CN108933945B (en) * | 2018-08-17 | 2020-06-19 | 腾讯科技(深圳)有限公司 | GIF picture compression method, device and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1516848A (en) * | 2001-06-15 | 2004-07-28 | ��˹��ŵ�� | Method and system for achieving coding ganis in wavelet-based image coding-decoding device |
US20080112634A1 (en) * | 2006-11-13 | 2008-05-15 | Samsung Electronics Co., Ltd. | Method and apparatus for image processing |
CN101540901A (en) * | 2008-03-20 | 2009-09-23 | 华为技术有限公司 | Method and device for coding/decoding |
CN102231836A (en) * | 2011-06-27 | 2011-11-02 | 深圳市茁壮网络股份有限公司 | Graphics interchange format (GIF) file processing method and device for digital television system |
CN106383880A (en) * | 2016-09-13 | 2017-02-08 | 广州视睿电子科技有限公司 | GIF file playing method and system |
CN106899861A (en) * | 2017-04-08 | 2017-06-27 | 腾讯科技(深圳)有限公司 | A kind of photograph document handling method and its equipment, system |
CN106921869A (en) * | 2017-04-08 | 2017-07-04 | 腾讯科技(深圳)有限公司 | A kind of photograph document handling method and its equipment |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8189908B2 (en) * | 2005-09-02 | 2012-05-29 | Adobe Systems, Inc. | System and method for compressing video data and alpha channel data using a single stream |
CN101459829B (en) * | 2008-12-25 | 2011-05-04 | 杭州恒生数字设备科技有限公司 | Full digital monitoring system with low latency |
CN101742317B (en) * | 2009-12-31 | 2012-03-28 | 北京中科大洋科技发展股份有限公司 | Video compressing and encoding method with alpha transparent channel |
CN104333762B (en) * | 2014-11-24 | 2017-10-10 | 成都瑞博慧窗信息技术有限公司 | A kind of video encoding/decoding method |
-
2017
- 2017-04-08 CN CN201810834942.8A patent/CN109151503B/en active Active
- 2017-04-08 CN CN201710225916.0A patent/CN106921869B/en active Active
-
2018
- 2018-03-19 WO PCT/CN2018/079463 patent/WO2018184465A1/en active Application Filing
- 2018-04-03 TW TW107111915A patent/TWI672942B/en active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1516848A (en) * | 2001-06-15 | 2004-07-28 | ��˹��ŵ�� | Method and system for achieving coding ganis in wavelet-based image coding-decoding device |
US20080112634A1 (en) * | 2006-11-13 | 2008-05-15 | Samsung Electronics Co., Ltd. | Method and apparatus for image processing |
CN101540901A (en) * | 2008-03-20 | 2009-09-23 | 华为技术有限公司 | Method and device for coding/decoding |
CN102231836A (en) * | 2011-06-27 | 2011-11-02 | 深圳市茁壮网络股份有限公司 | Graphics interchange format (GIF) file processing method and device for digital television system |
CN106383880A (en) * | 2016-09-13 | 2017-02-08 | 广州视睿电子科技有限公司 | GIF file playing method and system |
CN106899861A (en) * | 2017-04-08 | 2017-06-27 | 腾讯科技(深圳)有限公司 | A kind of photograph document handling method and its equipment, system |
CN106921869A (en) * | 2017-04-08 | 2017-07-04 | 腾讯科技(深圳)有限公司 | A kind of photograph document handling method and its equipment |
Non-Patent Citations (1)
Title |
---|
CAO HONG: "A graphic interchange format file display model", COMPUTER ERA, no. 10, 25 October 2003 (2003-10-25), pages 45 - 46, ISSN: 1006-8228 * |
Also Published As
Publication number | Publication date |
---|---|
CN106921869B (en) | 2018-09-04 |
CN109151503B (en) | 2022-03-15 |
TW201838416A (en) | 2018-10-16 |
CN106921869A (en) | 2017-07-04 |
CN109151503A (en) | 2019-01-04 |
TWI672942B (en) | 2019-09-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TWI680671B (en) | Image file processing method, apparatus and system, and storage medium | |
US12256089B2 (en) | Coded-block-flag coding and derivation | |
CN113411577B (en) | Coding method and device | |
RU2668723C2 (en) | Method and equipment for coding and decoding video signals | |
US20150229933A1 (en) | Adaptive screen and video coding scheme | |
TWI672942B (en) | Picture file processing method, device, and storage medium | |
RU2693185C2 (en) | Encoding method and colour conversion decoding method and corresponding devices | |
WO2017129023A1 (en) | Decoding method, encoding method, decoding apparatus, and encoding apparatus | |
CN112954367B (en) | Encoder, decoder and corresponding methods using palette coding | |
KR102349788B1 (en) | Method and apparatus for encoding/decoding video | |
CN110754085B (en) | Color remapping for non-4:4:4 format video content | |
JP2023549210A (en) | Video frame compression method, video frame decompression method and device | |
CN112204971A (en) | Video image coding method and device and movable platform | |
WO2019109955A1 (en) | Interframe prediction method and apparatus, and terminal device | |
CN111246208B (en) | Video processing method and device and electronic equipment | |
CN113557727B (en) | Video decoding method and related device | |
WO2020042853A1 (en) | Method and apparatus for intra prediction | |
WO2021169817A1 (en) | Video processing method and electronic device | |
CN115150370B (en) | Image processing method | |
CN119032566A (en) | Video encoding and decoding method, device, equipment, system and storage medium | |
WO2023092404A1 (en) | Video coding and decoding methods and devices, system, and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18780447 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18780447 Country of ref document: EP Kind code of ref document: A1 |