CN109040789A - A kind of photograph document handling method - Google Patents

A kind of photograph document handling method Download PDF

Info

Publication number
CN109040789A
CN109040789A CN201811273801.XA CN201811273801A CN109040789A CN 109040789 A CN109040789 A CN 109040789A CN 201811273801 A CN201811273801 A CN 201811273801A CN 109040789 A CN109040789 A CN 109040789A
Authority
CN
China
Prior art keywords
data
picture file
image
code stream
header information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201811273801.XA
Other languages
Chinese (zh)
Other versions
CN109040789B (en
Inventor
王诗涛
刘晓宇
陈家君
黄晓政
丁飘
刘海军
罗斌姬
陈新星
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201811273801.XA priority Critical patent/CN109040789B/en
Publication of CN109040789A publication Critical patent/CN109040789A/en
Application granted granted Critical
Publication of CN109040789B publication Critical patent/CN109040789B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/2343Processing 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/234318Processing 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/2343Processing 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/234336Processing 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing 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/44Processing 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/4402Processing 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/440218Processing 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing 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/44Processing 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/4402Processing 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/440236Processing 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The embodiment of the invention discloses a kind of photograph document handling methods, and wherein method includes: to be decoded according to the first video decoding mode to the first bit stream data, generate the RGB data of the first image;The second bit stream data is decoded according to the second video decoding mode, generates the transparency data of the first image;According to the RGB data of the first image and the transparency data, the corresponding RGBA data of the first image are generated;First bit stream data and second bit stream data are that the data generated by the first image are read from the bit stream data section of picture file.Using the present invention, the transparency data remained in picture file while using coding and decoding video mode are realized, ensure that the quality of picture file.

Description

Picture file processing method
Technical Field
The invention relates to the technical field of computers, in particular to a picture file processing method.
Background
With the development of the mobile internet, the download flow of the terminal device is greatly increased, and the picture file flow occupies a large proportion in the download flow of the user. The large number of picture files also puts a great strain on network transmission bandwidth load. If the size of the picture file can be reduced, the loading speed can be increased, and a large amount of bandwidth and storage cost can be saved. If the bandwidth or the storage cost is saved, firstly, the quality of the picture file is reduced, for example, the quality of the jpeg picture file is reduced from jpeg80 to jpeg70 or even lower, but the quality of the picture file is greatly reduced, which affects the user experience; the other method is to adopt a more efficient picture file compression method, while the current mainstream picture files are jpeg, png, gif and the like, but on the premise of ensuring the quality of the picture files, the compression efficiency is not high.
Disclosure of Invention
The technical problem to be solved by the embodiments of the present invention is to provide a picture file processing method, which obtains RGBA data by decoding first code stream data and second code stream data respectively, so as to maintain transparency data while adopting a video coding and decoding mode, and ensure the quality of a picture file.
In a first aspect, an embodiment of the present invention provides a method for processing an image file, including:
the method comprises the steps of obtaining RGBA data corresponding to a first image in a picture file, and separating the RGBA data to obtain RGB data and transparency data of the first image, wherein the RGB data are color data contained in the RGBA data, and the transparency data are transparency data contained in the RGBA data;
encoding the RGB data of the first image according to a first video encoding mode to generate first code stream data;
coding the transparency data of the first image according to a second video coding mode to generate second code stream data;
and writing the first code stream data and the second code stream data into a code stream data section of the picture file.
In one embodiment, the decoding the first code stream data according to the first video decoding mode to generate RGB data of the first image includes:
decoding the first code stream data according to a first video coding mode to generate first YUV data of a first image;
converting the first YUV data into RGB data of the first image.
In one embodiment, the decoding the second bitstream data in the second video decoding mode to generate transparency data of the first image includes:
decoding the second code stream data according to a second image video coding mode to generate second YUV data of the first image;
and converting the second YUV data into transparency data of the first image.
In one embodiment, the converting the second YUV data into transparency data of the first image comprises:
setting a Y component in the second YUV data as the transparency data of the first image and discarding a UV component in the second YUV data.
In one embodiment, the method further comprises:
if the picture file is in a dynamic format and the first image is an image corresponding to a kth frame in the picture file in the dynamic format, acquiring third code stream data and fourth code stream data generated by a second image corresponding to a (k +1) th frame in the picture file from a code stream data segment of the picture file;
decoding the third code stream data according to a third video decoding mode to generate RGB data of the second image;
decoding the fourth code stream data according to a fourth video decoding mode to generate transparency data of the second image;
and generating RGBA data corresponding to the second image according to the RGB data and the transparency data of the second image.
In an embodiment, before decoding the first code stream data according to the first video decoding mode to generate RGB data of the first image, the method further includes:
analyzing a picture file to obtain picture header information and frame header information of the picture file, wherein the picture header information comprises image characteristic information of whether the picture file has transparency data, and the frame header information is used for indicating a code stream data segment of the picture file.
In one embodiment, the parsing the picture file to obtain the picture header information of the picture file includes:
reading the picture header information of the picture file from the picture header information data segment of the picture file;
the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
In one embodiment, the image feature information further includes the start code of the image feature information, the length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value field adopted by the picture file, the width of the picture file, the height of the picture file, and a frame number used for indicating the picture file in a dynamic format.
In an embodiment, the parsing the picture file to obtain the header information of the picture file includes:
reading frame header information of the picture file from a frame header information data section of the picture file;
the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
In one embodiment, the method further comprises:
and if the picture file is determined to contain transparency data through the image characteristic information, reading code stream data in a code stream data section indicated by the frame header information in the picture file, wherein the code stream data comprises first code stream data and second code stream data.
In a second aspect, a method for processing a picture file is provided for an embodiment of the present invention, including:
decoding the first code stream data according to a first video decoding mode to generate RGB data of a first image;
decoding second code stream data according to a second video decoding mode to generate transparency data of the first image;
generating RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image;
the first code stream data and the second code stream data are data generated by reading the first image from a code stream data segment of a picture file.
In one embodiment, the parsing the picture file to obtain the picture header information of the picture file includes:
reading the picture header information of the picture file from the picture header information data segment of the picture file;
the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
In one embodiment, the image feature information further includes the start code of the image feature information, the length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value field adopted by the picture file, the width of the picture file, the height of the picture file, and a frame number used for indicating the picture file in a dynamic format.
In an embodiment, the parsing the picture file to obtain the header information of the picture file includes:
reading frame header information of the picture file from a frame header information data section of the picture file;
the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
In one embodiment, the method further comprises:
and if the picture file is determined to contain transparency data through the image characteristic information, reading code stream data in a code stream data section indicated by the frame header information in the picture file, wherein the code stream data comprises first code stream data and second code stream data.
And respectively decoding the first code stream data and the second code stream data.
In a third aspect, an embodiment of the present invention provides a method for processing an image file, including:
generating picture header information and frame header information corresponding to a picture file, wherein the picture header information comprises image characteristic information of whether the picture file has transparency data, and the frame header information is used for indicating a code stream data segment of the picture file.
In a fourth aspect, a method for processing a picture file is provided for an embodiment of the present invention, including:
analyzing a picture file to obtain picture header information and frame header information of the picture file, wherein the picture header information comprises image characteristic information of whether the picture file has transparency data, and the frame header information is used for indicating a code stream data segment of the picture file.
In a fifth aspect, an encoding apparatus is provided for an embodiment of the present invention, including:
the data acquisition module is used for acquiring RGBA data corresponding to a first image in a picture file and separating the RGBA data to obtain RGB data and transparency data of the first image, wherein the RGB data is color data contained in the RGBA data, and the transparency data is transparency data contained in the RGBA data;
the first encoding module is used for encoding the RGB data of the first image according to a first video encoding mode to generate first code stream data;
the second coding module is used for coding the transparency data of the first image according to a second video coding mode to generate second code stream data;
and the data writing module is used for writing the first code stream data and the second code stream data into a code stream data segment of the picture file, wherein the first image is an image contained in the picture file.
In a sixth aspect, a decoding apparatus is provided for an embodiment of the present invention, including:
the first decoding module is used for decoding the first code stream data according to a first video decoding mode to generate RGB data of a first image;
the second decoding module is used for decoding second code stream data according to a second video decoding mode to generate transparency data of the first image;
the data generation module is used for generating RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image;
the first code stream data and the second code stream data are data generated by reading the first image from a code stream data segment of a picture file.
A seventh aspect provides an image file processing apparatus according to an embodiment of the present invention, including:
the information generating module is used for generating picture header information and frame header information corresponding to a picture file, wherein the picture header information comprises image characteristic information of whether the picture file has transparency data, and the frame header information is used for indicating a code stream data segment of the picture file.
In an eighth aspect, a method for processing a picture file is provided for an embodiment of the present invention, including:
the file analysis module is used for analyzing the picture file to obtain picture header information and frame header information of the picture file, wherein the picture header information comprises image characteristic information of whether the picture file has transparency data, and the frame header information is used for indicating a code stream data segment of the picture file.
In a ninth aspect, a picture file processing system is provided for an embodiment of the present invention, where the picture file processing system includes an encoding apparatus and a decoding apparatus, the encoding apparatus includes a processor, a memory and a communication interface, the memory is used for storing program codes, and the processor calls the program codes stored in the memory to execute the picture file processing method provided in the first aspect; the decoding device comprises a processor, a memory and a communication interface, wherein the memory is used for storing program codes, and the processor calls the program codes stored in the memory to execute the picture file processing method provided by the second aspect.
In a tenth aspect, a picture file processing system is provided for an embodiment of the present invention, where the picture file processing system includes a first picture file processing apparatus and a second picture file processing apparatus, the first picture file processing apparatus includes a processor, a memory and a communication interface, the memory is used for storing program codes, and the processor calls the program codes stored in the memory to execute the picture file processing method provided in the third aspect; the second picture file processing device comprises a processor, a memory and a communication interface, wherein the memory is used for storing program codes, and the processor calls the program codes stored in the memory to execute the picture file processing method provided by the fourth aspect.
In the embodiment of the invention, when a first image is RGBA data, an encoding device acquires RGBA data corresponding to the first image in a picture file, obtains RGB data and transparency data of the first image by separating the RGBA data, and encodes the RGB data of the first image according to a first video encoding mode to generate first code stream data; coding the transparency data of the first image according to a second video coding mode to generate second code stream data; and writing the first code stream data and the second code stream data into the code stream data section. In addition, the RGB data and the transparency data in the picture file are respectively coded, so that the transparency data in the picture file are kept while the video coding mode is adopted, and the quality of the picture file is ensured.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flow chart illustrating a method for processing a picture file according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart illustrating another method for processing a picture file according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating another method for processing a picture file according to an embodiment of the present invention;
FIG. 4a is a flowchart illustrating another method for processing a picture file according to an embodiment of the present invention;
FIG. 4b is a diagram illustrating an example of converting RGB data to YUV data according to an embodiment of the present invention;
fig. 4c is a diagram illustrating an example of converting transparency data into YUV data according to an embodiment of the present invention;
fig. 4d is an exemplary diagram of converting transparency data into YUV data according to an embodiment of the present invention;
FIG. 5a is a diagram illustrating header information according to an embodiment of the present invention;
FIG. 5b is an exemplary diagram of an image characteristic information data segment according to an embodiment of the present invention;
FIG. 5c is an exemplary diagram illustrating user-defined information, according to an embodiment of the present invention;
FIG. 6a is a diagram illustrating an example of a static format of a picture file package according to an embodiment of the present invention;
FIG. 6b is a diagram illustrating an example of a dynamic format package for a picture file according to an embodiment of the present invention;
FIG. 7a is a diagram illustrating an example of a still-format picture file package according to an embodiment of the present invention;
FIG. 7b is a diagram illustrating an example of a package for a picture file in another dynamic format according to an embodiment of the present invention;
FIG. 8a is a diagram illustrating an example of frame header information according to an embodiment of the present invention;
FIG. 8b is a diagram illustrating header information of an image frame according to an embodiment of the present invention;
FIG. 8c is a diagram illustrating an example of header information of a transparent channel according to an embodiment of the present invention;
FIG. 9 is a flowchart illustrating another method for processing a picture file according to an embodiment of the present invention;
FIG. 10 is a flowchart illustrating another method for processing a picture file according to an embodiment of the present invention;
FIG. 11 is a flowchart illustrating another method for processing a picture file according to an embodiment of the present invention;
FIG. 12 is a flowchart illustrating another method for processing a picture file according to an embodiment of the present invention;
FIG. 13 is a flowchart illustrating another method for processing a picture file according to an embodiment of the present invention;
fig. 14 is a schematic structural diagram of an encoding apparatus according to an embodiment of the present invention;
FIG. 15 is a schematic structural diagram of another encoding apparatus according to an embodiment of the present invention;
fig. 16 is a schematic structural diagram of a decoding apparatus according to an embodiment of the present invention;
fig. 17 is a schematic structural diagram of another decoding device according to an embodiment of the present invention;
FIG. 18 is a schematic structural diagram of an image file processing apparatus according to an embodiment of the present invention;
FIG. 19 is a schematic structural diagram of an image file processing apparatus according to an embodiment of the present invention;
FIG. 20 is a schematic structural diagram of an image file processing apparatus according to an embodiment of the present invention;
FIG. 21 is a schematic structural diagram of an image file processing apparatus according to an embodiment of the present invention;
FIG. 22 is a system architecture diagram of a picture file processing system according to an embodiment of the present invention;
FIG. 23 provides an exemplary diagram of an encoding module according to an embodiment of the present invention;
FIG. 24 is a diagram of an example of a decoding module provided by an embodiment of the present invention;
fig. 25 is a schematic structural diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, a schematic flow chart of a picture file processing method according to an embodiment of the present invention is provided, and as shown in fig. 1, the method according to the embodiment of the present invention may include steps 101 to 104.
101, obtaining RGBA data corresponding to a first image in a picture file, and separating the RGBA data to obtain RGB data and transparency data of the first image.
Specifically, the encoding device acquires RGBA data corresponding to a first image in a picture file, and separates the RGBA data to obtain RGB data and transparency data of the first image. And the data corresponding to the first image is RGBA data. RGBA data is a color space representing Red (Red), Green (Green), Blue (Blue), and transparency information (Alpha). And separating RGBA data corresponding to the first image into RGB data and transparency data. The RGB data is color data included in the RGBA data, and the transparency data is transparency data included in the RGBA data.
For example, if the data corresponding to the first image is RGBA data, since the first image is composed of a plurality of pixels, and each pixel corresponds to one RGBA data, the first image composed of N pixels includes N RGBA data, and its form is as follows:
RGBA RGBA RGBA RGBA RGBA RGBA……RGBA
therefore, optionally, the encoding device needs to separate the RGBA data of the first image to obtain the RGB data and the transparency data of the first image, for example, after the first image composed of the above N pixel points is separated, the RGB data of each pixel point and the transparency data of each pixel point in the N pixel points are obtained, and the form of these data is as follows:
RGB RGB RGB RGB RGB RGB……RGB
A A A A A A……A
further, after the RGB data and the transparency data of the first image are obtained, step 102 and step 103 are performed, respectively.
And 102, encoding the RGB data of the first image according to a first video encoding mode to generate first code stream data.
Specifically, the encoding device encodes RGB data of the first image according to the first video encoding mode to generate first code stream data. The first image may be a frame of image contained in a picture file in a static format; alternatively, the first image may be any one of a plurality of frame images included in a picture file in a dynamic format.
103, encoding the transparency data of the first image according to a second video encoding mode to generate second code stream data.
Specifically, the encoding device encodes transparency data of the first image in a second video encoding mode to generate second bitstream data.
For steps 102 and 103, the first video coding mode or the second video coding mode may include, but is not limited to, an Intra-Prediction (I) frame coding mode and an inter-Prediction (P) frame coding mode. The I frame represents a key frame, and when I frame data is decoded, a complete image can be reconstructed only by the frame data; p-frames need to reference previously encoded frames in order to reconstruct a complete picture. The embodiment of the invention does not limit the video coding mode adopted by each frame of image in the picture file with the static format or the picture file with the dynamic format.
For example, for a picture file in a static format, since the picture file in the static format only includes one frame of image, which is the first image in the embodiment of the present invention, the RGB data and the transparency data of the first image are I-frame encoded. For another example, for a picture file in a dynamic format, since the picture file in a dynamic format generally includes at least two frames of images, in the embodiment of the present invention, I-frame encoding is performed on RGB data and transparency data of a first frame of image in the picture file in a dynamic format; i-frame encoding may be performed for RGB data and transparency data of a non-first frame image, and P-frame encoding may be performed.
104, writing the first code stream data and the second code stream data into the code stream data section of the picture file.
Specifically, the encoding device writes first code stream data generated from RGB data of the first image and second code stream data generated from transparency data of the first image into a code stream data segment of the picture file. The first code stream data and the second code stream data are complete code stream data corresponding to the first image, that is, the RGBA data of the first image can be obtained by decoding the first code stream data and the second code stream data.
It should be noted that step 102 and step 103 are not sequentially executed.
It should be further noted that, in the embodiment of the present invention, the RGBA data input before encoding may be obtained by decoding picture files in various formats, where the Format of the picture file may be any one of a Joint Photographic Experts Group (JPEG), an image file Format (Bitmap, BMP), a Portable Network Graphics Format (PNG), an Bitmap animation Format (APNG), an image Interchange Format (GIF), and the like, and the Format of the picture file before encoding is not limited in the embodiment of the present invention.
It should be further noted that, in the embodiment of the present invention, the first image is RGBA data including RGB data and transparency data, and for the case that the first image only includes RGB data, the encoding device may perform step 102 on the RGB data after acquiring the RGB data corresponding to the first image to generate first code stream data, and determine the first code stream data as complete code stream data corresponding to the first image, so that the first image only including RGB data may still be encoded in a video encoding mode to implement compression of the first image.
In the embodiment of the invention, when a first image is RGBA data, an encoding device acquires RGBA data corresponding to the first image in a picture file, obtains RGB data and transparency data of the first image by separating the RGBA data, and encodes the RGB data of the first image according to a first video encoding mode to generate first code stream data; coding the transparency data of the first image according to a second video coding mode to generate second code stream data; and writing the first code stream data and the second code stream data into the code stream data section. In addition, the RGB data and the transparency data in the picture file are respectively coded, so that the transparency data in the picture file are kept while the video coding mode is adopted, and the quality of the picture file is ensured.
Referring to fig. 2, a flowchart of another picture file processing method according to an embodiment of the present invention is shown, and as shown in fig. 2, the method according to the embodiment of the present invention may include steps 201 to 207. The embodiment of the present invention is explained with reference to a picture file in a dynamic format, and please refer to the following detailed description.
And 201, acquiring RGBA data corresponding to a first image corresponding to a kth frame in a picture file in a dynamic format, and separating the RGBA data to obtain RGB data and transparency data of the first image.
Specifically, the encoding device acquires a picture file in a dynamic format to be encoded, the picture file in the dynamic format includes at least two frames of images, and the encoding device acquires a first image corresponding to a kth frame in the picture file in the dynamic format. The kth frame may be any one of the at least two frames of images, and k is a positive integer greater than 0.
Optionally, the encoding device may encode the image corresponding to each frame in the picture file in the dynamic format according to a sequence of the images, that is, an image corresponding to a first frame of the picture file in the dynamic format may be obtained first. The embodiment of the present invention does not limit the order in which the encoding device acquires the images included in the picture file in the dynamic format.
Further, if the data corresponding to the first image is RGBA data, the RGBA data is a color space representing Red, Green, Blue, and Alpha. And separating RGBA data corresponding to the first image into RGB data and transparency data. The method comprises the following steps: because the first image is composed of a plurality of pixel points, each pixel point corresponds to one RGBA data, therefore, the first image composed of N pixel points comprises N RGBA data, and the form is as follows:
RGBA RGBA RGBA RGBA RGBA RGBA……RGBA
therefore, the encoding apparatus needs to separate the RGBA data of the first image to obtain the RGB data and the transparency data of the first image, for example, after the first image composed of the above-mentioned N pixel points is separated, the RGB data of each pixel point and the transparency data of each pixel point in the N pixel points are obtained, which are in the following form:
RGB RGB RGB RGB RGB RGB……RGB
A A A A A A……A
further, after the RGB data and the transparency data of the first image are obtained, step 202 and step 203 are performed, respectively.
202, encoding the RGB data of the first image according to a first video encoding mode, and generating first code stream data.
Specifically, the encoding device encodes RGB data of the first image in the first video encoding mode. The RGB data is color data separated from RGBA data corresponding to the first image.
And 203, coding the transparency data of the first image according to a second video coding mode to generate second code stream data.
Specifically, the encoding device encodes transparency data of the first image in a second video encoding mode to generate second bitstream data. Wherein the transparency data is separated from RGBA data corresponding to the first image.
It should be noted that step 202 and step 203 are not performed sequentially.
And 204, writing the first code stream data and the second code stream data into a code stream data segment of the picture file.
Specifically, the encoding device writes first code stream data generated from RGB data of the first image and second code stream data generated from transparency data of the first image into a code stream data segment of the picture file. The first code stream data and the second code stream data are complete code stream data corresponding to the first image, that is, the RGBA data of the first image can be obtained by decoding the first code stream data and the second code stream data.
And 205, judging whether the first image corresponding to the k-th frame is the last frame in the picture file in the dynamic format.
Specifically, the encoding device determines whether the first image corresponding to the kth frame is the last frame in the picture file in the dynamic format, and if so, the encoding device indicates that the encoding of the picture file in the dynamic format is completed, and then step 207 is executed; if the frame is not the last frame, it indicates that there is an image that has not been encoded in the picture file in the dynamic format, and step 206 is performed.
And 206, if not, updating k, triggering and executing to acquire RGBA data corresponding to the first image corresponding to the kth frame in the picture file in the dynamic format, and separating the RGBA data to obtain RGB data and transparency data of the first image.
Specifically, the encoding device determines that the first image corresponding to the k-th frame is not the last frame in the picture file in the dynamic format, and encodes the image corresponding to the next frame, that is, updates k with the value of (k + 1). After k is updated, triggering and executing to acquire RGBA data corresponding to a first image corresponding to a kth frame in a picture file in a dynamic format, and separating the RGBA data to obtain RGB data and transparency data of the first image.
It is understood that the image acquired by using k update is not the image corresponding to the same frame as the image acquired before k update, and for convenience of description, the image corresponding to k frame before k update is set as the first image, and the image corresponding to k frame after k update is set as the second image, so as to facilitate the distinction.
When step 202 to step 204 are performed on the second image, optionally, RGBA data corresponding to the second image includes RGB data and transparency data, and the encoding device encodes the RGB data of the second image according to a third video encoding mode to generate third code stream data; coding the transparency data of the second image according to a fourth video coding mode to generate fourth code stream data; and writing the third code stream data and the fourth code stream data into a code stream data section of a picture file.
For steps 202 and 203, the first video coding mode, the second video coding mode, the third video coding mode, or the fourth video coding mode referred to above may include, but are not limited to, an I-frame coding mode and a P-frame coding mode. The I frame represents a key frame, and when I frame data is decoded, a complete image can be reconstructed only by the frame data; p-frames need to reference previously encoded frames in order to reconstruct a complete picture. The embodiment of the invention does not limit the video coding mode adopted by the RGB data and the transparency data in each frame of image in the picture file with the dynamic format. For example, RGB data and transparency data in the same frame image may be encoded in different video encoding modes; alternatively, the encoding may be performed in the same video encoding mode. RGB data in different frame images can be coded according to different video coding modes; alternatively, the encoding may be performed in the same video encoding mode. Transparency data in different frame images can be coded according to different video coding modes; alternatively, the encoding may be performed in the same video encoding mode.
It should be further noted that the picture file in the dynamic format includes a plurality of code stream data segments, and optionally, one frame of image corresponds to one code stream data segment; or, one code stream data corresponds to one code stream data segment. Therefore, the code stream data segments written by the first code stream data and the second code stream data are different from the code stream data segments written by the third code stream data and the fourth code stream data.
For example, please refer to fig. 3, which is an exemplary diagram of a method for processing a picture file according to an embodiment of the present invention. As shown in fig. 3, fig. 3 is described with respect to a picture file in a dynamic format, which includes multiple frames of images, for example, an image corresponding to a 1 st frame, an image corresponding to a 2 nd frame, an image corresponding to a 3 rd frame, an image corresponding to a 4 th frame, and the like, wherein each frame of image includes RGB data and transparency data. In a feasible scheme, the encoding device may encode RGB data and transparency data in the image corresponding to the 1 st frame according to an I-frame encoding mode, and encode images corresponding to other frames such as the 2 nd frame, the 3 rd frame, and the 4 th frame according to a P-frame encoding mode, for example, RGB data in the image corresponding to the 2 nd frame is encoded according to a P-frame encoding mode, RGB data in the image corresponding to the 1 st frame needs to be referred to, transparency data in the image corresponding to the 2 nd frame is encoded according to a P-frame encoding mode, transparency data in the image corresponding to the 1 st frame needs to be referred to, and so on, other frames such as the 3 rd frame and the 4 th frame may be encoded according to a P-frame encoding mode with reference to the 2 nd frame.
It should be noted that, the above-mentioned picture file with only dynamic format is an optional encoding scheme; alternatively, the encoding apparatus may encode all other frames such as the 1 st frame, the 2 nd frame, the 3 rd frame, and the 4 th frame in the I-frame encoding mode.
And 207, if so, finishing the coding of the picture file in the dynamic format.
Specifically, the encoding device determines that the first image corresponding to the k-th frame is the last frame in the picture file in the dynamic format, and then indicates that encoding of the picture file in the dynamic format is completed.
Optionally, the encoding device may generate frame header information for code stream data generated by an image corresponding to each frame, and generate picture header information for the picture file in the dynamic format, so that whether the picture file includes transparency data may be determined by the picture header information, and it may be further determined whether to acquire only first code stream data generated by RGB data or to acquire first code stream data generated by RGB data and second code stream data generated by transparency data in a decoding process.
It should be noted that, in the embodiment of the present invention, the image corresponding to each frame in the picture file in the dynamic format is RGBA data including RGB data and transparency data, and for the case that the image corresponding to each frame in the picture file in the dynamic format only includes RGB data, the encoding device may perform step 202 on the RGB data of each frame of the image to generate first code stream data and write the first code stream data into a code stream data segment of the picture file, and finally determine the first code stream data as complete code stream data corresponding to the first image, so that the first image only including RGB data may still be encoded in a video encoding mode to implement compression of the first image.
It should be further noted that, in the embodiment of the present invention, the RGBA data input before encoding may be obtained by decoding picture files in various dynamic formats, where the dynamic format of the picture file may be any one of APNG, GIF, and the like, and the dynamic format of the picture file before encoding is not limited in the embodiment of the present invention.
In the embodiment of the invention, under the condition that a first image in a picture file with a dynamic format is RGBA data, an encoding device acquires the RGBA data corresponding to the first image in the picture file, obtains the RGB data and transparency data of the first image by separating the RGBA data, and encodes the RGB data of the first image according to a first video encoding mode to generate first code stream data; coding the transparency data of the first image according to a second video coding mode to generate second code stream data; and writing the first code stream data and the second code stream data into the code stream data section. In addition, the image corresponding to each frame in the picture file with the dynamic format can be encoded in the mode of the first image. In addition, the RGB data and the transparency data in the picture file are respectively coded, so that the transparency data in the picture file are kept while the video coding mode is adopted, and the quality of the picture file is ensured.
Referring to fig. 4a, a schematic flow chart of another picture file processing method according to an embodiment of the present invention is shown, and as shown in fig. 4a, the method according to the embodiment of the present invention may include steps 301 to 307.
301, obtaining RGBA data corresponding to a first image in a picture file, and separating the RGBA data to obtain RGB data and transparency data of the first image.
Specifically, the encoding device acquires RGBA data corresponding to a first image in a picture file, and separates the RGBA data to obtain RGB data and transparency data of the first image. And the data corresponding to the first image is RGBA data. RGBA data is a color space that represents Red, Green, Blue, and Alpha. And separating RGBA data corresponding to the first image into RGB data and transparency data. The RGB data is color data included in the RGBA data, and the transparency data is transparency data included in the RGBA data.
For example, if the data corresponding to the first image is RGBA data, since the first image is composed of a plurality of pixels, and each pixel corresponds to one RGBA data, the first image composed of N pixels includes N RGBA data, and its form is as follows:
RGBA RGBA RGBA RGBA RGBA RGBA……RGBA
therefore, optionally, the encoding device needs to separate the RGBA data of the first image to obtain the RGB data and the transparency data of the first image, for example, after the first image composed of the above N pixel points is separated, the RGB data of each pixel point and the transparency data of each pixel point in the N pixel points are obtained, and the form of these data is as follows:
RGB RGB RGB RGB RGB RGB……RGB
A A A A A A……A
further, after the RGB data and the transparency data of the first image are obtained, step 302 and step 303 are performed, respectively.
And 302, encoding the RGB data of the first image according to a first video encoding mode to generate first code stream data.
Specifically, the encoding device encodes RGB data of a first image according to a first video encoding mode, where the first image may be a frame of image included in a picture file in a static format; alternatively, the first image may be any one of a plurality of frame images included in a picture file in a dynamic format.
Optionally, the specific process of the encoding device encoding the RGB data of the first image according to the first video encoding mode and generating the first code stream data is as follows: converting the RGB data of the first image into first YUV data; and coding the first YUV data according to a first video coding mode to generate first code stream data. In a possible scenario, the encoding apparatus may convert the RGB data into the first YUV data according to a preset YUV color space format, for example, the preset YUV color space format may include, but is not limited to, YUV420, YUV422, and YUV 444.
303, encoding the transparency data of the first image according to a second video encoding mode to generate second code stream data.
Specifically, the encoding device encodes transparency data of the first image in a second video encoding mode to generate second bitstream data.
The first video coding mode for step 302 or the second video coding mode for step 303 may include, but is not limited to, an I-frame coding mode and a P-frame coding mode. The I frame represents a key frame, and when I frame data is decoded, a complete image can be reconstructed only by the frame data; p-frames need to reference previously encoded frames in order to reconstruct a complete picture. The embodiment of the invention does not limit the video coding mode adopted by each frame of image in the picture file with the static format or the picture file with the dynamic format.
For example, for a picture file in a static format, since the picture file in the static format only includes one frame of image, which is the first image in the embodiment of the present invention, the RGB data and the transparency data of the first image are I-frame encoded. For another example, for a picture file in a dynamic format, since the picture file in the dynamic format includes at least two frames of images, in the embodiment of the present invention, I-frame encoding is performed on RGB data and transparency data of a first frame of image in the picture file in the dynamic format; i-frame encoding may be performed for RGB data and transparency data of a non-first frame image, or P-frame encoding may also be performed.
Optionally, the specific process of the encoding device encoding the transparency data of the first image according to the second video encoding mode and generating the second bitstream data includes: converting the transparency data of the first image into second YUV data; and coding the second YUV data according to a second video coding mode to generate second code stream data.
The converting, by the encoding device, the transparency data of the first image into second YUV data specifically includes: in one possible scheme, the encoding means sets transparency data of the first image as a Y component in second YUV data, and does not set a UV component in the second YUV data; or, in another possible scheme, the transparency data of the first image is set as a Y component in second YUV data, and a UV component in the second YUV data is set as preset data; in a possible scheme, the encoding apparatus may convert the transparency data into the second YUV data according to a preset YUV color space format, for example, the preset YUV color space format may include, but is not limited to, YUV400, YUV420, YUV422, and YUV444, and may set the UV component according to the YUV color space format.
Further, if the data corresponding to the first image is RGBA data, the encoding device obtains the RGB data and the transparency data of the first image by separating the RGBA data of the first image. Next, an example of converting the RGB data of the first image into the first YUV data and converting the transparency data of the first image into the second YUV data is described, taking an example that the first image includes 4 pixels, where the RGB data of the first image is the RGB data of the 4 pixels, and the transparency data of the first image is the transparency data of the 4 pixels, and a specific process of converting the RGB data and the transparency data of the first image is described with reference to fig. 4b to 4 d.
Fig. 4b shows an exemplary diagram of converting RGB data into YUV data according to an embodiment of the present invention. As shown in fig. 4b, the RGB data includes RGB data of 4 pixels, and the RGB data of 4 pixels is converted according to the color space conversion mode, and if the format of the YUV color space is YUV444, the RGB data of one pixel can be converted into one YUV data according to the corresponding conversion formula, so that the RGB data of 4 pixels is converted into 4 YUV data, and the first YUV data includes the 4 YUV data. Wherein, the conversion formulas corresponding to different YUV color space formats are different.
Further, please refer to fig. 4c and fig. 4d, which respectively provide an exemplary diagram of converting transparency data into YUV data according to an embodiment of the present invention. First, as shown in fig. 4c and 4d, the transparency data includes a data of 4 pixels, where a represents the transparency, and the transparency data of each pixel is set as the Y component; a YUV color space format is then determined to determine second YUV data.
If the format of the YUV color space is YUV400, the UV component is not set, and the Y component of 4 pixels is determined as the second YUV data of the first image (as shown in fig. 4 c).
If the YUV color space format is a format having a UV component other than YUV400, the UV component is set as the preset data, as shown in fig. 4d, the conversion is performed in the YUV444 color space format in fig. 4d, that is, each pixel point is set to have a U component and a V component as the preset data. In addition, for example, if the YUV color space format is YUV422, a U component and a V component, which are preset data, are set for every two pixel points; or, if the format of the YUV color space is YUV420, a U component and a V component, which are preset data, are set for every four pixel points. Other formats are analogized, and are not described herein again; and finally, determining the YUV data of 4 pixel points as second YUV data of the first image.
It should be noted that step 302 and step 303 are not performed in a sequential order.
And 304, writing the first code stream data and the second code stream data into a code stream data segment of the picture file.
Specifically, the encoding device writes first code stream data generated from RGB data of the first image and second code stream data generated from transparency data of the first image into a code stream data segment of the picture file. The first code stream data and the second code stream data are complete code stream data corresponding to the first image, that is, the RGBA data of the first image can be obtained by decoding the first code stream data and the second code stream data.
And 305, generating picture header information and frame header information corresponding to the picture file.
Specifically, the encoding device generates picture header information and frame header information corresponding to the picture file. The picture file can be a picture file in a static format, namely only containing the first image; or, the picture file is a picture file in a dynamic format, that is, the picture file includes the first image and other images. Whether the picture file is a picture file in a static format or a picture file in a dynamic format, the encoding apparatus needs to generate picture header information corresponding to the picture file. The picture header information comprises image characteristic information of whether transparency data exist in the picture file or not, so that the decoding device determines how to acquire code stream data by determining whether the transparency data are included or not and whether the acquired code stream data include second code stream data generated by the transparency data or not.
Further, the frame header information is used to indicate a code stream data segment of the picture file, so that the decoding device determines the code stream data segment capable of acquiring the code stream data through the frame header information, thereby realizing decoding of the code stream data.
It should be noted that, in the embodiment of the present invention, the order of the step 302, the step 303, and the step 304 is not limited to the generation of the picture header information and the frame header information corresponding to the picture file in the step 305.
And 306, writing the picture header information into a picture header information data segment of the picture file.
Specifically, the encoding device writes the picture header information into a picture header information data segment of the picture file. Wherein the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
Optionally, the picture header information may further include user-defined information, where the user-defined information includes a start code of the user-defined information, a length of the user-defined information, and user-defined information; the user-defined information includes Exchangeable Image File (EXIF) information, such as an aperture, a shutter, a white balance, an International Organization for Standardization (ISO), a focal length, a date and time, and shooting conditions, a camera brand, a model, a color code, a sound recorded during shooting, global positioning system data, a thumbnail, and the like, when shooting, and the user-defined information includes information that can be set by user-definition, which is not limited in the embodiment of the present invention.
The image characteristic information further includes the start code of the image characteristic information, the length of the data segment of the image characteristic information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value range adopted by the picture file, the width of the picture file, the height of the picture file, and a frame number used for indicating the picture file in the dynamic format. Optionally, the image feature information may further include a YUV color space format adopted by the picture file.
For example, please refer to fig. 5a, which is an exemplary diagram of picture header information according to an embodiment of the present invention. As shown in fig. 5a, the picture header information of a picture file is composed of an image sequence header data segment, an image feature information data segment, and a user-defined information data segment.
Wherein the image sequence header data segment includes an image file identifier, a decoder identifier, a version number, and the image characteristic information.
Image file identifier (image _ identifier): the type of the picture file can be represented by a predetermined identifier, for example, an image file identifier occupies 4 bytes, such as a bit string 'AVSP', to identify that the picture file is an AVS picture file.
Decoder identifier: the identification of the codec standard used to compress the current picture file is represented, for example, by 4 bytes. Or may be interpreted as indicating a decoder kernel model employed for current picture decoding, and when the AVS2 kernel is employed, code _ id is 'AVS 2'.
Version number: the level used to represent the codec standard indicated by the compression standard identifier may include, for example, a basic level (Baseline Profile), a Main level (Main Profile), an Extended level (Extended Profile), and so on. For example, using an 8-bit unsigned number identification, as shown in table one, the type of version number is given.
Watch 1
Value of version number Grade of
‘B’ Base Profile
‘M’ Main Profile
‘H’ High Profile
Referring to fig. 5b, an exemplary diagram of an image characteristic information data segment is provided for the embodiment of the present invention, as shown in fig. 5b, the image characteristic information data segment includes an image characteristic information start code, an image characteristic information data segment length, whether there is an alpha channel flag, a dynamic image flag, a YUV color space format, a lossless mode flag, a YUV color space value domain flag, a reserved bit, an image width, and a frame number. Please refer to the following detailed description.
Image characteristic information start code: is a field for indicating the start position of the image characteristic information data segment of the picture file, for example, in 1-byte representation, and is the field D0.
Length of image characteristic information data segment: the number of bytes occupied by the image characteristic information data segment is represented by, for example, 2 bytes, for example, for a picture file in a dynamic format, 9 bytes are totally included in the image characteristic information data segment in fig. 5b, and 9 can be filled in; for a still format picture file, the image characteristic information data segment in fig. 5b has a total of 12 bytes, and 12 can be filled in.
Image transparency flag: and the method is used for indicating whether the image in the picture file carries transparency data or not. For example, one bit is used for representing, 0 represents that the image in the picture file does not carry transparency data, and 1 represents that the image in the picture file carries transparency data; it will be appreciated that whether there is an alpha channel is synonymous with whether transparency data is included.
Moving image flag: for indicating whether the picture file is a picture file in a dynamic format and whether the picture file is a picture file in a static format, for example, one bit is used to indicate that 0 indicates a picture file in a static format and 1 indicates a picture file in a dynamic format.
YUV color space format: the format of the chrominance component used to convert the RGB data indicating the picture file to YUV data is, for example, represented by two bits, as shown in table two below.
Watch two
Value of YUV _ color space format YUV color space format
00 4:0:0
01 4:2:0
10 4: 2: 2 (Retention)
11 4:4:4
Lossless mode flag: for indicating whether the encoding is lossless or lossy, for example, one bit is used to indicate, 0 indicates lossy encoding, and 1 indicates lossless encoding, where RGB data in a picture file is directly encoded in a video encoding mode, indicating lossless encoding; and converting the RGB data in the picture file into YUV data, and then coding the YUV data, wherein the coding is represented by lossy coding.
YUV color space value domain flag: for indicating that the YUV color space range of values complies with the ITU-r bt.601 standard. For example, using one bit to represent, 1 represents the value range of the Y component as [16,235], and the value range of the UV component as [16,240 ]; 0 indicates that the value range of the Y component and the UV component is [0,255 ].
Reserving a bit: a 10-bit unsigned integer. The excess bits in the byte are set as reserved bits.
Image width: for example, if the image width ranges from 0 to 65535, the image width may be represented by 2 bytes.
Image height: for example, if the image width ranges from 0 to 65535, the height of each image in the picture file can be represented by 2 bytes.
Number of image frames: it is only in the case of a picture file in a dynamic format that it represents the total number of frames contained in the picture file, for example, in 3 bytes.
Referring to fig. 5c, an exemplary diagram of a user-defined information data segment is provided for the embodiment of the present invention, as shown in fig. 5c, and specifically referred to the following detailed description.
User-defined information start code: is a field for indicating the starting position of the user-defined information, for example, in 1-byte representation, e.g., the bit string '0 x000001 BC' identifies the start of the user-defined information.
User-defined information data segment length: the data length of the current user-defined information is represented, for example, in 2 bytes.
User self-defined information: the byte number used for writing the data required to be input by the user, such as EXIF and other information, can be determined according to the length of the user-defined information.
It should be noted that, the above is only an example, and the name of each piece of information included in the picture header information, the position of each piece of information in the picture header information, and the number of bits occupied by representing each piece of information are not limited in the embodiment of the present invention.
307, writing the frame header information into a frame header information data segment of the picture file.
Specifically, the encoding device writes the frame header information into a frame header information data segment of the picture file.
In an alternative scheme, one frame of image of the picture file corresponds to one frame header information. Specifically, for the case that the picture file is in the static format, the picture file in the static format includes a frame of image, which is the first image, and therefore the picture file in the static format includes frame header information. For the situation that the picture file is in a dynamic format, the picture file in the dynamic format generally comprises at least two frames of images, and one frame header information is added to each frame of image.
Referring to fig. 6a, a diagram of an example of a package of a picture file in a static format is provided in the embodiment of the present invention. As shown in fig. 6a, the picture file includes a picture header information data segment, a frame header information data segment, and a code stream data segment. A picture file in a static format includes picture header information, frame header information, and code stream data representing an image of the picture file, where the code stream data includes first code stream data generated from RGB data of the frame image and second code stream data generated from transparency data of the frame image. Writing each piece of information or data into a corresponding data segment, for example, writing picture header information into a picture header information data segment; writing the frame header information into a frame header information data section; and writing the code stream data into the code stream data section. It should be noted that, because the first code stream data and the second code stream data in the code stream data segment are obtained through a video coding mode, the code stream data segment may be described by using a video frame data segment, and thus, the information written in the video frame data segment is the first code stream data and the second code stream data obtained by coding the image file in the static format.
Referring to fig. 6b, a diagram of an example of a package of a picture file with a dynamic format is provided in the embodiment of the present invention. As shown in fig. 6b, the picture file includes a picture header information segment, a plurality of frame header information segments, and a plurality of code stream data segments. A picture file in a dynamic format includes picture header information, a plurality of frame header information, and code stream data representing a plurality of frames of images. The code stream data corresponding to one frame of image corresponds to one frame of header information, wherein the code stream data representing each frame of image comprises first code stream data generated by RGB data of the frame of image and second code stream data generated by transparency data of the frame of image. Writing each piece of information or data into a corresponding data segment, for example, writing picture header information into a picture header information data segment; writing the frame header information corresponding to the 1 st frame into the frame header information data section corresponding to the 1 st frame; and writing the code stream data corresponding to the 1 st frame into the code stream data segment corresponding to the 1 st frame, and so on, so as to write the frame header information corresponding to the multiple frames into the frame header information segment corresponding to each frame, and write the code stream data corresponding to the multiple frames into the code stream data segment corresponding to each frame. It should be noted that, because the first code stream data and the second code stream data in the code stream data segment are obtained through a video coding mode, the code stream data segment may be described by using a video frame data segment, so that the information written in the video frame data segment corresponding to each frame image is the second code stream data of the first code stream data obtained by coding the frame image.
In another feasible scheme, one code stream data in one frame of image of the picture file corresponds to one frame header information. Specifically, for the situation of the picture file in the static format, the picture file in the static format includes a frame of image, that is, a first image, and the first image including the transparency data corresponds to two code stream data, that is, the first code stream data and the second code stream data, respectively, so that the first code stream data corresponds to one frame header information and the second code stream data corresponds to another frame header information in the picture file in the static format. Aiming at the condition of the picture file with the dynamic format, the picture file with the dynamic format comprises at least two frames of images, each frame of image containing transparency data corresponds to two code stream data, namely first code stream information and second code stream information, and frame header information is added to the first code stream information and the second code stream information of each frame of image.
Referring to fig. 7a, a diagram of another example of packaging a picture file in a static format is provided according to an embodiment of the present invention. In order to distinguish frame header information corresponding to the first code stream data from frame header information corresponding to the second code stream data, the first code stream data generated by the RGB data corresponds to the frame header information of the image, and the second code stream data generated by the transparency data corresponds to the frame header information of the transparent channel. As shown in fig. 7a, the picture file includes a picture header information data segment, an image frame header information data segment corresponding to the first code stream data, a first code stream data segment, a transparent channel frame header information data segment corresponding to the second code stream data, and a second code stream data segment. The picture file in the static format comprises picture header information, two frame header information, first code stream data and second code stream data, wherein the first code stream data is generated by RGB data of a frame image, and the second code stream data is generated by transparency data of the frame image. Writing each piece of information or data into a corresponding data segment, for example, writing picture header information into a picture header information data segment; writing the image frame header information corresponding to the first code stream data into the image frame header information data segment corresponding to the first code stream data; writing the first code stream data into a first code stream data segment; writing the transparent channel frame header information corresponding to the second code stream data into the transparent channel frame header information data segment corresponding to the second code stream data; and writing the second code stream data into a second code stream data segment. Optionally, the image frame header information data segment and the first code stream data segment corresponding to the first code stream data may be set as image frame data segments, and the transparent channel frame header information data segment and the second code stream data segment corresponding to the second code stream data may be set as transparent channel frame data segments.
Optionally, for a case that one code stream data in one frame of image of the picture file corresponds to one frame header information, the encoding device may arrange a frame header information data segment corresponding to the first code stream data, a first code stream data segment, a frame header information data segment corresponding to the second code stream data, and a second code stream data segment according to a preset sequence; for example, for a first code stream data segment, a second code stream data segment, and a frame header information data segment corresponding to each code stream data of a frame of image, the first code stream data segment, the frame header information data segment corresponding to the first code stream data, and the second code stream data segment may be arranged according to the frame header information data segment corresponding to the first code stream data, the frame header information data segment corresponding to the second code stream data, so that in a decoding process of a decoding device, which of two frame header information representing the frame of image and code stream data segments indicated by two frame headers can be determined which can obtain the first code stream data and which can obtain the second code stream data. It is to be understood that the first bitstream data is generated from RGB data, and the second bitstream data is generated from transparency data.
Referring to fig. 7b, a diagram of another example of packaging a picture file with a dynamic format is provided according to an embodiment of the present invention. In order to distinguish frame header information corresponding to the first code stream data from frame header information corresponding to the second code stream data, the first code stream data generated by the RGB data corresponds to the frame header information of the image, and the second code stream data generated by the transparency data corresponds to the frame header information of the transparent channel. As shown in fig. 7b, the picture file includes a picture header information segment, a plurality of frame header information segments, and a plurality of code stream data segments. A picture file in a dynamic format includes picture header information, a plurality of frame header information, and code stream data representing a plurality of frames of images. The first code stream data and the second code stream data corresponding to one frame of image respectively correspond to one frame header information, wherein the first code stream data is generated by RGB data of the frame of image, and the second code stream data is generated by transparency data of the frame of image. Each piece of information or data is written into a corresponding data segment. For example, writing picture header information into the picture header information data segment; writing image frame header information corresponding to first code stream data in a 1 st frame into an image frame header information data segment corresponding to the first code stream data in the 1 st frame; writing first code stream data corresponding to the 1 st frame into a first code stream data segment in the 1 st frame; writing the transparent channel frame header information corresponding to the second code stream data in the 1 st frame into the transparent channel frame header information data segment corresponding to the second code stream data in the 1 st frame; and writing the second code stream data corresponding to the 1 st frame into the second code stream data segment in the 1 st frame, and so on, so as to write the frame header information corresponding to each code stream data in the multiple frames into the frame header information data segment corresponding to the corresponding code stream data in each frame, and write each code stream data in the multiple frames into the code stream data segment corresponding to the corresponding code stream data in each frame. Optionally, the image frame header information data segment and the first code stream data segment corresponding to the first code stream data may be set as image frame data segments, and the transparent channel frame header information data segment and the second code stream data segment corresponding to the second code stream data may be set as transparent channel frame data segments.
Further, the frame header information includes a start code of the frame header information and delay time information for indicating the picture file in the dynamic format if the picture file is the dynamic format. Optionally, the frame header information further includes at least one of a length of a data segment of the frame header information and a length of a data segment of a code stream indicated by the frame header information. Further, optionally, the frame header information further includes specific information different from other frame images, such as coding region information, transparency information, a color table, and the like, which is not limited in this embodiment of the present invention.
For the case that the first code stream data and the second code stream data obtained by encoding a frame of image correspond to a frame header information, the frame header information may refer to an exemplary diagram of the frame header information shown in fig. 8a, as shown in fig. 8a, please refer to the following detailed description.
Frame header information start code: is a field for indicating the start position of the frame header information, for example, in 1 byte.
Length of frame header information data segment: the length of the header information is represented, for example, by 1 byte, which is optional information.
Length of code stream data segment: and indicating the code stream length of the code stream data segment indicated by the frame header information, wherein for the condition that the first code stream data and the second code stream data correspond to one frame header information, the code stream length is the sum of the length of the first code stream data and the length of the second code stream data, and the information is optional information.
Delay time information: the time difference between displaying the image corresponding to the current frame and displaying the image corresponding to the next frame is indicated only when the picture file is a picture file in a dynamic format, for example, 1 byte is used for the indication.
It should be noted that, the above is only an example, and the names of the pieces of information included in the frame header information, the positions of the pieces of information in the frame header information, and the number of bits occupied by representing the pieces of information are not limited in the embodiment of the present invention.
For the case that the first code stream data and the second code stream data respectively correspond to a frame header information, the frame header information is divided into the frame header information of the image and the frame header information of the transparent channel, please refer to fig. 8b and fig. 8c together.
FIG. 8b is a diagram illustrating an example of header information of an image frame according to an embodiment of the present invention. The image frame header information comprises an image frame header information start code and delay time information used for indicating the image file with the dynamic format. Optionally, the video frame header information further includes at least one of a length of the video frame header information data segment and a length of a first code stream data segment of the first code stream data segment indicated by the video frame header information. Further, optionally, the frame header information of the image further includes specific information different from other frame images, such as coding region information, transparency information, a color table, and the like, which is not limited in this embodiment of the present invention.
Image frame header information start code: is a field for indicating the start position of the header information of the image frame, for example, in 1 byte representation, such as a bit string '0 x000001 BA'.
Length of image frame header information data segment: the length of the header information of the image is expressed, for example, in 1 byte, and the information is optional information.
Length of data segment of first code stream: and the information represents the code stream length of the first code stream data segment indicated by the image frame header information, and is optional information.
Delay time information: the time difference between displaying the image corresponding to the current frame and displaying the image corresponding to the next frame is indicated only when the picture file is a picture file in a dynamic format, for example, 1 byte is used for the indication.
As shown in fig. 8c, an exemplary diagram of transparent channel frame header information is provided for the embodiment of the present invention. The transparent channel frame header information comprises a transparent channel frame header information start code. Optionally, the transparent channel frame header information further includes at least one of a length of a data segment of the transparent channel frame header information, a length of a second code stream data segment of the second code stream data segment indicated by the transparent channel frame header information, and delay time information used for indicating the picture file in the dynamic format if the picture file is the dynamic format. Further, optionally, the frame header information of the transparent channel further includes specific information different from other frame images, such as coding region information, transparency information, a color table, and the like, which is not limited in this embodiment of the present invention.
Transparent channel frame header information start code: is a field for indicating the start position of the transparent channel frame header information, for example, in 1 byte representation, such as a bit string '0 x000001 BB'.
Length of transparent channel frame header information data segment: the length of the transparent channel header information is represented, for example, by 1 byte, and the information is optional information.
Length of data segment of first code stream: and the information represents the code stream length of the second code stream data segment indicated by the transparent channel frame header information, and is optional information.
Delay time information: the time difference between displaying the image corresponding to the current frame and displaying the image corresponding to the next frame is indicated only when the picture file is a picture file in a dynamic format, for example, 1 byte is used for the indication. This information is optional information. The transparent channel frame header information may refer to the delay time information in the frame header information of the image without including the delay time information.
In the embodiment of the present invention, the words such as the picture file, the image, the first code stream data, the second code stream data, the picture header information, the frame header information, and each information included in the picture header information, and each information included in the frame header information may appear by other names, for example, the picture file is described by "picture", and as long as the functions of each time are similar to those of the present invention, the picture file falls within the scope of the claims of the present invention and the equivalent technology thereof.
It should be further noted that, in the embodiment of the present invention, the RGBA data input before encoding may be obtained by decoding picture files in various formats, where the format of the picture file may be any one of JPEG, BMP, PNG, APNG, GIF, and the like, and the format of the picture file before encoding is not limited in the embodiment of the present invention.
It should be noted that the form of each start code in the embodiment of the present invention is unique in the entire compressed image data, so as to uniquely identify each data segment. The picture file referred to in the embodiments of the present invention is used to represent a complete picture file or an image file, and may include one or more images, where an image refers to a frame of a picture. The video frame data related in the embodiment of the present invention is code stream data obtained by video coding each frame image in the image file, for example, a first code stream data obtained by coding RGB data may be regarded as one video frame data, and a second code stream data obtained by coding transparency data may also be regarded as one video frame data.
In the embodiment of the invention, when a first image is RGBA data, an encoding device acquires RGBA data corresponding to the first image in a picture file, obtains RGB data and transparency data of the first image by separating the RGBA data, and encodes the RGB data of the first image according to a first video encoding mode to generate first code stream data; coding the transparency data of the first image according to a second video coding mode to generate second code stream data; generating picture header information and frame header information corresponding to a picture file containing the first image; and finally, writing the first code stream data and the second code stream data into a code stream data segment, writing picture header information into a picture header information data segment, and writing frame header information into a frame header information data segment. In addition, the RGB data and the transparency data in the picture file are respectively coded, so that the transparency data in the picture file are kept while the video coding mode is adopted, and the quality of the picture file is ensured.
Referring to fig. 9, a flowchart of a method for processing a picture file according to an embodiment of the present invention is shown, and as shown in fig. 9, the method according to the embodiment of the present invention may include steps 401 to 403.
401, decoding the first code stream data according to the first video decoding mode to generate RGB data of the first image.
Specifically, the decoding device decodes the first code stream data according to the first video decoding mode. The decoding device reads data generated by the first image from a code stream data segment by analyzing a picture file, and acquires code stream data related to the first image, wherein the first code stream data and the second code stream data are the data generated by reading the first image from the code stream data segment by analyzing the picture file, and the first image is an image contained in the image file. For the case where the image file contains transparency data, the decoding apparatus acquires first codestream data and second codestream data representing a first image. The first image may be a frame of image contained in a picture file in a static format; alternatively, the first image may be any one of a plurality of frame images included in a picture file in a dynamic format.
Optionally, for a case that the picture file includes RGB data and transparency data, information indicating a code stream data segment exists in the picture file, and for a picture file in a dynamic format, information indicating a code stream data segment corresponding to different frame images exists in the picture file, so that the decoding apparatus can acquire first code stream data generated from the RGB data of the first image and second code stream data generated from the transparency data of the first image.
Further, the decoding device decodes the first code stream data to generate RGB data of the first image.
And 402, decoding the second code stream data according to a second video decoding mode to generate transparency data of the first image.
Specifically, the decoding device decodes second bitstream data according to a second video decoding mode to generate transparency data of the first image. The second code stream data is also read in the same way as the first code stream data in the synchronization step 401.
For step 401 and step 402, the first video decoding mode or the second video decoding mode may be determined according to a video encoding mode adopted for generating first code stream data or generating second code stream data, for example, the first code stream data is taken as an example for description, if the first code stream data adopts I-frame encoding, the first video encoding mode is that RGB data may be generated according to current code stream data; and if the first code stream data adopts P frame coding, the first video coding mode is to generate RGB data of the current frame according to the decoded data. The second video coding mode can refer to the introduction of the first video coding mode, and is not described herein again.
It should be noted that step 401 and step 402 are not sequentially executed.
And 403, generating RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image.
Specifically, the decoding device generates RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image. Wherein, RGBA data is a color space representing Red, Green, Blue, and Alpha. The RGB data and the transparency data can be synthesized into RGBA data. Therefore, the corresponding RGBA data can be generated through the corresponding video decoding mode according to the code stream data obtained by coding in the video coding mode, the transparency data in the picture file is reserved while the video coding and decoding mode is adopted, and the quality and the display effect of the picture file are ensured.
For example, the decoding device decodes the RGB data and transparency data of the obtained first image in the form of:
RGB RGB RGB RGB RGB RGB……RGB
A A A A A A……A
the decoding means combines the corresponding RGB data and transparency data to obtain RGBA data for the first image in the form:
RGBA RGBA RGBA RGBA RGBA RGBA……RGBA
it should be noted that, the picture file in the embodiment of the present invention is a case that includes RGB data and transparency data, so that the first code stream data that can generate RGB data and the second code stream data that can generate transparency data can be read by parsing the picture file, and step 401 and step 402 are respectively performed. For the case that the picture file only contains RGB data, the first code stream data capable of generating RGB data can be read by parsing the picture file, and step 401 is executed to generate RGB data, i.e., the decoding of the first code stream data is completed.
In the embodiment of the invention, a decoding device decodes first code stream data according to a first video decoding mode to generate RGB data of a first image; decoding the second code stream data according to a second video decoding mode to generate transparency data of the first image; and generating RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image. The first code stream data and the second code stream data in the picture file are respectively decoded to further obtain RGBA data, so that the transparency data in the picture file is kept while a video coding and decoding mode is adopted, and the quality of the picture file is ensured.
Referring to fig. 10, a flowchart of another picture file processing method according to an embodiment of the present invention is shown, and as shown in fig. 10, the method according to the embodiment of the present invention may include steps 501 to 507. The embodiment of the present invention is explained with reference to a picture file in a dynamic format, and please refer to the following detailed description.
501, acquiring first code stream data and second code stream data generated by a first image corresponding to a k-th frame in a picture file in a dynamic format.
Specifically, the decoding device analyzes the picture file in the dynamic format, and acquires first code stream data and second code stream data generated by a first image corresponding to a kth frame from a code stream data segment of the picture file. Wherein, for a case where the image file contains transparency data, the decoding apparatus acquires first codestream data and second codestream data representing the first image. The picture file in the dynamic format includes at least two frames of images, and the k-th frame may be any one of the at least two frames of images. Wherein k is a positive integer greater than 0.
Optionally, for a case that a picture file in a dynamic format includes RGB data and transparency data, information for indicating code stream data segments corresponding to different frame images exists in the picture file, so that the decoding apparatus can acquire first code stream data generated from the RGB data of the first image and second code stream data generated from the transparency data of the first image.
Optionally, the decoding device may decode according to a sequence of code stream data corresponding to each frame in the picture file in the dynamic format, that is, may first acquire code stream data corresponding to a first frame of the picture file in the dynamic format to decode. The embodiment of the invention does not limit the sequence of the decoding device for acquiring the code stream data of the picture file in the dynamic format, which represents each frame of image.
Optionally, the decoding apparatus may determine, through the picture header information and the frame header information of the picture file, code stream data indicating an image corresponding to each frame, and refer to specific descriptions about the picture header information and the frame header information in the following embodiment.
502, decoding the first code stream data according to the first video decoding mode to generate the RGB data of the first image.
Specifically, the decoding device decodes the first code stream data according to the first video decoding mode to generate RGB data of the first image. Optionally, the decoding device decodes the first code stream data according to a first video coding mode to generate first YUV data of a first image; converting the first YUV data into RGB data of the first image.
503, decoding the second encoded stream data according to the second video decoding mode to generate transparency data of the first image.
Specifically, the decoding device decodes second bitstream data according to a second video decoding mode to generate transparency data of the first image. Optionally, decoding the second code stream data according to a second image video coding mode to generate second YUV data of the first image; and converting the second YUV data into transparency data of the first image.
For example, the decoding device decodes the RGB data and transparency data of the obtained first image in the form of:
RGB RGB RGB RGB RGB RGB……RGB
A A A A A A……A
the decoding means combines the corresponding RGB data and transparency data to obtain RGBA data for the first image in the form:
RGBA RGBA RGBA RGBA RGBA RGBA……RGBA
it should be noted that step 502 and step 503 are not sequentially executed.
And 504, generating RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image.
Specifically, the decoding device generates RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image. Wherein, RGBA data is a color space representing Red, Green, Blue, and Alpha. The RGB data and the transparency data can be synthesized into RGBA data. Therefore, the corresponding RGBA data can be generated through the corresponding video decoding mode according to the code stream data obtained by coding in the video coding mode, the transparency data in the picture file is reserved while the video coding and decoding mode is adopted, and the quality and the display effect of the picture file are ensured.
505, determining whether the k-th frame is the last frame of the picture file in the dynamic format.
Specifically, the decoding apparatus determines whether the k-th frame is the last frame of the picture file in the dynamic format, and optionally, determines whether to complete decoding of the picture file by detecting the number of frames included in the picture header information. If the k-th frame is the last frame of the picture file in the dynamic format, the decoding of the picture file in the dynamic format is finished, and step 507 is executed; if the k-th frame is not the last frame of the picture file in the dynamic format, step 506 is executed.
And 506, if not, updating k, and triggering and executing the acquisition of the first code stream data and the second code stream data of the first image corresponding to the kth frame in the picture file in the dynamic format.
Specifically, if the kth frame is not the last frame of the picture file in the dynamic format, decoding code stream data of an image corresponding to the next frame, that is, updating k with a value of (k + 1). And after k is updated, triggering and executing to acquire first code stream data and second code stream data of a first image corresponding to the kth frame in the picture file in the dynamic format.
It is understood that the image acquired by using k update is not the image corresponding to the same frame as the image acquired before k update, and for convenience of description, the image corresponding to k frame before k update is set as the first image, and the image corresponding to k frame after k update is set as the second image, so as to facilitate the distinction.
When step 502 to step 504 are performed on the second image, optionally, code stream data representing the second image is third code stream data and fourth code stream data; decoding the third code stream data according to a third video decoding mode to generate RGB data of the second image; decoding the fourth code stream data according to a fourth video decoding mode to generate transparency data of the second image, wherein the third code stream data is generated according to RGB data of the second image, and the fourth code stream data is generated according to the transparency data of the second image; and generating RGBA data corresponding to the second image according to the RGB data and the transparency data of the second image.
With respect to step 502 and step 503, the first video decoding mode, the second video decoding mode, the third video decoding mode, or the fourth video decoding mode referred to above is determined according to a video encoding mode adopted for generating code stream data. For example, taking a first code stream data as an example for description, if the first code stream data adopts I-frame coding, the first video coding mode is that RGB data can be generated according to current code stream data; and if the first code stream data adopts P frame coding, the first video coding mode is to generate RGB data of the current frame according to the decoded data. For other video coding modes, reference may be made to the description of the first video coding mode, and the description thereof is omitted here.
It should be further noted that the picture file in the dynamic format includes a plurality of code stream data segments, and optionally, one frame of image corresponds to one code stream data segment; or, one code stream data corresponds to one code stream data segment. Therefore, the code stream data segment for reading the first code stream data and the second code stream data is different from the code stream data segment for reading the third code stream data and the fourth code stream data.
And 507, if so, decoding the picture file in the dynamic format.
Specifically, if the k-th frame is determined to be the last frame of the picture file in the dynamic format, it indicates that decoding of the picture file in the dynamic format is completed.
Optionally, the decoding apparatus may generate frame header information for code stream data generated by an image corresponding to each frame, and generate picture header information for the picture file in the dynamic format, so that whether the picture file includes transparency data may be determined by the picture header information, and it may be further determined whether to acquire only first code stream data generated by RGB data or to acquire first code stream data generated by RGB data and second code stream data generated by transparency data in a decoding process.
It should be noted that, in the embodiment of the present invention, the image corresponding to each frame in the picture file in the dynamic format is RGBA data including RGB data and transparency data, and for the case that the image corresponding to each frame in the picture file in the dynamic format only includes RGB data, the code stream data representing each frame image is only the first code stream data, so the decoding apparatus may perform step 502 on the first code stream data representing each frame image to generate RGB data. This still allows decoding of the code stream data containing only RGB data by the video decoding mode.
In the embodiment of the invention, under the condition that the picture file in the dynamic format contains RGB data and transparency data, a decoding device decodes first code stream data in each frame of image according to a first video decoding mode to generate RGB data of a first image; decoding second code stream data in each frame of image according to a second video decoding mode to generate transparency data of the first image; and generating RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image. The first code stream data and the second code stream data in the picture file are respectively decoded to further obtain RGBA data, so that the transparency data in the picture file is kept while a video coding and decoding mode is adopted, and the quality of the picture file is ensured.
Referring to fig. 11, a flowchart of another picture file processing method according to an embodiment of the present invention is shown, and as shown in fig. 11, the method according to the embodiment of the present invention may include steps 601 to 606.
601, analyzing the picture file to obtain picture header information and frame header information of the picture file.
Specifically, the decoding apparatus parses the picture file to obtain picture header information and frame header information of the picture file. The picture header information comprises image characteristic information of whether the picture file has transparency data, and how to acquire code stream data can be determined by determining whether the picture file contains the transparency data and whether the acquired code stream data contains second code stream data generated by the transparency data. The frame header information is used for indicating a code stream data segment of the picture file, and the code stream data segment capable of acquiring the code stream data can be determined through the frame header information, so that the decoding of the code stream data is realized. For example, the frame header information includes a frame header information start code, and the code stream data segment can be determined by identifying the frame header information start code.
Optionally, the analyzing, by the decoding device, the picture file to obtain the picture header information of the picture file may specifically be: and reading the picture header information of the picture file from the picture header information data segment of the picture file. Wherein the picture header information comprises the picture header information including an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
Optionally, the picture header information may further include user-defined information, where the user-defined information includes identification information corresponding to the user-defined information, a length of the user-defined information, and user-defined information; the user-defined information includes EXIF information such as an aperture at the time of photographing, a shutter, a white balance, ISO, a focal length, a date and time, etc., and photographing conditions as well as a camera brand, a model, a color code, a sound recorded at the time of photographing, and global positioning system data, a thumbnail, etc.
Optionally, the image feature information further includes a start code of the image feature information, a length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value range adopted by the picture file, a width of the picture file, a height of the picture file, and a frame number used for indicating if the picture file is a picture file in a dynamic format. Optionally, the image feature information may further include a YUV color space format adopted by the picture file.
Optionally, the analyzing, by the decoding device, the picture file to obtain the frame header information of the picture file may specifically be: and reading the frame header information of the picture file from the frame header information data section of the picture file. The frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format. Optionally, the frame header information further includes at least one of a length of a data segment of the frame header information and a length of a data segment of a code stream indicated by the frame header information. Further, optionally, the frame header information further includes specific information different from other frame images, such as coding region information, transparency information, a color table, and the like, which is not limited in this embodiment of the present invention.
It should be noted that, for example, fig. 5a, fig. 5b, fig. 5c, fig. 6a, fig. 6b, fig. 7a, fig. 7b, fig. 8a, fig. 8b, and fig. 8c may be referred to for picture header information and frame header information in the embodiment of the present invention, and are not repeated herein.
And 602, reading code stream data in the code stream data segment indicated by the frame header information in the picture file.
Specifically, if it is determined that the picture file contains transparency data through the image feature information, the decoding device reads code stream data in a code stream data segment indicated by the frame header information in the picture file. The code stream data comprises first code stream data and second code stream data.
In a feasible scheme, one frame of image of the picture file corresponds to one frame header information, that is, the frame header information may be used to indicate a code stream data segment including the first code stream data and the second code stream data. Specifically, for the case that the picture file is in the static format, the picture file in the static format includes a frame of image, which is the first image, and therefore the picture file in the static format includes frame header information. For the situation that the picture file is in a dynamic format, the picture file in the dynamic format generally comprises at least two frames of images, and each frame of image has frame header information. And if the picture file is determined to contain the transparency data, the decoding device reads the first code stream data and the second code stream data according to the code stream data segment indicated by the frame header information.
In another feasible scheme, one code stream data in one frame of image of the picture file corresponds to one frame header information, that is, a code stream data segment indicated in one frame header information contains one code stream data. Specifically, for the situation of the picture file in the static format, the picture file in the static format includes a frame of image, that is, a first image, and the first image including the transparency data corresponds to two code stream data, that is, the first code stream data and the second code stream data, respectively, so that the first code stream data corresponds to one frame header information and the second code stream data corresponds to another frame header information in the picture file in the static format. Aiming at the condition of the picture file with the dynamic format, the picture file with the dynamic format comprises at least two frames of images, each frame of image containing transparency data corresponds to two code stream data, namely first code stream information and second code stream information, and frame header information is added to the first code stream information and the second code stream information of each frame of image. Therefore, if it is determined that the picture file contains the transparency data, the decoding device respectively obtains the first code stream data and the second code stream data according to the two code stream data segments respectively indicated by the two frame header information.
It should be noted that, for a case that one code stream data in one frame image of the picture file corresponds to one frame header information, the encoding device may arrange a frame header information data segment corresponding to the first code stream data, a first code stream data segment, a frame header information data segment corresponding to the second code stream data, and a second code stream data segment according to a preset order, and the decoding device may determine an arrangement order of the encoding device. For example, for a first code stream data segment, a second code stream data segment, and a frame header information data segment corresponding to each code stream data of a frame of image, the first code stream data segment, the frame header information data segment corresponding to the first code stream data, and the second code stream data segment may be arranged according to the frame header information data segment corresponding to the first code stream data, the first code stream data segment, the frame header information data segment corresponding to the second code stream data, and the second code stream data segment. It is to be understood that the first bitstream data is generated from RGB data, and the second bitstream data is generated from transparency data.
603, decoding the first code stream data according to the first video decoding mode to generate the RGB data of the first image.
604, decoding the second encoded stream data according to a second video decoding mode to generate transparency data for the first image.
605, generating RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image.
For steps 603 to 605, reference may be made to the detailed description of corresponding steps in the embodiments of fig. 9 and fig. 10, which is not repeated herein.
In the embodiment of the invention, under the condition that the picture file comprises RGB data and transparency data, the decoding device analyzes the picture file to obtain picture header information and frame header information of the picture file, and reads code stream data in a code stream data section indicated by the frame header information in the picture file; decoding first code stream data in each frame of image according to a first video decoding mode to generate RGB data of a first image; decoding second code stream data in each frame of image according to a second video decoding mode to generate transparency data of the first image; and generating RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image. The first code stream data and the second code stream data in the picture file are respectively decoded to further obtain RGBA data, so that the transparency data in the picture file is kept while a video coding and decoding mode is adopted, and the quality of the picture file is ensured.
Referring to fig. 12, a flowchart of another picture file processing method according to an embodiment of the present invention is provided, and as shown in fig. 12, the method according to the embodiment of the present invention may include steps 701 to 705.
701, generating picture header information and frame header information corresponding to the picture file.
Specifically, the picture file processing device generates picture header information and frame header information corresponding to the picture file. The picture file can be a picture file in a static format, namely only containing the first image; or, the picture file is a picture file in a dynamic format, that is, the picture file includes the first image and other images. Whether the picture file is a picture file in a static format or a picture file in a dynamic format, the picture file processing apparatus needs to generate picture header information corresponding to the picture file. The picture header information comprises image characteristic information of whether transparency data exist in the picture file or not, so that the decoding device determines how to acquire code stream data by determining whether the transparency data are included or not and whether the acquired code stream data include second code stream data generated by the transparency data or not.
Further, the frame header information is used to indicate a code stream data segment of the picture file, so that the decoding device determines the code stream data segment capable of acquiring the code stream data through the frame header information, thereby realizing decoding of the code stream data. For example, the frame header information includes a frame header information start code, and the code stream data segment can be determined by identifying the frame header information start code.
Optionally, the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
Optionally, the picture header information may further include user-defined information, where the user-defined information includes identification information corresponding to the user-defined information, a length of the user-defined information, and user-defined information; the user-defined information includes EXIF information such as an aperture at the time of photographing, a shutter, a white balance, ISO, a focal length, a date and time, etc., and photographing conditions as well as a camera brand, a model, a color code, a sound recorded at the time of photographing, and global positioning system data, a thumbnail, etc.
Optionally, the image feature information further includes a start code of the image feature information, a length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value range adopted by the picture file, a width of the picture file, a height of the picture file, and a frame number used for indicating if the picture file is a picture file in a dynamic format. Optionally, the image feature information may further include a YUV color space format adopted by the picture file.
Optionally, the frame header information includes a start code of the frame header information and delay time information used for indicating that the picture file is in a dynamic format. Optionally, the frame header information further includes at least one of a length of a data segment of the frame header information and a length of a data segment of a code stream indicated by the frame header information. Further, optionally, the frame header information further includes specific information different from other frame images, such as coding region information, transparency information, a color table, and the like, which is not limited in this embodiment of the present invention.
And 702, writing the picture header information into a picture header information data segment of the picture file.
Specifically, the picture file processing apparatus writes the picture header information into the picture file picture header information data segment.
703, writing the frame header information into a frame header information data segment of the picture file.
Specifically, the picture file processing device writes the frame header information into a frame header information data segment of the picture file.
And 704, if it is determined that the image characteristic information includes transparency data, encoding RGB data included in RGBA data corresponding to the first image to generate first code stream data, and encoding the included transparency data to generate second code stream data.
Specifically, if it is determined that the image feature information includes transparency data, the picture file processing apparatus encodes RGB data included in RGBA data corresponding to the first image to generate first code stream data, and encodes the included transparency data to generate second code stream data.
Optionally, after the image file processing device acquires RGBA data corresponding to a first image in the image file, the RGBA data is separated to obtain RGB data and transparency data of the first image, where the RGB data is color data included in the RGBA data, and the transparency data is transparency data included in the RGBA data. Further, the RGB data and the transparency data are respectively encoded, and a specific encoding process may be specifically described in the embodiments shown in fig. 1 to fig. 4d, which is not described herein again.
705, writing the first code stream data and the second code stream data into a code stream data segment indicated by the frame header information corresponding to the first image.
Specifically, the picture file processing apparatus writes the first code stream data and the second code stream data into a code stream data segment indicated by frame header information corresponding to the first image.
It should be noted that, for example, fig. 5a, fig. 5b, fig. 5c, fig. 6a, fig. 6b, fig. 7a, fig. 7b, fig. 8a, fig. 8b, and fig. 8c may be referred to for picture header information and frame header information in the embodiment of the present invention, and are not repeated herein.
It should be further noted that, in the embodiment of the present invention, the RGBA data input before encoding may be obtained by decoding picture files in various formats, where the format of the picture file may be any one of JPEG, BMP, PNG, APNG, GIF, and the like, and the format of the picture file before encoding is not limited in the embodiment of the present invention.
In the embodiment of the invention, the picture file processing device generates picture header information and frame header information corresponding to the picture file, and the decoding device can determine how to acquire code stream data and whether the acquired code stream data contains second code stream data generated by transparency data according to whether the picture file contained in the picture header information has image characteristic information of the transparency data; the decoding device can acquire the code stream data in the code stream data section through the code stream data section of the picture file indicated by the frame header information, so that the decoding of the code stream data is realized.
Referring to fig. 13, a flowchart of another picture file processing method according to an embodiment of the present invention is provided, and as shown in fig. 13, the method according to the embodiment of the present invention may include steps 801 to 803.
801, analyzing the picture file to obtain picture header information and frame header information of the picture file.
Specifically, the picture file processing device parses the picture file to obtain picture header information and frame header information of the picture file. The picture header information comprises image characteristic information of whether the picture file has transparency data, and how to acquire code stream data can be determined by determining whether the picture file contains the transparency data and whether the acquired code stream data contains second code stream data generated by the transparency data. The frame header information is used for indicating a code stream data segment of the picture file, and the code stream data segment capable of acquiring the code stream data can be determined through the frame header information, so that the decoding of the code stream data is realized. For example, the frame header information includes a frame header information start code, and the code stream data segment can be determined by identifying the frame header information start code.
Optionally, the analyzing, by the picture file processing apparatus, the picture header information of the picture file may specifically be: and reading the picture header information of the picture file from the picture header information data segment of the picture file. Wherein the picture header information comprises the picture header information including an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
Optionally, the picture header information may further include user-defined information, where the user-defined information includes identification information corresponding to the user-defined information, a length of the user-defined information, and user-defined information; the user-defined information includes EXIF information such as an aperture at the time of photographing, a shutter, a white balance, ISO, a focal length, a date and time, etc., and photographing conditions as well as a camera brand, a model, a color code, a sound recorded at the time of photographing, and global positioning system data, a thumbnail, etc.
Optionally, the image feature information further includes a start code of the image feature information, a length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value range adopted by the picture file, a width of the picture file, a height of the picture file, and a frame number used for indicating if the picture file is a picture file in a dynamic format. Optionally, the image feature information may further include a YUV color space format adopted by the picture file.
Optionally, the analyzing, by the picture file processing device, the picture file to obtain the frame header information of the picture file may specifically be: and reading the frame header information of the picture file from the frame header information data section of the picture file. The frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format. Optionally, the frame header information further includes at least one of a length of a data segment of the frame header information and a length of a data segment of a code stream indicated by the frame header information. Further, optionally, the frame header information further includes specific information different from other frame images, such as coding region information, transparency information, a color table, and the like, which is not limited in this embodiment of the present invention.
It should be noted that, for example, fig. 5a, fig. 5b, fig. 5c, fig. 6a, fig. 6b, fig. 7a, fig. 7b, fig. 8a, fig. 8b, and fig. 8c may be referred to for picture header information and frame header information in the embodiment of the present invention, and are not repeated herein.
And 802, if the picture file is determined to contain transparency data through the image characteristic information, reading code stream data in a code stream data segment indicated by the frame header information in the picture file, wherein the code stream data comprises first code stream data and second code stream data.
Specifically, if it is determined that the picture file contains transparency data through the image feature information, the picture file processing device reads code stream data in a code stream data segment indicated by the frame header information in the picture file. The code stream data comprises first code stream data and second code stream data.
In a feasible scheme, one frame of image of the picture file corresponds to one frame header information, that is, the frame header information may be used to indicate a code stream data segment including the first code stream data and the second code stream data. Specifically, for the case that the picture file is in the static format, the picture file in the static format includes a frame of image, which is the first image, and therefore the picture file in the static format includes frame header information. For the situation that the picture file is in a dynamic format, the picture file in the dynamic format generally comprises at least two frames of images, and one frame header information is added to each frame of image. And if the picture file is determined to contain the transparency data, the picture file processing device reads the first code stream data and the second code stream data according to the code stream data segment indicated by the frame header information.
In another feasible scheme, one code stream data in one frame of image of the picture file corresponds to one frame header information, that is, a code stream data segment indicated in one frame header information contains one code stream data. Specifically, for the situation of the picture file in the static format, the picture file in the static format includes a frame of image, that is, a first image, and the first image including the transparency data corresponds to two code stream data, that is, the first code stream data and the second code stream data, respectively, so that the first code stream data corresponds to one frame header information and the second code stream data corresponds to another frame header information in the picture file in the static format. Aiming at the condition of the picture file with the dynamic format, the picture file with the dynamic format comprises at least two frames of images, each frame of image containing transparency data corresponds to two code stream data, namely first code stream information and second code stream information, and frame header information is added to the first code stream information and the second code stream information of each frame of image. Therefore, if it is determined that the picture file contains the transparency data, the picture file processing device respectively obtains the first code stream data and the second code stream data according to the two code stream data segments respectively indicated by the two frame header information.
It should be noted that, for a case that one code stream data in one frame image of the picture file corresponds to one frame header information, the encoding device may arrange a frame header information data segment corresponding to the first code stream data, a first code stream data segment, a frame header information data segment corresponding to the second code stream data, and a second code stream data segment according to a preset order, and the picture file processing device may determine an arrangement order of the encoding device. For example, for a first code stream data segment, a second code stream data segment, and a frame header information data segment corresponding to each code stream data of a frame of image, the frame header information data segment corresponding to the first code stream data, the first code stream data segment, the frame header information data segment corresponding to the second code stream data, and the second code stream data segment may be arranged, so that in the process of decoding by the picture file processing apparatus, which of the two frame header information representing the frame of image and the code stream data segments indicated by the two frame headers can be determined which can obtain the first code stream data and which can obtain the second code stream data. It is to be understood that the first bitstream data is generated from RGB data, and the second bitstream data is generated from transparency data.
803, decoding the first code stream data and the second code stream data respectively.
Specifically, after the picture file processing device acquires the first code stream data and the second code stream data from the code stream data segment, the picture file processing device decodes the first code stream data and the second code stream data.
It should be noted that, the picture file processing apparatus may implement decoding of the first code stream data and the second code stream data with reference to the execution process of the decoding apparatus in the embodiments shown in fig. 9 to 11, which is not described herein again.
In the embodiment of the invention, the picture file processing device analyzes the picture file to obtain picture header information and frame header information, and can determine how to acquire code stream data and whether the acquired code stream data contains second code stream data generated by transparency data according to whether the picture file contained in the picture header information has image characteristic information of the transparency data; and acquiring the code stream data segment of the code stream data through the code stream data segment of the picture file indicated by the frame header information, thereby realizing the decoding of the code stream data.
Please refer to fig. 14, which is a schematic structural diagram of an encoding apparatus according to an embodiment of the present invention. As shown in fig. 14, the encoding apparatus 1 according to the embodiment of the present invention may include: the device comprises a data acquisition module 11, a first encoding module 12, a second encoding module 13 and a data writing module 14. Optionally, the encoding apparatus 1 may further include an information generating module 15.
The data acquisition module 11 is configured to acquire RGBA data corresponding to a first image in a picture file, and separate the RGBA data to obtain RGB data and transparency data of the first image, where the RGB data is color data included in the RGBA data, and the transparency data is transparency data included in the RGBA data;
a first encoding module 12, configured to encode RGB data of the first image according to a first video encoding mode, and generate first code stream data;
a second encoding module 13, configured to encode transparency data of the first image according to a second video encoding mode, and generate second bitstream data;
a data writing module 14, configured to write the first code stream data and the second code stream data into a code stream data segment of the picture file, where the first image is an image included in the picture file.
Optionally, the first encoding module 12 includes a first data conversion unit and a first code stream generation unit, where:
a first data conversion unit for converting the RGB data of the first image into first YUV data;
and the first code stream generating unit is used for coding the first YUV data according to a first video coding mode to generate first code stream data.
Optionally, the second encoding module 13 includes a second data conversion unit and a second code stream generation unit, where:
a second data conversion unit, configured to convert transparency data of the first image into second YUV data;
and the second code stream generating unit is used for coding the second YUV data according to a second video coding mode to generate second code stream data.
Optionally, the second data conversion unit is specifically configured to set the transparency data of the first image as a Y component in second YUV data, and not set a UV component in the second YUV data. Or the second data conversion unit is specifically configured to set transparency data of the first image as a Y component in second YUV data, and set a UV component in the second YUV data as preset data.
Optionally, the data obtaining module 11 is configured to, if the picture file is a picture file in a dynamic format and the first image is an image corresponding to a kth frame in the picture file, obtain RGBA data corresponding to a second image corresponding to a (k +1) th frame in the picture file, and separate the RGBA data to obtain RGB data and transparency data of the second image;
the first encoding module 12 is further configured to encode the RGB data of the second image according to a third video encoding mode, so as to generate third encoded stream data;
the second encoding module 13 is further configured to encode the transparency data of the second image according to a fourth video encoding mode, and generate fourth code stream data;
the data writing module 14 is further configured to write the third code stream data and the fourth code stream data into a code stream data segment of the picture file.
Optionally, the encoding apparatus 1 further includes:
the information generating module 15 is configured to generate picture header information and frame header information corresponding to the picture file, where the picture header information includes image characteristic information of whether the picture file has transparency data, and the frame header information is used to indicate a code stream data segment of the picture file.
Optionally, the data writing module 13 is further configured to write the picture header information generated by the information generating module 15 into a picture header information data segment of the picture file; the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
Optionally, the image feature information further includes a start code of the image feature information, a length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value range adopted by the picture file, a width of the picture file, a height of the picture file, and a frame number used for indicating if the picture file is a picture file in a dynamic format.
Optionally, the data writing module 13 is further configured to write the frame header information generated by the information generating module 15 into a frame header information data segment of the picture file;
the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
It should be noted that the modules, units and beneficial effects of the encoding apparatus 1 described in the embodiment of the present invention can be specifically implemented according to the method in the embodiment of the method shown in fig. 1 to 8, and are not described herein again.
Fig. 15 is a schematic structural diagram of another encoding apparatus according to an embodiment of the present invention. As shown in fig. 15, the encoding apparatus 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, memory 1005, at least one communication bus 1002. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may optionally be at least one memory device located remotely from the processor 1001. Wherein a communication bus 1002 is used to enable connective communication between these components. Optionally, the encoding apparatus 1000 includes a user interface 1003, where optionally, the user interface 1003 may include a Display screen (Display) and a Keyboard (Keyboard). As shown in fig. 15, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a coding application program.
In the encoding apparatus 1000 shown in fig. 15, the processor 1001 may be configured to call an encoding application stored in the memory 1005, and specifically perform the following operations:
the method comprises the steps of obtaining RGBA data corresponding to a first image in a picture file, and separating the RGBA data to obtain RGB data and transparency data of the first image, wherein the RGB data are color data contained in the RGBA data, and the transparency data are transparency data contained in the RGBA data;
encoding the RGB data of the first image according to a first video encoding mode to generate first code stream data;
coding the transparency data of the first image according to a second video coding mode to generate second code stream data;
and writing the first code stream data and the second code stream data into a code stream data section of the picture file.
In a possible embodiment, the processor 1001 performs encoding on the RGB data of the first image according to a first video encoding mode to generate first code stream data, and specifically performs:
converting the RGB data of the first image into first YUV data; and coding the first YUV data according to a first video coding mode to generate first code stream data.
In a possible embodiment, the processor 1001 performs encoding on the transparency data of the first image according to the second video encoding mode to generate second bitstream data, and specifically performs:
converting the transparency data of the first image into second YUV data; and coding the second YUV data according to a second video coding mode to generate second code stream data.
In a possible embodiment, the processor 1001 performs, in converting the transparency data of the first image into the second YUV data, specifically:
setting transparency data of the first image as a Y component in second YUV data and not setting a UV component in the second YUV data; or,
setting transparency data of the first image as a Y component in second YUV data, and setting a UV component in the second YUV data as preset data.
In one possible embodiment, the processor 1001 further performs the following steps:
if the picture file is in a dynamic format and the first image is an image corresponding to a kth frame in the picture file, acquiring RGBA data corresponding to a second image corresponding to a (k +1) th frame in the picture file, and separating the RGBA data to obtain RGB data and transparency data of the second image;
encoding the RGB data of the second image according to a third video encoding mode to generate third code stream data;
coding the transparency data of the second image according to a fourth video coding mode to generate fourth code stream data;
and writing the third code stream data and the fourth code stream data into a code stream data section of the picture file.
In one possible embodiment, the processor 1001 further performs the following steps:
and generating picture header information and frame header information corresponding to the picture file, wherein the picture header information comprises image characteristic information of whether the picture file has transparency data, and the frame header information is used for indicating a code stream data segment of the picture file.
In one possible embodiment, the processor 1001 further performs the following steps:
writing the picture header information into a picture header information data segment of the picture file;
the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
In a possible embodiment, the image feature information further includes the start code of the image feature information, the length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value field adopted by the picture file, the width of the picture file, the height of the picture file, and a frame number used for indicating if the picture file is a picture file in a dynamic format.
In one possible embodiment, the processor 1001 further performs the following steps:
writing the frame header information into a frame header information data section of the picture file;
the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
It should be noted that the steps executed by the processor 1001 and the beneficial effects thereof described in the embodiment of the present invention can be implemented according to the method in the embodiment of the method shown in fig. 1 to 8, and are not described herein again.
Please refer to fig. 16, which is a schematic structural diagram of a decoding apparatus according to an embodiment of the present invention. As shown in fig. 16, the decoding apparatus 2 according to an embodiment of the present invention may include: a first decoding module 21, a second decoding module 22 and a data generating module 23. Optionally, the decoding apparatus 2 may further include at least one of a first data obtaining module 24, a file parsing module 25 and a second data obtaining module 26. The first code stream data and the second code stream data in the embodiment of the present invention are data generated by reading the first image from a code stream data section of a picture file.
The first decoding module 21 is configured to decode the first code stream data according to a first video decoding mode to generate RGB data of the first image;
a second decoding module 22, configured to decode second bitstream data according to a second video decoding mode, and generate transparency data of the first image;
a data generating module 23, configured to generate RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image;
optionally, the first decoding module 21 includes a first data generating unit and a first data converting unit, where:
the first data generation unit is used for decoding the first code stream data according to a first video coding mode to generate first YUV data of a first image;
a first data conversion unit for converting the first YUV data into RGB data of the first image.
Optionally, the second decoding module 22 includes a second data generating unit and a second data converting unit, where:
a second data generating unit, configured to decode the second encoded stream data according to a second image video coding mode, and generate second YUV data of the first image;
and the second data conversion unit is used for converting the second YUV data into transparency data of the first image.
Optionally, the second data conversion unit is specifically configured to set a Y component in the second YUV data as the transparency data of the first image, and discard a UV component in the second YUV data.
Optionally, the decoding apparatus 2 further includes:
a first data obtaining module 24, configured to obtain, from a code stream data segment of the picture file, third code stream data and fourth code stream data generated from a second image corresponding to a (k +1) th frame in the picture file if the picture file is a picture file in a dynamic format and the first image is an image corresponding to the kth frame in the picture file in the dynamic format;
the first decoding module 21 is further configured to decode the third encoded stream data according to a third video decoding mode, and generate RGB data of the second image;
the second decoding module 22 is further configured to decode the fourth code stream data according to a fourth video decoding mode, and generate transparency data of the second image;
the data generating module 23 is further configured to generate RGBA data corresponding to the second image according to the RGB data and the transparency data of the second image.
Optionally, the decoding apparatus 2 further includes a file parsing module 25:
the file parsing module 25 is configured to parse a picture file to obtain picture header information and frame header information of the picture file, where the picture header information includes image characteristic information of whether the picture file has transparency data, and the frame header information is used to indicate a code stream data segment of the picture file.
Optionally, the file parsing module 25 is specifically configured to read the picture header information of the picture file from the picture header information data segment of the picture file in parsing the picture file to obtain the picture header information of the picture file;
the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
Further optionally, the image feature information further includes the start code of the image feature information, the length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value range adopted by the picture file, the width of the picture file, the height of the picture file, and a frame number used for indicating the picture file in a dynamic format.
Optionally, the file parsing module 25 is specifically configured to read frame header information of the picture file from a frame header information data segment of the picture file in terms of parsing the picture file to obtain frame header information of the picture file;
the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
Optionally, the decoding apparatus 2 further includes:
a second data obtaining module 26, configured to, if it is determined that the picture file includes transparency data according to the image feature information, read code stream data in a code stream data segment indicated by the frame header information in the picture file, where the code stream data includes first code stream data and second code stream data.
It should be noted that the modules, units, and advantageous effects performed by the decoding apparatus 2 according to the embodiments of the present invention can be specifically implemented according to the methods in the method embodiments shown in fig. 9 to fig. 11, and are not described herein again.
Fig. 17 is a schematic structural diagram of another decoding apparatus according to an embodiment of the present invention. As shown in fig. 17, the decoding apparatus 2000 may include: at least one processor 2001, e.g., a CPU, at least one network interface 2004, memory 2005, at least one communication bus 2002. The network interface 2004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). Memory 2005 may be a high-speed RAM memory or a non-volatile memory (e.g., at least one disk memory). The memory 2005 may optionally also be at least one memory device located remotely from the aforementioned processor 2001. The communication bus 2002 is used to implement connection communication between these components. Optionally, the decoding apparatus 2000 includes a user interface 2003, wherein, optionally, the user interface 2003 may include a Display (Display) and a Keyboard (Keyboard). As shown in fig. 17, the memory 2005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a decoding application program.
In the decoding apparatus 2000 shown in fig. 17, the processor 2001 may be configured to call a decoding application program stored in the memory 2005, and specifically perform the following operations:
decoding the first code stream data according to a first video decoding mode to generate RGB data of a first image;
decoding second code stream data according to a second video decoding mode to generate transparency data of the first image;
generating RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image;
the first code stream data and the second code stream data are data generated by reading the first image from a code stream data segment of a picture file.
In a possible embodiment, the processor 2001 performs decoding on the first code stream data according to the first video decoding mode to generate RGB data of the first image, and specifically performs:
decoding the first code stream data according to a first video coding mode to generate first YUV data of a first image; converting the first YUV data into RGB data of the first image.
In a possible embodiment, the processor 2001 performs decoding on the second bitstream data according to the second video decoding mode to generate transparency data of the first image, and specifically performs:
decoding the second code stream data according to a second image video coding mode to generate second YUV data of the first image; and converting the second YUV data into transparency data of the first image.
In a possible embodiment, the processor 2001 performs, in the converting the second YUV data into transparency data of the first image, specifically:
setting a Y component in the second YUV data as the transparency data of the first image and discarding a UV component in the second YUV data.
In one possible embodiment, the processor 2001 further performs the following steps:
if the picture file is in a dynamic format and the first image is an image corresponding to a kth frame in the picture file in the dynamic format, acquiring third code stream data and fourth code stream data generated by a second image corresponding to a (k +1) th frame in the picture file from a code stream data segment of the picture file;
decoding the third code stream data according to a third video decoding mode to generate RGB data of the second image;
decoding the fourth code stream data according to a fourth video decoding mode to generate transparency data of the second image;
and generating RGBA data corresponding to the second image according to the RGB data and the transparency data of the second image.
In one possible embodiment, before performing decoding on the first code stream data according to the first video decoding mode to generate RGB data of the first image, the processor 2001 further performs the following steps:
analyzing a picture file to obtain picture header information and frame header information of the picture file, wherein the picture header information comprises image characteristic information of whether the picture file has transparency data, and the frame header information is used for indicating a code stream data segment of the picture file.
In a possible embodiment, the processor 2001 performs parsing on the picture file to obtain the picture header information of the picture file, and specifically performs:
reading the picture header information of the picture file from the picture header information data segment of the picture file;
the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
In a possible embodiment, the image feature information further includes the start code of the image feature information, the length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value field adopted by the picture file, the width of the picture file, the height of the picture file, and a frame number used for indicating if the picture file is a picture file in a dynamic format.
In a possible embodiment, the processor 2001 performs parsing of a picture file to obtain frame header information of the picture file, and specifically performs:
reading frame header information of the picture file from a frame header information data section of the picture file;
the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
In one possible embodiment, the processor 2001 further performs the following steps: and if the picture file is determined to contain transparency data through the image characteristic information, reading code stream data in a code stream data section indicated by the frame header information in the picture file, wherein the code stream data comprises first code stream data and second code stream data.
It should be noted that the steps executed by the processor 2001 and the beneficial effects thereof described in the embodiments of the present invention can be specifically implemented according to the method in the method embodiment shown in fig. 9 to fig. 11, and are not described herein again.
Fig. 18 is a schematic structural diagram of a picture file processing apparatus according to an embodiment of the present invention. As shown in fig. 18, the picture file processing apparatus 3 according to the embodiment of the present invention may include: an information generation module 31. Optionally, the picture file processing apparatus 3 may further include at least one of a first information writing module 32, a second information writing module 33, a data encoding module 34, and a data writing module 35.
The information generating module 31 is configured to generate picture header information and frame header information corresponding to a picture file, where the picture header information includes image characteristic information of whether the picture file has transparency data, and the frame header information is used to indicate a code stream data segment of the picture file.
Optionally, the picture file processing apparatus 3 further includes:
a first information writing module 32, configured to write the picture header information into a picture header information data segment of the picture file; the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
Further optionally, the image feature information further includes the start code of the image feature information, the length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value range adopted by the picture file, the width of the picture file, the height of the picture file, and a frame number used for indicating the picture file in a dynamic format.
The picture file processing apparatus 3 further includes a second information writing module 33:
the second information writing module 33 is configured to write the frame header information into a frame header information data segment of the picture file, where the first image is an image included in the picture file; the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
The picture file processing apparatus 3 further includes a data encoding module 34 and a data writing module 35:
if it is determined that the image characteristic information includes transparency data, the data encoding module 34 encodes RGB data included in RGBA data corresponding to the first image to generate first code stream data, and encodes the included transparency data to generate second code stream data;
the data writing module 35 writes the first code stream data and the second code stream data into a code stream data segment indicated by the frame header information corresponding to the first image.
It should be noted that the modules executed by the image file processing apparatus 3 and the beneficial effects brought by the modules described in the embodiment of the present invention can be specifically implemented according to the method in the embodiment of the method shown in fig. 12, and are not described herein again.
Referring to fig. 19, a schematic structural diagram of another picture file processing apparatus according to an embodiment of the present invention is provided. As shown in fig. 19, the picture file processing apparatus 3000 may include: at least one processor 3001, e.g., a CPU, at least one network interface 3004, memory 3005, at least one communication bus 3002. The network interface 3004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 3005 may be a high-speed RAM memory or a non-volatile memory (e.g., at least one disk memory). The memory 3005 may alternatively be at least one storage device located remotely from the processor 3001. The communication bus 3002 is used to realize connection communication between these components.
Optionally, the picture file processing apparatus 3000 includes a user interface 3003, wherein optionally, the user interface 3003 may include a Display screen (Display) and a Keyboard (Keyboard). As shown in fig. 19, a memory 3005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a picture file processing application program.
In the picture file processing apparatus 3000 shown in fig. 19, the processor 3001 may be configured to call a picture file processing application stored in the memory 3005, and specifically perform the following operations:
generating picture header information and frame header information corresponding to a picture file, wherein the picture header information comprises image characteristic information of whether the picture file has transparency data, and the frame header information is used for indicating a code stream data segment of the picture file.
In one possible embodiment, the processor 3001 further performs the following steps:
writing the picture header information into a picture header information data segment of the picture file;
the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
In a possible embodiment, the image feature information further includes the start code of the image feature information, the length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value field adopted by the picture file, the width of the picture file, the height of the picture file, and a frame number used for indicating if the picture file is a picture file in a dynamic format.
In one possible embodiment, the processor 3001 further performs the following steps:
writing the frame header information into a frame header information data segment of the picture file, wherein the first image is an image contained in the picture file;
the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
In one possible embodiment, the processor 3001 further performs the following steps:
if the image characteristic information is determined to contain transparency data, encoding RGB data contained in RGBA data corresponding to the first image to generate first code stream data, and encoding the contained transparency data to generate second code stream data;
and writing the first code stream data and the second code stream data into a code stream data segment indicated by the frame header information corresponding to the first image.
It should be noted that the steps executed by the processor 3001 and the beneficial effects brought by the steps described in the embodiment of the present invention can be specifically implemented according to the method in the embodiment of the method shown in fig. 12, and are not described herein again.
Referring to fig. 20, a schematic structural diagram of a picture file processing apparatus according to an embodiment of the present invention is provided. As shown in fig. 20, the picture file processing apparatus 4 according to the embodiment of the present invention may include: a file parsing module 41. Optionally, the picture file processing apparatus 4 may further include at least one of a data reading module 42 and a data decoding module 43.
The file parsing module 42 is configured to parse a picture file to obtain picture header information and frame header information of the picture file, where the picture header information includes image characteristic information of whether the picture file has transparency data, and the frame header information is used to indicate a code stream data segment of the picture file.
Optionally, the file parsing module 42 is specifically configured to read the picture header information of the picture file from the picture header information data segment of the picture file in parsing the picture file to obtain the picture header information of the picture file; wherein the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
Further optionally, the image feature information further includes the start code of the image feature information, the length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value range adopted by the picture file, the width of the picture file, the height of the picture file, and a frame number used for indicating the picture file in a dynamic format.
Optionally, the file parsing module 41 is specifically configured to read frame header information of the picture file from a frame header information data segment of the picture file in terms of parsing the picture file to obtain frame header information of the picture file; the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
Optionally, the picture file processing apparatus 4 further includes a data reading module 42 and a data decoding module 43, wherein:
the data reading module 42 is configured to read, if it is determined that the picture file includes transparency data according to the image feature information, code stream data in a code stream data segment indicated by the frame header information in the picture file, where the code stream data includes first code stream data and second code stream data.
The data decoding module 43 is configured to decode the first code stream data and the second code stream data respectively.
It should be noted that the modules executed by the image file processing apparatus 4 and the beneficial effects brought by the modules described in the embodiment of the present invention can be specifically implemented according to the method in the embodiment of the method shown in fig. 12, and are not described herein again.
Referring to fig. 21, a schematic structural diagram of another picture file processing apparatus according to an embodiment of the present invention is provided. As shown in fig. 21, the picture file processing apparatus 4000 may include: at least one processor 4001, e.g., a CPU, at least one network interface 4004, a memory 4005, and at least one communication bus 4002. Network interface 4004 may optionally include a standard wired interface, a wireless interface (e.g., a WI-FI interface). The memory 4005 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 4005 may alternatively be at least one memory device located remotely from the processor 4001. The communication bus 4002 is used to realize connection communication among these components. Optionally, the picture file processing apparatus 4000 includes a user interface 4003, where optionally, the user interface 4003 may include a Display screen (Display) and a Keyboard (Keyboard). As shown in fig. 21, a memory 4005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a picture file processing application.
In the picture file processing apparatus 4000 shown in fig. 21, the processor 4001 may be configured to call a picture file processing application stored in the memory 4005, and specifically perform the following operations:
analyzing a picture file to obtain picture header information and frame header information of the picture file, wherein the picture header information comprises image characteristic information of whether the picture file has transparency data, and the frame header information is used for indicating a code stream data segment of the picture file.
In a possible embodiment, the processor 4001 performs parsing of a picture file to obtain picture header information of the picture file, and specifically performs:
reading the picture header information of the picture file from the picture header information data segment of the picture file;
the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
In a possible embodiment, the image feature information further includes the start code of the image feature information, the length of the data segment of the image feature information, whether the picture file is a picture file in a static format, whether the picture file is a picture file in a dynamic format, whether the picture file is lossless coded, a YUV color space value field adopted by the picture file, the width of the picture file, the height of the picture file, and a frame number used for indicating if the picture file is a picture file in a dynamic format.
In a possible embodiment, the processor 4001 performs parsing of a picture file to obtain header information of the picture file, and specifically performs:
reading frame header information of the picture file from a frame header information data section of the picture file;
the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
In one possible embodiment, the processor 4001 further performs the steps of:
and if the picture file is determined to contain transparency data through the image characteristic information, reading code stream data in a code stream data section indicated by the frame header information in the picture file, wherein the code stream data comprises first code stream data and second code stream data.
And respectively decoding the first code stream data and the second code stream data.
It should be noted that the steps executed by the processor 4001 and the beneficial effects thereof described in the embodiment of the present invention can be specifically implemented according to the method in the embodiment of the method shown in fig. 13, and are not described herein again.
Referring to fig. 22, a system architecture diagram of a picture file processing system according to an embodiment of the present invention is provided. As shown in fig. 22, the picture file processing system 5000 includes an encoding device 5001 and a decoding device 5002.
In a possible scheme, the encoding apparatus 5001 may be the encoding device shown in fig. 1 to 8, or may also include a terminal apparatus having an encoding module that implements the function of the encoding device shown in fig. 1 to 8; accordingly, the decoding device 5002 may be the decoding apparatus shown in fig. 9 to 11, or may include a terminal device having a decoding module that implements the function of the decoding apparatus shown in fig. 9 to 11.
In another possible solution, the encoding apparatus 5001 may be the picture file processing device shown in fig. 12, or may also include a picture file processing module having a function of implementing the picture file processing device shown in fig. 12; accordingly, the decoding apparatus 5002 may be a picture file processing device shown in fig. 13, or may also include a picture file processing module having a function of implementing the picture file processing device shown in fig. 13.
The encoding device, the decoding device, the picture file processing device, and the terminal device according to the embodiments of the present invention may include a tablet Computer, a mobile phone, an electronic reader, a Personal Computer (PC), a notebook Computer, a vehicle-mounted device, a web tv, and a wearable device, and the like.
Further, the encoding apparatus 5001 and the decoding apparatus 5002 according to the embodiment of the present invention are specifically described with reference to fig. 23 and 24. Fig. 23 and 24 more fully illustrate other aspects that may be involved in the above-described method from the functional logic point of view, to facilitate the reader's further understanding of the technical solutions set forth herein. Referring to fig. 23, an exemplary diagram of a coding module is provided according to an embodiment of the present invention. As shown in fig. 23, the encoding apparatus 5001 may include the encoding module 6000 shown in fig. 23, and the encoding module 6000 may include: the system comprises an RGB data and transparency data separation sub-module, a first video coding mode sub-module, a second video coding mode sub-module, and a picture header information and frame header information packaging sub-module. The RGB data and transparency data separation sub-module is used for separating RGBA data in the picture source format into RGB data and transparency data. The first video coding mode sub-module is used for realizing the coding of the RGB data to generate first code stream data. The second video coding mode submodule is used for realizing the coding of the transparency data to generate second code stream data. The picture header information and frame header information packaging submodule is used for generating picture header information and frame header information of code stream data including first code stream data and second code stream data so as to output compressed image data.
In specific implementation, for a picture file in a static format, firstly, the coding module 6000 receives input RGBA data of the picture file, and the RGBA data is divided into RGB data and transparency data by the RGB data and transparency data separation submodule; then, encoding the RGB data according to a first video encoding mode to generate first code stream data; then, coding the transparency data according to a second video coding mode to generate second code stream data; then, generating picture header information and frame header information of the picture file, writing the first code stream data, the second code stream data, the frame header information and the picture header information into corresponding data segments, and further generating compressed image data corresponding to the RGBA data.
For a picture file in a dynamic format, firstly, the encoding module 6000 determines the number of frames contained; dividing the RGBA data of each frame into RGB data and transparency data through an RGB data and transparency data separation module, coding the RGB data according to a first video coding mode to generate first code stream data, coding the transparency data according to a second video coding mode to generate second code stream data, generating frame header information corresponding to each frame, and writing each code stream data and the frame header information into corresponding data segments; and finally, generating picture header information of the picture file, writing the picture header information into a corresponding data segment, and further generating compressed image data corresponding to the RGBA data.
Optionally, the compressed image data may also be described by names such as a compressed code stream and an image sequence, which are not limited in the embodiment of the present invention.
Referring to fig. 24, an exemplary diagram of a decoding module according to an embodiment of the present invention is provided. As shown in fig. 24, the decoding apparatus 5002 may include an encoding module 7000 shown in fig. 24, and the decoding module 7000 may include: the device comprises a picture header information analysis submodule, a frame header information analysis submodule, a first video decoding mode submodule, a second video decoding mode submodule and an RGB data and transparency data separation submodule. The picture header information and frame header information parsing submodule is configured to parse compressed image data of the picture file to determine picture header information and frame header information, where the compressed image data is obtained after the encoding is completed by the encoding module shown in fig. 23. The first video decoding mode sub-module is used for decoding first code stream data, wherein the first code stream data is generated by RGB data. The second video decoding mode submodule is used for realizing decoding of second code stream data, wherein the second code stream data is generated by transparency data. The RGB data and transparency data merging submodule is used for merging the RGB data and the transparency data into RGBA data so as to output the RGBA data.
In the specific implementation, for a picture file in a static format, firstly, the decoding module 7000 analyzes the compressed image data of the picture file through the picture header information and frame header information analysis sub-module to obtain the picture header information and the frame header information of the picture file, and if it is determined that the picture file has transparency data according to the picture header information, first code stream data and second code stream data are obtained from a code stream data segment indicated by the frame header information; then, decoding the first code stream data according to a first video decoding mode to generate RGB data; then, decoding the second code stream data according to a second video decoding mode to generate transparency data; and finally, combining the RGB data and the transparency data to generate RGBA data, and outputting the RGBA data.
For a picture file with a dynamic format, firstly, the decoding module 7000 analyzes the compressed image data of the picture file through the picture header information and frame header information analysis sub-module to obtain the picture header information and the frame header information of the picture file, and determines the number of frames contained in the picture file; then, if the picture file has transparency data according to the picture header information, acquiring first code stream data and second code stream data from a code stream data segment indicated by the frame header information of each frame of picture, decoding the first code stream data corresponding to each frame of picture according to a first video decoding mode to generate RGB data, and decoding the second code stream data corresponding to each frame of picture according to a second video decoding mode to generate transparency data; and finally, combining the RGB data and the transparency data of each frame of image to generate RGBA data, and outputting the RGBA data of all frames contained in the compressed image data.
For the picture file processing system shown in fig. 22, for example, the encoding device 5001 may encode a picture file in a source format according to the encoding module shown in fig. 23 and generate compressed image data, transmit the encoded compressed image data to the decoding device 5002, and after receiving the compressed image data, the decoding device 5002 decodes the compressed image data according to the decoding module shown in fig. 24 to obtain RGBA data corresponding to the picture file. The picture file in the source format may include, but is not limited to, jpeg, png, gif, and the like.
Fig. 25 is a schematic structural diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 25, the terminal device includes an encoding module and a decoding module. In a possible scheme, the encoding module may be an encoding module having a function of implementing the encoding apparatus shown in fig. 1 to 8; accordingly, the decoding module may be a decoding module having a function of implementing the decoding apparatus shown in fig. 9 to 11. In a possible scheme, the encoding module may implement encoding according to the encoding module 6000 described in fig. 23, and the decoding module may implement decoding according to the decoding module 7000 shown in fig. 24. For a specific implementation process, reference may be made to specific descriptions of corresponding embodiments, which are not described herein again. Therefore, the picture files in the source formats such as jpeg, png, gif and the like can be encoded in one terminal device to form the picture file in the new format, the compression rate of the picture file can be improved by encoding in the video encoding mode, and in addition, the transparency data in the picture file is reserved while the video encoding mode is adopted by encoding the RGB data and the transparency data in the picture file respectively. The method and the device can also decode the picture file with the new format to obtain corresponding RGBA data, realize that RGB data and transparency data are obtained by adopting a video coding and decoding mode, and ensure the quality of the picture file.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention, and it is therefore to be understood that the invention is not limited by the scope of the appended claims.

