CN108154539A - A kind of colorspace data converting algorithm based on Opengl ES - Google Patents

A kind of colorspace data converting algorithm based on Opengl ES Download PDF

Info

Publication number
CN108154539A
CN108154539A CN201711362472.1A CN201711362472A CN108154539A CN 108154539 A CN108154539 A CN 108154539A CN 201711362472 A CN201711362472 A CN 201711362472A CN 108154539 A CN108154539 A CN 108154539A
Authority
CN
China
Prior art keywords
opengl
colorspace
texture
shader
data
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.)
Pending
Application number
CN201711362472.1A
Other languages
Chinese (zh)
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.)
Beijing Kuwo Technology Co Ltd
Original Assignee
Beijing Kuwo Technology 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 Beijing Kuwo Technology Co Ltd filed Critical Beijing Kuwo Technology Co Ltd
Priority to CN201711362472.1A priority Critical patent/CN108154539A/en
Publication of CN108154539A publication Critical patent/CN108154539A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/20Processor architectures; Processor configuration, e.g. pipelining

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Processing (AREA)
  • Image Generation (AREA)

Abstract

The present invention relates to a kind of colorspace data converting algorithms based on Opengl ES, include the following steps:Tinter shader is write using Opengl shading languages GLSL so that a tinter shader is run on parallel on multiple cores of GPU, improves the speed of colorspace data conversion;It needs to create two kinds of tinters in Opengl ES:Vertex shader vertex shaders and fragment shader fragment shaders.The present invention handles data using GPU, and completing YUV colorspace datas based on Opengl ES is converted into RGBA color spatial data, can increase substantially transformation efficiency, support 1080P(1920x1080)The requirement per second of 30 frame picture of video.

Description

