Invention content
In consideration of it, it is necessary to provide a kind of Alpha channel transmission methods, Alpha channel transfers device, terminal installation and meters
Calculation machine readable storage medium storing program for executing can optimize the operation of Alpha channel transfers, promote user experience.
On the one hand the embodiment of the present invention provides a kind of Alpha channel transmission methods, the Alpha channel transmission methods packet
It includes:
The RGBA data of each pixel of image are converted to the first YUVA data of each pixel of image;
By the data in the form of the coding form of YUV422 coding YUV420, the 2nd YUVA data are obtained;
After the 2nd YUVA data are transferred to receiving terminal, the 2nd YUVA data are converted into RGBA forms
Data.
Further, in above-mentioned Alpha channel transmission methods provided in an embodiment of the present invention, each pixel of described image
First YUVA data include the data and Alpha channel datas of YUV422 forms.
Further, in above-mentioned Alpha channel transmission methods provided in an embodiment of the present invention, the volume with YUV422
Code form coding YUV420 forms data include:
U, V, A value and Y value are set with preset rules;
The preset rules include:
One RGB color data one Y channel data of correspondence, four RGB color data sharings, one bis- channel data of UV,
Two RGB color data sharings, one Alpha channel data.
Further, in above-mentioned Alpha channel transmission methods provided in an embodiment of the present invention, setting U, V, A value
Including:
The two-dimensional position information of U, V are converted into one-dimensional position information;
Obtain the start position of U, V;
Obtain the component address information of U, V, A;
The value of U, V, A are set with predetermined manner.
Further, in above-mentioned Alpha channel transmission methods provided in an embodiment of the present invention, the predetermined manner packet
It includes:
Obtain the value of four pixels in mono- channel datas of Y;
Ratio of the sum of the value that U, V value are four pixels with 4 is set separately;
Set A values as the sum of value of two pixels with 2 ratio.
Further, described by described second in above-mentioned Alpha channel transmission methods provided in an embodiment of the present invention
The data that YUVA data are converted to RGBA forms include:
Obtain the component address information of Y, U, V, A;
According to the data information of described component address acquisition of information Y, U, V, A;
The data information of described Y, U, V, A are converted to the RGBA numbers of each pixel of described image according to the preset rules
According to.
Another further aspect of the embodiment of the present invention also provides a kind of Alpha channel transfers device, the Alpha channel transfers device
Including:
First conversion module, the first YUVA numbers for the RGBA data of each pixel of image to be converted to each pixel of image
According to;
Coding module obtains the 2nd YUVA numbers for the data in the form of the coding form of YUVA422 coding YUVA420
According to;
Second conversion module, for after the 2nd YUVA data are transferred to receiving terminal, by the 2nd YUVA numbers
According to the data for being converted to RGBA forms.
Further, in above-mentioned Alpha channel transfers device provided in an embodiment of the present invention, the coding module also wraps
It includes:
Setting module, for setting U, V, A value and Y value with preset rules;
The preset rules include:
One RGB color data one Y channel data of correspondence, four RGB color data sharings, one bis- channel data of UV,
Two RGB color data sharings, one Alpha channel data.
Another further aspect of the embodiment of the present invention also provides a kind of terminal installation, and the terminal installation includes processor, the place
Reason device is used to realize the Alpha channel transmission methods described in above-mentioned any one when executing the computer program stored in memory
The step of.
Another further aspect of the embodiment of the present invention also provides a kind of computer readable storage medium, is stored thereon with computer journey
The step of sequence, the computer program realizes the Alpha channel transmission methods described in above-mentioned any one when being executed by processor.
Alpha channel transmission methods, Alpha channel transfers device, terminal installation and meter provided in an embodiment of the present invention
The RGBA data of each pixel of image are converted to the first YUVA data of each pixel of image by calculation machine readable storage medium storing program for executing;With
The data of the coding form coding YUV420 forms of YUV422, obtain the 2nd YUVA data;It is passed by the 2nd YUVA data
After being defeated by receiving terminal, the 2nd YUVA data are converted to the data of RGBA forms.Using the embodiment of the present invention, can optimize
Alpha channel transfers operate, and save the flow bandwidth and carrying cost of the image with the channels Alpha to a certain extent,
Promote user experience.
Specific implementation mode
In order to be more clearly understood that the above objects, features, and advantages of the embodiment of the present invention, below in conjunction with the accompanying drawings and
The present invention will be described in detail for specific implementation mode.It should be noted that in the absence of conflict, the embodiment party of the application
Feature in formula can be combined with each other.
Many details are elaborated in the following description in order to fully understand the embodiment of the present invention, described reality
The mode of applying is some embodiments of the invention, rather than whole embodiments.Based on the embodiment in the present invention, ability
The every other embodiment that domain those of ordinary skill is obtained without making creative work, belongs to the present invention
The range of embodiment protection.
Unless otherwise defined, all of technologies and scientific terms used here by the article and the technology for belonging to the embodiment of the present invention
The normally understood meaning of technical staff in field is identical.Used term is intended merely in the description of the invention herein
The purpose of specific embodiment is described, it is not intended that in the limitation embodiment of the present invention.
Fig. 1 is the flow chart of Alpha channel transmission methods provided in an embodiment of the present invention.The channel transfer sides Alpha
Method can be applied to terminal, and the terminal can be such as smart mobile phone, laptop, desk-top/tablet computer, smartwatch
Equal smart machines.As shown in Figure 1, the Alpha channel transmission methods may include steps of:
S101:The RGBA data of each pixel of image are converted to the first YUVA data of each pixel of image.
In present embodiment, using video encoder (coding side) and Video Decoder (decoding end) come to including Alpha
The image in channel carries out coding and decoding operation.In video encoder, the channels Y, the channels U and the channels V, video are generally comprised
Encoder is completed to compress the coding of video frame based on these three channels.Wherein, Y channel datas indicate brightness namely grayscale value;
U, bis- channel datas of V indicate coloration, can be used for the color of specified pixel.For human eye, brightness is very sensitive, and coloration
Small change human eye is usually can not discover Chu Lai, thus chrominance information is compressible.Using coding side by each picture of image
Before the RGBA data of element are converted to the first YUVA data of each pixel of image, can data solution first be carried out to image to be encoded
Analysis, obtains RGBA data, the RGBA data include R (red), G (green), B (indigo plant), A (Alpha) four-way track data.Wherein,
RGB data is the color data of image, and the channels Alpha are one 8 gray channels, are typically used as opacity parameter.If
The numerical value in the channels Alpha of one pixel is 0, then it represents that the pixel is fully transparent;If the channels Alpha of a pixel
Numerical value be 1, then it represents that the pixel is fully opaque;If the numerical value in the channels Alpha of a pixel between 0 to 1,
Then indicate that the pixel is translucent.
In present embodiment, the RGBA data of each pixel of image are converted directly into each pixel of image using coding mode
First YUVA data of the first YUVA data, each pixel of described image include the data and Alpha port numbers of YUV422 forms
According to.Each two Y channel datas share a pair of bis- channel data of U, V in the data of the YUV422 forms.It is understood that institute
When stating RGB color data and being converted into yuv data, the Y channel datas obtained by RGB color data are one-to-one, for example, having
The information of 1920*1080 RGB triple channel just has 1920*1080 Y channel data.Bis- channel datas of UV be it is compressible,
The data of YUV422 forms are exactly two RGB color data sharings, one bis- channel data of UV, are as above exactly 960*540 U
One channel data, 960*540 mono- channel data of V.The data of YUV420 forms are exactly four RGB color data sharings, one UV
Two channel datas are as above exactly 480*270 mono- channel data of U, and 480*270 mono- channel data of V, Y channel datas are always
It is 1920*1080.
In one embodiment, the yuv data of the RGB color data of each pixel of image and each pixel of image may be used as
Change formula shown in lower:
Y=0.299R+0.587G+0.114B
U=-0.1687R-0.3313G+0.5B+128
V=0.5R-0.4187G-0.0813B+128
R=Y+1.402 (Cr-128)
G=Y-0.34414 (Cb-128) -0.71414 (Cr-128)
B=Y+1.772 (Cb-128)
S102:By the data in the form of the coding form of YUV422 coding YUV420, the 2nd YUVA data are obtained.
In present embodiment, the data in the form of the coding form of YUV422 coding YUV420 may include:With pre-
If rule settings Y value and U, V, A value.The preset rules include:One RGB color data one Y channel data of correspondence, four
One bis- channel data of UV of RGB color data sharing, two RGB color data sharings, one Alpha channel data.Wherein, if
The method for determining U, V, A value may include:The two-dimensional position information of U, V are first converted into one-dimensional position information;Obtain the starting point of U, V
Position;Obtain the component address information of U, V, A;The value of U, V, A are set with predetermined manner.The predetermined manner includes:It is logical to obtain Y
The value of four pixels in track data;Ratio of the sum of the value that U, V value are four pixels with 4 is set separately;Set A values as
The sum of value of two pixels with 2 ratio.Preferably, the position of four pixels may include:A selected point is made
For a pixel, then select one point the right/following/right lower position point as the other three pixel.It can be with
Understand, every four Y channel datas share a pair of bis- channel datas of UV, YUV422 forms in the data of the YUV420 forms
Data be exactly each two Y channel datas share bis- channel data of UV.The data of YUV422 forms and YUV420 forms
Data in data all without the position channels storage Alpha, and the data of YUV422 forms are compared with the data of YUV420 forms, it is more
Bis- channel datas of a pair of of UV are gone out.If encoding the data of YUV420 forms, additional a pair of UV with the coding form of YUV422
The position of two channel datas can be used to store Alpha channel datas namely each two Y channel datas share an Alpha and lead to
Track data.The 2nd YUVA data may include:The data of the YUV420 forms preserved in the form of YUV422 and the channels Alpha
Data.
S103:After the 2nd YUVA data are transferred to receiving terminal, the 2nd YUVA data are converted into RGBA
The data of form.
In present embodiment, after the 2nd YUVA data are transferred to receiving terminal, the receiving terminal control will be described
2nd YUVA data are converted to the data of RGBA forms.The data that the 2nd YUVA data are converted to RGBA forms can
To include:The component address information of Y, U, V, A in the 2nd YUVA data are obtained by Video Decoder (decoding end);Root
According to the data information of described component address acquisition of information Y, U, V, A;The data of described Y, U, V, A are believed according to the preset rules
Breath is converted to the RGBA data of each pixel of described image.The preset rules include:Y value is one-to-one deposit with RGB color data
, four RGB color data sharings, one bis- channel data of UV, two RGB color data sharings, one Alpha channel data.
The RGBA data of each pixel of image are converted to image by Alpha channel transmission methods provided in an embodiment of the present invention
First YUVA data of each pixel;By the data in the form of the coding form of YUV422 coding YUV420, the 2nd YUVA data are obtained;
After the 2nd YUVA data are transferred to receiving terminal, the 2nd YUVA data are converted to the data of RGBA forms.Profit
With the embodiment of the present invention, the operation of Alpha channel transfers can be optimized, save the image with the channels Alpha to a certain extent
Flow bandwidth and carrying cost, promoted user experience.
It is the detailed description for being provided for the embodiments of the invention method progress above.Stream shown according to different requirements,
The execution sequence of square can change in journey figure, and certain squares can be omitted.It is provided for the embodiments of the invention terminal below
It is described.
The embodiment of the present invention also provides a kind of terminal installation, including memory, processor and storage are on a memory and can
The computer program run on a processor, the processor are realized when executing described program described in any of the above-described embodiment
Alpha channel transmission methods the step of.
Fig. 2 is the structural schematic diagram of the terminal of an embodiment of the present invention.As shown in Fig. 2, terminal 1 includes memory 10,
Alpha channel transfers device 100 is stored in memory 10.The Alpha channel transfers device 100 can be by each pixel of image
RGBA data be converted to the first YUVA data of each pixel of image;By the number in the form of the coding form of YUV422 coding YUV420
According to obtaining the 2nd YUVA data;After the 2nd YUVA data are transferred to receiving terminal, by the 2nd YUVA data conversions
For the data of RGBA forms.Using the embodiment of the present invention, the operation of Alpha channel transfers can be optimized, saved to a certain extent
The flow bandwidth and carrying cost of image with the channels Alpha promote user experience.
In present embodiment, terminal 1 can also include display screen 20 and processor 30.Memory 10, display screen 20 can be with
It is electrically connected respectively with processor 30.
The memory 10 can be different type storage device, for storing Various types of data.For example, it may be terminal
1 memory, memory, can also be the storage card that can be external in the terminal 1, as flash memory, SM cards (Smart Media Card,
Smart media card), SD card (Secure Digital Card, safe digital card) etc..In addition, memory may include high speed with
Machine accesses memory, can also include nonvolatile memory, such as hard disk, memory, plug-in type hard disk, intelligent memory card
(Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card), at least
One disk memory, flush memory device or other volatile solid-state parts.Memory is for storing Various types of data, example
Such as, the types of applications program (Applications) installed in the terminal 1 is set using above-mentioned Alpha channel transmission methods
The information such as the data set, obtained.
Display screen 20 is installed on terminal 1, for showing information.
Processor 30 is used to execute all kinds of softwares installed in the Alpha channel transmission methods and the terminal 1, example
Such as operating system and application show software.Processor 30 is including but not limited to processor (Central Processing
Unit, CPU), micro-control unit (Micro Controller Unit, MCU) etc. is based on interpretive machine instructs and handles
The device of data in calculation machine software.
The Alpha channel transfers device 100 may include the module of one or more, one or more of modules
Be stored in the memory 10 of terminal 1 and be configured to by one or more processors (present embodiment be a processor
30) it executes, to complete the embodiment of the present invention.For example, as shown in fig.3, the Alpha channel transfers device 100 may include
First conversion module 11, coding module 12, the second conversion module 13;Wherein, the coding module 12 can also include setting mould
Block 121.The so-called module of the embodiment of the present invention can complete the program segment of a specific function, softer more suitable for describing than program
The implementation procedure of part in the processor.
It is understood that each embodiment in corresponding above-mentioned Alpha channel transmission methods, Alpha channel transfers dress
It may include part or all in each function module shown in Fig. 3 to set 100, and the function of each module will be situated between in detail below
It continues.It should be noted that identical noun related terms and its specific in each embodiment of the above Alpha channel transmission methods
Explanation be readily applicable to the following function introduction to each module.For the sake of saving space and avoiding repetition, herein
It repeats no more.
First conversion module 11 can be used for being converted to the RGBA data of each pixel of image the first of each pixel of image
YUVA data.
Coding module 12 can be used for the data in the form of the coding form of YUVA422 coding YUVA420, obtain second
YUVA data.
Second conversion module 13 can be used for after the 2nd YUVA data are transferred to receiving terminal, by described second
YUVA data are converted to the data of RGBA forms.
Setting module 121 can be used for setting module, for preset rules setting Y value and U, V, A value;The default rule
Include then:One RGB color data one Y channel data of correspondence, four RGB color data sharings, one bis- channel data of UV,
Two RGB color data sharings, one Alpha channel data.
The embodiment of the present invention also provides a kind of computer readable storage medium, is stored thereon with computer program, the meter
Calculation machine program realizes the step of Alpha channel transmission methods in any of the above-described embodiment when being executed by processor.
If the integrated module/unit of the Alpha channel transfers device/terminal/computer equipment is with software function list
The form of member is realized and when sold or used as an independent product, can be stored in a computer read/write memory medium
In.Based on this understanding, the present invention realizes all or part of flow in the above embodiment method, can also pass through calculating
Machine program is completed to instruct relevant hardware, and the computer program can be stored in a computer readable storage medium,
The computer program is when being executed by processor, it can be achieved that the step of above-mentioned each embodiment of the method.Wherein, the computer journey
Sequence includes computer program code, and the computer program code can be source code form, object identification code form, executable text
Part or certain intermediate forms etc..The computer readable storage medium may include:The computer program code can be carried
Any entity or device, recording medium, USB flash disk, mobile hard disk, magnetic disc, CD, computer storage, read-only memory (ROM,
Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunications letter
Number and software distribution medium etc..
Alleged processor can be central processing unit (Central Processing Unit, CPU), can also be it
His general processor, digital signal processor (Digital Signal Processor, DSP), application-specific integrated circuit
(Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-
Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic,
Discrete hardware components etc..General processor can be microprocessor or the processor can also be any conventional processor
Deng the processor is the control centre of the Alpha channel transfers device/terminal, whole using various interfaces and connection
The various pieces of a Alpha channel transfers device/terminal.
The memory for storing the computer program and/or module, by running or executing deposited by the processor
Computer program in the memory and/or module are stored up, and calls the data being stored in memory, described in realization
The various functions of Alpha channel transfers device/terminal.The memory can include mainly storing program area and storage data field,
Wherein, storing program area can storage program area, application program (such as sound-playing function, figure needed at least one function
As playing function etc.) etc.;Storage data field can be stored uses created data (such as audio data, phone according to mobile phone
This etc.) etc..In addition, memory may include high-speed random access memory, can also include nonvolatile memory, such as firmly
Disk, memory, plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital,
SD) block, flash card (Flash Card), at least one disk memory, flush memory device or other volatile solid-states
Part.
Referring to Fig. 4, Fig. 4 is the schematic diagram for the data for preserving YUV420 forms using YUV422 forms.YUV422 forms
Data in every 2 Y channel datas share bis- channel data of UV, every 4 Y channel datas are total in the data of YUV420 forms
With bis- channel data of UV, thus some information are had more using the data of the data of YUV422 forms ratio YUVA420 forms.
As shown in figure 4, Y indicates that Y channel datas, U, V indicate that U, V channel data, A indicate Alpha channel datas respectively.It can be seen that Y
Space size shared by channel data is that four times of space size shared by U, V channel data namely 4 Y channel datas are total to respectively
With bis- channel data of UV, the space size shared by Y channel datas is 2 times of space size shared by Alpha channel datas,
I.e. 2 Y channel datas share an Alpha channel data.It is more when preserving the data of YUV420 forms using YUV422 forms
The position for having gone out some information is just used to store the Alpha channel datas in RGBA data.Each two adjacent pixel coexist into
One Alpha channel data.The embodiment of the present invention is thus utilized, the operation of Alpha channel transfers can be optimized, and to a certain degree
The upper flow bandwidth and carrying cost for saving the image with the channels Alpha, promotes user experience.
Further, the embodiment of the present invention can use Computer Shader that this algorithm can be counted on GPU
It calculates, greatly improves operational efficiency.
Alpha channel transmission methods, Alpha channel transfers device, terminal installation and meter provided in an embodiment of the present invention
The RGBA data of each pixel of image are converted to the first YUVA data of each pixel of image by calculation machine readable storage medium storing program for executing;With
The data of the coding form coding YUV420 forms of YUV422, obtain the 2nd YUVA data;It is passed by the 2nd YUVA data
After being defeated by receiving terminal, the 2nd YUVA data are converted to the data of RGBA forms.Using the embodiment of the present invention, can optimize
Alpha channel transfers operate, and save the flow bandwidth and carrying cost of the image with the channels Alpha to a certain extent,
Promote user experience.
In several specific implementation modes provided by the present invention, it should be understood that disclosed terminal and method, it can be with
It realizes by another way.For example, system embodiment described above is only schematical, for example, the module
Division, only a kind of division of logic function, formula that in actual implementation, there may be another division manner.
It is obvious to a person skilled in the art that the embodiment of the present invention is not limited to the details of above-mentioned exemplary embodiment,
And without departing substantially from the spirit or essential attributes of the embodiment of the present invention, this hair can be realized in other specific forms
Bright embodiment.Therefore, in all respects, the present embodiments are to be considered as illustrative and not restrictive, this
The range of inventive embodiments is indicated by the appended claims rather than the foregoing description, it is intended that being equal in claim will be fallen
All changes in the meaning and scope of important document are included in the embodiment of the present invention.It should not be by any attached drawing mark in claim
Note, which is considered as, to be limited the claims involved.Multiple units, module or the device stated in system, device or terminal claim
It can also be realized by software or hardware by the same unit, module or device.
Embodiment of above is only to illustrate the technical solution of the embodiment of the present invention and unrestricted, although with reference to it is above preferably
The embodiment of the present invention is described in detail in embodiment, it will be understood by those of ordinary skill in the art that, it can be to this hair
The technical solution of bright embodiment is modified or equivalent replacement should not all be detached from the embodiment of the present invention technical solution spirit and
Range.