Claims (10)

1. A picture file processing method is characterized by comprising the following steps:
decoding the first code stream data according to a first video decoding mode to generate RGB data of a first image;
decoding second code stream data according to a second video decoding mode to generate transparency data of the first image;
and generating RGBA data corresponding to the first image according to the RGB data and the transparency data of the first image.
2. The method of claim 1, further comprising:
if the picture file is in a dynamic format and the first image is an image corresponding to a kth frame in the picture file in the dynamic format, acquiring third code stream data and fourth code stream data generated by a second image corresponding to a (k +1) th frame in the picture file from a code stream data segment of the picture file;
decoding the third code stream data according to a third video decoding mode to generate RGB data of the second image;
decoding the fourth code stream data according to a fourth video decoding mode to generate transparency data of the second image;
and generating RGBA data corresponding to the second image according to the RGB data and the transparency data of the second image.
3. The method according to claim 1 or 2, wherein before decoding the first bitstream data according to the first video decoding mode to generate the RGB data of the first image, the method further comprises:
analyzing a picture file to obtain picture header information and frame header information of the picture file, wherein the picture header information comprises image characteristic information of whether the picture file has transparency data, and the frame header information is used for indicating a code stream data segment of the picture file.
4. The method of claim 3, wherein parsing the picture file to obtain the picture header information of the picture file comprises:
reading the picture header information of the picture file from the picture header information data segment of the picture file;
the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
5. The method of claim 4, wherein the image characteristic information further comprises the image characteristic information start code, the image characteristic information data segment length, whether the picture file is a still format picture file, whether the picture file is a dynamic format picture file, whether the picture file is lossless coding, a YUV color space value range adopted by the picture file, a width of the picture file, a height of the picture file, and a frame number used for indicating the picture file if the picture file is a dynamic format picture file.
6. The method according to claim 3, wherein the parsing the picture file to obtain the header information of the picture file comprises:
reading frame header information of the picture file from a frame header information data section of the picture file;
the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
7. A picture file processing method is characterized by comprising the following steps:
analyzing a picture file to obtain picture header information and frame header information of the picture file, wherein the picture header information comprises image characteristic information of whether transparency data exist in the picture file, and the frame header information is used for indicating a code stream data section of the picture file, and the picture file comprises a picture header information data section, a frame header information data section and a code stream data section.
8. The method of claim 7, wherein parsing the picture file to obtain the picture header information of the picture file comprises:
reading the picture header information of the picture file from the picture header information data segment of the picture file;
the picture header information includes an image file identifier, a decoder identifier, a version number, and the image feature information; the image file identifier is used for representing the type of the picture file, and the decoder identifier is used for representing the identification of the coding and decoding standard adopted by the picture file; the version number is used for representing the grade of the coding and decoding standard adopted by the picture file.
9. The method of claim 8, wherein the image characteristic information further comprises the image characteristic information start code, the image characteristic information data segment length, whether the picture file is a still format picture file, whether the picture file is a dynamic format picture file, whether the picture file is lossless coding, a YUV color space value range adopted by the picture file, a width of the picture file, a height of the picture file, and a frame number used for indicating the picture file if the picture file is a dynamic format picture file.
10. The method according to any one of claims 7 to 9, wherein the parsing the picture file to obtain the header information of the picture file comprises:
reading frame header information of the picture file from a frame header information data section of the picture file;
the frame header information comprises a frame header information start code and delay time information used for indicating the picture file with the dynamic format if the picture file is the dynamic format.
CN201811273801.XA 2017-04-08 2017-04-08 Picture file processing method Active CN109040789B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811273801.XA CN109040789B (en) 2017-04-08 2017-04-08 Picture file processing method

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811273801.XA CN109040789B (en) 2017-04-08 2017-04-08 Picture file processing method
CN201710225913.7A CN107071516B (en) 2017-04-08 2017-04-08 A kind of photograph document handling method

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN201710225913.7A Division CN107071516B (en) 2017-04-08 2017-04-08 A kind of photograph document handling method