A kind of colorspace data converting algorithm based on Opengl ES
Technical field
The present invention relates to colorspace data transformation technology field, specifically a kind of color based on Opengl ES is empty Between data converting algorithm.
Background technology
Existing mobile hand-held device, in addition to central processing unit(CPU)Except performance is continuously improved, also match accordingly mostly For the graphics processor of profession(GPU).
Graphics processor(GPU)And central processing unit(CPU)It compares:CPU need very strong versatility handle it is various not Same data type, while have logic judgment again, the processing that a large amount of branch redirects and interrupts can be therefore introduced, these all cause The internal structure complex of CPU.And GPU is faced be then type high unity, the large-scale data mutually without dependence and The pure computing environment being interrupted is not needed to.
It is suitble to the program of operation on GPU:
(1)The program of computation-intensive.So-called computation-intensive(Compute-intensive)Program, be exactly its major part For run time flower on Register operations, the speed of register and the speed of processor are suitable, several from register read-write data It is not delayed.
(2)It is easy to parallel program.GPU is a kind of SIMD frameworks in fact(Single Instruction Multiple Data), it has hundreds and thousands of a cores, each core can do same thing in the same time.
When being converted into RGBA color spatial data with CPU completion YUV colorspace datas, because of CPU register numbers It is not very much, it is difficult to realize highly-parallel, algorithm(As C++ is realized)Performance is low, it is impossible to meet high definition(Such as 1080P)The reality of video When show.
Invention content
For defect in the prior art, the purpose of the present invention is to provide a kind of colors based on Opengl ES Spatial data converting algorithm handles data using GPU, and completing YUV colorspace datas based on Opengl ES is converted into RGBA face Colour space data can increase substantially transformation efficiency, support 1080P(1920x1080)The requirement per second of 30 frame picture of video.
To achieve the above objectives, the technical solution adopted by the present invention is that:
A kind of colorspace data converting algorithm based on Opengl ES, which is characterized in that include the following steps:
Tinter shader is write using Opengl shading languages GLSL so that a tinter shader runs on GPU parallel Multiple cores on, improve colorspace data conversion speed;
It needs to create two kinds of tinters in Opengl ES:Vertex shader vertex shaders and fragment shader fragment shaders。
Based on the above technical solution, the colorspace data conversion refers to YUV colorspace datas and is converted into RGBA color spatial data.
Based on the above technical solution, the data that the YUV colorspace datas are captured from camera,
Specific form is NV21 forms.
Based on the above technical solution, it is empty to complete YUV colors using following conversion formula by the tinter shader Between data be converted into RGBA color spatial data:
R = Y + 1.13983 *(V - 128)
G = Y - 0.39465 *(V - 128)- 0.58060 * (V - 128)
B = Y + 2.03211 * (U -128).
Based on the above technical solution, the fragment shader, image sampling is used using 256 as maximum It is worth normalized floating number,
YUV conversions RGB uses the floating number between 0.0 to 1.0 to be represented with matrix.
Based on the above technical solution, the fragment shader,
The principal function interface main called automatically by system is provided,
Texture sample coordinates vTextureCoord is set,
It sets and precision is given tacit consent in vertex shader as precision highp float,
Y texture cell texture are set,
VU texture cell texture2 are set,
Texture texture cells are uploaded to using the grayscale format LUMINANCE of Opengl ES to single pass Y images,
Transparency form LUMINANCE_ALPHA is added to upload to using the gray scale of Opengl ES twin-channel VU images Texture2 texture cells,
By texture sample coordinates vTextureCoord, texture texture cells and texture2 texture cells are adopted respectively Sample obtains two 4 dimensions color vector vec41 and vec42,
4 dimension color vector vec41, the r dimension vec41.r is y pixels,
4 dimension color vector vec42, the r and a dimension vec42.ra is vu pixels,
One y pixel and a vu pixel are formed into three-dimensional color vector v ec3 (vec41.r, vec42.ra),
According to conversion formula, three-dimensional color vector v ec3 is multiplied by transformed matrix mat3 and just obtains a rgb pixels output display.
Colorspace data converting algorithm of the present invention based on Opengl ES handles data using GPU, is based on Opengl ES complete YUV colorspace datas and are converted into RGBA color spatial data, can increase substantially transformation efficiency, support 1080P(1920x1080)The requirement per second of 30 frame picture of video.With the algorithm method of wide high progress dual ring calculation to image of CPU It compares, substantially increases efficiency of algorithm.
Specific embodiment
Colorspace data converting algorithm of the present invention based on Opengl ES, includes the following steps:
Using Opengl shading languages GLSL(Opengl Shader Language)Write tinter shader so that one Color device shader is run on parallel on multiple cores of GPU, improves the speed of colorspace data conversion.
Opengl ES(Opengl for Embedded Systems)It is the subset of Opengl 3-D graphic API, for The embedded devices such as mobile phone, PDA and game host and design.The API defines popularization by Khronos groups, and Khronos is one Figure software and hardware employer's organization, the association are primarily upon the open standard in terms of figure and multimedia.
Tinter(shader)It is that small, the program based on C language is write with shading language.It is needed in Opengl ES Create two kinds of tinters:Vertex shader(vertex shaders)And fragment shader(fragment shaders).This two Kind tinter is the two halves of a complete routine, it is impossible to only create any of which one;Want to create a complete coloring journey Sequence is both necessarily present.Vertex shader defines how the geometric figure in 2D 3D scenes is handled.One Vertex refers to a point in 2D or 3d space.In image procossing, there are 4 vertex:Each vertex representative image One angle.Vertex shader sets the position on vertex, and parameter as position and texture coordinate is sent to fragment shading Device.It is calculated in each of object or picture pixel using fragment shader, finally calculates each pixel most Whole color.
Based on the above technical solution, the colorspace data conversion refers to YUV colorspace datas and is converted into RGBA color spatial data.
" Y " represents brightness in YUV(Luminance or Luma), that is, grayscale value;And what " U " and " V " was represented is then Coloration(Chrominance or Chroma), effect is description colors of image and saturation degree, for the color of specified pixel.I.e.:It is bright Spend signal Y, colour difference signal B-Y(That is U), R-Y(That is V).
RGBA represents Red(It is red)、Green(Green)、Blue(Blue)It is that is, transparent with the color space of Alpha Degree/opacity.
Based on the above technical solution, the data that the YUV colorspace datas are captured from camera.
Its specific form can be NV21 forms.NV21 is before V after U.Also referred to as YUV420 frame informations or cry The quantity ratio of tri- components of YCbCr_420_SP, Y, U, V is 4:1:1, that is to say, that every four pixels share a pair of of UV.
The camera is mobile phone camera.
Based on the above technical solution, it is empty to complete YUV colors using following conversion formula by the tinter shader Between data be converted into RGBA color spatial data:
R = Y + 1.13983 *(V - 128)
G = Y - 0.39465 *(V - 128)- 0.58060 * (V - 128)
B = Y + 2.03211 * (U -128).
Based on the above technical solution, the fragment shader, also known as piece member tinter(Fragment Shader), image sampling is used using 256 as the normalized floating number of maximum value,
YUV conversions RGB uses the floating number between 0.0 to 1.0 to represent as follows with matrix:
= *
I.e.:Using the floating-point matrix of 3*3, i.e. transformed matrix,
mat3(1, -0.00093,1.401687,
1, -0.3437, -0.71417,
1,1.77216,0.00099).
Based on the above technical solution, the fragment shader,
The principal function interface main called automatically by system is provided,
Texture sample coordinates vTextureCoord is set,
It sets and precision is given tacit consent in vertex shader as precision highp float,
Y texture cell texture are set,
VU texture cell texture2 are set,
Texture texture cells are uploaded to using the grayscale format LUMINANCE of Opengl ES to single pass Y images,
Transparency form LUMINANCE_ALPHA is added to upload to using the gray scale of Opengl ES twin-channel VU images Texture2 texture cells,
By texture sample coordinates vTextureCoord, texture texture cells and texture2 texture cells are adopted respectively Sample obtains two 4 dimensions color vector vec41 and vec42,
4 dimension color vector vec41, the r dimension vec41.r is y pixels,
4 dimension color vector vec42, the r and a dimension vec42.ra is vu pixels,
One y pixel and a vu pixel are formed into three-dimensional color vector v ec3 (vec41.r, vec42.ra),
According to conversion formula, three-dimensional color vector v ec3 is multiplied by transformed matrix mat3 and just obtains a rgb pixels output display.
The content not being described in detail in this specification belongs to the prior art well known to professional and technical personnel in the field.