Publications (2)

Publication Number Publication Date
CN109040789A true CN109040789A (en) 2018-12-18
CN109040789B CN109040789B (en) 2021-05-28

Family

ID=59602473

Family Applications (2)

Application Number Title Priority Date Filing Date
CN201710225913.7A Active CN107071516B (en) 2017-04-08 2017-04-08 A kind of photograph document handling method
CN201811273801.XA Active CN109040789B (en) 2017-04-08 2017-04-08 Picture file processing method

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN201710225913.7A Active CN107071516B (en) 2017-04-08 2017-04-08 A kind of photograph document handling method

Country Status (3)

Country Link
CN (2) CN107071516B (en)
TW (1) TWI672939B (en)
WO (1) WO2018184464A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111885385A (en) * 2019-05-02 2020-11-03 西克Ivp股份公司 Pixel value encoding method and encoder for realizing lossless compression of digital image

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107071516B (en) * 2017-04-08 2018-12-21 腾讯科技(深圳)有限公司 A kind of photograph document handling method
CN108322722B (en) * 2018-01-24 2020-01-21 阿里巴巴集团控股有限公司 Image processing method and device based on augmented reality and electronic equipment
CN109309868B (en) * 2018-08-19 2019-06-18 上海极链网络科技有限公司 Video file Command Line Parsing system
CN112070867A (en) * 2019-06-11 2020-12-11 腾讯科技(深圳)有限公司 Animation file processing method and device, computer readable storage medium and computer equipment
WO2021237569A1 (en) * 2020-05-28 2021-12-02 深圳市大疆创新科技有限公司 Encoding method, decoding method, apparatus and system
EP4231640A1 (en) * 2022-02-16 2023-08-23 Beijing Xiaomi Mobile Software Co., Ltd. Encoding/decoding video picture data
WO2023210594A1 (en) * 2022-04-27 2023-11-02 ヌヴォトンテクノロジージャパン株式会社 Image encoding device and image encoding method

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101742317A (en) * 2009-12-31 2010-06-16 北京中科大洋科技发展股份有限公司 Video compressing and encoding method with alpha transparent channel
CN102036059A (en) * 2009-09-25 2011-04-27 腾讯科技(深圳)有限公司 Method, device and system for compressing and decompressing transparent images
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
CN102724582A (en) * 2012-05-31 2012-10-10 福州瑞芯微电子有限公司 Method for displaying color key based on user interface
CN102724471A (en) * 2012-06-11 2012-10-10 宇龙计算机通信科技(深圳)有限公司 Picture and video converting method and device
US8655086B1 (en) * 2011-11-01 2014-02-18 Zynga, Inc. Image compression with alpha channel data
US8681170B2 (en) * 2011-05-05 2014-03-25 Ati Technologies Ulc Apparatus and method for multi-streaming for more than three pixel component values
CN104333762A (en) * 2014-11-24 2015-02-04 成都瑞博慧窗信息技术有限公司 Video decoding method
CN104980798A (en) * 2015-07-14 2015-10-14 天脉聚源(北京)教育科技有限公司 Remote video display method and device
KR20160026005A (en) * 2014-08-29 2016-03-09 (주) 디아이지 커뮤니케이션 Apparatus and method for compressing autmented-reality video having alpha channel
CN106375759A (en) * 2016-08-31 2017-02-01 深圳超多维科技有限公司 Video image data coding method and device, and video image data decoding method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101540901B (en) * 2008-03-20 2011-04-06 华为技术有限公司 Method and device for coding/decoding
US20150074735A1 (en) * 2013-09-06 2015-03-12 Seespace Ltd. Method and Apparatus for Rendering Video Content Including Secondary Digital Content
CN107071516B (en) * 2017-04-08 2018-12-21 腾讯科技(深圳)有限公司 A kind of photograph document handling method