Claims (6)

1. a kind of colorspace data converting algorithm based on Opengl ES, which is characterized in that include the following steps:
Tinter shader is write using Opengl shading languages GLSL so that a tinter shader runs on GPU parallel Multiple cores on, improve colorspace data conversion speed;
It needs to create two kinds of tinters in Opengl ES:Vertex shader vertex shaders and fragment shader fragment shaders。
2. the colorspace data converting algorithm based on Opengl ES as described in claim 1, it is characterised in that:The face The conversion of colour space data refers to YUV colorspace datas and is converted into RGBA color spatial data.
3. the colorspace data converting algorithm based on Opengl ES as claimed in claim 2, it is characterised in that:The YUV The data that colorspace data is captured from camera,
Specific form is NV21 forms.
4. the colorspace data converting algorithm based on Opengl ES as claimed in claim 3, it is characterised in that:Described Color device shader completes YUV colorspace datas using following conversion formula and is converted into RGBA color spatial data:
R = Y + 1.13983 *(V - 128)
G = Y - 0.39465 *(V - 128)- 0.58060 * (V - 128)
B = Y + 2.03211 * (U -128).
5. the colorspace data converting algorithm based on Opengl ES as claimed in claim 3, it is characterised in that:Described Section tinter uses image sampling using 256 as the normalized floating number of maximum value,
YUV conversions RGB uses the floating number between 0.0 to 1.0 to be represented with matrix.
6. the colorspace data converting algorithm based on Opengl ES as claimed in claim 5, it is characterised in that:Described Section tinter,
The principal function interface main called automatically by system is provided,
Texture sample coordinates vTextureCoord is set,
It sets and precision is given tacit consent in vertex shader as precision highp float,
Y texture cell texture are set,
VU texture cell texture2 are set,
Texture texture cells are uploaded to using the grayscale format LUMINANCE of Opengl ES to single pass Y images,
Transparency form LUMINANCE_ALPHA is added to upload to using the gray scale of Opengl ES twin-channel VU images Texture2 texture cells,
By texture sample coordinates vTextureCoord, texture texture cells and texture2 texture cells are adopted respectively Sample obtains two 4 dimensions color vector vec41 and vec42,
4 dimension color vector vec41, the r dimension vec41.r is y pixels,
4 dimension color vector vec42, the r and a dimension vec42.ra is vu pixels,
One y pixel and a vu pixel are formed into three-dimensional color vector v ec3 (vec41.r, vec42.ra),
According to conversion formula, three-dimensional color vector v ec3 is multiplied by transformed matrix mat3 and just obtains a rgb pixels output display.
CN201711362472.1A 2017-12-18 2017-12-18 A kind of colorspace data converting algorithm based on Opengl ES Pending CN108154539A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711362472.1A CN108154539A (en) 2017-12-18 2017-12-18 A kind of colorspace data converting algorithm based on Opengl ES

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711362472.1A CN108154539A (en) 2017-12-18 2017-12-18 A kind of colorspace data converting algorithm based on Opengl ES

Publications (1)

Publication Number Publication Date
CN108154539A true CN108154539A (en) 2018-06-12

Family

ID=62467429

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711362472.1A Pending CN108154539A (en) 2017-12-18 2017-12-18 A kind of colorspace data converting algorithm based on Opengl ES

Country Status (1)