Patent Citations (11)

* Cited by examiner, † Cited by third party
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
CN102036059A (en) * 2009-09-25 2011-04-27 腾讯科技(深圳)有限公司 Method, device and system for compressing and decompressing transparent images
CN101742317A (en) * 2009-12-31 2010-06-16 北京中科大洋科技发展股份有限公司 Video compressing and encoding method with alpha transparent channel
US8681170B2 (en) * 2011-05-05 2014-03-25 Ati Technologies Ulc Apparatus and method for multi-streaming for more than three pixel component values
US8655086B1 (en) * 2011-11-01 2014-02-18 Zynga, Inc. Image compression with alpha channel data
CN102724582A (en) * 2012-05-31 2012-10-10 福州瑞芯微电子有限公司 Method for displaying color key based on user interface
CN102724471A (en) * 2012-06-11 2012-10-10 宇龙计算机通信科技(深圳)有限公司 Picture and video converting method and device
KR20160026005A (en) * 2014-08-29 2016-03-09 (주) 디아이지 커뮤니케이션 Apparatus and method for compressing autmented-reality video having alpha channel
CN104333762A (en) * 2014-11-24 2015-02-04 成都瑞博慧窗信息技术有限公司 Video decoding method
CN104980798A (en) * 2015-07-14 2015-10-14 天脉聚源(北京)教育科技有限公司 Remote video display method and device
CN106375759A (en) * 2016-08-31 2017-02-01 深圳超多维科技有限公司 Video image data coding method and device, and video image data decoding method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李紫阳: "基于Android平台的视频客户端的设计与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111885385A (en) * 2019-05-02 2020-11-03 西克Ivp股份公司 Pixel value encoding method and encoder for realizing lossless compression of digital image
CN111885385B (en) * 2019-05-02 2023-11-28 西克Ivp股份公司 Method and encoder for encoding pixel values for achieving lossless compression of digital images

Also Published As

Publication number Publication date
TWI672939B (en) 2019-09-21
CN107071516A (en) 2017-08-18
CN107071516B (en) 2018-12-21
WO2018184464A1 (en) 2018-10-11
TW201838409A (en) 2018-10-16
CN109040789B (en) 2021-05-28

Similar Documents

Publication Publication Date Title
CN106937132B (en) A kind of photograph document handling method
CN107071515B (en) A kind of photograph document handling method and system
CN107071516B (en) A kind of photograph document handling method
US11012489B2 (en) Picture file processing method, picture file processing device, and storage medium
JP7053722B2 (en) A method and apparatus for signaling a picture / video format of an LDR picture within a bitstream and a picture / video format of a decoded HDR picture obtained from this LDR picture and an illumination picture.
CN112929590B (en) Boot animation playing system, compression method and device, and decompression method and device
US20240323544A1 (en) Image capture method, image display method, and apparatus
CN114079823A (en) Video rendering method, device, equipment and medium based on Flutter
TWI835238B (en) Image processing method and image processing device
CN118214872A (en) Ultra-high definition lossless image coding and decoding method and system
CN118283271A (en) Image encoding/decoding device, method and storage medium
CN117560498A (en) Image processing method and image processing apparatus
CN118660167A (en) Image decoding method, device, electronic equipment and readable storage medium

Legal Events

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