Country Link
CN (1) CN108154539A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109358852A (en) * 2018-08-31 2019-02-19 惠州市德赛西威汽车电子股份有限公司 A method of realizing that vehicle-mounted GUI changes skin using shader
CN111093096A (en) * 2019-12-25 2020-05-01 广州酷狗计算机科技有限公司 Video encoding method and apparatus, and storage medium
CN111813380A (en) * 2019-04-29 2020-10-23 厦门雅基软件有限公司 Coloring data processing method and device based on game engine and electronic equipment
CN113096233A (en) * 2021-06-11 2021-07-09 腾讯科技(深圳)有限公司 Image processing method and device, electronic equipment and readable storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101867833A (en) * 2010-06-12 2010-10-20 北京东方艾迪普科技发展有限公司 Method and device for converting video image format
CN106331532A (en) * 2016-08-26 2017-01-11 北京金山安全软件有限公司 Data conversion method and device and electronic equipment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101867833A (en) * 2010-06-12 2010-10-20 北京东方艾迪普科技发展有限公司 Method and device for converting video image format
CN106331532A (en) * 2016-08-26 2017-01-11 北京金山安全软件有限公司 Data conversion method and device and electronic equipment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
MYDDDFLY: "《Android平台Camera实时滤镜实现方法探讨(三)--通过Shader实现YUV转换RBG》", 《HTTPS://WWW.CNBLOGS.COM/JUKAN/P/6994048.HTML》 *
思考的轨迹: "《用Shader实现的YUV到RGB转换》", 《HTTP://WWW.360DOC.COM/CONTENT/11/1008/17/1016783_154377024.SHTML》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109358852A (en) * 2018-08-31 2019-02-19 惠州市德赛西威汽车电子股份有限公司 A method of realizing that vehicle-mounted GUI changes skin using shader
CN109358852B (en) * 2018-08-31 2021-08-20 惠州市德赛西威汽车电子股份有限公司 Method for realizing skin changing of vehicle-mounted GUI (graphical user interface) by using shader
CN111813380A (en) * 2019-04-29 2020-10-23 厦门雅基软件有限公司 Coloring data processing method and device based on game engine and electronic equipment
CN111813380B (en) * 2019-04-29 2022-11-08 厦门雅基软件有限公司 Coloring data processing method and device based on game engine and electronic equipment
CN111093096A (en) * 2019-12-25 2020-05-01 广州酷狗计算机科技有限公司 Video encoding method and apparatus, and storage medium
CN113096233A (en) * 2021-06-11 2021-07-09 腾讯科技(深圳)有限公司 Image processing method and device, electronic equipment and readable storage medium
CN113096233B (en) * 2021-06-11 2021-08-27 腾讯科技(深圳)有限公司 Image processing method and device, electronic equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN108154539A (en) A kind of colorspace data converting algorithm based on Opengl ES
US9508185B2 (en) Texturing in graphics hardware
US10134360B2 (en) Compressing the size of color lookup tables
US10636336B2 (en) Mixed primary display with spatially modulated backlight
CN106210883A (en) A kind of method of Video Rendering, equipment
CN110291563A (en) Multiple tinter processes in graphics process
CN109358852B (en) Method for realizing skin changing of vehicle-mounted GUI (graphical user interface) by using shader
CN106228581B (en) Pixel format is converted to the method and system of NV12 by GPU by ARGB
CN110349225B (en) BIM model external contour rapid extraction method
US9224227B2 (en) Tile shader for screen space, a method of rendering and a graphics processing unit employing the tile shader
WO2019119791A1 (en) Driving method and driving apparatus for display apparatus
WO2019144744A1 (en) Augmented reality-based image processing method and apparatus, and electronic device
CN107465939B (en) Method and device for processing video image data stream
CN101227621A (en) Method of performing interpolation for CFA in CMOS sensor and circuit thereof
CN105488769B (en) A kind of real-time video defogging method
US20180097527A1 (en) 32-bit hdr pixel format with optimum precision
CN109658488B (en) Method for accelerating decoding of camera video stream through programmable GPU in virtual-real fusion system
US11039153B2 (en) Efficient processing of translucent objects in video keying
CN104318509B (en) A kind of high-volume targeted cache drawing method based on GPU
US20150103252A1 (en) System, method, and computer program product for gamma correction in a video or image processing engine
WO2021184931A1 (en) Color contrast enhancement drawing method, apparatus and system applicable to optical see-through head-mounted display
US20150054843A1 (en) Color-correct alpha blending texture filter and method of use thereof
WO2023051590A1 (en) Render format selection method and device related thereto
CN106408617A (en) Interactive single image material acquiring system based on YUV color space and method
US20090184977A1 (en) Multi-format support for surface creation in a graphics processing system

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20180612