blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
โŒ€
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
โŒ€
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
โŒ€
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
11ee7c334c99893c878810b89233213d22b4e224
f03cc0f5dd196b1abe9464bf602b7859865df53c
/ๅญ—็ฌฆไธฒๅพช็Žฏ็งปไฝๅŒ…ๅซ.cpp
74d094477b6dffb885f946ba29512bbfb634b92e
[]
no_license
faradayin/jz
556881452557566b77f16cb4c2bd3b9670f64088
dce5ec8cd339169ad764867e0bdd2bcc34e0bb2c
refs/heads/master
2020-08-01T14:21:35.156140
2019-09-26T07:02:04
2019-09-26T07:02:04
211,013,185
0
0
null
null
null
null
UTF-8
C++
false
false
1,390
cpp
/* ็ป™ๅฎšไธคไธชๅญ—็ฌฆไธฒs1๏ผŒs2๏ผŒ่ฆๆฑ‚ๅˆคๅฎšs2ๆ˜ฏๅฆ่ƒฝๅคŸ่ขซs1ๅšๅพช็Žฏ็งปไฝๅพ—ๅˆฐ็š„ๅญ—็ฌฆไธฒๅŒ…ๅซใ€‚ */ //Cไปฃ็  #include <stdio.h> #include <string.h> int main() { char s1[] = "AABCDEF"; char s2[] = "CDEFA"; int len = strlen(s1); int i, j; char temp; for (i = 0; i < len; i++) { temp = s1[0]; for (j = 0; j < len - 1; j++) { s1[j] = s1[j + 1]; } s1[len - 1] = temp; if (strstr(s1, s2) != 0) { printf("TRUE\n"); return 0; } } printf("FALSE\n"); return 0; } //C++ไปฃ็  #include <iostream> using namespace std; bool find(char* src, char* dst) { int lens = 0, lend = 0; char* p2src = NULL; bool find = false; if ((NULL == src) || (NULL == dst)) return false; lens = strlen(src); lend = strlen(dst); if (lend > lens) return false; p2src = new char[lens*2+1]; memcpy(p2src, src, lens); memcpy(p2src+lens, src, lens); p2src[lens*2] = '\0'; if (NULL == strstr(p2src, dst)) { find = false; cout << dst << " Not exist in " << src << endl; } else { find = true; cout << dst << " exist in " << src << endl; } delete[] p2src; p2src = NULL; return find; } void main() { int i = 0; //char* str = "ABCDE"; //char* dst = "DEAB"; char* str = "ABCDEF"; char* dst = "DEAB"; find(str, dst); }
[ "yinfeng.v@gmail.com" ]
yinfeng.v@gmail.com
e158dc292706608db070e99bcea8a9c89aefa09f
62836532e3170e0f9d6be67ea546e8b462ebf80e
/Ambos-Pi/src/Order.hpp
bffc2cd4c36b5cc190742be239cfa229903a1194
[]
no_license
AMBOS-3D/Ambos-3D-Repo
38fb308fd2deb896eaaf454af4cec91be2c65902
3ce09fd457f01775e1ebbc10be02e60dc36fb624
refs/heads/master
2022-03-13T11:40:13.466321
2022-03-02T09:04:28
2022-03-02T09:04:28
129,708,095
0
0
null
null
null
null
UTF-8
C++
false
false
1,252
hpp
#pragma once #include <string> #include "Component.hpp" #include "Workplace.hpp" #include "Settings.hpp" #include "HandDetector.hpp" /** * @class Order * @brief Zentrales Objekt fรผr V1. Main-loop wird in processOrder gestartet. Fรผr die Verarbeitung wird ein FrameHandler Objekt verwendet */ class Order { // Funktionen public: // Konstruktor Order(std::string name, int nr, std::string client, int nrComponents, Workplace curWorkplace, Settings* newSettings); // Ablaufsteuerung int processOrder(HandDetector* model, bool soundsOn); // Ansteuerung des LED Strips // liest den aktuellen Zustand aus dem Order-Objekt und setzt passend die LEDs void setLEDs(); // Manuelles Reset per Knopfdruck ODER nach vollstรคndigem Prozess int orderReset(); // Initialisiere die Buttons void initGPIO(); // LED-Show wenn Auftrag/Packung fertig void orderFinishLED(); // Settings Settings settings; //Attribute public: // Order Attribute std::string m_name; int m_nr; std::string m_client; // Taster int pinred; // fรผr das Ausschalten int pingreen; // fรผr Reset // Komponenten und Workplace Objekt Component* m_compList; int m_nrComponents; Workplace m_curWorkplace; };
[ "christian.jauch@ipa.fraunhofer.de" ]
christian.jauch@ipa.fraunhofer.de
94ef55167e500305b711d270b32a67754b170844
45472ac0c43ebce4e1f85dd8aff69fb99a8c1307
/CG_Fase4/generator/figures.cpp
021bb34a6296c72af6481cd8c1e54ef5620bb7ad
[]
no_license
AdrianaMeireles80/CG
f1b1bd87087ad15cf76398caba9acc735aa0f801
d7322acd9724872e13572a776d1923eb114cfff6
refs/heads/master
2021-03-13T21:05:27.545327
2020-03-28T21:09:33
2020-03-28T21:09:33
246,712,430
1
0
null
null
null
null
UTF-8
C++
false
false
20,849
cpp
#define _USE_MATH_DEFINES #include "headers/figures.h" #include <math.h> using namespace std; float quadrants[8][3] = { { 1, 1, 1}, { 1, 1, -1}, {-1, 1, -1}, {-1, 1, 1}, { 1, -1, 1}, { 1, -1, -1}, {-1, -1, -1}, {-1, -1, 1}, }; float normals[6][3] = { {0,1,0}, {0,-1,0}, {0,0,1}, {0,0,-1}, {1,0,0}, {-1,0,0} }; float texturePlane[4][2] = { {1,0}, {1,1}, {0,1}, {0,0} }; vector<Point> plane(float size,vector<Point> *normal, vector<float> *texture){ Point pt; vector<Point> points; int face[6] = { 0, 1, 3, 3, 1, 2 }; for (int i = 0, j; i < 6; i++) { j = face[i]; pt.x = size * quadrants[j][0]; pt.y = 0; pt.z = size * quadrants[j][2]; points.push_back(pt); pt.x = 0; pt.y = 1; pt.z = 0; (*normal).push_back(pt); (*texture).push_back(texturePlane[j][0]); (*texture).push_back(texturePlane[j][1]); } return points; } Point drawPoints(float radius, float angle, float height) { Point p; p.x = radius * sin(angle); p.y = height; p.z = radius * cos(angle); return p; } Point drawNormalPoints(float angle, float teta) { Point p; p.x = cos(angle) * sin(teta); p.y = sin(angle); p.z = cos(angle) * cos(teta); return p; } // draw cone vector<Point> cone(float radius, float height, int slices, int layers, vector<Point> *normal, vector<float> *texture){ vector<Point> points; Point p0, p1, p2, p3; float teta, alpha, scaleHeigth, heigthNow, scaleRadius, radiusNow, radiusNext, tetaNext; alpha = (2 * M_PI) / slices; scaleHeigth = height / layers; scaleRadius = radius / layers; //draw base for (int i = 0; i < slices; i++) { teta = i * alpha; tetaNext = (i + 1) * alpha; p0.x = 0; p0.y = 0; p0.z = 0; p1 = drawPoints(radius, tetaNext, 0); p2 = drawPoints(radius, teta, 0); p3.x = 0; p3.y = -1; p3.z = 0; points.push_back(p0); points.push_back(p1); points.push_back(p2); //normal (*normal).push_back(p3); (*normal).push_back(p3); (*normal).push_back(p3); //texture (*texture).push_back(0.25f); (*texture).push_back(0.5f); (*texture).push_back(0.25f + cos(tetaNext) / 4.0f); (*texture).push_back(0.5f + sin(tetaNext) / 2.0f); (*texture).push_back(0.25f + cos(teta) / 4.0f); (*texture).push_back(0.5f + sin(teta) / 2.0f); } float angle = atan(radius / height); for (int i = 0; i < layers; i++) { heigthNow = i * scaleHeigth; radiusNow = radius - i * scaleRadius; radiusNext = radius - (1 + i) * scaleRadius; for (int j = 0; j < slices; j++) { teta = j * alpha; tetaNext = (j + 1) * alpha; p0 = drawPoints(radiusNow, teta, heigthNow); p1 = drawPoints(radiusNow, tetaNext, heigthNow); p2 = drawPoints(radiusNext, tetaNext, heigthNow + scaleHeigth); p3 = drawPoints(radiusNext, teta, heigthNow + scaleHeigth); //draw first triangle points.push_back(p0); points.push_back(p1); points.push_back(p2); //draw second triangle points.push_back(p0); points.push_back(p2); points.push_back(p3); //normal p0 = drawNormalPoints(angle,teta); p1 = drawNormalPoints(angle,tetaNext); (*normal).push_back(p0); (*normal).push_back(p1); (*normal).push_back(p1); (*normal).push_back(p0); (*normal).push_back(p1); (*normal).push_back(p0); //texture float res = (float) (layers - i) / layers; float resNext = (float) (layers - (i+1)) / layers; (*texture).push_back(0.75f + 0.25f * cos(teta) * res); (*texture).push_back(0.5f + 0.5f * sin(teta) * res); (*texture).push_back(0.75f + 0.25f * cos(tetaNext) * res); (*texture).push_back( 0.5f + 0.5f * sin(tetaNext) * res); (*texture).push_back(0.75f + 0.25f * cos(tetaNext) * resNext); (*texture).push_back( 0.5f + 0.5f * sin(tetaNext) * resNext); (*texture).push_back(0.75f + 0.25f * cos(teta) * res); (*texture).push_back( 0.5f + 0.5f * sin(teta) * res); (*texture).push_back(0.75f + 0.25f * cos(tetaNext) * resNext); (*texture).push_back( 0.5f + 0.5f * sin(tetaNext) * resNext); (*texture).push_back(0.75f + 0.25f * cos(teta) * resNext); (*texture).push_back( 0.5f + 0.5f * sin(teta) * resNext); } } return points; } void divide(float length, float width, float height, int divisions, vector<Point> pointsTriangle, vector<Point> *points, vector<float> *textureList, int face, int tipo) { Point p1 = pointsTriangle[0], p2 = pointsTriangle[1], p3 = pointsTriangle[2], newP1, newP2, newP3; float l, h, newl, newh,neww; newl = length / divisions; neww = width / divisions; newh = height / divisions; if (p1.y == p2.y && p2.y == p3.y) { if (p1.x >= p2.x) l = -newl; else l = newl; if (p1.z >= p3.z) h = -neww; else h = neww; p2.y = p3.y = p1.y; p2.x = p3.x = p1.x + l; p2.z = p1.z; p3.z = p2.z + h; } else if (p1.x == p2.x && p2.x == p3.x) { if (p1.z <= p2.z) l = neww; else l = -neww; if (p1.y >= p3.y) h = -newh; else h = newh; p2.x = p3.x = p1.x; p2.z = p3.z = p1.z + l; p2.y = p1.y; p3.y = p1.y + h; } else if (p1.z == p2.z && p2.z == p3.z) { if (p1.x < p2.x) l = newl; else l = -newl; if (p1.y < p3.y) h = newh; else h = -newh; p2.z = p3.z = p1.z; p2.x = p3.x = p1.x + l; p2.y = p1.y; p3.y = p2.y + h; } for (int i = 0; i < divisions; i++) { newP1 = p1, newP2 = p2, newP3 = p3; for (int j = 0; j < divisions; j++) { (*points).push_back(newP1); (*points).push_back(newP2); (*points).push_back(newP3); if(face == 5){ newP1.y += h; newP2.y += h; newP3.y += h; if (tipo == -1){ (*textureList).push_back(0.5f - i * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(0.5f - (i+1) * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(0.5f - (i+1) * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - (j+1) * 1.0f/3.0f / divisions); } else { (*textureList).push_back(0.25f + i * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + j * 1.0f/3.0f / divisions); (*textureList).push_back(0.25f + (i + 1) * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + j * 1.0f/3.0f / divisions); (*textureList).push_back(0.25f + (i + 1) * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + (j + 1) * 1.0f / 3.0f / divisions); } } else if(face == 4){ newP1.y += h; newP2.y += h; newP3.y += h; if (tipo == -1){ (*textureList).push_back(1.0f - i * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(1.0f - (i+1) * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(1.0f - (i+1) * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - (j+1) * 1.0f/3.0f / divisions); } else { (*textureList).push_back(0.75f + i * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + j * 1.0f/3.0f / divisions); (*textureList).push_back(0.75f + (i+1) * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + j * 1.0f/3.0f / divisions); (*textureList).push_back(0.75f + (i+1) * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + (j+1) * 1.0f/3.0f / divisions); } } else if(face == 2){ newP1.y += h; newP2.y += h; newP3.y += h; if (tipo == -1){ (*textureList).push_back(0.25f - i * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(0.25f - (i+1) * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(0.25f - (i+1) * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - (j+1) * 1.0f/3.0f / divisions); } else { (*textureList).push_back( i * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + j * 1.0f/3.0f / divisions); (*textureList).push_back( (i+1) * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + j * 1.0f/3.0f / divisions); (*textureList).push_back( (i+1) * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + (j+1) * 1.0f/3.0f / divisions); } } else if(face == 1){ newP1.y += h; newP2.y += h; newP3.y += h; if(tipo == -1){ (*textureList).push_back(0.75f - i * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(0.75f - (i+1) * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(0.75f - (i+1) * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f - (j+1) * 1.0f/3.0f / divisions); } else { (*textureList).push_back(0.50f + i * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + j * 1.0f/3.0f / divisions); (*textureList).push_back(0.50f + (i+1) * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + j * 1.0f/3.0f / divisions); (*textureList).push_back(0.50f + (i+1) * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f + (j+1) * 1.0f/3.0f / divisions); } } else if(face == 3){ newP1.z += h; newP2.z += h; newP3.z += h; if(tipo == -1){ (*textureList).push_back(0.50f - i * 0.25f / divisions); (*textureList).push_back(1.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(0.50f - (i+1) * 0.25f / divisions); (*textureList).push_back(1.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(0.50f - (i+1) * 0.25f / divisions); (*textureList).push_back(1.0f - (j+1) * 1.0f/3.0f / divisions); } else { (*textureList).push_back(0.25f + i * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f + j * 1.0f/3.0f / divisions); (*textureList).push_back(0.25f + (i+1) * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f + j * 1.0f/3.0f / divisions); (*textureList).push_back(0.25f + (i+1) * 0.25f / divisions); (*textureList).push_back(2.0f/3.0f + (j+1) * 1.0f/3.0f / divisions); } } else{ newP1.z += h; newP2.z += h; newP3.z += h; if(tipo == -1){ (*textureList).push_back(0.50f - i * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(0.50f - (i + 1) * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f - j * 1.0f/3.0f / divisions); (*textureList).push_back(0.50f - (i + 1) * 0.25f / divisions); (*textureList).push_back(1.0f/3.0f - (j + 1) * 1.0f/3.0f / divisions); } else { (*textureList).push_back(0.25f + i * 0.25f / divisions); (*textureList).push_back( j * 1.0f/3.0f / divisions); (*textureList).push_back(0.25f + (i + 1) * 0.25f / divisions); (*textureList).push_back( j * 1.0f/3.0f / divisions); (*textureList).push_back(0.25f + (i + 1) * 0.25f / divisions); (*textureList).push_back( (j + 1) * 1.0f/3.0f / divisions); } } } if(face == 1 || face == 2){ p1.z += l; p2.z += l; p3.z += l; } else { p1.x += l; p2.x += l; p3.x += l; } } } //draw box vector<Point> box(float length, float width, float height, int divisions, vector<Point> *normal, vector<float> *texture) { vector<Point> points; int tam = 36, face = 0; vector<Point> pointsTriangle(3); Point p; int tipo = -1; int faces[36] = { 4,7,6,6,5,4, 1,0,4,4,5,1, 3,2,6,6,7,3, 1,2,3,3,0,1, 2,1,5,5,6,2, 0,3,7,7,4,0, }; int norm[6] = {1,4,5,0,3,2}; for (int i = 0,j=0; i < tam; i++) { int f = faces[i]; p.x = length / 2 * quadrants[f][0]; p.y = height / 2 * quadrants[f][1]; p.z = width / 2 * quadrants[f][2]; pointsTriangle[j++] = p; if ((i+1)%3 == 0){ divide(length, width, height, divisions, pointsTriangle,&points,texture,face,tipo); j = 0; tipo *= -1; } if ((i+1)%6 == 0) face++; } int num = (int) points.size() / 6; for (int i = 0; i < 6; i++) { int n = norm[i]; p.x = normals[n][0]; p.y = normals[n][1]; p.z = normals[n][2]; for (int j = 0; j < num; j++) (*normal).push_back(p); } return points; } Point pointsSphere (float radius, float beta, float alpha) { Point result; result.x = radius * sin(alpha) * cos(beta); result.y = radius * sin(beta); result.z = radius * cos(beta) * cos(alpha); return result; } //draw sphere vector<Point> sphere(float radius, int slices, int layers, vector<Point> *normal, vector<float> *texture) { Point p1, p2, p3, p4; vector<Point> points; float alpha, nextAlpha, beta, nextBeta; for (int i = 0; i < layers; i++) { beta = i * (M_PI / layers) - M_PI_2; nextBeta = (i + 1) * (M_PI / layers) - M_PI_2; for (int j = 0; j < slices; j++) { alpha = j * 2 * M_PI / slices; nextAlpha = (j + 1) * 2 * M_PI / slices; p1 = pointsSphere(radius, nextBeta, alpha); p2 = pointsSphere(radius, beta, alpha); p3 = pointsSphere(radius, nextBeta, nextAlpha); p4 = pointsSphere(radius, beta, nextAlpha); // First triangle points.push_back(p1); points.push_back(p2); points.push_back(p3); // Second triangle points.push_back(p3); points.push_back(p2); points.push_back(p4); p1 = pointsSphere(1,nextBeta,alpha); p2 = pointsSphere(1,beta,alpha); p3 = pointsSphere(1,nextBeta,nextAlpha); p4 = pointsSphere(1,beta,nextAlpha); //normal (*normal).push_back(p1); (*normal).push_back(p2); (*normal).push_back(p3); (*normal).push_back(p3); (*normal).push_back(p2); (*normal).push_back(p4); //texture (*texture).push_back( (float) j/slices ); (*texture).push_back( (float)(i+1)/layers ); (*texture).push_back( (float) j/slices ); (*texture).push_back( (float) i/layers ); (*texture).push_back( (float)(j+1)/slices ); (*texture).push_back( (float)(i+1)/layers ); (*texture).push_back( (float)(j+1)/slices ); (*texture).push_back( (float)(i+1)/layers ); (*texture).push_back( (float) j/slices ); (*texture).push_back( (float) i/layers ); (*texture).push_back( (float)(j+1)/slices ); (*texture).push_back( (float) i/layers ); } } return points; } //draw cylinder vector<Point> cylinder(float radius, float height, int slices, int layers, vector<Point> *normal, vector<float> *texture){ vector<Point> points; Point p0, p1, p2, p3; float teta, alpha, scaleHeigth, heigthNow, tetaNext; alpha = (2 * M_PI) / slices; scaleHeigth = height / layers; //draw base for (int i = 0; i < slices; i++) { teta = i * alpha; tetaNext = (i + 1) * alpha; p0.x = 0; p0.y = 0; p0.z = 0; p3.x = 0; p3.y = -1; p3.z = 0; p1 = drawPoints(radius, tetaNext, 0); p2 = drawPoints(radius, teta, 0); points.push_back(p0); points.push_back(p1); points.push_back(p2); //normal (*normal).push_back(p3); (*normal).push_back(p3); (*normal).push_back(p3); //texture (*texture).push_back(0.8125f); (*texture).push_back(0.1875f); (*texture).push_back(0.8125f + 0.1875f * sin(teta + alpha)); (*texture).push_back(0.1875f + 0.1875f * cos(teta + alpha)); (*texture).push_back(0.8125f + 0.1875f * sin(teta)); (*texture).push_back(0.1875f + 0.1875f * cos(teta)); } for (int i = 0; i < layers; i++) { heigthNow = i * scaleHeigth; for (int j = 0; j < slices; j++) { teta = j * alpha; tetaNext = (j + 1) * alpha; p0 = drawPoints(radius, teta, heigthNow); p1 = drawPoints(radius, tetaNext, heigthNow); p2 = drawPoints(radius, tetaNext, heigthNow + scaleHeigth); p3 = drawPoints(radius, teta, heigthNow + scaleHeigth); //draw first triangle points.push_back(p0); points.push_back(p1); points.push_back(p2); //draw second triangle points.push_back(p0); points.push_back(p2); points.push_back(p3); Point p4; p4.x = sin(teta); p4.y = 0; p4.z = cos(teta); Point p5; p5.x = sin(tetaNext); p5.y = 0; p5.z = cos(teta); Point p6; p6.x = sin(tetaNext); p6.y = 0; p6.z = cos(tetaNext); (*normal).push_back(p4); (*normal).push_back(p5); (*normal).push_back(p4); (*normal).push_back(p6); (*normal).push_back(p6); (*normal).push_back(p6); (*texture).push_back((1.0f/slices) * (j)); (*texture).push_back(i*0.625f/layers + 0.375f); (*texture).push_back((1.0f/slices) * (j + 1)); (*texture).push_back(i*0.625f/layers + 0.375f); (*texture).push_back((1.0f/slices) * (j + 1)); (*texture).push_back((i+1)*0.625f/layers + 0.375f); (*texture).push_back((1.0f/slices) * (j)); (*texture).push_back(i*0.625f/layers + 0.375f); (*texture).push_back((1.0f/slices) * (j + 1)); (*texture).push_back((i+1)*0.625f/layers + 0.375f); (*texture).push_back((1.0f/slices) * j); (*texture).push_back((i+1)*0.625f/layers + 0.375f); } } //draw topo for (int i = 0; i < slices; i++) { teta = i * alpha; tetaNext = (i + 1) * alpha; p0.x = 0; p0.y = height; p0.z = 0; p3.x = 0; p3.y = 1; p3.z = 0; p1 = drawPoints(radius, tetaNext, height); p2 = drawPoints(radius, teta, height); points.push_back(p0); points.push_back(p2); points.push_back(p1); //normal (*normal).push_back(p3); (*normal).push_back(p3); (*normal).push_back(p3); //texture (*texture).push_back(0.4375f); (*texture).push_back(0.1875f); (*texture).push_back(0.4375f + 0.1875f * sin(teta)); (*texture).push_back(0.1875f + 0.1875f * cos(teta)); (*texture).push_back(0.4375f + 0.1875f * sin(tetaNext)); (*texture).push_back(0.1875f + 0.1875f * cos(tetaNext)); } return points; } //draw torus Point pointsTorus(float radiusIn,float radiusOut,float beta,float alpha){ Point result; result.x = cos(alpha) * (radiusIn*cos(beta) + radiusOut); result.y = sin(alpha) * (radiusIn*cos(beta) + radiusOut); result.z = radiusIn * sin(beta); return result; } vector<Point> torus(float radiusIn,float radiusOut , int slices, int layers,vector<Point> *normal, vector<float> *texture){ Point p1,p2,p3,p4; vector<Point> points; for (int i = 0; i < layers; i++) { float beta = i * (2*M_PI)/layers; float nextBeta = (i+1) * (2*M_PI)/layers; for (int j = 0; j < slices; j++) { float alpha = j * (2*M_PI)/slices; float nextAlpha = (j+1) * (2*M_PI)/slices; p1 = pointsTorus(radiusIn,radiusOut,beta,alpha); p2 = pointsTorus(radiusIn,radiusOut,beta,nextAlpha); p3 = pointsTorus(radiusIn,radiusOut,nextBeta,alpha); p4 = pointsTorus(radiusIn,radiusOut,nextBeta,nextAlpha); points.push_back(p1);points.push_back(p2);points.push_back(p3); points.push_back(p3);points.push_back(p2);points.push_back(p4); p1 = pointsTorus(1,1,beta,alpha); p2 = pointsTorus(1,1,beta,nextAlpha); p3 = pointsTorus(1,1,nextBeta,alpha); p4 = pointsTorus(1,1,nextBeta,nextAlpha); (*normal).push_back(p1);(*normal).push_back(p2);(*normal).push_back(p3); (*normal).push_back(p3);(*normal).push_back(p2);(*normal).push_back(p4); (*texture).push_back( (float) j/slices ); (*texture).push_back( (float) i/layers ); (*texture).push_back( (float)(j+1)/slices ); (*texture).push_back( (float) i/layers ); (*texture).push_back( (float) j/slices ); (*texture).push_back( (float)(i+1)/layers ); (*texture).push_back( (float) j/slices ); (*texture).push_back( (float)(i+1)/layers ); (*texture).push_back( (float)(j+1)/slices ); (*texture).push_back( (float) i/layers ); (*texture).push_back( (float)(j+1)/slices ); (*texture).push_back( (float)(i+1)/layers ); } } return points; }
[ "adriana_1998@live.com.pt" ]
adriana_1998@live.com.pt
371695e48663f1ca9e5b67dee34e0bd768560f49
5bce87c99f3c62c9caafdc253ed1e26ee3887c68
/src/board.cc
5ac57101f62113d9ff25ce0fa113aa800d3b545e
[ "MIT" ]
permissive
CS126SP20/tetris-lucianatl
aff834d19067dc22c142cb96671dba3b9cde31b1
d55bbf32c05f793ff0dbbc0c9a8dc7e78a27fd9f
refs/heads/master
2022-06-08T00:27:32.688450
2020-05-07T02:25:15
2020-05-07T02:25:15
257,122,922
0
0
null
null
null
null
UTF-8
C++
false
false
4,670
cc
// // Created by Luciana Toledo-Lopez on 4/22/20. // #include "mylibrary/board.h" namespace tetris { Board::Board() {} Board::Board(int screen_height) { kScreenHeight = screen_height; FillBoard(); } int Board::GetScreenHeight() const { return kScreenHeight; } void Board::FillBoard() { for (int i = 0; i < kBoardWidth; i++) { for (int j = 0; j < kBoardHeight; j++) { board[i][j] = free; } } } void Board::StorePiece(int x, int y, char piece, int rotation) { // Store each block of the piece into the board for (int i_board = x, i_matrix = 0; i_board < x + kPieceMatrixSize; i_board++, i_matrix++) { for (int j_board = y, j_matrix = 0; j_board < y + kPieceMatrixSize; j_board++, j_matrix++) { // Store only the blocks of the piece that are not holes if (pieces.GetBlockType(piece, rotation, j_matrix, i_matrix) != 0) { board[i_board][j_board] = filled; } } } } bool Board::IsGameOver() { //check if the first line has blocks for (int i = 0; i < kBoardWidth; i++) { if (board[i][0] == filled) { return true; } } return false; } void Board::DeleteLine(int y) { // Moves all the upper lines one row down for (int j = y; j > 0; j--) { for (int i = 0; i < kBoardWidth; i++) { board[i][j] = board[i][j-1]; } } } // double check to make sure this works void Board::DeletePossibleLines() { for (int j = 0; j < kBoardHeight; j++) { int row_ = 0; for (int i = 0; i < kBoardWidth; i++) { if (board[i][j] != filled) { break; } row_ = i; } int deleted_counter_ = 0 ; if (row_ == kBoardWidth - 1) { deleted_counter_++; level_counter_++; DeleteLine(j); } // add points switch(deleted_counter_) { case 0 : break; case 1 : score_ += kOneLinePoints; break; case 2 : score_ += kTwoLinePoints; break; case 3 : score_ += kThreeLinePoints; break; case 4 : score_ += kFourLinePoints; break; default : score_ += kFourLinePoints;; } } } bool Board::IsFreeBlock (int x, int y) { return (board[x][y] == free); } bool Board::IsMovementPossible(int x, int y, char piece, int rotation) { // Checks collision with pieces already stored in the board or the board limits int i_matrix = 0; for (int i_board = x; i_board < x + kPieceMatrixSize; i_board++) { int j_matrix = 0; for (int j_board = y; j_board < y + kPieceMatrixSize; j_board++) { // Check if the piece is outside the limits of the board if (i_board < 0 || i_board > kBoardWidth - 1 || j_board > kBoardHeight - 1) { // if you want to return false if (pieces.GetBlockType(piece, rotation, j_matrix, i_matrix) != 0) { // end game? return 0? return false; } } // Check if the piece have collided with a block already stored in the array if (j_board >= 0) { if ((pieces.GetBlockType(piece, rotation, j_matrix, i_matrix) != 0) && (!IsFreeBlock(i_board, j_board))) { return false; } } j_matrix++; } i_matrix++; } // No collision return true; } int Board::GetXPosInScreen(int x_position) { return ((kBoardMiddle - (kBlockSize * (kBoardWidth / 2))) + (x_position * kBlockSize)); } int Board::GetYPosInScreen (int y_position) { return ((kScreenHeight - (kBlockSize * kBoardHeight)) + (y_position * kBlockSize)); } bool Board::ShouldIncreaseSpeed() { //check if need to increase speed if (level_counter_ >= increase_level_) { level_counter_ = 0; return true; } return false; } }
[ "Csc3maat" ]
Csc3maat
2a5fcfbb4a4fde05393f7886768d498102c749d3
97478e6083db1b7ec79680cfcfd78ed6f5895c7d
/base/message_loop/message_loop_io_posix_unittest.cc
f98d4668d3a6299e16047c250e3098bdb830a337
[ "BSD-3-Clause" ]
permissive
zeph1912/milkomeda_chromium
94e81510e1490d504b631a29af2f1fef76110733
7b29a87147c40376bcdd1742f687534bcd0e4c78
refs/heads/master
2023-03-15T11:05:27.924423
2018-12-19T07:58:08
2018-12-19T07:58:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,458
cc
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/message_loop/message_loop.h" #include "base/bind.h" #include "base/compiler_specific.h" #include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/posix/eintr_wrapper.h" #include "base/run_loop.h" #include "base/test/gtest_util.h" #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" namespace base { #if !defined(OS_NACL) namespace { class MessageLoopForIoPosixTest : public testing::Test { public: MessageLoopForIoPosixTest() = default; // testing::Test interface. void SetUp() override { // Create a file descriptor. Doesn't need to be readable or writable, // as we don't need to actually get any notifications. // pipe() is just the easiest way to do it. int pipefds[2]; int err = pipe(pipefds); ASSERT_EQ(0, err); read_fd_ = ScopedFD(pipefds[0]); write_fd_ = ScopedFD(pipefds[1]); } void TriggerReadEvent() { // Write from the other end of the pipe to trigger the event. char c = '\0'; EXPECT_EQ(1, HANDLE_EINTR(write(write_fd_.get(), &c, 1))); } protected: ScopedFD read_fd_; ScopedFD write_fd_; DISALLOW_COPY_AND_ASSIGN(MessageLoopForIoPosixTest); }; class TestHandler : public MessageLoopForIO::Watcher { public: void OnFileCanReadWithoutBlocking(int fd) override { watcher_to_delete_ = nullptr; is_readable_ = true; RunLoop::QuitCurrentWhenIdleDeprecated(); } void OnFileCanWriteWithoutBlocking(int fd) override { watcher_to_delete_ = nullptr; is_writable_ = true; RunLoop::QuitCurrentWhenIdleDeprecated(); } bool is_readable_ = false; bool is_writable_ = false; // If set then the contained watcher will be deleted on notification. std::unique_ptr<MessageLoopForIO::FileDescriptorWatcher> watcher_to_delete_; }; // Watcher that calls specified closures when read/write events occur. Verifies // that each non-null closure passed to this class is called once and only once. // Also resets the read event by reading from the FD. class CallClosureHandler : public MessageLoopForIO::Watcher { public: CallClosureHandler(OnceClosure read_closure, OnceClosure write_closure) : read_closure_(std::move(read_closure)), write_closure_(std::move(write_closure)) {} ~CallClosureHandler() override { EXPECT_TRUE(read_closure_.is_null()); EXPECT_TRUE(write_closure_.is_null()); } void SetReadClosure(OnceClosure read_closure) { EXPECT_TRUE(read_closure_.is_null()); read_closure_ = std::move(read_closure); } void SetWriteClosure(OnceClosure write_closure) { EXPECT_TRUE(write_closure_.is_null()); write_closure_ = std::move(write_closure); } // base:MessagePumpFuchsia::Watcher interface. void OnFileCanReadWithoutBlocking(int fd) override { // Empty the pipe buffer to reset the event. Otherwise libevent // implementation of MessageLoop may call the event handler again even if // |read_closure_| below quits the RunLoop. char c; int result = HANDLE_EINTR(read(fd, &c, 1)); if (result == -1) { PLOG(ERROR) << "read"; FAIL(); } EXPECT_EQ(result, 1); ASSERT_FALSE(read_closure_.is_null()); std::move(read_closure_).Run(); } void OnFileCanWriteWithoutBlocking(int fd) override { ASSERT_FALSE(write_closure_.is_null()); std::move(write_closure_).Run(); } private: OnceClosure read_closure_; OnceClosure write_closure_; }; TEST_F(MessageLoopForIoPosixTest, FileDescriptorWatcherOutlivesMessageLoop) { // Simulate a MessageLoop that dies before an FileDescriptorWatcher. // This could happen when people use the Singleton pattern or atexit. // Arrange for watcher to live longer than message loop. MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); TestHandler handler; { MessageLoopForIO message_loop; message_loop.WatchFileDescriptor(write_fd_.get(), true, MessageLoopForIO::WATCH_WRITE, &watcher, &handler); // Don't run the message loop, just destroy it. } ASSERT_FALSE(handler.is_readable_); ASSERT_FALSE(handler.is_writable_); } TEST_F(MessageLoopForIoPosixTest, FileDescriptorWatcherDoubleStop) { // Verify that it's ok to call StopWatchingFileDescriptor(). // (Errors only showed up in valgrind.) // Arrange for message loop to live longer than watcher. MessageLoopForIO message_loop; { MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); TestHandler handler; message_loop.WatchFileDescriptor(write_fd_.get(), true, MessageLoopForIO::WATCH_WRITE, &watcher, &handler); ASSERT_TRUE(watcher.StopWatchingFileDescriptor()); ASSERT_TRUE(watcher.StopWatchingFileDescriptor()); } } TEST_F(MessageLoopForIoPosixTest, FileDescriptorWatcherDeleteInCallback) { // Verify that it is OK to delete the FileDescriptorWatcher from within a // callback. MessageLoopForIO message_loop; TestHandler handler; handler.watcher_to_delete_ = std::make_unique<MessageLoopForIO::FileDescriptorWatcher>(FROM_HERE); message_loop.WatchFileDescriptor(write_fd_.get(), true, MessageLoopForIO::WATCH_WRITE, handler.watcher_to_delete_.get(), &handler); RunLoop().Run(); } // Verify that basic readable notification works. TEST_F(MessageLoopForIoPosixTest, WatchReadable) { MessageLoopForIO message_loop; MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); TestHandler handler; // Watch the pipe for readability. ASSERT_TRUE(MessageLoopForIO::current()->WatchFileDescriptor( read_fd_.get(), /*persistent=*/false, MessageLoopForIO::WATCH_READ, &watcher, &handler)); // The pipe should not be readable when first created. RunLoop().RunUntilIdle(); ASSERT_FALSE(handler.is_readable_); ASSERT_FALSE(handler.is_writable_); TriggerReadEvent(); // We don't want to assume that the read fd becomes readable the // instant a bytes is written, so Run until quit by an event. RunLoop().Run(); ASSERT_TRUE(handler.is_readable_); ASSERT_FALSE(handler.is_writable_); } // Verify that watching a file descriptor for writability succeeds. TEST_F(MessageLoopForIoPosixTest, WatchWritable) { MessageLoopForIO message_loop; MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); TestHandler handler; // Watch the pipe for writability. ASSERT_TRUE(MessageLoopForIO::current()->WatchFileDescriptor( write_fd_.get(), /*persistent=*/false, MessageLoopForIO::WATCH_WRITE, &watcher, &handler)); // We should not receive a writable notification until we process events. ASSERT_FALSE(handler.is_readable_); ASSERT_FALSE(handler.is_writable_); // The pipe should be writable immediately, but wait for the quit closure // anyway, to be sure. RunLoop().Run(); ASSERT_FALSE(handler.is_readable_); ASSERT_TRUE(handler.is_writable_); } // Verify that RunUntilIdle() receives IO notifications. TEST_F(MessageLoopForIoPosixTest, RunUntilIdle) { MessageLoopForIO message_loop; MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); TestHandler handler; // Watch the pipe for readability. ASSERT_TRUE(MessageLoopForIO::current()->WatchFileDescriptor( read_fd_.get(), /*persistent=*/false, MessageLoopForIO::WATCH_READ, &watcher, &handler)); // The pipe should not be readable when first created. RunLoop().RunUntilIdle(); ASSERT_FALSE(handler.is_readable_); TriggerReadEvent(); while (!handler.is_readable_) RunLoop().RunUntilIdle(); } void StopWatching(MessageLoopForIO::FileDescriptorWatcher* controller, RunLoop* run_loop) { controller->StopWatchingFileDescriptor(); run_loop->Quit(); } // Verify that StopWatchingFileDescriptor() works from an event handler. TEST_F(MessageLoopForIoPosixTest, StopFromHandler) { MessageLoopForIO message_loop; RunLoop run_loop; MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); CallClosureHandler handler(BindOnce(&StopWatching, &watcher, &run_loop), OnceClosure()); // Create persistent watcher. ASSERT_TRUE(MessageLoopForIO::current()->WatchFileDescriptor( read_fd_.get(), /*persistent=*/true, MessageLoopForIO::WATCH_READ, &watcher, &handler)); TriggerReadEvent(); run_loop.Run(); // Trigger the event again. The event handler should not be called again. TriggerReadEvent(); RunLoop().RunUntilIdle(); } // Verify that non-persistent watcher is called only once. TEST_F(MessageLoopForIoPosixTest, NonPersistentWatcher) { MessageLoopForIO message_loop; MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); RunLoop run_loop; CallClosureHandler handler(run_loop.QuitClosure(), OnceClosure()); // Create a non-persistent watcher. ASSERT_TRUE(MessageLoopForIO::current()->WatchFileDescriptor( read_fd_.get(), /*persistent=*/false, MessageLoopForIO::WATCH_READ, &watcher, &handler)); TriggerReadEvent(); run_loop.Run(); // Trigger the event again. handler should not be called again. TriggerReadEvent(); RunLoop().RunUntilIdle(); } // Verify that persistent watcher is called every time the event is triggered. TEST_F(MessageLoopForIoPosixTest, PersistentWatcher) { MessageLoopForIO message_loop; MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); RunLoop run_loop1; CallClosureHandler handler(run_loop1.QuitClosure(), OnceClosure()); // Create persistent watcher. ASSERT_TRUE(MessageLoopForIO::current()->WatchFileDescriptor( read_fd_.get(), /*persistent=*/true, MessageLoopForIO::WATCH_READ, &watcher, &handler)); TriggerReadEvent(); run_loop1.Run(); RunLoop run_loop2; handler.SetReadClosure(run_loop2.QuitClosure()); // Trigger the event again. handler should be called now, which will quit // run_loop2. TriggerReadEvent(); run_loop2.Run(); } void StopWatchingAndWatchAgain( MessageLoopForIO::FileDescriptorWatcher* controller, int fd, MessageLoopForIO::Watcher* new_handler, RunLoop* run_loop) { controller->StopWatchingFileDescriptor(); ASSERT_TRUE(MessageLoopForIO::current()->WatchFileDescriptor( fd, /*persistent=*/true, MessageLoopForIO::WATCH_READ, controller, new_handler)); run_loop->Quit(); } // Verify that a watcher can be stopped and reused from an event handler. TEST_F(MessageLoopForIoPosixTest, StopAndRestartFromHandler) { MessageLoopForIO message_loop; MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); RunLoop run_loop1; RunLoop run_loop2; CallClosureHandler handler2(run_loop2.QuitClosure(), OnceClosure()); CallClosureHandler handler1(BindOnce(&StopWatchingAndWatchAgain, &watcher, read_fd_.get(), &handler2, &run_loop1), OnceClosure()); // Create persistent watcher. ASSERT_TRUE(MessageLoopForIO::current()->WatchFileDescriptor( read_fd_.get(), /*persistent=*/true, MessageLoopForIO::WATCH_READ, &watcher, &handler1)); TriggerReadEvent(); run_loop1.Run(); // Trigger the event again. handler2 should be called now, which will quit // run_loop2 TriggerReadEvent(); run_loop2.Run(); } // Verify that the pump properly handles a delayed task after an IO event. TEST_F(MessageLoopForIoPosixTest, IoEventThenTimer) { MessageLoopForIO message_loop; MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); RunLoop timer_run_loop; message_loop.task_runner()->PostDelayedTask( FROM_HERE, timer_run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(10)); RunLoop watcher_run_loop; CallClosureHandler handler(watcher_run_loop.QuitClosure(), OnceClosure()); // Create a non-persistent watcher. ASSERT_TRUE(MessageLoopForIO::current()->WatchFileDescriptor( read_fd_.get(), /*persistent=*/false, MessageLoopForIO::WATCH_READ, &watcher, &handler)); TriggerReadEvent(); // Normally the IO event will be received before the delayed task is // executed, so this run loop will first handle the IO event and then quit on // the timer. timer_run_loop.Run(); // Run watcher_run_loop in case the IO event wasn't received before the // delayed task. watcher_run_loop.Run(); } // Verify that the pipe can handle an IO event after a delayed task. TEST_F(MessageLoopForIoPosixTest, TimerThenIoEvent) { MessageLoopForIO message_loop; MessageLoopForIO::FileDescriptorWatcher watcher(FROM_HERE); // Trigger read event from a delayed task. message_loop.task_runner()->PostDelayedTask( FROM_HERE, BindOnce(&MessageLoopForIoPosixTest::TriggerReadEvent, Unretained(this)), TimeDelta::FromMilliseconds(1)); RunLoop run_loop; CallClosureHandler handler(run_loop.QuitClosure(), OnceClosure()); // Create a non-persistent watcher. ASSERT_TRUE(MessageLoopForIO::current()->WatchFileDescriptor( read_fd_.get(), /*persistent=*/false, MessageLoopForIO::WATCH_READ, &watcher, &handler)); run_loop.Run(); } } // namespace #endif // !defined(OS_NACL) } // namespace base
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
d0a2f8dc6db2356c0b467dd57657aee35f51e601
948f4e13af6b3014582909cc6d762606f2a43365
/testcases/juliet_test_suite/testcases/CWE789_Uncontrolled_Mem_Alloc/s01/CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_84_goodG2B.cpp
01ff71d446cc7b8e5da5605854525df9b9a3b7f0
[]
no_license
junxzm1990/ASAN--
0056a341b8537142e10373c8417f27d7825ad89b
ca96e46422407a55bed4aa551a6ad28ec1eeef4e
refs/heads/master
2022-08-02T15:38:56.286555
2022-06-16T22:19:54
2022-06-16T22:19:54
408,238,453
74
13
null
2022-06-16T22:19:55
2021-09-19T21:14:59
null
UTF-8
C++
false
false
2,130
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_84_goodG2B.cpp Label Definition File: CWE789_Uncontrolled_Mem_Alloc__malloc.label.xml Template File: sources-sinks-84_goodG2B.tmpl.cpp */ /* * @description * CWE: 789 Uncontrolled Memory Allocation * BadSource: rand Set data to result of rand(), which may be zero * GoodSource: Small number greater than zero * Sinks: * GoodSink: Allocate memory with malloc() and check the size of the memory to be allocated * BadSink : Allocate memory with malloc(), but incorrectly check the size of the memory to be allocated * Flow Variant: 84 Data flow: data passed to class constructor and destructor by declaring the class object on the heap and deleting it after use * * */ #ifndef OMITGOOD #include "std_testcase.h" #include "CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_84.h" #define HELLO_STRING "hello" namespace CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_84 { CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_84_goodG2B::CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_84_goodG2B(size_t dataCopy) { data = dataCopy; /* FIX: Use a relatively small number for memory allocation */ data = 20; } CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_84_goodG2B::~CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_84_goodG2B() { { char * myString; /* POTENTIAL FLAW: No MAXIMUM limitation for memory allocation, but ensure data is large enough * for the strcpy() function to not cause a buffer overflow */ /* INCIDENTAL FLAW: The source could cause a type overrun in data or in the memory allocation */ if (data > strlen(HELLO_STRING)) { myString = (char *)malloc(data*sizeof(char)); /* Copy a small string into myString */ strcpy(myString, HELLO_STRING); printLine(myString); free(myString); } else { printLine("Input is less than the length of the source string"); } } } } #endif /* OMITGOOD */
[ "yzhang0701@gmail.com" ]
yzhang0701@gmail.com
7edd28d0b1c75bcdea8a4587028eaad9cfde468b
607c0886ca3e52e99313053e7be77bee60cb41ac
/infantry/rune/tiny_dnn/core/kernels/global_avepool_grad_op.h
dc5b6eed42aed586cae84196e0776f6913f173f7
[]
no_license
bobbyshashin/RoboMasters
9620e27c6967a3da35fb7df5f4b853dfde343890
589c879ab276d05ddf283adfe5292629fb6dc408
refs/heads/master
2021-03-24T09:10:27.787322
2017-07-21T18:59:27
2017-07-21T18:59:27
63,122,244
3
0
null
null
null
null
UTF-8
C++
false
false
1,091
h
/* Copyright (c) 2017, Taiga Nomi All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. */ #pragma once #include "tiny_dnn/core/framework/op_kernel.h" #include "tiny_dnn/core/kernels/global_avepool_op_internal.h" namespace tiny_dnn { class GlobalAvePoolGradOp : public core::OpKernel { public: explicit GlobalAvePoolGradOp(const core::OpKernelConstruction &context) : core::OpKernel(context) {} void compute(core::OpKernelContext &context) override { auto &params = OpKernel::params_->global_avepool(); // incoming/outcoming data tensor_t &prev_delta = context.input_grad(0); tensor_t &curr_delta = context.output_grad(0); // initialize outputs fill_tensor(prev_delta, float_t{0}); // only internal kernel op implemented yet, so use it regardless // of the specified backend engine kernels::global_avepool_grad_op_internal(prev_delta, curr_delta, params, context.parallelize()); } }; } // namespace tiny_dnn
[ "xvjiarui0826@gmail.com" ]
xvjiarui0826@gmail.com
ed03d2aa673e8592147f3e1f2c91699f019c98fa
3c0ddf4722dec4ab07c571705f46c98942c55efe
/cpp/chap02/02_01.cpp
5adbd500415ad9809be7a4de47504144b73d2c87
[]
no_license
bennyang/Hello-World
5430385c479fd3e887a5248fbe8abb6669b0322c
880a4cb7d1fe1e6cb8e94229416b9e822fe70d48
refs/heads/master
2021-01-19T18:17:04.157075
2017-08-20T09:35:34
2017-08-20T09:35:34
88,352,231
0
0
null
null
null
null
UTF-8
C++
false
false
339
cpp
#include <iostream> int main() { bool b = 42; std::cout << b << std::endl; int i = b; std::cout << i << std::endl; i = 3.14; std::cout << i << std::endl; double pi = i; std::cout << pi << std::endl; unsigned char c = -i; std::cout << c << std::endl; signed char c2 =256; std::cout << c2 << std::endl; return 0; }
[ "benn2015@163.com" ]
benn2015@163.com
745323ca11d0f20fc3dfc19a6d873e96f19e3325
70b106ea0a9286533fdb6e3ff7157ca82b836d8f
/code/ListBoxHandler.h
62950dc5f4817cac775d74797b5c9c39039f5d9d
[ "MIT" ]
permissive
Mankua/texlay
c03458ee1577da6f9093acfae132534203528c85
8e67db732b525ac2abf6622c926c7b347fc211ec
refs/heads/master
2021-01-23T19:46:10.384985
2014-06-12T13:36:38
2014-06-12T13:36:38
20,766,708
0
1
null
null
null
null
UTF-8
C++
false
false
790
h
#pragma once // custom drag&drop notification message // dragged item as WPARAM // dropped position as LPARAM #define USER_LB_DRAGDROP WM_USER+1 #define USER_LB_SETSEL WM_USER+2 #define USER_LB_ACTIVATE WM_USER+3 class CListBoxHandler { public: CListBoxHandler(); virtual ~CListBoxHandler(); public: BOOL SetTarget(HINSTANCE hInstance, HWND hwndListbox); protected: int xpos; int ypos; HWND m_hwndListBox; static WNDPROC m_pfOriginalProc; int m_curSel; HCURSOR m_hcurDrag; HINSTANCE m_hInstance; protected: HCURSOR GetDragCursor(); //Win32 : static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static LONG_PTR CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); public: HWND GetHwnd(); };
[ "diego@mankua.com" ]
diego@mankua.com
09446eb6f017a3054418ead27d0c27f47fc848d2
11348e739dee821e4bdd6ec0e4c6c041a01b0b59
/kk/916.่‚ก็ฅžไน.cpp
80a1dfbe83415ced29265dbc0223485c4bc9e360
[]
no_license
Spartan859/Noip_Code
580b1f022ca4b8bf3e77ff8d57d230340715a98d
8efe9e7cc6f29cd864b9570944932f50115c3089
refs/heads/master
2022-11-18T15:09:19.500944
2020-07-11T13:36:21
2020-07-11T13:36:21
163,517,575
1
0
null
null
null
null
UTF-8
C++
false
false
592
cpp
#include<bits/stdc++.h> #define N 10005 #define ll long long using namespace std; ll f[N][2],n,k,x[N],tmp=0,bf,cnt=1,ans,cntz=0,sumz=0; const ll zr=0; int main(){ //freopen("god9.in","r",stdin); //freopen("god9.out","w",stdout); scanf("%lld %lld",&n,&k); for(ll i=1;i<=n;i++){ scanf("%lld",&x[i]); } for(ll i=1;i<=n;i++) f[i][1]=x[i]+max(zr,f[i-1][1]); for(ll j=2;j<=(n>>1)+1;j++){ tmp=0; for(ll i=1;i<=n;i++){ tmp=max(tmp,f[i-1][j&1^1]); f[i][j&1]=x[i]+max(f[i-1][j&1],tmp); if(f[i][j&1]>=k){ cout<<j<<endl; return 0; } } } cout<<-1<<endl; return 0; }
[ "36628376+Spartan859@users.noreply.github.com" ]
36628376+Spartan859@users.noreply.github.com
faed9c002399c6cc96115cfd7e1ea973ec470562
814fda3bc42d0b324b33c2cbb57cb4a327f71e96
/test/2019/Day05PuzzleTests.cpp
10a27b55f0c5fee7a7dac2d331673cfea2533fe7
[ "MIT" ]
permissive
MarkRDavison/AdventOfCode
377591ce341e37ef2bffa563ccd596fdacc83b60
a415f3311ad29a5ed2703113769b04b9614e7d57
refs/heads/main
2022-12-21T10:04:37.032919
2022-12-18T05:55:29
2022-12-18T05:55:29
162,899,531
0
0
null
null
null
null
UTF-8
C++
false
false
588
cpp
#include <catch/catch.hpp> #include <2019/Day05Puzzle.hpp> namespace TwentyNineteen { TEST_CASE("2019 Day 5 Part 1 Example work", "[2019][Day05]") { const std::vector<std::string> input = {}; Day05Puzzle puzzle{}; puzzle.setVerbose(true); puzzle.setInputLines(input); auto answers = puzzle.fastSolve(); } TEST_CASE("2019 Day 5 Part 2 Example work", "[2019][Day05]") { const std::vector<std::string> input = {}; Day05Puzzle puzzle{}; puzzle.setVerbose(true); puzzle.setInputLines(input); auto answers = puzzle.fastSolve(); } }
[ "markdavison0+github@gmail.com" ]
markdavison0+github@gmail.com
cc82e7648d031ee6f0aad43e0df6b4b17cfdffe1
dd9ce0e1ebbb2dd0e2110eae8246346b5e4e6bb3
/diamnet-core/src/ledger/LedgerTxnHeader.h
712cfd5514d86d6781f09a07d670c6237d241b5d
[ "MIT", "BSD-3-Clause", "BSL-1.0", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
shanhashcah/diamnet-core15
f9a4d2b9dd93ac504782df85225e4f924ac8bdc2
de15c6b197f8c21f269c0b99d90c6b243d1addb0
refs/heads/master
2023-08-25T01:45:11.747763
2021-10-20T16:09:35
2021-10-20T16:09:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,321
h
#pragma once // Copyright 2018 Diamnet Development Foundation and contributors. Licensed // under the Apache License, Version 2.0. See the COPYING file at the root // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0 #include <memory> namespace diamnet { class AbstractLedgerTxn; struct LedgerHeader; class LedgerTxnHeader { public: class Impl; private: std::weak_ptr<Impl> mImpl; std::shared_ptr<Impl> getImpl(); std::shared_ptr<Impl const> getImpl() const; public: // LedgerTxnEntry constructors do not throw explicit LedgerTxnHeader(std::shared_ptr<Impl> const& impl); ~LedgerTxnHeader(); // Copy construction and copy assignment are forbidden. LedgerTxnHeader(LedgerTxnHeader const&) = delete; LedgerTxnHeader& operator=(LedgerTxnHeader const&) = delete; // Move construction and move assignment are permitted. LedgerTxnHeader(LedgerTxnHeader&& other); LedgerTxnHeader& operator=(LedgerTxnHeader&& other); explicit operator bool() const; LedgerHeader& current(); LedgerHeader const& current() const; void deactivate(); void swap(LedgerTxnHeader& other); static std::shared_ptr<Impl> makeSharedImpl(AbstractLedgerTxn& ltx, LedgerHeader& current); }; }
[ "ubuntu@ip-172-31-22-243.us-west-1.compute.internal" ]
ubuntu@ip-172-31-22-243.us-west-1.compute.internal
aa5f341b655fd86ea3cde9f959b5505226d93115
10fdc68abb2110732bc3928a577aa404153c824b
/third_party/skcms/skcms.cc
b746879d60c25f42310ee54fb6c502b43cbb6cda
[ "BSD-3-Clause" ]
permissive
EdSchouten/skia
6f60471eebe2faf398b7915d1d6f057fe761afc5
a583a06f831e9e03c303920b9d34f085508135c1
refs/heads/master
2020-04-01T14:02:12.877873
2018-10-16T07:19:03
2018-10-16T07:45:33
153,277,813
0
0
NOASSERTION
2018-10-16T11:57:33
2018-10-16T11:57:33
null
UTF-8
C++
false
false
83,896
cc
/* * Copyright 2018 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "skcms.h" #include "skcms_internal.h" #include <assert.h> #include <float.h> #include <limits.h> #include <stdlib.h> #include <string.h> #if defined(__ARM_NEON) #include <arm_neon.h> #elif defined(__SSE__) #include <immintrin.h> #endif // sizeof(x) will return size_t, which is 32-bit on some machines and 64-bit on others. // We have better testing on 64-bit machines, so force 32-bit machines to behave like 64-bit. // // Please do not use sizeof() directly, and size_t only when required. // (We have no way of enforcing these requests...) #define SAFE_SIZEOF(x) ((uint64_t)sizeof(x)) // Same sort of thing for _Layout structs with a variable sized array at the end (named "variable"). #define SAFE_FIXED_SIZE(type) ((uint64_t)offsetof(type, variable)) static const union { uint32_t bits; float f; } inf_ = { 0x7f800000 }; #define INFINITY_ inf_.f static float fmaxf_(float x, float y) { return x > y ? x : y; } static float fminf_(float x, float y) { return x < y ? x : y; } static bool isfinitef_(float x) { return 0 == x*0; } static float minus_1_ulp(float x) { int32_t bits; memcpy(&bits, &x, sizeof(bits)); bits = bits - 1; memcpy(&x, &bits, sizeof(bits)); return x; } static float eval_curve(const skcms_Curve* curve, float x) { if (curve->table_entries == 0) { return skcms_TransferFunction_eval(&curve->parametric, x); } float ix = fmaxf_(0, fminf_(x, 1)) * (curve->table_entries - 1); int lo = (int) ix , hi = (int)(float)minus_1_ulp(ix + 1.0f); float t = ix - (float)lo; float l, h; if (curve->table_8) { l = curve->table_8[lo] * (1/255.0f); h = curve->table_8[hi] * (1/255.0f); } else { uint16_t be_l, be_h; memcpy(&be_l, curve->table_16 + 2*lo, 2); memcpy(&be_h, curve->table_16 + 2*hi, 2); uint16_t le_l = ((be_l << 8) | (be_l >> 8)) & 0xffff; uint16_t le_h = ((be_h << 8) | (be_h >> 8)) & 0xffff; l = le_l * (1/65535.0f); h = le_h * (1/65535.0f); } return l + (h-l)*t; } static float max_roundtrip_error(const skcms_Curve* curve, const skcms_TransferFunction* inv_tf) { uint32_t N = curve->table_entries > 256 ? curve->table_entries : 256; const float dx = 1.0f / (N - 1); float err = 0; for (uint32_t i = 0; i < N; i++) { float x = i * dx, y = eval_curve(curve, x); err = fmaxf_(err, fabsf_(x - skcms_TransferFunction_eval(inv_tf, y))); } return err; } bool skcms_AreApproximateInverses(const skcms_Curve* curve, const skcms_TransferFunction* inv_tf) { return max_roundtrip_error(curve, inv_tf) < (1/512.0f); } // Additional ICC signature values that are only used internally enum { // File signature skcms_Signature_acsp = 0x61637370, // Tag signatures skcms_Signature_rTRC = 0x72545243, skcms_Signature_gTRC = 0x67545243, skcms_Signature_bTRC = 0x62545243, skcms_Signature_kTRC = 0x6B545243, skcms_Signature_rXYZ = 0x7258595A, skcms_Signature_gXYZ = 0x6758595A, skcms_Signature_bXYZ = 0x6258595A, skcms_Signature_A2B0 = 0x41324230, skcms_Signature_A2B1 = 0x41324231, skcms_Signature_mAB = 0x6D414220, skcms_Signature_CHAD = 0x63686164, // Type signatures skcms_Signature_curv = 0x63757276, skcms_Signature_mft1 = 0x6D667431, skcms_Signature_mft2 = 0x6D667432, skcms_Signature_para = 0x70617261, skcms_Signature_sf32 = 0x73663332, // XYZ is also a PCS signature, so it's defined in skcms.h // skcms_Signature_XYZ = 0x58595A20, }; static uint16_t read_big_u16(const uint8_t* ptr) { uint16_t be; memcpy(&be, ptr, sizeof(be)); #if defined(_MSC_VER) return _byteswap_ushort(be); #else return __builtin_bswap16(be); #endif } static uint32_t read_big_u32(const uint8_t* ptr) { uint32_t be; memcpy(&be, ptr, sizeof(be)); #if defined(_MSC_VER) return _byteswap_ulong(be); #else return __builtin_bswap32(be); #endif } static int32_t read_big_i32(const uint8_t* ptr) { return (int32_t)read_big_u32(ptr); } static float read_big_fixed(const uint8_t* ptr) { return read_big_i32(ptr) * (1.0f / 65536.0f); } // Maps to an in-memory profile so that fields line up to the locations specified // in ICC.1:2010, section 7.2 typedef struct { uint8_t size [ 4]; uint8_t cmm_type [ 4]; uint8_t version [ 4]; uint8_t profile_class [ 4]; uint8_t data_color_space [ 4]; uint8_t pcs [ 4]; uint8_t creation_date_time [12]; uint8_t signature [ 4]; uint8_t platform [ 4]; uint8_t flags [ 4]; uint8_t device_manufacturer [ 4]; uint8_t device_model [ 4]; uint8_t device_attributes [ 8]; uint8_t rendering_intent [ 4]; uint8_t illuminant_X [ 4]; uint8_t illuminant_Y [ 4]; uint8_t illuminant_Z [ 4]; uint8_t creator [ 4]; uint8_t profile_id [16]; uint8_t reserved [28]; uint8_t tag_count [ 4]; // Technically not part of header, but required } header_Layout; typedef struct { uint8_t signature [4]; uint8_t offset [4]; uint8_t size [4]; } tag_Layout; static const tag_Layout* get_tag_table(const skcms_ICCProfile* profile) { return (const tag_Layout*)(profile->buffer + SAFE_SIZEOF(header_Layout)); } // s15Fixed16ArrayType is technically variable sized, holding N values. However, the only valid // use of the type is for the CHAD tag that stores exactly nine values. typedef struct { uint8_t type [ 4]; uint8_t reserved [ 4]; uint8_t values [36]; } sf32_Layout; bool skcms_GetCHAD(const skcms_ICCProfile* profile, skcms_Matrix3x3* m) { skcms_ICCTag tag; if (!skcms_GetTagBySignature(profile, skcms_Signature_CHAD, &tag)) { return false; } if (tag.type != skcms_Signature_sf32 || tag.size < SAFE_SIZEOF(sf32_Layout)) { return false; } const sf32_Layout* sf32Tag = (const sf32_Layout*)tag.buf; const uint8_t* values = sf32Tag->values; for (int r = 0; r < 3; ++r) for (int c = 0; c < 3; ++c, values += 4) { m->vals[r][c] = read_big_fixed(values); } return true; } // XYZType is technically variable sized, holding N XYZ triples. However, the only valid uses of // the type are for tags/data that store exactly one triple. typedef struct { uint8_t type [4]; uint8_t reserved [4]; uint8_t X [4]; uint8_t Y [4]; uint8_t Z [4]; } XYZ_Layout; static bool read_tag_xyz(const skcms_ICCTag* tag, float* x, float* y, float* z) { if (tag->type != skcms_Signature_XYZ || tag->size < SAFE_SIZEOF(XYZ_Layout)) { return false; } const XYZ_Layout* xyzTag = (const XYZ_Layout*)tag->buf; *x = read_big_fixed(xyzTag->X); *y = read_big_fixed(xyzTag->Y); *z = read_big_fixed(xyzTag->Z); return true; } static bool read_to_XYZD50(const skcms_ICCTag* rXYZ, const skcms_ICCTag* gXYZ, const skcms_ICCTag* bXYZ, skcms_Matrix3x3* toXYZ) { return read_tag_xyz(rXYZ, &toXYZ->vals[0][0], &toXYZ->vals[1][0], &toXYZ->vals[2][0]) && read_tag_xyz(gXYZ, &toXYZ->vals[0][1], &toXYZ->vals[1][1], &toXYZ->vals[2][1]) && read_tag_xyz(bXYZ, &toXYZ->vals[0][2], &toXYZ->vals[1][2], &toXYZ->vals[2][2]); } static bool tf_is_valid(const skcms_TransferFunction* tf) { // Reject obviously malformed inputs if (!isfinitef_(tf->a + tf->b + tf->c + tf->d + tf->e + tf->f + tf->g)) { return false; } // All of these parameters should be non-negative if (tf->a < 0 || tf->c < 0 || tf->d < 0 || tf->g < 0) { return false; } return true; } typedef struct { uint8_t type [4]; uint8_t reserved_a [4]; uint8_t function_type [2]; uint8_t reserved_b [2]; uint8_t variable [1/*variable*/]; // 1, 3, 4, 5, or 7 s15.16, depending on function_type } para_Layout; static bool read_curve_para(const uint8_t* buf, uint32_t size, skcms_Curve* curve, uint32_t* curve_size) { if (size < SAFE_FIXED_SIZE(para_Layout)) { return false; } const para_Layout* paraTag = (const para_Layout*)buf; enum { kG = 0, kGAB = 1, kGABC = 2, kGABCD = 3, kGABCDEF = 4 }; uint16_t function_type = read_big_u16(paraTag->function_type); if (function_type > kGABCDEF) { return false; } static const uint32_t curve_bytes[] = { 4, 12, 16, 20, 28 }; if (size < SAFE_FIXED_SIZE(para_Layout) + curve_bytes[function_type]) { return false; } if (curve_size) { *curve_size = SAFE_FIXED_SIZE(para_Layout) + curve_bytes[function_type]; } curve->table_entries = 0; curve->parametric.a = 1.0f; curve->parametric.b = 0.0f; curve->parametric.c = 0.0f; curve->parametric.d = 0.0f; curve->parametric.e = 0.0f; curve->parametric.f = 0.0f; curve->parametric.g = read_big_fixed(paraTag->variable); switch (function_type) { case kGAB: curve->parametric.a = read_big_fixed(paraTag->variable + 4); curve->parametric.b = read_big_fixed(paraTag->variable + 8); if (curve->parametric.a == 0) { return false; } curve->parametric.d = -curve->parametric.b / curve->parametric.a; break; case kGABC: curve->parametric.a = read_big_fixed(paraTag->variable + 4); curve->parametric.b = read_big_fixed(paraTag->variable + 8); curve->parametric.e = read_big_fixed(paraTag->variable + 12); if (curve->parametric.a == 0) { return false; } curve->parametric.d = -curve->parametric.b / curve->parametric.a; curve->parametric.f = curve->parametric.e; break; case kGABCD: curve->parametric.a = read_big_fixed(paraTag->variable + 4); curve->parametric.b = read_big_fixed(paraTag->variable + 8); curve->parametric.c = read_big_fixed(paraTag->variable + 12); curve->parametric.d = read_big_fixed(paraTag->variable + 16); break; case kGABCDEF: curve->parametric.a = read_big_fixed(paraTag->variable + 4); curve->parametric.b = read_big_fixed(paraTag->variable + 8); curve->parametric.c = read_big_fixed(paraTag->variable + 12); curve->parametric.d = read_big_fixed(paraTag->variable + 16); curve->parametric.e = read_big_fixed(paraTag->variable + 20); curve->parametric.f = read_big_fixed(paraTag->variable + 24); break; } return tf_is_valid(&curve->parametric); } typedef struct { uint8_t type [4]; uint8_t reserved [4]; uint8_t value_count [4]; uint8_t variable [1/*variable*/]; // value_count, 8.8 if 1, uint16 (n*65535) if > 1 } curv_Layout; static bool read_curve_curv(const uint8_t* buf, uint32_t size, skcms_Curve* curve, uint32_t* curve_size) { if (size < SAFE_FIXED_SIZE(curv_Layout)) { return false; } const curv_Layout* curvTag = (const curv_Layout*)buf; uint32_t value_count = read_big_u32(curvTag->value_count); if (size < SAFE_FIXED_SIZE(curv_Layout) + value_count * SAFE_SIZEOF(uint16_t)) { return false; } if (curve_size) { *curve_size = SAFE_FIXED_SIZE(curv_Layout) + value_count * SAFE_SIZEOF(uint16_t); } if (value_count < 2) { curve->table_entries = 0; curve->parametric.a = 1.0f; curve->parametric.b = 0.0f; curve->parametric.c = 0.0f; curve->parametric.d = 0.0f; curve->parametric.e = 0.0f; curve->parametric.f = 0.0f; if (value_count == 0) { // Empty tables are a shorthand for an identity curve curve->parametric.g = 1.0f; } else { // Single entry tables are a shorthand for simple gamma curve->parametric.g = read_big_u16(curvTag->variable) * (1.0f / 256.0f); } } else { curve->table_8 = nullptr; curve->table_16 = curvTag->variable; curve->table_entries = value_count; } return true; } // Parses both curveType and parametricCurveType data. Ensures that at most 'size' bytes are read. // If curve_size is not nullptr, writes the number of bytes used by the curve in (*curve_size). static bool read_curve(const uint8_t* buf, uint32_t size, skcms_Curve* curve, uint32_t* curve_size) { if (!buf || size < 4 || !curve) { return false; } uint32_t type = read_big_u32(buf); if (type == skcms_Signature_para) { return read_curve_para(buf, size, curve, curve_size); } else if (type == skcms_Signature_curv) { return read_curve_curv(buf, size, curve, curve_size); } return false; } // mft1 and mft2 share a large chunk of data typedef struct { uint8_t type [ 4]; uint8_t reserved_a [ 4]; uint8_t input_channels [ 1]; uint8_t output_channels [ 1]; uint8_t grid_points [ 1]; uint8_t reserved_b [ 1]; uint8_t matrix [36]; } mft_CommonLayout; typedef struct { mft_CommonLayout common [1]; uint8_t variable [1/*variable*/]; } mft1_Layout; typedef struct { mft_CommonLayout common [1]; uint8_t input_table_entries [2]; uint8_t output_table_entries [2]; uint8_t variable [1/*variable*/]; } mft2_Layout; static bool read_mft_common(const mft_CommonLayout* mftTag, skcms_A2B* a2b) { // MFT matrices are applied before the first set of curves, but must be identity unless the // input is PCSXYZ. We don't support PCSXYZ profiles, so we ignore this matrix. Note that the // matrix in skcms_A2B is applied later in the pipe, so supporting this would require another // field/flag. a2b->matrix_channels = 0; a2b->input_channels = mftTag->input_channels[0]; a2b->output_channels = mftTag->output_channels[0]; // We require exactly three (ie XYZ/Lab/RGB) output channels if (a2b->output_channels != ARRAY_COUNT(a2b->output_curves)) { return false; } // We require at least one, and no more than four (ie CMYK) input channels if (a2b->input_channels < 1 || a2b->input_channels > ARRAY_COUNT(a2b->input_curves)) { return false; } for (uint32_t i = 0; i < a2b->input_channels; ++i) { a2b->grid_points[i] = mftTag->grid_points[0]; } // The grid only makes sense with at least two points along each axis if (a2b->grid_points[0] < 2) { return false; } return true; } static bool init_a2b_tables(const uint8_t* table_base, uint64_t max_tables_len, uint32_t byte_width, uint32_t input_table_entries, uint32_t output_table_entries, skcms_A2B* a2b) { // byte_width is 1 or 2, [input|output]_table_entries are in [2, 4096], so no overflow uint32_t byte_len_per_input_table = input_table_entries * byte_width; uint32_t byte_len_per_output_table = output_table_entries * byte_width; // [input|output]_channels are <= 4, so still no overflow uint32_t byte_len_all_input_tables = a2b->input_channels * byte_len_per_input_table; uint32_t byte_len_all_output_tables = a2b->output_channels * byte_len_per_output_table; uint64_t grid_size = a2b->output_channels * byte_width; for (uint32_t axis = 0; axis < a2b->input_channels; ++axis) { grid_size *= a2b->grid_points[axis]; } if (max_tables_len < byte_len_all_input_tables + grid_size + byte_len_all_output_tables) { return false; } for (uint32_t i = 0; i < a2b->input_channels; ++i) { a2b->input_curves[i].table_entries = input_table_entries; if (byte_width == 1) { a2b->input_curves[i].table_8 = table_base + i * byte_len_per_input_table; a2b->input_curves[i].table_16 = nullptr; } else { a2b->input_curves[i].table_8 = nullptr; a2b->input_curves[i].table_16 = table_base + i * byte_len_per_input_table; } } if (byte_width == 1) { a2b->grid_8 = table_base + byte_len_all_input_tables; a2b->grid_16 = nullptr; } else { a2b->grid_8 = nullptr; a2b->grid_16 = table_base + byte_len_all_input_tables; } const uint8_t* output_table_base = table_base + byte_len_all_input_tables + grid_size; for (uint32_t i = 0; i < a2b->output_channels; ++i) { a2b->output_curves[i].table_entries = output_table_entries; if (byte_width == 1) { a2b->output_curves[i].table_8 = output_table_base + i * byte_len_per_output_table; a2b->output_curves[i].table_16 = nullptr; } else { a2b->output_curves[i].table_8 = nullptr; a2b->output_curves[i].table_16 = output_table_base + i * byte_len_per_output_table; } } return true; } static bool read_tag_mft1(const skcms_ICCTag* tag, skcms_A2B* a2b) { if (tag->size < SAFE_FIXED_SIZE(mft1_Layout)) { return false; } const mft1_Layout* mftTag = (const mft1_Layout*)tag->buf; if (!read_mft_common(mftTag->common, a2b)) { return false; } uint32_t input_table_entries = 256; uint32_t output_table_entries = 256; return init_a2b_tables(mftTag->variable, tag->size - SAFE_FIXED_SIZE(mft1_Layout), 1, input_table_entries, output_table_entries, a2b); } static bool read_tag_mft2(const skcms_ICCTag* tag, skcms_A2B* a2b) { if (tag->size < SAFE_FIXED_SIZE(mft2_Layout)) { return false; } const mft2_Layout* mftTag = (const mft2_Layout*)tag->buf; if (!read_mft_common(mftTag->common, a2b)) { return false; } uint32_t input_table_entries = read_big_u16(mftTag->input_table_entries); uint32_t output_table_entries = read_big_u16(mftTag->output_table_entries); // ICC spec mandates that 2 <= table_entries <= 4096 if (input_table_entries < 2 || input_table_entries > 4096 || output_table_entries < 2 || output_table_entries > 4096) { return false; } return init_a2b_tables(mftTag->variable, tag->size - SAFE_FIXED_SIZE(mft2_Layout), 2, input_table_entries, output_table_entries, a2b); } static bool read_curves(const uint8_t* buf, uint32_t size, uint32_t curve_offset, uint32_t num_curves, skcms_Curve* curves) { for (uint32_t i = 0; i < num_curves; ++i) { if (curve_offset > size) { return false; } uint32_t curve_bytes; if (!read_curve(buf + curve_offset, size - curve_offset, &curves[i], &curve_bytes)) { return false; } if (curve_bytes > UINT32_MAX - 3) { return false; } curve_bytes = (curve_bytes + 3) & ~3U; uint64_t new_offset_64 = (uint64_t)curve_offset + curve_bytes; curve_offset = (uint32_t)new_offset_64; if (new_offset_64 != curve_offset) { return false; } } return true; } typedef struct { uint8_t type [ 4]; uint8_t reserved_a [ 4]; uint8_t input_channels [ 1]; uint8_t output_channels [ 1]; uint8_t reserved_b [ 2]; uint8_t b_curve_offset [ 4]; uint8_t matrix_offset [ 4]; uint8_t m_curve_offset [ 4]; uint8_t clut_offset [ 4]; uint8_t a_curve_offset [ 4]; } mAB_Layout; typedef struct { uint8_t grid_points [16]; uint8_t grid_byte_width [ 1]; uint8_t reserved [ 3]; uint8_t variable [1/*variable*/]; } mABCLUT_Layout; static bool read_tag_mab(const skcms_ICCTag* tag, skcms_A2B* a2b, bool pcs_is_xyz) { if (tag->size < SAFE_SIZEOF(mAB_Layout)) { return false; } const mAB_Layout* mABTag = (const mAB_Layout*)tag->buf; a2b->input_channels = mABTag->input_channels[0]; a2b->output_channels = mABTag->output_channels[0]; // We require exactly three (ie XYZ/Lab/RGB) output channels if (a2b->output_channels != ARRAY_COUNT(a2b->output_curves)) { return false; } // We require no more than four (ie CMYK) input channels if (a2b->input_channels > ARRAY_COUNT(a2b->input_curves)) { return false; } uint32_t b_curve_offset = read_big_u32(mABTag->b_curve_offset); uint32_t matrix_offset = read_big_u32(mABTag->matrix_offset); uint32_t m_curve_offset = read_big_u32(mABTag->m_curve_offset); uint32_t clut_offset = read_big_u32(mABTag->clut_offset); uint32_t a_curve_offset = read_big_u32(mABTag->a_curve_offset); // "B" curves must be present if (0 == b_curve_offset) { return false; } if (!read_curves(tag->buf, tag->size, b_curve_offset, a2b->output_channels, a2b->output_curves)) { return false; } // "M" curves and Matrix must be used together if (0 != m_curve_offset) { if (0 == matrix_offset) { return false; } a2b->matrix_channels = a2b->output_channels; if (!read_curves(tag->buf, tag->size, m_curve_offset, a2b->matrix_channels, a2b->matrix_curves)) { return false; } // Read matrix, which is stored as a row-major 3x3, followed by the fourth column if (tag->size < matrix_offset + 12 * SAFE_SIZEOF(uint32_t)) { return false; } float encoding_factor = pcs_is_xyz ? 65535 / 32768.0f : 1.0f; const uint8_t* mtx_buf = tag->buf + matrix_offset; a2b->matrix.vals[0][0] = encoding_factor * read_big_fixed(mtx_buf + 0); a2b->matrix.vals[0][1] = encoding_factor * read_big_fixed(mtx_buf + 4); a2b->matrix.vals[0][2] = encoding_factor * read_big_fixed(mtx_buf + 8); a2b->matrix.vals[1][0] = encoding_factor * read_big_fixed(mtx_buf + 12); a2b->matrix.vals[1][1] = encoding_factor * read_big_fixed(mtx_buf + 16); a2b->matrix.vals[1][2] = encoding_factor * read_big_fixed(mtx_buf + 20); a2b->matrix.vals[2][0] = encoding_factor * read_big_fixed(mtx_buf + 24); a2b->matrix.vals[2][1] = encoding_factor * read_big_fixed(mtx_buf + 28); a2b->matrix.vals[2][2] = encoding_factor * read_big_fixed(mtx_buf + 32); a2b->matrix.vals[0][3] = encoding_factor * read_big_fixed(mtx_buf + 36); a2b->matrix.vals[1][3] = encoding_factor * read_big_fixed(mtx_buf + 40); a2b->matrix.vals[2][3] = encoding_factor * read_big_fixed(mtx_buf + 44); } else { if (0 != matrix_offset) { return false; } a2b->matrix_channels = 0; } // "A" curves and CLUT must be used together if (0 != a_curve_offset) { if (0 == clut_offset) { return false; } if (!read_curves(tag->buf, tag->size, a_curve_offset, a2b->input_channels, a2b->input_curves)) { return false; } if (tag->size < clut_offset + SAFE_FIXED_SIZE(mABCLUT_Layout)) { return false; } const mABCLUT_Layout* clut = (const mABCLUT_Layout*)(tag->buf + clut_offset); if (clut->grid_byte_width[0] == 1) { a2b->grid_8 = clut->variable; a2b->grid_16 = nullptr; } else if (clut->grid_byte_width[0] == 2) { a2b->grid_8 = nullptr; a2b->grid_16 = clut->variable; } else { return false; } uint64_t grid_size = a2b->output_channels * clut->grid_byte_width[0]; for (uint32_t i = 0; i < a2b->input_channels; ++i) { a2b->grid_points[i] = clut->grid_points[i]; // The grid only makes sense with at least two points along each axis if (a2b->grid_points[i] < 2) { return false; } grid_size *= a2b->grid_points[i]; } if (tag->size < clut_offset + SAFE_FIXED_SIZE(mABCLUT_Layout) + grid_size) { return false; } } else { if (0 != clut_offset) { return false; } // If there is no CLUT, the number of input and output channels must match if (a2b->input_channels != a2b->output_channels) { return false; } // Zero out the number of input channels to signal that we're skipping this stage a2b->input_channels = 0; } return true; } static int fit_linear(const skcms_Curve* curve, int N, float tol, float* c, float* d, float* f) { assert(N > 1); // We iteratively fit the first points to the TF's linear piece. // We want the cx + f line to pass through the first and last points we fit exactly. // // As we walk along the points we find the minimum and maximum slope of the line before the // error would exceed our tolerance. We stop when the range [slope_min, slope_max] becomes // emtpy, when we definitely can't add any more points. // // Some points' error intervals may intersect the running interval but not lie fully // within it. So we keep track of the last point we saw that is a valid end point candidate, // and once the search is done, back up to build the line through *that* point. const float dx = 1.0f / (N - 1); int lin_points = 1; *f = eval_curve(curve, 0); float slope_min = -INFINITY_; float slope_max = +INFINITY_; for (int i = 1; i < N; ++i) { float x = i * dx; float y = eval_curve(curve, x); float slope_max_i = (y + tol - *f) / x, slope_min_i = (y - tol - *f) / x; if (slope_max_i < slope_min || slope_max < slope_min_i) { // Slope intervals would no longer overlap. break; } slope_max = fminf_(slope_max, slope_max_i); slope_min = fmaxf_(slope_min, slope_min_i); float cur_slope = (y - *f) / x; if (slope_min <= cur_slope && cur_slope <= slope_max) { lin_points = i + 1; *c = cur_slope; } } // Set D to the last point that met our tolerance. *d = (lin_points - 1) * dx; return lin_points; } static bool read_a2b(const skcms_ICCTag* tag, skcms_A2B* a2b, bool pcs_is_xyz) { bool ok = false; if (tag->type == skcms_Signature_mft1) { ok = read_tag_mft1(tag, a2b); } else if (tag->type == skcms_Signature_mft2) { ok = read_tag_mft2(tag, a2b); } else if (tag->type == skcms_Signature_mAB) { ok = read_tag_mab(tag, a2b, pcs_is_xyz); } if (!ok) { return false; } // Detect and canonicalize identity tables. skcms_Curve* curves[] = { a2b->input_channels > 0 ? a2b->input_curves + 0 : nullptr, a2b->input_channels > 1 ? a2b->input_curves + 1 : nullptr, a2b->input_channels > 2 ? a2b->input_curves + 2 : nullptr, a2b->input_channels > 3 ? a2b->input_curves + 3 : nullptr, a2b->matrix_channels > 0 ? a2b->matrix_curves + 0 : nullptr, a2b->matrix_channels > 1 ? a2b->matrix_curves + 1 : nullptr, a2b->matrix_channels > 2 ? a2b->matrix_curves + 2 : nullptr, a2b->output_channels > 0 ? a2b->output_curves + 0 : nullptr, a2b->output_channels > 1 ? a2b->output_curves + 1 : nullptr, a2b->output_channels > 2 ? a2b->output_curves + 2 : nullptr, }; for (int i = 0; i < ARRAY_COUNT(curves); i++) { skcms_Curve* curve = curves[i]; if (curve && curve->table_entries && curve->table_entries <= (uint32_t)INT_MAX) { int N = (int)curve->table_entries; float c,d,f; if (N == fit_linear(curve, N, 1.0f/(2*N), &c,&d,&f) && c == 1.0f && f == 0.0f) { curve->table_entries = 0; curve->table_8 = nullptr; curve->table_16 = nullptr; curve->parametric = skcms_TransferFunction{1,1,0,0,0,0,0}; } } } return true; } void skcms_GetTagByIndex(const skcms_ICCProfile* profile, uint32_t idx, skcms_ICCTag* tag) { if (!profile || !profile->buffer || !tag) { return; } if (idx > profile->tag_count) { return; } const tag_Layout* tags = get_tag_table(profile); tag->signature = read_big_u32(tags[idx].signature); tag->size = read_big_u32(tags[idx].size); tag->buf = read_big_u32(tags[idx].offset) + profile->buffer; tag->type = read_big_u32(tag->buf); } bool skcms_GetTagBySignature(const skcms_ICCProfile* profile, uint32_t sig, skcms_ICCTag* tag) { if (!profile || !profile->buffer || !tag) { return false; } const tag_Layout* tags = get_tag_table(profile); for (uint32_t i = 0; i < profile->tag_count; ++i) { if (read_big_u32(tags[i].signature) == sig) { tag->signature = sig; tag->size = read_big_u32(tags[i].size); tag->buf = read_big_u32(tags[i].offset) + profile->buffer; tag->type = read_big_u32(tag->buf); return true; } } return false; } static bool usable_as_src(const skcms_ICCProfile* profile) { return profile->has_A2B || (profile->has_trc && profile->has_toXYZD50); } bool skcms_Parse(const void* buf, size_t len, skcms_ICCProfile* profile) { assert(SAFE_SIZEOF(header_Layout) == 132); if (!profile) { return false; } memset(profile, 0, SAFE_SIZEOF(*profile)); if (len < SAFE_SIZEOF(header_Layout)) { return false; } // Byte-swap all header fields const header_Layout* header = (const header_Layout*)buf; profile->buffer = (const uint8_t*)buf; profile->size = read_big_u32(header->size); uint32_t version = read_big_u32(header->version); profile->data_color_space = read_big_u32(header->data_color_space); profile->pcs = read_big_u32(header->pcs); uint32_t signature = read_big_u32(header->signature); float illuminant_X = read_big_fixed(header->illuminant_X); float illuminant_Y = read_big_fixed(header->illuminant_Y); float illuminant_Z = read_big_fixed(header->illuminant_Z); profile->tag_count = read_big_u32(header->tag_count); // Validate signature, size (smaller than buffer, large enough to hold tag table), // and major version uint64_t tag_table_size = profile->tag_count * SAFE_SIZEOF(tag_Layout); if (signature != skcms_Signature_acsp || profile->size > len || profile->size < SAFE_SIZEOF(header_Layout) + tag_table_size || (version >> 24) > 4) { return false; } // Validate that illuminant is D50 white if (fabsf_(illuminant_X - 0.9642f) > 0.0100f || fabsf_(illuminant_Y - 1.0000f) > 0.0100f || fabsf_(illuminant_Z - 0.8249f) > 0.0100f) { return false; } // Validate that all tag entries have sane offset + size const tag_Layout* tags = get_tag_table(profile); for (uint32_t i = 0; i < profile->tag_count; ++i) { uint32_t tag_offset = read_big_u32(tags[i].offset); uint32_t tag_size = read_big_u32(tags[i].size); uint64_t tag_end = (uint64_t)tag_offset + (uint64_t)tag_size; if (tag_size < 4 || tag_end > profile->size) { return false; } } if (profile->pcs != skcms_Signature_XYZ && profile->pcs != skcms_Signature_Lab) { return false; } bool pcs_is_xyz = profile->pcs == skcms_Signature_XYZ; // Pre-parse commonly used tags. skcms_ICCTag kTRC; if (profile->data_color_space == skcms_Signature_Gray && skcms_GetTagBySignature(profile, skcms_Signature_kTRC, &kTRC)) { if (!read_curve(kTRC.buf, kTRC.size, &profile->trc[0], nullptr)) { // Malformed tag return false; } profile->trc[1] = profile->trc[0]; profile->trc[2] = profile->trc[0]; profile->has_trc = true; if (pcs_is_xyz) { profile->toXYZD50.vals[0][0] = illuminant_X; profile->toXYZD50.vals[1][1] = illuminant_Y; profile->toXYZD50.vals[2][2] = illuminant_Z; profile->has_toXYZD50 = true; } } else { skcms_ICCTag rTRC, gTRC, bTRC; if (skcms_GetTagBySignature(profile, skcms_Signature_rTRC, &rTRC) && skcms_GetTagBySignature(profile, skcms_Signature_gTRC, &gTRC) && skcms_GetTagBySignature(profile, skcms_Signature_bTRC, &bTRC)) { if (!read_curve(rTRC.buf, rTRC.size, &profile->trc[0], nullptr) || !read_curve(gTRC.buf, gTRC.size, &profile->trc[1], nullptr) || !read_curve(bTRC.buf, bTRC.size, &profile->trc[2], nullptr)) { // Malformed TRC tags return false; } profile->has_trc = true; } skcms_ICCTag rXYZ, gXYZ, bXYZ; if (skcms_GetTagBySignature(profile, skcms_Signature_rXYZ, &rXYZ) && skcms_GetTagBySignature(profile, skcms_Signature_gXYZ, &gXYZ) && skcms_GetTagBySignature(profile, skcms_Signature_bXYZ, &bXYZ)) { if (!read_to_XYZD50(&rXYZ, &gXYZ, &bXYZ, &profile->toXYZD50)) { // Malformed XYZ tags return false; } profile->has_toXYZD50 = true; } } skcms_ICCTag a2b_tag; // For now, we're preferring A2B0, like Skia does and the ICC spec tells us to. // TODO: prefer A2B1 (relative colormetric) over A2B0 (perceptual)? // This breaks with the ICC spec, but we think it's a good idea, given that TRC curves // and all our known users are thinking exclusively in terms of relative colormetric. const uint32_t sigs[] = { skcms_Signature_A2B0, skcms_Signature_A2B1 }; for (int i = 0; i < ARRAY_COUNT(sigs); i++) { if (skcms_GetTagBySignature(profile, sigs[i], &a2b_tag)) { if (!read_a2b(&a2b_tag, &profile->A2B, pcs_is_xyz)) { // Malformed A2B tag return false; } profile->has_A2B = true; break; } } return usable_as_src(profile); } const skcms_ICCProfile* skcms_sRGB_profile() { static const skcms_ICCProfile sRGB_profile = { nullptr, // buffer, moot here 0, // size, moot here skcms_Signature_RGB, // data_color_space skcms_Signature_XYZ, // pcs 0, // tag count, moot here // We choose to represent sRGB with its canonical transfer function, // and with its canonical XYZD50 gamut matrix. true, // has_trc, followed by the 3 trc curves { {{0, {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0}}}, {{0, {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0}}}, {{0, {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0}}}, }, true, // has_toXYZD50, followed by 3x3 toXYZD50 matrix {{ { 0.436065674f, 0.385147095f, 0.143066406f }, { 0.222488403f, 0.716873169f, 0.060607910f }, { 0.013916016f, 0.097076416f, 0.714096069f }, }}, false, // has_A2B, followed by a2b itself which we don't care about. { 0, { {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, }, {0,0,0,0}, nullptr, nullptr, 0, { {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, }, {{ { 0,0,0,0 }, { 0,0,0,0 }, { 0,0,0,0 }, }}, 0, { {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, }, }, }; return &sRGB_profile; } const skcms_ICCProfile* skcms_XYZD50_profile() { // Just like sRGB above, but with identity transfer functions and toXYZD50 matrix. static const skcms_ICCProfile XYZD50_profile = { nullptr, // buffer, moot here 0, // size, moot here skcms_Signature_RGB, // data_color_space skcms_Signature_XYZ, // pcs 0, // tag count, moot here true, // has_trc, followed by the 3 trc curves { {{0, {1,1, 0,0,0,0,0}}}, {{0, {1,1, 0,0,0,0,0}}}, {{0, {1,1, 0,0,0,0,0}}}, }, true, // has_toXYZD50, followed by 3x3 toXYZD50 matrix {{ { 1,0,0 }, { 0,1,0 }, { 0,0,1 }, }}, false, // has_A2B, followed by a2b itself which we don't care about. { 0, { {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, }, {0,0,0,0}, nullptr, nullptr, 0, { {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, }, {{ { 0,0,0,0 }, { 0,0,0,0 }, { 0,0,0,0 }, }}, 0, { {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, {{0, {0,0, 0,0,0,0,0}}}, }, }, }; return &XYZD50_profile; } const skcms_TransferFunction* skcms_sRGB_TransferFunction() { return &skcms_sRGB_profile()->trc[0].parametric; } const skcms_TransferFunction* skcms_sRGB_Inverse_TransferFunction() { static const skcms_TransferFunction sRGB_inv = { (float)(1/2.4), 1.137119f, 0, 12.92f, 0.0031308f, -0.055f, 0 }; return &sRGB_inv; } const skcms_TransferFunction* skcms_Identity_TransferFunction() { static const skcms_TransferFunction identity = {1,1,0,0,0,0,0}; return &identity; } const uint8_t skcms_252_random_bytes[] = { 8, 179, 128, 204, 253, 38, 134, 184, 68, 102, 32, 138, 99, 39, 169, 215, 119, 26, 3, 223, 95, 239, 52, 132, 114, 74, 81, 234, 97, 116, 244, 205, 30, 154, 173, 12, 51, 159, 122, 153, 61, 226, 236, 178, 229, 55, 181, 220, 191, 194, 160, 126, 168, 82, 131, 18, 180, 245, 163, 22, 246, 69, 235, 252, 57, 108, 14, 6, 152, 240, 255, 171, 242, 20, 227, 177, 238, 96, 85, 16, 211, 70, 200, 149, 155, 146, 127, 145, 100, 151, 109, 19, 165, 208, 195, 164, 137, 254, 182, 248, 64, 201, 45, 209, 5, 147, 207, 210, 113, 162, 83, 225, 9, 31, 15, 231, 115, 37, 58, 53, 24, 49, 197, 56, 120, 172, 48, 21, 214, 129, 111, 11, 50, 187, 196, 34, 60, 103, 71, 144, 47, 203, 77, 80, 232, 140, 222, 250, 206, 166, 247, 139, 249, 221, 72, 106, 27, 199, 117, 54, 219, 135, 118, 40, 79, 41, 251, 46, 93, 212, 92, 233, 148, 28, 121, 63, 123, 158, 105, 59, 29, 42, 143, 23, 0, 107, 176, 87, 104, 183, 156, 193, 189, 90, 188, 65, 190, 17, 198, 7, 186, 161, 1, 124, 78, 125, 170, 133, 174, 218, 67, 157, 75, 101, 89, 217, 62, 33, 141, 228, 25, 35, 91, 230, 4, 2, 13, 73, 86, 167, 237, 84, 243, 44, 185, 66, 130, 110, 150, 142, 216, 88, 112, 36, 224, 136, 202, 76, 94, 98, 175, 213 }; bool skcms_ApproximatelyEqualProfiles(const skcms_ICCProfile* A, const skcms_ICCProfile* B) { // Test for exactly equal profiles first. if (A == B || 0 == memcmp(A,B, sizeof(skcms_ICCProfile))) { return true; } // For now this is the essentially the same strategy we use in test_only.c // for our skcms_Transform() smoke tests: // 1) transform A to XYZD50 // 2) transform B to XYZD50 // 3) return true if they're similar enough // Our current criterion in 3) is maximum 1 bit error per XYZD50 byte. // skcms_252_random_bytes are 252 of a random shuffle of all possible bytes. // 252 is evenly divisible by 3 and 4. Only 192, 10, 241, and 43 are missing. if (A->data_color_space != B->data_color_space) { return false; } // Interpret as RGB_888 if data color space is RGB or GRAY, RGBA_8888 if CMYK. // TODO: working with RGBA_8888 either way is probably fastest. skcms_PixelFormat fmt = skcms_PixelFormat_RGB_888; size_t npixels = 84; if (A->data_color_space == skcms_Signature_CMYK) { fmt = skcms_PixelFormat_RGBA_8888; npixels = 63; } // TODO: if A or B is a known profile (skcms_sRGB_profile, skcms_XYZD50_profile), // use pre-canned results and skip that skcms_Transform() call? uint8_t dstA[252], dstB[252]; if (!skcms_Transform( skcms_252_random_bytes, fmt, skcms_AlphaFormat_Unpremul, A, dstA, skcms_PixelFormat_RGB_888, skcms_AlphaFormat_Unpremul, skcms_XYZD50_profile(), npixels)) { return false; } if (!skcms_Transform( skcms_252_random_bytes, fmt, skcms_AlphaFormat_Unpremul, B, dstB, skcms_PixelFormat_RGB_888, skcms_AlphaFormat_Unpremul, skcms_XYZD50_profile(), npixels)) { return false; } // TODO: make sure this final check has reasonable codegen. for (size_t i = 0; i < 252; i++) { if (abs((int)dstA[i] - (int)dstB[i]) > 1) { return false; } } return true; } bool skcms_TRCs_AreApproximateInverse(const skcms_ICCProfile* profile, const skcms_TransferFunction* inv_tf) { if (!profile || !profile->has_trc) { return false; } return skcms_AreApproximateInverses(&profile->trc[0], inv_tf) && skcms_AreApproximateInverses(&profile->trc[1], inv_tf) && skcms_AreApproximateInverses(&profile->trc[2], inv_tf); } static bool is_zero_to_one(float x) { return 0 <= x && x <= 1; } typedef struct { float vals[3]; } skcms_Vector3; static skcms_Vector3 mv_mul(const skcms_Matrix3x3* m, const skcms_Vector3* v) { skcms_Vector3 dst = {{0,0,0}}; for (int row = 0; row < 3; ++row) { dst.vals[row] = m->vals[row][0] * v->vals[0] + m->vals[row][1] * v->vals[1] + m->vals[row][2] * v->vals[2]; } return dst; } bool skcms_PrimariesToXYZD50(float rx, float ry, float gx, float gy, float bx, float by, float wx, float wy, skcms_Matrix3x3* toXYZD50) { if (!is_zero_to_one(rx) || !is_zero_to_one(ry) || !is_zero_to_one(gx) || !is_zero_to_one(gy) || !is_zero_to_one(bx) || !is_zero_to_one(by) || !is_zero_to_one(wx) || !is_zero_to_one(wy) || !toXYZD50) { return false; } // First, we need to convert xy values (primaries) to XYZ. skcms_Matrix3x3 primaries = {{ { rx, gx, bx }, { ry, gy, by }, { 1 - rx - ry, 1 - gx - gy, 1 - bx - by }, }}; skcms_Matrix3x3 primaries_inv; if (!skcms_Matrix3x3_invert(&primaries, &primaries_inv)) { return false; } // Assumes that Y is 1.0f. skcms_Vector3 wXYZ = { { wx / wy, 1, (1 - wx - wy) / wy } }; skcms_Vector3 XYZ = mv_mul(&primaries_inv, &wXYZ); skcms_Matrix3x3 toXYZ = {{ { XYZ.vals[0], 0, 0 }, { 0, XYZ.vals[1], 0 }, { 0, 0, XYZ.vals[2] }, }}; toXYZ = skcms_Matrix3x3_concat(&primaries, &toXYZ); // Now convert toXYZ matrix to toXYZD50. skcms_Vector3 wXYZD50 = { { 0.96422f, 1.0f, 0.82521f } }; // Calculate the chromatic adaptation matrix. We will use the Bradford method, thus // the matrices below. The Bradford method is used by Adobe and is widely considered // to be the best. skcms_Matrix3x3 xyz_to_lms = {{ { 0.8951f, 0.2664f, -0.1614f }, { -0.7502f, 1.7135f, 0.0367f }, { 0.0389f, -0.0685f, 1.0296f }, }}; skcms_Matrix3x3 lms_to_xyz = {{ { 0.9869929f, -0.1470543f, 0.1599627f }, { 0.4323053f, 0.5183603f, 0.0492912f }, { -0.0085287f, 0.0400428f, 0.9684867f }, }}; skcms_Vector3 srcCone = mv_mul(&xyz_to_lms, &wXYZ); skcms_Vector3 dstCone = mv_mul(&xyz_to_lms, &wXYZD50); skcms_Matrix3x3 DXtoD50 = {{ { dstCone.vals[0] / srcCone.vals[0], 0, 0 }, { 0, dstCone.vals[1] / srcCone.vals[1], 0 }, { 0, 0, dstCone.vals[2] / srcCone.vals[2] }, }}; DXtoD50 = skcms_Matrix3x3_concat(&DXtoD50, &xyz_to_lms); DXtoD50 = skcms_Matrix3x3_concat(&lms_to_xyz, &DXtoD50); *toXYZD50 = skcms_Matrix3x3_concat(&DXtoD50, &toXYZ); return true; } bool skcms_Matrix3x3_invert(const skcms_Matrix3x3* src, skcms_Matrix3x3* dst) { double a00 = src->vals[0][0], a01 = src->vals[1][0], a02 = src->vals[2][0], a10 = src->vals[0][1], a11 = src->vals[1][1], a12 = src->vals[2][1], a20 = src->vals[0][2], a21 = src->vals[1][2], a22 = src->vals[2][2]; double b0 = a00*a11 - a01*a10, b1 = a00*a12 - a02*a10, b2 = a01*a12 - a02*a11, b3 = a20, b4 = a21, b5 = a22; double determinant = b0*b5 - b1*b4 + b2*b3; if (determinant == 0) { return false; } double invdet = 1.0 / determinant; if (invdet > +FLT_MAX || invdet < -FLT_MAX || !isfinitef_((float)invdet)) { return false; } b0 *= invdet; b1 *= invdet; b2 *= invdet; b3 *= invdet; b4 *= invdet; b5 *= invdet; dst->vals[0][0] = (float)( a11*b5 - a12*b4 ); dst->vals[1][0] = (float)( a02*b4 - a01*b5 ); dst->vals[2][0] = (float)( + b2 ); dst->vals[0][1] = (float)( a12*b3 - a10*b5 ); dst->vals[1][1] = (float)( a00*b5 - a02*b3 ); dst->vals[2][1] = (float)( - b1 ); dst->vals[0][2] = (float)( a10*b4 - a11*b3 ); dst->vals[1][2] = (float)( a01*b3 - a00*b4 ); dst->vals[2][2] = (float)( + b0 ); for (int r = 0; r < 3; ++r) for (int c = 0; c < 3; ++c) { if (!isfinitef_(dst->vals[r][c])) { return false; } } return true; } skcms_Matrix3x3 skcms_Matrix3x3_concat(const skcms_Matrix3x3* A, const skcms_Matrix3x3* B) { skcms_Matrix3x3 m = { { { 0,0,0 },{ 0,0,0 },{ 0,0,0 } } }; for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) { m.vals[r][c] = A->vals[r][0] * B->vals[0][c] + A->vals[r][1] * B->vals[1][c] + A->vals[r][2] * B->vals[2][c]; } return m; } #if defined(__clang__) || defined(__GNUC__) #define small_memcpy __builtin_memcpy #else #define small_memcpy memcpy #endif static float log2f_(float x) { // The first approximation of log2(x) is its exponent 'e', minus 127. int32_t bits; small_memcpy(&bits, &x, sizeof(bits)); float e = (float)bits * (1.0f / (1<<23)); // If we use the mantissa too we can refine the error signficantly. int32_t m_bits = (bits & 0x007fffff) | 0x3f000000; float m; small_memcpy(&m, &m_bits, sizeof(m)); return (e - 124.225514990f - 1.498030302f*m - 1.725879990f/(0.3520887068f + m)); } static float exp2f_(float x) { float fract = x - floorf_(x); float fbits = (1.0f * (1<<23)) * (x + 121.274057500f - 1.490129070f*fract + 27.728023300f/(4.84252568f - fract)); if (fbits > INT_MAX) { return INFINITY_; } else if (fbits < INT_MIN) { return -INFINITY_; } int32_t bits = (int32_t)fbits; small_memcpy(&x, &bits, sizeof(x)); return x; } float powf_(float x, float y) { return (x == 0) || (x == 1) ? x : exp2f_(log2f_(x) * y); } float skcms_TransferFunction_eval(const skcms_TransferFunction* tf, float x) { float sign = x < 0 ? -1.0f : 1.0f; x *= sign; return sign * (x < tf->d ? tf->c * x + tf->f : powf_(tf->a * x + tf->b, tf->g) + tf->e); } // TODO: Adjust logic here? This still assumes that purely linear inputs will have D > 1, which // we never generate. It also emits inverted linear using the same formulation. Standardize on // G == 1 here, too? bool skcms_TransferFunction_invert(const skcms_TransferFunction* src, skcms_TransferFunction* dst) { // Original equation is: y = (ax + b)^g + e for x >= d // y = cx + f otherwise // // so 1st inverse is: (y - e)^(1/g) = ax + b // x = ((y - e)^(1/g) - b) / a // // which can be re-written as: x = (1/a)(y - e)^(1/g) - b/a // x = ((1/a)^g)^(1/g) * (y - e)^(1/g) - b/a // x = ([(1/a)^g]y + [-((1/a)^g)e]) ^ [1/g] + [-b/a] // // and 2nd inverse is: x = (y - f) / c // which can be re-written as: x = [1/c]y + [-f/c] // // and now both can be expressed in terms of the same parametric form as the // original - parameters are enclosed in square brackets. skcms_TransferFunction tf_inv = { 0, 0, 0, 0, 0, 0, 0 }; // This rejects obviously malformed inputs, as well as decreasing functions if (!tf_is_valid(src)) { return false; } // There are additional constraints to be invertible bool has_nonlinear = (src->d <= 1); bool has_linear = (src->d > 0); // Is the linear section not invertible? if (has_linear && src->c == 0) { return false; } // Is the nonlinear section not invertible? if (has_nonlinear && (src->a == 0 || src->g == 0)) { return false; } // If both segments are present, they need to line up if (has_linear && has_nonlinear) { float l_at_d = src->c * src->d + src->f; float n_at_d = powf_(src->a * src->d + src->b, src->g) + src->e; if (fabsf_(l_at_d - n_at_d) > (1 / 512.0f)) { return false; } } // Invert linear segment if (has_linear) { tf_inv.c = 1.0f / src->c; tf_inv.f = -src->f / src->c; } // Invert nonlinear segment if (has_nonlinear) { tf_inv.g = 1.0f / src->g; tf_inv.a = powf_(1.0f / src->a, src->g); tf_inv.b = -tf_inv.a * src->e; tf_inv.e = -src->b / src->a; } if (!has_linear) { tf_inv.d = 0; } else if (!has_nonlinear) { // Any value larger than 1 works tf_inv.d = 2.0f; } else { tf_inv.d = src->c * src->d + src->f; } *dst = tf_inv; return true; } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // From here below we're approximating an skcms_Curve with an skcms_TransferFunction{g,a,b,c,d,e,f}: // // tf(x) = cx + f x < d // tf(x) = (ax + b)^g + e x โ‰ฅ d // // When fitting, we add the additional constraint that both pieces meet at d: // // cd + f = (ad + b)^g + e // // Solving for e and folding it through gives an alternate formulation of the non-linear piece: // // tf(x) = cx + f x < d // tf(x) = (ax + b)^g - (ad + b)^g + cd + f x โ‰ฅ d // // Our overall strategy is then: // For a couple tolerances, // - fit_linear(): fit c,d,f iteratively to as many points as our tolerance allows // - invert c,d,f // - fit_nonlinear(): fit g,a,b using Gauss-Newton given those inverted c,d,f // (and by constraint, inverted e) to the inverse of the table. // Return the parameters with least maximum error. // // To run Gauss-Newton to find g,a,b, we'll also need the gradient of the residuals // of round-trip f_inv(x), the inverse of the non-linear piece of f(x). // // let y = Table(x) // r(x) = x - f_inv(y) // // โˆ‚r/โˆ‚g = ln(ay + b)*(ay + b)^g // - ln(ad + b)*(ad + b)^g // โˆ‚r/โˆ‚a = yg(ay + b)^(g-1) // - dg(ad + b)^(g-1) // โˆ‚r/โˆ‚b = g(ay + b)^(g-1) // - g(ad + b)^(g-1) // Return the residual of roundtripping skcms_Curve(x) through f_inv(y) with parameters P, // and fill out the gradient of the residual into dfdP. static float rg_nonlinear(float x, const skcms_Curve* curve, const skcms_TransferFunction* tf, const float P[3], float dfdP[3]) { const float y = eval_curve(curve, x); const float g = P[0], a = P[1], b = P[2], c = tf->c, d = tf->d, f = tf->f; const float Y = fmaxf_(a*y + b, 0.0f), D = a*d + b; assert (D >= 0); // The gradient. dfdP[0] = 0.69314718f*log2f_(Y)*powf_(Y, g) - 0.69314718f*log2f_(D)*powf_(D, g); dfdP[1] = y*g*powf_(Y, g-1) - d*g*powf_(D, g-1); dfdP[2] = g*powf_(Y, g-1) - g*powf_(D, g-1); // The residual. const float f_inv = powf_(Y, g) - powf_(D, g) + c*d + f; return x - f_inv; } static bool gauss_newton_step(const skcms_Curve* curve, const skcms_TransferFunction* tf, float P[3], float x0, float dx, int N) { // We'll sample x from the range [x0,x1] (both inclusive) N times with even spacing. // // We want to do P' = P + (Jf^T Jf)^-1 Jf^T r(P), // where r(P) is the residual vector // and Jf is the Jacobian matrix of f(), โˆ‚r/โˆ‚P. // // Let's review the shape of each of these expressions: // r(P) is [N x 1], a column vector with one entry per value of x tested // Jf is [N x 3], a matrix with an entry for each (x,P) pair // Jf^T is [3 x N], the transpose of Jf // // Jf^T Jf is [3 x N] * [N x 3] == [3 x 3], a 3x3 matrix, // and so is its inverse (Jf^T Jf)^-1 // Jf^T r(P) is [3 x N] * [N x 1] == [3 x 1], a column vector with the same shape as P // // Our implementation strategy to get to the final โˆ†P is // 1) evaluate Jf^T Jf, call that lhs // 2) evaluate Jf^T r(P), call that rhs // 3) invert lhs // 4) multiply inverse lhs by rhs // // This is a friendly implementation strategy because we don't have to have any // buffers that scale with N, and equally nice don't have to perform any matrix // operations that are variable size. // // Other implementation strategies could trade this off, e.g. evaluating the // pseudoinverse of Jf ( (Jf^T Jf)^-1 Jf^T ) directly, then multiplying that by // the residuals. That would probably require implementing singular value // decomposition, and would create a [3 x N] matrix to be multiplied by the // [N x 1] residual vector, but on the upside I think that'd eliminate the // possibility of this gauss_newton_step() function ever failing. // 0) start off with lhs and rhs safely zeroed. skcms_Matrix3x3 lhs = {{ {0,0,0}, {0,0,0}, {0,0,0} }}; skcms_Vector3 rhs = { {0,0,0} }; // 1,2) evaluate lhs and evaluate rhs // We want to evaluate Jf only once, but both lhs and rhs involve Jf^T, // so we'll have to update lhs and rhs at the same time. for (int i = 0; i < N; i++) { float x = x0 + i*dx; float dfdP[3] = {0,0,0}; float resid = rg_nonlinear(x,curve,tf,P, dfdP); for (int r = 0; r < 3; r++) { for (int c = 0; c < 3; c++) { lhs.vals[r][c] += dfdP[r] * dfdP[c]; } rhs.vals[r] += dfdP[r] * resid; } } // If any of the 3 P parameters are unused, this matrix will be singular. // Detect those cases and fix them up to indentity instead, so we can invert. for (int k = 0; k < 3; k++) { if (lhs.vals[0][k]==0 && lhs.vals[1][k]==0 && lhs.vals[2][k]==0 && lhs.vals[k][0]==0 && lhs.vals[k][1]==0 && lhs.vals[k][2]==0) { lhs.vals[k][k] = 1; } } // 3) invert lhs skcms_Matrix3x3 lhs_inv; if (!skcms_Matrix3x3_invert(&lhs, &lhs_inv)) { return false; } // 4) multiply inverse lhs by rhs skcms_Vector3 dP = mv_mul(&lhs_inv, &rhs); P[0] += dP.vals[0]; P[1] += dP.vals[1]; P[2] += dP.vals[2]; return isfinitef_(P[0]) && isfinitef_(P[1]) && isfinitef_(P[2]); } // Fit the points in [L,N) to the non-linear piece of tf, or return false if we can't. static bool fit_nonlinear(const skcms_Curve* curve, int L, int N, skcms_TransferFunction* tf) { float P[3] = { tf->g, tf->a, tf->b }; // No matter where we start, dx should always represent N even steps from 0 to 1. const float dx = 1.0f / (N-1); for (int j = 0; j < 3/*TODO: tune*/; j++) { // These extra constraints a >= 0 and ad+b >= 0 are not modeled in the optimization. // We don't really know how to fix up a if it goes negative. if (P[1] < 0) { return false; } // If ad+b goes negative, we feel just barely not uneasy enough to tweak b so ad+b is zero. if (P[1] * tf->d + P[2] < 0) { P[2] = -P[1] * tf->d; } assert (P[1] >= 0 && P[1] * tf->d + P[2] >= 0); if (!gauss_newton_step(curve, tf, P, L*dx, dx, N-L)) { return false; } } // We need to apply our fixups one last time if (P[1] < 0) { return false; } if (P[1] * tf->d + P[2] < 0) { P[2] = -P[1] * tf->d; } tf->g = P[0]; tf->a = P[1]; tf->b = P[2]; tf->e = tf->c*tf->d + tf->f - powf_(tf->a*tf->d + tf->b, tf->g); return true; } bool skcms_ApproximateCurve(const skcms_Curve* curve, skcms_TransferFunction* approx, float* max_error) { if (!curve || !approx || !max_error) { return false; } if (curve->table_entries == 0) { // No point approximating an skcms_TransferFunction with an skcms_TransferFunction! return false; } if (curve->table_entries == 1 || curve->table_entries > (uint32_t)INT_MAX) { // We need at least two points, and must put some reasonable cap on the maximum number. return false; } int N = (int)curve->table_entries; const float dx = 1.0f / (N - 1); *max_error = INFINITY_; const float kTolerances[] = { 1.5f / 65535.0f, 1.0f / 512.0f }; for (int t = 0; t < ARRAY_COUNT(kTolerances); t++) { skcms_TransferFunction tf, tf_inv; int L = fit_linear(curve, N, kTolerances[t], &tf.c, &tf.d, &tf.f); if (L == N) { // If the entire data set was linear, move the coefficients to the nonlinear portion // with G == 1. This lets use a canonical representation with d == 0. tf.g = 1; tf.a = tf.c; tf.b = tf.f; tf.c = tf.d = tf.e = tf.f = 0; } else if (L == N - 1) { // Degenerate case with only two points in the nonlinear segment. Solve directly. tf.g = 1; tf.a = (eval_curve(curve, (N-1)*dx) - eval_curve(curve, (N-2)*dx)) / dx; tf.b = eval_curve(curve, (N-2)*dx) - tf.a * (N-2)*dx; tf.e = 0; } else { // Start by guessing a gamma-only curve through the midpoint. int mid = (L + N) / 2; float mid_x = mid / (N - 1.0f); float mid_y = eval_curve(curve, mid_x); tf.g = log2f_(mid_y) / log2f_(mid_x);; tf.a = 1; tf.b = 0; tf.e = tf.c*tf.d + tf.f - powf_(tf.a*tf.d + tf.b, tf.g); if (!skcms_TransferFunction_invert(&tf, &tf_inv) || !fit_nonlinear(curve, L,N, &tf_inv)) { continue; } // We fit tf_inv, so calculate tf to keep in sync. if (!skcms_TransferFunction_invert(&tf_inv, &tf)) { continue; } } // We find our error by roundtripping the table through tf_inv. // // (The most likely use case for this approximation is to be inverted and // used as the transfer function for a destination color space.) // // We've kept tf and tf_inv in sync above, but we can't guarantee that tf is // invertible, so re-verify that here (and use the new inverse for testing). if (!skcms_TransferFunction_invert(&tf, &tf_inv)) { continue; } float err = max_roundtrip_error(curve, &tf_inv); if (*max_error > err) { *max_error = err; *approx = tf; } } return isfinitef_(*max_error); } // ~~~~ Impl. of skcms_Transform() ~~~~ typedef enum { Op_load_a8, Op_load_g8, Op_load_4444, Op_load_565, Op_load_888, Op_load_8888, Op_load_1010102, Op_load_161616LE, Op_load_16161616LE, Op_load_161616BE, Op_load_16161616BE, Op_load_hhh, Op_load_hhhh, Op_load_fff, Op_load_ffff, Op_swap_rb, Op_clamp, Op_invert, Op_force_opaque, Op_premul, Op_unpremul, Op_matrix_3x3, Op_matrix_3x4, Op_lab_to_xyz, Op_tf_r, Op_tf_g, Op_tf_b, Op_tf_a, Op_table_8_r, Op_table_8_g, Op_table_8_b, Op_table_8_a, Op_table_16_r, Op_table_16_g, Op_table_16_b, Op_table_16_a, Op_clut_1D_8, Op_clut_1D_16, Op_clut_2D_8, Op_clut_2D_16, Op_clut_3D_8, Op_clut_3D_16, Op_clut_4D_8, Op_clut_4D_16, Op_store_a8, Op_store_g8, Op_store_4444, Op_store_565, Op_store_888, Op_store_8888, Op_store_1010102, Op_store_161616LE, Op_store_16161616LE, Op_store_161616BE, Op_store_16161616BE, Op_store_hhh, Op_store_hhhh, Op_store_fff, Op_store_ffff, } Op; // Without this wasm would try to use the N=4 128-bit vector code path, // which while ideal, causes tons of compiler problems. This would be // a good thing to revisit as emcc matures (currently 1.38.5). #if 1 && defined(__EMSCRIPTEN_major__) #if !defined(SKCMS_PORTABLE) #define SKCMS_PORTABLE #endif #endif #if defined(__clang__) template <int N, typename T> using Vec = T __attribute__((ext_vector_type(N))); #elif defined(__GNUC__) // For some reason GCC accepts this nonsense, but not the more straightforward version, // template <int N, typename T> using Vec = T __attribute__((vector_size(N*sizeof(T)))); template <int N, typename T> struct VecHelper { typedef T __attribute__((vector_size(N*sizeof(T)))) V; }; template <int N, typename T> using Vec = typename VecHelper<N,T>::V; #endif // First, instantiate our default exec_ops() implementation using the default compiliation target. namespace baseline { #if defined(SKCMS_PORTABLE) || !(defined(__clang__) || defined(__GNUC__)) #define N 1 using F = float; using U64 = uint64_t; using U32 = uint32_t; using I32 = int32_t; using U16 = uint16_t; using U8 = uint8_t; #elif defined(__AVX512F__) #define N 16 using F = Vec<N,float>; using I32 = Vec<N,int32_t>; using U64 = Vec<N,uint64_t>; using U32 = Vec<N,uint32_t>; using U16 = Vec<N,uint16_t>; using U8 = Vec<N,uint8_t>; #elif defined(__AVX__) #define N 8 using F = Vec<N,float>; using I32 = Vec<N,int32_t>; using U64 = Vec<N,uint64_t>; using U32 = Vec<N,uint32_t>; using U16 = Vec<N,uint16_t>; using U8 = Vec<N,uint8_t>; #else #define N 4 using F = Vec<N,float>; using I32 = Vec<N,int32_t>; using U64 = Vec<N,uint64_t>; using U32 = Vec<N,uint32_t>; using U16 = Vec<N,uint16_t>; using U8 = Vec<N,uint8_t>; #endif #include "src/Transform_inl.h" #undef N } // Now, instantiate any other versions of run_program() we may want for runtime detection. #if !defined(SKCMS_PORTABLE) && \ (( defined(__clang__) && __clang_major__ >= 5) || \ (!defined(__clang__) && defined(__GNUC__))) \ && defined(__x86_64__) && !defined(__AVX2__) #if defined(__clang__) #pragma clang attribute push(__attribute__((target("avx2,f16c"))), apply_to=function) #elif defined(__GNUC__) #pragma GCC push_options #pragma GCC target("avx2,f16c") #endif namespace hsw { #define USING_AVX #define USING_AVX_F16C #define USING_AVX2 #define N 8 using F = Vec<N,float>; using I32 = Vec<N,int32_t>; using U64 = Vec<N,uint64_t>; using U32 = Vec<N,uint32_t>; using U16 = Vec<N,uint16_t>; using U8 = Vec<N,uint8_t>; #include "src/Transform_inl.h" // src/Transform_inl.h will undefine USING_* for us. #undef N } #if defined(__clang__) #pragma clang attribute pop #elif defined(__GNUC__) #pragma GCC pop_options #endif #define TEST_FOR_HSW static bool hsw_ok() { static const bool ok = []{ // See http://www.sandpile.org/x86/cpuid.htm // First, a basic cpuid(1). uint32_t eax, ebx, ecx, edx; __asm__ __volatile__("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "0"(1), "2"(0)); // Sanity check for prerequisites. if ((edx & (1<<25)) != (1<<25)) { return false; } // SSE if ((edx & (1<<26)) != (1<<26)) { return false; } // SSE2 if ((ecx & (1<< 0)) != (1<< 0)) { return false; } // SSE3 if ((ecx & (1<< 9)) != (1<< 9)) { return false; } // SSSE3 if ((ecx & (1<<19)) != (1<<19)) { return false; } // SSE4.1 if ((ecx & (1<<20)) != (1<<20)) { return false; } // SSE4.2 if ((ecx & (3<<26)) != (3<<26)) { return false; } // XSAVE + OSXSAVE { uint32_t eax_xgetbv, edx_xgetbv; __asm__ __volatile__("xgetbv" : "=a"(eax_xgetbv), "=d"(edx_xgetbv) : "c"(0)); if ((eax_xgetbv & (3<<1)) != (3<<1)) { return false; } // XMM+YMM state saved? } if ((ecx & (1<<28)) != (1<<28)) { return false; } // AVX if ((ecx & (1<<29)) != (1<<29)) { return false; } // F16C if ((ecx & (1<<12)) != (1<<12)) { return false; } // FMA (TODO: not currently used) // Call cpuid(7) to check for our final AVX2 feature bit! __asm__ __volatile__("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "0"(7), "2"(0)); if ((ebx & (1<< 5)) != (1<< 5)) { return false; } // AVX2 return true; }(); return ok; } #endif static bool is_identity_tf(const skcms_TransferFunction* tf) { return tf->g == 1 && tf->a == 1 && tf->b == 0 && tf->c == 0 && tf->d == 0 && tf->e == 0 && tf->f == 0; } typedef struct { Op op; const void* arg; } OpAndArg; static OpAndArg select_curve_op(const skcms_Curve* curve, int channel) { static const struct { Op parametric, table_8, table_16; } ops[] = { { Op_tf_r, Op_table_8_r, Op_table_16_r }, { Op_tf_g, Op_table_8_g, Op_table_16_g }, { Op_tf_b, Op_table_8_b, Op_table_16_b }, { Op_tf_a, Op_table_8_a, Op_table_16_a }, }; const OpAndArg noop = { Op_load_a8/*doesn't matter*/, nullptr }; if (curve->table_entries == 0) { return is_identity_tf(&curve->parametric) ? noop : OpAndArg{ ops[channel].parametric, &curve->parametric }; } else if (curve->table_8) { return OpAndArg{ ops[channel].table_8, curve }; } else if (curve->table_16) { return OpAndArg{ ops[channel].table_16, curve }; } assert(false); return noop; } static size_t bytes_per_pixel(skcms_PixelFormat fmt) { switch (fmt >> 1) { // ignore rgb/bgr case skcms_PixelFormat_A_8 >> 1: return 1; case skcms_PixelFormat_G_8 >> 1: return 1; case skcms_PixelFormat_ABGR_4444 >> 1: return 2; case skcms_PixelFormat_RGB_565 >> 1: return 2; case skcms_PixelFormat_RGB_888 >> 1: return 3; case skcms_PixelFormat_RGBA_8888 >> 1: return 4; case skcms_PixelFormat_RGBA_1010102 >> 1: return 4; case skcms_PixelFormat_RGB_161616LE >> 1: return 6; case skcms_PixelFormat_RGBA_16161616LE >> 1: return 8; case skcms_PixelFormat_RGB_161616BE >> 1: return 6; case skcms_PixelFormat_RGBA_16161616BE >> 1: return 8; case skcms_PixelFormat_RGB_hhh >> 1: return 6; case skcms_PixelFormat_RGBA_hhhh >> 1: return 8; case skcms_PixelFormat_RGB_fff >> 1: return 12; case skcms_PixelFormat_RGBA_ffff >> 1: return 16; } assert(false); return 0; } static bool prep_for_destination(const skcms_ICCProfile* profile, skcms_Matrix3x3* fromXYZD50, skcms_TransferFunction* invR, skcms_TransferFunction* invG, skcms_TransferFunction* invB) { // We only support destinations with parametric transfer functions // and with gamuts that can be transformed from XYZD50. return profile->has_trc && profile->has_toXYZD50 && profile->trc[0].table_entries == 0 && profile->trc[1].table_entries == 0 && profile->trc[2].table_entries == 0 && skcms_TransferFunction_invert(&profile->trc[0].parametric, invR) && skcms_TransferFunction_invert(&profile->trc[1].parametric, invG) && skcms_TransferFunction_invert(&profile->trc[2].parametric, invB) && skcms_Matrix3x3_invert(&profile->toXYZD50, fromXYZD50); } bool skcms_Transform(const void* src, skcms_PixelFormat srcFmt, skcms_AlphaFormat srcAlpha, const skcms_ICCProfile* srcProfile, void* dst, skcms_PixelFormat dstFmt, skcms_AlphaFormat dstAlpha, const skcms_ICCProfile* dstProfile, size_t nz) { const size_t dst_bpp = bytes_per_pixel(dstFmt), src_bpp = bytes_per_pixel(srcFmt); // Let's just refuse if the request is absurdly big. if (nz * dst_bpp > INT_MAX || nz * src_bpp > INT_MAX) { return false; } int n = (int)nz; // Null profiles default to sRGB. Passing null for both is handy when doing format conversion. if (!srcProfile) { srcProfile = skcms_sRGB_profile(); } if (!dstProfile) { dstProfile = skcms_sRGB_profile(); } // We can't transform in place unless the PixelFormats are the same size. if (dst == src && dst_bpp != src_bpp) { return false; } // TODO: more careful alias rejection (like, dst == src + 1)? Op program [32]; const void* arguments[32]; Op* ops = program; const void** args = arguments; skcms_TransferFunction inv_dst_tf_r, inv_dst_tf_g, inv_dst_tf_b; skcms_Matrix3x3 from_xyz; switch (srcFmt >> 1) { default: return false; case skcms_PixelFormat_A_8 >> 1: *ops++ = Op_load_a8; break; case skcms_PixelFormat_G_8 >> 1: *ops++ = Op_load_g8; break; case skcms_PixelFormat_ABGR_4444 >> 1: *ops++ = Op_load_4444; break; case skcms_PixelFormat_RGB_565 >> 1: *ops++ = Op_load_565; break; case skcms_PixelFormat_RGB_888 >> 1: *ops++ = Op_load_888; break; case skcms_PixelFormat_RGBA_8888 >> 1: *ops++ = Op_load_8888; break; case skcms_PixelFormat_RGBA_1010102 >> 1: *ops++ = Op_load_1010102; break; case skcms_PixelFormat_RGB_161616LE >> 1: *ops++ = Op_load_161616LE; break; case skcms_PixelFormat_RGBA_16161616LE >> 1: *ops++ = Op_load_16161616LE; break; case skcms_PixelFormat_RGB_161616BE >> 1: *ops++ = Op_load_161616BE; break; case skcms_PixelFormat_RGBA_16161616BE >> 1: *ops++ = Op_load_16161616BE; break; case skcms_PixelFormat_RGB_hhh >> 1: *ops++ = Op_load_hhh; break; case skcms_PixelFormat_RGBA_hhhh >> 1: *ops++ = Op_load_hhhh; break; case skcms_PixelFormat_RGB_fff >> 1: *ops++ = Op_load_fff; break; case skcms_PixelFormat_RGBA_ffff >> 1: *ops++ = Op_load_ffff; break; } if (srcFmt & 1) { *ops++ = Op_swap_rb; } skcms_ICCProfile gray_dst_profile; if ((dstFmt >> 1) == (skcms_PixelFormat_G_8 >> 1)) { // When transforming to gray, stop at XYZ (by setting toXYZ to identity), then transform // luminance (Y) by the destination transfer function. gray_dst_profile = *dstProfile; skcms_SetXYZD50(&gray_dst_profile, &skcms_XYZD50_profile()->toXYZD50); dstProfile = &gray_dst_profile; } if (srcProfile->data_color_space == skcms_Signature_CMYK) { // Photoshop creates CMYK images as inverse CMYK. // These happen to be the only ones we've _ever_ seen. *ops++ = Op_invert; // With CMYK, ignore the alpha type, to avoid changing K or conflating CMY with K. srcAlpha = skcms_AlphaFormat_Unpremul; } if (srcAlpha == skcms_AlphaFormat_Opaque) { *ops++ = Op_force_opaque; } else if (srcAlpha == skcms_AlphaFormat_PremulAsEncoded) { *ops++ = Op_unpremul; } if (dstProfile != srcProfile) { if (!prep_for_destination(dstProfile, &from_xyz, &inv_dst_tf_r, &inv_dst_tf_b, &inv_dst_tf_g)) { return false; } if (srcProfile->has_A2B) { if (srcProfile->A2B.input_channels) { for (int i = 0; i < (int)srcProfile->A2B.input_channels; i++) { OpAndArg oa = select_curve_op(&srcProfile->A2B.input_curves[i], i); if (oa.arg) { *ops++ = oa.op; *args++ = oa.arg; } } *ops++ = Op_clamp; switch (srcProfile->A2B.input_channels) { case 1: *ops++ = srcProfile->A2B.grid_8 ? Op_clut_1D_8 : Op_clut_1D_16; break; case 2: *ops++ = srcProfile->A2B.grid_8 ? Op_clut_2D_8 : Op_clut_2D_16; break; case 3: *ops++ = srcProfile->A2B.grid_8 ? Op_clut_3D_8 : Op_clut_3D_16; break; case 4: *ops++ = srcProfile->A2B.grid_8 ? Op_clut_4D_8 : Op_clut_4D_16; break; default: return false; } *args++ = &srcProfile->A2B; } if (srcProfile->A2B.matrix_channels == 3) { for (int i = 0; i < 3; i++) { OpAndArg oa = select_curve_op(&srcProfile->A2B.matrix_curves[i], i); if (oa.arg) { *ops++ = oa.op; *args++ = oa.arg; } } static const skcms_Matrix3x4 I = {{ {1,0,0,0}, {0,1,0,0}, {0,0,1,0}, }}; if (0 != memcmp(&I, &srcProfile->A2B.matrix, sizeof(I))) { *ops++ = Op_matrix_3x4; *args++ = &srcProfile->A2B.matrix; } } if (srcProfile->A2B.output_channels == 3) { for (int i = 0; i < 3; i++) { OpAndArg oa = select_curve_op(&srcProfile->A2B.output_curves[i], i); if (oa.arg) { *ops++ = oa.op; *args++ = oa.arg; } } } if (srcProfile->pcs == skcms_Signature_Lab) { *ops++ = Op_lab_to_xyz; } } else if (srcProfile->has_trc && srcProfile->has_toXYZD50) { for (int i = 0; i < 3; i++) { OpAndArg oa = select_curve_op(&srcProfile->trc[i], i); if (oa.arg) { *ops++ = oa.op; *args++ = oa.arg; } } } else { return false; } // A2B sources should already be in XYZD50 at this point. // Others still need to be transformed using their toXYZD50 matrix. // N.B. There are profiles that contain both A2B tags and toXYZD50 matrices. // If we use the A2B tags, we need to ignore the XYZD50 matrix entirely. assert (srcProfile->has_A2B || srcProfile->has_toXYZD50); static const skcms_Matrix3x3 I = {{ { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, }}; const skcms_Matrix3x3* to_xyz = srcProfile->has_A2B ? &I : &srcProfile->toXYZD50; // There's a chance the source and destination gamuts are identical, // in which case we can skip the gamut transform. if (0 != memcmp(&dstProfile->toXYZD50, to_xyz, sizeof(skcms_Matrix3x3))) { // Concat the entire gamut transform into from_xyz, // now slightly misnamed but it's a handy spot to stash the result. from_xyz = skcms_Matrix3x3_concat(&from_xyz, to_xyz); *ops++ = Op_matrix_3x3; *args++ = &from_xyz; } // Encode back to dst RGB using its parametric transfer functions. if (!is_identity_tf(&inv_dst_tf_r)) { *ops++ = Op_tf_r; *args++ = &inv_dst_tf_r; } if (!is_identity_tf(&inv_dst_tf_g)) { *ops++ = Op_tf_g; *args++ = &inv_dst_tf_g; } if (!is_identity_tf(&inv_dst_tf_b)) { *ops++ = Op_tf_b; *args++ = &inv_dst_tf_b; } } // Clamp here before premul to make sure we're clamping to fixed-point values _and_ gamut, // not just to values that fit in the fixed point representation. // // E.g. r = 1.1, a = 0.5 would fit fine in fixed point after premul (ra=0.55,a=0.5), // but would be carrying r > 1, which is really unexpected for downstream consumers. if (dstFmt < skcms_PixelFormat_RGB_hhh) { *ops++ = Op_clamp; } if (dstAlpha == skcms_AlphaFormat_Opaque) { *ops++ = Op_force_opaque; } else if (dstAlpha == skcms_AlphaFormat_PremulAsEncoded) { *ops++ = Op_premul; } if (dstFmt & 1) { *ops++ = Op_swap_rb; } switch (dstFmt >> 1) { default: return false; case skcms_PixelFormat_A_8 >> 1: *ops++ = Op_store_a8; break; case skcms_PixelFormat_G_8 >> 1: *ops++ = Op_store_g8; break; case skcms_PixelFormat_ABGR_4444 >> 1: *ops++ = Op_store_4444; break; case skcms_PixelFormat_RGB_565 >> 1: *ops++ = Op_store_565; break; case skcms_PixelFormat_RGB_888 >> 1: *ops++ = Op_store_888; break; case skcms_PixelFormat_RGBA_8888 >> 1: *ops++ = Op_store_8888; break; case skcms_PixelFormat_RGBA_1010102 >> 1: *ops++ = Op_store_1010102; break; case skcms_PixelFormat_RGB_161616LE >> 1: *ops++ = Op_store_161616LE; break; case skcms_PixelFormat_RGBA_16161616LE >> 1: *ops++ = Op_store_16161616LE; break; case skcms_PixelFormat_RGB_161616BE >> 1: *ops++ = Op_store_161616BE; break; case skcms_PixelFormat_RGBA_16161616BE >> 1: *ops++ = Op_store_16161616BE; break; case skcms_PixelFormat_RGB_hhh >> 1: *ops++ = Op_store_hhh; break; case skcms_PixelFormat_RGBA_hhhh >> 1: *ops++ = Op_store_hhhh; break; case skcms_PixelFormat_RGB_fff >> 1: *ops++ = Op_store_fff; break; case skcms_PixelFormat_RGBA_ffff >> 1: *ops++ = Op_store_ffff; break; } auto run = baseline::run_program; #if defined(TEST_FOR_HSW) if (hsw_ok()) { run = hsw::run_program; } #endif run(program, arguments, (const char*)src, (char*)dst, n, src_bpp,dst_bpp); return true; } static void assert_usable_as_destination(const skcms_ICCProfile* profile) { #if defined(NDEBUG) (void)profile; #else skcms_Matrix3x3 fromXYZD50; skcms_TransferFunction invR, invG, invB; assert(prep_for_destination(profile, &fromXYZD50, &invR, &invG, &invB)); #endif } bool skcms_MakeUsableAsDestination(skcms_ICCProfile* profile) { skcms_Matrix3x3 fromXYZD50; if (!profile->has_trc || !profile->has_toXYZD50 || !skcms_Matrix3x3_invert(&profile->toXYZD50, &fromXYZD50)) { return false; } skcms_TransferFunction tf[3]; for (int i = 0; i < 3; i++) { skcms_TransferFunction inv; if (profile->trc[i].table_entries == 0 && skcms_TransferFunction_invert(&profile->trc[i].parametric, &inv)) { tf[i] = profile->trc[i].parametric; continue; } float max_error; // Parametric curves from skcms_ApproximateCurve() are guaranteed to be invertible. if (!skcms_ApproximateCurve(&profile->trc[i], &tf[i], &max_error)) { return false; } } for (int i = 0; i < 3; ++i) { profile->trc[i].table_entries = 0; profile->trc[i].parametric = tf[i]; } assert_usable_as_destination(profile); return true; } bool skcms_MakeUsableAsDestinationWithSingleCurve(skcms_ICCProfile* profile) { // Operate on a copy of profile, so we can choose the best TF for the original curves skcms_ICCProfile result = *profile; if (!skcms_MakeUsableAsDestination(&result)) { return false; } int best_tf = 0; float min_max_error = INFINITY_; for (int i = 0; i < 3; i++) { skcms_TransferFunction inv; if (!skcms_TransferFunction_invert(&result.trc[i].parametric, &inv)) { return false; } float err = 0; for (int j = 0; j < 3; ++j) { err = fmaxf_(err, max_roundtrip_error(&profile->trc[j], &inv)); } if (min_max_error > err) { min_max_error = err; best_tf = i; } } for (int i = 0; i < 3; i++) { result.trc[i].parametric = result.trc[best_tf].parametric; } *profile = result; assert_usable_as_destination(profile); return true; }
[ "skia-commit-bot@chromium.org" ]
skia-commit-bot@chromium.org
f0a505a4b5337baa695646180bde0534801ba0e3
879681c994f1ca9c8d2c905a4e5064997ad25a27
/root-2.3.0/run/tutorials/multiphase/twoPhaseEulerFoam/RAS/fluidisedBed/0.9/p
2d4df613a55cb025445f2012d3f2adec1dbf4ac7
[]
no_license
MizuhaWatanabe/OpenFOAM-2.3.0-with-Ubuntu
3828272d989d45fb020e83f8426b849e75560c62
daeb870be81275e8a81f5cbac4ca1906a9bc69c0
refs/heads/master
2020-05-17T16:36:41.848261
2015-04-18T09:29:48
2015-04-18T09:29:48
34,159,882
1
0
null
null
null
null
UTF-8
C++
false
false
46,716
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.3.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.9"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [1 -1 -2 0 0 0 0]; internalField nonuniform List<scalar> 6000 ( 105881 105888 105896 105905 105907 105909 105916 105931 105950 105969 105979 105982 105977 105964 105954 105944 105922 105900 105890 105881 105871 105855 105832 105805 105784 105799 105835 105848 105848 105848 105820 105826 105832 105838 105841 105844 105845 105846 105852 105863 105869 105870 105867 105862 105860 105855 105845 105836 105827 105817 105804 105783 105753 105720 105703 105707 105726 105742 105741 105755 105771 105777 105781 105784 105787 105787 105786 105785 105788 105794 105797 105793 105783 105774 105775 105781 105782 105782 105777 105770 105753 105723 105682 105655 105653 105652 105654 105660 105660 105678 105713 105711 105710 105708 105706 105701 105694 105686 105695 105702 105705 105698 105678 105661 105670 105691 105702 105707 105704 105693 105671 105636 105607 105606 105610 105611 105610 105609 105610 105617 105634 105626 105620 105616 105608 105589 105567 105557 105567 105587 105593 105581 105565 105568 105584 105605 105617 105616 105611 105601 105578 105560 105560 105567 105571 105574 105576 105575 105576 105578 105524 105514 105508 105503 105492 105482 105479 105481 105484 105489 105494 105498 105504 105512 105526 105537 105537 105523 105517 105514 105512 105515 105524 105530 105535 105538 105541 105541 105542 105546 105410 105408 105410 105416 105424 105431 105438 105444 105447 105448 105453 105460 105469 105477 105486 105487 105474 105470 105470 105472 105478 105484 105490 105495 105499 105503 105505 105507 105509 105513 105372 105374 105378 105384 105394 105404 105412 105418 105421 105424 105428 105433 105439 105446 105452 105446 105437 105440 105443 105448 105453 105455 105458 105462 105465 105468 105471 105472 105474 105478 105360 105361 105364 105369 105376 105383 105390 105394 105397 105400 105403 105407 105410 105415 105418 105411 105409 105411 105416 105423 105428 105428 105429 105430 105432 105434 105437 105439 105441 105444 105350 105351 105353 105357 105361 105365 105369 105372 105374 105376 105378 105380 105382 105384 105386 105380 105382 105384 105388 105395 105400 105401 105400 105400 105401 105402 105403 105405 105407 105410 105340 105341 105342 105345 105347 105348 105350 105351 105351 105352 105353 105354 105355 105355 105355 105353 105356 105358 105361 105366 105371 105375 105373 105372 105371 105371 105371 105373 105374 105377 105329 105330 105331 105332 105333 105332 105331 105330 105330 105329 105329 105329 105329 105328 105326 105329 105331 105333 105336 105339 105345 105349 105348 105345 105343 105341 105341 105342 105343 105343 105319 105320 105320 105320 105319 105316 105313 105310 105308 105307 105306 105305 105305 105305 105303 105307 105309 105311 105312 105314 105320 105324 105325 105321 105317 105314 105312 105313 105315 105314 105309 105310 105309 105308 105304 105300 105294 105290 105287 105284 105283 105282 105282 105283 105284 105288 105290 105290 105290 105291 105295 105299 105302 105299 105293 105288 105286 105287 105290 105290 105300 105300 105299 105295 105290 105283 105276 105270 105265 105262 105260 105258 105259 105260 105264 105268 105270 105270 105269 105269 105270 105272 105275 105276 105270 105264 105261 105262 105267 105267 105290 105290 105287 105282 105274 105266 105257 105249 105244 105239 105236 105234 105234 105235 105239 105244 105249 105250 105248 105246 105242 105239 105240 105245 105246 105240 105236 105237 105240 105236 105279 105278 105274 105267 105258 105247 105238 105228 105221 105216 105212 105210 105209 105209 105210 105216 105221 105224 105223 105218 105204 105191 105186 105192 105206 105206 105202 105200 105194 105182 105263 105262 105256 105246 105236 105226 105218 105207 105199 105192 105187 105184 105182 105181 105180 105183 105186 105190 105188 105175 105149 105126 105113 105113 105125 105137 105133 105120 105098 105099 105239 105235 105226 105214 105205 105199 105195 105186 105175 105168 105162 105159 105156 105154 105151 105149 105148 105145 105136 105109 105073 105034 105015 105013 105015 105016 105013 105001 104993 104995 105196 105190 105178 105168 105162 105162 105165 105162 105152 105143 105137 105133 105131 105128 105125 105119 105109 105094 105071 105031 104987 104964 104956 104954 104954 104955 104955 104954 104954 104954 105131 105123 105114 105109 105109 105115 105125 105133 105127 105117 105111 105108 105107 105105 105102 105092 105070 105041 105005 104968 104947 104940 104937 104935 104935 104936 104937 104938 104939 104939 105049 105045 105042 105043 105049 105060 105076 105093 105098 105091 105085 105083 105084 105086 105083 105065 105030 104993 104961 104941 104933 104930 104928 104927 104926 104926 104927 104927 104928 104928 104962 104962 104965 104971 104982 104999 105019 105043 105061 105061 105057 105058 105062 105068 105060 105029 104991 104958 104937 104927 104924 104921 104919 104918 104917 104917 104916 104916 104916 104916 104871 104874 104881 104893 104909 104930 104956 104986 105014 105025 105027 105031 105038 105040 105016 104982 104953 104930 104917 104912 104911 104911 104909 104908 104907 104906 104905 104904 104903 104902 104775 104781 104793 104809 104830 104855 104886 104921 104957 104978 104990 105000 105005 104985 104947 104916 104897 104888 104888 104890 104893 104896 104896 104895 104893 104892 104891 104889 104886 104885 104669 104679 104697 104719 104744 104774 104808 104847 104886 104916 104940 104953 104942 104897 104858 104833 104821 104821 104830 104847 104862 104872 104876 104875 104874 104873 104871 104868 104865 104862 104542 104564 104596 104626 104655 104687 104723 104762 104799 104834 104865 104870 104832 104787 104752 104731 104726 104733 104749 104774 104802 104828 104842 104846 104845 104845 104843 104840 104836 104833 104437 104456 104497 104534 104566 104598 104632 104668 104700 104734 104756 104740 104702 104661 104627 104609 104611 104626 104651 104682 104716 104751 104782 104797 104802 104803 104803 104801 104797 104794 104381 104387 104415 104453 104483 104510 104535 104564 104591 104619 104622 104603 104568 104524 104480 104460 104473 104499 104536 104578 104618 104658 104695 104723 104736 104743 104746 104747 104746 104743 104356 104355 104364 104390 104412 104426 104434 104447 104471 104489 104488 104473 104439 104385 104333 104312 104318 104345 104405 104462 104513 104559 104599 104632 104652 104664 104672 104678 104679 104679 104337 104335 104334 104343 104349 104344 104325 104315 104336 104360 104367 104359 104325 104270 104233 104226 104225 104235 104270 104337 104403 104458 104503 104540 104563 104577 104589 104597 104601 104603 104316 104312 104308 104304 104289 104256 104227 104213 104221 104243 104264 104265 104234 104198 104188 104187 104186 104188 104195 104229 104295 104360 104410 104450 104475 104491 104503 104512 104517 104520 104290 104286 104277 104261 104234 104195 104175 104170 104168 104172 104184 104193 104174 104158 104160 104162 104162 104163 104165 104174 104211 104269 104322 104362 104388 104406 104419 104428 104432 104437 104259 104253 104242 104219 104189 104164 104151 104146 104141 104137 104138 104141 104140 104131 104134 104136 104138 104141 104143 104147 104162 104199 104242 104279 104305 104324 104338 104348 104353 104357 104223 104217 104205 104184 104160 104142 104132 104124 104117 104112 104108 104117 104111 104108 104108 104111 104114 104117 104121 104127 104135 104153 104180 104207 104231 104250 104264 104274 104281 104284 104185 104179 104168 104151 104134 104121 104111 104101 104093 104087 104084 104087 104085 104083 104083 104085 104089 104093 104098 104106 104113 104123 104137 104154 104172 104188 104200 104210 104217 104219 104143 104140 104131 104119 104108 104097 104088 104077 104068 104061 104058 104058 104060 104059 104058 104060 104064 104068 104075 104083 104089 104096 104105 104116 104127 104137 104146 104153 104158 104161 104098 104097 104092 104085 104077 104069 104061 104051 104040 104032 104029 104029 104033 104034 104033 104035 104039 104044 104051 104057 104061 104067 104074 104080 104086 104092 104097 104102 104105 104108 104046 104047 104046 104043 104039 104035 104029 104020 104009 103999 103995 103994 104004 104008 104008 104010 104014 104019 104025 104028 104031 104036 104039 104042 104045 104048 104051 104053 104056 104059 103990 103991 103992 103993 103993 103992 103990 103984 103974 103961 103955 103954 103969 103982 103984 103986 103990 103995 103997 103997 103998 103999 103999 103999 104000 104002 104004 104007 104009 104010 103929 103931 103934 103936 103939 103941 103942 103940 103932 103919 103912 103910 103925 103951 103960 103963 103966 103968 103967 103964 103961 103958 103955 103953 103952 103953 103955 103957 103959 103958 103865 103868 103872 103876 103880 103884 103887 103888 103884 103872 103864 103862 103866 103904 103930 103937 103940 103938 103933 103926 103918 103910 103905 103902 103901 103901 103902 103903 103903 103902 103800 103803 103807 103813 103819 103825 103829 103832 103832 103821 103813 103809 103803 103832 103879 103899 103903 103898 103890 103879 103867 103858 103852 103848 103846 103845 103845 103845 103843 103842 103733 103735 103741 103749 103757 103764 103771 103775 103776 103770 103763 103756 103748 103753 103799 103834 103847 103843 103833 103820 103809 103801 103795 103791 103788 103786 103785 103784 103782 103781 103666 103664 103674 103684 103695 103704 103712 103719 103722 103723 103717 103708 103698 103686 103704 103744 103766 103771 103764 103755 103747 103740 103734 103730 103727 103725 103723 103721 103720 103719 103606 103601 103607 103621 103634 103644 103654 103663 103670 103678 103676 103665 103650 103633 103625 103650 103679 103691 103691 103687 103681 103676 103671 103667 103664 103662 103659 103658 103657 103657 103556 103554 103555 103563 103575 103586 103596 103607 103619 103632 103634 103624 103604 103586 103571 103575 103599 103614 103618 103617 103613 103610 103606 103603 103600 103597 103596 103594 103594 103594 103523 103520 103516 103516 103521 103529 103538 103548 103564 103582 103587 103576 103554 103536 103525 103521 103534 103544 103548 103547 103545 103542 103540 103537 103535 103533 103531 103531 103530 103530 103495 103491 103484 103477 103475 103475 103480 103490 103506 103522 103528 103514 103494 103483 103479 103479 103483 103482 103479 103476 103475 103474 103473 103471 103469 103467 103466 103466 103465 103465 103456 103457 103450 103441 103431 103426 103426 103434 103445 103453 103449 103433 103424 103425 103430 103436 103430 103418 103407 103403 103405 103406 103406 103404 103402 103401 103400 103400 103399 103399 103400 103404 103406 103399 103387 103378 103376 103378 103379 103371 103354 103342 103352 103366 103379 103386 103371 103349 103327 103323 103332 103338 103338 103337 103335 103334 103333 103333 103333 103332 103333 103336 103341 103342 103338 103331 103326 103320 103306 103284 103262 103267 103289 103308 103327 103328 103305 103271 103248 103249 103260 103268 103270 103269 103268 103267 103266 103266 103266 103265 103261 103263 103268 103273 103277 103276 103269 103256 103234 103208 103200 103216 103236 103254 103271 103263 103233 103197 103187 103189 103195 103197 103200 103200 103199 103199 103199 103199 103199 103198 103186 103185 103192 103200 103205 103208 103205 103194 103176 103158 103163 103176 103190 103204 103210 103195 103161 103138 103138 103141 103140 103135 103131 103130 103130 103130 103131 103132 103132 103132 103109 103102 103111 103123 103132 103138 103142 103142 103134 103126 103133 103141 103149 103155 103151 103131 103103 103091 103090 103092 103082 103071 103063 103060 103061 103062 103064 103066 103067 103067 103037 103030 103034 103040 103049 103062 103075 103095 103104 103104 103106 103109 103112 103112 103101 103078 103053 103040 103038 103030 103012 102997 102991 102989 102992 102995 102999 103001 103002 103004 102992 102990 102989 102990 102995 103003 103015 103039 103071 103084 103085 103083 103081 103077 103062 103035 103006 102983 102969 102951 102927 102910 102911 102918 102924 102930 102935 102938 102939 102941 102968 102967 102966 102965 102966 102969 102975 102989 103029 103062 103066 103062 103058 103050 103031 102995 102952 102913 102884 102860 102834 102823 102826 102846 102859 102869 102875 102878 102877 102881 102951 102950 102949 102948 102947 102947 102951 102957 102982 103032 103046 103042 103035 103022 102991 102938 102882 102837 102810 102786 102773 102770 102772 102785 102800 102815 102823 102828 102825 102828 102934 102933 102932 102930 102927 102926 102925 102924 102930 102979 103010 103010 102996 102963 102907 102848 102796 102775 102764 102751 102746 102746 102746 102749 102760 102774 102783 102785 102787 102788 102911 102913 102911 102909 102905 102901 102895 102887 102879 102890 102929 102932 102905 102844 102784 102751 102735 102737 102735 102730 102730 102730 102732 102733 102736 102742 102750 102756 102759 102761 102877 102882 102882 102881 102877 102870 102860 102847 102831 102814 102810 102799 102769 102733 102713 102704 102705 102711 102710 102710 102712 102715 102718 102721 102723 102725 102730 102735 102737 102739 102826 102833 102838 102842 102840 102832 102820 102805 102787 102763 102736 102715 102698 102687 102683 102681 102684 102688 102686 102689 102693 102699 102704 102707 102709 102710 102712 102715 102716 102717 102764 102769 102776 102784 102789 102786 102777 102764 102749 102725 102701 102683 102671 102664 102661 102660 102663 102664 102663 102667 102674 102681 102686 102688 102690 102689 102688 102687 102686 102681 102695 102699 102706 102714 102722 102727 102727 102721 102711 102693 102675 102660 102648 102641 102637 102635 102638 102637 102638 102644 102653 102660 102663 102662 102659 102653 102646 102638 102631 102625 102623 102626 102632 102640 102649 102657 102664 102668 102666 102658 102645 102633 102622 102613 102608 102606 102607 102604 102608 102617 102627 102631 102628 102619 102607 102595 102583 102571 102562 102556 102549 102551 102557 102565 102574 102583 102591 102599 102606 102611 102609 102601 102590 102580 102575 102573 102570 102565 102571 102584 102591 102587 102573 102558 102542 102526 102511 102497 102486 102480 102474 102475 102481 102489 102498 102507 102515 102524 102534 102546 102557 102559 102553 102543 102537 102534 102529 102523 102529 102540 102539 102525 102508 102490 102471 102453 102435 102418 102405 102398 102399 102397 102403 102413 102422 102430 102437 102444 102455 102469 102486 102502 102505 102498 102493 102492 102485 102479 102482 102485 102477 102459 102439 102419 102399 102377 102356 102337 102321 102314 102328 102322 102325 102339 102348 102354 102356 102360 102368 102383 102402 102428 102445 102444 102442 102445 102438 102431 102432 102427 102414 102391 102369 102347 102324 102301 102276 102253 102235 102229 102270 102262 102262 102272 102277 102278 102273 102267 102269 102283 102305 102336 102366 102378 102383 102390 102384 102378 102381 102371 102350 102321 102296 102273 102250 102224 102196 102168 102147 102144 102225 102221 102219 102217 102216 102204 102184 102165 102155 102161 102178 102218 102265 102295 102314 102327 102325 102323 102325 102310 102273 102243 102220 102199 102177 102151 102118 102084 102060 102062 102183 102185 102181 102170 102156 102133 102103 102071 102045 102027 102022 102065 102137 102192 102229 102252 102259 102262 102261 102232 102186 102158 102140 102124 102107 102083 102052 102023 102009 102009 102129 102137 102131 102115 102092 102063 102029 101994 101959 101926 101917 101935 101994 102070 102128 102162 102176 102188 102176 102136 102094 102068 102058 102050 102043 102028 102009 101994 101989 101987 102048 102055 102053 102041 102021 101995 101963 101929 101893 101866 101869 101877 101899 101956 102020 102055 102069 102084 102064 102028 102000 101983 101978 101978 101982 101983 101984 101980 101978 101976 101957 101963 101968 101964 101950 101926 101897 101866 101836 101828 101836 101844 101852 101878 101922 101944 101944 101951 101936 101920 101914 101907 101903 101909 101921 101938 101958 101968 101968 101967 101861 101869 101885 101893 101884 101862 101834 101807 101789 101795 101802 101810 101816 101826 101846 101849 101835 101830 101827 101833 101842 101843 101838 101843 101859 101886 101919 101949 101956 101954 101769 101768 101796 101823 101821 101802 101778 101759 101752 101760 101767 101775 101781 101783 101788 101779 101772 101768 101766 101775 101785 101787 101781 101783 101799 101827 101863 101905 101931 101934 101685 101684 101708 101744 101753 101741 101728 101721 101723 101729 101735 101742 101748 101749 101746 101738 101740 101738 101736 101740 101742 101736 101725 101723 101736 101763 101797 101834 101866 101890 101625 101630 101646 101670 101683 101681 101682 101689 101698 101704 101710 101716 101722 101723 101719 101714 101717 101718 101719 101718 101709 101683 101657 101649 101666 101694 101727 101759 101771 101803 101584 101588 101597 101610 101617 101619 101637 101658 101675 101685 101693 101700 101705 101706 101701 101697 101701 101703 101703 101695 101664 101612 101571 101549 101578 101616 101658 101691 101693 101706 101548 101544 101536 101536 101533 101541 101586 101627 101655 101670 101681 101689 101693 101693 101685 101680 101682 101683 101670 101635 101573 101514 101479 101466 101477 101521 101583 101631 101631 101629 101508 101494 101483 101479 101471 101474 101518 101583 101627 101653 101668 101676 101679 101674 101662 101651 101640 101618 101568 101509 101465 101440 101425 101422 101424 101442 101495 101565 101578 101574 101463 101456 101452 101448 101440 101436 101448 101500 101565 101604 101624 101634 101635 101625 101606 101575 101523 101469 101438 101420 101409 101405 101405 101407 101407 101410 101431 101489 101522 101525 101429 101430 101430 101428 101421 101415 101410 101416 101436 101460 101482 101499 101501 101489 101463 101437 101413 101399 101394 101392 101393 101395 101397 101398 101398 101397 101400 101417 101458 101474 101406 101409 101409 101410 101404 101398 101392 101385 101382 101382 101384 101388 101388 101385 101381 101379 101379 101381 101384 101385 101386 101388 101389 101390 101390 101389 101388 101389 101403 101424 101390 101390 101390 101392 101388 101382 101378 101373 101368 101363 101360 101358 101358 101359 101362 101366 101370 101374 101376 101378 101379 101381 101382 101382 101382 101381 101379 101378 101379 101387 101378 101376 101375 101375 101372 101368 101366 101362 101359 101356 101354 101352 101352 101354 101356 101359 101362 101365 101368 101371 101372 101374 101374 101375 101374 101373 101371 101370 101368 101369 101367 101364 101363 101362 101359 101356 101353 101351 101349 101347 101346 101346 101346 101347 101348 101350 101353 101356 101360 101364 101366 101367 101367 101367 101366 101365 101364 101363 101362 101361 101356 101354 101353 101350 101347 101343 101342 101340 101338 101337 101337 101337 101337 101338 101339 101341 101343 101347 101352 101357 101359 101360 101360 101360 101359 101358 101357 101357 101356 101356 101346 101345 101343 101339 101334 101331 101330 101329 101328 101327 101327 101327 101327 101328 101329 101331 101333 101336 101343 101348 101352 101353 101353 101352 101352 101351 101351 101350 101350 101350 101334 101335 101332 101326 101321 101319 101318 101318 101317 101317 101317 101317 101317 101318 101319 101320 101322 101324 101331 101338 101343 101344 101345 101345 101345 101345 101345 101345 101345 101345 101319 101320 101317 101312 101307 101307 101307 101306 101306 101306 101306 101307 101307 101307 101308 101309 101310 101311 101317 101327 101334 101336 101337 101338 101339 101339 101339 101339 101339 101339 101303 101304 101301 101298 101294 101295 101295 101295 101295 101295 101296 101296 101296 101297 101297 101297 101298 101299 101303 101314 101323 101327 101329 101331 101332 101333 101334 101334 101334 101335 101288 101289 101286 101284 101282 101283 101284 101284 101284 101284 101285 101285 101286 101286 101286 101286 101287 101287 101289 101300 101312 101318 101321 101323 101325 101327 101328 101329 101330 101330 101275 101273 101272 101269 101270 101271 101272 101273 101273 101274 101274 101275 101275 101275 101275 101275 101275 101276 101277 101287 101301 101309 101313 101315 101318 101320 101322 101324 101325 101326 101264 101261 101261 101257 101259 101260 101261 101262 101262 101263 101263 101264 101264 101264 101264 101264 101264 101265 101267 101275 101289 101299 101304 101307 101311 101314 101316 101319 101321 101322 101255 101256 101252 101248 101250 101251 101251 101252 101252 101252 101253 101253 101253 101253 101253 101253 101254 101254 101256 101264 101277 101287 101293 101298 101302 101306 101310 101313 101315 101318 101248 101245 101240 101240 101241 101241 101241 101242 101242 101242 101242 101243 101243 101243 101243 101243 101243 101243 101246 101253 101264 101274 101281 101287 101292 101297 101301 101305 101310 101309 101235 101231 101230 101232 101232 101232 101232 101232 101232 101232 101232 101232 101232 101232 101232 101232 101232 101232 101235 101241 101251 101259 101266 101273 101278 101284 101291 101295 101295 101295 101222 101221 101222 101223 101224 101223 101222 101222 101222 101222 101222 101222 101222 101221 101221 101221 101221 101221 101223 101228 101236 101243 101250 101256 101262 101270 101275 101278 101277 101271 101212 101212 101213 101214 101215 101214 101213 101213 101212 101212 101212 101211 101211 101211 101211 101210 101210 101210 101211 101216 101222 101227 101232 101238 101245 101253 101259 101261 101255 101247 101203 101203 101203 101205 101205 101205 101204 101203 101203 101202 101202 101201 101201 101201 101200 101199 101199 101199 101199 101203 101208 101212 101216 101222 101230 101240 101246 101244 101236 101231 101193 101193 101194 101195 101196 101196 101195 101194 101193 101192 101192 101191 101191 101190 101190 101189 101188 101188 101188 101192 101195 101198 101201 101208 101219 101231 101234 101228 101226 101220 101184 101184 101185 101186 101187 101186 101185 101184 101183 101183 101182 101181 101181 101180 101179 101179 101178 101178 101177 101180 101182 101185 101189 101198 101212 101222 101223 101219 101214 101213 101175 101175 101175 101176 101177 101177 101176 101175 101174 101173 101172 101171 101171 101170 101169 101168 101168 101167 101167 101169 101170 101174 101179 101190 101205 101213 101217 101211 101210 101210 101166 101166 101167 101167 101167 101167 101166 101165 101164 101163 101162 101161 101161 101160 101159 101158 101157 101157 101157 101157 101158 101163 101170 101184 101197 101205 101209 101207 101206 101206 101158 101157 101158 101158 101158 101158 101157 101155 101154 101153 101153 101152 101151 101150 101149 101148 101147 101147 101146 101144 101147 101153 101163 101176 101188 101197 101201 101202 101202 101202 101150 101149 101150 101149 101149 101148 101147 101146 101145 101144 101143 101142 101141 101140 101139 101138 101137 101136 101135 101133 101137 101145 101155 101169 101182 101191 101195 101197 101197 101197 101142 101142 101142 101141 101140 101139 101138 101136 101135 101134 101133 101132 101131 101130 101129 101128 101127 101127 101125 101123 101129 101136 101148 101162 101176 101185 101190 101192 101192 101192 101134 101134 101133 101132 101131 101130 101128 101126 101125 101124 101123 101122 101121 101121 101120 101119 101118 101117 101117 101115 101117 101125 101139 101154 101169 101180 101185 101186 101187 101187 101123 101124 101123 101122 101122 101121 101119 101117 101116 101115 101113 101112 101112 101111 101110 101109 101109 101108 101108 101107 101107 101116 101130 101146 101161 101173 101179 101180 101181 101181 101105 101109 101110 101111 101112 101112 101110 101108 101106 101105 101104 101103 101102 101101 101100 101100 101099 101099 101100 101100 101100 101109 101121 101138 101153 101167 101171 101173 101174 101174 101079 101084 101091 101096 101100 101102 101101 101098 101096 101095 101094 101093 101092 101091 101090 101090 101090 101090 101091 101092 101094 101100 101113 101129 101144 101156 101162 101165 101166 101167 101041 101053 101065 101076 101085 101091 101091 101089 101086 101084 101083 101082 101082 101081 101080 101080 101080 101081 101082 101084 101086 101091 101104 101119 101132 101142 101149 101154 101156 101157 100998 101015 101036 101052 101066 101077 101081 101079 101075 101074 101073 101072 101071 101071 101070 101070 101070 101071 101072 101074 101077 101081 101091 101104 101116 101127 101135 101141 101144 101145 100969 100977 101002 101026 101045 101062 101070 101067 101064 101063 101062 101061 101061 101060 101060 101060 101060 101060 101061 101063 101065 101070 101079 101090 101100 101111 101120 101125 101128 101130 100961 100963 100972 100997 101024 101044 101056 101053 101052 101051 101051 101050 101050 101050 101049 101049 101049 101050 101051 101052 101053 101058 101066 101076 101085 101094 101102 101107 101110 101112 100959 100959 100961 100972 101000 101027 101043 101041 101040 101040 101040 101040 101039 101039 101039 101039 101039 101039 101040 101040 101041 101045 101053 101062 101070 101076 101082 101087 101089 101091 100958 100958 100959 100963 100979 101013 101031 101030 101029 101029 101029 101029 101029 101028 101028 101028 101028 101029 101029 101029 101030 101033 101040 101047 101054 101059 101063 101066 101067 101069 100957 100957 100957 100959 100970 101000 101018 101020 101019 101019 101018 101018 101018 101018 101018 101018 101018 101018 101019 101019 101019 101021 101026 101032 101037 101040 101043 101045 101045 101046 100956 100956 100956 100957 100964 100990 101006 101010 101009 101008 101008 101008 101008 101007 101007 101007 101008 101008 101009 101010 101010 101011 101013 101017 101019 101021 101022 101023 101023 101023 100954 100955 100955 100955 100960 100978 100995 100999 100999 100998 100998 100997 100997 100997 100997 100997 100998 100999 101000 101001 101001 101000 101000 101000 101001 101001 101001 101001 101002 101002 100953 100953 100953 100954 100957 100970 100984 100989 100989 100988 100987 100987 100986 100986 100986 100987 100987 100989 100991 100993 100993 100990 100987 100985 100984 100983 100982 100982 100982 100982 100951 100951 100951 100951 100955 100964 100974 100978 100980 100978 100977 100976 100976 100975 100975 100976 100977 100979 100982 100984 100983 100978 100974 100970 100968 100966 100965 100964 100962 100963 100948 100948 100948 100949 100951 100960 100966 100970 100971 100969 100967 100966 100965 100964 100964 100965 100966 100969 100972 100973 100970 100965 100959 100955 100952 100950 100948 100946 100944 100945 100944 100944 100945 100945 100947 100953 100958 100962 100962 100959 100956 100954 100953 100953 100952 100953 100954 100958 100961 100961 100956 100950 100944 100939 100935 100932 100930 100928 100926 100929 100941 100941 100940 100940 100941 100944 100950 100953 100952 100949 100945 100943 100941 100941 100940 100940 100942 100945 100948 100946 100940 100934 100928 100923 100918 100915 100912 100910 100910 100913 100936 100936 100936 100935 100934 100936 100939 100941 100940 100936 100932 100930 100929 100928 100927 100927 100928 100930 100931 100929 100924 100919 100913 100908 100903 100898 100895 100894 100896 100898 100931 100931 100931 100929 100928 100928 100928 100926 100924 100920 100917 100916 100916 100915 100914 100914 100914 100914 100914 100912 100908 100903 100898 100893 100888 100884 100881 100881 100882 100884 100926 100926 100925 100923 100921 100919 100915 100910 100905 100903 100903 100903 100903 100902 100901 100900 100900 100898 100896 100895 100892 100889 100884 100879 100874 100870 100867 100866 100866 100866 100920 100920 100918 100916 100912 100908 100901 100892 100885 100886 100889 100890 100890 100890 100889 100887 100886 100882 100879 100879 100878 100875 100871 100866 100860 100855 100851 100848 100846 100844 100913 100912 100909 100905 100901 100894 100885 100873 100869 100872 100876 100878 100878 100878 100877 100875 100873 100869 100865 100864 100865 100862 100858 100851 100844 100837 100832 100827 100822 100818 100901 100900 100895 100890 100885 100880 100869 100859 100859 100863 100866 100868 100868 100868 100867 100865 100863 100859 100856 100854 100855 100851 100844 100835 100826 100817 100809 100803 100797 100793 100884 100881 100876 100870 100867 100864 100856 100853 100854 100856 100858 100859 100859 100859 100858 100856 100855 100852 100850 100847 100847 100842 100830 100818 100805 100794 100785 100777 100771 100767 100859 100857 100853 100850 100849 100850 100849 100849 100850 100851 100851 100851 100851 100850 100850 100849 100847 100846 100845 100843 100840 100831 100816 100799 100784 100771 100760 100751 100744 100742 100832 100830 100829 100829 100831 100836 100841 100845 100847 100846 100845 100844 100844 100843 100842 100841 100841 100841 100841 100839 100834 100821 100801 100781 100763 100748 100735 100724 100717 100714 100804 100803 100804 100807 100812 100820 100831 100841 100844 100842 100839 100838 100837 100836 100835 100835 100835 100836 100836 100834 100825 100805 100780 100757 100738 100721 100706 100694 100686 100682 100773 100773 100776 100781 100790 100801 100815 100832 100839 100838 100834 100831 100829 100829 100828 100828 100830 100831 100831 100826 100810 100781 100751 100725 100704 100685 100670 100657 100649 100645 100737 100739 100745 100753 100764 100778 100792 100808 100825 100831 100826 100823 100822 100821 100821 100822 100824 100825 100826 100819 100793 100753 100717 100689 100666 100646 100629 100616 100609 100604 100698 100704 100712 100722 100734 100746 100761 100780 100801 100818 100818 100815 100813 100813 100813 100815 100818 100820 100820 100806 100766 100727 100689 100656 100629 100606 100588 100575 100567 100562 100661 100667 100674 100683 100694 100709 100728 100751 100776 100801 100808 100805 100804 100805 100805 100807 100811 100814 100805 100766 100724 100687 100653 100624 100596 100572 100551 100535 100525 100520 100622 100625 100630 100639 100652 100671 100694 100721 100751 100781 100794 100795 100795 100796 100796 100799 100803 100800 100767 100719 100676 100637 100604 100576 100550 100528 100509 100494 100483 100477 100577 100578 100583 100593 100609 100631 100657 100689 100723 100756 100774 100780 100783 100785 100786 100788 100789 100770 100721 100670 100624 100584 100549 100520 100496 100475 100457 100444 100434 100429 100525 100526 100532 100544 100563 100588 100618 100653 100692 100728 100750 100761 100767 100770 100772 100773 100767 100730 100672 100619 100570 100528 100492 100462 100437 100416 100399 100387 100378 100374 100467 100469 100477 100491 100513 100541 100574 100613 100656 100695 100721 100737 100745 100750 100753 100751 100735 100682 100618 100561 100512 100469 100433 100402 100376 100355 100338 100324 100315 100311 100405 100409 100419 100435 100460 100491 100528 100569 100614 100655 100685 100704 100716 100721 100723 100716 100684 100618 100552 100494 100445 100404 100369 100339 100313 100291 100273 100258 100248 100244 100342 100347 100358 100378 100406 100440 100478 100520 100564 100602 100634 100657 100670 100675 100673 100654 100605 100537 100472 100417 100371 100333 100301 100273 100248 100226 100206 100187 100174 100171 100277 100283 100296 100317 100346 100379 100413 100448 100487 100524 100558 100585 100599 100601 100590 100557 100504 100442 100383 100332 100290 100257 100231 100208 100185 100163 100139 100115 100095 100090 100209 100214 100228 100247 100273 100300 100327 100356 100389 100423 100454 100480 100492 100490 100471 100436 100391 100340 100289 100243 100209 100184 100164 100146 100127 100105 100077 100048 100029 100025 100135 100136 100149 100165 100184 100205 100228 100256 100285 100313 100337 100355 100362 100356 100336 100308 100273 100232 100190 100153 100128 100112 100102 100090 100074 100054 100028 100012 100007 100006 100060 100049 100061 100079 100095 100111 100129 100154 100182 100205 100222 100232 100233 100223 100205 100181 100154 100121 100088 100064 100049 100045 100046 100041 100030 100016 100006 100003 100003 100003 100015 100012 100015 100021 100028 100036 100042 100058 100083 100102 100113 100117 100114 100102 100083 100065 100049 100034 100023 100015 100012 100011 100011 100010 100006 100004 100003 100003 100003 100003 100003 100003 100003 100004 100006 100006 100005 100008 100017 100024 100028 100028 100025 100021 100016 100012 100009 100007 100005 100004 100004 100003 100003 100003 100002 100002 100003 100003 100003 100003 100002 100002 100002 100001 100001 100000 100000 100000 100001 100003 100004 100004 100004 100004 100004 100004 100003 100003 100003 100003 100003 100003 100003 100002 100003 100003 100003 100003 100003 100003 100002 100002 100002 100002 100001 100001 100001 100001 100000 100001 100001 100001 100002 100002 100003 100003 100003 100004 100004 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100002 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100001 100002 100002 100002 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100002 100002 100002 100002 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100002 100002 100002 100002 100002 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100002 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100002 100002 100002 100002 100002 100002 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100003 100003 100003 100003 100003 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100003 100003 100003 100003 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100002 100002 100002 100002 100002 100002 100002 100002 100003 100003 100003 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100002 100002 100002 100002 100002 100002 100002 100003 100003 100003 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 ) ; boundaryField { inlet { type fixedFluxPressure; gradient nonuniform List<scalar> 30 ( 43.0701 64.6243 69.6296 76.5362 69.7512 54.9642 64.8241 93.1374 101.639 101.439 101.344 101.329 101.056 95.3099 90.6625 98.7976 87.4136 50.9354 49.5741 57.2416 72.4074 79.1589 81.4569 82.6486 72.2594 76.6972 76.1549 75.3775 74.7275 73.4418 ) ; value nonuniform List<scalar> 30 ( 105881 105888 105896 105905 105907 105909 105917 105932 105950 105969 105980 105982 105977 105964 105954 105944 105922 105900 105890 105882 105872 105856 105832 105805 105784 105799 105835 105848 105848 105849 ) ; } outlet { type fixedValue; value uniform 100000; } walls { type fixedFluxPressure; gradient uniform 0; value nonuniform List<scalar> 400 ( 105881 105820 105771 105713 105634 105524 105410 105372 105360 105350 105340 105329 105319 105309 105300 105290 105279 105263 105239 105196 105131 105049 104962 104871 104775 104669 104542 104437 104381 104356 104337 104316 104290 104259 104223 104185 104143 104098 104046 103990 103929 103865 103800 103733 103666 103606 103556 103523 103495 103456 103400 103333 103261 103186 103109 103037 102992 102968 102951 102934 102911 102877 102826 102764 102695 102623 102549 102474 102399 102328 102270 102225 102183 102129 102048 101957 101861 101769 101685 101625 101584 101548 101508 101463 101429 101406 101390 101378 101367 101356 101346 101334 101319 101303 101288 101275 101264 101255 101248 101235 101222 101212 101203 101193 101184 101175 101166 101158 101150 101142 101134 101123 101105 101079 101041 100998 100969 100961 100959 100958 100957 100956 100954 100953 100951 100948 100944 100941 100936 100931 100926 100920 100913 100901 100884 100859 100832 100804 100773 100737 100698 100661 100622 100577 100525 100467 100405 100342 100277 100209 100135 100060 100015 100003 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100000 100000 100000 100000 100000 100000 100000 100000 100000 105848 105755 105678 105617 105578 105546 105513 105478 105444 105410 105377 105343 105314 105290 105267 105236 105182 105099 104995 104954 104939 104928 104916 104902 104885 104862 104833 104794 104743 104679 104603 104520 104437 104357 104284 104219 104161 104108 104059 104010 103958 103902 103842 103781 103719 103657 103594 103530 103465 103399 103332 103265 103198 103132 103067 103004 102941 102881 102828 102788 102761 102739 102717 102681 102625 102556 102480 102398 102314 102229 102144 102062 102009 101987 101976 101967 101954 101934 101890 101803 101706 101629 101574 101525 101474 101424 101387 101369 101361 101356 101350 101345 101339 101335 101330 101326 101322 101318 101309 101295 101271 101247 101231 101220 101213 101210 101206 101202 101197 101192 101187 101181 101174 101167 101157 101145 101130 101112 101091 101069 101046 101023 101002 100982 100963 100945 100929 100913 100898 100884 100866 100844 100818 100793 100767 100742 100714 100682 100645 100604 100562 100520 100477 100429 100374 100311 100244 100171 100090 100025 100006 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 ) ; } frontAndBackPlanes { type empty; } } // ************************************************************************* //
[ "mizuha.watanabe@gmail.com" ]
mizuha.watanabe@gmail.com
582b0c950c3e9ee0932c8ac16951bf7a6a5c94c3
bd6726e677dd8ef16856747ce4f7450e5cc9b00b
/src/FelZenSegment/imconv.cpp
b5f38eacc6dc8e6565b4c213eb8515e9b2aa3bc0
[]
no_license
i-genius/image-segment
63c05b9227c4dbd9d6dc9527d7d99dfd45086fd2
653840e53ef2b31ec2cf09a747628af56efd6b29
refs/heads/master
2021-05-02T06:49:26.746806
2018-02-09T07:08:04
2018-02-09T07:08:04
120,864,802
0
1
null
null
null
null
UTF-8
C++
false
false
4,863
cpp
/* Copyright (C) 2006 Pedro Felzenszwalb This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* image conversion */ #include <limits.h> #include "imutil.h" #include "imconv.h" image<uchar> *imageRGBtoGRAY(image<rgb> *input) { int i_width = input->width(); int i_height = input->height(); image<uchar> *pouc_output = new image<uchar>(i_width, i_height, false); for (int y = 0; y < i_height; y++) { for (int x = 0; x < i_width; x++) { imRef(pouc_output, x, y) = (uchar) (imRef(input, x, y).r * RED_WEIGHT + imRef(input, x, y).g * GREEN_WEIGHT + imRef(input, x, y).b * BLUE_WEIGHT); } } return pouc_output; } image<rgb> *imageGRAYtoRGB(image<uchar> *input) { int i_width = input->width(); int i_height = input->height(); image<rgb> *po_output = new image<rgb>(i_width, i_height, false); for (int y = 0; y < i_height; y++) { for (int x = 0; x < i_width; x++) { imRef(po_output, x, y).r = imRef(input, x, y); imRef(po_output, x, y).g = imRef(input, x, y); imRef(po_output, x, y).b = imRef(input, x, y); } } return po_output; } image<float> *imageUCHARtoFLOAT(image<uchar> *input) { int i_width = input->width(); int i_height = input->height(); image<float> *pofl_output = new image<float>(i_width, i_height, false); for (int y = 0; y < i_height; y++) { for (int x = 0; x < i_width; x++) { imRef(pofl_output, x, y) = imRef(input, x, y); } } return pofl_output; } image<float> *imageINTtoFLOAT(image<int> *input) { int i_width = input->width(); int i_height = input->height(); image<float> *pofl_output = new image<float>(i_width, i_height, false); for (int y = 0; y < i_height; y++) { for (int x = 0; x < i_width; x++) { imRef(pofl_output, x, y) = imRef(input, x, y); } } return pofl_output; } image<uchar> *imageFLOATtoUCHAR(image<float> *input, float min, float max) { int i_width = input->width(); int i_height = input->height(); image<uchar> *pouc_output = new image<uchar>(i_width, i_height, false); if (max == min) return pouc_output; float fl_scale = UCHAR_MAX / (max - min); for (int y = 0; y < i_height; y++) { for (int x = 0; x < i_width; x++) { uchar uc_val = (uchar)((imRef(input, x, y) - min) * fl_scale); imRef(pouc_output, x, y) = bound(uc_val, (uchar)0, (uchar)UCHAR_MAX); } } return pouc_output; } image<uchar> *imageFLOATtoUCHAR(image<float> *input) { float fl_min, fl_max; min_max(input, &fl_min, &fl_max); return imageFLOATtoUCHAR(input, fl_min, fl_max); } image<long> *imageUCHARtoLONG(image<uchar> *input) { int i_width = input->width(); int i_height = input->height(); image<long> *pol_output = new image<long>(i_width, i_height, false); for (int y = 0; y < i_height; y++) { for (int x = 0; x < i_width; x++) { imRef(pol_output, x, y) = imRef(input, x, y); } } return pol_output; } image<uchar> *imageLONGtoUCHAR(image<long> *input, long min, long max) { int i_width = input->width(); int i_height = input->height(); image<uchar> *pouc_output = new image<uchar>(i_width, i_height, false); if (max == min) return pouc_output; float fl_scale = UCHAR_MAX / (float)(max - min); for (int y = 0; y < i_height; y++) { for (int x = 0; x < i_width; x++) { uchar uc_val = (uchar)((imRef(input, x, y) - min) * fl_scale); imRef(pouc_output, x, y) = bound(uc_val, (uchar)0, (uchar)UCHAR_MAX); } } return pouc_output; } image<uchar> *imageLONGtoUCHAR(image<long> *input) { long l_min, l_max; min_max(input, &l_min, &l_max); return imageLONGtoUCHAR(input, l_min, l_max); } image<uchar> *imageSHORTtoUCHAR(image<short> *input, short min, short max) { int i_width = input->width(); int i_height = input->height(); image<uchar> *pouc_output = new image<uchar>(i_width, i_height, false); if (max == min) return pouc_output; float fl_scale = UCHAR_MAX / (float)(max - min); for (int y = 0; y < i_height; y++) { for (int x = 0; x < i_width; x++) { uchar uc_val = (uchar)((imRef(input, x, y) - min) * fl_scale); imRef(pouc_output, x, y) = bound(uc_val, (uchar)0, (uchar)UCHAR_MAX); } } return pouc_output; } image<uchar> *imageSHORTtoUCHAR(image<short> *input) { short s_min, s_max; min_max(input, &s_min, &s_max); return imageSHORTtoUCHAR(input, s_min, s_max); }
[ "Tx_huntaway1023@163.com" ]
Tx_huntaway1023@163.com
d29b2df26638bb029a429e97d5041f2357e0b087
e929869ccbcd6142760b7b4acbb52d2d60beb2af
/lib/PID/PID.h
95e1a28bfbe7e02bdc2cf239b160abee5cc3b056
[]
no_license
rudra-potlapally/Epsilon-6-2022
6481974f406a76bb98f80d0fa1db3f1ea8dd5538
ce2c152a4d82d4d307c7522f179945734efd0775
refs/heads/main
2023-08-17T19:25:33.670674
2021-10-11T04:33:16
2021-10-11T04:33:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
366
h
#ifndef PID_H #define PID_H #include <Arduino.h> class PID { public: double kp; double ki; double kd; PID(double p, double i, double d, double absoluteMax = 0.0); double update(double input, double setpoint, double modulus = 0.0); private: unsigned long lastTime; double absMax; double integral; double lastInput; }; #endif
[ "27093@bbc.qld.edu.au" ]
27093@bbc.qld.edu.au
836eb26637f9d8a9fe2ea0bb1277a24c901dc174
ed033bdd4ded921dc94cc78110507e1e9e8c257c
/GL_Game_Colors/GL_Game_Colors/Painter.cpp
8ed8e7849b2adb86a13590ff34d035442710c64c
[]
no_license
coint-my/store
cda8f37db9859a02141e1f59aee9c56d79fdc145
395d717c8f3053ab3db3084f4261b0344cbbc4ba
refs/heads/master
2023-04-14T22:52:36.659403
2023-04-05T13:48:17
2023-04-05T13:48:17
245,461,456
0
0
null
null
null
null
UTF-8
C++
false
false
823
cpp
#include "Painter.h" Painter::Painter(void) { } Painter::~Painter(void) { } void Painter::DrawTile(const int _rad, const int _seg, const float _x, const float _y, const Color &_col) { glColor3f(_col.r, _col.g, _col.b); glBegin(GL_POLYGON); for(int i = 0; i < _seg; i++) { float angle = M_PI / _seg; float pos_x = _x + (cos(angle * i) * _rad); float pos_y = _y + (sin(angle * i) * _rad); glVertex2f(pos_x, pos_y); } glEnd(); } void Painter::DrawCircle(const int _rad, const float _x, const float _y, const Color &_col) { glLineWidth(4.0f); glColor3f(_col.r, _col.g, _col.b); glBegin(GL_LINE_STRIP); for(int i = 0; i < 24; i++) { float angle = M_PI / 23; float pos_x = _x + (cos(angle * i) * _rad); float pos_y = _y + (sin(angle * i) * _rad); glVertex2f(pos_x, pos_y); } glEnd(); }
[ "vovabelyaev1984@gmail.com" ]
vovabelyaev1984@gmail.com
21d3c5dac9a8fccb1a8f4de7e81df4674e4e79a0
80788be5905eee6c573fb310602dfe54143d0fba
/Source/DemoDisc1/EndGame/EndGameUI.h
bb6c83b3782e9d63ba0d87c55470bdb448cacf3e
[]
no_license
bgonz12/DemoDisc1
72e49c8601d17b4a019a3546f181825db84a27c1
6963d516e7e290330fe9a5aed32849e9dc9aec27
refs/heads/master
2021-04-19T03:30:07.701981
2020-05-27T18:11:39
2020-05-27T18:11:39
249,575,454
0
0
null
null
null
null
UTF-8
C++
false
false
547
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Blueprint/UserWidget.h" #include "EndGameUI.generated.h" /** * */ UCLASS() class DEMODISC1_API UEndGameUI : public UUserWidget { GENERATED_BODY() public: virtual bool Initialize() override; protected: UFUNCTION() void PhaseThreeAttack(); public: UFUNCTION(BlueprintImplementableEvent) void PlayCurtainFadeIn(float Delay); UFUNCTION(BlueprintImplementableEvent) void PlayCurtainFadeOut(float Delay); };
[ "bgonz12@hotmail.com" ]
bgonz12@hotmail.com
da6e2356d32819241b2f922b46da256fdd28dba1
d1827a314078bd6ea73bbe47e892853b2c578c9e
/src/qt/signverifymessagedialog.cpp
d4c3b1756dfdfa593aaba044de017bd79efd0ba7
[ "MIT" ]
permissive
404c/404
814fa768e518e72da629b21a32e13276a6808e26
2c9beab63f7fc6ba2faeff00faa9a6d38f82b728
refs/heads/master
2021-01-20T20:32:44.637573
2016-06-07T11:00:47
2016-06-07T11:00:47
60,607,108
0
0
null
null
null
null
UTF-8
C++
false
false
8,779
cpp
#include "signverifymessagedialog.h" #include "ui_signverifymessagedialog.h" #include "addressbookpage.h" #include "base58.h" #include "guiutil.h" #include "init.h" #include "main.h" #include "optionsmodel.h" #include "walletmodel.h" #include "wallet.h" #include <string> #include <vector> #include <QClipboard> SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SignVerifyMessageDialog), model(0) { ui->setupUi(this); #if (QT_VERSION >= 0x040700) /* Do not move this to the XML file, Qt before 4.7 will choke on it */ ui->addressIn_SM->setPlaceholderText(tr("Enter a 404coin address (e.g. B8gZqgY4r2RoEdqYk3QsAqFckyf9pRHN6i)")); ui->signatureOut_SM->setPlaceholderText(tr("Click \"Sign Message\" to generate signature")); ui->addressIn_VM->setPlaceholderText(tr("Enter a 404coin address (e.g. B8gZqgY4r2RoEdqYk3QsAqFckyf9pRHN6i)")); ui->signatureIn_VM->setPlaceholderText(tr("Enter 404coin signature")); #endif GUIUtil::setupAddressWidget(ui->addressIn_SM, this); GUIUtil::setupAddressWidget(ui->addressIn_VM, this); ui->addressIn_SM->installEventFilter(this); ui->messageIn_SM->installEventFilter(this); ui->signatureOut_SM->installEventFilter(this); ui->addressIn_VM->installEventFilter(this); ui->messageIn_VM->installEventFilter(this); ui->signatureIn_VM->installEventFilter(this); ui->signatureOut_SM->setFont(GUIUtil::bitcoinAddressFont()); ui->signatureIn_VM->setFont(GUIUtil::bitcoinAddressFont()); } SignVerifyMessageDialog::~SignVerifyMessageDialog() { delete ui; } void SignVerifyMessageDialog::setModel(WalletModel *model) { this->model = model; } void SignVerifyMessageDialog::setAddress_SM(QString address) { ui->addressIn_SM->setText(address); ui->messageIn_SM->setFocus(); } void SignVerifyMessageDialog::setAddress_VM(QString address) { ui->addressIn_VM->setText(address); ui->messageIn_VM->setFocus(); } void SignVerifyMessageDialog::showTab_SM(bool fShow) { ui->tabWidget->setCurrentIndex(0); if (fShow) this->show(); } void SignVerifyMessageDialog::showTab_VM(bool fShow) { ui->tabWidget->setCurrentIndex(1); if (fShow) this->show(); } void SignVerifyMessageDialog::on_addressBookButton_SM_clicked() { if (model && model->getAddressTableModel()) { AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this); dlg.setModel(model->getAddressTableModel()); if (dlg.exec()) { setAddress_SM(dlg.getReturnValue()); } } } void SignVerifyMessageDialog::on_pasteButton_SM_clicked() { setAddress_SM(QApplication::clipboard()->text()); } void SignVerifyMessageDialog::on_signMessageButton_SM_clicked() { /* Clear old signature to ensure users don't get confused on error with an old signature displayed */ ui->signatureOut_SM->clear(); CBitcoinAddress addr(ui->addressIn_SM->text().toStdString()); if (!addr.IsValid()) { ui->addressIn_SM->setValid(false); ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_SM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again.")); return; } CKeyID keyID; if (!addr.GetKeyID(keyID)) { ui->addressIn_SM->setValid(false); ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_SM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again.")); return; } WalletModel::UnlockContext ctx(model->requestUnlock()); if (!ctx.isValid()) { ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_SM->setText(tr("Wallet unlock was cancelled.")); return; } CKey key; if (!pwalletMain->GetKey(keyID, key)) { ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_SM->setText(tr("Private key for the entered address is not available.")); return; } CDataStream ss(SER_GETHASH, 0); ss << strMessageMagic; ss << ui->messageIn_SM->document()->toPlainText().toStdString(); std::vector<unsigned char> vchSig; if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig)) { ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_SM->setText(QString("<nobr>") + tr("Message signing failed.") + QString("</nobr>")); return; } ui->statusLabel_SM->setStyleSheet("QLabel { color: green; }"); ui->statusLabel_SM->setText(QString("<nobr>") + tr("Message signed.") + QString("</nobr>")); ui->signatureOut_SM->setText(QString::fromStdString(EncodeBase64(&vchSig[0], vchSig.size()))); } void SignVerifyMessageDialog::on_copySignatureButton_SM_clicked() { QApplication::clipboard()->setText(ui->signatureOut_SM->text()); } void SignVerifyMessageDialog::on_clearButton_SM_clicked() { ui->addressIn_SM->clear(); ui->messageIn_SM->clear(); ui->signatureOut_SM->clear(); ui->statusLabel_SM->clear(); ui->addressIn_SM->setFocus(); } void SignVerifyMessageDialog::on_addressBookButton_VM_clicked() { if (model && model->getAddressTableModel()) { AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); dlg.setModel(model->getAddressTableModel()); if (dlg.exec()) { setAddress_VM(dlg.getReturnValue()); } } } void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked() { CBitcoinAddress addr(ui->addressIn_VM->text().toStdString()); if (!addr.IsValid()) { ui->addressIn_VM->setValid(false); ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_VM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again.")); return; } CKeyID keyID; if (!addr.GetKeyID(keyID)) { ui->addressIn_VM->setValid(false); ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_VM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again.")); return; } bool fInvalid = false; std::vector<unsigned char> vchSig = DecodeBase64(ui->signatureIn_VM->text().toStdString().c_str(), &fInvalid); if (fInvalid) { ui->signatureIn_VM->setValid(false); ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_VM->setText(tr("The signature could not be decoded.") + QString(" ") + tr("Please check the signature and try again.")); return; } CDataStream ss(SER_GETHASH, 0); ss << strMessageMagic; ss << ui->messageIn_VM->document()->toPlainText().toStdString(); CKey key; if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig)) { ui->signatureIn_VM->setValid(false); ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_VM->setText(tr("The signature did not match the message digest.") + QString(" ") + tr("Please check the signature and try again.")); return; } if (!(CBitcoinAddress(key.GetPubKey().GetID()) == addr)) { ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_VM->setText(QString("<nobr>") + tr("Message verification failed.") + QString("</nobr>")); return; } ui->statusLabel_VM->setStyleSheet("QLabel { color: green; }"); ui->statusLabel_VM->setText(QString("<nobr>") + tr("Message verified.") + QString("</nobr>")); } void SignVerifyMessageDialog::on_clearButton_VM_clicked() { ui->addressIn_VM->clear(); ui->signatureIn_VM->clear(); ui->messageIn_VM->clear(); ui->statusLabel_VM->clear(); ui->addressIn_VM->setFocus(); } bool SignVerifyMessageDialog::eventFilter(QObject *object, QEvent *event) { if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::FocusIn) { if (ui->tabWidget->currentIndex() == 0) { /* Clear status message on focus change */ ui->statusLabel_SM->clear(); /* Select generated signature */ if (object == ui->signatureOut_SM) { ui->signatureOut_SM->selectAll(); return true; } } else if (ui->tabWidget->currentIndex() == 1) { /* Clear status message on focus change */ ui->statusLabel_VM->clear(); } } return QDialog::eventFilter(object, event); }
[ "404coin@scryptmail.com" ]
404coin@scryptmail.com
2a465783748c7c72a8877a8e5b5f4666644d2b23
6ef6213d2fa39d1d0ab7e2373d882b9d263e8c6d
/vision_sdk/apps/tools/vision_sdk_usecase_gen/vsdk-ctx.h
73879caf09fc890b2d528bace629a62530deba94
[]
no_license
Zhangh2018/PROCESSOR_SDK_VISION_03_06_00_00
9c380d3167b156a11a8f21814e94ac5550cddc87
05c72de5d031006c7565d4234abd53670a926acd
refs/heads/master
2021-10-16T13:43:05.313842
2019-02-11T09:10:44
2019-02-11T09:10:44
null
0
0
null
null
null
null
MacCentralEurope
C++
false
false
3,144
h
/****************************************************************************** Copyright (c) [2012 - 2017] Texas Instruments Incorporated All rights reserved not granted herein. Limited License. Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive license under copyrights and patents it now or hereafter owns or controls to make, have made, use, import, offer to sell and sell ("Utilize") this software subject to the terms herein. With respect to the foregoing patent license, such license is granted solely to the extent that any such patent is necessary to Utilize the software alone. The patent license shall not apply to any combinations which include this software, other than combinations with devices manufactured by or for TI ("TI Devices"). No hardware patent is licensed hereunder. Redistributions must preserve existing copyright notices and reproduce this license (including the above copyright notice and the disclaimer and (if applicable) source code license limitations below) in the documentation and/or other materials provided with the distribution Redistribution and use in binary form, without modification, are permitted provided that the following conditions are met: * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any software provided in binary form. * Any redistribution and use are licensed by TI for use only with TI Devices. * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code. If software source code is provided to you, modification and redistribution of the source code are permitted provided that the following conditions are met: * Any redistribution and use of the source code, including any resulting derivative works, are licensed by TI for use only with TI Devices. * Any redistribution and use of any object code compiled from the source code and any resulting derivative works, are licensed by TI for use only with TI Devices. Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or promote products derived from this software without specific prior written permission. DISCLAIMER. THIS SOFTWARE IS PROVIDED BY TI AND TIรญS LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TI AND TIรญS LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ class vsdk_ctx { public: vsdk_ctx(); };
[ "yukichen@otobrite.com" ]
yukichen@otobrite.com
077e108ff2502363cd26c6bb66914be2a8c4b812
ddf1edc6d185169aabfbbf4465d24421e568868a
/Activity2/main.cpp
8db639bdf4ef510027aa63a95e0ce810ae9ff721
[]
no_license
Jatapiaro/Activity
b7ab22f0bc7abb780b9bccd69615ef371b830636
8cbcb3f16147c8a28897ca14d63adf98e3c6d0e4
refs/heads/master
2020-05-26T14:41:58.479224
2017-03-15T00:55:29
2017-03-15T00:55:29
85,006,901
0
0
null
null
null
null
UTF-8
C++
false
false
7,815
cpp
/* TC3022. Computer Graphics Sergio Ruiz External geometry loader activity. */ #ifdef __APPLE__ #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include <GLUT/glut.h> #else #include "freeglut.h" #endif #include <stdio.h> #include <math.h> // NATE ROBINS' OBJ MODEL LOADER (http://devernay.free.fr/hacks/glm/) #include "glm.h" ///////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// #include "cPlaneCreator.h" #define DO_ROTATION_X GLfloat rotationY = 0.0f; GLfloat rotationX = 0.0f; GLfloat* mat0_specular; GLfloat* mat0_diffuse; GLfloat* mat0_shininess; GLfloat* light0_position; GLMmodel* model; PlaneCreator* pc; void init(void) { glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); glClearColor(0.2, 0.2, 0.2, 1.0); pc = new PlaneCreator(20, 30); pc->create(); /* A C T I V I T Y 2. (90 minutes). PERSONAL / PROJECT TEAMS -------------------------------------------------------------- 1. GEOMETRY 1.1 Open a new text file (in Notepad or some editor) and type lines 54-73: # THIS IS A COMMENT. # CUBE TC3022. EXTERNAL GEOMETRY # VERTICES. Format: # v X Y Z v -1.0 -1.0 1.0 v 1.0 -1.0 1.0 v 1.0 1.0 1.0 v -1.0 1.0 1.0 # NORMALS. Format: # vn X Y Z vn 0 0 1 # FACES. Format: # f VERTEX_INDEX/TEXTURE_INDEX/NORMAL_INDEX # >>>Indices start from 1. f 1//1 2//1 3//1 4//1 1.2 Save the file as "assets/cube.obj" inside this project. 1.3 This information is the front face only. Finish the cube: 1.3.1 Do not repeat vertices, normals or faces. 1.3.2 To make the process easier, complete the faces in the following order: FRONT, RIGHT, BACK, LEFT, TOP, BOTTOM 1.3.3 Write vertices forming each face starting from the bottom-left and counter-clockwise. Remember not to repeat the vertices you already have. 1.4 When the cube is ready, create a new folder (ACTIVITY2) and copy your cube.obj and a screen capture of this application (NOT any other OBJ viewer) displaying your cube to the ACTIVITY2 folder. 2. MATERIALS 2.1 Open a new text file (in Notepad or some editor) and type lines 78-92: # cube_material.mtl for cube_material.obj # material name: newmtl cube_mat # light power: illum 1 # AMBIENT COMPONENT: Ka 0.1 0.01 0.01 # DIFFUSE COMPONENT: Kd 1.0 0.101960786 0.05882353 # SPECULAR COPONENT: Ks 0.0 0.0 0.0 # SPECULAR POWER: Ns 1.0 2.2 Save the file as "assets/cube_material.mtl" inside this project. 2.3 Save a copy of your "assets/cube.obj" file as "assets/cube_material.obj". Edit "assets/cube_material.obj" inserting the following lines before the vertices (insert around line 3): mtllib cube_material.mtl usemtl cube_mat 2.4 You'll end up with two new files: "assets/cube_material.mtl" and "assets/cube_material.obj". Now edit this file (main.cpp), at the display function to go from this: glmDraw(model, GLM_SMOOTH); To this: glmDraw(model, GLM_MATERIAL | GLM_SMOOTH); 2.5 When the cube is ready, copy your cube_material.obj, cube_material.mtl and a screen capture of this application (NOT any other OBJ viewer) displaying your cube with materials to the ACTIVITY2 folder. 3. SCALING 3.1 Download mystery1.obj to your assets folder. 3.2 Read the rest of this code and add a screen capture of this application displaying the full shape of mystery1.obj to your ACTIVITY2 folder. 4. GENERATION OF NORMALS 4.1 Download mystery2.obj to your assets folder. 4.2 Read the rest of this code and use the GLM library to generate model normals after loading. Add a screen capture of this application displaying the full shape of mystery2.obj with the generated normals to your ACTIVITY2 folder. 5. DO YOUR OWN 5.1 Visit http://tf3dm.com/ and download an OBJ you like. Display it and save a screenshot of this application to your ACTIVITY2 folder. 6. ADVANCED: CREATE GEOMETRY PROGRAMMATICALLY 6.1 Complete cPlaneCreator.cpp and uncomment line 44 in this file to generate plane.obj (20x30 triangles). 6.1.1 Complete the constructor with the size of "faces" (line 9). Consider that the final shape will have (rows-1) X (columns-1) cells, and each cell will have 2 faces (triangles). 6.1.2 In the "create" function, fill the "faces" array and finally write the output to the file. 6.2 Copy cPlaneCreator.cpp and plane.obj to your ACTIVITY2 folder. 7. Upload ACTIVITY2.zip to Blackboard, checking that you send: * cube.obj (10 points) * cube SCREENSHOT (10 points) * cube_material.obj (10 points) * cube_material.mtl (10 points) * cube_material SCREENSHOT (10 points) * mystery1 SCREENSHOT (10 points) * mystery2 SCREENSHOT (10 points) * your geometry SCREENSHOT (10 points) * cPlaneCreator.cpp (10 points) * plane.obj (10 points) */ model = glmReadOBJ("/Users/jacobotapia/Desktop/Activity2/my_plane.obj"); // When the model is too big make it fit inside a 1x1x1 cube: //glmUnitize(model); // You can also scale it later: //glmScale(model, 1.8f); // When the model doesn't have normals, glm can add them automatically for you: glmVertexNormals(model, 45.0f, false); // first per vertex... glmFacetNormals(model); // ...and then per face light0_position = new GLfloat[4]; light0_position[0] = 3; light0_position[1] = 3; light0_position[2] = 0; light0_position[3] = 1; // POINT LIGHT glLightfv(GL_LIGHT0, GL_POSITION, light0_position); mat0_specular = new GLfloat[4]; mat0_specular[0] = 1.0f; mat0_specular[1] = 1.0f; mat0_specular[2] = 1.0f; mat0_specular[3] = 1.0f; mat0_diffuse = new GLfloat[4]; mat0_diffuse[0] = 0.8f; mat0_diffuse[1] = 0.7f; mat0_diffuse[2] = 0.6f; mat0_diffuse[3] = 1.0f; mat0_shininess = new GLfloat[1]; mat0_shininess[0] = 100.0f; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat0_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat0_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat0_shininess); glPushMatrix(); { glRotatef(rotationX, 1, 0, 0); glRotatef(rotationY, 0, 1, 0); //glmDraw(model, GLM_MATERIAL | GLM_SMOOTH); } glPopMatrix(); glutSwapBuffers(); } void idle(void) { rotationY += 0.08f; if (rotationY > 360) { rotationY = 0; } #ifdef DO_ROTATION_X rotationX += 0.02f; if (rotationX > 360) { rotationX = 0; } #endif glutPostRedisplay(); } void reshape(int w, int h) { glViewport(0, 0, (GLsizei)w, (GLsizei)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(40.0, (GLdouble)w / (GLdouble)h, 0.01, 20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0, 2.1, 5.3, 0, 0, 0, 0, 1, 0); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(800, 800); glutInitWindowPosition(100, 50); glutCreateWindow("OBJ Loader!"); glutReshapeFunc(reshape); init(); glutDisplayFunc(display); glutIdleFunc(idle); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
[ "jacob.et.cetera@gmail.com" ]
jacob.et.cetera@gmail.com
0fd69a9dcfead279458bb054b40fcb440c90eda0
0dca3325c194509a48d0c4056909175d6c29f7bc
/outboundbot/src/model/GetAfterAnswerDelayPlaybackRequest.cc
ed610557a4d3a05edd6b979d3d0c794e0f3731c7
[ "Apache-2.0" ]
permissive
dingshiyu/aliyun-openapi-cpp-sdk
3eebd9149c2e6a2b835aba9d746ef9e6bef9ad62
4edd799a79f9b94330d5705bb0789105b6d0bb44
refs/heads/master
2023-07-31T10:11:20.446221
2021-09-26T10:08:42
2021-09-26T10:08:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,586
cc
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <alibabacloud/outboundbot/model/GetAfterAnswerDelayPlaybackRequest.h> using AlibabaCloud::OutboundBot::Model::GetAfterAnswerDelayPlaybackRequest; GetAfterAnswerDelayPlaybackRequest::GetAfterAnswerDelayPlaybackRequest() : RpcServiceRequest("outboundbot", "2019-12-26", "GetAfterAnswerDelayPlayback") { setMethod(HttpRequest::Method::Post); } GetAfterAnswerDelayPlaybackRequest::~GetAfterAnswerDelayPlaybackRequest() {} int GetAfterAnswerDelayPlaybackRequest::getStrategyLevel()const { return strategyLevel_; } void GetAfterAnswerDelayPlaybackRequest::setStrategyLevel(int strategyLevel) { strategyLevel_ = strategyLevel; setParameter("StrategyLevel", std::to_string(strategyLevel)); } std::string GetAfterAnswerDelayPlaybackRequest::getEntryId()const { return entryId_; } void GetAfterAnswerDelayPlaybackRequest::setEntryId(const std::string& entryId) { entryId_ = entryId; setParameter("EntryId", entryId); }
[ "sdk-team@alibabacloud.com" ]
sdk-team@alibabacloud.com
d0879019378c1879ee807f523a2f9a06935626e3
4d6aba3a0de0cd804305360649d9571a55b1c26c
/src/merkleblock.cpp
fddf7dbda695bbdae4a6d13589a57414738c4cb8
[ "MIT" ]
permissive
PPeshev/MOK
cddf68771b73b573d377e13ce2297ee3b46a0c4c
eae922e60159aa4db696ea64ca69198669ed56d1
refs/heads/master
2020-03-25T12:00:27.334757
2018-09-24T14:52:19
2018-09-24T14:52:19
133,274,119
0
0
null
null
null
null
UTF-8
C++
false
false
5,838
cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2016-2018 The PIVX developers // Copyright (c) 2018 The MOKEN developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "merkleblock.h" #include "hash.h" #include "primitives/block.h" // for MAX_BLOCK_SIZE #include "utilstrencodings.h" using namespace std; CMerkleBlock::CMerkleBlock(const CBlock& block, CBloomFilter& filter) { header = block.GetBlockHeader(); vector<bool> vMatch; vector<uint256> vHashes; vMatch.reserve(block.vtx.size()); vHashes.reserve(block.vtx.size()); for (unsigned int i = 0; i < block.vtx.size(); i++) { const uint256& hash = block.vtx[i].GetHash(); if (filter.IsRelevantAndUpdate(block.vtx[i])) { vMatch.push_back(true); vMatchedTxn.push_back(make_pair(i, hash)); } else vMatch.push_back(false); vHashes.push_back(hash); } txn = CPartialMerkleTree(vHashes, vMatch); } uint256 CPartialMerkleTree::CalcHash(int height, unsigned int pos, const std::vector<uint256>& vTxid) { if (height == 0) { // hash at height 0 is the txids themself return vTxid[pos]; } else { // calculate left hash uint256 left = CalcHash(height - 1, pos * 2, vTxid), right; // calculate right hash if not beyond the end of the array - copy left hash otherwise1 if (pos * 2 + 1 < CalcTreeWidth(height - 1)) right = CalcHash(height - 1, pos * 2 + 1, vTxid); else right = left; // combine subhashes return Hash(BEGIN(left), END(left), BEGIN(right), END(right)); } } void CPartialMerkleTree::TraverseAndBuild(int height, unsigned int pos, const std::vector<uint256>& vTxid, const std::vector<bool>& vMatch) { // determine whether this node is the parent of at least one matched txid bool fParentOfMatch = false; for (unsigned int p = pos << height; p < (pos + 1) << height && p < nTransactions; p++) fParentOfMatch |= vMatch[p]; // store as flag bit vBits.push_back(fParentOfMatch); if (height == 0 || !fParentOfMatch) { // if at height 0, or nothing interesting below, store hash and stop vHash.push_back(CalcHash(height, pos, vTxid)); } else { // otherwise, don't store any hash, but descend into the subtrees TraverseAndBuild(height - 1, pos * 2, vTxid, vMatch); if (pos * 2 + 1 < CalcTreeWidth(height - 1)) TraverseAndBuild(height - 1, pos * 2 + 1, vTxid, vMatch); } } uint256 CPartialMerkleTree::TraverseAndExtract(int height, unsigned int pos, unsigned int& nBitsUsed, unsigned int& nHashUsed, std::vector<uint256>& vMatch) { if (nBitsUsed >= vBits.size()) { // overflowed the bits array - failure fBad = true; return 0; } bool fParentOfMatch = vBits[nBitsUsed++]; if (height == 0 || !fParentOfMatch) { // if at height 0, or nothing interesting below, use stored hash and do not descend if (nHashUsed >= vHash.size()) { // overflowed the hash array - failure fBad = true; return 0; } const uint256& hash = vHash[nHashUsed++]; if (height == 0 && fParentOfMatch) // in case of height 0, we have a matched txid vMatch.push_back(hash); return hash; } else { // otherwise, descend into the subtrees to extract matched txids and hashes uint256 left = TraverseAndExtract(height - 1, pos * 2, nBitsUsed, nHashUsed, vMatch), right; if (pos * 2 + 1 < CalcTreeWidth(height - 1)) right = TraverseAndExtract(height - 1, pos * 2 + 1, nBitsUsed, nHashUsed, vMatch); else right = left; // and combine them before returning return Hash(BEGIN(left), END(left), BEGIN(right), END(right)); } } CPartialMerkleTree::CPartialMerkleTree(const std::vector<uint256>& vTxid, const std::vector<bool>& vMatch) : nTransactions(vTxid.size()), fBad(false) { // reset state vBits.clear(); vHash.clear(); // calculate height of tree int nHeight = 0; while (CalcTreeWidth(nHeight) > 1) nHeight++; // traverse the partial tree TraverseAndBuild(nHeight, 0, vTxid, vMatch); } CPartialMerkleTree::CPartialMerkleTree() : nTransactions(0), fBad(true) {} uint256 CPartialMerkleTree::ExtractMatches(std::vector<uint256>& vMatch) { vMatch.clear(); // An empty set will not work if (nTransactions == 0) return 0; // check for excessively high numbers of transactions if (nTransactions > MAX_BLOCK_SIZE_CURRENT / 60) // 60 is the lower bound for the size of a serialized CTransaction return 0; // there can never be more hashes provided than one for every txid if (vHash.size() > nTransactions) return 0; // there must be at least one bit per node in the partial tree, and at least one node per hash if (vBits.size() < vHash.size()) return 0; // calculate height of tree int nHeight = 0; while (CalcTreeWidth(nHeight) > 1) nHeight++; // traverse the partial tree unsigned int nBitsUsed = 0, nHashUsed = 0; uint256 hashMerkleRoot = TraverseAndExtract(nHeight, 0, nBitsUsed, nHashUsed, vMatch); // verify that no problems occured during the tree traversal if (fBad) return 0; // verify that all bits were consumed (except for the padding caused by serializing it as a byte sequence) if ((nBitsUsed + 7) / 8 != (vBits.size() + 7) / 8) return 0; // verify that all hashes were consumed if (nHashUsed != vHash.size()) return 0; return hashMerkleRoot; }
[ "lordpgp@gmail.com" ]
lordpgp@gmail.com
3fd298f92410e488e2bc52f253306f73c0c68239
a7bedf7925ce55e12337d3c6827c1e456c8d4d89
/BinaryTreePreorderTraversal.cpp
5cf970ca5581ac5831bfac4a2e6e158f54b18d86
[]
no_license
denisewu/LeetCode
f9d1e90d8d6e205727426a330d7d32021e8c3445
cea84d40a79106803f5d0ffdcdd548a96d0e86eb
refs/heads/master
2021-01-01T15:25:17.356794
2015-03-16T14:08:30
2015-03-16T14:08:30
10,868,083
0
0
null
null
null
null
UTF-8
C++
false
false
787
cpp
/* Given a binary tree, return the preorder traversal of its nodes' values. */ /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: vector<int> preorderTraversal(TreeNode *root) { vector<int> ret; stack<TreeNode* > s; if(root == NULL) return ret; s.push(root); while(!s.empty()) { TreeNode *p = s.top(); ret.push_back(p->val); s.pop(); if(p->right) s.push(p->right); if(p->left) s.push(p->left); } return ret; } };
[ "denisewu.ict@gmail.com" ]
denisewu.ict@gmail.com
f2d4248cfec4132eafb14863dc0c3f334d9cdd21
cf2d0d0a648e912abb4b9b600ea0f287c2e4cac2
/DMD/DMD.cpp
2d9d5a3effd5f9f0a7d8366de02945e2b24f70d2
[]
no_license
tqkhcmut/DMD_APP
a8f031487f8ac466f3898566b77493a327363692
b2906d8917643d1e302491c6037aa75dfc438bdf
refs/heads/master
2020-06-01T04:29:41.820318
2014-04-08T10:06:05
2014-04-08T10:06:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
19,858
cpp
/*-------------------------------------------------------------------------------------- DMD.cpp - Function and support library for the Freetronics DMD, a 512 LED matrix display panel arranged in a 32 x 16 layout. Copyright (C) 2011 Marc Alexander (info <at> freetronics <dot> com) Note that the DMD library uses the SPI port for the fastest, low overhead writing to the display. Keep an eye on conflicts if there are any other devices running from the same SPI port, and that the chip select on those devices is correctly set to be inactive when the DMD is being written to. --- This program is free software: you can redistribute it and/or modify it under the terms of the version 3 GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. --------------------------------------------------------------------------------------*/ #include "DMD.h" // byte PIN_DMD_nOE = 9; // this is default /*-------------------------------------------------------------------------------------- Setup and instantiation of DMD library Note this currently uses the SPI port for the fastest performance to the DMD, be careful of possible conflicts with other SPI port devices --------------------------------------------------------------------------------------*/ DMD::DMD(byte panelsWide, byte panelsHigh, byte OE_Pin) { // OE_Pin_private = OE_Pin; PIN_DMD_nOE = OE_Pin_private; uint16_t ui; DisplaysWide=panelsWide; DisplaysHigh=panelsHigh; DisplaysTotal=DisplaysWide*DisplaysHigh; row1 = DisplaysTotal<<4; row2 = DisplaysTotal<<5; row3 = ((DisplaysTotal<<2)*3)<<2; bDMDScreenRAM = (byte *) malloc(DisplaysTotal*DMD_RAM_SIZE_BYTES); // initialize the SPI port SPI.begin(); // probably don't need this since it inits the port pins only, which we do just below with the appropriate DMD interface setup SPI.setBitOrder(MSBFIRST); // SPI.setDataMode(SPI_MODE0); // CPOL=0, CPHA=0 SPI.setClockDivider(SPI_CLOCK_DIV128); // system clock / 2 = 8MHz SPI CLK to shift registers digitalWrite(PIN_DMD_A, LOW); // digitalWrite(PIN_DMD_B, LOW); // digitalWrite(PIN_DMD_CLK, LOW); // digitalWrite(PIN_DMD_SCLK, LOW); // digitalWrite(PIN_DMD_R_DATA, HIGH); // digitalWrite(PIN_DMD_nOE, LOW); // pinMode(PIN_DMD_A, OUTPUT); // pinMode(PIN_DMD_B, OUTPUT); // pinMode(PIN_DMD_CLK, OUTPUT); // pinMode(PIN_DMD_SCLK, OUTPUT); // pinMode(PIN_DMD_R_DATA, OUTPUT); // pinMode(PIN_DMD_nOE, OUTPUT); // // this line have been added to prevent pin state was indefinite pinMode(PIN_OTHER_SPI_nCS, INPUT_PULLUP); // clearScreen(true); // init the scan line/ram pointer to the required start point bDMDByte = 0; } //DMD::~DMD() //{ // // nothing needed here //} /*-------------------------------------------------------------------------------------- Set or clear a pixel at the x and y location (0,0 is the top left corner) --------------------------------------------------------------------------------------*/ void DMD::writePixel(unsigned int bX, unsigned int bY, byte bGraphicsMode, byte bPixel) { unsigned int uiDMDRAMPointer; if (bX >= (DMD_PIXELS_ACROSS*DisplaysWide) || bY >= (DMD_PIXELS_DOWN * DisplaysHigh)) { return; } byte panel=(bX/DMD_PIXELS_ACROSS) + (DisplaysWide*(bY/DMD_PIXELS_DOWN)); bX=(bX % DMD_PIXELS_ACROSS) + (panel<<5); bY=bY % DMD_PIXELS_DOWN; //set pointer to DMD RAM byte to be modified uiDMDRAMPointer = bX/8 + bY*(DisplaysTotal<<2); byte lookup = bPixelLookupTable[bX & 0x07]; switch (bGraphicsMode) { case GRAPHICS_NORMAL: if (bPixel == true) bDMDScreenRAM[uiDMDRAMPointer] &= ~lookup; // zero bit is pixel on else bDMDScreenRAM[uiDMDRAMPointer] |= lookup; // one bit is pixel off break; case GRAPHICS_INVERSE: if (bPixel == false) bDMDScreenRAM[uiDMDRAMPointer] &= ~lookup; // zero bit is pixel on else bDMDScreenRAM[uiDMDRAMPointer] |= lookup; // one bit is pixel off break; case GRAPHICS_TOGGLE: if (bPixel == true) { if ((bDMDScreenRAM[uiDMDRAMPointer] & lookup) == 0) bDMDScreenRAM[uiDMDRAMPointer] |= lookup; // one bit is pixel off else bDMDScreenRAM[uiDMDRAMPointer] &= ~lookup; // one bit is pixel off } break; case GRAPHICS_OR: //only set pixels on if (bPixel == true) bDMDScreenRAM[uiDMDRAMPointer] &= ~lookup; // zero bit is pixel on break; case GRAPHICS_NOR: //only clear on pixels if ((bPixel == true) && ((bDMDScreenRAM[uiDMDRAMPointer] & lookup) == 0)) bDMDScreenRAM[uiDMDRAMPointer] |= lookup; // one bit is pixel off break; } } void DMD::drawString(int bX, int bY, const char *bChars, byte length, byte bGraphicsMode) { if (bX >= (DMD_PIXELS_ACROSS*DisplaysWide) || bY >= DMD_PIXELS_DOWN * DisplaysHigh) return; uint8_t height = pgm_read_byte(this->Font + FONT_HEIGHT); if (bY+height<0) return; int strWidth = 0; this->drawLine(bX -1 , bY, bX -1 , bY + height, GRAPHICS_INVERSE); for (int i = 0; i < length; i++) { int charWide = this->drawChar(bX+strWidth, bY, bChars[i], bGraphicsMode); if (charWide > 0) { strWidth += charWide ; this->drawLine(bX + strWidth , bY, bX + strWidth , bY + height, GRAPHICS_INVERSE); strWidth++; } else if (charWide < 0) { return; } if ((bX + strWidth) >= DMD_PIXELS_ACROSS * DisplaysWide || bY >= DMD_PIXELS_DOWN * DisplaysHigh) return; } } void DMD::drawMarquee(const char *bChars, byte length, int left, int top) { marqueeWidth = 0; for (int i = 0; i < length; i++) { marqueeText[i] = bChars[i]; marqueeWidth += charWidth(bChars[i]) + 1; } marqueeHeight=pgm_read_byte(this->Font + FONT_HEIGHT); marqueeText[length] = '\0'; marqueeOffsetY = top; marqueeOffsetX = left; marqueeLength = length; drawString(marqueeOffsetX, marqueeOffsetY, marqueeText, marqueeLength, GRAPHICS_NORMAL); } boolean DMD::stepMarquee(int amountX, int amountY) { boolean ret=false; marqueeOffsetX += amountX; marqueeOffsetY += amountY; if (marqueeOffsetX < -marqueeWidth) { marqueeOffsetX = DMD_PIXELS_ACROSS * DisplaysWide; clearScreen(true); ret=true; } else if (marqueeOffsetX > DMD_PIXELS_ACROSS * DisplaysWide) { marqueeOffsetX = -marqueeWidth; clearScreen(true); ret=true; } if (marqueeOffsetY < -marqueeHeight) { marqueeOffsetY = DMD_PIXELS_DOWN * DisplaysHigh; clearScreen(true); ret=true; } else if (marqueeOffsetY > DMD_PIXELS_DOWN * DisplaysHigh) { marqueeOffsetY = -marqueeHeight; clearScreen(true); ret=true; } // Special case horizontal scrolling to improve speed if (amountY==0 && amountX==-1) { // Shift entire screen one bit for (int i=0; i<DMD_RAM_SIZE_BYTES*DisplaysTotal;i++) { if ((i%(DisplaysWide*4)) == (DisplaysWide*4) -1) { bDMDScreenRAM[i]=(bDMDScreenRAM[i]<<1)+1; } else { bDMDScreenRAM[i]=(bDMDScreenRAM[i]<<1) + ((bDMDScreenRAM[i+1] & 0x80) >>7); } } // Redraw last char on screen int strWidth=marqueeOffsetX; for (byte i=0; i < marqueeLength; i++) { int wide = charWidth(marqueeText[i]); if (strWidth+wide >= DisplaysWide*DMD_PIXELS_ACROSS) { drawChar(strWidth, marqueeOffsetY,marqueeText[i],GRAPHICS_NORMAL); return ret; } strWidth += wide+1; } } else if (amountY==0 && amountX==1) { // Shift entire screen one bit for (int i=(DMD_RAM_SIZE_BYTES*DisplaysTotal)-1; i>=0;i--) { if ((i%(DisplaysWide*4)) == 0) { bDMDScreenRAM[i]=(bDMDScreenRAM[i]>>1)+128; } else { bDMDScreenRAM[i]=(bDMDScreenRAM[i]>>1) + ((bDMDScreenRAM[i-1] & 1) <<7); } } // Redraw last char on screen int strWidth=marqueeOffsetX; for (byte i=0; i < marqueeLength; i++) { int wide = charWidth(marqueeText[i]); if (strWidth+wide >= 0) { drawChar(strWidth, marqueeOffsetY,marqueeText[i],GRAPHICS_NORMAL); return ret; } strWidth += wide+1; } } else { drawString(marqueeOffsetX, marqueeOffsetY, marqueeText, marqueeLength, GRAPHICS_NORMAL); } return ret; } /*-------------------------------------------------------------------------------------- Clear the screen in DMD RAM --------------------------------------------------------------------------------------*/ void DMD::clearScreen(byte bNormal) { if (bNormal) // clear all pixels memset(bDMDScreenRAM,0xFF,DMD_RAM_SIZE_BYTES*DisplaysTotal); else // set all pixels memset(bDMDScreenRAM,0x00,DMD_RAM_SIZE_BYTES*DisplaysTotal); } /*-------------------------------------------------------------------------------------- Draw or clear a line from x1,y1 to x2,y2 --------------------------------------------------------------------------------------*/ void DMD::drawLine(int x1, int y1, int x2, int y2, byte bGraphicsMode) { int dy = y2 - y1; int dx = x2 - x1; int stepx, stepy; if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } dy <<= 1; // dy is now 2*dy dx <<= 1; // dx is now 2*dx writePixel(x1, y1, bGraphicsMode, true); if (dx > dy) { int fraction = dy - (dx >> 1); // same as 2*dy - dx while (x1 != x2) { if (fraction >= 0) { y1 += stepy; fraction -= dx; // same as fraction -= 2*dx } x1 += stepx; fraction += dy; // same as fraction -= 2*dy writePixel(x1, y1, bGraphicsMode, true); } } else { int fraction = dx - (dy >> 1); while (y1 != y2) { if (fraction >= 0) { x1 += stepx; fraction -= dy; } y1 += stepy; fraction += dx; writePixel(x1, y1, bGraphicsMode, true); } } } /*-------------------------------------------------------------------------------------- Draw or clear a circle of radius r at x,y centre --------------------------------------------------------------------------------------*/ void DMD::drawCircle(int xCenter, int yCenter, int radius, byte bGraphicsMode) { int x = 0; int y = radius; int p = (5 - radius * 4) / 4; drawCircleSub(xCenter, yCenter, x, y, bGraphicsMode); while (x < y) { x++; if (p < 0) { p += 2 * x + 1; } else { y--; p += 2 * (x - y) + 1; } drawCircleSub(xCenter, yCenter, x, y, bGraphicsMode); } } void DMD::drawCircleSub(int cx, int cy, int x, int y, byte bGraphicsMode) { if (x == 0) { writePixel(cx, cy + y, bGraphicsMode, true); writePixel(cx, cy - y, bGraphicsMode, true); writePixel(cx + y, cy, bGraphicsMode, true); writePixel(cx - y, cy, bGraphicsMode, true); } else if (x == y) { writePixel(cx + x, cy + y, bGraphicsMode, true); writePixel(cx - x, cy + y, bGraphicsMode, true); writePixel(cx + x, cy - y, bGraphicsMode, true); writePixel(cx - x, cy - y, bGraphicsMode, true); } else if (x < y) { writePixel(cx + x, cy + y, bGraphicsMode, true); writePixel(cx - x, cy + y, bGraphicsMode, true); writePixel(cx + x, cy - y, bGraphicsMode, true); writePixel(cx - x, cy - y, bGraphicsMode, true); writePixel(cx + y, cy + x, bGraphicsMode, true); writePixel(cx - y, cy + x, bGraphicsMode, true); writePixel(cx + y, cy - x, bGraphicsMode, true); writePixel(cx - y, cy - x, bGraphicsMode, true); } } /*-------------------------------------------------------------------------------------- Draw or clear a box(rectangle) with a single pixel border --------------------------------------------------------------------------------------*/ void DMD::drawBox(int x1, int y1, int x2, int y2, byte bGraphicsMode) { drawLine(x1, y1, x2, y1, bGraphicsMode); drawLine(x2, y1, x2, y2, bGraphicsMode); drawLine(x2, y2, x1, y2, bGraphicsMode); drawLine(x1, y2, x1, y1, bGraphicsMode); } /*-------------------------------------------------------------------------------------- Draw or clear a filled box(rectangle) with a single pixel border --------------------------------------------------------------------------------------*/ void DMD::drawFilledBox(int x1, int y1, int x2, int y2, byte bGraphicsMode) { for (int b = x1; b <= x2; b++) { drawLine(b, y1, b, y2, bGraphicsMode); } } /*-------------------------------------------------------------------------------------- Draw the selected test pattern --------------------------------------------------------------------------------------*/ void DMD::drawTestPattern(byte bPattern) { unsigned int ui; int numPixels=DisplaysTotal * DMD_PIXELS_ACROSS * DMD_PIXELS_DOWN; int pixelsWide=DMD_PIXELS_ACROSS*DisplaysWide; for (ui = 0; ui < numPixels; ui++) { switch (bPattern) { case PATTERN_ALT_0: // every alternate pixel, first pixel on if ((ui & pixelsWide) == 0) //even row writePixel((ui & (pixelsWide-1)), ((ui & ~(pixelsWide-1)) / pixelsWide), GRAPHICS_NORMAL, ui & 1); else //odd row writePixel((ui & (pixelsWide-1)), ((ui & ~(pixelsWide-1)) / pixelsWide), GRAPHICS_NORMAL, !(ui & 1)); break; case PATTERN_ALT_1: // every alternate pixel, first pixel off if ((ui & pixelsWide) == 0) //even row writePixel((ui & (pixelsWide-1)), ((ui & ~(pixelsWide-1)) / pixelsWide), GRAPHICS_NORMAL, !(ui & 1)); else //odd row writePixel((ui & (pixelsWide-1)), ((ui & ~(pixelsWide-1)) / pixelsWide), GRAPHICS_NORMAL, ui & 1); break; case PATTERN_STRIPE_0: // vertical stripes, first stripe on writePixel((ui & (pixelsWide-1)), ((ui & ~(pixelsWide-1)) / pixelsWide), GRAPHICS_NORMAL, ui & 1); break; case PATTERN_STRIPE_1: // vertical stripes, first stripe off writePixel((ui & (pixelsWide-1)), ((ui & ~(pixelsWide-1)) / pixelsWide), GRAPHICS_NORMAL, !(ui & 1)); break; } } } /*-------------------------------------------------------------------------------------- Scan the dot matrix LED panel display, from the RAM mirror out to the display hardware. Call 4 times to scan the whole display which is made up of 4 interleaved rows within the 16 total rows. Insert the calls to this function into the main loop for the highest call rate, or from a timer interrupt --------------------------------------------------------------------------------------*/ void DMD::scanDisplayBySPI() { // OE_DMD_ROWS_OFF(); PIN_DMD_nOE = OE_Pin_private; //if PIN_OTHER_SPI_nCS is in use during a DMD scan request then scanDisplayBySPI() will exit without conflict! (and skip that scan) if( digitalRead( PIN_OTHER_SPI_nCS ) == HIGH ) { //SPI transfer pixels to the display hardware shift registers int rowsize=DisplaysTotal<<2; int offset=rowsize * bDMDByte; for (int i=0;i<rowsize;i++) { SPI.transfer(bDMDScreenRAM[offset+i+row3]); SPI.transfer(bDMDScreenRAM[offset+i+row2]); SPI.transfer(bDMDScreenRAM[offset+i+row1]); SPI.transfer(bDMDScreenRAM[offset+i]); } OE_DMD_ROWS_OFF(); LATCH_DMD_SHIFT_REG_TO_OUTPUT(); switch (bDMDByte) { case 0: // row 1, 5, 9, 13 were clocked out LIGHT_DMD_ROW_01_05_09_13(); bDMDByte=1; break; case 1: // row 2, 6, 10, 14 were clocked out LIGHT_DMD_ROW_02_06_10_14(); bDMDByte=2; break; case 2: // row 3, 7, 11, 15 were clocked out LIGHT_DMD_ROW_03_07_11_15(); bDMDByte=3; break; case 3: // row 4, 8, 12, 16 were clocked out LIGHT_DMD_ROW_04_08_12_16(); bDMDByte=0; break; } OE_DMD_ROWS_ON(); } } void DMD::selectFont(const uint8_t * font) { this->Font = font; } int DMD::drawChar(const int bX, const int bY, const char letter, byte bGraphicsMode) { if (bX > (DMD_PIXELS_ACROSS*DisplaysWide) || bY > (DMD_PIXELS_DOWN*DisplaysHigh) ) return -1; char c = letter; uint8_t height = pgm_read_byte(this->Font + FONT_HEIGHT); if (c == ' ') { int charWide = charWidth(' '); this->drawFilledBox(bX, bY, bX + charWide, bY + height, GRAPHICS_INVERSE); return charWide; } uint8_t width = 0; uint8_t bytes = (height + 7) / 8; uint8_t firstChar = pgm_read_byte(this->Font + FONT_FIRST_CHAR); uint8_t charCount = pgm_read_byte(this->Font + FONT_CHAR_COUNT); uint16_t index = 0; if (c < firstChar || c >= (firstChar + charCount)) return 0; c -= firstChar; if (pgm_read_byte(this->Font + FONT_LENGTH) == 0 && pgm_read_byte(this->Font + FONT_LENGTH + 1) == 0) { // zero length is flag indicating fixed width font (array does not contain width data entries) width = pgm_read_byte(this->Font + FONT_FIXED_WIDTH); index = c * bytes * width + FONT_WIDTH_TABLE; } else { // variable width font, read width data, to get the index for (uint8_t i = 0; i < c; i++) { index += pgm_read_byte(this->Font + FONT_WIDTH_TABLE + i); } index = index * bytes + charCount + FONT_WIDTH_TABLE; width = pgm_read_byte(this->Font + FONT_WIDTH_TABLE + c); } if (bX < -width || bY < -height) return width; // last but not least, draw the character for (uint8_t j = 0; j < width; j++) { // Width for (uint8_t i = bytes - 1; i < 254; i--) { // Vertical Bytes uint8_t data = pgm_read_byte(this->Font + index + j + (i * width)); int offset = (i * 8); if ((i == bytes - 1) && bytes > 1) { offset = height - 8; } for (uint8_t k = 0; k < 8; k++) { // Vertical bits if ((offset+k >= i*8) && (offset+k <= height)) { if (data & (1 << k)) { writePixel(bX + j, bY + offset + k, bGraphicsMode, true); } else { writePixel(bX + j, bY + offset + k, bGraphicsMode, false); } } } } } return width; } int DMD::charWidth(const char letter) { char c = letter; // Space is often not included in font so use width of 'n' if (c == ' ') c = 'n'; uint8_t width = 0; uint8_t firstChar = pgm_read_byte(this->Font + FONT_FIRST_CHAR); uint8_t charCount = pgm_read_byte(this->Font + FONT_CHAR_COUNT); uint16_t index = 0; if (c < firstChar || c >= (firstChar + charCount)) { return 0; } c -= firstChar; if (pgm_read_byte(this->Font + FONT_LENGTH) == 0 && pgm_read_byte(this->Font + FONT_LENGTH + 1) == 0) { // zero length is flag indicating fixed width font (array does not contain width data entries) width = pgm_read_byte(this->Font + FONT_FIXED_WIDTH); } else { // variable width font, read width data width = pgm_read_byte(this->Font + FONT_WIDTH_TABLE + c); } return width; }
[ "kieutq@hotmail.com" ]
kieutq@hotmail.com
194d79f708e434b7352f8a3a921a73db559bcba2
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/rsync/gumtree/rsync_old_log_204.cpp
cff69d808b5ca5ecd592f11d4cd3295c6c8e6728
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
56
cpp
fprintf(stderr,"fstat %s : %s\n",fname,strerror(errno));
[ "993273596@qq.com" ]
993273596@qq.com
ea9d35310cc09482f6ea743a01fa9532975d7496
47ebf27cd965269321b5d07beea10aec6da494d9
/Analysis/ReprocessingTools/ExtractKretchmann/OscillotonPotential.hpp
0454ef4a6ac48357a24d04885a05a42768293cc5
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
JamieBamber/GRChombo
9220fa67eeaa97eee17bc3c0a8ad17bfd3d02d0e
4399e51f71618754282049d6f2946b69ad2c12ee
refs/heads/master
2022-03-21T18:49:41.668222
2020-11-24T23:21:14
2020-11-24T23:21:14
201,951,780
0
0
BSD-3-Clause
2020-03-11T10:19:26
2019-08-12T14:55:47
C++
UTF-8
C++
false
false
1,268
hpp
/* GRChombo * Copyright 2012 The GRChombo collaboration. * Please refer to LICENSE in GRChombo's root directory. */ #ifndef OSCILLOTONPOTENTIAL_HPP_ #define OSCILLOTONPOTENTIAL_HPP_ #include "simd.hpp" class OscillotonPotential { public: struct params_t { double scalar_mass; double f_axion; }; private: params_t m_params; public: //! The constructor OscillotonPotential(params_t a_params) : m_params(a_params) {} //! Set the potential function for the scalar field here template <class data_t, template <typename> class vars_t> void compute_potential(data_t &V_of_phi, data_t &dVdphi, const vars_t<data_t> &vars) const { // The potential value at phi // V_of_phi = pow(m_params.scalar_mass * m_params.f_axion, 2.0) * // (1.0 - cos(vars.phi / m_params.f_axion)); V_of_phi = 0.5 * pow(m_params.scalar_mass * vars.phi, 2.0); // The potential gradient at phi // dVdphi = m_params.f_axion * pow(m_params.scalar_mass, 2.0) * // sin(vars.phi / m_params.f_axion); dVdphi = pow(m_params.scalar_mass, 2.0) * vars.phi; } }; #endif /* OSCILLOTONPOTENTIAL_HPP_ */
[ "dc-bamb1@login-e-14.data.cluster" ]
dc-bamb1@login-e-14.data.cluster
6e31e936886220631a55db35e0c613f2e62ffe61
fc515a72800f3fc7b3de998cb944eab91e0baf7b
/52-2loopText ๅ›žๆ–‡ๅญ—็ฌฆไธฒโ€”โ€”้€’ๅฝ’็ผ–็จ‹็ปƒไน /main.cpp
caf8ef2017069b43976c04aad4fb523b63450ac1
[]
no_license
jbji/2019-Programming-Basics-C-
4211e0c25dd1fc88de71716ad6a37d41cd7b8b04
014d3d8a5f1d6a95c132699e98ef4bfb25ef845f
refs/heads/master
2022-12-30T08:12:09.214502
2020-10-13T14:17:57
2020-10-13T14:17:57
303,658,050
0
0
null
null
null
null
UTF-8
C++
false
false
926
cpp
#include<iostream> #include<cmath> using namespace std; int main() { int n; //ๆ•ฐ็ป„้•ฟๅบฆ cin>>n; int in[n]; //ไธดๆ—ถๅ˜้‡ int tmpDigit[10];//ๆ‹†่งฃ็”จไธดๆ—ถๅญ˜ๅ‚จ int isLoop; int i=0; int j=0; int k=0; for(i=0;i<=n-1;i++){ cin >> in[i]; } for(i=0;i<=n-1;i++){ //ๆ•ฐๅญ—ๆ‹†่งฃ int tmpIn=in[i]; for(j=0; tmpIn != 0 ; j++){ tmpDigit[j]= tmpIn % 10; tmpIn /= 10; } j--; //ๅˆคๆ–ญoriginIn[i]ๆ˜ฏๅฆๆ˜ฏไธ€ไธชๅ›žๆ–‡ๆ•ฐ //kๆ˜ฏ็ฌฌไธ€ไธชไฝ็ฝฎ่€Œjๆ˜ฏๆœ€ๅŽไธ€ไธชไฝ็ฝฎ isLoop=1; for(k=0;k<=j;k++,j--){ if(tmpDigit[k] != tmpDigit[j]){ isLoop=0; } } if(isLoop){ cout << in[i] << " is a loop number."<< endl; }else{ cout << in[i] << " is not a loop number."<<endl; } } return 0; }
[ "jbji@foxmail.com" ]
jbji@foxmail.com
adcd9768d53513c3ec88e6254542a5b73c772a72
863de8a7226bad3433e64ad212cb5abd90794254
/src/eve/server/Connection.hpp
698849174a4d2cfa0b60131eb658e64ab6f1627e
[]
no_license
Sol1du2/Eve
9b4ed93282593d8f8228bfa7564dfcb8d9ff9687
440a4d1ef418b7d7b04b5f5a72db86f439e181e3
refs/heads/master
2023-01-05T17:41:31.443438
2020-10-30T18:36:23
2020-10-30T18:36:23
308,386,238
0
0
null
null
null
null
UTF-8
C++
false
false
1,698
hpp
#ifndef EVE_SERVER_CONNECTION_HPP #define EVE_SERVER_CONNECTION_HPP #include <boost/asio.hpp> #include <boost/signals2.hpp> #include "../msg/Http_parser.hpp" #include "../msg/Reply.hpp" #include "../msg/Request.hpp" namespace eve { namespace server { /// This class holds a connection to the server. /// When the communication is done a signal is sent to inform about this. The /// connection does not close the socket itself and close needs to be called. class Connection : public std::enable_shared_from_this<Connection> { public: Connection(boost::asio::ip::tcp::socket socket); Connection(const Connection&) = delete; Connection& operator=(const Connection&) = delete; void open(); void close(); /// This function is used to connect a slot to the signal when the connection /// is done with the work. void on_ready_close( const boost::signals2::signal<void( const std::shared_ptr<Connection>& connection)>::slot_type& slot); private: boost::asio::ip::tcp::socket m_socket; boost::signals2::signal<void(const std::shared_ptr<Connection>& connection)> m_signal_ready_close; std::array<char, 8192> m_buffer; eve::msg::Http_parser m_parser; eve::msg::Request m_request; /// This will ready the resquest and parse it. The request might not have be /// fully read in one go. The function will call itself when necessary to /// continuing reading. Because of this it is important to keep the state in /// the parser. void read(); /// Once a reply has been written this will write it to the client. void write(const eve::msg::Reply& reply); }; } // namespace server } // namespace eve #endif // EVE_SERVER_CONNECTION_HPP
[ "jtrgouveia@gmail.com" ]
jtrgouveia@gmail.com
eee4b64fb7ca114cd146df7e0e05464bc59bdec1
039a30b5db53c7f828ea87b9f305f51be4d7e6cc
/ๆจกๆฟ/ๆ•ฐๆฎ็ป“ๆž„/ไธปๅธญๆ ‘-้™ๆ€็ฌฌkๅคง.cpp
e44d60df0f1e93b349ad11a6bb5d7a69dd813af6
[]
no_license
1092772959/My-ACM-code
cd5af7cebc04c3252ed880686759257237b63b34
87109a0a98e6ea49f8726927cc4357a9155ba3f2
refs/heads/master
2021-07-03T01:31:39.173353
2020-08-25T13:48:49
2020-08-25T13:48:49
151,587,646
0
0
null
null
null
null
UTF-8
C++
false
false
1,999
cpp
#include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; typedef long long LL; const int N = 200005; const int INF = 0x3f3f3f3f; int n,q,tot; struct lp{ int l,r,sum; lp(){l=r=sum=0;} }cw[N*20]; int ar[N],br[N],now[N]; int root[N]; void update(int l,int r,int last,int &cur,int x){ cw[++tot]=cw[last]; cw[tot].sum++; cur=tot; if(l==r)return; int mid = (l+r)>>1; if(x<=mid){ update(l,mid,cw[last].l,cw[cur].l,x); }else { update(mid+1,r,cw[last].r,cw[cur].r,x); } } int query(int l,int r,int last,int cur,int k){ if(l==r)return l; int l1=cw[last].l,l2=cw[cur].l,r1=cw[last].r,r2=cw[cur].r; int summ=cw[l2].sum-cw[l1].sum; int mid=(l+r)>>1; if(k<=summ){ return query(l,mid,cw[last].l,cw[cur].l,k); }else{ return query(mid+1,r,cw[last].r,cw[cur].r,k-summ); } } int main(){ while(~scanf("%d%d",&n,&q)){ memset(root,0,sizeof(root)); cw[0].l=cw[0].r=cw[0].sum=0; for(int i=1;i<=n;++i){ scanf("%d",&br[i]); ar[i]=br[i]; } sort(br+1,br+1+n); int k=1; for(int i=2;i<=n;++i){ if(br[i]!=br[i-1])br[++k]=br[i]; } tot=0; for(int i=1;i<=n;++i){ now[i]=lower_bound(br+1,br+1+k,ar[i])-br; } for(int i=1;i<=n;++i){ update(1,k,root[i-1],root[i],now[i]); } while(q--){ int u,v; scanf("%d%d",&u,&v); int L=1,R=v-u+1,mid,ans=1; while(L<=R){//ไบŒๅˆ†็š„ๅ†™ๆณ•ๅคงๅŒๅฐๅผ‚๏ผŒ็”จ่‡ชๅทฑไน ๆƒฏ็š„ๅ†™ๆณ• mid=(L+R)>>1; int tmp=query(1,k,root[u-1],root[v],v-u+1-mid+1); if(mid>br[tmp]){ ans=mid-1; R=mid-1; }else{ ans=mid; L=mid+1; } } printf("%d\n",ans); } } return 0; }
[ "32030091+1092772959@users.noreply.github.com" ]
32030091+1092772959@users.noreply.github.com
0a46294170763fae0c3b81ba37df43f5a6e51163
5950c4973a1862d2b67e072deeea8f4188d23d97
/Export/macos/obj/include/lime/media/openal/AL.h
0325dba409155693cd2408a403b1727c6d78bfe5
[ "MIT" ]
permissive
TrilateralX/TrilateralLimeTriangle
b3cc0283cd3745b57ccc9131fcc9b81427414718
219d8e54fc3861dc1ffeb3da25da6eda349847c1
refs/heads/master
2022-10-26T11:51:28.578254
2020-06-16T12:32:35
2020-06-16T12:32:35
272,572,760
0
0
null
null
null
null
UTF-8
C++
false
true
17,649
h
// Generated by Haxe 4.2.0-rc.1+cb30bd580 #ifndef INCLUDED_lime_media_openal_AL #define INCLUDED_lime_media_openal_AL #ifndef HXCPP_H #include <hxcpp.h> #endif HX_DECLARE_CLASS3(lime,media,openal,AL) HX_DECLARE_CLASS2(lime,utils,ArrayBufferView) namespace lime{ namespace media{ namespace openal{ class HXCPP_CLASS_ATTRIBUTES AL_obj : public ::hx::Object { public: typedef ::hx::Object super; typedef AL_obj OBJ_; AL_obj(); public: enum { _hx_ClassId = 0x2695cb8f }; void __construct(); inline void *operator new(size_t inSize, bool inContainer=false,const char *inName="lime.media.openal.AL") { return ::hx::Object::operator new(inSize,inContainer,inName); } inline void *operator new(size_t inSize, int extra) { return ::hx::Object::operator new(inSize+extra,false,"lime.media.openal.AL"); } inline static ::hx::ObjectPtr< AL_obj > __new() { ::hx::ObjectPtr< AL_obj > __this = new AL_obj(); __this->__construct(); return __this; } inline static ::hx::ObjectPtr< AL_obj > __alloc(::hx::Ctx *_hx_ctx) { AL_obj *__this = (AL_obj*)(::hx::Ctx::alloc(_hx_ctx, sizeof(AL_obj), false, "lime.media.openal.AL")); *(void **)__this = AL_obj::_hx_vtable; return __this; } static void * _hx_vtable; static Dynamic __CreateEmpty(); static Dynamic __Create(::hx::DynamicArray inArgs); //~AL_obj(); HX_DO_RTTI_ALL; static bool __GetStatic(const ::String &inString, Dynamic &outValue, ::hx::PropertyAccess inCallProp); static void __register(); bool _hx_isInstanceOf(int inClassId); ::String __ToString() const { return HX_("AL",eb,38,00,00); } static void __boot(); static int NONE; static int FALSE; static int TRUE; static int SOURCE_RELATIVE; static int CONE_INNER_ANGLE; static int CONE_OUTER_ANGLE; static int PITCH; static int POSITION; static int DIRECTION; static int VELOCITY; static int LOOPING; static int BUFFER; static int GAIN; static int MIN_GAIN; static int MAX_GAIN; static int ORIENTATION; static int SOURCE_STATE; static int INITIAL; static int PLAYING; static int PAUSED; static int STOPPED; static int BUFFERS_QUEUED; static int BUFFERS_PROCESSED; static int REFERENCE_DISTANCE; static int ROLLOFF_FACTOR; static int CONE_OUTER_GAIN; static int MAX_DISTANCE; static int SEC_OFFSET; static int SAMPLE_OFFSET; static int BYTE_OFFSET; static int SOURCE_TYPE; static int STATIC; static int STREAMING; static int UNDETERMINED; static int FORMAT_MONO8; static int FORMAT_MONO16; static int FORMAT_STEREO8; static int FORMAT_STEREO16; static int FREQUENCY; static int BITS; static int CHANNELS; static int SIZE; static int NO_ERROR; static int INVALID_NAME; static int INVALID_ENUM; static int INVALID_VALUE; static int INVALID_OPERATION; static int OUT_OF_MEMORY; static int VENDOR; static int VERSION; static int RENDERER; static int EXTENSIONS; static int DOPPLER_FACTOR; static int SPEED_OF_SOUND; static int DOPPLER_VELOCITY; static int DISTANCE_MODEL; static int INVERSE_DISTANCE; static int INVERSE_DISTANCE_CLAMPED; static int LINEAR_DISTANCE; static int LINEAR_DISTANCE_CLAMPED; static int EXPONENT_DISTANCE; static int EXPONENT_DISTANCE_CLAMPED; static int METERS_PER_UNIT; static int DIRECT_FILTER; static int AUXILIARY_SEND_FILTER; static int AIR_ABSORPTION_FACTOR; static int ROOM_ROLLOFF_FACTOR; static int CONE_OUTER_GAINHF; static int DIRECT_FILTER_GAINHF_AUTO; static int AUXILIARY_SEND_FILTER_GAIN_AUTO; static int AUXILIARY_SEND_FILTER_GAINHF_AUTO; static int REVERB_DENSITY; static int REVERB_DIFFUSION; static int REVERB_GAIN; static int REVERB_GAINHF; static int REVERB_DECAY_TIME; static int REVERB_DECAY_HFRATIO; static int REVERB_REFLECTIONS_GAIN; static int REVERB_REFLECTIONS_DELAY; static int REVERB_LATE_REVERB_GAIN; static int REVERB_LATE_REVERB_DELAY; static int REVERB_AIR_ABSORPTION_GAINHF; static int REVERB_ROOM_ROLLOFF_FACTOR; static int REVERB_DECAY_HFLIMIT; static int EAXREVERB_DENSITY; static int EAXREVERB_DIFFUSION; static int EAXREVERB_GAIN; static int EAXREVERB_GAINHF; static int EAXREVERB_GAINLF; static int EAXREVERB_DECAY_TIME; static int EAXREVERB_DECAY_HFRATIO; static int EAXREVERB_DECAY_LFRATIO; static int EAXREVERB_REFLECTIONS_GAIN; static int EAXREVERB_REFLECTIONS_DELAY; static int EAXREVERB_REFLECTIONS_PAN; static int EAXREVERB_LATE_REVERB_GAIN; static int EAXREVERB_LATE_REVERB_DELAY; static int EAXREVERB_LATE_REVERB_PAN; static int EAXREVERB_ECHO_TIME; static int EAXREVERB_ECHO_DEPTH; static int EAXREVERB_MODULATION_TIME; static int EAXREVERB_MODULATION_DEPTH; static int EAXREVERB_AIR_ABSORPTION_GAINHF; static int EAXREVERB_HFREFERENCE; static int EAXREVERB_LFREFERENCE; static int EAXREVERB_ROOM_ROLLOFF_FACTOR; static int EAXREVERB_DECAY_HFLIMIT; static int CHORUS_WAVEFORM; static int CHORUS_PHASE; static int CHORUS_RATE; static int CHORUS_DEPTH; static int CHORUS_FEEDBACK; static int CHORUS_DELAY; static int DISTORTION_EDGE; static int DISTORTION_GAIN; static int DISTORTION_LOWPASS_CUTOFF; static int DISTORTION_EQCENTER; static int DISTORTION_EQBANDWIDTH; static int ECHO_DELAY; static int ECHO_LRDELAY; static int ECHO_DAMPING; static int ECHO_FEEDBACK; static int ECHO_SPREAD; static int FLANGER_WAVEFORM; static int FLANGER_PHASE; static int FLANGER_RATE; static int FLANGER_DEPTH; static int FLANGER_FEEDBACK; static int FLANGER_DELAY; static int FREQUENCY_SHIFTER_FREQUENCY; static int FREQUENCY_SHIFTER_LEFT_DIRECTION; static int FREQUENCY_SHIFTER_RIGHT_DIRECTION; static int VOCAL_MORPHER_PHONEMEA; static int VOCAL_MORPHER_PHONEMEA_COARSE_TUNING; static int VOCAL_MORPHER_PHONEMEB; static int VOCAL_MORPHER_PHONEMEB_COARSE_TUNING; static int VOCAL_MORPHER_WAVEFORM; static int VOCAL_MORPHER_RATE; static int PITCH_SHIFTER_COARSE_TUNE; static int PITCH_SHIFTER_FINE_TUNE; static int RING_MODULATOR_FREQUENCY; static int RING_MODULATOR_HIGHPASS_CUTOFF; static int RING_MODULATOR_WAVEFORM; static int AUTOWAH_ATTACK_TIME; static int AUTOWAH_RELEASE_TIME; static int AUTOWAH_RESONANCE; static int AUTOWAH_PEAK_GAIN; static int COMPRESSOR_ONOFF; static int EQUALIZER_LOW_GAIN; static int EQUALIZER_LOW_CUTOFF; static int EQUALIZER_MID1_GAIN; static int EQUALIZER_MID1_CENTER; static int EQUALIZER_MID1_WIDTH; static int EQUALIZER_MID2_GAIN; static int EQUALIZER_MID2_CENTER; static int EQUALIZER_MID2_WIDTH; static int EQUALIZER_HIGH_GAIN; static int EQUALIZER_HIGH_CUTOFF; static int EFFECT_FIRST_PARAMETER; static int EFFECT_LAST_PARAMETER; static int EFFECT_TYPE; static int EFFECT_NULL; static int EFFECT_EAXREVERB; static int EFFECT_REVERB; static int EFFECT_CHORUS; static int EFFECT_DISTORTION; static int EFFECT_ECHO; static int EFFECT_FLANGER; static int EFFECT_FREQUENCY_SHIFTER; static int EFFECT_VOCAL_MORPHER; static int EFFECT_PITCH_SHIFTER; static int EFFECT_RING_MODULATOR; static int FFECT_AUTOWAH; static int EFFECT_COMPRESSOR; static int EFFECT_EQUALIZER; static int EFFECTSLOT_EFFECT; static int EFFECTSLOT_GAIN; static int EFFECTSLOT_AUXILIARY_SEND_AUTO; static int LOWPASS_GAIN; static int LOWPASS_GAINHF; static int HIGHPASS_GAIN; static int HIGHPASS_GAINLF; static int BANDPASS_GAIN; static int BANDPASS_GAINLF; static int BANDPASS_GAINHF; static int FILTER_FIRST_PARAMETER; static int FILTER_LAST_PARAMETER; static int FILTER_TYPE; static int FILTER_NULL; static int FILTER_LOWPASS; static int FILTER_HIGHPASS; static int FILTER_BANDPASS; static void removeDirectFilter( ::Dynamic source); static ::Dynamic removeDirectFilter_dyn(); static void removeSend( ::Dynamic source,int index); static ::Dynamic removeSend_dyn(); static void auxf( ::Dynamic aux,int param,Float value); static ::Dynamic auxf_dyn(); static void auxfv( ::Dynamic aux,int param,::Array< Float > values); static ::Dynamic auxfv_dyn(); static void auxi( ::Dynamic aux,int param, ::Dynamic value); static ::Dynamic auxi_dyn(); static void auxiv( ::Dynamic aux,int param,::Array< int > values); static ::Dynamic auxiv_dyn(); static void bufferData( ::Dynamic buffer,int format, ::lime::utils::ArrayBufferView data,int size,int freq); static ::Dynamic bufferData_dyn(); static void buffer3f( ::Dynamic buffer,int param,Float value1,Float value2,Float value3); static ::Dynamic buffer3f_dyn(); static void buffer3i( ::Dynamic buffer,int param,int value1,int value2,int value3); static ::Dynamic buffer3i_dyn(); static void bufferf( ::Dynamic buffer,int param,Float value); static ::Dynamic bufferf_dyn(); static void bufferfv( ::Dynamic buffer,int param,::Array< Float > values); static ::Dynamic bufferfv_dyn(); static void bufferi( ::Dynamic buffer,int param,int value); static ::Dynamic bufferi_dyn(); static void bufferiv( ::Dynamic buffer,int param,::Array< int > values); static ::Dynamic bufferiv_dyn(); static ::Dynamic createAux(); static ::Dynamic createAux_dyn(); static ::Dynamic createBuffer(); static ::Dynamic createBuffer_dyn(); static ::Dynamic createEffect(); static ::Dynamic createEffect_dyn(); static ::Dynamic createFilter(); static ::Dynamic createFilter_dyn(); static ::Dynamic createSource(); static ::Dynamic createSource_dyn(); static void deleteBuffer( ::Dynamic buffer); static ::Dynamic deleteBuffer_dyn(); static void deleteBuffers(::cpp::VirtualArray buffers); static ::Dynamic deleteBuffers_dyn(); static void deleteSource( ::Dynamic source); static ::Dynamic deleteSource_dyn(); static void deleteSources(::cpp::VirtualArray sources); static ::Dynamic deleteSources_dyn(); static void disable(int capability); static ::Dynamic disable_dyn(); static void distanceModel(int distanceModel); static ::Dynamic distanceModel_dyn(); static void dopplerFactor(Float value); static ::Dynamic dopplerFactor_dyn(); static void dopplerVelocity(Float value); static ::Dynamic dopplerVelocity_dyn(); static void effectf( ::Dynamic effect,int param,Float value); static ::Dynamic effectf_dyn(); static void effectfv( ::Dynamic effect,int param,::Array< Float > values); static ::Dynamic effectfv_dyn(); static void effecti( ::Dynamic effect,int param,int value); static ::Dynamic effecti_dyn(); static void effectiv( ::Dynamic effect,int param,::Array< int > values); static ::Dynamic effectiv_dyn(); static void enable(int capability); static ::Dynamic enable_dyn(); static ::Dynamic genSource(); static ::Dynamic genSource_dyn(); static ::cpp::VirtualArray genSources(int n); static ::Dynamic genSources_dyn(); static ::Dynamic genBuffer(); static ::Dynamic genBuffer_dyn(); static ::cpp::VirtualArray genBuffers(int n); static ::Dynamic genBuffers_dyn(); static bool getBoolean(int param); static ::Dynamic getBoolean_dyn(); static ::Array< bool > getBooleanv(int param,::hx::Null< int > count); static ::Dynamic getBooleanv_dyn(); static ::Array< Float > getBuffer3f( ::Dynamic buffer,int param); static ::Dynamic getBuffer3f_dyn(); static ::Array< int > getBuffer3i( ::Dynamic buffer,int param); static ::Dynamic getBuffer3i_dyn(); static Float getBufferf( ::Dynamic buffer,int param); static ::Dynamic getBufferf_dyn(); static ::Array< Float > getBufferfv( ::Dynamic buffer,int param,::hx::Null< int > count); static ::Dynamic getBufferfv_dyn(); static int getBufferi( ::Dynamic buffer,int param); static ::Dynamic getBufferi_dyn(); static ::Array< int > getBufferiv( ::Dynamic buffer,int param,::hx::Null< int > count); static ::Dynamic getBufferiv_dyn(); static Float getDouble(int param); static ::Dynamic getDouble_dyn(); static ::Array< Float > getDoublev(int param,::hx::Null< int > count); static ::Dynamic getDoublev_dyn(); static int getEnumValue(::String ename); static ::Dynamic getEnumValue_dyn(); static int getError(); static ::Dynamic getError_dyn(); static ::String getErrorString(); static ::Dynamic getErrorString_dyn(); static int getFilteri( ::Dynamic filter,int param); static ::Dynamic getFilteri_dyn(); static Float getFloat(int param); static ::Dynamic getFloat_dyn(); static ::Array< Float > getFloatv(int param,::hx::Null< int > count); static ::Dynamic getFloatv_dyn(); static int getInteger(int param); static ::Dynamic getInteger_dyn(); static ::Array< int > getIntegerv(int param,::hx::Null< int > count); static ::Dynamic getIntegerv_dyn(); static ::Array< Float > getListener3f(int param); static ::Dynamic getListener3f_dyn(); static ::Array< int > getListener3i(int param); static ::Dynamic getListener3i_dyn(); static Float getListenerf(int param); static ::Dynamic getListenerf_dyn(); static ::Array< Float > getListenerfv(int param,::hx::Null< int > count); static ::Dynamic getListenerfv_dyn(); static int getListeneri(int param); static ::Dynamic getListeneri_dyn(); static ::Array< int > getListeneriv(int param,::hx::Null< int > count); static ::Dynamic getListeneriv_dyn(); static ::Dynamic getParameter(int param); static ::Dynamic getParameter_dyn(); static ::Dynamic getProcAddress(::String fname); static ::Dynamic getProcAddress_dyn(); static ::Array< Float > getSource3f( ::Dynamic source,int param); static ::Dynamic getSource3f_dyn(); static Float getSourcef( ::Dynamic source,int param); static ::Dynamic getSourcef_dyn(); static ::Array< int > getSource3i( ::Dynamic source,int param); static ::Dynamic getSource3i_dyn(); static ::Array< Float > getSourcefv( ::Dynamic source,int param,::hx::Null< int > count); static ::Dynamic getSourcefv_dyn(); static ::Dynamic getSourcei( ::Dynamic source,int param); static ::Dynamic getSourcei_dyn(); static ::Array< int > getSourceiv( ::Dynamic source,int param,::hx::Null< int > count); static ::Dynamic getSourceiv_dyn(); static ::String getString(int param); static ::Dynamic getString_dyn(); static bool isBuffer( ::Dynamic buffer); static ::Dynamic isBuffer_dyn(); static bool isEnabled(int capability); static ::Dynamic isEnabled_dyn(); static bool isExtensionPresent(::String extname); static ::Dynamic isExtensionPresent_dyn(); static bool isAux( ::Dynamic aux); static ::Dynamic isAux_dyn(); static bool isEffect( ::Dynamic effect); static ::Dynamic isEffect_dyn(); static bool isFilter( ::Dynamic filter); static ::Dynamic isFilter_dyn(); static bool isSource( ::Dynamic source); static ::Dynamic isSource_dyn(); static void listener3f(int param,Float value1,Float value2,Float value3); static ::Dynamic listener3f_dyn(); static void listener3i(int param,int value1,int value2,int value3); static ::Dynamic listener3i_dyn(); static void listenerf(int param,Float value); static ::Dynamic listenerf_dyn(); static void listenerfv(int param,::Array< Float > values); static ::Dynamic listenerfv_dyn(); static void listeneri(int param,int value); static ::Dynamic listeneri_dyn(); static void listeneriv(int param,::Array< int > values); static ::Dynamic listeneriv_dyn(); static void source3f( ::Dynamic source,int param,Float value1,Float value2,Float value3); static ::Dynamic source3f_dyn(); static void source3i( ::Dynamic source,int param, ::Dynamic value1,int value2,int value3); static ::Dynamic source3i_dyn(); static void sourcef( ::Dynamic source,int param,Float value); static ::Dynamic sourcef_dyn(); static void sourcefv( ::Dynamic source,int param,::Array< Float > values); static ::Dynamic sourcefv_dyn(); static void sourcei( ::Dynamic source,int param, ::Dynamic value); static ::Dynamic sourcei_dyn(); static void filteri( ::Dynamic filter,int param, ::Dynamic value); static ::Dynamic filteri_dyn(); static void filterf( ::Dynamic filter,int param,Float value); static ::Dynamic filterf_dyn(); static void sourceiv( ::Dynamic source,int param,::Array< int > values); static ::Dynamic sourceiv_dyn(); static void sourcePlay( ::Dynamic source); static ::Dynamic sourcePlay_dyn(); static void sourcePlayv(::cpp::VirtualArray sources); static ::Dynamic sourcePlayv_dyn(); static void sourceStop( ::Dynamic source); static ::Dynamic sourceStop_dyn(); static void sourceStopv(::cpp::VirtualArray sources); static ::Dynamic sourceStopv_dyn(); static void sourceRewind( ::Dynamic source); static ::Dynamic sourceRewind_dyn(); static void sourceRewindv(::cpp::VirtualArray sources); static ::Dynamic sourceRewindv_dyn(); static void sourcePause( ::Dynamic source); static ::Dynamic sourcePause_dyn(); static void sourcePausev(::cpp::VirtualArray sources); static ::Dynamic sourcePausev_dyn(); static void sourceQueueBuffer( ::Dynamic source, ::Dynamic buffer); static ::Dynamic sourceQueueBuffer_dyn(); static void sourceQueueBuffers( ::Dynamic source,int nb,::cpp::VirtualArray buffers); static ::Dynamic sourceQueueBuffers_dyn(); static ::Dynamic sourceUnqueueBuffer( ::Dynamic source); static ::Dynamic sourceUnqueueBuffer_dyn(); static ::cpp::VirtualArray sourceUnqueueBuffers( ::Dynamic source,int nb); static ::Dynamic sourceUnqueueBuffers_dyn(); static void speedOfSound(Float value); static ::Dynamic speedOfSound_dyn(); }; } // end namespace lime } // end namespace media } // end namespace openal #endif /* INCLUDED_lime_media_openal_AL */
[ "none" ]
none
7ff27ea3854395b31f70ec3fafe8e1abd707312e
b58ed4aec5031dbd83b254da9e1c5d7b0ed76b49
/src/Checksummer.cpp
bd956f895483f16afb0b72922e7cb9cec13fff18
[ "BSD-2-Clause" ]
permissive
285424336/Middleware
ab961c94c7721950e9bf66660db7367f5363516d
6438bdef16671482ecc1330679fa56439f916c61
refs/heads/master
2021-05-30T12:07:01.298691
2016-02-25T12:01:19
2016-02-25T12:01:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
186
cpp
#include <r2p/Checksummer.hpp> namespace r2p { void Checksummer::add(const uint8_t *chunkp, size_t length) { while (length-- > 0) { add(*chunkp++); } } } // namespace r2p
[ "martino.migliavacca@gmail.com" ]
martino.migliavacca@gmail.com
5f3635f49d3531378096911d66128e86598ae259
e25e02848b4e9374a2d55b95d4773709b94f52f2
/omp_tests/atomic/sound/target_parallel.cpp
f3f3b6ab511f7b9641d2157533d0c50dce1a6f79
[]
no_license
josemonsalve2/OmpVal
06950f596048df525178929dabc6482044319862
fcf0f70896b0548df33d8715968bfacba31c95ff
refs/heads/master
2020-09-24T09:24:03.585369
2019-12-04T00:30:01
2019-12-04T00:30:01
225,727,692
0
0
null
2019-12-03T22:14:08
2019-12-03T22:14:08
null
UTF-8
C++
false
false
642
cpp
#include <stdlib.h> #include <numeric> #include <math.h> #include <cassert> #include <iostream> #include <cmath> void test_target_parallel(){ // Declare Size of Loop // Initialize array int A = 0; // Computation #pragma omp target parallel map(tofrom: A) { { #pragma omp atomic update A++; } } // Validation assert( A >= 0 ); std::cout << "OK" << std::endl ; } int main() { test_target_parallel(); }
[ "t.applencourt@anl.gov" ]
t.applencourt@anl.gov
ad237d495fe51ef4237bbb611fd6400be14beaf8
b44e1008ccbd87f50df13e92cb40513372e10d73
/Source/Database/PostgreSQL/Lock.cpp
55fa7ea16eeceb24689aed8039d409c68d02d12f
[]
no_license
perryiv/haf
d76bc205604b14c407a9883a44b7e2ea89e1cf2d
12e1df5fc67fcad3462f335072e025ef866f7c86
refs/heads/master
2020-04-06T07:44:05.044643
2018-12-04T20:06:02
2018-12-04T20:06:02
157,283,369
0
0
null
null
null
null
UTF-8
C++
false
false
1,720
cpp
/////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2009, Perry L Miller IV // All rights reserved. // BSD License: http://www.opensource.org/licenses/bsd-license.html // /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // // Helper class for managing a table lock. // /////////////////////////////////////////////////////////////////////////////// #include "Database/PostgreSQL/Lock.h" #include "Database/PostgreSQL/Connection.h" using namespace Database::PostgreSQL; /////////////////////////////////////////////////////////////////////////////// // // Constructor // /////////////////////////////////////////////////////////////////////////////// Lock::Lock ( Connection &c, const std::string &table, const std::string &mode ) : _c ( c ), _table ( table ), _mode ( mode ) { // "The keyword TRANSACTION is just a cosmetic alternative to WORK. // Neither keyword need be specified." // http://www.postgresql.org/docs/6.4/static/sql-beginwork.htm _c.execute ( "begin" ); _c.execute ( "lock table " + _table + " in " + _mode + " mode" ); } /////////////////////////////////////////////////////////////////////////////// // // Destructor // /////////////////////////////////////////////////////////////////////////////// Lock::~Lock() { _c.execute ( "rollback" ); } /////////////////////////////////////////////////////////////////////////////// // // Commit the transaction. // /////////////////////////////////////////////////////////////////////////////// void Lock::commit() { _c.execute ( "commit" ); }
[ "miller@ciespace.com" ]
miller@ciespace.com
ab8c0be700def324a697ed3b24d5c516530c34ff
91561183d0b64eab7de0e10daa328d39ebb229d4
/src/include/catalog/type_handle.h
4a2296b02f769c10ab23a7525489e11552df4434
[ "MIT" ]
permissive
jrolli/terrier
a2ae102e0290fc644d864545cc18d7efe483df69
77750bb3f54d9ec22908c1986e5412441c65ef11
refs/heads/schema_change
2021-10-26T21:59:25.631175
2019-05-17T13:36:48
2019-05-17T13:36:48
168,453,725
0
1
MIT
2019-07-09T15:33:36
2019-01-31T03:05:19
C++
UTF-8
C++
false
false
2,566
h
#pragma once #include <type/transient_value.h> #include <memory> #include <string> #include <utility> #include <vector> #include "catalog/catalog_defs.h" #include "catalog/catalog_entry.h" #include "catalog/catalog_sql_table.h" namespace terrier::catalog { class Catalog; /** * An TypeEntry is a row in pg_class catalog */ class TypeCatalogEntry : public CatalogEntry<type_oid_t> { public: /** * Constructor * @param oid type def oid * @param sql_table associated with this entry * @param entry a row in pg_type that represents this table */ TypeCatalogEntry(type_oid_t oid, catalog::SqlTableHelper *sql_table, std::vector<type::TransientValue> &&entry) : CatalogEntry(oid, sql_table, std::move(entry)) {} }; /** * A type handle contains information about data types. * * pg_type: * oid | typname | typlen | typtype | typcategory */ class TypeCatalogTable { public: /** * Construct a type handle. It keeps a pointer to the pg_type sql table. */ TypeCatalogTable(Catalog *catalog, SqlTableHelper *pg_type); /** * Get the oid of a type given its name. */ type_oid_t TypeToOid(transaction::TransactionContext *txn, const std::string &type); /** * Get a type entry from pg_type handle * * @param txn the transaction to run * @param oid type entry oid * @return a shared pointer to the type entry */ std::shared_ptr<TypeCatalogEntry> GetTypeEntry(transaction::TransactionContext *txn, type_oid_t oid); /** * Add a type entry into pg_type handle. */ void AddEntry(transaction::TransactionContext *txn, type_oid_t oid, const std::string &typname, namespace_oid_t typnamespace, int32_t typlen, const std::string &typtype); /** * Get a type entry from pg_type handle by name. */ std::shared_ptr<TypeCatalogEntry> GetTypeEntry(transaction::TransactionContext *txn, const std::string &type); /** * Create storage table */ static SqlTableHelper *Create(transaction::TransactionContext *txn, Catalog *catalog, db_oid_t db_oid, const std::string &name); /** * Debug methods */ void Dump(transaction::TransactionContext *txn) { auto limit = static_cast<int32_t>(TypeCatalogTable::schema_cols_.size()); pg_type_rw_->Dump(txn, limit); } /** Used schema columns */ static const std::vector<SchemaCol> schema_cols_; // TODO(yeshengm): we have to add support for UDF in the future private: Catalog *catalog_; catalog::SqlTableHelper *pg_type_rw_; }; } // namespace terrier::catalog
[ "34660288+pervazea@users.noreply.github.com" ]
34660288+pervazea@users.noreply.github.com
51a2461f17b290f487b04b45e40f5b9195ec388c
5f04291a134213aee5703edf1ce2caa2664a1e4f
/chefgr.cpp
65497ee0b59ff7603bf22a035777bef125ea54f6
[]
no_license
prateek1802/Codechef
5a9797bf0283f91e713ff63b39e1d244ea9ce9cd
a27e0feef561b3e9e02ec49e2a4c91d2a06a3a28
refs/heads/master
2020-03-19T04:13:29.264583
2018-07-21T06:17:44
2018-07-21T06:17:44
135,807,410
0
0
null
null
null
null
UTF-8
C++
false
false
623
cpp
#include<bits/stdc++.h> #include<algorithm> #define M_PI using namespace std; int main() { int t; scanf("%d",&t); while(t--) { int n,m; scanf("%d%d",&n,&m); int a[n],maxx=-1; for(int i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]>maxx) { maxx=a[i]; } } int c=0; for(int i=0;i<n;i++) { c+=(maxx-a[i]); } m=m-c; if(m==0||m%n==0) { printf("Yes\n"); } else printf("No\n"); } return 0; }
[ "sharma.prateek182@gmail.com" ]
sharma.prateek182@gmail.com
49086e999d5a1f7835b1864c9f36eb5bff759a65
83279b3c5e3337a56ba31f9a84bb5e4c746a786e
/Postfix.h
387f5bebd35629a6d72211bcb3adff895d5779ba
[ "MIT" ]
permissive
Zonr0/geneticPractice
0ea5d15ac855a9841912f05585f58278efd8ac10
02e26dc60765e36db2c12653068d56e0b023dfcc
refs/heads/master
2021-05-04T19:37:25.099386
2017-11-17T23:01:52
2017-11-17T23:01:52
106,791,660
0
0
null
null
null
null
UTF-8
C++
false
false
1,257
h
#ifndef POSTFIX_H #define POSTFIX_H #define NULL 0 #ifdef DEBUG #include <iostream> #endif namespace PostfixNodes { struct node { int value; struct node * pNext; node(); void deleteAll(); }; //TODO: Write comment explaining this const int SUBTRACTION = -1; const int ADDITION = -2; const int MULTIPLICATION = -3; const int DIVISION = -4; const int NOOP = -5; } using namespace PostfixNodes; class Postfix { public: Postfix(); ~Postfix(); void add(char); int evaluate(); #ifdef DEBUG void testClass(); #endif private: //Data structure operations //Stack operations void push(int value); int pop(); inline int peek() {if (!pExpressionStack) return NOOP; else return pExpressionStack->value;}; inline int peekOutput(); int dequeue(); void enqueueOutput(int value); int performOperator(int lhs, int op, int rhs); inline int getPrecedence(char input); inline int getPrecedence(int input); inline int convertChar(char); node * pOutputQueue; node * pExpressionStack; const static int PREC_HIGHEST = 4; const static int PREC_HIGH = 3; const static int PREC_NORMAL = 2; const static int PREC_LOW = 1; const static int PREC_VERY_LOW = 0; const static int PREC_ERROR = -1; }; #endif
[ "awaugh@pdx.edu" ]
awaugh@pdx.edu
a32ff185583a7d825975c3861ea03cb23e473f26
e0e025b0b186e047461d2d74ea5fa84fb8a21f7b
/.history/8_cosuri_20210307090917.cpp
79f95437541417130d298b3728d4e126e31ad6fd
[]
no_license
xKristee29/1nfo
fbd4b9c1b50f45fbd10b968f39d342a47a007da7
1aa9ec38f24a54c76cab8d94212bd33df616082d
refs/heads/main
2023-03-20T02:04:51.730374
2021-03-08T20:24:55
2021-03-08T20:24:55
345,783,580
0
0
null
null
null
null
UTF-8
C++
false
false
1,012
cpp
#include <bits/stdc++.h> using namespace std; ifstream f("cosuri.in"); ofstream g("cosuri.out"); vector<int> v; int n,cerinta,x,sum,prevsum; void cer1(){ int min1=1000005, min2=1000005,mins, max1=-1, max2=-1,maxs; for(int i=1;i<=2*n;++i){ f>>x; if(x<min1){ min2=min1; min1=x; } else if(x<min2){ min2=x; } if(x>max2){ max1=max2; max2=x; } else if(x>max1){ max1=x; } } mins=min1+min2; maxs=max1+max2; g<<mins<<' '<<maxs; } void cer2(){ for(int i=1;i<=2*n;++i){ f>>x; v.push_back(x); } sort(v.begin(), v.end()); prevsum=v[v.size()-1]+v[0]; for(int i=1;i<n;++i){ sum=v[v.size()-1-i]+v[i]; if(prevsum!=sum){ cout<<"" } } } int main(){ f>>cerinta>>n; if(cerinta==1){ cer1(); } else{ cer2(); } return 0; }
[ "c90717489@gmail.com" ]
c90717489@gmail.com
2b42ec3d0e2ab4c45eaefab9aa84dbe56900dff2
1aef58c912885e0abbabe359f6d887ca4812e55c
/MovieClustering/DataInitialize.cpp
3522da872aa8b8190e50aabaec3e1f3f2489fa14
[]
no_license
Apoorvalakshmi/MovieClustering
cfe72ebc6f9c05d5b9502276d73b38a9d4e98643
acf1a5a5548755e3d78beb4468e1dbf83596e847
refs/heads/master
2022-01-17T02:12:19.323920
2019-01-06T15:02:42
2019-01-06T15:02:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,134
cpp
#include "DataInitialize.h" #include <fstream> #include <ctime> #include "stdlib.h" #include <iostream> using namespace std; Data::Data() { for (int i = 0; i < K; i++) { for (int j = 0; j < MOVIE_NUMBER;j++) { KCenters[i][j] = 0; } } } void Data::initKCenters() { ofstream ofile("Kcenter1.dat"); srand((int)time(NULL)); for (int i = 0; i < K; i++) { for (int j = 0; j < MOVIE_NUMBER; j++) { KCenters[i][j] = rand() % 5 + 1; ofile << KCenters[i][j] << "\t"; } ofile << endl; } ofile.close(); /*ifstream infile("Kcenter1.dat",ios::in); for (int i = 0; i < K; i++) { for (int j = 0; j < MOVIE_NUMBER; j++) { infile>>KCenters[i][j]; } } infile.close();*/ } void Data::initUsers() { ifstream infile("rating1.dat", ios::in); int atr = 0; int j = 0; while ((infile >> users[atr].UserID) && (atr<USER_NUMBER)) { // cout << movies[atr].MovieID << " "; j = 0; while (j<MOVIE_NUMBER) { infile >> users[atr].Coordinate[j]; // cout << movies[atr].Coordinate[j] << " "; j++; } atr++; // cout << endl; } cout << atr << "+" << j << endl; infile.close(); //getchar(); }
[ "narcissuscyn@gmail.com" ]
narcissuscyn@gmail.com
ba8911472f475cc4574cc369ac9e4003d2bcf855
a15950e54e6775e6f7f7004bb90a5585405eade7
/ui/accessibility/ax_enum_util.cc
8c80b463557d35833ed170aeadeac86ca4f9fdb6
[ "BSD-3-Clause" ]
permissive
whycoding126/chromium
19f6b44d0ec3e4f1b5ef61cc083cae587de3df73
9191e417b00328d59a7060fa6bbef061a3fe4ce4
refs/heads/master
2023-02-26T22:57:28.582142
2018-04-09T11:12:57
2018-04-09T11:12:57
128,760,157
1
0
null
2018-04-09T11:17:03
2018-04-09T11:17:03
null
UTF-8
C++
false
false
85,873
cc
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/accessibility/ax_enum_util.h" namespace ui { const char* ToString(ax::mojom::Event event) { switch (event) { case ax::mojom::Event::kNone: return "none"; case ax::mojom::Event::kActiveDescendantChanged: return "activedescendantchanged"; case ax::mojom::Event::kAlert: return "alert"; case ax::mojom::Event::kAriaAttributeChanged: return "ariaAttributeChanged"; case ax::mojom::Event::kAutocorrectionOccured: return "autocorrectionOccured"; case ax::mojom::Event::kBlur: return "blur"; case ax::mojom::Event::kCheckedStateChanged: return "checkedStateChanged"; case ax::mojom::Event::kChildrenChanged: return "childrenChanged"; case ax::mojom::Event::kClicked: return "clicked"; case ax::mojom::Event::kDocumentSelectionChanged: return "documentSelectionChanged"; case ax::mojom::Event::kExpandedChanged: return "expandedChanged"; case ax::mojom::Event::kFocus: return "focus"; case ax::mojom::Event::kFocusContext: return "focusContext"; case ax::mojom::Event::kHide: return "hide"; case ax::mojom::Event::kHitTestResult: return "hitTestResult"; case ax::mojom::Event::kHover: return "hover"; case ax::mojom::Event::kImageFrameUpdated: return "imageFrameUpdated"; case ax::mojom::Event::kInvalidStatusChanged: return "invalidStatusChanged"; case ax::mojom::Event::kLayoutComplete: return "layoutComplete"; case ax::mojom::Event::kLiveRegionCreated: return "liveRegionCreated"; case ax::mojom::Event::kLiveRegionChanged: return "liveRegionChanged"; case ax::mojom::Event::kLoadComplete: return "loadComplete"; case ax::mojom::Event::kLocationChanged: return "locationChanged"; case ax::mojom::Event::kMediaStartedPlaying: return "mediaStartedPlaying"; case ax::mojom::Event::kMediaStoppedPlaying: return "mediaStoppedPlaying"; case ax::mojom::Event::kMenuEnd: return "menuEnd"; case ax::mojom::Event::kMenuListItemSelected: return "menuListItemSelected"; case ax::mojom::Event::kMenuListValueChanged: return "menuListValueChanged"; case ax::mojom::Event::kMenuPopupEnd: return "menuPopupEnd"; case ax::mojom::Event::kMenuPopupStart: return "menuPopupStart"; case ax::mojom::Event::kMenuStart: return "menuStart"; case ax::mojom::Event::kMouseCanceled: return "mouseCanceled"; case ax::mojom::Event::kMouseDragged: return "mouseDragged"; case ax::mojom::Event::kMouseMoved: return "mouseMoved"; case ax::mojom::Event::kMousePressed: return "mousePressed"; case ax::mojom::Event::kMouseReleased: return "mouseReleased"; case ax::mojom::Event::kRowCollapsed: return "rowCollapsed"; case ax::mojom::Event::kRowCountChanged: return "rowCountChanged"; case ax::mojom::Event::kRowExpanded: return "rowExpanded"; case ax::mojom::Event::kScrollPositionChanged: return "scrollPositionChanged"; case ax::mojom::Event::kScrolledToAnchor: return "scrolledToAnchor"; case ax::mojom::Event::kSelectedChildrenChanged: return "selectedChildrenChanged"; case ax::mojom::Event::kSelection: return "selection"; case ax::mojom::Event::kSelectionAdd: return "selectionAdd"; case ax::mojom::Event::kSelectionRemove: return "selectionRemove"; case ax::mojom::Event::kShow: return "show"; case ax::mojom::Event::kStateChanged: return "stateChanged"; case ax::mojom::Event::kTextChanged: return "textChanged"; case ax::mojom::Event::kTextSelectionChanged: return "textSelectionChanged"; case ax::mojom::Event::kTreeChanged: return "treeChanged"; case ax::mojom::Event::kValueChanged: return "valueChanged"; } return ""; } ax::mojom::Event ParseEvent(const char* event) { if (0 == strcmp(event, "none")) return ax::mojom::Event::kNone; if (0 == strcmp(event, "activedescendantchanged")) return ax::mojom::Event::kActiveDescendantChanged; if (0 == strcmp(event, "alert")) return ax::mojom::Event::kAlert; if (0 == strcmp(event, "ariaAttributeChanged")) return ax::mojom::Event::kAriaAttributeChanged; if (0 == strcmp(event, "autocorrectionOccured")) return ax::mojom::Event::kAutocorrectionOccured; if (0 == strcmp(event, "blur")) return ax::mojom::Event::kBlur; if (0 == strcmp(event, "checkedStateChanged")) return ax::mojom::Event::kCheckedStateChanged; if (0 == strcmp(event, "childrenChanged")) return ax::mojom::Event::kChildrenChanged; if (0 == strcmp(event, "clicked")) return ax::mojom::Event::kClicked; if (0 == strcmp(event, "documentSelectionChanged")) return ax::mojom::Event::kDocumentSelectionChanged; if (0 == strcmp(event, "expandedChanged")) return ax::mojom::Event::kExpandedChanged; if (0 == strcmp(event, "focus")) return ax::mojom::Event::kFocus; if (0 == strcmp(event, "hide")) return ax::mojom::Event::kHide; if (0 == strcmp(event, "hitTestResult")) return ax::mojom::Event::kHitTestResult; if (0 == strcmp(event, "hover")) return ax::mojom::Event::kHover; if (0 == strcmp(event, "imageFrameUpdated")) return ax::mojom::Event::kImageFrameUpdated; if (0 == strcmp(event, "invalidStatusChanged")) return ax::mojom::Event::kInvalidStatusChanged; if (0 == strcmp(event, "layoutComplete")) return ax::mojom::Event::kLayoutComplete; if (0 == strcmp(event, "liveRegionCreated")) return ax::mojom::Event::kLiveRegionCreated; if (0 == strcmp(event, "liveRegionChanged")) return ax::mojom::Event::kLiveRegionChanged; if (0 == strcmp(event, "loadComplete")) return ax::mojom::Event::kLoadComplete; if (0 == strcmp(event, "locationChanged")) return ax::mojom::Event::kLocationChanged; if (0 == strcmp(event, "mediaStartedPlaying")) return ax::mojom::Event::kMediaStartedPlaying; if (0 == strcmp(event, "mediaStoppedPlaying")) return ax::mojom::Event::kMediaStoppedPlaying; if (0 == strcmp(event, "menuEnd")) return ax::mojom::Event::kMenuEnd; if (0 == strcmp(event, "menuListItemSelected")) return ax::mojom::Event::kMenuListItemSelected; if (0 == strcmp(event, "menuListValueChanged")) return ax::mojom::Event::kMenuListValueChanged; if (0 == strcmp(event, "menuPopupEnd")) return ax::mojom::Event::kMenuPopupEnd; if (0 == strcmp(event, "menuPopupStart")) return ax::mojom::Event::kMenuPopupStart; if (0 == strcmp(event, "menuStart")) return ax::mojom::Event::kMenuStart; if (0 == strcmp(event, "mouseCanceled")) return ax::mojom::Event::kMouseCanceled; if (0 == strcmp(event, "mouseDragged")) return ax::mojom::Event::kMouseDragged; if (0 == strcmp(event, "mouseMoved")) return ax::mojom::Event::kMouseMoved; if (0 == strcmp(event, "mousePressed")) return ax::mojom::Event::kMousePressed; if (0 == strcmp(event, "mouseReleased")) return ax::mojom::Event::kMouseReleased; if (0 == strcmp(event, "rowCollapsed")) return ax::mojom::Event::kRowCollapsed; if (0 == strcmp(event, "rowCountChanged")) return ax::mojom::Event::kRowCountChanged; if (0 == strcmp(event, "rowExpanded")) return ax::mojom::Event::kRowExpanded; if (0 == strcmp(event, "scrollPositionChanged")) return ax::mojom::Event::kScrollPositionChanged; if (0 == strcmp(event, "scrolledToAnchor")) return ax::mojom::Event::kScrolledToAnchor; if (0 == strcmp(event, "selectedChildrenChanged")) return ax::mojom::Event::kSelectedChildrenChanged; if (0 == strcmp(event, "selection")) return ax::mojom::Event::kSelection; if (0 == strcmp(event, "selectionAdd")) return ax::mojom::Event::kSelectionAdd; if (0 == strcmp(event, "selectionRemove")) return ax::mojom::Event::kSelectionRemove; if (0 == strcmp(event, "show")) return ax::mojom::Event::kShow; if (0 == strcmp(event, "textChanged")) return ax::mojom::Event::kTextChanged; if (0 == strcmp(event, "textSelectionChanged")) return ax::mojom::Event::kTextSelectionChanged; if (0 == strcmp(event, "treeChanged")) return ax::mojom::Event::kTreeChanged; if (0 == strcmp(event, "valueChanged")) return ax::mojom::Event::kValueChanged; return ax::mojom::Event::kNone; } const char* ToString(ax::mojom::Role role) { switch (role) { case ax::mojom::Role::kNone: return "none"; case ax::mojom::Role::kAbbr: return "abbr"; case ax::mojom::Role::kAlertDialog: return "alertDialog"; case ax::mojom::Role::kAlert: return "alert"; case ax::mojom::Role::kAnchor: return "anchor"; case ax::mojom::Role::kAnnotation: return "annotation"; case ax::mojom::Role::kApplication: return "application"; case ax::mojom::Role::kArticle: return "article"; case ax::mojom::Role::kAudio: return "audio"; case ax::mojom::Role::kBanner: return "banner"; case ax::mojom::Role::kBlockquote: return "blockquote"; case ax::mojom::Role::kButton: return "button"; case ax::mojom::Role::kCanvas: return "canvas"; case ax::mojom::Role::kCaption: return "caption"; case ax::mojom::Role::kCaret: return "caret"; case ax::mojom::Role::kCell: return "cell"; case ax::mojom::Role::kCheckBox: return "checkBox"; case ax::mojom::Role::kClient: return "client"; case ax::mojom::Role::kColorWell: return "colorWell"; case ax::mojom::Role::kColumnHeader: return "columnHeader"; case ax::mojom::Role::kColumn: return "column"; case ax::mojom::Role::kComboBoxGrouping: return "comboBoxGrouping"; case ax::mojom::Role::kComboBoxMenuButton: return "comboBoxMenuButton"; case ax::mojom::Role::kComplementary: return "complementary"; case ax::mojom::Role::kContentInfo: return "contentInfo"; case ax::mojom::Role::kDate: return "date"; case ax::mojom::Role::kDateTime: return "dateTime"; case ax::mojom::Role::kDefinition: return "definition"; case ax::mojom::Role::kDescriptionListDetail: return "descriptionListDetail"; case ax::mojom::Role::kDescriptionList: return "descriptionList"; case ax::mojom::Role::kDescriptionListTerm: return "descriptionListTerm"; case ax::mojom::Role::kDesktop: return "desktop"; case ax::mojom::Role::kDetails: return "details"; case ax::mojom::Role::kDialog: return "dialog"; case ax::mojom::Role::kDirectory: return "directory"; case ax::mojom::Role::kDisclosureTriangle: return "disclosureTriangle"; case ax::mojom::Role::kDocument: return "document"; case ax::mojom::Role::kEmbeddedObject: return "embeddedObject"; case ax::mojom::Role::kFeed: return "feed"; case ax::mojom::Role::kFigcaption: return "figcaption"; case ax::mojom::Role::kFigure: return "figure"; case ax::mojom::Role::kFooter: return "footer"; case ax::mojom::Role::kForm: return "form"; case ax::mojom::Role::kGenericContainer: return "genericContainer"; case ax::mojom::Role::kGrid: return "grid"; case ax::mojom::Role::kGroup: return "group"; case ax::mojom::Role::kHeading: return "heading"; case ax::mojom::Role::kIframe: return "iframe"; case ax::mojom::Role::kIframePresentational: return "iframePresentational"; case ax::mojom::Role::kIgnored: return "ignored"; case ax::mojom::Role::kImageMap: return "imageMap"; case ax::mojom::Role::kImage: return "image"; case ax::mojom::Role::kInlineTextBox: return "inlineTextBox"; case ax::mojom::Role::kInputTime: return "inputTime"; case ax::mojom::Role::kLabelText: return "labelText"; case ax::mojom::Role::kLayoutTable: return "layoutTable"; case ax::mojom::Role::kLayoutTableCell: return "layoutTableCell"; case ax::mojom::Role::kLayoutTableColumn: return "layoutTableColumn"; case ax::mojom::Role::kLayoutTableRow: return "layoutTableRow"; case ax::mojom::Role::kLegend: return "legend"; case ax::mojom::Role::kLineBreak: return "lineBreak"; case ax::mojom::Role::kLink: return "link"; case ax::mojom::Role::kListBoxOption: return "listBoxOption"; case ax::mojom::Role::kListBox: return "listBox"; case ax::mojom::Role::kListItem: return "listItem"; case ax::mojom::Role::kListMarker: return "listMarker"; case ax::mojom::Role::kList: return "list"; case ax::mojom::Role::kLocationBar: return "locationBar"; case ax::mojom::Role::kLog: return "log"; case ax::mojom::Role::kMain: return "main"; case ax::mojom::Role::kMark: return "mark"; case ax::mojom::Role::kMarquee: return "marquee"; case ax::mojom::Role::kMath: return "math"; case ax::mojom::Role::kMenu: return "menu"; case ax::mojom::Role::kMenuBar: return "menuBar"; case ax::mojom::Role::kMenuButton: return "menuButton"; case ax::mojom::Role::kMenuItem: return "menuItem"; case ax::mojom::Role::kMenuItemCheckBox: return "menuItemCheckBox"; case ax::mojom::Role::kMenuItemRadio: return "menuItemRadio"; case ax::mojom::Role::kMenuListOption: return "menuListOption"; case ax::mojom::Role::kMenuListPopup: return "menuListPopup"; case ax::mojom::Role::kMeter: return "meter"; case ax::mojom::Role::kNavigation: return "navigation"; case ax::mojom::Role::kNote: return "note"; case ax::mojom::Role::kPane: return "pane"; case ax::mojom::Role::kParagraph: return "paragraph"; case ax::mojom::Role::kPopUpButton: return "popUpButton"; case ax::mojom::Role::kPre: return "pre"; case ax::mojom::Role::kPresentational: return "presentational"; case ax::mojom::Role::kProgressIndicator: return "progressIndicator"; case ax::mojom::Role::kRadioButton: return "radioButton"; case ax::mojom::Role::kRadioGroup: return "radioGroup"; case ax::mojom::Role::kRegion: return "region"; case ax::mojom::Role::kRootWebArea: return "rootWebArea"; case ax::mojom::Role::kRowHeader: return "rowHeader"; case ax::mojom::Role::kRow: return "row"; case ax::mojom::Role::kRuby: return "ruby"; case ax::mojom::Role::kSvgRoot: return "svgRoot"; case ax::mojom::Role::kScrollBar: return "scrollBar"; case ax::mojom::Role::kSearch: return "search"; case ax::mojom::Role::kSearchBox: return "searchBox"; case ax::mojom::Role::kSlider: return "slider"; case ax::mojom::Role::kSliderThumb: return "sliderThumb"; case ax::mojom::Role::kSpinButtonPart: return "spinButtonPart"; case ax::mojom::Role::kSpinButton: return "spinButton"; case ax::mojom::Role::kSplitter: return "splitter"; case ax::mojom::Role::kStaticText: return "staticText"; case ax::mojom::Role::kStatus: return "status"; case ax::mojom::Role::kSwitch: return "switch"; case ax::mojom::Role::kTabList: return "tabList"; case ax::mojom::Role::kTabPanel: return "tabPanel"; case ax::mojom::Role::kTab: return "tab"; case ax::mojom::Role::kTableHeaderContainer: return "tableHeaderContainer"; case ax::mojom::Role::kTable: return "table"; case ax::mojom::Role::kTerm: return "term"; case ax::mojom::Role::kTextField: return "textField"; case ax::mojom::Role::kTextFieldWithComboBox: return "textFieldWithComboBox"; case ax::mojom::Role::kTime: return "time"; case ax::mojom::Role::kTimer: return "timer"; case ax::mojom::Role::kTitleBar: return "titleBar"; case ax::mojom::Role::kToggleButton: return "toggleButton"; case ax::mojom::Role::kToolbar: return "toolbar"; case ax::mojom::Role::kTreeGrid: return "treeGrid"; case ax::mojom::Role::kTreeItem: return "treeItem"; case ax::mojom::Role::kTree: return "tree"; case ax::mojom::Role::kUnknown: return "unknown"; case ax::mojom::Role::kTooltip: return "tooltip"; case ax::mojom::Role::kVideo: return "video"; case ax::mojom::Role::kWebArea: return "webArea"; case ax::mojom::Role::kWebView: return "webView"; case ax::mojom::Role::kWindow: return "window"; } return ""; } ax::mojom::Role ParseRole(const char* role) { if (0 == strcmp(role, "none")) return ax::mojom::Role::kNone; if (0 == strcmp(role, "abbr")) return ax::mojom::Role::kAbbr; if (0 == strcmp(role, "alertDialog")) return ax::mojom::Role::kAlertDialog; if (0 == strcmp(role, "alert")) return ax::mojom::Role::kAlert; if (0 == strcmp(role, "anchor")) return ax::mojom::Role::kAnchor; if (0 == strcmp(role, "annotation")) return ax::mojom::Role::kAnnotation; if (0 == strcmp(role, "application")) return ax::mojom::Role::kApplication; if (0 == strcmp(role, "article")) return ax::mojom::Role::kArticle; if (0 == strcmp(role, "audio")) return ax::mojom::Role::kAudio; if (0 == strcmp(role, "banner")) return ax::mojom::Role::kBanner; if (0 == strcmp(role, "blockquote")) return ax::mojom::Role::kBlockquote; if (0 == strcmp(role, "button")) return ax::mojom::Role::kButton; if (0 == strcmp(role, "canvas")) return ax::mojom::Role::kCanvas; if (0 == strcmp(role, "caption")) return ax::mojom::Role::kCaption; if (0 == strcmp(role, "caret")) return ax::mojom::Role::kCaret; if (0 == strcmp(role, "cell")) return ax::mojom::Role::kCell; if (0 == strcmp(role, "checkBox")) return ax::mojom::Role::kCheckBox; if (0 == strcmp(role, "client")) return ax::mojom::Role::kClient; if (0 == strcmp(role, "colorWell")) return ax::mojom::Role::kColorWell; if (0 == strcmp(role, "columnHeader")) return ax::mojom::Role::kColumnHeader; if (0 == strcmp(role, "column")) return ax::mojom::Role::kColumn; if (0 == strcmp(role, "comboBoxGrouping")) return ax::mojom::Role::kComboBoxGrouping; if (0 == strcmp(role, "comboBoxMenuButton")) return ax::mojom::Role::kComboBoxMenuButton; if (0 == strcmp(role, "complementary")) return ax::mojom::Role::kComplementary; if (0 == strcmp(role, "contentInfo")) return ax::mojom::Role::kContentInfo; if (0 == strcmp(role, "date")) return ax::mojom::Role::kDate; if (0 == strcmp(role, "dateTime")) return ax::mojom::Role::kDateTime; if (0 == strcmp(role, "definition")) return ax::mojom::Role::kDefinition; if (0 == strcmp(role, "descriptionListDetail")) return ax::mojom::Role::kDescriptionListDetail; if (0 == strcmp(role, "descriptionList")) return ax::mojom::Role::kDescriptionList; if (0 == strcmp(role, "descriptionListTerm")) return ax::mojom::Role::kDescriptionListTerm; if (0 == strcmp(role, "desktop")) return ax::mojom::Role::kDesktop; if (0 == strcmp(role, "details")) return ax::mojom::Role::kDetails; if (0 == strcmp(role, "dialog")) return ax::mojom::Role::kDialog; if (0 == strcmp(role, "directory")) return ax::mojom::Role::kDirectory; if (0 == strcmp(role, "disclosureTriangle")) return ax::mojom::Role::kDisclosureTriangle; if (0 == strcmp(role, "document")) return ax::mojom::Role::kDocument; if (0 == strcmp(role, "embeddedObject")) return ax::mojom::Role::kEmbeddedObject; if (0 == strcmp(role, "feed")) return ax::mojom::Role::kFeed; if (0 == strcmp(role, "figcaption")) return ax::mojom::Role::kFigcaption; if (0 == strcmp(role, "figure")) return ax::mojom::Role::kFigure; if (0 == strcmp(role, "footer")) return ax::mojom::Role::kFooter; if (0 == strcmp(role, "form")) return ax::mojom::Role::kForm; if (0 == strcmp(role, "genericContainer")) return ax::mojom::Role::kGenericContainer; if (0 == strcmp(role, "grid")) return ax::mojom::Role::kGrid; if (0 == strcmp(role, "group")) return ax::mojom::Role::kGroup; if (0 == strcmp(role, "heading")) return ax::mojom::Role::kHeading; if (0 == strcmp(role, "iframe")) return ax::mojom::Role::kIframe; if (0 == strcmp(role, "iframePresentational")) return ax::mojom::Role::kIframePresentational; if (0 == strcmp(role, "ignored")) return ax::mojom::Role::kIgnored; if (0 == strcmp(role, "imageMap")) return ax::mojom::Role::kImageMap; if (0 == strcmp(role, "image")) return ax::mojom::Role::kImage; if (0 == strcmp(role, "inlineTextBox")) return ax::mojom::Role::kInlineTextBox; if (0 == strcmp(role, "inputTime")) return ax::mojom::Role::kInputTime; if (0 == strcmp(role, "labelText")) return ax::mojom::Role::kLabelText; if (0 == strcmp(role, "layoutTable")) return ax::mojom::Role::kLayoutTable; if (0 == strcmp(role, "layoutTableCell")) return ax::mojom::Role::kLayoutTableCell; if (0 == strcmp(role, "layoutTableColumn")) return ax::mojom::Role::kLayoutTableColumn; if (0 == strcmp(role, "layoutTableRow")) return ax::mojom::Role::kLayoutTableRow; if (0 == strcmp(role, "legend")) return ax::mojom::Role::kLegend; if (0 == strcmp(role, "lineBreak")) return ax::mojom::Role::kLineBreak; if (0 == strcmp(role, "link")) return ax::mojom::Role::kLink; if (0 == strcmp(role, "listBoxOption")) return ax::mojom::Role::kListBoxOption; if (0 == strcmp(role, "listBox")) return ax::mojom::Role::kListBox; if (0 == strcmp(role, "listItem")) return ax::mojom::Role::kListItem; if (0 == strcmp(role, "listMarker")) return ax::mojom::Role::kListMarker; if (0 == strcmp(role, "list")) return ax::mojom::Role::kList; if (0 == strcmp(role, "locationBar")) return ax::mojom::Role::kLocationBar; if (0 == strcmp(role, "log")) return ax::mojom::Role::kLog; if (0 == strcmp(role, "main")) return ax::mojom::Role::kMain; if (0 == strcmp(role, "mark")) return ax::mojom::Role::kMark; if (0 == strcmp(role, "marquee")) return ax::mojom::Role::kMarquee; if (0 == strcmp(role, "math")) return ax::mojom::Role::kMath; if (0 == strcmp(role, "menu")) return ax::mojom::Role::kMenu; if (0 == strcmp(role, "menuBar")) return ax::mojom::Role::kMenuBar; if (0 == strcmp(role, "menuButton")) return ax::mojom::Role::kMenuButton; if (0 == strcmp(role, "menuItem")) return ax::mojom::Role::kMenuItem; if (0 == strcmp(role, "menuItemCheckBox")) return ax::mojom::Role::kMenuItemCheckBox; if (0 == strcmp(role, "menuItemRadio")) return ax::mojom::Role::kMenuItemRadio; if (0 == strcmp(role, "menuListOption")) return ax::mojom::Role::kMenuListOption; if (0 == strcmp(role, "menuListPopup")) return ax::mojom::Role::kMenuListPopup; if (0 == strcmp(role, "meter")) return ax::mojom::Role::kMeter; if (0 == strcmp(role, "navigation")) return ax::mojom::Role::kNavigation; if (0 == strcmp(role, "note")) return ax::mojom::Role::kNote; if (0 == strcmp(role, "pane")) return ax::mojom::Role::kPane; if (0 == strcmp(role, "paragraph")) return ax::mojom::Role::kParagraph; if (0 == strcmp(role, "popUpButton")) return ax::mojom::Role::kPopUpButton; if (0 == strcmp(role, "pre")) return ax::mojom::Role::kPre; if (0 == strcmp(role, "presentational")) return ax::mojom::Role::kPresentational; if (0 == strcmp(role, "progressIndicator")) return ax::mojom::Role::kProgressIndicator; if (0 == strcmp(role, "radioButton")) return ax::mojom::Role::kRadioButton; if (0 == strcmp(role, "radioGroup")) return ax::mojom::Role::kRadioGroup; if (0 == strcmp(role, "region")) return ax::mojom::Role::kRegion; if (0 == strcmp(role, "rootWebArea")) return ax::mojom::Role::kRootWebArea; if (0 == strcmp(role, "rowHeader")) return ax::mojom::Role::kRowHeader; if (0 == strcmp(role, "row")) return ax::mojom::Role::kRow; if (0 == strcmp(role, "ruby")) return ax::mojom::Role::kRuby; if (0 == strcmp(role, "svgRoot")) return ax::mojom::Role::kSvgRoot; if (0 == strcmp(role, "scrollBar")) return ax::mojom::Role::kScrollBar; if (0 == strcmp(role, "search")) return ax::mojom::Role::kSearch; if (0 == strcmp(role, "searchBox")) return ax::mojom::Role::kSearchBox; if (0 == strcmp(role, "slider")) return ax::mojom::Role::kSlider; if (0 == strcmp(role, "sliderThumb")) return ax::mojom::Role::kSliderThumb; if (0 == strcmp(role, "spinButtonPart")) return ax::mojom::Role::kSpinButtonPart; if (0 == strcmp(role, "spinButton")) return ax::mojom::Role::kSpinButton; if (0 == strcmp(role, "splitter")) return ax::mojom::Role::kSplitter; if (0 == strcmp(role, "staticText")) return ax::mojom::Role::kStaticText; if (0 == strcmp(role, "status")) return ax::mojom::Role::kStatus; if (0 == strcmp(role, "switch")) return ax::mojom::Role::kSwitch; if (0 == strcmp(role, "tabList")) return ax::mojom::Role::kTabList; if (0 == strcmp(role, "tabPanel")) return ax::mojom::Role::kTabPanel; if (0 == strcmp(role, "tab")) return ax::mojom::Role::kTab; if (0 == strcmp(role, "tableHeaderContainer")) return ax::mojom::Role::kTableHeaderContainer; if (0 == strcmp(role, "table")) return ax::mojom::Role::kTable; if (0 == strcmp(role, "term")) return ax::mojom::Role::kTerm; if (0 == strcmp(role, "textField")) return ax::mojom::Role::kTextField; if (0 == strcmp(role, "textFieldWithComboBox")) return ax::mojom::Role::kTextFieldWithComboBox; if (0 == strcmp(role, "time")) return ax::mojom::Role::kTime; if (0 == strcmp(role, "timer")) return ax::mojom::Role::kTimer; if (0 == strcmp(role, "titleBar")) return ax::mojom::Role::kTitleBar; if (0 == strcmp(role, "toggleButton")) return ax::mojom::Role::kToggleButton; if (0 == strcmp(role, "toolbar")) return ax::mojom::Role::kToolbar; if (0 == strcmp(role, "treeGrid")) return ax::mojom::Role::kTreeGrid; if (0 == strcmp(role, "treeItem")) return ax::mojom::Role::kTreeItem; if (0 == strcmp(role, "tree")) return ax::mojom::Role::kTree; if (0 == strcmp(role, "unknown")) return ax::mojom::Role::kUnknown; if (0 == strcmp(role, "tooltip")) return ax::mojom::Role::kTooltip; if (0 == strcmp(role, "video")) return ax::mojom::Role::kVideo; if (0 == strcmp(role, "webArea")) return ax::mojom::Role::kWebArea; if (0 == strcmp(role, "webView")) return ax::mojom::Role::kWebView; if (0 == strcmp(role, "window")) return ax::mojom::Role::kWindow; return ax::mojom::Role::kNone; } const char* ToString(ax::mojom::State state) { switch (state) { case ax::mojom::State::kNone: return "none"; case ax::mojom::State::kCollapsed: return "collapsed"; case ax::mojom::State::kDefault: return "default"; case ax::mojom::State::kEditable: return "editable"; case ax::mojom::State::kExpanded: return "expanded"; case ax::mojom::State::kFocusable: return "focusable"; case ax::mojom::State::kHaspopup: return "haspopup"; case ax::mojom::State::kHorizontal: return "horizontal"; case ax::mojom::State::kHovered: return "hovered"; case ax::mojom::State::kIgnored: return "ignored"; case ax::mojom::State::kInvisible: return "invisible"; case ax::mojom::State::kLinked: return "linked"; case ax::mojom::State::kMultiline: return "multiline"; case ax::mojom::State::kMultiselectable: return "multiselectable"; case ax::mojom::State::kProtected: return "protected"; case ax::mojom::State::kRequired: return "required"; case ax::mojom::State::kRichlyEditable: return "richlyEditable"; case ax::mojom::State::kVertical: return "vertical"; case ax::mojom::State::kVisited: return "visited"; } return ""; } ax::mojom::State ParseState(const char* state) { if (0 == strcmp(state, "none")) return ax::mojom::State::kNone; if (0 == strcmp(state, "collapsed")) return ax::mojom::State::kCollapsed; if (0 == strcmp(state, "default")) return ax::mojom::State::kDefault; if (0 == strcmp(state, "editable")) return ax::mojom::State::kEditable; if (0 == strcmp(state, "expanded")) return ax::mojom::State::kExpanded; if (0 == strcmp(state, "focusable")) return ax::mojom::State::kFocusable; if (0 == strcmp(state, "haspopup")) return ax::mojom::State::kHaspopup; if (0 == strcmp(state, "horizontal")) return ax::mojom::State::kHorizontal; if (0 == strcmp(state, "hovered")) return ax::mojom::State::kHovered; if (0 == strcmp(state, "ignored")) return ax::mojom::State::kIgnored; if (0 == strcmp(state, "invisible")) return ax::mojom::State::kInvisible; if (0 == strcmp(state, "linked")) return ax::mojom::State::kLinked; if (0 == strcmp(state, "multiline")) return ax::mojom::State::kMultiline; if (0 == strcmp(state, "multiselectable")) return ax::mojom::State::kMultiselectable; if (0 == strcmp(state, "protected")) return ax::mojom::State::kProtected; if (0 == strcmp(state, "required")) return ax::mojom::State::kRequired; if (0 == strcmp(state, "richlyEditable")) return ax::mojom::State::kRichlyEditable; if (0 == strcmp(state, "vertical")) return ax::mojom::State::kVertical; if (0 == strcmp(state, "visited")) return ax::mojom::State::kVisited; return ax::mojom::State::kNone; } const char* ToString(ax::mojom::Action action) { switch (action) { case ax::mojom::Action::kNone: return "none"; case ax::mojom::Action::kBlur: return "blur"; case ax::mojom::Action::kCustomAction: return "customAction"; case ax::mojom::Action::kDecrement: return "decrement"; case ax::mojom::Action::kDoDefault: return "doDefault"; case ax::mojom::Action::kFocus: return "focus"; case ax::mojom::Action::kGetImageData: return "getImageData"; case ax::mojom::Action::kHitTest: return "hitTest"; case ax::mojom::Action::kIncrement: return "increment"; case ax::mojom::Action::kLoadInlineTextBoxes: return "loadInlineTextBoxes"; case ax::mojom::Action::kReplaceSelectedText: return "replaceSelectedText"; case ax::mojom::Action::kScrollBackward: return "scrollBackward"; case ax::mojom::Action::kScrollForward: return "scrollForward"; case ax::mojom::Action::kScrollUp: return "scrollUp"; case ax::mojom::Action::kScrollDown: return "scrollDown"; case ax::mojom::Action::kScrollLeft: return "scrollLeft"; case ax::mojom::Action::kScrollRight: return "scrollRight"; case ax::mojom::Action::kScrollToMakeVisible: return "scrollToMakeVisible"; case ax::mojom::Action::kScrollToPoint: return "scrollToPoint"; case ax::mojom::Action::kSetScrollOffset: return "setScrollOffset"; case ax::mojom::Action::kSetSelection: return "setSelection"; case ax::mojom::Action::kSetSequentialFocusNavigationStartingPoint: return "setSequentialFocusNavigationStartingPoint"; case ax::mojom::Action::kSetValue: return "setValue"; case ax::mojom::Action::kShowContextMenu: return "showContextMenu"; } return ""; } ax::mojom::Action ParseAction(const char* action) { if (0 == strcmp(action, "none")) return ax::mojom::Action::kNone; if (0 == strcmp(action, "blur")) return ax::mojom::Action::kBlur; if (0 == strcmp(action, "customAction")) return ax::mojom::Action::kCustomAction; if (0 == strcmp(action, "decrement")) return ax::mojom::Action::kDecrement; if (0 == strcmp(action, "doDefault")) return ax::mojom::Action::kDoDefault; if (0 == strcmp(action, "focus")) return ax::mojom::Action::kFocus; if (0 == strcmp(action, "getImageData")) return ax::mojom::Action::kGetImageData; if (0 == strcmp(action, "hitTest")) return ax::mojom::Action::kHitTest; if (0 == strcmp(action, "increment")) return ax::mojom::Action::kIncrement; if (0 == strcmp(action, "loadInlineTextBoxes")) return ax::mojom::Action::kLoadInlineTextBoxes; if (0 == strcmp(action, "replaceSelectedText")) return ax::mojom::Action::kReplaceSelectedText; if (0 == strcmp(action, "scrollBackward")) return ax::mojom::Action::kScrollBackward; if (0 == strcmp(action, "scrollForward")) return ax::mojom::Action::kScrollForward; if (0 == strcmp(action, "scrollUp")) return ax::mojom::Action::kScrollUp; if (0 == strcmp(action, "scrollDown")) return ax::mojom::Action::kScrollDown; if (0 == strcmp(action, "scrollLeft")) return ax::mojom::Action::kScrollLeft; if (0 == strcmp(action, "scrollRight")) return ax::mojom::Action::kScrollRight; if (0 == strcmp(action, "scrollToMakeVisible")) return ax::mojom::Action::kScrollToMakeVisible; if (0 == strcmp(action, "scrollToPoint")) return ax::mojom::Action::kScrollToPoint; if (0 == strcmp(action, "setScrollOffset")) return ax::mojom::Action::kSetScrollOffset; if (0 == strcmp(action, "setSelection")) return ax::mojom::Action::kSetSelection; if (0 == strcmp(action, "setSequentialFocusNavigationStartingPoint")) return ax::mojom::Action::kSetSequentialFocusNavigationStartingPoint; if (0 == strcmp(action, "setValue")) return ax::mojom::Action::kSetValue; if (0 == strcmp(action, "showContextMenu")) return ax::mojom::Action::kShowContextMenu; return ax::mojom::Action::kNone; } const char* ToString(ax::mojom::ActionFlags action_flags) { switch (action_flags) { case ax::mojom::ActionFlags::kNone: return "none"; case ax::mojom::ActionFlags::kRequestImages: return "requestImages"; case ax::mojom::ActionFlags::kRequestInlineTextBoxes: return "requestInlineTextBoxes"; } return ""; } ax::mojom::ActionFlags ParseActionFlags(const char* action_flags) { if (0 == strcmp(action_flags, "none")) return ax::mojom::ActionFlags::kNone; if (0 == strcmp(action_flags, "requestImages")) return ax::mojom::ActionFlags::kRequestImages; if (0 == strcmp(action_flags, "requestInlineTextBoxes")) return ax::mojom::ActionFlags::kRequestInlineTextBoxes; return ax::mojom::ActionFlags::kNone; } const char* ToString(ax::mojom::DefaultActionVerb default_action_verb) { switch (default_action_verb) { case ax::mojom::DefaultActionVerb::kNone: return "none"; case ax::mojom::DefaultActionVerb::kActivate: return "activate"; case ax::mojom::DefaultActionVerb::kCheck: return "check"; case ax::mojom::DefaultActionVerb::kClick: return "click"; case ax::mojom::DefaultActionVerb::kClickAncestor: return "clickAncestor"; case ax::mojom::DefaultActionVerb::kJump: return "jump"; case ax::mojom::DefaultActionVerb::kOpen: return "open"; case ax::mojom::DefaultActionVerb::kPress: return "press"; case ax::mojom::DefaultActionVerb::kSelect: return "select"; case ax::mojom::DefaultActionVerb::kUncheck: return "uncheck"; } return ""; } ax::mojom::DefaultActionVerb ParseDefaultActionVerb( const char* default_action_verb) { if (0 == strcmp(default_action_verb, "none")) return ax::mojom::DefaultActionVerb::kNone; if (0 == strcmp(default_action_verb, "activate")) return ax::mojom::DefaultActionVerb::kActivate; if (0 == strcmp(default_action_verb, "check")) return ax::mojom::DefaultActionVerb::kCheck; if (0 == strcmp(default_action_verb, "click")) return ax::mojom::DefaultActionVerb::kClick; if (0 == strcmp(default_action_verb, "clickAncestor")) return ax::mojom::DefaultActionVerb::kClickAncestor; if (0 == strcmp(default_action_verb, "jump")) return ax::mojom::DefaultActionVerb::kJump; if (0 == strcmp(default_action_verb, "open")) return ax::mojom::DefaultActionVerb::kOpen; if (0 == strcmp(default_action_verb, "press")) return ax::mojom::DefaultActionVerb::kPress; if (0 == strcmp(default_action_verb, "select")) return ax::mojom::DefaultActionVerb::kSelect; if (0 == strcmp(default_action_verb, "uncheck")) return ax::mojom::DefaultActionVerb::kUncheck; return ax::mojom::DefaultActionVerb::kNone; } const char* ToString(ax::mojom::Mutation mutation) { switch (mutation) { case ax::mojom::Mutation::kNone: return "none"; case ax::mojom::Mutation::kNodeCreated: return "nodeCreated"; case ax::mojom::Mutation::kSubtreeCreated: return "subtreeCreated"; case ax::mojom::Mutation::kNodeChanged: return "nodeChanged"; case ax::mojom::Mutation::kNodeRemoved: return "nodeRemoved"; } return ""; } ax::mojom::Mutation ParseMutation(const char* mutation) { if (0 == strcmp(mutation, "none")) return ax::mojom::Mutation::kNone; if (0 == strcmp(mutation, "nodeCreated")) return ax::mojom::Mutation::kNodeCreated; if (0 == strcmp(mutation, "subtreeCreated")) return ax::mojom::Mutation::kSubtreeCreated; if (0 == strcmp(mutation, "nodeChanged")) return ax::mojom::Mutation::kNodeChanged; if (0 == strcmp(mutation, "nodeRemoved")) return ax::mojom::Mutation::kNodeRemoved; return ax::mojom::Mutation::kNone; } const char* ToString(ax::mojom::StringAttribute string_attribute) { switch (string_attribute) { case ax::mojom::StringAttribute::kNone: return "none"; case ax::mojom::StringAttribute::kAccessKey: return "accessKey"; case ax::mojom::StringAttribute::kAriaInvalidValue: return "ariaInvalidValue"; case ax::mojom::StringAttribute::kAutoComplete: return "autoComplete"; case ax::mojom::StringAttribute::kChromeChannel: return "chromeChannel"; case ax::mojom::StringAttribute::kClassName: return "className"; case ax::mojom::StringAttribute::kContainerLiveRelevant: return "containerLiveRelevant"; case ax::mojom::StringAttribute::kContainerLiveStatus: return "containerLiveStatus"; case ax::mojom::StringAttribute::kDescription: return "description"; case ax::mojom::StringAttribute::kDisplay: return "display"; case ax::mojom::StringAttribute::kFontFamily: return "fontFamily"; case ax::mojom::StringAttribute::kHtmlTag: return "htmlTag"; case ax::mojom::StringAttribute::kImageDataUrl: return "imageDataUrl"; case ax::mojom::StringAttribute::kInnerHtml: return "innerHtml"; case ax::mojom::StringAttribute::kKeyShortcuts: return "keyShortcuts"; case ax::mojom::StringAttribute::kLanguage: return "language"; case ax::mojom::StringAttribute::kName: return "name"; case ax::mojom::StringAttribute::kLiveRelevant: return "liveRelevant"; case ax::mojom::StringAttribute::kLiveStatus: return "liveStatus"; case ax::mojom::StringAttribute::kPlaceholder: return "placeholder"; case ax::mojom::StringAttribute::kRole: return "role"; case ax::mojom::StringAttribute::kRoleDescription: return "roleDescription"; case ax::mojom::StringAttribute::kUrl: return "url"; case ax::mojom::StringAttribute::kValue: return "value"; } return ""; } ax::mojom::StringAttribute ParseStringAttribute(const char* string_attribute) { if (0 == strcmp(string_attribute, "none")) return ax::mojom::StringAttribute::kNone; if (0 == strcmp(string_attribute, "accessKey")) return ax::mojom::StringAttribute::kAccessKey; if (0 == strcmp(string_attribute, "ariaInvalidValue")) return ax::mojom::StringAttribute::kAriaInvalidValue; if (0 == strcmp(string_attribute, "autoComplete")) return ax::mojom::StringAttribute::kAutoComplete; if (0 == strcmp(string_attribute, "chromeChannel")) return ax::mojom::StringAttribute::kChromeChannel; if (0 == strcmp(string_attribute, "className")) return ax::mojom::StringAttribute::kClassName; if (0 == strcmp(string_attribute, "containerLiveRelevant")) return ax::mojom::StringAttribute::kContainerLiveRelevant; if (0 == strcmp(string_attribute, "containerLiveStatus")) return ax::mojom::StringAttribute::kContainerLiveStatus; if (0 == strcmp(string_attribute, "description")) return ax::mojom::StringAttribute::kDescription; if (0 == strcmp(string_attribute, "display")) return ax::mojom::StringAttribute::kDisplay; if (0 == strcmp(string_attribute, "fontFamily")) return ax::mojom::StringAttribute::kFontFamily; if (0 == strcmp(string_attribute, "htmlTag")) return ax::mojom::StringAttribute::kHtmlTag; if (0 == strcmp(string_attribute, "imageDataUrl")) return ax::mojom::StringAttribute::kImageDataUrl; if (0 == strcmp(string_attribute, "innerHtml")) return ax::mojom::StringAttribute::kInnerHtml; if (0 == strcmp(string_attribute, "keyShortcuts")) return ax::mojom::StringAttribute::kKeyShortcuts; if (0 == strcmp(string_attribute, "language")) return ax::mojom::StringAttribute::kLanguage; if (0 == strcmp(string_attribute, "name")) return ax::mojom::StringAttribute::kName; if (0 == strcmp(string_attribute, "liveRelevant")) return ax::mojom::StringAttribute::kLiveRelevant; if (0 == strcmp(string_attribute, "liveStatus")) return ax::mojom::StringAttribute::kLiveStatus; if (0 == strcmp(string_attribute, "placeholder")) return ax::mojom::StringAttribute::kPlaceholder; if (0 == strcmp(string_attribute, "role")) return ax::mojom::StringAttribute::kRole; if (0 == strcmp(string_attribute, "roleDescription")) return ax::mojom::StringAttribute::kRoleDescription; if (0 == strcmp(string_attribute, "url")) return ax::mojom::StringAttribute::kUrl; if (0 == strcmp(string_attribute, "value")) return ax::mojom::StringAttribute::kValue; return ax::mojom::StringAttribute::kNone; } const char* ToString(ax::mojom::IntAttribute int_attribute) { switch (int_attribute) { case ax::mojom::IntAttribute::kNone: return "none"; case ax::mojom::IntAttribute::kDefaultActionVerb: return "defaultActionVerb"; case ax::mojom::IntAttribute::kScrollX: return "scrollX"; case ax::mojom::IntAttribute::kScrollXMin: return "scrollXMin"; case ax::mojom::IntAttribute::kScrollXMax: return "scrollXMax"; case ax::mojom::IntAttribute::kScrollY: return "scrollY"; case ax::mojom::IntAttribute::kScrollYMin: return "scrollYMin"; case ax::mojom::IntAttribute::kScrollYMax: return "scrollYMax"; case ax::mojom::IntAttribute::kTextSelStart: return "textSelStart"; case ax::mojom::IntAttribute::kTextSelEnd: return "textSelEnd"; case ax::mojom::IntAttribute::kAriaColumnCount: return "ariaColumnCount"; case ax::mojom::IntAttribute::kAriaCellColumnIndex: return "ariaCellColumnIndex"; case ax::mojom::IntAttribute::kAriaRowCount: return "ariaRowCount"; case ax::mojom::IntAttribute::kAriaCellRowIndex: return "ariaCellRowIndex"; case ax::mojom::IntAttribute::kTableRowCount: return "tableRowCount"; case ax::mojom::IntAttribute::kTableColumnCount: return "tableColumnCount"; case ax::mojom::IntAttribute::kTableHeaderId: return "tableHeaderId"; case ax::mojom::IntAttribute::kTableRowIndex: return "tableRowIndex"; case ax::mojom::IntAttribute::kTableRowHeaderId: return "tableRowHeaderId"; case ax::mojom::IntAttribute::kTableColumnIndex: return "tableColumnIndex"; case ax::mojom::IntAttribute::kTableColumnHeaderId: return "tableColumnHeaderId"; case ax::mojom::IntAttribute::kTableCellColumnIndex: return "tableCellColumnIndex"; case ax::mojom::IntAttribute::kTableCellColumnSpan: return "tableCellColumnSpan"; case ax::mojom::IntAttribute::kTableCellRowIndex: return "tableCellRowIndex"; case ax::mojom::IntAttribute::kTableCellRowSpan: return "tableCellRowSpan"; case ax::mojom::IntAttribute::kSortDirection: return "sortDirection"; case ax::mojom::IntAttribute::kHierarchicalLevel: return "hierarchicalLevel"; case ax::mojom::IntAttribute::kNameFrom: return "nameFrom"; case ax::mojom::IntAttribute::kDescriptionFrom: return "descriptionFrom"; case ax::mojom::IntAttribute::kActivedescendantId: return "activedescendantId"; case ax::mojom::IntAttribute::kDetailsId: return "detailsId"; case ax::mojom::IntAttribute::kErrormessageId: return "errormessageId"; case ax::mojom::IntAttribute::kInPageLinkTargetId: return "inPageLinkTargetId"; case ax::mojom::IntAttribute::kMemberOfId: return "memberOfId"; case ax::mojom::IntAttribute::kNextOnLineId: return "nextOnLineId"; case ax::mojom::IntAttribute::kPreviousOnLineId: return "previousOnLineId"; case ax::mojom::IntAttribute::kChildTreeId: return "childTreeId"; case ax::mojom::IntAttribute::kRestriction: return "restriction"; case ax::mojom::IntAttribute::kSetSize: return "setSize"; case ax::mojom::IntAttribute::kPosInSet: return "posInSet"; case ax::mojom::IntAttribute::kColorValue: return "colorValue"; case ax::mojom::IntAttribute::kAriaCurrentState: return "ariaCurrentState"; case ax::mojom::IntAttribute::kBackgroundColor: return "backgroundColor"; case ax::mojom::IntAttribute::kColor: return "color"; case ax::mojom::IntAttribute::kInvalidState: return "invalidState"; case ax::mojom::IntAttribute::kCheckedState: return "checkedState"; case ax::mojom::IntAttribute::kTextDirection: return "textDirection"; case ax::mojom::IntAttribute::kTextStyle: return "textStyle"; case ax::mojom::IntAttribute::kPreviousFocusId: return "previousFocusId"; case ax::mojom::IntAttribute::kNextFocusId: return "nextFocusId"; } return ""; } ax::mojom::IntAttribute ParseIntAttribute(const char* int_attribute) { if (0 == strcmp(int_attribute, "none")) return ax::mojom::IntAttribute::kNone; if (0 == strcmp(int_attribute, "defaultActionVerb")) return ax::mojom::IntAttribute::kDefaultActionVerb; if (0 == strcmp(int_attribute, "scrollX")) return ax::mojom::IntAttribute::kScrollX; if (0 == strcmp(int_attribute, "scrollXMin")) return ax::mojom::IntAttribute::kScrollXMin; if (0 == strcmp(int_attribute, "scrollXMax")) return ax::mojom::IntAttribute::kScrollXMax; if (0 == strcmp(int_attribute, "scrollY")) return ax::mojom::IntAttribute::kScrollY; if (0 == strcmp(int_attribute, "scrollYMin")) return ax::mojom::IntAttribute::kScrollYMin; if (0 == strcmp(int_attribute, "scrollYMax")) return ax::mojom::IntAttribute::kScrollYMax; if (0 == strcmp(int_attribute, "textSelStart")) return ax::mojom::IntAttribute::kTextSelStart; if (0 == strcmp(int_attribute, "textSelEnd")) return ax::mojom::IntAttribute::kTextSelEnd; if (0 == strcmp(int_attribute, "ariaColumnCount")) return ax::mojom::IntAttribute::kAriaColumnCount; if (0 == strcmp(int_attribute, "ariaCellColumnIndex")) return ax::mojom::IntAttribute::kAriaCellColumnIndex; if (0 == strcmp(int_attribute, "ariaRowCount")) return ax::mojom::IntAttribute::kAriaRowCount; if (0 == strcmp(int_attribute, "ariaCellRowIndex")) return ax::mojom::IntAttribute::kAriaCellRowIndex; if (0 == strcmp(int_attribute, "tableRowCount")) return ax::mojom::IntAttribute::kTableRowCount; if (0 == strcmp(int_attribute, "tableColumnCount")) return ax::mojom::IntAttribute::kTableColumnCount; if (0 == strcmp(int_attribute, "tableHeaderId")) return ax::mojom::IntAttribute::kTableHeaderId; if (0 == strcmp(int_attribute, "tableRowIndex")) return ax::mojom::IntAttribute::kTableRowIndex; if (0 == strcmp(int_attribute, "tableRowHeaderId")) return ax::mojom::IntAttribute::kTableRowHeaderId; if (0 == strcmp(int_attribute, "tableColumnIndex")) return ax::mojom::IntAttribute::kTableColumnIndex; if (0 == strcmp(int_attribute, "tableColumnHeaderId")) return ax::mojom::IntAttribute::kTableColumnHeaderId; if (0 == strcmp(int_attribute, "tableCellColumnIndex")) return ax::mojom::IntAttribute::kTableCellColumnIndex; if (0 == strcmp(int_attribute, "tableCellColumnSpan")) return ax::mojom::IntAttribute::kTableCellColumnSpan; if (0 == strcmp(int_attribute, "tableCellRowIndex")) return ax::mojom::IntAttribute::kTableCellRowIndex; if (0 == strcmp(int_attribute, "tableCellRowSpan")) return ax::mojom::IntAttribute::kTableCellRowSpan; if (0 == strcmp(int_attribute, "sortDirection")) return ax::mojom::IntAttribute::kSortDirection; if (0 == strcmp(int_attribute, "hierarchicalLevel")) return ax::mojom::IntAttribute::kHierarchicalLevel; if (0 == strcmp(int_attribute, "nameFrom")) return ax::mojom::IntAttribute::kNameFrom; if (0 == strcmp(int_attribute, "descriptionFrom")) return ax::mojom::IntAttribute::kDescriptionFrom; if (0 == strcmp(int_attribute, "activedescendantId")) return ax::mojom::IntAttribute::kActivedescendantId; if (0 == strcmp(int_attribute, "detailsId")) return ax::mojom::IntAttribute::kDetailsId; if (0 == strcmp(int_attribute, "errormessageId")) return ax::mojom::IntAttribute::kErrormessageId; if (0 == strcmp(int_attribute, "inPageLinkTargetId")) return ax::mojom::IntAttribute::kInPageLinkTargetId; if (0 == strcmp(int_attribute, "memberOfId")) return ax::mojom::IntAttribute::kMemberOfId; if (0 == strcmp(int_attribute, "nextOnLineId")) return ax::mojom::IntAttribute::kNextOnLineId; if (0 == strcmp(int_attribute, "previousOnLineId")) return ax::mojom::IntAttribute::kPreviousOnLineId; if (0 == strcmp(int_attribute, "childTreeId")) return ax::mojom::IntAttribute::kChildTreeId; if (0 == strcmp(int_attribute, "restriction")) return ax::mojom::IntAttribute::kRestriction; if (0 == strcmp(int_attribute, "setSize")) return ax::mojom::IntAttribute::kSetSize; if (0 == strcmp(int_attribute, "posInSet")) return ax::mojom::IntAttribute::kPosInSet; if (0 == strcmp(int_attribute, "colorValue")) return ax::mojom::IntAttribute::kColorValue; if (0 == strcmp(int_attribute, "ariaCurrentState")) return ax::mojom::IntAttribute::kAriaCurrentState; if (0 == strcmp(int_attribute, "backgroundColor")) return ax::mojom::IntAttribute::kBackgroundColor; if (0 == strcmp(int_attribute, "color")) return ax::mojom::IntAttribute::kColor; if (0 == strcmp(int_attribute, "invalidState")) return ax::mojom::IntAttribute::kInvalidState; if (0 == strcmp(int_attribute, "checkedState")) return ax::mojom::IntAttribute::kCheckedState; if (0 == strcmp(int_attribute, "textDirection")) return ax::mojom::IntAttribute::kTextDirection; if (0 == strcmp(int_attribute, "textStyle")) return ax::mojom::IntAttribute::kTextStyle; if (0 == strcmp(int_attribute, "previousFocusId")) return ax::mojom::IntAttribute::kPreviousFocusId; if (0 == strcmp(int_attribute, "nextFocusId")) return ax::mojom::IntAttribute::kNextFocusId; return ax::mojom::IntAttribute::kNone; } const char* ToString(ax::mojom::FloatAttribute float_attribute) { switch (float_attribute) { case ax::mojom::FloatAttribute::kNone: return "none"; case ax::mojom::FloatAttribute::kValueForRange: return "valueForRange"; case ax::mojom::FloatAttribute::kMinValueForRange: return "minValueForRange"; case ax::mojom::FloatAttribute::kMaxValueForRange: return "maxValueForRange"; case ax::mojom::FloatAttribute::kStepValueForRange: return "stepValueForRange"; case ax::mojom::FloatAttribute::kFontSize: return "fontSize"; } return ""; } ax::mojom::FloatAttribute ParseFloatAttribute(const char* float_attribute) { if (0 == strcmp(float_attribute, "none")) return ax::mojom::FloatAttribute::kNone; if (0 == strcmp(float_attribute, "valueForRange")) return ax::mojom::FloatAttribute::kValueForRange; if (0 == strcmp(float_attribute, "minValueForRange")) return ax::mojom::FloatAttribute::kMinValueForRange; if (0 == strcmp(float_attribute, "maxValueForRange")) return ax::mojom::FloatAttribute::kMaxValueForRange; if (0 == strcmp(float_attribute, "stepValueForRange")) return ax::mojom::FloatAttribute::kStepValueForRange; if (0 == strcmp(float_attribute, "fontSize")) return ax::mojom::FloatAttribute::kFontSize; return ax::mojom::FloatAttribute::kNone; } const char* ToString(ax::mojom::BoolAttribute bool_attribute) { switch (bool_attribute) { case ax::mojom::BoolAttribute::kNone: return "none"; case ax::mojom::BoolAttribute::kBusy: return "busy"; case ax::mojom::BoolAttribute::kEditableRoot: return "editableRoot"; case ax::mojom::BoolAttribute::kContainerLiveAtomic: return "containerLiveAtomic"; case ax::mojom::BoolAttribute::kContainerLiveBusy: return "containerLiveBusy"; case ax::mojom::BoolAttribute::kLiveAtomic: return "liveAtomic"; case ax::mojom::BoolAttribute::kModal: return "modal"; case ax::mojom::BoolAttribute::kUpdateLocationOnly: return "updateLocationOnly"; case ax::mojom::BoolAttribute::kCanvasHasFallback: return "canvasHasFallback"; case ax::mojom::BoolAttribute::kScrollable: return "scrollable"; case ax::mojom::BoolAttribute::kClickable: return "clickable"; case ax::mojom::BoolAttribute::kClipsChildren: return "clipsChildren"; case ax::mojom::BoolAttribute::kSelected: return "selected"; } return ""; } ax::mojom::BoolAttribute ParseBoolAttribute(const char* bool_attribute) { if (0 == strcmp(bool_attribute, "none")) return ax::mojom::BoolAttribute::kNone; if (0 == strcmp(bool_attribute, "busy")) return ax::mojom::BoolAttribute::kBusy; if (0 == strcmp(bool_attribute, "editableRoot")) return ax::mojom::BoolAttribute::kEditableRoot; if (0 == strcmp(bool_attribute, "containerLiveAtomic")) return ax::mojom::BoolAttribute::kContainerLiveAtomic; if (0 == strcmp(bool_attribute, "containerLiveBusy")) return ax::mojom::BoolAttribute::kContainerLiveBusy; if (0 == strcmp(bool_attribute, "liveAtomic")) return ax::mojom::BoolAttribute::kLiveAtomic; if (0 == strcmp(bool_attribute, "modal")) return ax::mojom::BoolAttribute::kModal; if (0 == strcmp(bool_attribute, "updateLocationOnly")) return ax::mojom::BoolAttribute::kUpdateLocationOnly; if (0 == strcmp(bool_attribute, "canvasHasFallback")) return ax::mojom::BoolAttribute::kCanvasHasFallback; if (0 == strcmp(bool_attribute, "scrollable")) return ax::mojom::BoolAttribute::kScrollable; if (0 == strcmp(bool_attribute, "clickable")) return ax::mojom::BoolAttribute::kClickable; if (0 == strcmp(bool_attribute, "clipsChildren")) return ax::mojom::BoolAttribute::kClipsChildren; if (0 == strcmp(bool_attribute, "selected")) return ax::mojom::BoolAttribute::kSelected; return ax::mojom::BoolAttribute::kNone; } const char* ToString(ax::mojom::IntListAttribute int_list_attribute) { switch (int_list_attribute) { case ax::mojom::IntListAttribute::kNone: return "none"; case ax::mojom::IntListAttribute::kIndirectChildIds: return "indirectChildIds"; case ax::mojom::IntListAttribute::kControlsIds: return "controlsIds"; case ax::mojom::IntListAttribute::kDescribedbyIds: return "describedbyIds"; case ax::mojom::IntListAttribute::kFlowtoIds: return "flowtoIds"; case ax::mojom::IntListAttribute::kLabelledbyIds: return "labelledbyIds"; case ax::mojom::IntListAttribute::kRadioGroupIds: return "radioGroupIds"; case ax::mojom::IntListAttribute::kLineBreaks: return "lineBreaks"; case ax::mojom::IntListAttribute::kMarkerTypes: return "markerTypes"; case ax::mojom::IntListAttribute::kMarkerStarts: return "markerStarts"; case ax::mojom::IntListAttribute::kMarkerEnds: return "markerEnds"; case ax::mojom::IntListAttribute::kCellIds: return "cellIds"; case ax::mojom::IntListAttribute::kUniqueCellIds: return "uniqueCellIds"; case ax::mojom::IntListAttribute::kCharacterOffsets: return "characterOffsets"; case ax::mojom::IntListAttribute::kCachedLineStarts: return "cachedLineStarts"; case ax::mojom::IntListAttribute::kWordStarts: return "wordStarts"; case ax::mojom::IntListAttribute::kWordEnds: return "wordEnds"; case ax::mojom::IntListAttribute::kCustomActionIds: return "customActionIds"; } return ""; } ax::mojom::IntListAttribute ParseIntListAttribute( const char* int_list_attribute) { if (0 == strcmp(int_list_attribute, "none")) return ax::mojom::IntListAttribute::kNone; if (0 == strcmp(int_list_attribute, "indirectChildIds")) return ax::mojom::IntListAttribute::kIndirectChildIds; if (0 == strcmp(int_list_attribute, "controlsIds")) return ax::mojom::IntListAttribute::kControlsIds; if (0 == strcmp(int_list_attribute, "describedbyIds")) return ax::mojom::IntListAttribute::kDescribedbyIds; if (0 == strcmp(int_list_attribute, "flowtoIds")) return ax::mojom::IntListAttribute::kFlowtoIds; if (0 == strcmp(int_list_attribute, "labelledbyIds")) return ax::mojom::IntListAttribute::kLabelledbyIds; if (0 == strcmp(int_list_attribute, "radioGroupIds")) return ax::mojom::IntListAttribute::kRadioGroupIds; if (0 == strcmp(int_list_attribute, "lineBreaks")) return ax::mojom::IntListAttribute::kLineBreaks; if (0 == strcmp(int_list_attribute, "markerTypes")) return ax::mojom::IntListAttribute::kMarkerTypes; if (0 == strcmp(int_list_attribute, "markerStarts")) return ax::mojom::IntListAttribute::kMarkerStarts; if (0 == strcmp(int_list_attribute, "markerEnds")) return ax::mojom::IntListAttribute::kMarkerEnds; if (0 == strcmp(int_list_attribute, "cellIds")) return ax::mojom::IntListAttribute::kCellIds; if (0 == strcmp(int_list_attribute, "uniqueCellIds")) return ax::mojom::IntListAttribute::kUniqueCellIds; if (0 == strcmp(int_list_attribute, "characterOffsets")) return ax::mojom::IntListAttribute::kCharacterOffsets; if (0 == strcmp(int_list_attribute, "cachedLineStarts")) return ax::mojom::IntListAttribute::kCachedLineStarts; if (0 == strcmp(int_list_attribute, "wordStarts")) return ax::mojom::IntListAttribute::kWordStarts; if (0 == strcmp(int_list_attribute, "wordEnds")) return ax::mojom::IntListAttribute::kWordEnds; if (0 == strcmp(int_list_attribute, "customActionIds")) return ax::mojom::IntListAttribute::kCustomActionIds; return ax::mojom::IntListAttribute::kNone; } const char* ToString(ax::mojom::StringListAttribute string_list_attribute) { switch (string_list_attribute) { case ax::mojom::StringListAttribute::kNone: return "none"; case ax::mojom::StringListAttribute::kCustomActionDescriptions: return "customActionDescriptions"; } return ""; } ax::mojom::StringListAttribute ParseStringListAttribute( const char* string_list_attribute) { if (0 == strcmp(string_list_attribute, "none")) return ax::mojom::StringListAttribute::kNone; if (0 == strcmp(string_list_attribute, "customActionDescriptions")) return ax::mojom::StringListAttribute::kCustomActionDescriptions; return ax::mojom::StringListAttribute::kNone; } const char* ToString(ax::mojom::MarkerType marker_type) { switch (marker_type) { case ax::mojom::MarkerType::kNone: return "none"; case ax::mojom::MarkerType::kSpelling: return "spelling"; case ax::mojom::MarkerType::kGrammar: return "grammar"; case ax::mojom::MarkerType::kSpellingGrammar: return "spellingGrammar"; case ax::mojom::MarkerType::kTextMatch: return "textMatch"; case ax::mojom::MarkerType::kSpellingTextMatch: return "spellingTextMatch"; case ax::mojom::MarkerType::kGrammarTextMatch: return "grammarTextMatch"; case ax::mojom::MarkerType::kSpellingGrammarTextMatch: return "spellingGrammarTextMatch"; case ax::mojom::MarkerType::kActiveSuggestion: return "activeSuggestion"; case ax::mojom::MarkerType::kSpellingActiveSuggestion: return "spellingActiveSuggestion"; case ax::mojom::MarkerType::kGrammarActiveSuggestion: return "grammarActiveSuggestion"; case ax::mojom::MarkerType::kSpellingGrammarActiveSuggestion: return "spellingGrammarActiveSuggestion"; case ax::mojom::MarkerType::kTextMatchActiveSuggestion: return "textMatchActiveSuggestion"; case ax::mojom::MarkerType::kSpellingTextMatchActiveSuggestion: return "spellingTextMatchActiveSuggestion"; case ax::mojom::MarkerType::kGrammarTextMatchActiveSuggestion: return "grammarTextMatchActiveSuggestion"; case ax::mojom::MarkerType::kSpellingGrammarTextMatchActiveSuggestion: return "spellingGrammarTextMatchActiveSuggestion"; case ax::mojom::MarkerType::kSuggestion: return "suggestion"; case ax::mojom::MarkerType::kSpellingSuggestion: return "spellingSuggestion"; case ax::mojom::MarkerType::kGrammarSuggestion: return "grammarSuggestion"; case ax::mojom::MarkerType::kSpellingGrammarSuggestion: return "spellingGrammarSuggestion"; case ax::mojom::MarkerType::kTextMatchSuggestion: return "textMatchSuggestion"; case ax::mojom::MarkerType::kSpellingTextMatchSuggestion: return "spellingTextMatchSuggestion"; case ax::mojom::MarkerType::kGrammarTextMatchSuggestion: return "grammarTextMatchSuggestion"; case ax::mojom::MarkerType::kSpellingGrammarTextMatchSuggestion: return "spellingGrammarTextMatchSuggestion"; case ax::mojom::MarkerType::kActiveSuggestionSuggestion: return "activeSuggestionSuggestion"; case ax::mojom::MarkerType::kSpellingActiveSuggestionSuggestion: return "spellingActiveSuggestionSuggestion"; case ax::mojom::MarkerType::kGrammarActiveSuggestionSuggestion: return "grammarActiveSuggestionSuggestion"; case ax::mojom::MarkerType::kSpellingGrammarActiveSuggestionSuggestion: return "spellingGrammarActiveSuggestionSuggestion"; case ax::mojom::MarkerType::kTextMatchActiveSuggestionSuggestion: return "textMatchActiveSuggestionSuggestion"; case ax::mojom::MarkerType::kSpellingTextMatchActiveSuggestionSuggestion: return "spellingTextMatchActiveSuggestionSuggestion"; case ax::mojom::MarkerType::kGrammarTextMatchActiveSuggestionSuggestion: return "grammarTextMatchActiveSuggestionSuggestion"; case ax::mojom::MarkerType:: kSpellingGrammarTextMatchActiveSuggestionSuggestion: return "spellingGrammarTextMatchActiveSuggestionSuggestion"; } return ""; } ax::mojom::MarkerType ParseMarkerType(const char* marker_type) { if (0 == strcmp(marker_type, "none")) return ax::mojom::MarkerType::kNone; if (0 == strcmp(marker_type, "spelling")) return ax::mojom::MarkerType::kSpelling; if (0 == strcmp(marker_type, "grammar")) return ax::mojom::MarkerType::kGrammar; if (0 == strcmp(marker_type, "spellingGrammar")) return ax::mojom::MarkerType::kSpellingGrammar; if (0 == strcmp(marker_type, "textMatch")) return ax::mojom::MarkerType::kTextMatch; if (0 == strcmp(marker_type, "spellingTextMatch")) return ax::mojom::MarkerType::kSpellingTextMatch; if (0 == strcmp(marker_type, "grammarTextMatch")) return ax::mojom::MarkerType::kGrammarTextMatch; if (0 == strcmp(marker_type, "spellingGrammarTextMatch")) return ax::mojom::MarkerType::kSpellingGrammarTextMatch; if (0 == strcmp(marker_type, "activeSuggestion")) return ax::mojom::MarkerType::kActiveSuggestion; if (0 == strcmp(marker_type, "spellingActiveSuggestion")) return ax::mojom::MarkerType::kSpellingActiveSuggestion; if (0 == strcmp(marker_type, "grammarActiveSuggestion")) return ax::mojom::MarkerType::kGrammarActiveSuggestion; if (0 == strcmp(marker_type, "spellingGrammarActiveSuggestion")) return ax::mojom::MarkerType::kSpellingGrammarActiveSuggestion; if (0 == strcmp(marker_type, "textMatchActiveSuggestion")) return ax::mojom::MarkerType::kTextMatchActiveSuggestion; if (0 == strcmp(marker_type, "spellingTextMatchActiveSuggestion")) return ax::mojom::MarkerType::kSpellingTextMatchActiveSuggestion; if (0 == strcmp(marker_type, "grammarTextMatchActiveSuggestion")) return ax::mojom::MarkerType::kGrammarTextMatchActiveSuggestion; if (0 == strcmp(marker_type, "spellingGrammarTextMatchActiveSuggestion")) return ax::mojom::MarkerType::kSpellingGrammarTextMatchActiveSuggestion; if (0 == strcmp(marker_type, "suggestion")) return ax::mojom::MarkerType::kSuggestion; if (0 == strcmp(marker_type, "spellingSuggestion")) return ax::mojom::MarkerType::kSpellingSuggestion; if (0 == strcmp(marker_type, "grammarSuggestion")) return ax::mojom::MarkerType::kGrammarSuggestion; if (0 == strcmp(marker_type, "spellingGrammarSuggestion")) return ax::mojom::MarkerType::kSpellingGrammarSuggestion; if (0 == strcmp(marker_type, "textMatchSuggestion")) return ax::mojom::MarkerType::kTextMatchSuggestion; if (0 == strcmp(marker_type, "spellingTextMatchSuggestion")) return ax::mojom::MarkerType::kSpellingTextMatchSuggestion; if (0 == strcmp(marker_type, "grammarTextMatchSuggestion")) return ax::mojom::MarkerType::kGrammarTextMatchSuggestion; if (0 == strcmp(marker_type, "spellingGrammarTextMatchSuggestion")) return ax::mojom::MarkerType::kSpellingGrammarTextMatchSuggestion; if (0 == strcmp(marker_type, "activeSuggestionSuggestion")) return ax::mojom::MarkerType::kActiveSuggestionSuggestion; if (0 == strcmp(marker_type, "spellingActiveSuggestionSuggestion")) return ax::mojom::MarkerType::kSpellingActiveSuggestionSuggestion; if (0 == strcmp(marker_type, "grammarActiveSuggestionSuggestion")) return ax::mojom::MarkerType::kGrammarActiveSuggestionSuggestion; if (0 == strcmp(marker_type, "spellingGrammarActiveSuggestionSuggestion")) return ax::mojom::MarkerType::kSpellingGrammarActiveSuggestionSuggestion; if (0 == strcmp(marker_type, "textMatchActiveSuggestionSuggestion")) return ax::mojom::MarkerType::kTextMatchActiveSuggestionSuggestion; if (0 == strcmp(marker_type, "spellingTextMatchActiveSuggestionSuggestion")) return ax::mojom::MarkerType::kSpellingTextMatchActiveSuggestionSuggestion; if (0 == strcmp(marker_type, "grammarTextMatchActiveSuggestionSuggestion")) return ax::mojom::MarkerType::kGrammarTextMatchActiveSuggestionSuggestion; if (0 == strcmp(marker_type, "spellingGrammarTextMatchActiveSuggestionSuggestion")) return ax::mojom::MarkerType:: kSpellingGrammarTextMatchActiveSuggestionSuggestion; return ax::mojom::MarkerType::kNone; } const char* ToString(ax::mojom::TextDirection text_direction) { switch (text_direction) { case ax::mojom::TextDirection::kNone: return "none"; case ax::mojom::TextDirection::kLtr: return "ltr"; case ax::mojom::TextDirection::kRtl: return "rtl"; case ax::mojom::TextDirection::kTtb: return "ttb"; case ax::mojom::TextDirection::kBtt: return "btt"; } return ""; } ax::mojom::TextDirection ParseTextDirection(const char* text_direction) { if (0 == strcmp(text_direction, "none")) return ax::mojom::TextDirection::kNone; if (0 == strcmp(text_direction, "ltr")) return ax::mojom::TextDirection::kLtr; if (0 == strcmp(text_direction, "rtl")) return ax::mojom::TextDirection::kRtl; if (0 == strcmp(text_direction, "ttb")) return ax::mojom::TextDirection::kTtb; if (0 == strcmp(text_direction, "btt")) return ax::mojom::TextDirection::kBtt; return ax::mojom::TextDirection::kNone; } const char* ToString(ax::mojom::TextStyle text_style) { switch (text_style) { case ax::mojom::TextStyle::kNone: return "none"; case ax::mojom::TextStyle::kTextStyleBold: return "textStyleBold"; case ax::mojom::TextStyle::kTextStyleItalic: return "textStyleItalic"; case ax::mojom::TextStyle::kTextStyleBoldItalic: return "textStyleBoldItalic"; case ax::mojom::TextStyle::kTextStyleUnderline: return "textStyleUnderline"; case ax::mojom::TextStyle::kTextStyleBoldUnderline: return "textStyleBoldUnderline"; case ax::mojom::TextStyle::kTextStyleItalicUnderline: return "textStyleItalicUnderline"; case ax::mojom::TextStyle::kTextStyleBoldItalicUnderline: return "textStyleBoldItalicUnderline"; case ax::mojom::TextStyle::kTextStyleLineThrough: return "textStyleLineThrough"; case ax::mojom::TextStyle::kTextStyleBoldLineThrough: return "textStyleBoldLineThrough"; case ax::mojom::TextStyle::kTextStyleItalicLineThrough: return "textStyleItalicLineThrough"; case ax::mojom::TextStyle::kTextStyleBoldItalicLineThrough: return "textStyleBoldItalicLineThrough"; case ax::mojom::TextStyle::kTextStyleUnderlineLineThrough: return "textStyleUnderlineLineThrough"; case ax::mojom::TextStyle::kTextStyleBoldUnderlineLineThrough: return "textStyleBoldUnderlineLineThrough"; case ax::mojom::TextStyle::kTextStyleItalicUnderlineLineThrough: return "textStyleItalicUnderlineLineThrough"; case ax::mojom::TextStyle::kTextStyleBoldItalicUnderlineLineThrough: return "textStyleBoldItalicUnderlineLineThrough"; } return ""; } ax::mojom::TextStyle ParseTextStyle(const char* text_style) { if (0 == strcmp(text_style, "none")) return ax::mojom::TextStyle::kNone; if (0 == strcmp(text_style, "textStyleBold")) return ax::mojom::TextStyle::kTextStyleBold; if (0 == strcmp(text_style, "textStyleItalic")) return ax::mojom::TextStyle::kTextStyleItalic; if (0 == strcmp(text_style, "textStyleBoldItalic")) return ax::mojom::TextStyle::kTextStyleBoldItalic; if (0 == strcmp(text_style, "textStyleUnderline")) return ax::mojom::TextStyle::kTextStyleUnderline; if (0 == strcmp(text_style, "textStyleBoldUnderline")) return ax::mojom::TextStyle::kTextStyleBoldUnderline; if (0 == strcmp(text_style, "textStyleItalicUnderline")) return ax::mojom::TextStyle::kTextStyleItalicUnderline; if (0 == strcmp(text_style, "textStyleBoldItalicUnderline")) return ax::mojom::TextStyle::kTextStyleBoldItalicUnderline; if (0 == strcmp(text_style, "textStyleLineThrough")) return ax::mojom::TextStyle::kTextStyleLineThrough; if (0 == strcmp(text_style, "textStyleBoldLineThrough")) return ax::mojom::TextStyle::kTextStyleBoldLineThrough; if (0 == strcmp(text_style, "textStyleItalicLineThrough")) return ax::mojom::TextStyle::kTextStyleItalicLineThrough; if (0 == strcmp(text_style, "textStyleBoldItalicLineThrough")) return ax::mojom::TextStyle::kTextStyleBoldItalicLineThrough; if (0 == strcmp(text_style, "textStyleUnderlineLineThrough")) return ax::mojom::TextStyle::kTextStyleUnderlineLineThrough; if (0 == strcmp(text_style, "textStyleBoldUnderlineLineThrough")) return ax::mojom::TextStyle::kTextStyleBoldUnderlineLineThrough; if (0 == strcmp(text_style, "textStyleItalicUnderlineLineThrough")) return ax::mojom::TextStyle::kTextStyleItalicUnderlineLineThrough; if (0 == strcmp(text_style, "textStyleBoldItalicUnderlineLineThrough")) return ax::mojom::TextStyle::kTextStyleBoldItalicUnderlineLineThrough; return ax::mojom::TextStyle::kNone; } const char* ToString(ax::mojom::AriaCurrentState aria_current_state) { switch (aria_current_state) { case ax::mojom::AriaCurrentState::kNone: return "none"; case ax::mojom::AriaCurrentState::kFalse: return "false"; case ax::mojom::AriaCurrentState::kTrue: return "true"; case ax::mojom::AriaCurrentState::kPage: return "page"; case ax::mojom::AriaCurrentState::kStep: return "step"; case ax::mojom::AriaCurrentState::kLocation: return "location"; case ax::mojom::AriaCurrentState::kUnclippedLocation: return "unclippedLocation"; case ax::mojom::AriaCurrentState::kDate: return "date"; case ax::mojom::AriaCurrentState::kTime: return "time"; } return ""; } ax::mojom::AriaCurrentState ParseAriaCurrentState( const char* aria_current_state) { if (0 == strcmp(aria_current_state, "none")) return ax::mojom::AriaCurrentState::kNone; if (0 == strcmp(aria_current_state, "false")) return ax::mojom::AriaCurrentState::kFalse; if (0 == strcmp(aria_current_state, "true")) return ax::mojom::AriaCurrentState::kTrue; if (0 == strcmp(aria_current_state, "page")) return ax::mojom::AriaCurrentState::kPage; if (0 == strcmp(aria_current_state, "step")) return ax::mojom::AriaCurrentState::kStep; if (0 == strcmp(aria_current_state, "location")) return ax::mojom::AriaCurrentState::kLocation; if (0 == strcmp(aria_current_state, "unclippedLocation")) return ax::mojom::AriaCurrentState::kUnclippedLocation; if (0 == strcmp(aria_current_state, "date")) return ax::mojom::AriaCurrentState::kDate; if (0 == strcmp(aria_current_state, "time")) return ax::mojom::AriaCurrentState::kTime; return ax::mojom::AriaCurrentState::kNone; } const char* ToString(ax::mojom::InvalidState invalid_state) { switch (invalid_state) { case ax::mojom::InvalidState::kNone: return "none"; case ax::mojom::InvalidState::kFalse: return "false"; case ax::mojom::InvalidState::kTrue: return "true"; case ax::mojom::InvalidState::kSpelling: return "spelling"; case ax::mojom::InvalidState::kGrammar: return "grammar"; case ax::mojom::InvalidState::kOther: return "other"; } return ""; } ax::mojom::InvalidState ParseInvalidState(const char* invalid_state) { if (0 == strcmp(invalid_state, "none")) return ax::mojom::InvalidState::kNone; if (0 == strcmp(invalid_state, "false")) return ax::mojom::InvalidState::kFalse; if (0 == strcmp(invalid_state, "true")) return ax::mojom::InvalidState::kTrue; if (0 == strcmp(invalid_state, "spelling")) return ax::mojom::InvalidState::kSpelling; if (0 == strcmp(invalid_state, "grammar")) return ax::mojom::InvalidState::kGrammar; if (0 == strcmp(invalid_state, "other")) return ax::mojom::InvalidState::kOther; return ax::mojom::InvalidState::kNone; } const char* ToString(ax::mojom::Restriction restriction) { switch (restriction) { case ax::mojom::Restriction::kNone: return "none"; case ax::mojom::Restriction::kReadOnly: return "readOnly"; case ax::mojom::Restriction::kDisabled: return "disabled"; } return ""; } ax::mojom::Restriction ParseRestriction(const char* restriction) { if (0 == strcmp(restriction, "none")) return ax::mojom::Restriction::kNone; if (0 == strcmp(restriction, "readOnly")) return ax::mojom::Restriction::kReadOnly; if (0 == strcmp(restriction, "disabled")) return ax::mojom::Restriction::kDisabled; return ax::mojom::Restriction::kNone; } const char* ToString(ax::mojom::CheckedState checked_state) { switch (checked_state) { case ax::mojom::CheckedState::kNone: return "none"; case ax::mojom::CheckedState::kFalse: return "false"; case ax::mojom::CheckedState::kTrue: return "true"; case ax::mojom::CheckedState::kMixed: return "mixed"; } return ""; } ax::mojom::CheckedState ParseCheckedState(const char* checked_state) { if (0 == strcmp(checked_state, "none")) return ax::mojom::CheckedState::kNone; if (0 == strcmp(checked_state, "false")) return ax::mojom::CheckedState::kFalse; if (0 == strcmp(checked_state, "true")) return ax::mojom::CheckedState::kTrue; if (0 == strcmp(checked_state, "mixed")) return ax::mojom::CheckedState::kMixed; return ax::mojom::CheckedState::kNone; } const char* ToString(ax::mojom::SortDirection sort_direction) { switch (sort_direction) { case ax::mojom::SortDirection::kNone: return "none"; case ax::mojom::SortDirection::kUnsorted: return "unsorted"; case ax::mojom::SortDirection::kAscending: return "ascending"; case ax::mojom::SortDirection::kDescending: return "descending"; case ax::mojom::SortDirection::kOther: return "other"; } return ""; } ax::mojom::SortDirection ParseSortDirection(const char* sort_direction) { if (0 == strcmp(sort_direction, "none")) return ax::mojom::SortDirection::kNone; if (0 == strcmp(sort_direction, "unsorted")) return ax::mojom::SortDirection::kUnsorted; if (0 == strcmp(sort_direction, "ascending")) return ax::mojom::SortDirection::kAscending; if (0 == strcmp(sort_direction, "descending")) return ax::mojom::SortDirection::kDescending; if (0 == strcmp(sort_direction, "other")) return ax::mojom::SortDirection::kOther; return ax::mojom::SortDirection::kNone; } const char* ToString(ax::mojom::NameFrom name_from) { switch (name_from) { case ax::mojom::NameFrom::kNone: return "none"; case ax::mojom::NameFrom::kUninitialized: return "uninitialized"; case ax::mojom::NameFrom::kAttribute: return "attribute"; case ax::mojom::NameFrom::kAttributeExplicitlyEmpty: return "attributeExplicitlyEmpty"; case ax::mojom::NameFrom::kContents: return "contents"; case ax::mojom::NameFrom::kPlaceholder: return "placeholder"; case ax::mojom::NameFrom::kRelatedElement: return "relatedElement"; case ax::mojom::NameFrom::kValue: return "value"; } return ""; } ax::mojom::NameFrom ParseNameFrom(const char* name_from) { if (0 == strcmp(name_from, "none")) return ax::mojom::NameFrom::kNone; if (0 == strcmp(name_from, "uninitialized")) return ax::mojom::NameFrom::kUninitialized; if (0 == strcmp(name_from, "attribute")) return ax::mojom::NameFrom::kAttribute; if (0 == strcmp(name_from, "attributeExplicitlyEmpty")) return ax::mojom::NameFrom::kAttributeExplicitlyEmpty; if (0 == strcmp(name_from, "contents")) return ax::mojom::NameFrom::kContents; if (0 == strcmp(name_from, "placeholder")) return ax::mojom::NameFrom::kPlaceholder; if (0 == strcmp(name_from, "relatedElement")) return ax::mojom::NameFrom::kRelatedElement; if (0 == strcmp(name_from, "value")) return ax::mojom::NameFrom::kValue; return ax::mojom::NameFrom::kNone; } const char* ToString(ax::mojom::DescriptionFrom description_from) { switch (description_from) { case ax::mojom::DescriptionFrom::kNone: return "none"; case ax::mojom::DescriptionFrom::kUninitialized: return "uninitialized"; case ax::mojom::DescriptionFrom::kAttribute: return "attribute"; case ax::mojom::DescriptionFrom::kContents: return "contents"; case ax::mojom::DescriptionFrom::kPlaceholder: return "placeholder"; case ax::mojom::DescriptionFrom::kRelatedElement: return "relatedElement"; } return ""; } ax::mojom::DescriptionFrom ParseDescriptionFrom(const char* description_from) { if (0 == strcmp(description_from, "none")) return ax::mojom::DescriptionFrom::kNone; if (0 == strcmp(description_from, "uninitialized")) return ax::mojom::DescriptionFrom::kUninitialized; if (0 == strcmp(description_from, "attribute")) return ax::mojom::DescriptionFrom::kAttribute; if (0 == strcmp(description_from, "contents")) return ax::mojom::DescriptionFrom::kContents; if (0 == strcmp(description_from, "placeholder")) return ax::mojom::DescriptionFrom::kPlaceholder; if (0 == strcmp(description_from, "relatedElement")) return ax::mojom::DescriptionFrom::kRelatedElement; return ax::mojom::DescriptionFrom::kNone; } const char* ToString(ax::mojom::EventFrom event_from) { switch (event_from) { case ax::mojom::EventFrom::kNone: return "none"; case ax::mojom::EventFrom::kUser: return "user"; case ax::mojom::EventFrom::kPage: return "page"; case ax::mojom::EventFrom::kAction: return "action"; } return ""; } ax::mojom::EventFrom ParseEventFrom(const char* event_from) { if (0 == strcmp(event_from, "none")) return ax::mojom::EventFrom::kNone; if (0 == strcmp(event_from, "user")) return ax::mojom::EventFrom::kUser; if (0 == strcmp(event_from, "page")) return ax::mojom::EventFrom::kPage; if (0 == strcmp(event_from, "action")) return ax::mojom::EventFrom::kAction; return ax::mojom::EventFrom::kNone; } const char* ToString(ax::mojom::Gesture gesture) { switch (gesture) { case ax::mojom::Gesture::kNone: return "none"; case ax::mojom::Gesture::kClick: return "click"; case ax::mojom::Gesture::kSwipeLeft1: return "swipeLeft1"; case ax::mojom::Gesture::kSwipeUp1: return "swipeUp1"; case ax::mojom::Gesture::kSwipeRight1: return "swipeRight1"; case ax::mojom::Gesture::kSwipeDown1: return "swipeDown1"; case ax::mojom::Gesture::kSwipeLeft2: return "swipeLeft2"; case ax::mojom::Gesture::kSwipeUp2: return "swipeUp2"; case ax::mojom::Gesture::kSwipeRight2: return "swipeRight2"; case ax::mojom::Gesture::kSwipeDown2: return "swipeDown2"; case ax::mojom::Gesture::kSwipeLeft3: return "swipeLeft3"; case ax::mojom::Gesture::kSwipeUp3: return "swipeUp3"; case ax::mojom::Gesture::kSwipeRight3: return "swipeRight3"; case ax::mojom::Gesture::kSwipeDown3: return "swipeDown3"; case ax::mojom::Gesture::kSwipeLeft4: return "swipeLeft4"; case ax::mojom::Gesture::kSwipeUp4: return "swipeUp4"; case ax::mojom::Gesture::kSwipeRight4: return "swipeRight4"; case ax::mojom::Gesture::kSwipeDown4: return "swipeDown4"; case ax::mojom::Gesture::kTap2: return "tap2"; } return ""; } ax::mojom::Gesture ParseGesture(const char* gesture) { if (0 == strcmp(gesture, "none")) return ax::mojom::Gesture::kNone; if (0 == strcmp(gesture, "click")) return ax::mojom::Gesture::kClick; if (0 == strcmp(gesture, "swipeLeft1")) return ax::mojom::Gesture::kSwipeLeft1; if (0 == strcmp(gesture, "swipeUp1")) return ax::mojom::Gesture::kSwipeUp1; if (0 == strcmp(gesture, "swipeRight1")) return ax::mojom::Gesture::kSwipeRight1; if (0 == strcmp(gesture, "swipeDown1")) return ax::mojom::Gesture::kSwipeDown1; if (0 == strcmp(gesture, "swipeLeft2")) return ax::mojom::Gesture::kSwipeLeft2; if (0 == strcmp(gesture, "swipeUp2")) return ax::mojom::Gesture::kSwipeUp2; if (0 == strcmp(gesture, "swipeRight2")) return ax::mojom::Gesture::kSwipeRight2; if (0 == strcmp(gesture, "swipeDown2")) return ax::mojom::Gesture::kSwipeDown2; if (0 == strcmp(gesture, "swipeLeft3")) return ax::mojom::Gesture::kSwipeLeft3; if (0 == strcmp(gesture, "swipeUp3")) return ax::mojom::Gesture::kSwipeUp3; if (0 == strcmp(gesture, "swipeRight3")) return ax::mojom::Gesture::kSwipeRight3; if (0 == strcmp(gesture, "swipeDown3")) return ax::mojom::Gesture::kSwipeDown3; if (0 == strcmp(gesture, "swipeLeft4")) return ax::mojom::Gesture::kSwipeLeft4; if (0 == strcmp(gesture, "swipeUp4")) return ax::mojom::Gesture::kSwipeUp4; if (0 == strcmp(gesture, "swipeRight4")) return ax::mojom::Gesture::kSwipeRight4; if (0 == strcmp(gesture, "swipeDown4")) return ax::mojom::Gesture::kSwipeDown4; if (0 == strcmp(gesture, "tap2")) return ax::mojom::Gesture::kTap2; return ax::mojom::Gesture::kNone; } const char* ToString(ax::mojom::TextAffinity text_affinity) { switch (text_affinity) { case ax::mojom::TextAffinity::kNone: return "none"; case ax::mojom::TextAffinity::kDownstream: return "downstream"; case ax::mojom::TextAffinity::kUpstream: return "upstream"; } return ""; } ax::mojom::TextAffinity ParseTextAffinity(const char* text_affinity) { if (0 == strcmp(text_affinity, "none")) return ax::mojom::TextAffinity::kNone; if (0 == strcmp(text_affinity, "downstream")) return ax::mojom::TextAffinity::kDownstream; if (0 == strcmp(text_affinity, "upstream")) return ax::mojom::TextAffinity::kUpstream; return ax::mojom::TextAffinity::kNone; } const char* ToString(ax::mojom::TreeOrder tree_order) { switch (tree_order) { case ax::mojom::TreeOrder::kNone: return "none"; case ax::mojom::TreeOrder::kUndefined: return "undefined"; case ax::mojom::TreeOrder::kBefore: return "before"; case ax::mojom::TreeOrder::kEqual: return "equal"; case ax::mojom::TreeOrder::kAfter: return "after"; } return ""; } ax::mojom::TreeOrder ParseTreeOrder(const char* tree_order) { if (0 == strcmp(tree_order, "none")) return ax::mojom::TreeOrder::kNone; if (0 == strcmp(tree_order, "undefined")) return ax::mojom::TreeOrder::kUndefined; if (0 == strcmp(tree_order, "before")) return ax::mojom::TreeOrder::kBefore; if (0 == strcmp(tree_order, "equal")) return ax::mojom::TreeOrder::kEqual; if (0 == strcmp(tree_order, "after")) return ax::mojom::TreeOrder::kAfter; return ax::mojom::TreeOrder::kNone; } } // namespace ui
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
290b089dd70b3c0fc2e743259cd7803036505ead
2a7e77565c33e6b5d92ce6702b4a5fd96f80d7d0
/fuzzedpackages/varband/src/varbandcpp.cpp
b8402af8ad2c5029e5779eeafc4d68419691fab8
[]
no_license
akhikolla/testpackages
62ccaeed866e2194652b65e7360987b3b20df7e7
01259c3543febc89955ea5b79f3a08d3afe57e95
refs/heads/master
2023-02-18T03:50:28.288006
2021-01-18T13:23:32
2021-01-18T13:23:32
329,981,898
7
1
null
null
null
null
UTF-8
C++
false
false
15,070
cpp
#include <cmath> // we only include RcppArmadillo.h which pulls Rcpp.h in for us #include "RcppArmadillo.h" // via the depends attribute we tell Rcpp to create hooks for // RcppArmadillo so that the build process will know what to do // // [[Rcpp::depends(RcppArmadillo)]] #define TOL 1.0e-6 #define SMALL 1.0e-15 #define MAXIT 1.0e+3 ////' Soft-Threshold operator on a r-dim vector with the first element unpenalized ////' ////' @param beta An r-dim vector. ////' @param lam tuning paramter, i.e., the amount of penalization. ////' @param r row index, i.e., the length of beta. // [[Rcpp::export]] void soft_threshold(const arma::vec& beta, const double lam, const int r, arma::vec& result){ // the last element is the same as beta(unpenalized) result(r - 1) = beta(r - 1); // This performs the soft-threshold for beta // for the first r - 1 elements for (int l = 0; l < (r - 1); l++){ // element-wise soft-threshold if (beta(l) > lam) result(l) = beta(l) - lam; else if (beta(l) < -lam) result(l) = beta(l) + lam; else result(l) = 0; } } ////' Close-form update of beta in Algorithm 1 ////' ////' This function solves (6) in the paper with a closed form solution ////' ////' @param S An r-by-r submatrix of sample covariance matrix. ////' @param S_inv inverse of (2S_{-r,-r} + rho I) ////' @param r row index ////' @param rho parameter rho used in ADMM ////' @param u dual variable in ADMM ////' @param gamma priaml variable in ADMM // [[Rcpp::export]] void close_update(const arma::mat& S, const arma::mat& S_inv, const int r, const double rho, const arma::vec& u, const arma::vec& gamma, arma::vec& res){ // This performs the closed updated for beta // see Section 3 in the paper arma::vec vec_tmp = S_inv * S.col(r-1).head(r-1); double A = 4 * dot(vec_tmp, S.col(r-1).head(r-1)) - 2 * S(r-1, r-1) - rho; double B = 2 * dot(vec_tmp, u.head(r-1) - rho * gamma.head(r-1)) - u(r-1) + rho * gamma(r-1); // beta_r res(r-1) = (-std::sqrt(B * B - 8 * A) - B) / (2 * A); // beta_[-r] res.head(r-1) = -2 * res(r-1) * vec_tmp - S_inv * (u.head(r-1) - rho * gamma.head(r-1)); } // [[Rcpp::export]] void inverse_update(const arma::mat& S, double rho, arma::mat& S_inv){ S_inv = 2*S; S_inv.diag() += rho; S_inv = inv_sympd(S_inv); } ////' Evaluate the proximal operator of the hierarchical group lasso with simple weights ////' ////' This function solves (7) in the paper for unweighted version(w = 1) ////' by solving its dual by performing Newton's method on at most ////' r-1 univariate functions. ////' See Algorithm 2 in the paper ////' ////' @param y An r-dimensional vector. ////' @param tau lambda/rho // [[Rcpp::export]] void elliproj_u(const arma::vec& y, const double tau, arma::vec& pp){ // This function performs the ellipsoid projection // of the unweighted estimator, which is very easy // See algorithm 2 in the paper int r = y.n_elem; // pp is the z vector in the paper pp = y; double tmpnorm = 0; for(int l = 0; l < (r - 1); l++){ tmpnorm = arma::norm(pp.head(l + 1), 2); if(tmpnorm <= tau) pp.head(l+1).zeros(); else pp.head(l+1) = (1 - tau / tmpnorm) * pp.head(l+1); } } // [[Rcpp::export]] double rootfind(const arma::vec& pp, const arma::vec& ww, double tau, int l){ // perform rooting finding // using a combinationg of Newton's method and bisection // see Numerical Recipes (3rd Edition, 2007) pp.460-461 double xup = std::sqrt(arma::accu(arma::square(ww % pp.head(l+1)))) / tau; double xlo = ((xup-ww(l) * ww(l)) > 0.0 ? (xup-ww(l) * ww(l)) : 0.0); double fh = 1 - tau / std::sqrt(arma::accu(arma::square(pp.head(l+1) / (ww + xup / ww)))); double fl = 1 - tau / std::sqrt(arma::accu(arma::square(pp.head(l+1) / (ww + xlo / ww)))); if(std::fabs(fh) <= SMALL) return xup; if(std::fabs(fl) <= SMALL) return xlo; double xh, xl; if (fl < 0.0) { xl = xlo; xh = xup; } else { xh = xlo; xl = xup; } double rts = 0.5 * (xlo + xup); double dxold = std::fabs(xup - xlo); double dx = dxold; double f = 1 - tau / std::sqrt(arma::accu(arma::square(pp.head(l+1) / (ww + rts / ww)))); double df = -tau * arma::accu(arma::square(ww % pp.head(l+1)) / arma::pow(arma::square(ww)+rts, 3)) / std::pow(arma::accu(arma::square(pp.head(l+1) / (ww + rts / ww))), 1.5); for (int j = 0; j < MAXIT; j++) { // if Newton's out of range // or if not decreasing fast enough if ((((rts - xh) * df - f) * ((rts - xl) * df - f) > 0.0) || (std::fabs(2.0 * f) > std::fabs(dxold * df))) { // bisection dxold = dx; dx = 0.5 * (xh - xl); rts = xl + dx; if (xl == rts) return rts; } else { // Newton dxold = dx; dx = f / df; double temp = rts; rts -= dx; if (temp == rts) return rts; } // convergence criterion if (std::fabs(dx) < TOL) return rts; // if not converged, next iteration // new function and direvative function values evaluations f = 1 - tau / std::sqrt(arma::accu(arma::square(pp.head(l+1) / (ww + rts / ww)))); df = -tau * arma::accu(arma::square(ww % pp.head(l+1))/pow(arma::square(ww) + rts, 3))/std::pow(arma::accu(arma::square(pp.head(l+1) / (ww + rts / ww))), 1.5); if (f < 0.0) xl = rts; else xh = rts; } Rcpp::Rcout << "root finding fails to converge" << std::endl; return rts; } ////' Evaluate the proximal operator of the hierarchical group lasso with general weights ////' ////' This function solves (7) in the paper for general weight w ////' by solving its dual by performing Newton's method on at most ////' r-1 univariate functions. ////' See Algorithm 1 and Theorem 1 in the online supplemenatry. ////' ////' @param y An r-dimensional vector. ////' @param tau lambda/rho // [[Rcpp::export]] void elliproj_w(const arma::vec& y, const double tau, arma::vec& pp){ // This function performs the ellipsoid projection // See supplementary material int r = y.n_elem; arma::vec nu(r-1); nu.zeros(); // pp is the z vector in the paper pp = y; for(int l = 0; l < (r - 1); l++){ // ww[m] = w_{lm} arma::vec ww = arma::linspace<arma::vec>(l+1, 1, l+1); ww = 1 / arma::square(ww); // check if it lies in the ellipsoid if (arma::accu(arma::square(pp.head(l + 1) / ww)) <= tau * tau){ nu(l) = 0; pp.head(l + 1).zeros(); } else{ // project onto the elliposid nu(l) = rootfind(pp, ww, tau, l); pp.head(l + 1) = pp.head(l + 1) * nu(l) / ( arma::square(ww) + nu(l) ); } } } ////' Compute one row of varband estimate with hierarchical group lasso penalty for a fixed tuning parameter ////' ////' This function solve the following r-th row estimation problem \deqn{min_{beta_r>0} -2 log beta_r + 1/n ||X beta||^2 + lambda P(beta)} ////' using an ADMM algorithm with changing rho. ////' ////' See algorithm 1 in the paper. ////' ////' @param S An r-by-r submatrix of sample covariance matrix. ////' @param init_row The initial estimate of the row. ////' @param lambda Non-negative tuning parameter. Controls sparsity level. ////' @param w Logical. Should we use weighted version of the penalty or not? If \code{TRUE}, we use general weight. If \code{FALSE}, use unweighted penalty. Default is \code{FALSE}. ////' @param tol Tolerance for convergence. ////' @param itermax Maximum number of iterations of ADMM to perform. // [[Rcpp::export]] arma::vec rowadmm(const arma::mat& S, const arma::vec& init_row, const double lambda, const bool w = false, double tol = 1.0e-4, const int itermax = 1e+6){ // This function solve the following row estimation problem // \min_{\beta_r>0} -2 log \beta_r + 1/n ||X\beta||^2 // + \lambda P(\beta) // using an ADMM algorithm with changing rho int r = S.n_cols; // could use a lower tolerance for unweighted version if (!w) tol = 1.0e-8; // Default parameter in ADMM double tolabs = tol; double tolrel = tol; // Changing rho double rho = 2.0; double mu = 10.0; double inc = 2.0; double dec = 2.0; double pres = 0.0; double dres = 0.0; double peps = 0.0; double deps = 0.0; // Initialize the result arma::vec beta(init_row); arma::vec gamma(init_row); arma::vec beta_new(r); arma::vec gamma_new(r); // dual variable arma::vec u(r); u.zeros(); arma::mat S_inv(r-1, r-1); inverse_update(S.submat(0, 0, r-2, r-2), rho, S_inv); for(int i = 0; i < itermax; i++) { // Primal&Dual Updates close_update(S, S_inv, r, rho, u, gamma, beta_new); if (w) elliproj_w(beta_new + u/rho, lambda/rho, gamma_new); else elliproj_u(beta_new + u/rho, lambda/rho, gamma_new); u = u + rho*(beta_new - gamma_new); // check convergence See pp 22 Boyd(2011) // primal residual pres = norm(beta_new - gamma_new, 2); // dual residual dres = rho * norm(gamma_new - gamma, 2); // primal tolerance peps = tolabs * std::sqrt(r) + tolrel * std::max(arma::norm(beta_new, 2), arma::norm(gamma_new, 2)); // dual tolerance deps = tolabs * std::sqrt(r) + tolrel * arma::norm(u, 2); if(pres <= peps && dres <= deps) return gamma_new; else{ // if not, update estimates and rho beta = beta_new; gamma = gamma_new; // Update rho if needed and corresponding S_inv if(pres > mu * dres){ rho *= inc; inverse_update(S.submat(0, 0, r-2, r-2), rho, S_inv); } else if(dres > mu * pres){ rho /= dec; inverse_update(S.submat(0, 0, r-2, r-2), rho, S_inv); } } } Rcpp::Rcout << "ADMM fails to converge" << std::endl; return gamma_new; } ////' Compute one row of varband estimate with l1 penalty for a fixed tuning parameter ////' ////'This function solve the following r-th row estimation problem \deqn{min_{beta_r>0} -2 log beta_r + 1/n ||X beta||^2 + lambda |beta|_1} ////' using an ADMM algorithm with changing rho. ////' ////' See algorithm 1 in the paper. ////' ////' @param S An r-by-r submatrix of sample covariance matrix. ////' @param init_row The initial estimate of the row. ////' @param lambda Non-negative tuning parameter. Controls sparsity level. ////' @param tol Tolerance for convergence. ////' @param itermax Maximum number of iterations of ADMM to perform. // [[Rcpp::export]] arma::vec rowadmm_lasso(const arma::mat& S, const arma::vec& init_row, const double lambda, double tol = 1.0e-4, const int itermax = 1e+6){ // This function solve the following row estimation problem // \min_{\beta_r>0} -2 log \beta_r + 1/n ||X\beta||^2 // + \lambda |\beta|_1 // using an ADMM algorithm with changing rho int r = S.n_cols; // could use a lower tolerance for unweighted version // Default parameter in ADMM double tolabs = tol; double tolrel = tol; // Changing rho double rho = 2.0; double mu = 10.0; double inc = 2.0; double dec = 2.0; double pres = 0.0; double dres = 0.0; double peps = 0.0; double deps = 0.0; // Initialize the result arma::vec beta(init_row); arma::vec gamma(init_row); arma::vec beta_new(r); arma::vec gamma_new(r); // dual variable arma::vec u(r); u.zeros(); arma::mat S_inv(r-1, r-1); inverse_update(S.submat(0, 0, r-2, r-2), rho, S_inv); for(int i = 0; i < itermax; i++) { // Primal&Dual Updates close_update(S, S_inv, r, rho, u, gamma, beta_new); soft_threshold(beta_new + u/rho, lambda/rho, r, gamma_new); u = u + rho*(beta_new - gamma_new); // check convergence See pp 22 Boyd(2011) // primal residual pres = norm(beta_new - gamma_new, 2); // dual residual dres = rho * norm(gamma_new - gamma, 2); // primal tolerance peps = tolabs * std::sqrt(r) + tolrel * std::max(arma::norm(beta_new, 2), arma::norm(gamma_new, 2)); // dual tolerance deps = tolabs * std::sqrt(r) + tolrel * arma::norm(u, 2); if(pres <= peps && dres <= deps) return gamma_new; else{ // if not, update estimates and rho beta = beta_new; gamma = gamma_new; // Update rho if needed and corresponding S_inv if(pres > mu * dres){ rho *= inc; inverse_update(S.submat(0, 0, r-2, r-2), rho, S_inv); } else if(dres > mu * pres){ rho /= dec; inverse_update(S.submat(0, 0, r-2, r-2), rho, S_inv); } } } Rcpp::Rcout << "ADMM fails to converge" << std::endl; return gamma_new; } //' Compute the varband estimate for a fixed tuning parameter value with different penalty options. //' //' Solves the main optimization problem in Yu & Bien (2016): //' \deqn{min_L -2 \sum_{r=1}^p L_{rr} + tr(SLL^T) + lam * \sum_{r=2}^p P_r(L_{r.})}{min_L -2 sum_{r=1}^p L_{rr} + tr(SLL^T) + lam * sum_{r=2}^p P_r(L_{r.})} //' where \deqn{P_r(L_{r.}) = \sum_{\ell = 2}^{r-1} \left(\sum_{m=1}^\ell w_{\ell m}^2 L_{rm}^2\right)^{1/2}}{P_r(L_r.) = sum_{l=2}^{r-1} (sum_m=1^l w^2_lm L^2_rm)^{1/2}} //' or \deqn{P_r(L_{r.}) = \sum_{\ell = 1}^{r-1} |L_{r\ell}|} //' //' The function decomposes into p independent row problems, //' each of which is solved by an ADMM algorithm. //' see paper for more explanation. //' @param S The sample covariance matrix //' @param lambda Non-negative tuning parameter. Controls sparsity level. //' @param w Logical. Should we use weighted version of the penalty or not? If \code{TRUE}, we use general weight. If \code{FALSE}, use unweighted penalty. Default is \code{FALSE}. //' @param lasso Logical. Should we use l1 penalty instead of hierarchical group lasso penalty? Note that by using l1 penalty, we lose the banded structure in the resulting estimate. Default is \code{FALSE}. //' @param init Initial estimate of L. Default is a closed-form diagonal estimate of L. //' @return Returns the variable banding estimate of L, where L^TL = Omega. //' //' @examples //' set.seed(123) //' n <- 50 //' true <- varband_gen(p = 50, block = 5) //' x <- sample_gen(L = true, n = n) //' S <- crossprod(scale(x, center = TRUE, scale = FALSE)) / n //' init <- diag(1/sqrt(diag(S))) //' # unweighted estimate //' L_unweighted <- varband(S, lambda = 0.1, init, w = FALSE) //' # weighted estimate //' L_weighted <- varband(S, lambda = 0.1, init, w = TRUE) //' # lasso estimate //' L_lasso <- varband(S, lambda = 0.1, init, w = TRUE, lasso = TRUE) //' @seealso \code{\link{varband_path}} \code{\link{varband_cv}} //' //' @export // [[Rcpp::export]] arma::mat varband(arma::mat S, double lambda, arma::mat init, bool w = false, bool lasso = false){ int p = S.n_rows; arma::mat L(p, p); L.zeros(); L(0, 0) = 1/(std::sqrt(S(0, 0))); init = init.t(); if (lasso){ for (int r = 1; r < p; r++) L.col(r).head(r+1) = rowadmm_lasso(S.submat(0, 0, r, r), init.col(r).head(r+1), lambda); } else{ for (int r = 1; r < p; r++) L.col(r).head(r+1) = rowadmm(S.submat(0, 0, r, r), init.col(r).head(r+1), lambda, w); } return L.t(); }
[ "akhilakollasrinu424jf@gmail.com" ]
akhilakollasrinu424jf@gmail.com
7902d395ffbc69b1450153a76c08c8e07e7cbf49
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5662291475300352_0/C++/Kutso/C.cpp
5711eeab8e43b6808e4f6a602d479dd058341379
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,128
cpp
#include <iostream> #include <algorithm> #include <set> #include <map> #include <queue> #include <string> #include <vector> #include <cmath> #include <cstdio> #include <cstring> using namespace std; const int NMAX = 10010; int main() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); int t; cin >> t; for (int test = 1; test <= t; test++) { int n; cin >> n; vector <pair <int, int> > hikers; for (int i = 0; i < n; i++) { int start, num, time; cin >> start >> num >> time; for (int j = 0; j < num; j++) hikers.push_back(make_pair(start, time++)); } //0 int ans = 1; double time0 = ((360 - hikers[0].first) / 360.) * hikers[0].second; double time1 = ((360 - hikers[1].first) / 360.) * hikers[1].second; int cnt = 0; double diff = fabs(time0 - time1), times = 0.; if (time0 < time1) { times = diff / hikers[0].second; } else times = diff / hikers[1].second; if (times < 1) ans = 0; if (hikers.size() > 2) ans = -1; cout << "Case #" << test << ": " << ans << endl; } return 0; }
[ "eewestman@gmail.com" ]
eewestman@gmail.com
0df98c79e3dad9ca28b0985d7d34eb6e10440a97
32d554b66d3da0dc0df09739422236523b0dde2e
/src/ShapeTanimoto.H
8979b35a80fc8c9c9cc8faa75be980278a38ffa7
[ "BSD-3-Clause" ]
permissive
OpenEye-Contrib/Triphic
b916643e784edb966c122cc384d4695722b09cb6
7db4bbe3ebff27e222a3f3aacbf625f2f137ec20
refs/heads/master
2021-01-22T11:41:55.855524
2016-02-22T16:36:19
2016-02-22T16:36:19
35,508,854
11
0
null
null
null
null
UTF-8
C++
false
false
1,353
h
// // file ShapeTanimoto.H // David Cosgrove // AstraZeneca // 15th September 2009 // // Computes the approximate shape tanimoto coefficient for the 2 OEMolBases // passed in. Uses 1st order intersections only, so not a reliable way // of calculating volumes, but good enough for the tanimoto according to // JAG. It's how ROCS does it, or so he told me. #ifndef DAC_SHAPE_TANIMOTO #define DAC_SHAPE_TANIMOTO #include <vector> // ****************************************************************************** namespace OEChem { class OEMolBase; } namespace DACLIB { class ShapeTanimoto { public : ShapeTanimoto( OEChem::OEMolBase &mol1 , OEChem::OEMolBase &mol2 ); double shape_tanimoto() { return shape_tani_; } private : OEChem::OEMolBase &mol1_ , &mol2_; const double p_; const double lambda_; std::vector<double> mol1_atom_alphas_; std::vector<double> mol2_atom_alphas_; double mol1_vs_mol1_ , mol2_vs_mol2_ , mol1_vs_mol2_; double shape_tani_; void calculate_shape_tani(); void assign_alphas( OEChem::OEMolBase &mol , std::vector<double> &alphas ) const; double calc_gaussian_overlap( OEChem::OEMolBase &mol1 , OEChem::OEMolBase &mol2 , const std::vector<double> &alpha1s , const std::vector<double> &alpha2s ) const; }; } // EO namespace DACLIB #endif
[ "haigh@eyesopen.com" ]
haigh@eyesopen.com
d486524e59b8c215c577382db3b2c273023b2145
2cf838b54b556987cfc49f42935f8aa7563ea1f4
/aws-cpp-sdk-rds/include/aws/rds/model/CreateCustomAvailabilityZoneResult.h
744a9690e8ab992c50ff5ef93b7293a990f208b1
[ "MIT", "Apache-2.0", "JSON" ]
permissive
QPC-database/aws-sdk-cpp
d11e9f0ff6958c64e793c87a49f1e034813dac32
9f83105f7e07fe04380232981ab073c247d6fc85
refs/heads/main
2023-06-14T17:41:04.817304
2021-07-09T20:28:20
2021-07-09T20:28:20
384,714,703
1
0
Apache-2.0
2021-07-10T14:16:41
2021-07-10T14:16:41
null
UTF-8
C++
false
false
2,344
h
๏ปฟ/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/rds/RDS_EXPORTS.h> #include <aws/rds/model/CustomAvailabilityZone.h> #include <aws/rds/model/ResponseMetadata.h> #include <utility> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Xml { class XmlDocument; } // namespace Xml } // namespace Utils namespace RDS { namespace Model { class AWS_RDS_API CreateCustomAvailabilityZoneResult { public: CreateCustomAvailabilityZoneResult(); CreateCustomAvailabilityZoneResult(const Aws::AmazonWebServiceResult<Aws::Utils::Xml::XmlDocument>& result); CreateCustomAvailabilityZoneResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Xml::XmlDocument>& result); inline const CustomAvailabilityZone& GetCustomAvailabilityZone() const{ return m_customAvailabilityZone; } inline void SetCustomAvailabilityZone(const CustomAvailabilityZone& value) { m_customAvailabilityZone = value; } inline void SetCustomAvailabilityZone(CustomAvailabilityZone&& value) { m_customAvailabilityZone = std::move(value); } inline CreateCustomAvailabilityZoneResult& WithCustomAvailabilityZone(const CustomAvailabilityZone& value) { SetCustomAvailabilityZone(value); return *this;} inline CreateCustomAvailabilityZoneResult& WithCustomAvailabilityZone(CustomAvailabilityZone&& value) { SetCustomAvailabilityZone(std::move(value)); return *this;} inline const ResponseMetadata& GetResponseMetadata() const{ return m_responseMetadata; } inline void SetResponseMetadata(const ResponseMetadata& value) { m_responseMetadata = value; } inline void SetResponseMetadata(ResponseMetadata&& value) { m_responseMetadata = std::move(value); } inline CreateCustomAvailabilityZoneResult& WithResponseMetadata(const ResponseMetadata& value) { SetResponseMetadata(value); return *this;} inline CreateCustomAvailabilityZoneResult& WithResponseMetadata(ResponseMetadata&& value) { SetResponseMetadata(std::move(value)); return *this;} private: CustomAvailabilityZone m_customAvailabilityZone; ResponseMetadata m_responseMetadata; }; } // namespace Model } // namespace RDS } // namespace Aws
[ "aws-sdk-cpp-automation@github.com" ]
aws-sdk-cpp-automation@github.com
a8c51f2dfb549953b1c6d8204e6d2433375e775b
f679998d61e7f03c25e5cee32b14e4a3ee847510
/commonhelper.h
4a86f18ac6df1d777f311beec91468405c010b96
[]
no_license
xian0gang/xiaodan
4fe822577fe5bf4e076d0ad39bc52dd25ddf1f30
9cf177685a2fc19c96a9cd8436473db34419811b
refs/heads/master
2020-04-17T07:30:36.904560
2020-01-02T10:57:56
2020-01-02T10:57:56
166,372,883
1
0
null
null
null
null
UTF-8
C++
false
false
369
h
#ifndef COMMONHELPER_H #define COMMONHELPER_H #include <QFile> #include <QApplication> class CommonHelper { public: CommonHelper(); static void setStyle(const QString &style) { QFile qss(style); qss.open(QFile::ReadOnly); qApp->setStyleSheet(qss.readAll()); qss.close(); } }; #endif // COMMONHELPER_H
[ "xian0gang@163.com" ]
xian0gang@163.com
d42a6df0f44af402bdef7c55f2e0eeb0854303e8
a1cb6411fee13060d2e44d35de79945d49b3134a
/unit_tests/verify_seqs.hh
6825e26ab8f94d1bfbbea10bfe1981bfa02f1723
[ "MIT" ]
permissive
bruce2008github/PEGTL
72d4981df0092c10133222240ae122b899aa4c1f
2bbdde0f99e11fbce55607d4133bd4110b810428
refs/heads/master
2021-01-15T20:08:22.374235
2015-02-27T12:45:22
2015-02-27T12:45:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,991
hh
// Copyright (c) 2014-2015 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/ColinH/PEGTL/ #ifndef PEGTL_UNIT_TESTS_VERIFY_SEQS_HH #define PEGTL_UNIT_TESTS_VERIFY_SEQS_HH #include <pegtl.hh> #include "verify_rule.hh" #include "verify_analyze.hh" namespace pegtl { template< template< typename ... > class S > void verify_seqs( const result_type failure = result_type::LOCAL_FAILURE ) { verify_analyze< S< any > >( __LINE__, __FILE__, true ); verify_analyze< S< eof > >( __LINE__, __FILE__, false ); verify_analyze< S< any, eof > >( __LINE__, __FILE__, true ); verify_analyze< S< opt< any >, eof > >( __LINE__, __FILE__, false ); verify_rule< S< eof > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); verify_rule< S< eof > >( __LINE__, __FILE__, "a", failure, 1 ); verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "", failure, 0 ); verify_rule< S< one< 'c' >, eof > >( __LINE__, __FILE__, "", failure, 0 ); verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "c", result_type::SUCCESS, 0 ); verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "a", failure, 1 ); verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "b", failure, 1 ); verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "cc", result_type::SUCCESS, 1 ); verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "bc", failure, 2 ); verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", failure, 0 ); verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", failure, 1 ); verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", failure, 1 ); verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "c", failure, 1 ); verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::SUCCESS, 1 ); verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 1 ); verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 2 ); verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", failure, 0 ); verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "a", failure, 1 ); verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ab", failure, 2 ); verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 0 ); verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' >, eof > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 0 ); verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abcd", result_type::SUCCESS, 1 ); } } // pegtl #endif
[ "colinh-github-06134@icemx.net" ]
colinh-github-06134@icemx.net
9b622f383e2b65dc005286e0afbc0fce92f8c58d
473b54b77a402c261ee44fe3ea1878ea66d4a34a
/src/CSix.cpp
68e00703603dbffde52a9531cccf171f1cc6ee76
[]
no_license
baoleibai/CppExecises
7c62a350f674f16e4059bfa2a55a7c3946f68ec6
4bfa7baf902106e9bdccd763c1a2a9a4d7bf0d52
refs/heads/master
2021-01-15T14:29:14.770754
2014-03-10T09:59:15
2014-03-10T09:59:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,077
cpp
/* * CSix.cpp * * Created on: Dec 25, 2013 * Author: b576 */ #include "include/CSix.h" CSix::CSix() { } CSix::~CSix() { } void CSix::show() { program9(); program8(); program6(); program5(); program4(); program3(); program2(); program1(); exes(); readFromFileIO(); writeToFileIO(); practise(); } /* *Read contributors from a given file. first line is number of contributors. */ void CSix::program9() { char filename[50] = "contributors.txt"; ifstream readFile; readFile.open(filename); if (!readFile.is_open()) { cout << "Failed to open " << filename << ". quit the program." << endl; return; } int i = 0; char chars[50]; readFile.getline(chars, STRSIZE); cout << chars << endl; int number = atoi(chars); //stdlib.h is C-style method. Contributors *cons = new Contributors[number]; while (readFile.good()) { readFile.getline(cons[i].contributor, STRSIZE); readFile.getline(chars, STRSIZE); cons[i].amount = atoi(chars); i++; } if (readFile.fail()) { cout << "Reach EOF" << endl; } else if (readFile.bad()) { cout << "Something Unexpected" << endl; } else { cout << "Stopped for un-known reasons" << endl; } for (int x = 0; x < number; x++) { cout << " Countributor: " << cons[x].contributor << " " << cons[x].amount << endl; } readFile.close(); } /* * Enter a filename, read contents of the file and output * number of characters and empty spaces. */ void CSix::program8() { char filename[50]; cout<<"Please enter the filename that you wants to read: "; cin>>filename; ifstream fin; fin.open(filename); if(!fin.is_open()) { cout << "Could not open file " << filename << endl; cout << "Program terminating.\n"; return; } int charCount = 0, spaceCount = 0; char ch; ch = fin.get(); while(fin.good()){ if(isspace(ch)) spaceCount++; else charCount++; ch = fin.get(); } if(fin.fail()){ cout<<"Reached EOF."<<endl; } else if(fin.bad()) { cout<<"Something unexpected."<<endl; } else { cout << "Input terminated for unknown reason" << endl; } cout<<"Number of Character count is "<<charCount<<endl; cout<<"Number of Space count is "<<spaceCount<<endl; fin.close(); } /* * Enter the number of contributors and their name, amount,. * if donate >=10000, output as Grand donation. * else output as Headed patrons. */ void CSix::program6() { int contributorsNo = 0; do { cout << "Please enter the number of contributors: "; if (!(cin >> contributorsNo)) { cin.clear(); cin.get(); cout << "Invalid Input, Try Again." << endl; continue; } else { break; } } while (true); Contributors *lContributors = new Contributors[contributorsNo]; int NoGrand = 0, NoHeaded = 0; for (int i = 0; i < contributorsNo; i++) { cout << "The " << i << " contributor's name:"; cin >> lContributors[i].contributor; cout << "The contribution amount: "; cin >> lContributors[i].amount; if (lContributors[i].amount >= 10000) NoGrand++; else NoHeaded++; } cout << "The Grand donations:" << endl; if (NoGrand == 0) { cout << "none." << endl; } else { for (int i = 0; i < contributorsNo; i++) { if (lContributors[i].amount >= 10000) { cout << lContributors[i].contributor << " " << lContributors[i].amount << endl; } } } cout << "The Headed donations:" << endl; if (NoHeaded == 0) { cout << "none." << endl; } else { for (int i = 0; i < contributorsNo; i++) { if (lContributors[i].amount < 10000) { cout << lContributors[i].contributor << " " << lContributors[i].amount << endl; } } } } /* * Calculate the tax amount of annual income. */ void CSix::program5() { bool quit = false; const int salaryLevels = 4; double tax; double taxLevel[salaryLevels] = { 5000, 10000, 20000, 35000 }; double taxRate[salaryLevels] = { 0, 0.1, 0.15, 0.2 }; cout << "First 5,000 tvarps: 0% tax" << endl; cout << "Next 10,000 tvarps: 10% tax" << endl; cout << "Next 20,000 tvarps: 15% tax" << endl; cout << "Tvarps after 35,000: 20% tax" << endl; do { cout<< "Please enter your anual incout(enter 'q'/Negative numbers to quit): "; double income; if (!(cin >> income)) { cin.clear(); cin.get(); cout << "Quit! Bye" << endl; quit = true; } if (income < 0.0) { cin.get(); cout << "Quit! Bye" << endl; quit = true; } double temp = income; for (int i = 0 ; i < salaryLevels; i++) { if(temp - taxLevel[i] > 0) { tax+= taxLevel[i] * taxRate[i]; temp -= taxLevel[i]; } else { tax+= temp*taxRate[i]; break; } } cout << "The tax for annual income " << income << " is " << tax << endl; } while (!quit); } /* * Display a menu and select options to display info from an struct array. */ void CSix::program4() { Bop bops[3] = { { "Baolei Bai", "Engineer", "Tim White", 2 }, { "Xiying Cao", "A Engineer", "XYC", 1 }, { "Mu Li", "B Engineer", "Gary Li", 0 }, }; bool quite = false; do { cout << "Please enter one of the following choices(enter q to quite): " << endl; cout << "a) Display by Name b) Display by Title" << endl; cout << "c) Display by BOP Name d) Display by Preference" << endl; cout << " q) quit" << endl; cout << "Please enter your choice: "; char ch; if (!(ch = cin.get())) { cout << "Invalid input, try again." << endl; cin.clear(); cin.get(); //get the remaining "return" char left in the input queue. continue; } cout << endl; switch (ch) { case 'a': for (int i = 0; i < 3; i++) { cout << " " << bops[i].fullname << endl; } break; case 'b': for (int i = 0; i < 3; i++) { cout << " " << bops[i].title << endl; } break; case 'c': for (int i = 0; i < 3; i++) { cout << " " << bops[i].bopname << endl; } break; case 'd': for (int i = 0; i < 3; i++) { if (bops[i].preference == 0) //display full name cout << " " << bops[i].fullname << endl; else if (bops[i].preference == 1) cout << " " << bops[i].title << endl; else if (bops[i].preference == 2) cout << " " << bops[i].bopname << endl; } break; case 'q': cout << "quite the menu" << endl; quite = true; break; default: cout << ch << " is not an option." << endl; break; } } while (!quite); } /* * Create an menu and select option to output info with the help * of switch */ void CSix::program3() { bool quite = false; do { cout << "Please enter one of the following choices(enter q to quite): " << endl; cout << "c) carnivore p) pianist" << endl; cout << "t) tree g) game" << endl; cout << "Please enter a c, p, t, or g: "; char ch; if (!(ch = cin.get())) { cout << "Invalid input, try again." << endl; cin.clear(); cin.get(); //get the remaining "return" char left in the input queue. continue; } cout << endl; switch (ch) { case 'c': cout << "carnivore" << endl; break; case 'p': cout << "pianist" << endl; break; case 't': cout << "tree" << endl; break; case 'g': cout << "game" << endl; break; case 'q': cout << "quite the menu" << endl; quite = true; break; default: cout << ch << " is not an option." << endl; break; } } while (!quite); } /* * Enter donation and output its average and how many donations * are higher than the average. */ void CSix::program2() { int max = 10; double *donationvalue = new double[max]; double average, total; int i = 0; for (int x = 0; x < max; x++) { cout << "Please enter your donation value: "; if (!(cin >> donationvalue[x])) { //The point of this exercise is here cin.clear(); //reset the error flag. cin.get(); //get what is left in input queue. cout << "Input terminated. Entered an invalid value." << endl; break; } total += donationvalue[x]; i++; } if (i > 0) { average = total / i; cout << "The average value of " << i << " input is " << average << endl; int larger; for (int y = 0; y < i; y++) { if (donationvalue[y] > average) larger++; } cout << "There are " << larger << " values in donation are larger than average value " << average << endl; } } /* * Read input char, * if lower case alphabet -> upper case alphabet. * if upper case alphabet -> lower case alphabet. * if @ -> quit * ignore digits. * output the rest of the chars. */ void CSix::program1() { char ch; while ((ch = cin.get())) { if (ch <= 122 && ch >= 97) { ch = ch - 32; cout << ch; } else if (ch <= 90 && ch >= 65) { ch = ch + 32; cout << ch; } else if (ch == '@') break; else if (ch <= 57 && ch >= 48) { continue; } else { cout << ch; } } } void CSix::exes() { char ch; int ct1, ct2; ct1 = ct2 = 0; while ((ch = cin.get()) != '$') { cout << ch; ct1++; if (ch = '$') ct2++; cout << ch; } cout << "ct1 = " << ct1 << ", ct2 = " << ct2 << "\n"; int weight = 0; if (weight >= 115 && weight < 125) { } if (ch == 'q' || ch == 'Q') { } int x; if ((x % 2) == 0 && x != 26) { } if ((x % 2) == 0 && (x % 26) != 0) { } } bool CSix::readFromFileIO() { char filename[50]; ifstream readFile; cin.clear(); cin.get(); cout << "Enter the name of the data file: "; cin.getline(filename, 50); readFile.open(filename); if (!readFile.is_open()) { cout << "Could not open file " << filename << endl; cout << "Program terminating.\n"; return false; } char content[100]; readFile >> content; while (readFile.good()) { cout << content <<endl; readFile >> content; } if (readFile.eof()) { cout << " Reached at the end of file." << endl; } else if (readFile.fail()) { cout << "Input terminated by data mismatch" << endl; } else { cout << "Input terminated for unknown reason" << endl; } } void CSix::writeToFileIO() { char automobile[50]; int year; double a_price, d_price; ofstream outFile; outFile.open("carinfo.txt"); cout << "Enter the make and model of the car: "; cin.getline(automobile, 50); cout << "Enter the model year: "; cin >> year; cout << "Enter the original asking price: "; cin >> a_price; d_price = 0.913 * a_price; cout << fixed; cout.precision(2); cout.setf(ios_base::showpoint); cout << "make and model: " << automobile << endl; cout << "year: " << year << endl; cout << "price: " << d_price << endl; outFile << fixed; outFile.precision(2); outFile.setf(ios_base::showpoint); outFile << "make and model: " << automobile << endl; outFile << "year: " << year << endl; outFile << "price: " << d_price << endl; outFile.close(); } /* * Enter a given number of scores and output its average */ void CSix::practise() { int golf[Max]; cout << "Please enter your golf score:" << endl; int i; for (int i = 0; i < Max; i++) { cout << "round *" << i + 1 << ": "; while (!(cin >> golf[i])) { cin.clear(); while (cin.get() != '\n') continue; cout << "Please enter a number: "; } } double total = 0.0; for (int i = 0; i < Max; i++) { total += golf[i]; } cout << total / Max << " = average score " << Max << " rounds\n"; }
[ "b576@borqs.com" ]
b576@borqs.com
089c941220c92578ba6bb05582ba29b4cb05b2a1
8dc84558f0058d90dfc4955e905dab1b22d12c08
/third_party/blink/renderer/core/paint/clip_path_clipper_test.cc
88530ea7bda330cbfac3a49932887c2e1df76b3b
[ "LGPL-2.0-only", "BSD-2-Clause", "LGPL-2.1-only", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "LGPL-2.0-or-later", "GPL-1.0-or-later", "MIT", "Apache-2.0" ]
permissive
meniossin/src
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
44f73f7e76119e5ab415d4593ac66485e65d700a
refs/heads/master
2022-12-16T20:17:03.747113
2020-09-03T10:43:12
2020-09-03T10:43:12
263,710,168
1
0
BSD-3-Clause
2020-05-13T18:20:09
2020-05-13T18:20:08
null
UTF-8
C++
false
false
970
cc
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "third_party/blink/renderer/core/paint/clip_path_clipper.h" #include <gtest/gtest.h> #include "third_party/blink/renderer/core/testing/core_unit_test_helper.h" namespace blink { namespace { using ClipPathClipperTest = RenderingTest; TEST_F(ClipPathClipperTest, ClipPathBoundingBoxClamped) { SetBodyInnerHTML(R"HTML( <!DOCTYPE html> <div id="e" style="width:1000px; height:1000px; will-change:transform; clip-path:circle(1000000000%);"> </div> )HTML"); auto& object = *GetLayoutObjectByElementId("e"); base::Optional<FloatRect> bounding_box = ClipPathClipper::LocalClipPathBoundingBox(object); ASSERT_TRUE(bounding_box.has_value()); EXPECT_EQ(LayoutRect::InfiniteIntRect(), *bounding_box); } } // unnamed namespace } // namespace blink
[ "arnaud@geometry.ee" ]
arnaud@geometry.ee
e0a2afcb919433bb677c43bc745491e14666954d
bf5bbd1248cf94942cbb622c6e9383a0ceca3921
/BulletSwift/bullet-2.87/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h
04e648d39c46b69c24733fa3735587fd33d477a3
[]
no_license
yohei-yoshihara/BulletSwift
0ea3bcee10f988f312ea0b6a3f25cd2e2ae255c8
eb6f0a91068769f32959319509fe8f1c5dbace86
refs/heads/master
2021-07-02T09:23:19.798915
2020-09-12T08:07:11
2020-09-12T08:07:11
150,093,949
4
0
null
null
null
null
UTF-8
C++
false
false
2,919
h
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdocumentation" #pragma clang diagnostic ignored "-Wcomma" #pragma clang diagnostic ignored "-Wunused-function" #pragma clang diagnostic ignored "-Wunused-variable" #pragma clang diagnostic ignored "-Wunreachable-code" #pragma clang diagnostic ignored "-Wconditional-uninitialized" /* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef BT_CONTINUOUS_COLLISION_CONVEX_CAST_H #define BT_CONTINUOUS_COLLISION_CONVEX_CAST_H #include "btConvexCast.h" #include "btSimplexSolverInterface.h" class btConvexPenetrationDepthSolver; class btConvexShape; class btStaticPlaneShape; /// btContinuousConvexCollision implements angular and linear time of impact for convex objects. /// Based on Brian Mirtich's Conservative Advancement idea (PhD thesis). /// Algorithm operates in worldspace, in order to keep inbetween motion globally consistent. /// It uses GJK at the moment. Future improvement would use minkowski sum / supporting vertex, merging innerloops class btContinuousConvexCollision : public btConvexCast { btSimplexSolverInterface* m_simplexSolver; btConvexPenetrationDepthSolver* m_penetrationDepthSolver; const btConvexShape* m_convexA; //second object is either a convex or a plane (code sharing) const btConvexShape* m_convexB1; const btStaticPlaneShape* m_planeShape; void computeClosestPoints( const btTransform& transA, const btTransform& transB,struct btPointCollector& pointCollector); public: btContinuousConvexCollision (const btConvexShape* shapeA,const btConvexShape* shapeB ,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); btContinuousConvexCollision(const btConvexShape* shapeA,const btStaticPlaneShape* plane ); virtual bool calcTimeOfImpact( const btTransform& fromA, const btTransform& toA, const btTransform& fromB, const btTransform& toB, CastResult& result); }; #endif //BT_CONTINUOUS_COLLISION_CONVEX_CAST_H #pragma clang diagnostic pop
[ "yohei_yoshihara@cx5software.com" ]
yohei_yoshihara@cx5software.com
7100223ffcd60a7d6900c326680c7ed12df938b7
6901385058db4adecafc671745a3d0a301d09868
/Road_of_Gold/updateGroups.cpp
dec6e3d10ca8fe5cf2519de70bf48690fed40026
[ "MIT" ]
permissive
66588257/Road_of_Gold
91d45cbf8032c4ea015950db1ac8942f4e1b5b2a
848fabebc438db2cfc03eab03098205219e62a17
refs/heads/master
2021-01-21T01:03:21.178456
2017-08-30T08:10:11
2017-08-30T08:10:11
101,868,046
1
0
null
2017-08-30T10:20:42
2017-08-30T10:20:42
null
SHIFT_JIS
C++
false
false
877
cpp
#include"Planet.h" #include"Group.h" #include"Vehicle.h" #include"Wallet.h" #include"Planet.h" double tmr = 0.0; void updateGroups() { tmr += planet.timeSpeed; if (tmr > 0.0) { tmr -= 50.0; //ไธ‹ไฝ1/4ใฎไบ‹ๆฅญ่ฆ‹็›ดใ— for (int i = 0; i < int(vehicles.size() / 10); i++) { int min = 0; Vehicle* target = nullptr; for (auto& v : vehicles) { if (!v.stopFlag && (target == nullptr || min > v.wallet().money)) { target = &v; min = v.wallet().money; } } if (i == 0) Log(L"ๆœ€ไฝŽ:", min); if (target != nullptr) target->stopFlag = true; } int avg = 0; for (auto& v : vehicles) avg += v.wallet().money; Log(L"ๅนณๅ‡:", avg / double(vehicles.size())); for (auto& v : vehicles) { if (v.wallet().money <= 0) v.stopFlag = true; v.wallet().money = 0; v.wallet().expenses = 0; v.wallet().income = 0; } } }
[ "sknjpn@gmail.com" ]
sknjpn@gmail.com
5b7aaa81b5c1c3bf5e56f8a1c1094c9cdd47f4af
9ec67e83200f643f9f55ed90e0b2cae4581ebcb6
/JavaParserLib/JavaSyntaxStatement.cpp
f50ac2dff7ecfc279658dc18cdce37602f63970e
[]
no_license
andrewpaterson/Codaphela.Library
465770eaf2839589fc305660725abb38033f8aa2
2a4722ba0a4b98a304a297a9d74c9b6811fa4ac5
refs/heads/master
2023-05-25T13:01:45.587888
2023-05-14T11:46:36
2023-05-14T11:46:36
3,248,841
1
1
null
null
null
null
UTF-8
C++
false
false
1,651
cpp
#include "JavaSyntaxStatement.h" ////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////// void CJavaSyntaxStatement::Init(CJavaSyntaxTree* pcTree, CJavaSyntax* pcParent) { CJavaSyntax::Init(pcTree, pcParent); } ////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////// void CJavaSyntaxStatement::Kill(void) { CJavaSyntax::Kill(); } ////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////// char* CJavaSyntaxStatement::GetType(void) { return "Statement"; } ////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////// void CJavaSyntaxStatement::TypePrint(CChars* pszDest, int iDepth) { CJavaSyntax::TypePrint(pszDest, iDepth); } ////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////// bool CJavaSyntaxStatement::IsStatement(void) { return true; } ////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////// void CJavaSyntaxStatement::PrintModifiers(CChars* pszDest, CJavaModifiers cModifiers) { cModifiers.Print(pszDest); if (!cModifiers.IsNone()) { pszDest->Append(' '); } }
[ "andrew.ian.paterson@gmail.com" ]
andrew.ian.paterson@gmail.com
3566ee6ec664e96548f79c5aaf237bf4f1227ff9
817e9bf148738af01cd0d88180845b40b7aa069d
/C++/Classes/Structs/main.cpp
454e5f2c77becdf708626c5b788f9b45aa93a481
[]
no_license
mohamed-said-ibrahem/Hacker-Rank-Problems
6d98c7eea8ac0f470faa42885075337a46561e40
b373d261150e4f8b5932b9b43aefdd5fa173be8a
refs/heads/master
2020-03-31T01:16:20.005942
2018-10-17T06:30:22
2018-10-17T06:30:22
151,774,296
0
0
null
null
null
null
UTF-8
C++
false
false
415
cpp
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; struct Student{ int age; string first_name; int standard; string last_name; }; int main() { Student st; cin >> st.age >> st.first_name >> st.last_name >> st.standard; cout << st.age << " " << st.first_name << " " << st.last_name << " " << st.standard; return 0; }
[ "eng.mohamedsaid1996@gmail.com" ]
eng.mohamedsaid1996@gmail.com
65da106f074abfbc0121e80113730e5309e629f9
0d0e78c6262417fb1dff53901c6087b29fe260a0
/ckafka/src/v20190819/model/DescribeConsumerGroupResponse.cpp
c2dfcaf956a3fbfeba08f95a9f317aadddb18ab6
[ "Apache-2.0" ]
permissive
li5ch/tencentcloud-sdk-cpp
ae35ffb0c36773fd28e1b1a58d11755682ade2ee
12ebfd75a399ee2791f6ac1220a79ce8a9faf7c4
refs/heads/master
2022-12-04T15:33:08.729850
2020-07-20T00:52:24
2020-07-20T00:52:24
281,135,686
1
0
Apache-2.0
2020-07-20T14:14:47
2020-07-20T14:14:46
null
UTF-8
C++
false
false
3,192
cpp
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <tencentcloud/ckafka/v20190819/model/DescribeConsumerGroupResponse.h> #include <tencentcloud/core/utils/rapidjson/document.h> #include <tencentcloud/core/utils/rapidjson/writer.h> #include <tencentcloud/core/utils/rapidjson/stringbuffer.h> using TencentCloud::CoreInternalOutcome; using namespace TencentCloud::Ckafka::V20190819::Model; using namespace rapidjson; using namespace std; DescribeConsumerGroupResponse::DescribeConsumerGroupResponse() : m_resultHasBeenSet(false) { } CoreInternalOutcome DescribeConsumerGroupResponse::Deserialize(const string &payload) { Document d; d.Parse(payload.c_str()); if (d.HasParseError() || !d.IsObject()) { return CoreInternalOutcome(Error("response not json format")); } if (!d.HasMember("Response") || !d["Response"].IsObject()) { return CoreInternalOutcome(Error("response `Response` is null or not object")); } Value &rsp = d["Response"]; if (!rsp.HasMember("RequestId") || !rsp["RequestId"].IsString()) { return CoreInternalOutcome(Error("response `Response.RequestId` is null or not string")); } string requestId(rsp["RequestId"].GetString()); SetRequestId(requestId); if (rsp.HasMember("Error")) { if (!rsp["Error"].IsObject() || !rsp["Error"].HasMember("Code") || !rsp["Error"]["Code"].IsString() || !rsp["Error"].HasMember("Message") || !rsp["Error"]["Message"].IsString()) { return CoreInternalOutcome(Error("response `Response.Error` format error").SetRequestId(requestId)); } string errorCode(rsp["Error"]["Code"].GetString()); string errorMsg(rsp["Error"]["Message"].GetString()); return CoreInternalOutcome(Error(errorCode, errorMsg).SetRequestId(requestId)); } if (rsp.HasMember("Result") && !rsp["Result"].IsNull()) { if (!rsp["Result"].IsObject()) { return CoreInternalOutcome(Error("response `Result` is not object type").SetRequestId(requestId)); } CoreInternalOutcome outcome = m_result.Deserialize(rsp["Result"]); if (!outcome.IsSuccess()) { outcome.GetError().SetRequestId(requestId); return outcome; } m_resultHasBeenSet = true; } return CoreInternalOutcome(true); } ConsumerGroupResponse DescribeConsumerGroupResponse::GetResult() const { return m_result; } bool DescribeConsumerGroupResponse::ResultHasBeenSet() const { return m_resultHasBeenSet; }
[ "zhiqiangfan@tencent.com" ]
zhiqiangfan@tencent.com
8e5a4ed7c32325965aa6585f4ec6b3e3c84dc05a
e549363a6c9c445ddb8b13b8ee283d343a4d9e94
/pruebaSFML/src/game/setup/screens.h
70b71191162b380d3d493274204fe83010b57543
[]
no_license
frankvega2010/SFML-Template
4e1bd6283a611bdfc2a496960519a503601927d3
db1da550c10292b2887083cc4fe56a6543e64d10
refs/heads/master
2020-04-06T09:52:20.088069
2018-11-16T15:53:47
2018-11-16T15:53:47
157,360,062
0
0
null
null
null
null
UTF-8
C++
false
false
450
h
#ifndef SCREENS_H #define SCREENS_H namespace Juego { class Screens { private: bool _hasScreenFinished; public: Screens(); ~Screens(); bool getHasScreenFinished(); void setHasScreenFinished(bool hasScreenFinished); virtual void init() = 0; virtual void input() = 0; virtual void update() = 0; virtual void draw() = 0; virtual void deInit() = 0; virtual bool finish() = 0; }; } #endif // SCREENS_H
[ "franco_vega@msn.com" ]
franco_vega@msn.com
809db6d3baec3ebe0758d12b4613f32c3ed08941
ebb02bef87ad5a560cd4c942f656b2a415a3fdeb
/src/material/metal.hpp
c74441f97d1978d5d1b3667f7b0d52bd063fed93
[]
no_license
muramasa8191/raytracer_cpp
731414abde3f2fef4831d12104e9a3fac7dc743c
3249aa84834d8540114dfe2607f3b61d4a436673
refs/heads/master
2020-04-11T04:08:50.607049
2019-01-04T04:24:42
2019-01-04T04:24:42
161,502,605
0
0
null
null
null
null
UTF-8
C++
false
false
773
hpp
#ifndef RAYTRACER_CPP_METAL_HPP_ #define RAYTRACER_CPP_METAL_HPP_ #include <iostream> #include "material.hpp" #include "ray.hpp" #include "utils.hpp" #include "vector.hpp" namespace raytracer { class Metal : public Material { public: Metal(const Vec3 &albedo, float fuzz) : albedo_(albedo), fuzz_(fuzz) {} virtual ~Metal() = default; virtual bool scatter(const Ray &ray, const HitRecord &rec, Vec3 &attenuation, Ray &scattered) const override { Vec3 reflected = reflect(UnitVector(ray.GetDirection()), rec.normal); scattered = Ray(rec.p, reflected + fuzz_ * RandomInUnitSphere()); attenuation = albedo_; return (Dot(scattered.GetDirection(), rec.normal) > 0.0); } private: Vec3 albedo_; float fuzz_; }; } #endif // RAYTRACER_CPP_METAL_HPP_
[ "muramasa8191@gmail.com" ]
muramasa8191@gmail.com
f2325b065a9cce22d9ec83ca7bd31f8a2cbda780
a8504d0806086082a9caf4c00ead73eb0c143abc
/chinchiller/include/drivers/lcd.h
5959aa979dbd32bcb7a22229db80879c302bb28c
[ "MIT" ]
permissive
lucianodasilva/chinchiller
9b9d618af590bc1b97532c673c589f2ff54c7d06
67b50e5997f1bed18d3f68168a8e5b0734e6aaab
refs/heads/master
2021-01-23T01:12:10.583594
2017-07-21T16:50:17
2017-07-21T16:50:17
92,857,443
1
0
null
null
null
null
UTF-8
C++
false
false
4,459
h
#pragma once #ifndef _common_drivers_lcd_h_ #define _common_drivers_lcd_h_ #include "common/mcu.h" namespace drivers { struct pos { uint8_t x, y; }; template < mcu::io::pin_num_t _rs_pin_n, mcu::io::pin_num_t _e_pin_n, mcu::io::pin_num_t _data0_pin_n, mcu::io::pin_num_t _data1_pin_n, mcu::io::pin_num_t _data2_pin_n, mcu::io::pin_num_t _data3_pin_n > struct lcd { mcu::io::pin < _rs_pin_n > rs_pin = {mcu::io::pin_mode::output}; mcu::io::pin < _e_pin_n > e_pin = {mcu::io::pin_mode::output}; mcu::io::pin < _data0_pin_n > data0_pin = {mcu::io::pin_mode::output}; mcu::io::pin < _data1_pin_n > data1_pin = {mcu::io::pin_mode::output}; mcu::io::pin < _data2_pin_n > data2_pin = {mcu::io::pin_mode::output}; mcu::io::pin < _data3_pin_n > data3_pin = {mcu::io::pin_mode::output}; inline void clear () const { command (cmd_clear); mcu::delay(2); } inline void home () const { command (cmd_return_home); mcu::delay(2); } inline void set_display_on () { _disp_ctrl |= ctrl_display_on; command (cmd_display_control, _disp_ctrl); } inline void set_display_off () { _disp_ctrl &= ~ctrl_display_on; command (cmd_display_control, _disp_ctrl); } inline void set_cursor (uint8_t x, uint8_t y) const { uint8_t c_index = x + (y * 40); command (cmd_set_ddramaddr, c_index); } void init () { // function flags _disp_func = 0x00 /* 4 bit */ | 0x08 /* 2 line */ | 0x00 /* 5x8 dot */; // wait for lcd init mcu::delay (50); // reset pins rs_pin .set_low(); e_pin .set_low(); // set command sequence for 4 bit mode write_4(0x03); mcu::delay_us(4500); write_4(0x03); mcu::delay_us(4500); write_4(0x03); mcu::delay_us(150); write_4(0x02); command(cmd_function_set, _disp_func); // set default display control mode _disp_ctrl = ctrl_display_on | ctrl_cursor_off | ctrl_blink_off; set_display_on(); clear(); // set default display mode _disp_mode = mode_entry_left | mode_entry_shift_dec; command (cmd_entry_mode_set, _disp_mode); } inline void set_precision (uint8_t v) { _precision = v; } inline lcd & operator << (const pos & p) { set_cursor(p.x, p.y); return *this; } lcd & operator << (const char * s) { while (*s) send (*s++, 1); return *this; } lcd & operator << (int32_t v) { char buffer [16]; itoa(v, +buffer, 10); return operator << (+buffer); } lcd & operator << (uint32_t v) { char buffer [16]; utoa(v, +buffer, 10); return operator << (+buffer); } lcd & operator << (double v) { char buffer [16]; dtostrf(v, 0, _precision, +buffer); return operator << (+buffer); } private: inline void command (uint8_t c, uint8_t p = 0) const { send (c | p, 0); } inline void send (uint8_t value, uint8_t rs_mode) const { rs_pin.set(rs_mode); write(value); } inline void write (uint8_t v) const { write_4 (v >> 4); write_4 (v); } inline void write_4 (uint8_t v) const { write_to(v, data0_pin, data1_pin, data2_pin, data3_pin); pulse(); } template < class _pin_t > inline void write_to (uint8_t & v, _pin_t & p) const { p.set(v); v = v >> 1; } template < class _pin0_t, class ... _pin_t > inline void write_to (uint8_t v, _pin0_t & pin0, _pin_t & ... pins) const { write_to < _pin0_t > (v, pin0); write_to (v, pins...); } inline void pulse () const { e_pin.set_low(); mcu::delay_us(1); e_pin.set_high(); mcu::delay_us(1); e_pin.set_low(); mcu::delay_us(100); } uint8_t _disp_func; uint8_t _disp_ctrl; uint8_t _disp_mode; uint8_t _precision = 2; static constexpr uint8_t const // commands cmd_clear = 0x01, cmd_return_home = 0x02, cmd_entry_mode_set = 0x04, cmd_display_control = 0x08, cmd_cursor_shift = 0x10, cmd_function_set = 0x20, cmd_set_cgramaddr = 0x40, cmd_set_ddramaddr = 0x80, // display entry mode mode_entry_right = 0x00, mode_entry_left = 0x02, mode_entry_shift_inc = 0x01, mode_entry_shift_dec = 0x00, // display on / off ctrl_display_on = 0x04, ctrl_display_off = 0x00, ctrl_cursor_on = 0x02, ctrl_cursor_off = 0x00, ctrl_blink_on = 0x01, ctrl_blink_off = 0x00, // display/cursor shift cursor_display_move = 0x08, cursor_cursor_move = 0x00, cursor_move_right = 0x04, cursor_move_left = 0x00; }; } #endif
[ "luciano.silva@live.com.pt" ]
luciano.silva@live.com.pt
e7131ebb00f85ad433318e1b338cbe9bcf8753ba
c61c856258294fed5eb2a8b17c28d94db6f86fae
/exceptions/application_exceptions.hpp
9fbfd2efcc34590f3847376cd0762389966181df
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
hmito/hmLib
18b5cd5493e29168b5dc8ca488ed425caae42a8b
3d10a18cc9b4dbba52b5060208263bbb5bb29c4b
refs/heads/master
2023-08-16T22:47:45.550228
2022-05-10T03:01:21
2022-05-10T03:01:21
29,452,438
0
1
null
null
null
null
UTF-8
C++
false
false
1,206
hpp
๏ปฟ#ifndef HMLIB_EXCEPTIONS_APPLICATIONEXCEPTIONS_INC #define HMLIB_EXCEPTIONS_APPLICATIONEXCEPTIONS_INC 100 # #include"exception.hpp" namespace hmLib{ namespace application_exceptions { //applicationใซ้–ขใ‚ใ‚‹ไพ‹ๅค–ๅ‡ฆ็† class application_exception :public exceptions::exception { typedef exceptions::exception base_type; public: explicit application_exception(const std::string& Message_) :base_type(Message_.c_str()) {} explicit application_exception(const char* Message_) :base_type(Message_) {} }; //ๅฎŸ่กŒๅผ•ๆ•ฐใฎๆ•ฐใŒ็•ฐๅธธ class invalid_arguments_number :public application_exception { typedef application_exception base_type; public: explicit invalid_arguments_number(const std::string& Message_) :base_type(Message_.c_str()) {} explicit invalid_arguments_number(const char* Message_) :base_type(Message_) {} }; //ๅฎŸ่กŒๅผ•ๆ•ฐใฎๅ€คใŒ็•ฐๅธธ class invalid_argument_value :public application_exception { typedef application_exception base_type; public: explicit invalid_argument_value(const std::string& Message_) :base_type(Message_.c_str()) {} explicit invalid_argument_value(const char* Message_) :base_type(Message_) {} }; } } # #endif
[ "hmito@outlook.com" ]
hmito@outlook.com
9488a905c7f3d47e460056bdcecc885227c84981
af88798163d01a149de2ae04f8354311e734da08
/BitSet/parser.h
d014a07b45ad71af9cc453bc7f26843b4ca1ccef
[ "MIT" ]
permissive
vlad-shevchenko/BitSet
abe3121826662e8f250e155ec1e7639aa49ab542
e9b24e8e0c432d7eeda3bb460693d1006bbd63cb
refs/heads/master
2020-12-24T21:27:23.999498
2016-06-01T06:36:59
2016-06-01T06:36:59
56,754,837
0
0
null
null
null
null
UTF-8
C++
false
false
508
h
#ifndef PARSER_H #define PARSER_H #include <symbols.h> #include <bitset.h> #include <QString> class Parser { private: QList<symbols::Symbol> tokens; symbols::Symbol cur; symbols::Symbol next; void goNext(); BitSet parseConcat(); BitSet parseShift(); BitSet parseXor(); BitSet parseAnd(); BitSet parseOr(); BitSet parseNegate(); BitSet parseTerm(); public: Parser(); Parser(QList<symbols::Symbol>& tokens); BitSet parse(); }; #endif // PARSER_H
[ "vlad.shevchenko.ua@gmail.com" ]
vlad.shevchenko.ua@gmail.com
8b7cd369226b90a3e39d20060a03ed95ebd0ecfb
5bc07dbbdcda1a772de18a36432086a4c09299a9
/TXCloudPortal/UI/CreateRoom.h
dc6ba15d9cd123dd007070d2390e88faa8e05951
[]
no_license
shengang1978/webexe_exe_source
f37715405b0e822c779cd00496765f34285981bb
716e85310449db720558eea7e2d6dbf803824e56
refs/heads/master
2020-04-06T17:00:01.144573
2018-09-29T10:52:45
2018-09-29T10:52:45
157,642,349
0
1
null
2018-11-15T02:46:19
2018-11-15T02:46:18
null
UTF-8
C++
false
false
804
h
#pragma once #include <QDialog> #include "ui_CreateRoom.h" typedef std::function<void(bool, const std::string&)> handlefunction; class CreateRoom : public QDialog { Q_OBJECT public: CreateRoom(QWidget *parent = Q_NULLPTR); ~CreateRoom(); void setLogo(QString styleSheet); void setHanleFunction(handlefunction func); protected: virtual void mousePressEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event); virtual void keyPressEvent(QKeyEvent *event); protected slots: void onCloseBtnClicked(); void onOperateBtnClicked(); void onCancelBtnClicked(); private: Ui::CreateRoom ui; bool m_pressed; QPoint m_point; handlefunction m_func; QString m_roomName; };
[ "xuanyiyan@tencent.com" ]
xuanyiyan@tencent.com
700f609fb736c3026fd522ee2ce20c4520a64fe2
33a92a350d18515613a7c5bac8518556c2c1d799
/VC++6.0/ๆ•ฐๅญ—ๅ›พๅƒ/ljz153/ljz153.h
1f02c60d5d8f63c2ed10462d41bdae2e7d167c29
[]
no_license
WemtFox/MyLearningCode
7b35345524f7cc047e364ab3d9f54892776213fa
e7df5692ea57756ae9563a84a5345e0b688c470d
refs/heads/master
2020-04-12T07:50:30.255469
2015-12-05T01:47:40
2015-12-05T01:47:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,307
h
// ljz153.h : main header file for the LJZ153 application // #if !defined(AFX_LJZ153_H__38C58EDA_692E_41E0_BEB8_CF94E24D2CC0__INCLUDED_) #define AFX_LJZ153_H__38C58EDA_692E_41E0_BEB8_CF94E24D2CC0__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH #endif #include "resource.h" // main symbols ///////////////////////////////////////////////////////////////////////////// // CLjz153App: // See ljz153.cpp for the implementation of this class // class CLjz153App : public CWinApp { public: CLjz153App(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CLjz153App) public: virtual BOOL InitInstance(); //}}AFX_VIRTUAL // Implementation //{{AFX_MSG(CLjz153App) afx_msg void OnAppAbout(); // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_LJZ153_H__38C58EDA_692E_41E0_BEB8_CF94E24D2CC0__INCLUDED_)
[ "sslujuzhi@sina.cn" ]
sslujuzhi@sina.cn
15e98d16b9d317e6b47cbaae56d35e249e1b3447
050c8a810d34fe125aecae582f9adfd0625356c6
/cf1540/B.cpp
cfbb3c60bdcf0125a72cd34a79fa6582cf8fb874
[]
no_license
georgerapeanu/c-sources
adff7a268121ae8c314e846726267109ba1c62e6
af95d3ce726325dcd18b3d94fe99969006b8e138
refs/heads/master
2022-12-24T22:57:39.526205
2022-12-21T16:05:01
2022-12-21T16:05:01
144,864,608
11
0
null
null
null
null
UTF-8
C++
false
false
2,344
cpp
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int NMAX = 200; int fact[NMAX + 5]; int ifact[NMAX + 5]; int pw2[NMAX + 5]; int ipw2[NMAX + 5]; int dp[NMAX + 5][NMAX + 5]; int add(int a,int b){ a += b; if(a >= MOD){ a -= MOD; } return a; } int mult(int a,int b){ return 1LL * a * b % MOD; } int comb(int n,int k){ return mult(fact[n],mult(ifact[n - k],ifact[k])); } int lgpow(int base,int exp){ int answer = 1; while(exp){ if(exp & 1){ answer = mult(answer,base); } base = mult(base,base); exp >>= 1; } return answer; } int n; int weight[NMAX + 5]; vector<int> graph[NMAX + 5]; vector<int> dfs_stack; void predfs(int nod,int tata){ weight[nod] = 1; for(auto it:graph[nod]){ if(it == tata){ continue; } predfs(it,nod); weight[nod] += weight[it]; } } int invN; int global_answer = 0; void dfs(int nod,int tata){ dfs_stack.push_back(nod); if(nod != dfs_stack[0]){ int ans = mult(weight[dfs_stack[0]] - weight[dfs_stack[1]],invN); for(int i = 1;i < (int)dfs_stack.size() - 1;i++){ int coef = mult(weight[dfs_stack[i]] - weight[dfs_stack[i + 1]],invN); ans = add(ans,mult(coef,dp[i][(int)dfs_stack.size() - 1 - i])); } if(dfs_stack[0] > nod){ global_answer = add(global_answer,ans); } } for(auto it:graph[nod]){ if(it != tata){ dfs(it,nod); } } dfs_stack.pop_back(); } int main(){ fact[0] = 1; pw2[0] = 1; for(int i = 1;i <= NMAX;i++){ fact[i] = mult(i,fact[i - 1]); pw2[i] = add(pw2[i - 1],pw2[i - 1]); } ifact[NMAX] = lgpow(fact[NMAX],MOD - 2); ipw2[NMAX] = lgpow(pw2[NMAX],MOD - 2); for(int i = NMAX - 1;i >= 0;i--){ ifact[i] = mult(ifact[i + 1],i + 1); ipw2[i] = mult(2,ipw2[i + 1]); } scanf("%d",&n); invN = lgpow(n,MOD - 2); for(int i = 1;i < n;i++){ int x,y; scanf("%d %d",&x,&y); graph[x].push_back(y); graph[y].push_back(x); } for(int i = 1;i <= n;i++){ dp[0][i] = 1; } for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++){ dp[i][j] = mult(add(dp[i][j - 1],dp[i - 1][j]),ipw2[1]); } } for(int i = 1;i <= n;i++){ predfs(i,0); dfs(i,0); } printf("%d\n",global_answer); return 0; }
[ "alexandrurapeanu@yahoo.com" ]
alexandrurapeanu@yahoo.com
90bb81b28fdd34f50cf584bcafdb83d1c7e4ce88
c43cbfca4056ea30051e46e1917e7946beb1e331
/src/qt/editaddressdialog.cpp
891eca042a2c3bf7f409b8b29dda130872a3c88e
[ "MIT" ]
permissive
Legioncrypto/Legion
c9017fce536e9d296f6af9e1d06e5a9b03c9b0c9
f7b5a0287e530bec85f3081fd7ac7a8a020cdcf9
refs/heads/master
2020-03-18T19:55:28.823995
2019-03-14T02:29:52
2019-03-14T02:29:52
135,185,573
1
4
null
null
null
null
UTF-8
C++
false
false
4,480
cpp
#include "editaddressdialog.h" #include "ui_editaddressdialog.h" #include "addresstablemodel.h" #include "guiutil.h" #include <QDataWidgetMapper> #include <QMessageBox> #include <QClipboard> EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) : QDialog(parent), ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0) { ui->setupUi(this); GUIUtil::setupAddressWidget(ui->addressEdit, this); switch(mode) { case NewReceivingAddress: setWindowTitle(tr("New receiving address")); ui->addressEdit->setEnabled(false); ui->addressEdit->setVisible(false); ui->stealthCB->setEnabled(true); ui->stealthCB->setVisible(true); break; case NewSendingAddress: setWindowTitle(tr("New sending address")); ui->stealthCB->setVisible(false); break; case EditReceivingAddress: setWindowTitle(tr("Edit receiving address")); ui->addressEdit->setEnabled(false); ui->addressEdit->setVisible(true); ui->stealthCB->setEnabled(false); ui->stealthCB->setVisible(true); break; case EditSendingAddress: setWindowTitle(tr("Edit sending address")); ui->stealthCB->setVisible(false); break; } mapper = new QDataWidgetMapper(this); mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); } EditAddressDialog::~EditAddressDialog() { delete ui; } void EditAddressDialog::setModel(AddressTableModel *model) { this->model = model; if(!model) return; mapper->setModel(model); mapper->addMapping(ui->labelEdit, AddressTableModel::Label); mapper->addMapping(ui->addressEdit, AddressTableModel::Address); mapper->addMapping(ui->stealthCB, AddressTableModel::Type); } void EditAddressDialog::loadRow(int row) { mapper->setCurrentIndex(row); } bool EditAddressDialog::saveCurrentRow() { if(!model) return false; switch(mode) { case NewReceivingAddress: case NewSendingAddress: { int typeInd = ui->stealthCB->isChecked() ? AddressTableModel::AT_Stealth : AddressTableModel::AT_Normal; address = model->addRow( mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive, ui->labelEdit->text(), ui->addressEdit->text(), typeInd); } break; case EditReceivingAddress: case EditSendingAddress: if(mapper->submit()) { address = ui->addressEdit->text(); } break; } return !address.isEmpty(); } void EditAddressDialog::accept() { if(!model) return; if(!saveCurrentRow()) { switch(model->getEditStatus()) { case AddressTableModel::OK: // Failed with unknown reason. Just reject. break; case AddressTableModel::NO_CHANGES: // No changes were made during edit operation. Just reject. break; case AddressTableModel::INVALID_ADDRESS: QMessageBox::warning(this, windowTitle(), tr("The entered address \"%1\" is not a valid Legion address.").arg(ui->addressEdit->text()), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::DUPLICATE_ADDRESS: QMessageBox::warning(this, windowTitle(), tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::WALLET_UNLOCK_FAILURE: QMessageBox::critical(this, windowTitle(), tr("Could not unlock wallet."), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::KEY_GENERATION_FAILURE: QMessageBox::critical(this, windowTitle(), tr("New key generation failed."), QMessageBox::Ok, QMessageBox::Ok); break; } return; } QDialog::accept(); } QString EditAddressDialog::getAddress() const { return address; } void EditAddressDialog::setAddress(const QString &address) { this->address = address; ui->addressEdit->setText(address); } void EditAddressDialog::on_EditAddressPasteButton_clicked() { // Paste text from clipboard into recipient field ui->addressEdit->setText(QApplication::clipboard()->text()); }
[ "legioncrypto@users.noreply.github.com" ]
legioncrypto@users.noreply.github.com
077988cb4e85122c644aea246d26d91cbf2ad0a1
1060214b1efa068d20a756126ad1ffcbfeb0814b
/estrutura/PontosdeFeno.cpp
aa7ab141b613b2202e44f8b8a12b66db0bb20078
[]
no_license
blogdarkspot/MaratonadeProgramacao
4b0aecc063033caebad78e34bb090d1822e1fb26
41420c2c06b6849f50f9ea99e70d841e15c0f1ea
refs/heads/master
2021-05-30T01:57:26.007257
2015-10-06T14:49:00
2015-10-06T14:49:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
769
cpp
//https://www.urionlinejudge.com.br/judge/pt/problems/view/1261 #include<iostream> #include<string> #include<cstdio> #include<map> using namespace std; int main () { string buffer; map<string, int> dic; int i,j,k, total = 0; cin>>i>>j; total = 0; dic.clear(); while(i--) { cin>>buffer>>k; dic[buffer]=k; } while (getline(cin, buffer)) { for (int a=0, b=0, c=0; a<buffer.size(); a++) { while(buffer[a]!=' ' && a<buffer.size() && buffer[a]!='.') { a++; c++; } if (a!=b && dic.count(buffer.substr(b,c))>0) total+=dic.find(buffer.substr(b,c))->second; if(buffer[a]=='.') { cout<<total<<endl; total=0; } b = a+1; c =0; } } return 0; }
[ "fabio.scienvitarso@gmail.com" ]
fabio.scienvitarso@gmail.com
c5a199aca76e8092977a016cd814325578ead538
a366d89b4e41bde44d471f163c49f76abb3da8fc
/homing.cpp
b242f7e997a6174f31c3fa54674fbf3d7520f3fa
[]
no_license
pigranya1218/WinAPI-worms
6bc3ff2a3ac6e4216fc973a6b6c7c0031605283c
7f864994aa26afc00bfcc3d405b513f9665a627e
refs/heads/master
2022-11-25T18:05:30.278987
2020-07-29T02:17:49
2020-07-29T02:17:49
276,584,039
0
1
null
null
null
null
UHC
C++
false
false
1,651
cpp
#include "stdafx.h" #include "homing.h" #include "stageManager.h" #include "wormManager.h" #include "objectManager.h" void homing::update() { if (!_isFinish) { if (_homingCount++ >= 50) // ๋ฐ”์ถ”์นด์™€ ๊ฐ™๋‹ค { if (!_isHoming) { _angle = TTYONE_UTIL::getAngle(_x, _y, _pointX, _pointY); float degree = _angle * (180 / PI); _isHoming = true; _power = 20; SOUND_MANAGER->stop("WEAPON_HOMING_ON"); SOUND_MANAGER->play("WEAPON_HOMING_ON", 1); } } else { _ani->frameUpdate(TIME_MANAGER->getElapsedTime()); } EFFECT_MANAGER->play("EFFECT_HEXHAUST", _x, _y, 40, 40); bool isBomb = gravityMove(0); if (isBomb) // ํญํŒŒ์‹œํ‚ค๊ธฐ { SOUND_MANAGER->stop("WEAPON_HOMING_ON"); EFFECT_MANAGER->play("EFFECT_CIRCLE", _x, _y, _bombWidth, _bombWidth); EFFECT_MANAGER->play("EFFECT_ELIPSE", _x, _y, _bombWidth + 30, _bombWidth + 30); EFFECT_MANAGER->play("EFFECT_EX_POW", _x, _y - 50, 50, 50); _stageManager->pixelBomb(_x, _y, _damage, _bombWidth); // ํ”ฝ์…€ ํญํŒŒ์‹œํ‚ค๊ธฐ _wormManager->wormBomb(_x, _y, _damage, _bombWidth); // ๋งž์€ ์›œ์ฆˆ ๋‚ ๋ผ๊ฐ€๊ฒŒ ํ•˜๊ธฐ _objectManager->objectBomb(_x, _y, _damage, _bombWidth); _objectManager->makeBombEffect(_x, _y, _bombWidth); _isFinish = true; } } } void homing::render() { if (_isHoming) { _img = IMAGE_MANAGER->findImage("PROJECTILE_HOMING_RED"); projectile::render(); // ๋นจ๊ฐ„ ์œ ๋„ ๋ฏธ์‚ฌ์ผ ๋ฟ…๋ฟ… ๋‚ ๋ผ๊ฐ„๋‹ค } else { // ํŒŒ๋ž€ ์œ ๋„๋ฏธ์‚ฌ์ผ ๋น™๊ธ€๋น™๊ธ€ ๋‚ ์•„๊ฐ„๋‹ค CAMERA_MANAGER->aniRender(getMemDC(), _img, _x - (_img->getFrameWidth() / 2), _y - (_img->getFrameHeight() / 2), _ani, false); } }
[ "ddodd34@gmail.com" ]
ddodd34@gmail.com
089c5270881b5dd21f1fef4645de3d704cc37e27
fcdea24e6466d4ec8d7798555358a9af8acf9b35
/Engine/mrayEngine/src/MorphAnimator.cpp
46e44ecb119f9f0d93b058b68ea3ee17eeb52279
[]
no_license
yingzhang536/mrayy-Game-Engine
6634afecefcb79c2117cecf3e4e635d3089c9590
6b6fcbab8674a6169e26f0f20356d0708620b828
refs/heads/master
2021-01-17T07:59:30.135446
2014-11-30T16:10:54
2014-11-30T16:10:54
27,630,181
2
0
null
null
null
null
UTF-8
C++
false
false
2,802
cpp
#include "stdafx.h" #include "MorphAnimator.h" #include "ILogManager.h" #include "IMeshBuffer.h" namespace mray{ namespace scene{ MorphAnimator::MorphAnimator(IMeshBuffer*mesh) :IMorphAnimator(mesh) { m_needUpdate=false; setMeshBuffer(mesh); } MorphAnimator::~MorphAnimator(){ m_targets.clear(); } void MorphAnimator::setMeshBuffer(IMeshBuffer*mesh) { m_needUpdate=false; m_buffer=mesh; video::IHardwareStreamBuffer*s=mesh->getStream(0,video::EMST_Position); m_tempVector.resize(m_vertexCount); m_baseVector.resize(m_vertexCount); math::vector3d*mainVert=(math::vector3d*) s->lock(0,0,video::IHardwareBuffer::ELO_ReadOnly); for (int v=0;v<m_baseVector.size();v++){ m_baseVector[v]=mainVert[v]; } s->unlock(); } void MorphAnimator::update(float dt){ m_needUpdate=false; for (int i=0;i<m_targets.size();++i) { if(m_targets[i].target->getPercent()!=m_targets[i].oldVal){ m_needUpdate=true; break; } } if(!m_needUpdate)return; m_needUpdate=false; for (int i=0;i<m_tempVector.size();++i) { m_tempVector[i]=0; } float total=1; bool changed=0; for(int i=0;i<m_targets.size();++i){ MorphTarget*t=m_targets[i].target; if(t->getPercent()==0)continue; m_targets[i].oldVal=t->getPercent(); float p=m_targets[i].oldVal*0.01f; video::IHardwareStreamBuffer*stream=t->getMesh()->getStream(0,video::EMST_Position); math::vector3d*pV=(math::vector3d*) stream->lock(0,0,video::IHardwareBuffer::ELO_ReadOnly); int cnt=stream->length(); for (int v=0;v<cnt;v++) { m_tempVector[v]+=pV[v]*p; } total-=p; stream->unlock(); changed=true; } if(changed){ video::IHardwareStreamBuffer*mainStream=m_buffer->getStream(0,video::EMST_Position); math::vector3d*mainVert=(math::vector3d*) mainStream->lock(0,0,video::IHardwareBuffer::ELO_Normal); int len=mainStream->length(); for (int v=0;v<m_tempVector.size();v++){ mainVert[v]=m_tempVector[v]+m_baseVector[v]*total; } mainStream->unlock(); } } const MorphTargetPtr& MorphAnimator::addTarget(scene::IMeshBuffer*buff,float p){ const MorphTargetPtr& t=IMorphAnimator::addTarget(buff,p); if(p!=0 && t.pointer()!=0) m_needUpdate=true; return t; } void MorphAnimator::setTargetPercent(int index,float v){ if(index>=m_targets.size())return; MorphTarget*t=m_targets[index].target; v=math::clamp(v,0.0f,1.0f); if(t->getPercent()!=v){ m_needUpdate=true; t->setPercent(v); } } IMeshAnimator* MorphAnimator::duplicate() { MorphAnimator* c=new MorphAnimator(m_buffer); for(int i=0;i<m_targets.size();++i) { MorphTargetInfo ifo(new MorphTarget(m_targets[i].target->getMesh(),m_targets[i].target->getPercent())); c->m_targets.push_back(ifo); } return c; } } }
[ "mrayyamen@gmail.com" ]
mrayyamen@gmail.com
1de0c1f4544030bdb1b8b0665e7443ee8b195520
297497957c531d81ba286bc91253fbbb78b4d8be
/media/libyuv/libyuv/source/planar_functions.cc
f4463d547deb03eab1965e14dd323ae03e0e18be
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
marco-c/gecko-dev-comments-removed
7a9dd34045b07e6b22f0c636c0a836b9e639f9d3
61942784fb157763e65608e5a29b3729b0aa66fa
refs/heads/master
2023-08-09T18:55:25.895853
2023-08-01T00:40:39
2023-08-01T00:40:39
211,297,481
0
0
NOASSERTION
2019-09-29T01:27:49
2019-09-27T10:44:24
C++
UTF-8
C++
false
false
149,944
cc
#include "libyuv/planar_functions.h" #include <assert.h> #include <string.h> #include "libyuv/cpu_id.h" #ifdef HAVE_JPEG #include "libyuv/mjpeg_decoder.h" #endif #include "libyuv/row.h" #include "libyuv/scale_row.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif LIBYUV_API void CopyPlane(const uint8_t* src_y, int src_stride_y, uint8_t* dst_y, int dst_stride_y, int width, int height) { int y; void (*CopyRow)(const uint8_t* src, uint8_t* dst, int width) = CopyRow_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; dst_stride_y = -dst_stride_y; } if (src_stride_y == width && dst_stride_y == width) { width *= height; height = 1; src_stride_y = dst_stride_y = 0; } if (src_y == dst_y && src_stride_y == dst_stride_y) { return; } #if defined(HAS_COPYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { CopyRow = IS_ALIGNED(width, 32) ? CopyRow_SSE2 : CopyRow_Any_SSE2; } #endif #if defined(HAS_COPYROW_AVX) if (TestCpuFlag(kCpuHasAVX)) { CopyRow = IS_ALIGNED(width, 64) ? CopyRow_AVX : CopyRow_Any_AVX; } #endif #if defined(HAS_COPYROW_ERMS) if (TestCpuFlag(kCpuHasERMS)) { CopyRow = CopyRow_ERMS; } #endif #if defined(HAS_COPYROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { CopyRow = IS_ALIGNED(width, 32) ? CopyRow_NEON : CopyRow_Any_NEON; } #endif for (y = 0; y < height; ++y) { CopyRow(src_y, dst_y, width); src_y += src_stride_y; dst_y += dst_stride_y; } } LIBYUV_API void CopyPlane_16(const uint16_t* src_y, int src_stride_y, uint16_t* dst_y, int dst_stride_y, int width, int height) { CopyPlane((const uint8_t*)src_y, src_stride_y * 2, (uint8_t*)dst_y, dst_stride_y * 2, width * 2, height); } LIBYUV_API void Convert16To8Plane(const uint16_t* src_y, int src_stride_y, uint8_t* dst_y, int dst_stride_y, int scale, int width, int height) { int y; void (*Convert16To8Row)(const uint16_t* src_y, uint8_t* dst_y, int scale, int width) = Convert16To8Row_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; dst_stride_y = -dst_stride_y; } if (src_stride_y == width && dst_stride_y == width) { width *= height; height = 1; src_stride_y = dst_stride_y = 0; } #if defined(HAS_CONVERT16TO8ROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { Convert16To8Row = Convert16To8Row_Any_NEON; if (IS_ALIGNED(width, 16)) { Convert16To8Row = Convert16To8Row_NEON; } } #endif #if defined(HAS_CONVERT16TO8ROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { Convert16To8Row = Convert16To8Row_Any_SSSE3; if (IS_ALIGNED(width, 16)) { Convert16To8Row = Convert16To8Row_SSSE3; } } #endif #if defined(HAS_CONVERT16TO8ROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { Convert16To8Row = Convert16To8Row_Any_AVX2; if (IS_ALIGNED(width, 32)) { Convert16To8Row = Convert16To8Row_AVX2; } } #endif for (y = 0; y < height; ++y) { Convert16To8Row(src_y, dst_y, scale, width); src_y += src_stride_y; dst_y += dst_stride_y; } } LIBYUV_API void Convert8To16Plane(const uint8_t* src_y, int src_stride_y, uint16_t* dst_y, int dst_stride_y, int scale, int width, int height) { int y; void (*Convert8To16Row)(const uint8_t* src_y, uint16_t* dst_y, int scale, int width) = Convert8To16Row_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; dst_stride_y = -dst_stride_y; } if (src_stride_y == width && dst_stride_y == width) { width *= height; height = 1; src_stride_y = dst_stride_y = 0; } #if defined(HAS_CONVERT8TO16ROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { Convert8To16Row = Convert8To16Row_Any_SSE2; if (IS_ALIGNED(width, 16)) { Convert8To16Row = Convert8To16Row_SSE2; } } #endif #if defined(HAS_CONVERT8TO16ROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { Convert8To16Row = Convert8To16Row_Any_AVX2; if (IS_ALIGNED(width, 32)) { Convert8To16Row = Convert8To16Row_AVX2; } } #endif for (y = 0; y < height; ++y) { Convert8To16Row(src_y, dst_y, scale, width); src_y += src_stride_y; dst_y += dst_stride_y; } } LIBYUV_API int I422Copy(const uint8_t* src_y, int src_stride_y, const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height) { int halfwidth = (width + 1) >> 1; if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; src_u = src_u + (height - 1) * src_stride_u; src_v = src_v + (height - 1) * src_stride_v; src_stride_y = -src_stride_y; src_stride_u = -src_stride_u; src_stride_v = -src_stride_v; } if (dst_y) { CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); } CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, height); CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, height); return 0; } LIBYUV_API int I444Copy(const uint8_t* src_y, int src_stride_y, const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height) { if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; src_u = src_u + (height - 1) * src_stride_u; src_v = src_v + (height - 1) * src_stride_v; src_stride_y = -src_stride_y; src_stride_u = -src_stride_u; src_stride_v = -src_stride_v; } if (dst_y) { CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); } CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height); CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height); return 0; } LIBYUV_API int I210Copy(const uint16_t* src_y, int src_stride_y, const uint16_t* src_u, int src_stride_u, const uint16_t* src_v, int src_stride_v, uint16_t* dst_y, int dst_stride_y, uint16_t* dst_u, int dst_stride_u, uint16_t* dst_v, int dst_stride_v, int width, int height) { int halfwidth = (width + 1) >> 1; if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; src_u = src_u + (height - 1) * src_stride_u; src_v = src_v + (height - 1) * src_stride_v; src_stride_y = -src_stride_y; src_stride_u = -src_stride_u; src_stride_v = -src_stride_v; } if (dst_y) { CopyPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, width, height); } CopyPlane_16(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, height); CopyPlane_16(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, height); return 0; } LIBYUV_API int I410Copy(const uint16_t* src_y, int src_stride_y, const uint16_t* src_u, int src_stride_u, const uint16_t* src_v, int src_stride_v, uint16_t* dst_y, int dst_stride_y, uint16_t* dst_u, int dst_stride_u, uint16_t* dst_v, int dst_stride_v, int width, int height) { if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; src_u = src_u + (height - 1) * src_stride_u; src_v = src_v + (height - 1) * src_stride_v; src_stride_y = -src_stride_y; src_stride_u = -src_stride_u; src_stride_v = -src_stride_v; } if (dst_y) { CopyPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, width, height); } CopyPlane_16(src_u, src_stride_u, dst_u, dst_stride_u, width, height); CopyPlane_16(src_v, src_stride_v, dst_v, dst_stride_v, width, height); return 0; } LIBYUV_API int I400ToI400(const uint8_t* src_y, int src_stride_y, uint8_t* dst_y, int dst_stride_y, int width, int height) { if (!src_y || !dst_y || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; src_stride_y = -src_stride_y; } CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); return 0; } LIBYUV_API int I420ToI400(const uint8_t* src_y, int src_stride_y, const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_y, int dst_stride_y, int width, int height) { (void)src_u; (void)src_stride_u; (void)src_v; (void)src_stride_v; if (!src_y || !dst_y || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; src_stride_y = -src_stride_y; } CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); return 0; } LIBYUV_API int NV12Copy(const uint8_t* src_y, int src_stride_y, const uint8_t* src_uv, int src_stride_uv, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_uv, int dst_stride_uv, int width, int height) { int halfwidth = (width + 1) >> 1; int halfheight = (height + 1) >> 1; if (!src_y || !dst_y || !src_uv || !dst_uv || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; halfheight = (height + 1) >> 1; src_y = src_y + (height - 1) * src_stride_y; src_uv = src_uv + (halfheight - 1) * src_stride_uv; src_stride_y = -src_stride_y; src_stride_uv = -src_stride_uv; } CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); CopyPlane(src_uv, src_stride_uv, dst_uv, dst_stride_uv, halfwidth * 2, halfheight); return 0; } LIBYUV_API int NV21Copy(const uint8_t* src_y, int src_stride_y, const uint8_t* src_vu, int src_stride_vu, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_vu, int dst_stride_vu, int width, int height) { return NV12Copy(src_y, src_stride_y, src_vu, src_stride_vu, dst_y, dst_stride_y, dst_vu, dst_stride_vu, width, height); } LIBYUV_API void SplitUVPlane(const uint8_t* src_uv, int src_stride_uv, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height) { int y; void (*SplitUVRow)(const uint8_t* src_uv, uint8_t* dst_u, uint8_t* dst_v, int width) = SplitUVRow_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_u = dst_u + (height - 1) * dst_stride_u; dst_v = dst_v + (height - 1) * dst_stride_v; dst_stride_u = -dst_stride_u; dst_stride_v = -dst_stride_v; } if (src_stride_uv == width * 2 && dst_stride_u == width && dst_stride_v == width) { width *= height; height = 1; src_stride_uv = dst_stride_u = dst_stride_v = 0; } #if defined(HAS_SPLITUVROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { SplitUVRow = SplitUVRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { SplitUVRow = SplitUVRow_SSE2; } } #endif #if defined(HAS_SPLITUVROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { SplitUVRow = SplitUVRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { SplitUVRow = SplitUVRow_AVX2; } } #endif #if defined(HAS_SPLITUVROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SplitUVRow = SplitUVRow_Any_NEON; if (IS_ALIGNED(width, 16)) { SplitUVRow = SplitUVRow_NEON; } } #endif #if defined(HAS_SPLITUVROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { SplitUVRow = SplitUVRow_Any_MSA; if (IS_ALIGNED(width, 32)) { SplitUVRow = SplitUVRow_MSA; } } #endif #if defined(HAS_SPLITUVROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { SplitUVRow = SplitUVRow_Any_LSX; if (IS_ALIGNED(width, 32)) { SplitUVRow = SplitUVRow_LSX; } } #endif for (y = 0; y < height; ++y) { SplitUVRow(src_uv, dst_u, dst_v, width); dst_u += dst_stride_u; dst_v += dst_stride_v; src_uv += src_stride_uv; } } LIBYUV_API void MergeUVPlane(const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_uv, int dst_stride_uv, int width, int height) { int y; void (*MergeUVRow)(const uint8_t* src_u, const uint8_t* src_v, uint8_t* dst_uv, int width) = MergeUVRow_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_uv = dst_uv + (height - 1) * dst_stride_uv; dst_stride_uv = -dst_stride_uv; } if (src_stride_u == width && src_stride_v == width && dst_stride_uv == width * 2) { width *= height; height = 1; src_stride_u = src_stride_v = dst_stride_uv = 0; } #if defined(HAS_MERGEUVROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { MergeUVRow = MergeUVRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { MergeUVRow = MergeUVRow_SSE2; } } #endif #if defined(HAS_MERGEUVROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MergeUVRow = MergeUVRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { MergeUVRow = MergeUVRow_AVX2; } } #endif #if defined(HAS_MERGEUVROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { MergeUVRow = MergeUVRow_Any_NEON; if (IS_ALIGNED(width, 16)) { MergeUVRow = MergeUVRow_NEON; } } #endif #if defined(HAS_MERGEUVROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { MergeUVRow = MergeUVRow_Any_MSA; if (IS_ALIGNED(width, 16)) { MergeUVRow = MergeUVRow_MSA; } } #endif #if defined(HAS_MERGEUVROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { MergeUVRow = MergeUVRow_Any_LSX; if (IS_ALIGNED(width, 16)) { MergeUVRow = MergeUVRow_LSX; } } #endif for (y = 0; y < height; ++y) { MergeUVRow(src_u, src_v, dst_uv, width); src_u += src_stride_u; src_v += src_stride_v; dst_uv += dst_stride_uv; } } LIBYUV_API void SplitUVPlane_16(const uint16_t* src_uv, int src_stride_uv, uint16_t* dst_u, int dst_stride_u, uint16_t* dst_v, int dst_stride_v, int width, int height, int depth) { int y; void (*SplitUVRow_16)(const uint16_t* src_uv, uint16_t* dst_u, uint16_t* dst_v, int depth, int width) = SplitUVRow_16_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_u = dst_u + (height - 1) * dst_stride_u; dst_v = dst_v + (height - 1) * dst_stride_v; dst_stride_u = -dst_stride_u; dst_stride_v = -dst_stride_v; } if (src_stride_uv == width * 2 && dst_stride_u == width && dst_stride_v == width) { width *= height; height = 1; src_stride_uv = dst_stride_u = dst_stride_v = 0; } #if defined(HAS_SPLITUVROW_16_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { SplitUVRow_16 = SplitUVRow_16_Any_AVX2; if (IS_ALIGNED(width, 16)) { SplitUVRow_16 = SplitUVRow_16_AVX2; } } #endif #if defined(HAS_SPLITUVROW_16_NEON) if (TestCpuFlag(kCpuHasNEON)) { SplitUVRow_16 = SplitUVRow_16_Any_NEON; if (IS_ALIGNED(width, 8)) { SplitUVRow_16 = SplitUVRow_16_NEON; } } #endif for (y = 0; y < height; ++y) { SplitUVRow_16(src_uv, dst_u, dst_v, depth, width); dst_u += dst_stride_u; dst_v += dst_stride_v; src_uv += src_stride_uv; } } LIBYUV_API void MergeUVPlane_16(const uint16_t* src_u, int src_stride_u, const uint16_t* src_v, int src_stride_v, uint16_t* dst_uv, int dst_stride_uv, int width, int height, int depth) { int y; void (*MergeUVRow_16)(const uint16_t* src_u, const uint16_t* src_v, uint16_t* dst_uv, int depth, int width) = MergeUVRow_16_C; assert(depth >= 8); assert(depth <= 16); if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_uv = dst_uv + (height - 1) * dst_stride_uv; dst_stride_uv = -dst_stride_uv; } if (src_stride_u == width && src_stride_v == width && dst_stride_uv == width * 2) { width *= height; height = 1; src_stride_u = src_stride_v = dst_stride_uv = 0; } #if defined(HAS_MERGEUVROW_16_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MergeUVRow_16 = MergeUVRow_16_Any_AVX2; if (IS_ALIGNED(width, 16)) { MergeUVRow_16 = MergeUVRow_16_AVX2; } } #endif #if defined(HAS_MERGEUVROW_16_NEON) if (TestCpuFlag(kCpuHasNEON)) { MergeUVRow_16 = MergeUVRow_16_Any_NEON; if (IS_ALIGNED(width, 8)) { MergeUVRow_16 = MergeUVRow_16_NEON; } } #endif for (y = 0; y < height; ++y) { MergeUVRow_16(src_u, src_v, dst_uv, depth, width); src_u += src_stride_u; src_v += src_stride_v; dst_uv += dst_stride_uv; } } LIBYUV_API void ConvertToMSBPlane_16(const uint16_t* src_y, int src_stride_y, uint16_t* dst_y, int dst_stride_y, int width, int height, int depth) { int y; int scale = 1 << (16 - depth); void (*MultiplyRow_16)(const uint16_t* src_y, uint16_t* dst_y, int scale, int width) = MultiplyRow_16_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; dst_stride_y = -dst_stride_y; } if (src_stride_y == width && dst_stride_y == width) { width *= height; height = 1; src_stride_y = dst_stride_y = 0; } #if defined(HAS_MULTIPLYROW_16_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MultiplyRow_16 = MultiplyRow_16_Any_AVX2; if (IS_ALIGNED(width, 32)) { MultiplyRow_16 = MultiplyRow_16_AVX2; } } #endif #if defined(HAS_MULTIPLYROW_16_NEON) if (TestCpuFlag(kCpuHasNEON)) { MultiplyRow_16 = MultiplyRow_16_Any_NEON; if (IS_ALIGNED(width, 16)) { MultiplyRow_16 = MultiplyRow_16_NEON; } } #endif for (y = 0; y < height; ++y) { MultiplyRow_16(src_y, dst_y, scale, width); src_y += src_stride_y; dst_y += dst_stride_y; } } LIBYUV_API void ConvertToLSBPlane_16(const uint16_t* src_y, int src_stride_y, uint16_t* dst_y, int dst_stride_y, int width, int height, int depth) { int y; int scale = 1 << depth; void (*DivideRow)(const uint16_t* src_y, uint16_t* dst_y, int scale, int width) = DivideRow_16_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; dst_stride_y = -dst_stride_y; } if (src_stride_y == width && dst_stride_y == width) { width *= height; height = 1; src_stride_y = dst_stride_y = 0; } #if defined(HAS_DIVIDEROW_16_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { DivideRow = DivideRow_16_Any_AVX2; if (IS_ALIGNED(width, 32)) { DivideRow = DivideRow_16_AVX2; } } #endif #if defined(HAS_DIVIDEROW_16_NEON) if (TestCpuFlag(kCpuHasNEON)) { DivideRow = DivideRow_16_Any_NEON; if (IS_ALIGNED(width, 16)) { DivideRow = DivideRow_16_NEON; } } #endif for (y = 0; y < height; ++y) { DivideRow(src_y, dst_y, scale, width); src_y += src_stride_y; dst_y += dst_stride_y; } } LIBYUV_API void SwapUVPlane(const uint8_t* src_uv, int src_stride_uv, uint8_t* dst_vu, int dst_stride_vu, int width, int height) { int y; void (*SwapUVRow)(const uint8_t* src_uv, uint8_t* dst_vu, int width) = SwapUVRow_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; src_uv = src_uv + (height - 1) * src_stride_uv; src_stride_uv = -src_stride_uv; } if (src_stride_uv == width * 2 && dst_stride_vu == width * 2) { width *= height; height = 1; src_stride_uv = dst_stride_vu = 0; } #if defined(HAS_SWAPUVROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { SwapUVRow = SwapUVRow_Any_SSSE3; if (IS_ALIGNED(width, 16)) { SwapUVRow = SwapUVRow_SSSE3; } } #endif #if defined(HAS_SWAPUVROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { SwapUVRow = SwapUVRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { SwapUVRow = SwapUVRow_AVX2; } } #endif #if defined(HAS_SWAPUVROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SwapUVRow = SwapUVRow_Any_NEON; if (IS_ALIGNED(width, 16)) { SwapUVRow = SwapUVRow_NEON; } } #endif for (y = 0; y < height; ++y) { SwapUVRow(src_uv, dst_vu, width); src_uv += src_stride_uv; dst_vu += dst_stride_vu; } } LIBYUV_API int NV21ToNV12(const uint8_t* src_y, int src_stride_y, const uint8_t* src_vu, int src_stride_vu, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_uv, int dst_stride_uv, int width, int height) { int halfwidth = (width + 1) >> 1; int halfheight = (height + 1) >> 1; if (!src_vu || !dst_uv || width <= 0 || height == 0) { return -1; } if (dst_y) { CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); } if (height < 0) { height = -height; halfheight = (height + 1) >> 1; src_vu = src_vu + (halfheight - 1) * src_stride_vu; src_stride_vu = -src_stride_vu; } SwapUVPlane(src_vu, src_stride_vu, dst_uv, dst_stride_uv, halfwidth, halfheight); return 0; } #define IS_POWEROFTWO(x) (!((x) & ((x)-1))) LIBYUV_API int DetilePlane(const uint8_t* src_y, int src_stride_y, uint8_t* dst_y, int dst_stride_y, int width, int height, int tile_height) { const ptrdiff_t src_tile_stride = 16 * tile_height; int y; void (*DetileRow)(const uint8_t* src, ptrdiff_t src_tile_stride, uint8_t* dst, int width) = DetileRow_C; if (!src_y || !dst_y || width <= 0 || height == 0 || !IS_POWEROFTWO(tile_height)) { return -1; } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; dst_stride_y = -dst_stride_y; } #if defined(HAS_DETILEROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { DetileRow = DetileRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { DetileRow = DetileRow_SSE2; } } #endif #if defined(HAS_DETILEROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { DetileRow = DetileRow_Any_NEON; if (IS_ALIGNED(width, 16)) { DetileRow = DetileRow_NEON; } } #endif for (y = 0; y < height; ++y) { DetileRow(src_y, src_tile_stride, dst_y, width); dst_y += dst_stride_y; src_y += 16; if ((y & (tile_height - 1)) == (tile_height - 1)) { src_y = src_y - src_tile_stride + src_stride_y * tile_height; } } return 0; } LIBYUV_API int DetilePlane_16(const uint16_t* src_y, int src_stride_y, uint16_t* dst_y, int dst_stride_y, int width, int height, int tile_height) { const ptrdiff_t src_tile_stride = 16 * tile_height; int y; void (*DetileRow_16)(const uint16_t* src, ptrdiff_t src_tile_stride, uint16_t* dst, int width) = DetileRow_16_C; if (!src_y || !dst_y || width <= 0 || height == 0 || !IS_POWEROFTWO(tile_height)) { return -1; } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; dst_stride_y = -dst_stride_y; } #if defined(HAS_DETILEROW_16_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { DetileRow_16 = DetileRow_16_Any_SSE2; if (IS_ALIGNED(width, 16)) { DetileRow_16 = DetileRow_16_SSE2; } } #endif #if defined(HAS_DETILEROW_16_AVX) if (TestCpuFlag(kCpuHasAVX)) { DetileRow_16 = DetileRow_16_Any_AVX; if (IS_ALIGNED(width, 16)) { DetileRow_16 = DetileRow_16_AVX; } } #endif #if defined(HAS_DETILEROW_16_NEON) if (TestCpuFlag(kCpuHasNEON)) { DetileRow_16 = DetileRow_16_Any_NEON; if (IS_ALIGNED(width, 16)) { DetileRow_16 = DetileRow_16_NEON; } } #endif for (y = 0; y < height; ++y) { DetileRow_16(src_y, src_tile_stride, dst_y, width); dst_y += dst_stride_y; src_y += 16; if ((y & (tile_height - 1)) == (tile_height - 1)) { src_y = src_y - src_tile_stride + src_stride_y * tile_height; } } return 0; } LIBYUV_API void DetileSplitUVPlane(const uint8_t* src_uv, int src_stride_uv, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height, int tile_height) { const ptrdiff_t src_tile_stride = 16 * tile_height; int y; void (*DetileSplitUVRow)(const uint8_t* src, ptrdiff_t src_tile_stride, uint8_t* dst_u, uint8_t* dst_v, int width) = DetileSplitUVRow_C; assert(src_stride_uv >= 0); assert(tile_height > 0); assert(src_stride_uv > 0); if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_u = dst_u + (height - 1) * dst_stride_u; dst_stride_u = -dst_stride_u; dst_v = dst_v + (height - 1) * dst_stride_v; dst_stride_v = -dst_stride_v; } #if defined(HAS_DETILESPLITUVROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { DetileSplitUVRow = DetileSplitUVRow_Any_SSSE3; if (IS_ALIGNED(width, 16)) { DetileSplitUVRow = DetileSplitUVRow_SSSE3; } } #endif #if defined(HAS_DETILESPLITUVROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { DetileSplitUVRow = DetileSplitUVRow_Any_NEON; if (IS_ALIGNED(width, 16)) { DetileSplitUVRow = DetileSplitUVRow_NEON; } } #endif for (y = 0; y < height; ++y) { DetileSplitUVRow(src_uv, src_tile_stride, dst_u, dst_v, width); dst_u += dst_stride_u; dst_v += dst_stride_v; src_uv += 16; if ((y & (tile_height - 1)) == (tile_height - 1)) { src_uv = src_uv - src_tile_stride + src_stride_uv * tile_height; } } } LIBYUV_API void DetileToYUY2(const uint8_t* src_y, int src_stride_y, const uint8_t* src_uv, int src_stride_uv, uint8_t* dst_yuy2, int dst_stride_yuy2, int width, int height, int tile_height) { const ptrdiff_t src_y_tile_stride = 16 * tile_height; const ptrdiff_t src_uv_tile_stride = src_y_tile_stride / 2; int y; void (*DetileToYUY2)(const uint8_t* src_y, ptrdiff_t src_y_tile_stride, const uint8_t* src_uv, ptrdiff_t src_uv_tile_stride, uint8_t* dst_yuy2, int width) = DetileToYUY2_C; assert(src_stride_y >= 0); assert(src_stride_y > 0); assert(src_stride_uv >= 0); assert(src_stride_uv > 0); assert(tile_height > 0); if (width <= 0 || height == 0 || tile_height <= 0) { return; } if (height < 0) { height = -height; dst_yuy2 = dst_yuy2 + (height - 1) * dst_stride_yuy2; dst_stride_yuy2 = -dst_stride_yuy2; } #if defined(HAS_DETILETOYUY2_NEON) if (TestCpuFlag(kCpuHasNEON)) { DetileToYUY2 = DetileToYUY2_Any_NEON; if (IS_ALIGNED(width, 16)) { DetileToYUY2 = DetileToYUY2_NEON; } } #endif #if defined(HAS_DETILETOYUY2_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { DetileToYUY2 = DetileToYUY2_Any_SSE2; if (IS_ALIGNED(width, 16)) { DetileToYUY2 = DetileToYUY2_SSE2; } } #endif for (y = 0; y < height; ++y) { DetileToYUY2(src_y, src_y_tile_stride, src_uv, src_uv_tile_stride, dst_yuy2, width); dst_yuy2 += dst_stride_yuy2; src_y += 16; if (y & 0x1) src_uv += 16; if ((y & (tile_height - 1)) == (tile_height - 1)) { src_y = src_y - src_y_tile_stride + src_stride_y * tile_height; src_uv = src_uv - src_uv_tile_stride + src_stride_uv * (tile_height / 2); } } } LIBYUV_API void SplitRGBPlane(const uint8_t* src_rgb, int src_stride_rgb, uint8_t* dst_r, int dst_stride_r, uint8_t* dst_g, int dst_stride_g, uint8_t* dst_b, int dst_stride_b, int width, int height) { int y; void (*SplitRGBRow)(const uint8_t* src_rgb, uint8_t* dst_r, uint8_t* dst_g, uint8_t* dst_b, int width) = SplitRGBRow_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_r = dst_r + (height - 1) * dst_stride_r; dst_g = dst_g + (height - 1) * dst_stride_g; dst_b = dst_b + (height - 1) * dst_stride_b; dst_stride_r = -dst_stride_r; dst_stride_g = -dst_stride_g; dst_stride_b = -dst_stride_b; } if (src_stride_rgb == width * 3 && dst_stride_r == width && dst_stride_g == width && dst_stride_b == width) { width *= height; height = 1; src_stride_rgb = dst_stride_r = dst_stride_g = dst_stride_b = 0; } #if defined(HAS_SPLITRGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { SplitRGBRow = SplitRGBRow_Any_SSSE3; if (IS_ALIGNED(width, 16)) { SplitRGBRow = SplitRGBRow_SSSE3; } } #endif #if defined(HAS_SPLITRGBROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SplitRGBRow = SplitRGBRow_Any_NEON; if (IS_ALIGNED(width, 16)) { SplitRGBRow = SplitRGBRow_NEON; } } #endif for (y = 0; y < height; ++y) { SplitRGBRow(src_rgb, dst_r, dst_g, dst_b, width); dst_r += dst_stride_r; dst_g += dst_stride_g; dst_b += dst_stride_b; src_rgb += src_stride_rgb; } } LIBYUV_API void MergeRGBPlane(const uint8_t* src_r, int src_stride_r, const uint8_t* src_g, int src_stride_g, const uint8_t* src_b, int src_stride_b, uint8_t* dst_rgb, int dst_stride_rgb, int width, int height) { int y; void (*MergeRGBRow)(const uint8_t* src_r, const uint8_t* src_g, const uint8_t* src_b, uint8_t* dst_rgb, int width) = MergeRGBRow_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_rgb = dst_rgb + (height - 1) * dst_stride_rgb; dst_stride_rgb = -dst_stride_rgb; } if (src_stride_r == width && src_stride_g == width && src_stride_b == width && dst_stride_rgb == width * 3) { width *= height; height = 1; src_stride_r = src_stride_g = src_stride_b = dst_stride_rgb = 0; } #if defined(HAS_MERGERGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { MergeRGBRow = MergeRGBRow_Any_SSSE3; if (IS_ALIGNED(width, 16)) { MergeRGBRow = MergeRGBRow_SSSE3; } } #endif #if defined(HAS_MERGERGBROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { MergeRGBRow = MergeRGBRow_Any_NEON; if (IS_ALIGNED(width, 16)) { MergeRGBRow = MergeRGBRow_NEON; } } #endif for (y = 0; y < height; ++y) { MergeRGBRow(src_r, src_g, src_b, dst_rgb, width); src_r += src_stride_r; src_g += src_stride_g; src_b += src_stride_b; dst_rgb += dst_stride_rgb; } } LIBYUV_NOINLINE static void SplitARGBPlaneAlpha(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_r, int dst_stride_r, uint8_t* dst_g, int dst_stride_g, uint8_t* dst_b, int dst_stride_b, uint8_t* dst_a, int dst_stride_a, int width, int height) { int y; void (*SplitARGBRow)(const uint8_t* src_rgb, uint8_t* dst_r, uint8_t* dst_g, uint8_t* dst_b, uint8_t* dst_a, int width) = SplitARGBRow_C; assert(height > 0); if (src_stride_argb == width * 4 && dst_stride_r == width && dst_stride_g == width && dst_stride_b == width && dst_stride_a == width) { width *= height; height = 1; src_stride_argb = dst_stride_r = dst_stride_g = dst_stride_b = dst_stride_a = 0; } #if defined(HAS_SPLITARGBROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { SplitARGBRow = SplitARGBRow_Any_SSE2; if (IS_ALIGNED(width, 8)) { SplitARGBRow = SplitARGBRow_SSE2; } } #endif #if defined(HAS_SPLITARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { SplitARGBRow = SplitARGBRow_Any_SSSE3; if (IS_ALIGNED(width, 8)) { SplitARGBRow = SplitARGBRow_SSSE3; } } #endif #if defined(HAS_SPLITARGBROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { SplitARGBRow = SplitARGBRow_Any_AVX2; if (IS_ALIGNED(width, 16)) { SplitARGBRow = SplitARGBRow_AVX2; } } #endif #if defined(HAS_SPLITARGBROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SplitARGBRow = SplitARGBRow_Any_NEON; if (IS_ALIGNED(width, 16)) { SplitARGBRow = SplitARGBRow_NEON; } } #endif for (y = 0; y < height; ++y) { SplitARGBRow(src_argb, dst_r, dst_g, dst_b, dst_a, width); dst_r += dst_stride_r; dst_g += dst_stride_g; dst_b += dst_stride_b; dst_a += dst_stride_a; src_argb += src_stride_argb; } } LIBYUV_NOINLINE static void SplitARGBPlaneOpaque(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_r, int dst_stride_r, uint8_t* dst_g, int dst_stride_g, uint8_t* dst_b, int dst_stride_b, int width, int height) { int y; void (*SplitXRGBRow)(const uint8_t* src_rgb, uint8_t* dst_r, uint8_t* dst_g, uint8_t* dst_b, int width) = SplitXRGBRow_C; assert(height > 0); if (src_stride_argb == width * 4 && dst_stride_r == width && dst_stride_g == width && dst_stride_b == width) { width *= height; height = 1; src_stride_argb = dst_stride_r = dst_stride_g = dst_stride_b = 0; } #if defined(HAS_SPLITXRGBROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { SplitXRGBRow = SplitXRGBRow_Any_SSE2; if (IS_ALIGNED(width, 8)) { SplitXRGBRow = SplitXRGBRow_SSE2; } } #endif #if defined(HAS_SPLITXRGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { SplitXRGBRow = SplitXRGBRow_Any_SSSE3; if (IS_ALIGNED(width, 8)) { SplitXRGBRow = SplitXRGBRow_SSSE3; } } #endif #if defined(HAS_SPLITXRGBROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { SplitXRGBRow = SplitXRGBRow_Any_AVX2; if (IS_ALIGNED(width, 16)) { SplitXRGBRow = SplitXRGBRow_AVX2; } } #endif #if defined(HAS_SPLITXRGBROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SplitXRGBRow = SplitXRGBRow_Any_NEON; if (IS_ALIGNED(width, 16)) { SplitXRGBRow = SplitXRGBRow_NEON; } } #endif for (y = 0; y < height; ++y) { SplitXRGBRow(src_argb, dst_r, dst_g, dst_b, width); dst_r += dst_stride_r; dst_g += dst_stride_g; dst_b += dst_stride_b; src_argb += src_stride_argb; } } LIBYUV_API void SplitARGBPlane(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_r, int dst_stride_r, uint8_t* dst_g, int dst_stride_g, uint8_t* dst_b, int dst_stride_b, uint8_t* dst_a, int dst_stride_a, int width, int height) { if (height < 0) { height = -height; dst_r = dst_r + (height - 1) * dst_stride_r; dst_g = dst_g + (height - 1) * dst_stride_g; dst_b = dst_b + (height - 1) * dst_stride_b; dst_a = dst_a + (height - 1) * dst_stride_a; dst_stride_r = -dst_stride_r; dst_stride_g = -dst_stride_g; dst_stride_b = -dst_stride_b; dst_stride_a = -dst_stride_a; } if (dst_a == NULL) { SplitARGBPlaneOpaque(src_argb, src_stride_argb, dst_r, dst_stride_r, dst_g, dst_stride_g, dst_b, dst_stride_b, width, height); } else { SplitARGBPlaneAlpha(src_argb, src_stride_argb, dst_r, dst_stride_r, dst_g, dst_stride_g, dst_b, dst_stride_b, dst_a, dst_stride_a, width, height); } } LIBYUV_NOINLINE static void MergeARGBPlaneAlpha(const uint8_t* src_r, int src_stride_r, const uint8_t* src_g, int src_stride_g, const uint8_t* src_b, int src_stride_b, const uint8_t* src_a, int src_stride_a, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*MergeARGBRow)(const uint8_t* src_r, const uint8_t* src_g, const uint8_t* src_b, const uint8_t* src_a, uint8_t* dst_argb, int width) = MergeARGBRow_C; assert(height > 0); if (src_stride_r == width && src_stride_g == width && src_stride_b == width && src_stride_a == width && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_r = src_stride_g = src_stride_b = src_stride_a = dst_stride_argb = 0; } #if defined(HAS_MERGEARGBROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { MergeARGBRow = MergeARGBRow_Any_SSE2; if (IS_ALIGNED(width, 8)) { MergeARGBRow = MergeARGBRow_SSE2; } } #endif #if defined(HAS_MERGEARGBROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MergeARGBRow = MergeARGBRow_Any_AVX2; if (IS_ALIGNED(width, 16)) { MergeARGBRow = MergeARGBRow_AVX2; } } #endif #if defined(HAS_MERGEARGBROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { MergeARGBRow = MergeARGBRow_Any_NEON; if (IS_ALIGNED(width, 16)) { MergeARGBRow = MergeARGBRow_NEON; } } #endif for (y = 0; y < height; ++y) { MergeARGBRow(src_r, src_g, src_b, src_a, dst_argb, width); src_r += src_stride_r; src_g += src_stride_g; src_b += src_stride_b; src_a += src_stride_a; dst_argb += dst_stride_argb; } } LIBYUV_NOINLINE static void MergeARGBPlaneOpaque(const uint8_t* src_r, int src_stride_r, const uint8_t* src_g, int src_stride_g, const uint8_t* src_b, int src_stride_b, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*MergeXRGBRow)(const uint8_t* src_r, const uint8_t* src_g, const uint8_t* src_b, uint8_t* dst_argb, int width) = MergeXRGBRow_C; assert(height > 0); if (src_stride_r == width && src_stride_g == width && src_stride_b == width && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_r = src_stride_g = src_stride_b = dst_stride_argb = 0; } #if defined(HAS_MERGEXRGBROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { MergeXRGBRow = MergeXRGBRow_Any_SSE2; if (IS_ALIGNED(width, 8)) { MergeXRGBRow = MergeXRGBRow_SSE2; } } #endif #if defined(HAS_MERGEXRGBROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MergeXRGBRow = MergeXRGBRow_Any_AVX2; if (IS_ALIGNED(width, 16)) { MergeXRGBRow = MergeXRGBRow_AVX2; } } #endif #if defined(HAS_MERGEXRGBROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { MergeXRGBRow = MergeXRGBRow_Any_NEON; if (IS_ALIGNED(width, 16)) { MergeXRGBRow = MergeXRGBRow_NEON; } } #endif for (y = 0; y < height; ++y) { MergeXRGBRow(src_r, src_g, src_b, dst_argb, width); src_r += src_stride_r; src_g += src_stride_g; src_b += src_stride_b; dst_argb += dst_stride_argb; } } LIBYUV_API void MergeARGBPlane(const uint8_t* src_r, int src_stride_r, const uint8_t* src_g, int src_stride_g, const uint8_t* src_b, int src_stride_b, const uint8_t* src_a, int src_stride_a, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { if (height < 0) { height = -height; dst_argb = dst_argb + (height - 1) * dst_stride_argb; dst_stride_argb = -dst_stride_argb; } if (src_a == NULL) { MergeARGBPlaneOpaque(src_r, src_stride_r, src_g, src_stride_g, src_b, src_stride_b, dst_argb, dst_stride_argb, width, height); } else { MergeARGBPlaneAlpha(src_r, src_stride_r, src_g, src_stride_g, src_b, src_stride_b, src_a, src_stride_a, dst_argb, dst_stride_argb, width, height); } } LIBYUV_API void MergeXR30Plane(const uint16_t* src_r, int src_stride_r, const uint16_t* src_g, int src_stride_g, const uint16_t* src_b, int src_stride_b, uint8_t* dst_ar30, int dst_stride_ar30, int width, int height, int depth) { int y; void (*MergeXR30Row)(const uint16_t* src_r, const uint16_t* src_g, const uint16_t* src_b, uint8_t* dst_ar30, int depth, int width) = MergeXR30Row_C; if (height < 0) { height = -height; dst_ar30 = dst_ar30 + (height - 1) * dst_stride_ar30; dst_stride_ar30 = -dst_stride_ar30; } if (src_stride_r == width && src_stride_g == width && src_stride_b == width && dst_stride_ar30 == width * 4) { width *= height; height = 1; src_stride_r = src_stride_g = src_stride_b = dst_stride_ar30 = 0; } #if defined(HAS_MERGEXR30ROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MergeXR30Row = MergeXR30Row_Any_AVX2; if (IS_ALIGNED(width, 16)) { MergeXR30Row = MergeXR30Row_AVX2; } } #endif #if defined(HAS_MERGEXR30ROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { if (depth == 10) { MergeXR30Row = MergeXR30Row_10_Any_NEON; if (IS_ALIGNED(width, 8)) { MergeXR30Row = MergeXR30Row_10_NEON; } } else { MergeXR30Row = MergeXR30Row_Any_NEON; if (IS_ALIGNED(width, 8)) { MergeXR30Row = MergeXR30Row_NEON; } } } #endif for (y = 0; y < height; ++y) { MergeXR30Row(src_r, src_g, src_b, dst_ar30, depth, width); src_r += src_stride_r; src_g += src_stride_g; src_b += src_stride_b; dst_ar30 += dst_stride_ar30; } } LIBYUV_NOINLINE static void MergeAR64PlaneAlpha(const uint16_t* src_r, int src_stride_r, const uint16_t* src_g, int src_stride_g, const uint16_t* src_b, int src_stride_b, const uint16_t* src_a, int src_stride_a, uint16_t* dst_ar64, int dst_stride_ar64, int width, int height, int depth) { int y; void (*MergeAR64Row)(const uint16_t* src_r, const uint16_t* src_g, const uint16_t* src_b, const uint16_t* src_a, uint16_t* dst_argb, int depth, int width) = MergeAR64Row_C; if (src_stride_r == width && src_stride_g == width && src_stride_b == width && src_stride_a == width && dst_stride_ar64 == width * 4) { width *= height; height = 1; src_stride_r = src_stride_g = src_stride_b = src_stride_a = dst_stride_ar64 = 0; } #if defined(HAS_MERGEAR64ROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MergeAR64Row = MergeAR64Row_Any_AVX2; if (IS_ALIGNED(width, 16)) { MergeAR64Row = MergeAR64Row_AVX2; } } #endif #if defined(HAS_MERGEAR64ROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { MergeAR64Row = MergeAR64Row_Any_NEON; if (IS_ALIGNED(width, 8)) { MergeAR64Row = MergeAR64Row_NEON; } } #endif for (y = 0; y < height; ++y) { MergeAR64Row(src_r, src_g, src_b, src_a, dst_ar64, depth, width); src_r += src_stride_r; src_g += src_stride_g; src_b += src_stride_b; src_a += src_stride_a; dst_ar64 += dst_stride_ar64; } } LIBYUV_NOINLINE static void MergeAR64PlaneOpaque(const uint16_t* src_r, int src_stride_r, const uint16_t* src_g, int src_stride_g, const uint16_t* src_b, int src_stride_b, uint16_t* dst_ar64, int dst_stride_ar64, int width, int height, int depth) { int y; void (*MergeXR64Row)(const uint16_t* src_r, const uint16_t* src_g, const uint16_t* src_b, uint16_t* dst_argb, int depth, int width) = MergeXR64Row_C; if (src_stride_r == width && src_stride_g == width && src_stride_b == width && dst_stride_ar64 == width * 4) { width *= height; height = 1; src_stride_r = src_stride_g = src_stride_b = dst_stride_ar64 = 0; } #if defined(HAS_MERGEXR64ROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MergeXR64Row = MergeXR64Row_Any_AVX2; if (IS_ALIGNED(width, 16)) { MergeXR64Row = MergeXR64Row_AVX2; } } #endif #if defined(HAS_MERGEXR64ROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { MergeXR64Row = MergeXR64Row_Any_NEON; if (IS_ALIGNED(width, 8)) { MergeXR64Row = MergeXR64Row_NEON; } } #endif for (y = 0; y < height; ++y) { MergeXR64Row(src_r, src_g, src_b, dst_ar64, depth, width); src_r += src_stride_r; src_g += src_stride_g; src_b += src_stride_b; dst_ar64 += dst_stride_ar64; } } LIBYUV_API void MergeAR64Plane(const uint16_t* src_r, int src_stride_r, const uint16_t* src_g, int src_stride_g, const uint16_t* src_b, int src_stride_b, const uint16_t* src_a, int src_stride_a, uint16_t* dst_ar64, int dst_stride_ar64, int width, int height, int depth) { if (height < 0) { height = -height; dst_ar64 = dst_ar64 + (height - 1) * dst_stride_ar64; dst_stride_ar64 = -dst_stride_ar64; } if (src_a == NULL) { MergeAR64PlaneOpaque(src_r, src_stride_r, src_g, src_stride_g, src_b, src_stride_b, dst_ar64, dst_stride_ar64, width, height, depth); } else { MergeAR64PlaneAlpha(src_r, src_stride_r, src_g, src_stride_g, src_b, src_stride_b, src_a, src_stride_a, dst_ar64, dst_stride_ar64, width, height, depth); } } LIBYUV_NOINLINE static void MergeARGB16To8PlaneAlpha(const uint16_t* src_r, int src_stride_r, const uint16_t* src_g, int src_stride_g, const uint16_t* src_b, int src_stride_b, const uint16_t* src_a, int src_stride_a, uint8_t* dst_argb, int dst_stride_argb, int width, int height, int depth) { int y; void (*MergeARGB16To8Row)(const uint16_t* src_r, const uint16_t* src_g, const uint16_t* src_b, const uint16_t* src_a, uint8_t* dst_argb, int depth, int width) = MergeARGB16To8Row_C; if (src_stride_r == width && src_stride_g == width && src_stride_b == width && src_stride_a == width && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_r = src_stride_g = src_stride_b = src_stride_a = dst_stride_argb = 0; } #if defined(HAS_MERGEARGB16TO8ROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MergeARGB16To8Row = MergeARGB16To8Row_Any_AVX2; if (IS_ALIGNED(width, 16)) { MergeARGB16To8Row = MergeARGB16To8Row_AVX2; } } #endif #if defined(HAS_MERGEARGB16TO8ROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { MergeARGB16To8Row = MergeARGB16To8Row_Any_NEON; if (IS_ALIGNED(width, 8)) { MergeARGB16To8Row = MergeARGB16To8Row_NEON; } } #endif for (y = 0; y < height; ++y) { MergeARGB16To8Row(src_r, src_g, src_b, src_a, dst_argb, depth, width); src_r += src_stride_r; src_g += src_stride_g; src_b += src_stride_b; src_a += src_stride_a; dst_argb += dst_stride_argb; } } LIBYUV_NOINLINE static void MergeARGB16To8PlaneOpaque(const uint16_t* src_r, int src_stride_r, const uint16_t* src_g, int src_stride_g, const uint16_t* src_b, int src_stride_b, uint8_t* dst_argb, int dst_stride_argb, int width, int height, int depth) { int y; void (*MergeXRGB16To8Row)(const uint16_t* src_r, const uint16_t* src_g, const uint16_t* src_b, uint8_t* dst_argb, int depth, int width) = MergeXRGB16To8Row_C; if (src_stride_r == width && src_stride_g == width && src_stride_b == width && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_r = src_stride_g = src_stride_b = dst_stride_argb = 0; } #if defined(HAS_MERGEXRGB16TO8ROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MergeXRGB16To8Row = MergeXRGB16To8Row_Any_AVX2; if (IS_ALIGNED(width, 16)) { MergeXRGB16To8Row = MergeXRGB16To8Row_AVX2; } } #endif #if defined(HAS_MERGEXRGB16TO8ROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { MergeXRGB16To8Row = MergeXRGB16To8Row_Any_NEON; if (IS_ALIGNED(width, 8)) { MergeXRGB16To8Row = MergeXRGB16To8Row_NEON; } } #endif for (y = 0; y < height; ++y) { MergeXRGB16To8Row(src_r, src_g, src_b, dst_argb, depth, width); src_r += src_stride_r; src_g += src_stride_g; src_b += src_stride_b; dst_argb += dst_stride_argb; } } LIBYUV_API void MergeARGB16To8Plane(const uint16_t* src_r, int src_stride_r, const uint16_t* src_g, int src_stride_g, const uint16_t* src_b, int src_stride_b, const uint16_t* src_a, int src_stride_a, uint8_t* dst_argb, int dst_stride_argb, int width, int height, int depth) { if (height < 0) { height = -height; dst_argb = dst_argb + (height - 1) * dst_stride_argb; dst_stride_argb = -dst_stride_argb; } if (src_a == NULL) { MergeARGB16To8PlaneOpaque(src_r, src_stride_r, src_g, src_stride_g, src_b, src_stride_b, dst_argb, dst_stride_argb, width, height, depth); } else { MergeARGB16To8PlaneAlpha(src_r, src_stride_r, src_g, src_stride_g, src_b, src_stride_b, src_a, src_stride_a, dst_argb, dst_stride_argb, width, height, depth); } } LIBYUV_API int YUY2ToI422(const uint8_t* src_yuy2, int src_stride_yuy2, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height) { int y; void (*YUY2ToUV422Row)(const uint8_t* src_yuy2, uint8_t* dst_u, uint8_t* dst_v, int width) = YUY2ToUV422Row_C; void (*YUY2ToYRow)(const uint8_t* src_yuy2, uint8_t* dst_y, int width) = YUY2ToYRow_C; if (!src_yuy2 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2; src_stride_yuy2 = -src_stride_yuy2; } if (src_stride_yuy2 == width * 2 && dst_stride_y == width && dst_stride_u * 2 == width && dst_stride_v * 2 == width && width * height <= 32768) { width *= height; height = 1; src_stride_yuy2 = dst_stride_y = dst_stride_u = dst_stride_v = 0; } #if defined(HAS_YUY2TOYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { YUY2ToUV422Row = YUY2ToUV422Row_Any_SSE2; YUY2ToYRow = YUY2ToYRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { YUY2ToUV422Row = YUY2ToUV422Row_SSE2; YUY2ToYRow = YUY2ToYRow_SSE2; } } #endif #if defined(HAS_YUY2TOYROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { YUY2ToUV422Row = YUY2ToUV422Row_Any_AVX2; YUY2ToYRow = YUY2ToYRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { YUY2ToUV422Row = YUY2ToUV422Row_AVX2; YUY2ToYRow = YUY2ToYRow_AVX2; } } #endif #if defined(HAS_YUY2TOYROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { YUY2ToYRow = YUY2ToYRow_Any_NEON; YUY2ToUV422Row = YUY2ToUV422Row_Any_NEON; if (IS_ALIGNED(width, 16)) { YUY2ToYRow = YUY2ToYRow_NEON; YUY2ToUV422Row = YUY2ToUV422Row_NEON; } } #endif #if defined(HAS_YUY2TOYROW_MSA) && defined(HAS_YUY2TOUV422ROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { YUY2ToYRow = YUY2ToYRow_Any_MSA; YUY2ToUV422Row = YUY2ToUV422Row_Any_MSA; if (IS_ALIGNED(width, 32)) { YUY2ToYRow = YUY2ToYRow_MSA; YUY2ToUV422Row = YUY2ToUV422Row_MSA; } } #endif #if defined(HAS_YUY2TOYROW_LASX) && defined(HAS_YUY2TOUV422ROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { YUY2ToYRow = YUY2ToYRow_Any_LASX; YUY2ToUV422Row = YUY2ToUV422Row_Any_LASX; if (IS_ALIGNED(width, 32)) { YUY2ToYRow = YUY2ToYRow_LASX; YUY2ToUV422Row = YUY2ToUV422Row_LASX; } } #endif for (y = 0; y < height; ++y) { YUY2ToUV422Row(src_yuy2, dst_u, dst_v, width); YUY2ToYRow(src_yuy2, dst_y, width); src_yuy2 += src_stride_yuy2; dst_y += dst_stride_y; dst_u += dst_stride_u; dst_v += dst_stride_v; } return 0; } LIBYUV_API int UYVYToI422(const uint8_t* src_uyvy, int src_stride_uyvy, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height) { int y; void (*UYVYToUV422Row)(const uint8_t* src_uyvy, uint8_t* dst_u, uint8_t* dst_v, int width) = UYVYToUV422Row_C; void (*UYVYToYRow)(const uint8_t* src_uyvy, uint8_t* dst_y, int width) = UYVYToYRow_C; if (!src_uyvy || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy; src_stride_uyvy = -src_stride_uyvy; } if (src_stride_uyvy == width * 2 && dst_stride_y == width && dst_stride_u * 2 == width && dst_stride_v * 2 == width && width * height <= 32768) { width *= height; height = 1; src_stride_uyvy = dst_stride_y = dst_stride_u = dst_stride_v = 0; } #if defined(HAS_UYVYTOYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { UYVYToUV422Row = UYVYToUV422Row_Any_SSE2; UYVYToYRow = UYVYToYRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { UYVYToUV422Row = UYVYToUV422Row_SSE2; UYVYToYRow = UYVYToYRow_SSE2; } } #endif #if defined(HAS_UYVYTOYROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { UYVYToUV422Row = UYVYToUV422Row_Any_AVX2; UYVYToYRow = UYVYToYRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { UYVYToUV422Row = UYVYToUV422Row_AVX2; UYVYToYRow = UYVYToYRow_AVX2; } } #endif #if defined(HAS_UYVYTOYROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { UYVYToYRow = UYVYToYRow_Any_NEON; UYVYToUV422Row = UYVYToUV422Row_Any_NEON; if (IS_ALIGNED(width, 16)) { UYVYToYRow = UYVYToYRow_NEON; UYVYToUV422Row = UYVYToUV422Row_NEON; } } #endif #if defined(HAS_UYVYTOYROW_MSA) && defined(HAS_UYVYTOUV422ROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { UYVYToYRow = UYVYToYRow_Any_MSA; UYVYToUV422Row = UYVYToUV422Row_Any_MSA; if (IS_ALIGNED(width, 32)) { UYVYToYRow = UYVYToYRow_MSA; UYVYToUV422Row = UYVYToUV422Row_MSA; } } #endif #if defined(HAS_UYVYTOYROW_LASX) && defined(HAS_UYVYTOUV422ROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { UYVYToYRow = UYVYToYRow_Any_LASX; UYVYToUV422Row = UYVYToUV422Row_Any_LASX; if (IS_ALIGNED(width, 32)) { UYVYToYRow = UYVYToYRow_LASX; UYVYToUV422Row = UYVYToUV422Row_LASX; } } #endif for (y = 0; y < height; ++y) { UYVYToUV422Row(src_uyvy, dst_u, dst_v, width); UYVYToYRow(src_uyvy, dst_y, width); src_uyvy += src_stride_uyvy; dst_y += dst_stride_y; dst_u += dst_stride_u; dst_v += dst_stride_v; } return 0; } LIBYUV_API int YUY2ToY(const uint8_t* src_yuy2, int src_stride_yuy2, uint8_t* dst_y, int dst_stride_y, int width, int height) { int y; void (*YUY2ToYRow)(const uint8_t* src_yuy2, uint8_t* dst_y, int width) = YUY2ToYRow_C; if (!src_yuy2 || !dst_y || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2; src_stride_yuy2 = -src_stride_yuy2; } if (src_stride_yuy2 == width * 2 && dst_stride_y == width) { width *= height; height = 1; src_stride_yuy2 = dst_stride_y = 0; } #if defined(HAS_YUY2TOYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { YUY2ToYRow = YUY2ToYRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { YUY2ToYRow = YUY2ToYRow_SSE2; } } #endif #if defined(HAS_YUY2TOYROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { YUY2ToYRow = YUY2ToYRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { YUY2ToYRow = YUY2ToYRow_AVX2; } } #endif #if defined(HAS_YUY2TOYROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { YUY2ToYRow = YUY2ToYRow_Any_NEON; if (IS_ALIGNED(width, 16)) { YUY2ToYRow = YUY2ToYRow_NEON; } } #endif #if defined(HAS_YUY2TOYROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { YUY2ToYRow = YUY2ToYRow_Any_MSA; if (IS_ALIGNED(width, 32)) { YUY2ToYRow = YUY2ToYRow_MSA; } } #endif for (y = 0; y < height; ++y) { YUY2ToYRow(src_yuy2, dst_y, width); src_yuy2 += src_stride_yuy2; dst_y += dst_stride_y; } return 0; } LIBYUV_API int UYVYToY(const uint8_t* src_uyvy, int src_stride_uyvy, uint8_t* dst_y, int dst_stride_y, int width, int height) { int y; void (*UYVYToYRow)(const uint8_t* src_uyvy, uint8_t* dst_y, int width) = UYVYToYRow_C; if (!src_uyvy || !dst_y || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy; src_stride_uyvy = -src_stride_uyvy; } if (src_stride_uyvy == width * 2 && dst_stride_y == width) { width *= height; height = 1; src_stride_uyvy = dst_stride_y = 0; } #if defined(HAS_UYVYTOYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { UYVYToYRow = UYVYToYRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { UYVYToYRow = UYVYToYRow_SSE2; } } #endif #if defined(HAS_UYVYTOYROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { UYVYToYRow = UYVYToYRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { UYVYToYRow = UYVYToYRow_AVX2; } } #endif #if defined(HAS_UYVYTOYROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { UYVYToYRow = UYVYToYRow_Any_NEON; if (IS_ALIGNED(width, 16)) { UYVYToYRow = UYVYToYRow_NEON; } } #endif #if defined(HAS_UYVYTOYROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { UYVYToYRow = UYVYToYRow_Any_MSA; if (IS_ALIGNED(width, 32)) { UYVYToYRow = UYVYToYRow_MSA; } } #endif for (y = 0; y < height; ++y) { UYVYToYRow(src_uyvy, dst_y, width); src_uyvy += src_stride_uyvy; dst_y += dst_stride_y; } return 0; } LIBYUV_API void MirrorPlane(const uint8_t* src_y, int src_stride_y, uint8_t* dst_y, int dst_stride_y, int width, int height) { int y; void (*MirrorRow)(const uint8_t* src, uint8_t* dst, int width) = MirrorRow_C; if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; src_stride_y = -src_stride_y; } #if defined(HAS_MIRRORROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { MirrorRow = MirrorRow_Any_NEON; if (IS_ALIGNED(width, 32)) { MirrorRow = MirrorRow_NEON; } } #endif #if defined(HAS_MIRRORROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { MirrorRow = MirrorRow_Any_SSSE3; if (IS_ALIGNED(width, 16)) { MirrorRow = MirrorRow_SSSE3; } } #endif #if defined(HAS_MIRRORROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MirrorRow = MirrorRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { MirrorRow = MirrorRow_AVX2; } } #endif #if defined(HAS_MIRRORROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { MirrorRow = MirrorRow_Any_MSA; if (IS_ALIGNED(width, 64)) { MirrorRow = MirrorRow_MSA; } } #endif #if defined(HAS_MIRRORROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { MirrorRow = MirrorRow_Any_LASX; if (IS_ALIGNED(width, 64)) { MirrorRow = MirrorRow_LASX; } } #endif for (y = 0; y < height; ++y) { MirrorRow(src_y, dst_y, width); src_y += src_stride_y; dst_y += dst_stride_y; } } LIBYUV_API void MirrorUVPlane(const uint8_t* src_uv, int src_stride_uv, uint8_t* dst_uv, int dst_stride_uv, int width, int height) { int y; void (*MirrorUVRow)(const uint8_t* src, uint8_t* dst, int width) = MirrorUVRow_C; if (height < 0) { height = -height; src_uv = src_uv + (height - 1) * src_stride_uv; src_stride_uv = -src_stride_uv; } #if defined(HAS_MIRRORUVROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { MirrorUVRow = MirrorUVRow_Any_NEON; if (IS_ALIGNED(width, 32)) { MirrorUVRow = MirrorUVRow_NEON; } } #endif #if defined(HAS_MIRRORUVROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { MirrorUVRow = MirrorUVRow_Any_SSSE3; if (IS_ALIGNED(width, 8)) { MirrorUVRow = MirrorUVRow_SSSE3; } } #endif #if defined(HAS_MIRRORUVROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { MirrorUVRow = MirrorUVRow_Any_AVX2; if (IS_ALIGNED(width, 16)) { MirrorUVRow = MirrorUVRow_AVX2; } } #endif #if defined(HAS_MIRRORUVROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { MirrorUVRow = MirrorUVRow_Any_MSA; if (IS_ALIGNED(width, 8)) { MirrorUVRow = MirrorUVRow_MSA; } } #endif #if defined(HAS_MIRRORUVROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { MirrorUVRow = MirrorUVRow_Any_LASX; if (IS_ALIGNED(width, 16)) { MirrorUVRow = MirrorUVRow_LASX; } } #endif for (y = 0; y < height; ++y) { MirrorUVRow(src_uv, dst_uv, width); src_uv += src_stride_uv; dst_uv += dst_stride_uv; } } LIBYUV_API int I400Mirror(const uint8_t* src_y, int src_stride_y, uint8_t* dst_y, int dst_stride_y, int width, int height) { if (!src_y || !dst_y || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; src_stride_y = -src_stride_y; } MirrorPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); return 0; } LIBYUV_API int I420Mirror(const uint8_t* src_y, int src_stride_y, const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height) { int halfwidth = (width + 1) >> 1; int halfheight = (height + 1) >> 1; if (!src_y || !src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; halfheight = (height + 1) >> 1; src_y = src_y + (height - 1) * src_stride_y; src_u = src_u + (halfheight - 1) * src_stride_u; src_v = src_v + (halfheight - 1) * src_stride_v; src_stride_y = -src_stride_y; src_stride_u = -src_stride_u; src_stride_v = -src_stride_v; } if (dst_y) { MirrorPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); } MirrorPlane(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, halfheight); MirrorPlane(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, halfheight); return 0; } LIBYUV_API int NV12Mirror(const uint8_t* src_y, int src_stride_y, const uint8_t* src_uv, int src_stride_uv, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_uv, int dst_stride_uv, int width, int height) { int halfwidth = (width + 1) >> 1; int halfheight = (height + 1) >> 1; if (!src_y || !src_uv || !dst_uv || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; halfheight = (height + 1) >> 1; src_y = src_y + (height - 1) * src_stride_y; src_uv = src_uv + (halfheight - 1) * src_stride_uv; src_stride_y = -src_stride_y; src_stride_uv = -src_stride_uv; } if (dst_y) { MirrorPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); } MirrorUVPlane(src_uv, src_stride_uv, dst_uv, dst_stride_uv, halfwidth, halfheight); return 0; } LIBYUV_API int ARGBMirror(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*ARGBMirrorRow)(const uint8_t* src, uint8_t* dst, int width) = ARGBMirrorRow_C; if (!src_argb || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } #if defined(HAS_ARGBMIRRORROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ARGBMirrorRow = ARGBMirrorRow_Any_NEON; if (IS_ALIGNED(width, 8)) { ARGBMirrorRow = ARGBMirrorRow_NEON; } } #endif #if defined(HAS_ARGBMIRRORROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ARGBMirrorRow = ARGBMirrorRow_Any_SSE2; if (IS_ALIGNED(width, 4)) { ARGBMirrorRow = ARGBMirrorRow_SSE2; } } #endif #if defined(HAS_ARGBMIRRORROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBMirrorRow = ARGBMirrorRow_Any_AVX2; if (IS_ALIGNED(width, 8)) { ARGBMirrorRow = ARGBMirrorRow_AVX2; } } #endif #if defined(HAS_ARGBMIRRORROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { ARGBMirrorRow = ARGBMirrorRow_Any_MSA; if (IS_ALIGNED(width, 16)) { ARGBMirrorRow = ARGBMirrorRow_MSA; } } #endif #if defined(HAS_ARGBMIRRORROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { ARGBMirrorRow = ARGBMirrorRow_Any_LASX; if (IS_ALIGNED(width, 16)) { ARGBMirrorRow = ARGBMirrorRow_LASX; } } #endif for (y = 0; y < height; ++y) { ARGBMirrorRow(src_argb, dst_argb, width); src_argb += src_stride_argb; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int RGB24Mirror(const uint8_t* src_rgb24, int src_stride_rgb24, uint8_t* dst_rgb24, int dst_stride_rgb24, int width, int height) { int y; void (*RGB24MirrorRow)(const uint8_t* src, uint8_t* dst, int width) = RGB24MirrorRow_C; if (!src_rgb24 || !dst_rgb24 || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_rgb24 = src_rgb24 + (height - 1) * src_stride_rgb24; src_stride_rgb24 = -src_stride_rgb24; } #if defined(HAS_RGB24MIRRORROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { RGB24MirrorRow = RGB24MirrorRow_Any_NEON; if (IS_ALIGNED(width, 16)) { RGB24MirrorRow = RGB24MirrorRow_NEON; } } #endif #if defined(HAS_RGB24MIRRORROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { RGB24MirrorRow = RGB24MirrorRow_Any_SSSE3; if (IS_ALIGNED(width, 16)) { RGB24MirrorRow = RGB24MirrorRow_SSSE3; } } #endif for (y = 0; y < height; ++y) { RGB24MirrorRow(src_rgb24, dst_rgb24, width); src_rgb24 += src_stride_rgb24; dst_rgb24 += dst_stride_rgb24; } return 0; } LIBYUV_API ARGBBlendRow GetARGBBlend() { void (*ARGBBlendRow)(const uint8_t* src_argb, const uint8_t* src_argb1, uint8_t* dst_argb, int width) = ARGBBlendRow_C; #if defined(HAS_ARGBBLENDROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { ARGBBlendRow = ARGBBlendRow_SSSE3; return ARGBBlendRow; } #endif #if defined(HAS_ARGBBLENDROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ARGBBlendRow = ARGBBlendRow_NEON; } #endif #if defined(HAS_ARGBBLENDROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { ARGBBlendRow = ARGBBlendRow_MSA; } #endif #if defined(HAS_ARGBBLENDROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { ARGBBlendRow = ARGBBlendRow_LSX; } #endif return ARGBBlendRow; } LIBYUV_API int ARGBBlend(const uint8_t* src_argb0, int src_stride_argb0, const uint8_t* src_argb1, int src_stride_argb1, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*ARGBBlendRow)(const uint8_t* src_argb, const uint8_t* src_argb1, uint8_t* dst_argb, int width) = GetARGBBlend(); if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; dst_argb = dst_argb + (height - 1) * dst_stride_argb; dst_stride_argb = -dst_stride_argb; } if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0; } for (y = 0; y < height; ++y) { ARGBBlendRow(src_argb0, src_argb1, dst_argb, width); src_argb0 += src_stride_argb0; src_argb1 += src_stride_argb1; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int BlendPlane(const uint8_t* src_y0, int src_stride_y0, const uint8_t* src_y1, int src_stride_y1, const uint8_t* alpha, int alpha_stride, uint8_t* dst_y, int dst_stride_y, int width, int height) { int y; void (*BlendPlaneRow)(const uint8_t* src0, const uint8_t* src1, const uint8_t* alpha, uint8_t* dst, int width) = BlendPlaneRow_C; if (!src_y0 || !src_y1 || !alpha || !dst_y || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; dst_stride_y = -dst_stride_y; } if (src_stride_y0 == width && src_stride_y1 == width && alpha_stride == width && dst_stride_y == width) { width *= height; height = 1; src_stride_y0 = src_stride_y1 = alpha_stride = dst_stride_y = 0; } #if defined(HAS_BLENDPLANEROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { BlendPlaneRow = BlendPlaneRow_Any_SSSE3; if (IS_ALIGNED(width, 8)) { BlendPlaneRow = BlendPlaneRow_SSSE3; } } #endif #if defined(HAS_BLENDPLANEROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { BlendPlaneRow = BlendPlaneRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { BlendPlaneRow = BlendPlaneRow_AVX2; } } #endif for (y = 0; y < height; ++y) { BlendPlaneRow(src_y0, src_y1, alpha, dst_y, width); src_y0 += src_stride_y0; src_y1 += src_stride_y1; alpha += alpha_stride; dst_y += dst_stride_y; } return 0; } #define MAXTWIDTH 2048 LIBYUV_API int I420Blend(const uint8_t* src_y0, int src_stride_y0, const uint8_t* src_u0, int src_stride_u0, const uint8_t* src_v0, int src_stride_v0, const uint8_t* src_y1, int src_stride_y1, const uint8_t* src_u1, int src_stride_u1, const uint8_t* src_v1, int src_stride_v1, const uint8_t* alpha, int alpha_stride, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height) { int y; int halfwidth = (width + 1) >> 1; void (*BlendPlaneRow)(const uint8_t* src0, const uint8_t* src1, const uint8_t* alpha, uint8_t* dst, int width) = BlendPlaneRow_C; void (*ScaleRowDown2)(const uint8_t* src_ptr, ptrdiff_t src_stride, uint8_t* dst_ptr, int dst_width) = ScaleRowDown2Box_C; if (!src_y0 || !src_u0 || !src_v0 || !src_y1 || !src_u1 || !src_v1 || !alpha || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; dst_stride_y = -dst_stride_y; } BlendPlane(src_y0, src_stride_y0, src_y1, src_stride_y1, alpha, alpha_stride, dst_y, dst_stride_y, width, height); #if defined(HAS_BLENDPLANEROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { BlendPlaneRow = BlendPlaneRow_Any_SSSE3; if (IS_ALIGNED(halfwidth, 8)) { BlendPlaneRow = BlendPlaneRow_SSSE3; } } #endif #if defined(HAS_BLENDPLANEROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { BlendPlaneRow = BlendPlaneRow_Any_AVX2; if (IS_ALIGNED(halfwidth, 32)) { BlendPlaneRow = BlendPlaneRow_AVX2; } } #endif if (!IS_ALIGNED(width, 2)) { ScaleRowDown2 = ScaleRowDown2Box_Odd_C; } #if defined(HAS_SCALEROWDOWN2_NEON) if (TestCpuFlag(kCpuHasNEON)) { ScaleRowDown2 = ScaleRowDown2Box_Odd_NEON; if (IS_ALIGNED(width, 2)) { ScaleRowDown2 = ScaleRowDown2Box_Any_NEON; if (IS_ALIGNED(halfwidth, 16)) { ScaleRowDown2 = ScaleRowDown2Box_NEON; } } } #endif #if defined(HAS_SCALEROWDOWN2_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { ScaleRowDown2 = ScaleRowDown2Box_Odd_SSSE3; if (IS_ALIGNED(width, 2)) { ScaleRowDown2 = ScaleRowDown2Box_Any_SSSE3; if (IS_ALIGNED(halfwidth, 16)) { ScaleRowDown2 = ScaleRowDown2Box_SSSE3; } } } #endif #if defined(HAS_SCALEROWDOWN2_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ScaleRowDown2 = ScaleRowDown2Box_Odd_AVX2; if (IS_ALIGNED(width, 2)) { ScaleRowDown2 = ScaleRowDown2Box_Any_AVX2; if (IS_ALIGNED(halfwidth, 32)) { ScaleRowDown2 = ScaleRowDown2Box_AVX2; } } } #endif align_buffer_64(halfalpha, halfwidth); for (y = 0; y < height; y += 2) { if (y == (height - 1)) { alpha_stride = 0; } ScaleRowDown2(alpha, alpha_stride, halfalpha, halfwidth); alpha += alpha_stride * 2; BlendPlaneRow(src_u0, src_u1, halfalpha, dst_u, halfwidth); BlendPlaneRow(src_v0, src_v1, halfalpha, dst_v, halfwidth); src_u0 += src_stride_u0; src_u1 += src_stride_u1; dst_u += dst_stride_u; src_v0 += src_stride_v0; src_v1 += src_stride_v1; dst_v += dst_stride_v; } free_aligned_buffer_64(halfalpha); return 0; } LIBYUV_API int ARGBMultiply(const uint8_t* src_argb0, int src_stride_argb0, const uint8_t* src_argb1, int src_stride_argb1, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*ARGBMultiplyRow)(const uint8_t* src0, const uint8_t* src1, uint8_t* dst, int width) = ARGBMultiplyRow_C; if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; dst_argb = dst_argb + (height - 1) * dst_stride_argb; dst_stride_argb = -dst_stride_argb; } if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0; } #if defined(HAS_ARGBMULTIPLYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ARGBMultiplyRow = ARGBMultiplyRow_Any_SSE2; if (IS_ALIGNED(width, 4)) { ARGBMultiplyRow = ARGBMultiplyRow_SSE2; } } #endif #if defined(HAS_ARGBMULTIPLYROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBMultiplyRow = ARGBMultiplyRow_Any_AVX2; if (IS_ALIGNED(width, 8)) { ARGBMultiplyRow = ARGBMultiplyRow_AVX2; } } #endif #if defined(HAS_ARGBMULTIPLYROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ARGBMultiplyRow = ARGBMultiplyRow_Any_NEON; if (IS_ALIGNED(width, 8)) { ARGBMultiplyRow = ARGBMultiplyRow_NEON; } } #endif #if defined(HAS_ARGBMULTIPLYROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { ARGBMultiplyRow = ARGBMultiplyRow_Any_MSA; if (IS_ALIGNED(width, 4)) { ARGBMultiplyRow = ARGBMultiplyRow_MSA; } } #endif #if defined(HAS_ARGBMULTIPLYROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { ARGBMultiplyRow = ARGBMultiplyRow_Any_LASX; if (IS_ALIGNED(width, 8)) { ARGBMultiplyRow = ARGBMultiplyRow_LASX; } } #endif for (y = 0; y < height; ++y) { ARGBMultiplyRow(src_argb0, src_argb1, dst_argb, width); src_argb0 += src_stride_argb0; src_argb1 += src_stride_argb1; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int ARGBAdd(const uint8_t* src_argb0, int src_stride_argb0, const uint8_t* src_argb1, int src_stride_argb1, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*ARGBAddRow)(const uint8_t* src0, const uint8_t* src1, uint8_t* dst, int width) = ARGBAddRow_C; if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; dst_argb = dst_argb + (height - 1) * dst_stride_argb; dst_stride_argb = -dst_stride_argb; } if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0; } #if defined(HAS_ARGBADDROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ARGBAddRow = ARGBAddRow_SSE2; } #endif #if defined(HAS_ARGBADDROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ARGBAddRow = ARGBAddRow_Any_SSE2; if (IS_ALIGNED(width, 4)) { ARGBAddRow = ARGBAddRow_SSE2; } } #endif #if defined(HAS_ARGBADDROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBAddRow = ARGBAddRow_Any_AVX2; if (IS_ALIGNED(width, 8)) { ARGBAddRow = ARGBAddRow_AVX2; } } #endif #if defined(HAS_ARGBADDROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ARGBAddRow = ARGBAddRow_Any_NEON; if (IS_ALIGNED(width, 8)) { ARGBAddRow = ARGBAddRow_NEON; } } #endif #if defined(HAS_ARGBADDROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { ARGBAddRow = ARGBAddRow_Any_MSA; if (IS_ALIGNED(width, 8)) { ARGBAddRow = ARGBAddRow_MSA; } } #endif #if defined(HAS_ARGBADDROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { ARGBAddRow = ARGBAddRow_Any_LASX; if (IS_ALIGNED(width, 8)) { ARGBAddRow = ARGBAddRow_LASX; } } #endif for (y = 0; y < height; ++y) { ARGBAddRow(src_argb0, src_argb1, dst_argb, width); src_argb0 += src_stride_argb0; src_argb1 += src_stride_argb1; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int ARGBSubtract(const uint8_t* src_argb0, int src_stride_argb0, const uint8_t* src_argb1, int src_stride_argb1, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*ARGBSubtractRow)(const uint8_t* src0, const uint8_t* src1, uint8_t* dst, int width) = ARGBSubtractRow_C; if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; dst_argb = dst_argb + (height - 1) * dst_stride_argb; dst_stride_argb = -dst_stride_argb; } if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0; } #if defined(HAS_ARGBSUBTRACTROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ARGBSubtractRow = ARGBSubtractRow_Any_SSE2; if (IS_ALIGNED(width, 4)) { ARGBSubtractRow = ARGBSubtractRow_SSE2; } } #endif #if defined(HAS_ARGBSUBTRACTROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBSubtractRow = ARGBSubtractRow_Any_AVX2; if (IS_ALIGNED(width, 8)) { ARGBSubtractRow = ARGBSubtractRow_AVX2; } } #endif #if defined(HAS_ARGBSUBTRACTROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ARGBSubtractRow = ARGBSubtractRow_Any_NEON; if (IS_ALIGNED(width, 8)) { ARGBSubtractRow = ARGBSubtractRow_NEON; } } #endif #if defined(HAS_ARGBSUBTRACTROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { ARGBSubtractRow = ARGBSubtractRow_Any_MSA; if (IS_ALIGNED(width, 8)) { ARGBSubtractRow = ARGBSubtractRow_MSA; } } #endif #if defined(HAS_ARGBSUBTRACTROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { ARGBSubtractRow = ARGBSubtractRow_Any_LASX; if (IS_ALIGNED(width, 8)) { ARGBSubtractRow = ARGBSubtractRow_LASX; } } #endif for (y = 0; y < height; ++y) { ARGBSubtractRow(src_argb0, src_argb1, dst_argb, width); src_argb0 += src_stride_argb0; src_argb1 += src_stride_argb1; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int RAWToRGB24(const uint8_t* src_raw, int src_stride_raw, uint8_t* dst_rgb24, int dst_stride_rgb24, int width, int height) { int y; void (*RAWToRGB24Row)(const uint8_t* src_rgb, uint8_t* dst_rgb24, int width) = RAWToRGB24Row_C; if (!src_raw || !dst_rgb24 || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_raw = src_raw + (height - 1) * src_stride_raw; src_stride_raw = -src_stride_raw; } if (src_stride_raw == width * 3 && dst_stride_rgb24 == width * 3) { width *= height; height = 1; src_stride_raw = dst_stride_rgb24 = 0; } #if defined(HAS_RAWTORGB24ROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { RAWToRGB24Row = RAWToRGB24Row_Any_SSSE3; if (IS_ALIGNED(width, 8)) { RAWToRGB24Row = RAWToRGB24Row_SSSE3; } } #endif #if defined(HAS_RAWTORGB24ROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { RAWToRGB24Row = RAWToRGB24Row_Any_NEON; if (IS_ALIGNED(width, 8)) { RAWToRGB24Row = RAWToRGB24Row_NEON; } } #endif #if defined(HAS_RAWTORGB24ROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { RAWToRGB24Row = RAWToRGB24Row_Any_MSA; if (IS_ALIGNED(width, 16)) { RAWToRGB24Row = RAWToRGB24Row_MSA; } } #endif #if defined(HAS_RAWTORGB24ROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { RAWToRGB24Row = RAWToRGB24Row_Any_LSX; if (IS_ALIGNED(width, 16)) { RAWToRGB24Row = RAWToRGB24Row_LSX; } } #endif for (y = 0; y < height; ++y) { RAWToRGB24Row(src_raw, dst_rgb24, width); src_raw += src_stride_raw; dst_rgb24 += dst_stride_rgb24; } return 0; } LIBYUV_API void SetPlane(uint8_t* dst_y, int dst_stride_y, int width, int height, uint32_t value) { int y; void (*SetRow)(uint8_t* dst, uint8_t value, int width) = SetRow_C; if (width <= 0 || height == 0) { return; } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; dst_stride_y = -dst_stride_y; } if (dst_stride_y == width) { width *= height; height = 1; dst_stride_y = 0; } #if defined(HAS_SETROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SetRow = SetRow_Any_NEON; if (IS_ALIGNED(width, 16)) { SetRow = SetRow_NEON; } } #endif #if defined(HAS_SETROW_X86) if (TestCpuFlag(kCpuHasX86)) { SetRow = SetRow_Any_X86; if (IS_ALIGNED(width, 4)) { SetRow = SetRow_X86; } } #endif #if defined(HAS_SETROW_ERMS) if (TestCpuFlag(kCpuHasERMS)) { SetRow = SetRow_ERMS; } #endif #if defined(HAS_SETROW_MSA) if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 16)) { SetRow = SetRow_MSA; } #endif #if defined(HAS_SETROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { SetRow = SetRow_Any_LSX; if (IS_ALIGNED(width, 16)) { SetRow = SetRow_LSX; } } #endif for (y = 0; y < height; ++y) { SetRow(dst_y, (uint8_t)value, width); dst_y += dst_stride_y; } } LIBYUV_API int I420Rect(uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int x, int y, int width, int height, int value_y, int value_u, int value_v) { int halfwidth = (width + 1) >> 1; int halfheight = (height + 1) >> 1; uint8_t* start_y = dst_y + y * dst_stride_y + x; uint8_t* start_u = dst_u + (y / 2) * dst_stride_u + (x / 2); uint8_t* start_v = dst_v + (y / 2) * dst_stride_v + (x / 2); if (!dst_y || !dst_u || !dst_v || width <= 0 || height == 0 || x < 0 || y < 0 || value_y < 0 || value_y > 255 || value_u < 0 || value_u > 255 || value_v < 0 || value_v > 255) { return -1; } SetPlane(start_y, dst_stride_y, width, height, value_y); SetPlane(start_u, dst_stride_u, halfwidth, halfheight, value_u); SetPlane(start_v, dst_stride_v, halfwidth, halfheight, value_v); return 0; } LIBYUV_API int ARGBRect(uint8_t* dst_argb, int dst_stride_argb, int dst_x, int dst_y, int width, int height, uint32_t value) { int y; void (*ARGBSetRow)(uint8_t* dst_argb, uint32_t value, int width) = ARGBSetRow_C; if (!dst_argb || width <= 0 || height == 0 || dst_x < 0 || dst_y < 0) { return -1; } if (height < 0) { height = -height; dst_argb = dst_argb + (height - 1) * dst_stride_argb; dst_stride_argb = -dst_stride_argb; } dst_argb += dst_y * dst_stride_argb + dst_x * 4; if (dst_stride_argb == width * 4) { width *= height; height = 1; dst_stride_argb = 0; } #if defined(HAS_ARGBSETROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ARGBSetRow = ARGBSetRow_Any_NEON; if (IS_ALIGNED(width, 4)) { ARGBSetRow = ARGBSetRow_NEON; } } #endif #if defined(HAS_ARGBSETROW_X86) if (TestCpuFlag(kCpuHasX86)) { ARGBSetRow = ARGBSetRow_X86; } #endif #if defined(HAS_ARGBSETROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { ARGBSetRow = ARGBSetRow_Any_MSA; if (IS_ALIGNED(width, 4)) { ARGBSetRow = ARGBSetRow_MSA; } } #endif #if defined(HAS_ARGBSETROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { ARGBSetRow = ARGBSetRow_Any_LSX; if (IS_ALIGNED(width, 4)) { ARGBSetRow = ARGBSetRow_LSX; } } #endif for (y = 0; y < height; ++y) { ARGBSetRow(dst_argb, value, width); dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int ARGBAttenuate(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*ARGBAttenuateRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width) = ARGBAttenuateRow_C; if (!src_argb || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb = dst_stride_argb = 0; } #if defined(HAS_ARGBATTENUATEROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { ARGBAttenuateRow = ARGBAttenuateRow_Any_SSSE3; if (IS_ALIGNED(width, 4)) { ARGBAttenuateRow = ARGBAttenuateRow_SSSE3; } } #endif #if defined(HAS_ARGBATTENUATEROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBAttenuateRow = ARGBAttenuateRow_Any_AVX2; if (IS_ALIGNED(width, 8)) { ARGBAttenuateRow = ARGBAttenuateRow_AVX2; } } #endif #if defined(HAS_ARGBATTENUATEROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON; if (IS_ALIGNED(width, 8)) { ARGBAttenuateRow = ARGBAttenuateRow_NEON; } } #endif #if defined(HAS_ARGBATTENUATEROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { ARGBAttenuateRow = ARGBAttenuateRow_Any_MSA; if (IS_ALIGNED(width, 8)) { ARGBAttenuateRow = ARGBAttenuateRow_MSA; } } #endif #if defined(HAS_ARGBATTENUATEROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { ARGBAttenuateRow = ARGBAttenuateRow_Any_LASX; if (IS_ALIGNED(width, 16)) { ARGBAttenuateRow = ARGBAttenuateRow_LASX; } } #endif for (y = 0; y < height; ++y) { ARGBAttenuateRow(src_argb, dst_argb, width); src_argb += src_stride_argb; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int ARGBUnattenuate(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*ARGBUnattenuateRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width) = ARGBUnattenuateRow_C; if (!src_argb || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb = dst_stride_argb = 0; } #if defined(HAS_ARGBUNATTENUATEROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ARGBUnattenuateRow = ARGBUnattenuateRow_Any_SSE2; if (IS_ALIGNED(width, 4)) { ARGBUnattenuateRow = ARGBUnattenuateRow_SSE2; } } #endif #if defined(HAS_ARGBUNATTENUATEROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBUnattenuateRow = ARGBUnattenuateRow_Any_AVX2; if (IS_ALIGNED(width, 8)) { ARGBUnattenuateRow = ARGBUnattenuateRow_AVX2; } } #endif for (y = 0; y < height; ++y) { ARGBUnattenuateRow(src_argb, dst_argb, width); src_argb += src_stride_argb; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int ARGBGrayTo(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*ARGBGrayRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width) = ARGBGrayRow_C; if (!src_argb || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb = dst_stride_argb = 0; } #if defined(HAS_ARGBGRAYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8)) { ARGBGrayRow = ARGBGrayRow_SSSE3; } #endif #if defined(HAS_ARGBGRAYROW_NEON) if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) { ARGBGrayRow = ARGBGrayRow_NEON; } #endif #if defined(HAS_ARGBGRAYROW_MSA) if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) { ARGBGrayRow = ARGBGrayRow_MSA; } #endif #if defined(HAS_ARGBGRAYROW_LASX) if (TestCpuFlag(kCpuHasLASX) && IS_ALIGNED(width, 16)) { ARGBGrayRow = ARGBGrayRow_LASX; } #endif for (y = 0; y < height; ++y) { ARGBGrayRow(src_argb, dst_argb, width); src_argb += src_stride_argb; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int ARGBGray(uint8_t* dst_argb, int dst_stride_argb, int dst_x, int dst_y, int width, int height) { int y; void (*ARGBGrayRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width) = ARGBGrayRow_C; uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) { return -1; } if (dst_stride_argb == width * 4) { width *= height; height = 1; dst_stride_argb = 0; } #if defined(HAS_ARGBGRAYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8)) { ARGBGrayRow = ARGBGrayRow_SSSE3; } #endif #if defined(HAS_ARGBGRAYROW_NEON) if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) { ARGBGrayRow = ARGBGrayRow_NEON; } #endif #if defined(HAS_ARGBGRAYROW_MSA) if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) { ARGBGrayRow = ARGBGrayRow_MSA; } #endif #if defined(HAS_ARGBGRAYROW_LASX) if (TestCpuFlag(kCpuHasLASX) && IS_ALIGNED(width, 16)) { ARGBGrayRow = ARGBGrayRow_LASX; } #endif for (y = 0; y < height; ++y) { ARGBGrayRow(dst, dst, width); dst += dst_stride_argb; } return 0; } LIBYUV_API int ARGBSepia(uint8_t* dst_argb, int dst_stride_argb, int dst_x, int dst_y, int width, int height) { int y; void (*ARGBSepiaRow)(uint8_t* dst_argb, int width) = ARGBSepiaRow_C; uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) { return -1; } if (dst_stride_argb == width * 4) { width *= height; height = 1; dst_stride_argb = 0; } #if defined(HAS_ARGBSEPIAROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8)) { ARGBSepiaRow = ARGBSepiaRow_SSSE3; } #endif #if defined(HAS_ARGBSEPIAROW_NEON) if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) { ARGBSepiaRow = ARGBSepiaRow_NEON; } #endif #if defined(HAS_ARGBSEPIAROW_MSA) if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) { ARGBSepiaRow = ARGBSepiaRow_MSA; } #endif #if defined(HAS_ARGBSEPIAROW_LASX) if (TestCpuFlag(kCpuHasLASX) && IS_ALIGNED(width, 16)) { ARGBSepiaRow = ARGBSepiaRow_LASX; } #endif for (y = 0; y < height; ++y) { ARGBSepiaRow(dst, width); dst += dst_stride_argb; } return 0; } LIBYUV_API int ARGBColorMatrix(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, const int8_t* matrix_argb, int width, int height) { int y; void (*ARGBColorMatrixRow)(const uint8_t* src_argb, uint8_t* dst_argb, const int8_t* matrix_argb, int width) = ARGBColorMatrixRow_C; if (!src_argb || !dst_argb || !matrix_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb = dst_stride_argb = 0; } #if defined(HAS_ARGBCOLORMATRIXROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8)) { ARGBColorMatrixRow = ARGBColorMatrixRow_SSSE3; } #endif #if defined(HAS_ARGBCOLORMATRIXROW_NEON) if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) { ARGBColorMatrixRow = ARGBColorMatrixRow_NEON; } #endif #if defined(HAS_ARGBCOLORMATRIXROW_MSA) if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) { ARGBColorMatrixRow = ARGBColorMatrixRow_MSA; } #endif #if defined(HAS_ARGBCOLORMATRIXROW_LSX) if (TestCpuFlag(kCpuHasLSX) && IS_ALIGNED(width, 8)) { ARGBColorMatrixRow = ARGBColorMatrixRow_LSX; } #endif for (y = 0; y < height; ++y) { ARGBColorMatrixRow(src_argb, dst_argb, matrix_argb, width); src_argb += src_stride_argb; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int RGBColorMatrix(uint8_t* dst_argb, int dst_stride_argb, const int8_t* matrix_rgb, int dst_x, int dst_y, int width, int height) { SIMD_ALIGNED(int8_t matrix_argb[16]); uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; if (!dst_argb || !matrix_rgb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) { return -1; } matrix_argb[0] = matrix_rgb[0] / 2; matrix_argb[1] = matrix_rgb[1] / 2; matrix_argb[2] = matrix_rgb[2] / 2; matrix_argb[3] = matrix_rgb[3] / 2; matrix_argb[4] = matrix_rgb[4] / 2; matrix_argb[5] = matrix_rgb[5] / 2; matrix_argb[6] = matrix_rgb[6] / 2; matrix_argb[7] = matrix_rgb[7] / 2; matrix_argb[8] = matrix_rgb[8] / 2; matrix_argb[9] = matrix_rgb[9] / 2; matrix_argb[10] = matrix_rgb[10] / 2; matrix_argb[11] = matrix_rgb[11] / 2; matrix_argb[14] = matrix_argb[13] = matrix_argb[12] = 0; matrix_argb[15] = 64; return ARGBColorMatrix((const uint8_t*)(dst), dst_stride_argb, dst, dst_stride_argb, &matrix_argb[0], width, height); } LIBYUV_API int ARGBColorTable(uint8_t* dst_argb, int dst_stride_argb, const uint8_t* table_argb, int dst_x, int dst_y, int width, int height) { int y; void (*ARGBColorTableRow)(uint8_t* dst_argb, const uint8_t* table_argb, int width) = ARGBColorTableRow_C; uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; if (!dst_argb || !table_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) { return -1; } if (dst_stride_argb == width * 4) { width *= height; height = 1; dst_stride_argb = 0; } #if defined(HAS_ARGBCOLORTABLEROW_X86) if (TestCpuFlag(kCpuHasX86)) { ARGBColorTableRow = ARGBColorTableRow_X86; } #endif for (y = 0; y < height; ++y) { ARGBColorTableRow(dst, table_argb, width); dst += dst_stride_argb; } return 0; } LIBYUV_API int RGBColorTable(uint8_t* dst_argb, int dst_stride_argb, const uint8_t* table_argb, int dst_x, int dst_y, int width, int height) { int y; void (*RGBColorTableRow)(uint8_t* dst_argb, const uint8_t* table_argb, int width) = RGBColorTableRow_C; uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; if (!dst_argb || !table_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) { return -1; } if (dst_stride_argb == width * 4) { width *= height; height = 1; dst_stride_argb = 0; } #if defined(HAS_RGBCOLORTABLEROW_X86) if (TestCpuFlag(kCpuHasX86)) { RGBColorTableRow = RGBColorTableRow_X86; } #endif for (y = 0; y < height; ++y) { RGBColorTableRow(dst, table_argb, width); dst += dst_stride_argb; } return 0; } LIBYUV_API int ARGBQuantize(uint8_t* dst_argb, int dst_stride_argb, int scale, int interval_size, int interval_offset, int dst_x, int dst_y, int width, int height) { int y; void (*ARGBQuantizeRow)(uint8_t* dst_argb, int scale, int interval_size, int interval_offset, int width) = ARGBQuantizeRow_C; uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4; if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0 || interval_size < 1 || interval_size > 255) { return -1; } if (dst_stride_argb == width * 4) { width *= height; height = 1; dst_stride_argb = 0; } #if defined(HAS_ARGBQUANTIZEROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 4)) { ARGBQuantizeRow = ARGBQuantizeRow_SSE2; } #endif #if defined(HAS_ARGBQUANTIZEROW_NEON) if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) { ARGBQuantizeRow = ARGBQuantizeRow_NEON; } #endif #if defined(HAS_ARGBQUANTIZEROW_MSA) if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) { ARGBQuantizeRow = ARGBQuantizeRow_MSA; } #endif #if defined(HAS_ARGBQUANTIZEROW_LSX) if (TestCpuFlag(kCpuHasLSX) && IS_ALIGNED(width, 8)) { ARGBQuantizeRow = ARGBQuantizeRow_LSX; } #endif for (y = 0; y < height; ++y) { ARGBQuantizeRow(dst, scale, interval_size, interval_offset, width); dst += dst_stride_argb; } return 0; } LIBYUV_API int ARGBComputeCumulativeSum(const uint8_t* src_argb, int src_stride_argb, int32_t* dst_cumsum, int dst_stride32_cumsum, int width, int height) { int y; void (*ComputeCumulativeSumRow)(const uint8_t* row, int32_t* cumsum, const int32_t* previous_cumsum, int width) = ComputeCumulativeSumRow_C; int32_t* previous_cumsum = dst_cumsum; if (!dst_cumsum || !src_argb || width <= 0 || height <= 0) { return -1; } #if defined(HAS_CUMULATIVESUMTOAVERAGEROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ComputeCumulativeSumRow = ComputeCumulativeSumRow_SSE2; } #endif memset(dst_cumsum, 0, width * sizeof(dst_cumsum[0]) * 4); for (y = 0; y < height; ++y) { ComputeCumulativeSumRow(src_argb, dst_cumsum, previous_cumsum, width); previous_cumsum = dst_cumsum; dst_cumsum += dst_stride32_cumsum; src_argb += src_stride_argb; } return 0; } LIBYUV_API int ARGBBlur(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, int32_t* dst_cumsum, int dst_stride32_cumsum, int width, int height, int radius) { int y; void (*ComputeCumulativeSumRow)(const uint8_t* row, int32_t* cumsum, const int32_t* previous_cumsum, int width) = ComputeCumulativeSumRow_C; void (*CumulativeSumToAverageRow)( const int32_t* topleft, const int32_t* botleft, int width, int area, uint8_t* dst, int count) = CumulativeSumToAverageRow_C; int32_t* cumsum_bot_row; int32_t* max_cumsum_bot_row; int32_t* cumsum_top_row; if (!src_argb || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } if (radius > height) { radius = height; } if (radius > (width / 2 - 1)) { radius = width / 2 - 1; } if (radius <= 0 || height <= 1) { return -1; } #if defined(HAS_CUMULATIVESUMTOAVERAGEROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ComputeCumulativeSumRow = ComputeCumulativeSumRow_SSE2; CumulativeSumToAverageRow = CumulativeSumToAverageRow_SSE2; } #endif ARGBComputeCumulativeSum(src_argb, src_stride_argb, dst_cumsum, dst_stride32_cumsum, width, radius); src_argb = src_argb + radius * src_stride_argb; cumsum_bot_row = &dst_cumsum[(radius - 1) * dst_stride32_cumsum]; max_cumsum_bot_row = &dst_cumsum[(radius * 2 + 2) * dst_stride32_cumsum]; cumsum_top_row = &dst_cumsum[0]; for (y = 0; y < height; ++y) { int top_y = ((y - radius - 1) >= 0) ? (y - radius - 1) : 0; int bot_y = ((y + radius) < height) ? (y + radius) : (height - 1); int area = radius * (bot_y - top_y); int boxwidth = radius * 4; int x; int n; if (top_y) { cumsum_top_row += dst_stride32_cumsum; if (cumsum_top_row >= max_cumsum_bot_row) { cumsum_top_row = dst_cumsum; } } if ((y + radius) < height) { const int32_t* prev_cumsum_bot_row = cumsum_bot_row; cumsum_bot_row += dst_stride32_cumsum; if (cumsum_bot_row >= max_cumsum_bot_row) { cumsum_bot_row = dst_cumsum; } ComputeCumulativeSumRow(src_argb, cumsum_bot_row, prev_cumsum_bot_row, width); src_argb += src_stride_argb; } for (x = 0; x < radius + 1; ++x) { CumulativeSumToAverageRow(cumsum_top_row, cumsum_bot_row, boxwidth, area, &dst_argb[x * 4], 1); area += (bot_y - top_y); boxwidth += 4; } n = (width - 1) - radius - x + 1; CumulativeSumToAverageRow(cumsum_top_row, cumsum_bot_row, boxwidth, area, &dst_argb[x * 4], n); for (x += n; x <= width - 1; ++x) { area -= (bot_y - top_y); boxwidth -= 4; CumulativeSumToAverageRow(cumsum_top_row + (x - radius - 1) * 4, cumsum_bot_row + (x - radius - 1) * 4, boxwidth, area, &dst_argb[x * 4], 1); } dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int ARGBShade(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, int width, int height, uint32_t value) { int y; void (*ARGBShadeRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width, uint32_t value) = ARGBShadeRow_C; if (!src_argb || !dst_argb || width <= 0 || height == 0 || value == 0u) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb = dst_stride_argb = 0; } #if defined(HAS_ARGBSHADEROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 4)) { ARGBShadeRow = ARGBShadeRow_SSE2; } #endif #if defined(HAS_ARGBSHADEROW_NEON) if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) { ARGBShadeRow = ARGBShadeRow_NEON; } #endif #if defined(HAS_ARGBSHADEROW_MSA) if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 4)) { ARGBShadeRow = ARGBShadeRow_MSA; } #endif #if defined(HAS_ARGBSHADEROW_LASX) if (TestCpuFlag(kCpuHasLASX) && IS_ALIGNED(width, 8)) { ARGBShadeRow = ARGBShadeRow_LASX; } #endif for (y = 0; y < height; ++y) { ARGBShadeRow(src_argb, dst_argb, width, value); src_argb += src_stride_argb; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int InterpolatePlane(const uint8_t* src0, int src_stride0, const uint8_t* src1, int src_stride1, uint8_t* dst, int dst_stride, int width, int height, int interpolation) { int y; void (*InterpolateRow)(uint8_t* dst_ptr, const uint8_t* src_ptr, ptrdiff_t src_stride, int dst_width, int source_y_fraction) = InterpolateRow_C; if (!src0 || !src1 || !dst || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; dst = dst + (height - 1) * dst_stride; dst_stride = -dst_stride; } if (src_stride0 == width && src_stride1 == width && dst_stride == width) { width *= height; height = 1; src_stride0 = src_stride1 = dst_stride = 0; } #if defined(HAS_INTERPOLATEROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { InterpolateRow = InterpolateRow_Any_SSSE3; if (IS_ALIGNED(width, 16)) { InterpolateRow = InterpolateRow_SSSE3; } } #endif #if defined(HAS_INTERPOLATEROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { InterpolateRow = InterpolateRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { InterpolateRow = InterpolateRow_AVX2; } } #endif #if defined(HAS_INTERPOLATEROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { InterpolateRow = InterpolateRow_Any_NEON; if (IS_ALIGNED(width, 16)) { InterpolateRow = InterpolateRow_NEON; } } #endif #if defined(HAS_INTERPOLATEROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { InterpolateRow = InterpolateRow_Any_MSA; if (IS_ALIGNED(width, 32)) { InterpolateRow = InterpolateRow_MSA; } } #endif #if defined(HAS_INTERPOLATEROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { InterpolateRow = InterpolateRow_Any_LSX; if (IS_ALIGNED(width, 32)) { InterpolateRow = InterpolateRow_LSX; } } #endif for (y = 0; y < height; ++y) { InterpolateRow(dst, src0, src1 - src0, width, interpolation); src0 += src_stride0; src1 += src_stride1; dst += dst_stride; } return 0; } LIBYUV_API int InterpolatePlane_16(const uint16_t* src0, int src_stride0, const uint16_t* src1, int src_stride1, uint16_t* dst, int dst_stride, int width, int height, int interpolation) { int y; void (*InterpolateRow_16)(uint16_t* dst_ptr, const uint16_t* src_ptr, ptrdiff_t src_stride, int dst_width, int source_y_fraction) = InterpolateRow_16_C; if (!src0 || !src1 || !dst || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; dst = dst + (height - 1) * dst_stride; dst_stride = -dst_stride; } if (src_stride0 == width && src_stride1 == width && dst_stride == width) { width *= height; height = 1; src_stride0 = src_stride1 = dst_stride = 0; } #if defined(HAS_INTERPOLATEROW_16_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { InterpolateRow_16 = InterpolateRow_16_Any_SSSE3; if (IS_ALIGNED(width, 16)) { InterpolateRow_16 = InterpolateRow_16_SSSE3; } } #endif #if defined(HAS_INTERPOLATEROW_16_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { InterpolateRow_16 = InterpolateRow_16_Any_AVX2; if (IS_ALIGNED(width, 32)) { InterpolateRow_16 = InterpolateRow_16_AVX2; } } #endif #if defined(HAS_INTERPOLATEROW_16_NEON) if (TestCpuFlag(kCpuHasNEON)) { InterpolateRow_16 = InterpolateRow_16_Any_NEON; if (IS_ALIGNED(width, 8)) { InterpolateRow_16 = InterpolateRow_16_NEON; } } #endif #if defined(HAS_INTERPOLATEROW_16_MSA) if (TestCpuFlag(kCpuHasMSA)) { InterpolateRow_16 = InterpolateRow_16_Any_MSA; if (IS_ALIGNED(width, 32)) { InterpolateRow_16 = InterpolateRow_16_MSA; } } #endif #if defined(HAS_INTERPOLATEROW_16_LSX) if (TestCpuFlag(kCpuHasLSX)) { InterpolateRow_16 = InterpolateRow_16_Any_LSX; if (IS_ALIGNED(width, 32)) { InterpolateRow_16 = InterpolateRow_16_LSX; } } #endif for (y = 0; y < height; ++y) { InterpolateRow_16(dst, src0, src1 - src0, width, interpolation); src0 += src_stride0; src1 += src_stride1; dst += dst_stride; } return 0; } LIBYUV_API int ARGBInterpolate(const uint8_t* src_argb0, int src_stride_argb0, const uint8_t* src_argb1, int src_stride_argb1, uint8_t* dst_argb, int dst_stride_argb, int width, int height, int interpolation) { return InterpolatePlane(src_argb0, src_stride_argb0, src_argb1, src_stride_argb1, dst_argb, dst_stride_argb, width * 4, height, interpolation); } LIBYUV_API int I420Interpolate(const uint8_t* src0_y, int src0_stride_y, const uint8_t* src0_u, int src0_stride_u, const uint8_t* src0_v, int src0_stride_v, const uint8_t* src1_y, int src1_stride_y, const uint8_t* src1_u, int src1_stride_u, const uint8_t* src1_v, int src1_stride_v, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_u, int dst_stride_u, uint8_t* dst_v, int dst_stride_v, int width, int height, int interpolation) { int halfwidth = (width + 1) >> 1; int halfheight = (height + 1) >> 1; if (!src0_y || !src0_u || !src0_v || !src1_y || !src1_u || !src1_v || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) { return -1; } InterpolatePlane(src0_y, src0_stride_y, src1_y, src1_stride_y, dst_y, dst_stride_y, width, height, interpolation); InterpolatePlane(src0_u, src0_stride_u, src1_u, src1_stride_u, dst_u, dst_stride_u, halfwidth, halfheight, interpolation); InterpolatePlane(src0_v, src0_stride_v, src1_v, src1_stride_v, dst_v, dst_stride_v, halfwidth, halfheight, interpolation); return 0; } LIBYUV_API int ARGBShuffle(const uint8_t* src_bgra, int src_stride_bgra, uint8_t* dst_argb, int dst_stride_argb, const uint8_t* shuffler, int width, int height) { int y; void (*ARGBShuffleRow)(const uint8_t* src_bgra, uint8_t* dst_argb, const uint8_t* shuffler, int width) = ARGBShuffleRow_C; if (!src_bgra || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_bgra = src_bgra + (height - 1) * src_stride_bgra; src_stride_bgra = -src_stride_bgra; } if (src_stride_bgra == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_bgra = dst_stride_argb = 0; } #if defined(HAS_ARGBSHUFFLEROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { ARGBShuffleRow = ARGBShuffleRow_Any_SSSE3; if (IS_ALIGNED(width, 8)) { ARGBShuffleRow = ARGBShuffleRow_SSSE3; } } #endif #if defined(HAS_ARGBSHUFFLEROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBShuffleRow = ARGBShuffleRow_Any_AVX2; if (IS_ALIGNED(width, 16)) { ARGBShuffleRow = ARGBShuffleRow_AVX2; } } #endif #if defined(HAS_ARGBSHUFFLEROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ARGBShuffleRow = ARGBShuffleRow_Any_NEON; if (IS_ALIGNED(width, 4)) { ARGBShuffleRow = ARGBShuffleRow_NEON; } } #endif #if defined(HAS_ARGBSHUFFLEROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { ARGBShuffleRow = ARGBShuffleRow_Any_MSA; if (IS_ALIGNED(width, 8)) { ARGBShuffleRow = ARGBShuffleRow_MSA; } } #endif #if defined(HAS_ARGBSHUFFLEROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { ARGBShuffleRow = ARGBShuffleRow_Any_LASX; if (IS_ALIGNED(width, 16)) { ARGBShuffleRow = ARGBShuffleRow_LASX; } } #endif for (y = 0; y < height; ++y) { ARGBShuffleRow(src_bgra, dst_argb, shuffler, width); src_bgra += src_stride_bgra; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int AR64Shuffle(const uint16_t* src_ar64, int src_stride_ar64, uint16_t* dst_ar64, int dst_stride_ar64, const uint8_t* shuffler, int width, int height) { int y; void (*AR64ShuffleRow)(const uint8_t* src_ar64, uint8_t* dst_ar64, const uint8_t* shuffler, int width) = AR64ShuffleRow_C; if (!src_ar64 || !dst_ar64 || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_ar64 = src_ar64 + (height - 1) * src_stride_ar64; src_stride_ar64 = -src_stride_ar64; } if (src_stride_ar64 == width * 4 && dst_stride_ar64 == width * 4) { width *= height; height = 1; src_stride_ar64 = dst_stride_ar64 = 0; } #if defined(HAS_ARGBSHUFFLEROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { AR64ShuffleRow = ARGBShuffleRow_Any_SSSE3; if (IS_ALIGNED(width, 8)) { AR64ShuffleRow = ARGBShuffleRow_SSSE3; } } #endif #if defined(HAS_ARGBSHUFFLEROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { AR64ShuffleRow = ARGBShuffleRow_Any_AVX2; if (IS_ALIGNED(width, 16)) { AR64ShuffleRow = ARGBShuffleRow_AVX2; } } #endif #if defined(HAS_ARGBSHUFFLEROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { AR64ShuffleRow = ARGBShuffleRow_Any_NEON; if (IS_ALIGNED(width, 4)) { AR64ShuffleRow = ARGBShuffleRow_NEON; } } #endif for (y = 0; y < height; ++y) { AR64ShuffleRow((uint8_t*)(src_ar64), (uint8_t*)(dst_ar64), shuffler, width * 2); src_ar64 += src_stride_ar64; dst_ar64 += dst_stride_ar64; } return 0; } LIBYUV_API int GaussPlane_F32(const float* src, int src_stride, float* dst, int dst_stride, int width, int height) { int y; void (*GaussCol_F32)(const float* src0, const float* src1, const float* src2, const float* src3, const float* src4, float* dst, int width) = GaussCol_F32_C; void (*GaussRow_F32)(const float* src, float* dst, int width) = GaussRow_F32_C; if (!src || !dst || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src = src + (height - 1) * src_stride; src_stride = -src_stride; } #if defined(HAS_GAUSSCOL_F32_NEON) if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) { GaussCol_F32 = GaussCol_F32_NEON; } #endif #if defined(HAS_GAUSSROW_F32_NEON) if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) { GaussRow_F32 = GaussRow_F32_NEON; } #endif { align_buffer_64(rowbuf, (4 + width + 4) * 4); memset(rowbuf, 0, 16); memset(rowbuf + (4 + width) * 4, 0, 16); float* row = (float*)(rowbuf + 16); const float* src0 = src; const float* src1 = src; const float* src2 = src; const float* src3 = src2 + ((height > 1) ? src_stride : 0); const float* src4 = src3 + ((height > 2) ? src_stride : 0); for (y = 0; y < height; ++y) { GaussCol_F32(src0, src1, src2, src3, src4, row, width); row[-2] = row[-1] = row[0]; row[width + 1] = row[width] = row[width - 1]; GaussRow_F32(row - 2, dst, width); src0 = src1; src1 = src2; src2 = src3; src3 = src4; if ((y + 2) < (height - 1)) { src4 += src_stride; } dst += dst_stride; } free_aligned_buffer_64(rowbuf); } return 0; } static int ARGBSobelize(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, int width, int height, void (*SobelRow)(const uint8_t* src_sobelx, const uint8_t* src_sobely, uint8_t* dst, int width)) { int y; void (*ARGBToYJRow)(const uint8_t* src_argb, uint8_t* dst_g, int width) = ARGBToYJRow_C; void (*SobelYRow)(const uint8_t* src_y0, const uint8_t* src_y1, uint8_t* dst_sobely, int width) = SobelYRow_C; void (*SobelXRow)(const uint8_t* src_y0, const uint8_t* src_y1, const uint8_t* src_y2, uint8_t* dst_sobely, int width) = SobelXRow_C; const int kEdge = 16; if (!src_argb || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } #if defined(HAS_ARGBTOYJROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { ARGBToYJRow = ARGBToYJRow_Any_SSSE3; if (IS_ALIGNED(width, 16)) { ARGBToYJRow = ARGBToYJRow_SSSE3; } } #endif #if defined(HAS_ARGBTOYJROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBToYJRow = ARGBToYJRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { ARGBToYJRow = ARGBToYJRow_AVX2; } } #endif #if defined(HAS_ARGBTOYJROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ARGBToYJRow = ARGBToYJRow_Any_NEON; if (IS_ALIGNED(width, 16)) { ARGBToYJRow = ARGBToYJRow_NEON; } } #endif #if defined(HAS_ARGBTOYJROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { ARGBToYJRow = ARGBToYJRow_Any_MSA; if (IS_ALIGNED(width, 16)) { ARGBToYJRow = ARGBToYJRow_MSA; } } #endif #if defined(HAS_ARGBTOYJROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { ARGBToYJRow = ARGBToYJRow_Any_LSX; if (IS_ALIGNED(width, 16)) { ARGBToYJRow = ARGBToYJRow_LSX; } } #endif #if defined(HAS_ARGBTOYJROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { ARGBToYJRow = ARGBToYJRow_Any_LASX; if (IS_ALIGNED(width, 32)) { ARGBToYJRow = ARGBToYJRow_LASX; } } #endif #if defined(HAS_SOBELYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { SobelYRow = SobelYRow_SSE2; } #endif #if defined(HAS_SOBELYROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SobelYRow = SobelYRow_NEON; } #endif #if defined(HAS_SOBELYROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { SobelYRow = SobelYRow_MSA; } #endif #if defined(HAS_SOBELXROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { SobelXRow = SobelXRow_SSE2; } #endif #if defined(HAS_SOBELXROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SobelXRow = SobelXRow_NEON; } #endif #if defined(HAS_SOBELXROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { SobelXRow = SobelXRow_MSA; } #endif { const int row_size = (width + kEdge + 31) & ~31; align_buffer_64(rows, row_size * 2 + (kEdge + row_size * 3 + kEdge)); uint8_t* row_sobelx = rows; uint8_t* row_sobely = rows + row_size; uint8_t* row_y = rows + row_size * 2; uint8_t* row_y0 = row_y + kEdge; uint8_t* row_y1 = row_y0 + row_size; uint8_t* row_y2 = row_y1 + row_size; ARGBToYJRow(src_argb, row_y0, width); row_y0[-1] = row_y0[0]; memset(row_y0 + width, row_y0[width - 1], 16); ARGBToYJRow(src_argb, row_y1, width); row_y1[-1] = row_y1[0]; memset(row_y1 + width, row_y1[width - 1], 16); memset(row_y2 + width, 0, 16); for (y = 0; y < height; ++y) { if (y < (height - 1)) { src_argb += src_stride_argb; } ARGBToYJRow(src_argb, row_y2, width); row_y2[-1] = row_y2[0]; row_y2[width] = row_y2[width - 1]; SobelXRow(row_y0 - 1, row_y1 - 1, row_y2 - 1, row_sobelx, width); SobelYRow(row_y0 - 1, row_y2 - 1, row_sobely, width); SobelRow(row_sobelx, row_sobely, dst_argb, width); { uint8_t* row_yt = row_y0; row_y0 = row_y1; row_y1 = row_y2; row_y2 = row_yt; } dst_argb += dst_stride_argb; } free_aligned_buffer_64(rows); } return 0; } LIBYUV_API int ARGBSobel(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { void (*SobelRow)(const uint8_t* src_sobelx, const uint8_t* src_sobely, uint8_t* dst_argb, int width) = SobelRow_C; #if defined(HAS_SOBELROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { SobelRow = SobelRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { SobelRow = SobelRow_SSE2; } } #endif #if defined(HAS_SOBELROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SobelRow = SobelRow_Any_NEON; if (IS_ALIGNED(width, 8)) { SobelRow = SobelRow_NEON; } } #endif #if defined(HAS_SOBELROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { SobelRow = SobelRow_Any_MSA; if (IS_ALIGNED(width, 16)) { SobelRow = SobelRow_MSA; } } #endif #if defined(HAS_SOBELROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { SobelRow = SobelRow_Any_LSX; if (IS_ALIGNED(width, 16)) { SobelRow = SobelRow_LSX; } } #endif return ARGBSobelize(src_argb, src_stride_argb, dst_argb, dst_stride_argb, width, height, SobelRow); } LIBYUV_API int ARGBSobelToPlane(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_y, int dst_stride_y, int width, int height) { void (*SobelToPlaneRow)(const uint8_t* src_sobelx, const uint8_t* src_sobely, uint8_t* dst_, int width) = SobelToPlaneRow_C; #if defined(HAS_SOBELTOPLANEROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { SobelToPlaneRow = SobelToPlaneRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { SobelToPlaneRow = SobelToPlaneRow_SSE2; } } #endif #if defined(HAS_SOBELTOPLANEROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SobelToPlaneRow = SobelToPlaneRow_Any_NEON; if (IS_ALIGNED(width, 16)) { SobelToPlaneRow = SobelToPlaneRow_NEON; } } #endif #if defined(HAS_SOBELTOPLANEROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { SobelToPlaneRow = SobelToPlaneRow_Any_MSA; if (IS_ALIGNED(width, 32)) { SobelToPlaneRow = SobelToPlaneRow_MSA; } } #endif #if defined(HAS_SOBELTOPLANEROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { SobelToPlaneRow = SobelToPlaneRow_Any_LSX; if (IS_ALIGNED(width, 32)) { SobelToPlaneRow = SobelToPlaneRow_LSX; } } #endif return ARGBSobelize(src_argb, src_stride_argb, dst_y, dst_stride_y, width, height, SobelToPlaneRow); } LIBYUV_API int ARGBSobelXY(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { void (*SobelXYRow)(const uint8_t* src_sobelx, const uint8_t* src_sobely, uint8_t* dst_argb, int width) = SobelXYRow_C; #if defined(HAS_SOBELXYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { SobelXYRow = SobelXYRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { SobelXYRow = SobelXYRow_SSE2; } } #endif #if defined(HAS_SOBELXYROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SobelXYRow = SobelXYRow_Any_NEON; if (IS_ALIGNED(width, 8)) { SobelXYRow = SobelXYRow_NEON; } } #endif #if defined(HAS_SOBELXYROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { SobelXYRow = SobelXYRow_Any_MSA; if (IS_ALIGNED(width, 16)) { SobelXYRow = SobelXYRow_MSA; } } #endif #if defined(HAS_SOBELXYROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { SobelXYRow = SobelXYRow_Any_LSX; if (IS_ALIGNED(width, 16)) { SobelXYRow = SobelXYRow_LSX; } } #endif return ARGBSobelize(src_argb, src_stride_argb, dst_argb, dst_stride_argb, width, height, SobelXYRow); } LIBYUV_API int ARGBPolynomial(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, const float* poly, int width, int height) { int y; void (*ARGBPolynomialRow)(const uint8_t* src_argb, uint8_t* dst_argb, const float* poly, int width) = ARGBPolynomialRow_C; if (!src_argb || !dst_argb || !poly || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb = dst_stride_argb = 0; } #if defined(HAS_ARGBPOLYNOMIALROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 2)) { ARGBPolynomialRow = ARGBPolynomialRow_SSE2; } #endif #if defined(HAS_ARGBPOLYNOMIALROW_AVX2) if (TestCpuFlag(kCpuHasAVX2) && TestCpuFlag(kCpuHasFMA3) && IS_ALIGNED(width, 2)) { ARGBPolynomialRow = ARGBPolynomialRow_AVX2; } #endif for (y = 0; y < height; ++y) { ARGBPolynomialRow(src_argb, dst_argb, poly, width); src_argb += src_stride_argb; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int HalfFloatPlane(const uint16_t* src_y, int src_stride_y, uint16_t* dst_y, int dst_stride_y, float scale, int width, int height) { int y; void (*HalfFloatRow)(const uint16_t* src, uint16_t* dst, float scale, int width) = HalfFloatRow_C; if (!src_y || !dst_y || width <= 0 || height == 0) { return -1; } src_stride_y >>= 1; dst_stride_y >>= 1; if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; src_stride_y = -src_stride_y; } if (src_stride_y == width && dst_stride_y == width) { width *= height; height = 1; src_stride_y = dst_stride_y = 0; } #if defined(HAS_HALFFLOATROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { HalfFloatRow = HalfFloatRow_Any_SSE2; if (IS_ALIGNED(width, 8)) { HalfFloatRow = HalfFloatRow_SSE2; } } #endif #if defined(HAS_HALFFLOATROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { HalfFloatRow = HalfFloatRow_Any_AVX2; if (IS_ALIGNED(width, 16)) { HalfFloatRow = HalfFloatRow_AVX2; } } #endif #if defined(HAS_HALFFLOATROW_F16C) if (TestCpuFlag(kCpuHasAVX2) && TestCpuFlag(kCpuHasF16C)) { HalfFloatRow = (scale == 1.0f) ? HalfFloat1Row_Any_F16C : HalfFloatRow_Any_F16C; if (IS_ALIGNED(width, 16)) { HalfFloatRow = (scale == 1.0f) ? HalfFloat1Row_F16C : HalfFloatRow_F16C; } } #endif #if defined(HAS_HALFFLOATROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { HalfFloatRow = (scale == 1.0f) ? HalfFloat1Row_Any_NEON : HalfFloatRow_Any_NEON; if (IS_ALIGNED(width, 8)) { HalfFloatRow = (scale == 1.0f) ? HalfFloat1Row_NEON : HalfFloatRow_NEON; } } #endif #if defined(HAS_HALFFLOATROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { HalfFloatRow = HalfFloatRow_Any_MSA; if (IS_ALIGNED(width, 32)) { HalfFloatRow = HalfFloatRow_MSA; } } #endif #if defined(HAS_HALFFLOATROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { HalfFloatRow = HalfFloatRow_Any_LSX; if (IS_ALIGNED(width, 32)) { HalfFloatRow = HalfFloatRow_LSX; } } #endif for (y = 0; y < height; ++y) { HalfFloatRow(src_y, dst_y, scale, width); src_y += src_stride_y; dst_y += dst_stride_y; } return 0; } LIBYUV_API int ByteToFloat(const uint8_t* src_y, float* dst_y, float scale, int width) { void (*ByteToFloatRow)(const uint8_t* src, float* dst, float scale, int width) = ByteToFloatRow_C; if (!src_y || !dst_y || width <= 0) { return -1; } #if defined(HAS_BYTETOFLOATROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ByteToFloatRow = ByteToFloatRow_Any_NEON; if (IS_ALIGNED(width, 8)) { ByteToFloatRow = ByteToFloatRow_NEON; } } #endif ByteToFloatRow(src_y, dst_y, scale, width); return 0; } LIBYUV_API int ARGBLumaColorTable(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, const uint8_t* luma, int width, int height) { int y; void (*ARGBLumaColorTableRow)( const uint8_t* src_argb, uint8_t* dst_argb, int width, const uint8_t* luma, const uint32_t lumacoeff) = ARGBLumaColorTableRow_C; if (!src_argb || !dst_argb || !luma || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb = dst_stride_argb = 0; } #if defined(HAS_ARGBLUMACOLORTABLEROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 4)) { ARGBLumaColorTableRow = ARGBLumaColorTableRow_SSSE3; } #endif for (y = 0; y < height; ++y) { ARGBLumaColorTableRow(src_argb, dst_argb, width, luma, 0x00264b0f); src_argb += src_stride_argb; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int ARGBCopyAlpha(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*ARGBCopyAlphaRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width) = ARGBCopyAlphaRow_C; if (!src_argb || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb = src_argb + (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_argb = dst_stride_argb = 0; } #if defined(HAS_ARGBCOPYALPHAROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ARGBCopyAlphaRow = ARGBCopyAlphaRow_Any_SSE2; if (IS_ALIGNED(width, 8)) { ARGBCopyAlphaRow = ARGBCopyAlphaRow_SSE2; } } #endif #if defined(HAS_ARGBCOPYALPHAROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBCopyAlphaRow = ARGBCopyAlphaRow_Any_AVX2; if (IS_ALIGNED(width, 16)) { ARGBCopyAlphaRow = ARGBCopyAlphaRow_AVX2; } } #endif for (y = 0; y < height; ++y) { ARGBCopyAlphaRow(src_argb, dst_argb, width); src_argb += src_stride_argb; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int ARGBExtractAlpha(const uint8_t* src_argb, int src_stride_argb, uint8_t* dst_a, int dst_stride_a, int width, int height) { if (!src_argb || !dst_a || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_argb += (height - 1) * src_stride_argb; src_stride_argb = -src_stride_argb; } if (src_stride_argb == width * 4 && dst_stride_a == width) { width *= height; height = 1; src_stride_argb = dst_stride_a = 0; } void (*ARGBExtractAlphaRow)(const uint8_t* src_argb, uint8_t* dst_a, int width) = ARGBExtractAlphaRow_C; #if defined(HAS_ARGBEXTRACTALPHAROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ARGBExtractAlphaRow = IS_ALIGNED(width, 8) ? ARGBExtractAlphaRow_SSE2 : ARGBExtractAlphaRow_Any_SSE2; } #endif #if defined(HAS_ARGBEXTRACTALPHAROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBExtractAlphaRow = IS_ALIGNED(width, 32) ? ARGBExtractAlphaRow_AVX2 : ARGBExtractAlphaRow_Any_AVX2; } #endif #if defined(HAS_ARGBEXTRACTALPHAROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { ARGBExtractAlphaRow = IS_ALIGNED(width, 16) ? ARGBExtractAlphaRow_NEON : ARGBExtractAlphaRow_Any_NEON; } #endif #if defined(HAS_ARGBEXTRACTALPHAROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { ARGBExtractAlphaRow = IS_ALIGNED(width, 16) ? ARGBExtractAlphaRow_MSA : ARGBExtractAlphaRow_Any_MSA; } #endif #if defined(HAS_ARGBEXTRACTALPHAROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { ARGBExtractAlphaRow = IS_ALIGNED(width, 16) ? ARGBExtractAlphaRow_LSX : ARGBExtractAlphaRow_Any_LSX; } #endif for (int y = 0; y < height; ++y) { ARGBExtractAlphaRow(src_argb, dst_a, width); src_argb += src_stride_argb; dst_a += dst_stride_a; } return 0; } LIBYUV_API int ARGBCopyYToAlpha(const uint8_t* src_y, int src_stride_y, uint8_t* dst_argb, int dst_stride_argb, int width, int height) { int y; void (*ARGBCopyYToAlphaRow)(const uint8_t* src_y, uint8_t* dst_argb, int width) = ARGBCopyYToAlphaRow_C; if (!src_y || !dst_argb || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_y = src_y + (height - 1) * src_stride_y; src_stride_y = -src_stride_y; } if (src_stride_y == width && dst_stride_argb == width * 4) { width *= height; height = 1; src_stride_y = dst_stride_argb = 0; } #if defined(HAS_ARGBCOPYYTOALPHAROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { ARGBCopyYToAlphaRow = ARGBCopyYToAlphaRow_Any_SSE2; if (IS_ALIGNED(width, 8)) { ARGBCopyYToAlphaRow = ARGBCopyYToAlphaRow_SSE2; } } #endif #if defined(HAS_ARGBCOPYYTOALPHAROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { ARGBCopyYToAlphaRow = ARGBCopyYToAlphaRow_Any_AVX2; if (IS_ALIGNED(width, 16)) { ARGBCopyYToAlphaRow = ARGBCopyYToAlphaRow_AVX2; } } #endif for (y = 0; y < height; ++y) { ARGBCopyYToAlphaRow(src_y, dst_argb, width); src_y += src_stride_y; dst_argb += dst_stride_argb; } return 0; } LIBYUV_API int YUY2ToNV12(const uint8_t* src_yuy2, int src_stride_yuy2, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_uv, int dst_stride_uv, int width, int height) { int y; void (*YUY2ToYRow)(const uint8_t* src_yuy2, uint8_t* dst_y, int width) = YUY2ToYRow_C; void (*YUY2ToNVUVRow)(const uint8_t* src_yuy2, int stride_yuy2, uint8_t* dst_uv, int width) = YUY2ToNVUVRow_C; if (!src_yuy2 || !dst_y || !dst_uv || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2; src_stride_yuy2 = -src_stride_yuy2; } #if defined(HAS_YUY2TOYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { YUY2ToYRow = YUY2ToYRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { YUY2ToYRow = YUY2ToYRow_SSE2; } } #endif #if defined(HAS_YUY2TOYROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { YUY2ToYRow = YUY2ToYRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { YUY2ToYRow = YUY2ToYRow_AVX2; } } #endif #if defined(HAS_YUY2TOYROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { YUY2ToYRow = YUY2ToYRow_Any_NEON; if (IS_ALIGNED(width, 16)) { YUY2ToYRow = YUY2ToYRow_NEON; } } #endif #if defined(HAS_YUY2TOYROW_MSA) && defined(HAS_YUY2TOUV422ROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { YUY2ToYRow = YUY2ToYRow_Any_MSA; if (IS_ALIGNED(width, 32)) { YUY2ToYRow = YUY2ToYRow_MSA; } } #endif #if defined(HAS_YUY2TOYROW_LASX) && defined(HAS_YUY2TOUV422ROW_LASX) if (TestCpuFlag(kCpuHasLASX)) { YUY2ToYRow = YUY2ToYRow_Any_LASX; if (IS_ALIGNED(width, 32)) { YUY2ToYRow = YUY2ToYRow_LASX; } } #endif #if defined(HAS_YUY2TONVUVROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { YUY2ToNVUVRow = YUY2ToNVUVRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { YUY2ToNVUVRow = YUY2ToNVUVRow_SSE2; } } #endif #if defined(HAS_YUY2TONVUVROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { YUY2ToNVUVRow = YUY2ToNVUVRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { YUY2ToNVUVRow = YUY2ToNVUVRow_AVX2; } } #endif #if defined(HAS_YUY2TONVUVROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { YUY2ToNVUVRow = YUY2ToNVUVRow_Any_NEON; if (IS_ALIGNED(width, 16)) { YUY2ToNVUVRow = YUY2ToNVUVRow_NEON; } } #endif for (y = 0; y < height - 1; y += 2) { YUY2ToYRow(src_yuy2, dst_y, width); YUY2ToYRow(src_yuy2 + src_stride_yuy2, dst_y + dst_stride_y, width); YUY2ToNVUVRow(src_yuy2, src_stride_yuy2, dst_uv, width); src_yuy2 += src_stride_yuy2 * 2; dst_y += dst_stride_y * 2; dst_uv += dst_stride_uv; } if (height & 1) { YUY2ToYRow(src_yuy2, dst_y, width); YUY2ToNVUVRow(src_yuy2, 0, dst_uv, width); } return 0; } LIBYUV_API int UYVYToNV12(const uint8_t* src_uyvy, int src_stride_uyvy, uint8_t* dst_y, int dst_stride_y, uint8_t* dst_uv, int dst_stride_uv, int width, int height) { int y; int halfwidth = (width + 1) >> 1; void (*SplitUVRow)(const uint8_t* src_uv, uint8_t* dst_u, uint8_t* dst_v, int width) = SplitUVRow_C; void (*InterpolateRow)(uint8_t* dst_ptr, const uint8_t* src_ptr, ptrdiff_t src_stride, int dst_width, int source_y_fraction) = InterpolateRow_C; if (!src_uyvy || !dst_y || !dst_uv || width <= 0 || height == 0) { return -1; } if (height < 0) { height = -height; src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy; src_stride_uyvy = -src_stride_uyvy; } #if defined(HAS_SPLITUVROW_SSE2) if (TestCpuFlag(kCpuHasSSE2)) { SplitUVRow = SplitUVRow_Any_SSE2; if (IS_ALIGNED(width, 16)) { SplitUVRow = SplitUVRow_SSE2; } } #endif #if defined(HAS_SPLITUVROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { SplitUVRow = SplitUVRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { SplitUVRow = SplitUVRow_AVX2; } } #endif #if defined(HAS_SPLITUVROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { SplitUVRow = SplitUVRow_Any_NEON; if (IS_ALIGNED(width, 16)) { SplitUVRow = SplitUVRow_NEON; } } #endif #if defined(HAS_SPLITUVROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { SplitUVRow = SplitUVRow_Any_MSA; if (IS_ALIGNED(width, 32)) { SplitUVRow = SplitUVRow_MSA; } } #endif #if defined(HAS_SPLITUVROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { SplitUVRow = SplitUVRow_Any_LSX; if (IS_ALIGNED(width, 32)) { SplitUVRow = SplitUVRow_LSX; } } #endif #if defined(HAS_INTERPOLATEROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { InterpolateRow = InterpolateRow_Any_SSSE3; if (IS_ALIGNED(width, 16)) { InterpolateRow = InterpolateRow_SSSE3; } } #endif #if defined(HAS_INTERPOLATEROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { InterpolateRow = InterpolateRow_Any_AVX2; if (IS_ALIGNED(width, 32)) { InterpolateRow = InterpolateRow_AVX2; } } #endif #if defined(HAS_INTERPOLATEROW_NEON) if (TestCpuFlag(kCpuHasNEON)) { InterpolateRow = InterpolateRow_Any_NEON; if (IS_ALIGNED(width, 16)) { InterpolateRow = InterpolateRow_NEON; } } #endif #if defined(HAS_INTERPOLATEROW_MSA) if (TestCpuFlag(kCpuHasMSA)) { InterpolateRow = InterpolateRow_Any_MSA; if (IS_ALIGNED(width, 32)) { InterpolateRow = InterpolateRow_MSA; } } #endif #if defined(HAS_INTERPOLATEROW_LSX) if (TestCpuFlag(kCpuHasLSX)) { InterpolateRow = InterpolateRow_Any_LSX; if (IS_ALIGNED(width, 32)) { InterpolateRow = InterpolateRow_LSX; } } #endif { int awidth = halfwidth * 2; align_buffer_64(rows, awidth * 3); for (y = 0; y < height - 1; y += 2) { SplitUVRow(src_uyvy, rows + awidth, rows, awidth); memcpy(dst_y, rows, width); SplitUVRow(src_uyvy + src_stride_uyvy, rows + awidth * 2, rows, awidth); memcpy(dst_y + dst_stride_y, rows, width); InterpolateRow(dst_uv, rows + awidth, awidth, awidth, 128); src_uyvy += src_stride_uyvy * 2; dst_y += dst_stride_y * 2; dst_uv += dst_stride_uv; } if (height & 1) { SplitUVRow(src_uyvy, dst_uv, rows, awidth); memcpy(dst_y, rows, width); } free_aligned_buffer_64(rows); } return 0; } LIBYUV_API void HalfMergeUVPlane(const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_uv, int dst_stride_uv, int width, int height) { int y; void (*HalfMergeUVRow)(const uint8_t* src_u, int src_stride_u, const uint8_t* src_v, int src_stride_v, uint8_t* dst_uv, int width) = HalfMergeUVRow_C; if (height < 0) { height = -height; src_u = src_u + (height - 1) * src_stride_u; src_v = src_v + (height - 1) * src_stride_v; src_stride_u = -src_stride_u; src_stride_v = -src_stride_v; } #if defined(HAS_HALFMERGEUVROW_NEON) if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) { HalfMergeUVRow = HalfMergeUVRow_NEON; } #endif #if defined(HAS_HALFMERGEUVROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 16)) { HalfMergeUVRow = HalfMergeUVRow_SSSE3; } #endif #if defined(HAS_HALFMERGEUVROW_AVX2) if (TestCpuFlag(kCpuHasAVX2) && IS_ALIGNED(width, 32)) { HalfMergeUVRow = HalfMergeUVRow_AVX2; } #endif for (y = 0; y < height - 1; y += 2) { HalfMergeUVRow(src_u, src_stride_u, src_v, src_stride_v, dst_uv, width); src_u += src_stride_u * 2; src_v += src_stride_v * 2; dst_uv += dst_stride_uv; } if (height & 1) { HalfMergeUVRow(src_u, 0, src_v, 0, dst_uv, width); } } #ifdef __cplusplus } } #endif
[ "mcastelluccio@mozilla.com" ]
mcastelluccio@mozilla.com
c207f19caf0c814ea18699171f20932ad31de9b5
b22588340d7925b614a735bbbde1b351ad657ffc
/athena/Trigger/TrigEvent/TrigParticle/TrigParticle/TrigEFBjetContainer.h
eaa39bf15909320a2dd009d109ca42c3e97137b5
[]
no_license
rushioda/PIXELVALID_athena
90befe12042c1249cbb3655dde1428bb9b9a42ce
22df23187ef85e9c3120122c8375ea0e7d8ea440
refs/heads/master
2020-12-14T22:01:15.365949
2020-01-19T03:59:35
2020-01-19T03:59:35
234,836,993
1
0
null
null
null
null
UTF-8
C++
false
false
897
h
/* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ // ************************************************ // // NAME: TrigEFBjetContainer.h // PACKAGE: Trigger/TrigEvent/TrigParticle // // AUTHOR: Andrea Coccaro // EMAIL: Andrea.Coccaro@ge.infn.it // // ************************************************ #ifndef TRIG_EF_BJET_CONTAINER #define TRIG_EF_BJET_CONTAINER #include "DataModel/DataVector.h" #include "CLIDSvc/CLASS_DEF.h" #include "TrigParticle/TrigEFBjet.h" #include "SGTools/BaseInfo.h" /** * @brief Container of TrigEFBjet objects to be stored in POOL. * * @author Andrea Coccaro <Andrea.Coccaro@ge.infn.it> */ class TrigEFBjetContainer: public DataVector<TrigEFBjet> { }; //typedef DataVector<TrigEFBjet> TrigEFBjetContainer; CLASS_DEF(TrigEFBjetContainer, 1142962358, 1) SG_BASE(TrigEFBjetContainer, DataVector<TrigEFBjet>); #endif
[ "rushioda@lxplus754.cern.ch" ]
rushioda@lxplus754.cern.ch
00c0ed7f2f33ed82c0133d78dbd68c1f52aea2fb
bbcb83e5d9bababc7d5ad017222f4f2d0127e152
/TestThreadLib/TestThreadLib/SharedMemoryThread.h
b39da1c0dc10c1f4f1102b21d3c0ae51797d89b3
[]
no_license
andrewpaterson/Codaphela.Test
d52f3c4d9c5b4ae21f265424cb01a246463f70b5
1678a4af46ce363e3d1b01ca931ca8f84330c764
refs/heads/master
2023-05-25T07:00:38.362742
2023-05-14T11:46:51
2023-05-14T11:46:51
3,249,605
0
1
null
null
null
null
UTF-8
C++
false
false
757
h
#ifndef __SHARED_MEMORY_THREAD_H__ #define __SHARED_MEMORY_THREAD_H__ #include "ThreadLib/Thread.h" #include "SharedMemoryFill.h" class CSharedMemoryThread : public CThread { CONSTRUCTABLE(CSharedMemoryThread); private: CSharedMemoryFill mcFill; public: CSharedMemoryThread(void) : CThread() {} CSharedMemoryThread(CThreadStarter* pcStarter, CThreadStateNotifer* pcNotify) : CThread(pcStarter, pcNotify) {} CSharedMemoryThread* Init(char* szSharedMemoryName, char* szMutexName, char* szFillChar, int iChunkSize) { CThread::Init(); mcFill.Init(szSharedMemoryName, szMutexName, szFillChar, iChunkSize); return this; } virtual void Run(void) { mcFill.Run(); } }; #endif // !__SHARED_MEMORY_THREAD_H__
[ "andrew.ian.paterson@gmail.com" ]
andrew.ian.paterson@gmail.com
a4927524fee30ef2cb25ecec7be414f8c11fb2ae
92dbe90d8cf56a38caaefff70b8d1f700f1562aa
/ash/system/holding_space/holding_space_tray.cc
9004a2414e79efb5945a52cca6d2cf3a0c09e8f3
[ "BSD-3-Clause" ]
permissive
jeeeez/chromium
4fb134eccfd1d3f469a838ac0b9ee375eb28ad88
ed032184fd1bf63ca0e9525f5ccca7d3165e2d63
refs/heads/master
2023-01-03T08:12:33.054587
2020-10-27T09:34:51
2020-10-27T09:34:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,375
cc
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ash/system/holding_space/holding_space_tray.h" #include <memory> #include "ash/accessibility/accessibility_controller_impl.h" #include "ash/public/cpp/holding_space/holding_space_constants.h" #include "ash/public/cpp/holding_space/holding_space_metrics.h" #include "ash/public/cpp/holding_space/holding_space_prefs.h" #include "ash/public/cpp/shelf_config.h" #include "ash/public/cpp/system_tray_client.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/session/session_controller_impl.h" #include "ash/shelf/shelf.h" #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" #include "ash/system/holding_space/holding_space_tray_bubble.h" #include "ash/system/tray/tray_container.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/paint_vector_icon.h" #include "ui/views/controls/image_view.h" #include "ui/views/controls/label.h" #include "ui/views/layout/fill_layout.h" #include "ui/views/vector_icons.h" namespace ash { HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) { controller_observer_.Add(HoldingSpaceController::Get()); SetVisible(false); SetLayoutManager(std::make_unique<views::FillLayout>()); icon_ = tray_container()->AddChildView(std::make_unique<views::ImageView>()); icon_->SetTooltipText(l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_TITLE)); icon_->SetImage(CreateVectorIcon(kHoldingSpaceIcon, ShelfConfig::Get()->shelf_icon_color())); tray_container()->SetMargin(kHoldingSpaceTrayMainAxisMargin, 0); } HoldingSpaceTray::~HoldingSpaceTray() = default; void HoldingSpaceTray::ClickedOutsideBubble() { CloseBubble(); } base::string16 HoldingSpaceTray::GetAccessibleNameForTray() { return l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_TITLE); } void HoldingSpaceTray::HandleLocaleChange() { icon_->SetTooltipText(l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_TITLE)); } void HoldingSpaceTray::HideBubbleWithView(const TrayBubbleView* bubble_view) {} void HoldingSpaceTray::AnchorUpdated() { if (bubble_) bubble_->AnchorUpdated(); } void HoldingSpaceTray::UpdateAfterLoginStatusChange() { UpdateVisibility(); } bool HoldingSpaceTray::PerformAction(const ui::Event& event) { holding_space_metrics::RecordPodAction( holding_space_metrics::PodAction::kClick); if (bubble_) { CloseBubble(); return true; } ShowBubble(event.IsMouseEvent() || event.IsGestureEvent()); // Activate the bubble for a11y or if it was shown via keypress. Otherwise // focus will remain on the tray when it should enter the bubble. if (event.IsKeyEvent() || Shell::Get()->accessibility_controller()->spoken_feedback().enabled()) { DCHECK(bubble_ && bubble_->GetBubbleWidget()); bubble_->GetBubbleWidget()->widget_delegate()->SetCanActivate(true); bubble_->GetBubbleWidget()->Activate(); } return true; } void HoldingSpaceTray::CloseBubble() { if (!bubble_) return; // If the call to `CloseBubble()` originated from `OnWidgetDestroying()`, as // would be the case when closing due to ESC key press, the bubble widget will // have already been destroyed. if (bubble_->GetBubbleWidget()) bubble_->GetBubbleWidget()->RemoveObserver(this); bubble_.reset(); SetIsActive(false); } void HoldingSpaceTray::ShowBubble(bool show_by_click) { if (bubble_) return; DCHECK(tray_container()); bubble_ = std::make_unique<HoldingSpaceTrayBubble>(this, show_by_click); // Observe the bubble widget so that we can do proper clean up when it is // being destroyed. If destruction is due to a call to `CloseBubble()` we will // have already cleaned up state but there are cases where the bubble widget // is destroyed independent of a call to `CloseBubble()`, e.g. ESC key press. bubble_->GetBubbleWidget()->AddObserver(this); SetIsActive(true); } TrayBubbleView* HoldingSpaceTray::GetBubbleView() { return bubble_ ? bubble_->GetBubbleView() : nullptr; } const char* HoldingSpaceTray::GetClassName() const { return "HoldingSpaceTray"; } void HoldingSpaceTray::UpdateVisibility() { HoldingSpaceModel* model = HoldingSpaceController::Get()->model(); bool logged_in = shelf()->GetStatusAreaWidget()->login_status() == LoginStatus::USER; if (!model || !logged_in) { SetVisiblePreferred(false); return; } PrefService* active_pref_service = Shell::Get()->session_controller()->GetActivePrefService(); bool has_ever_pinned_item = active_pref_service ? holding_space_prefs::GetTimeOfFirstPin(active_pref_service) .has_value() : false; SetVisiblePreferred(!model->items().empty() || !has_ever_pinned_item); } base::string16 HoldingSpaceTray::GetAccessibleNameForBubble() { return GetAccessibleNameForTray(); } bool HoldingSpaceTray::ShouldEnableExtraKeyboardAccessibility() { return Shell::Get()->accessibility_controller()->spoken_feedback().enabled(); } void HoldingSpaceTray::HideBubble(const TrayBubbleView* bubble_view) { CloseBubble(); } void HoldingSpaceTray::OnHoldingSpaceModelAttached(HoldingSpaceModel* model) { model_observer_.Add(model); UpdateVisibility(); } void HoldingSpaceTray::OnHoldingSpaceModelDetached(HoldingSpaceModel* model) { model_observer_.Remove(model); UpdateVisibility(); } void HoldingSpaceTray::OnHoldingSpaceItemAdded(const HoldingSpaceItem* item) { UpdateVisibility(); } void HoldingSpaceTray::OnHoldingSpaceItemRemoved(const HoldingSpaceItem* item) { UpdateVisibility(); } void HoldingSpaceTray::OnWidgetDragWillStart(views::Widget* widget) { // The holding space bubble should be closed while dragging holding space // items so as not to obstruct drop targets. Post the task to close the bubble // so that we don't attempt to destroy the bubble widget before the associated // drag event has been fully initialized. base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::BindOnce(&HoldingSpaceTray::CloseBubble, weak_factory_.GetWeakPtr())); } void HoldingSpaceTray::OnWidgetDestroying(views::Widget* widget) { widget->RemoveObserver(this); CloseBubble(); } } // namespace ash
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
f78aaae4f665073906caf8fd2ee5f4fce2f7cf84
92359e635b722f8c359b6a27133685c1c9b56565
/sandbox/FastBlurs/CPUT/CPUT/CPUTRenderTargetOGL.cpp
92a3dfb04260a11e0399ed5cc969578ea6f46aee
[ "MIT" ]
permissive
oamates/OpenGL
547ccb560d76182c70eae3ea6512df81c794f322
78c6d1fbdcb0c041b3333ea71c43c8f531e04481
refs/heads/master
2021-05-11T17:23:36.445056
2018-01-16T02:32:04
2018-01-16T02:32:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,248
cpp
//-------------------------------------------------------------------------------------- // Copyright 2013 Intel Corporation // All Rights Reserved // // Permission is granted to use, copy, distribute and prepare derivative works of this // software for any purpose and without fee, provided, that the above copyright notice // and this statement appear in all copies. Intel makes no representations about the // suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS." // INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, AND ALL LIABILITY, // INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE, // INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not // assume any responsibility for any errors which may appear in this software nor any // responsibility to update it. //-------------------------------------------------------------------------------------- #include "CPUTRenderTargetOGL.h" //#include "CPUTAssetLibrary.h" #include "CPUTTextureOGL.h" CPUTFramebufferOGL::CPUTFramebufferOGL() : mFramebuffer(0), mpColor(NULL), mpDepth(NULL), mpStencil(NULL) {}; CPUTFramebufferOGL::~CPUTFramebufferOGL() { SAFE_RELEASE(mpColor); SAFE_RELEASE(mpDepth); SAFE_RELEASE(mpStencil); if(mFramebuffer == 0) { glDeleteFramebuffers(1, &mFramebuffer); } } CPUTFramebufferOGL::CPUTFramebufferOGL(CPUTTextureOGL *pColor, CPUTTextureOGL *pDepth, CPUTTextureOGL *pStencil) { GLuint framebuffer = 0; GL_CHECK(glGenFramebuffers(1, &framebuffer)); GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, framebuffer)); if(pDepth) { GLuint depthTexture = pDepth->GetTexture(); GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0)); } if(pColor) { GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pColor->GetTexture(), 0)); GLenum pDrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; GL_CHECK(ES3_COMPAT(glDrawBuffers(1, pDrawBuffers))); } else { GLenum pDrawBuffers[1] = {GL_NONE}; GL_CHECK(ES3_COMPAT(glDrawBuffers(1, pDrawBuffers))); } GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER); ASSERT(status == GL_FRAMEBUFFER_COMPLETE, _L("Failed creating Framebuffer")); glBindFramebuffer(GL_FRAMEBUFFER, 0); mFramebuffer = framebuffer; mpColor = pColor; if(pColor != NULL) pColor->AddRef(); if(pDepth != NULL) pDepth->AddRef(); mpDepth = pDepth; if(pStencil != NULL) pStencil->AddRef(); mpStencil = pStencil; return; } void CPUTFramebufferOGL::SetActive() { GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer)); } void CPUTFramebufferOGL::UnSetActive() { GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0)); } GLuint CPUTFramebufferOGL::GetFramebufferName() { return mFramebuffer;} CPUTTextureOGL* CPUTFramebufferOGL::GetColorTexture() { return mpColor;} CPUTTextureOGL* CPUTFramebufferOGL::GetDepthTexture() { return mpDepth;} //void SetColorTexture(CPUTTextureOGL *pTexture) //void SetDepthTexture(CPUTTextureOGL *pTexture);
[ "afoksha@luxoft.com" ]
afoksha@luxoft.com
3db1d8ba3cc78ae6f0d286ba74ba205efe29311b
e4f9418990bfa3e07357c09922bd713432d4fefe
/include/E/Networking/E_NetworkLog.hpp
d14c40120cdedead8dc7d74ddacea73350d3f856
[ "MIT" ]
permissive
TerrySunty/KENS
7bac2ba1e3d75d4d98b618373e748f5f8edf4c7c
3fbd998830fbee0e9a6d3a072262034c178ccd16
refs/heads/master
2020-04-07T16:42:25.885705
2017-05-13T13:40:20
2017-05-13T13:40:20
158,539,716
0
1
MIT
2018-11-21T11:46:25
2018-11-21T11:46:25
null
UTF-8
C++
false
false
2,202
hpp
/** * @file E_NetworkLog.hpp * @Author leeopop (dlrmsghd@gmail.com) * @date November, 2014 * @brief Header for E::NetworkLog */ #ifndef E_NETWORKLOG_HPP_ #define E_NETWORKLOG_HPP_ #include <E/E_Common.hpp> namespace E { /** * @brief Log provides log-related utilities for network modules. * We recommend you to inherit this class privately to a network module, * and it will enable NetworkLog::print_log in your namespace. * * @note You cannot use both Log and NetworkLog simultaneously. * @see E::Log */ class NetworkSystem; class NetworkLog { private: uint64_t level; NetworkSystem* system; public: /** * @brief Constructs a NetworkLog instance. * * @param system NetworkSystem of a NetworkModule */ NetworkLog(NetworkSystem* system); /** * @brief Constructs a NetworkLog instance with log level. * * @param system NetworkSystem of a NetworkModule * @param level log level */ NetworkLog(NetworkSystem* system, uint64_t level); /** * @brief Destructs a NetworkLog instance. * */ ~NetworkLog(); /** * @brief Enumerations for log levels. * */ enum LOG_LEVEL { PACKET_TO_MODULE = 0UL, PACKET_FROM_MODULE, PACKET_TO_HOST, PACKET_FROM_HOST, PACKET_ALLOC, PACKET_CLONE, PACKET_FREE, PACKET_QUEUE, PACKET_DROPPED, SYSCALL_RAISED, SYSCALL_FINISHED, SYSCALL_BLOCKED, SYSCALL_UNBLOCKED, SYSCALL_ERROR, MODULE_ERROR, PROTOCOL_ERROR, PROTOCOL_WARNING, TCP_LOG, LEVEL_COUNT, }; protected: /** * @brief Prints log with specified log level and format. * NetworkLog::print_log prints logs specified in log level parameter. * For example, if log level is set to TCP_LOG, it only prints TCP_LOG logs. * If you want to print multiple log levels in NetworkLog, * you can set log level with OR operation (i.e. SYSCALL_ERROR | MODULE_ERROR). * * @note Log::print_log * * @param level log level * @param format Format string * @param ... Print arguments for format string * */ void print_log(uint64_t level, const char* format, ...) __attribute__((format(printf,3,4))); public: /** * @brief Default log level. * */ static uint64_t defaultLevel; }; } #endif /* E_NETWORKLOG_HPP_ */
[ "wwiiiii@naver.com" ]
wwiiiii@naver.com
1699ce3c3bf537fcaa3af5dc6c6ba404a666d600
aad6b08ee56c2760b207d562f16be0a5bb8e3e2a
/tags/Doduo_1.1/BAL/WKAL/Concretizations/Graphics/WK/BCIntRectWK.h
184ac411376ea626c23d90f21f62e417b0887abe
[]
no_license
Chengjian-Tang/owb-mirror
5ffd127685d06f2c8e00832c63cd235bec63f753
b48392a07a2f760bfc273d8d8b80e8d3f43b6b55
refs/heads/master
2021-05-27T02:09:03.654458
2010-06-23T11:10:12
2010-06-23T11:10:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,932
h
/* * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef IntRect_h #define IntRect_h #include "IntPoint.h" #include <wtf/Platform.h> #if PLATFORM(CG) typedef struct CGRect CGRect; #endif #if PLATFORM(MAC) #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES typedef struct CGRect NSRect; #else typedef struct _NSRect NSRect; #endif #endif #if PLATFORM(WIN) typedef struct tagRECT RECT; #elif PLATFORM(QT) QT_BEGIN_NAMESPACE class QRect; QT_END_NAMESPACE #elif PLATFORM(GTK) typedef struct _GdkRectangle GdkRectangle; #endif #if PLATFORM(SYMBIAN) class TRect; #endif #if PLATFORM(WX) class wxRect; #endif namespace WKAL { class FloatRect; class IntRect { public: IntRect() { } IntRect(const IntPoint& location, const IntSize& size) : m_location(location), m_size(size) { } IntRect(int x, int y, int width, int height) : m_location(IntPoint(x, y)), m_size(IntSize(width, height)) { } explicit IntRect(const FloatRect& rect); // don't do this implicitly since it's lossy IntPoint location() const { return m_location; } IntSize size() const { return m_size; } void setLocation(const IntPoint& location) { m_location = location; } void setSize(const IntSize& size) { m_size = size; } int x() const { return m_location.x(); } int y() const { return m_location.y(); } int width() const { return m_size.width(); } int height() const { return m_size.height(); } void setX(int x) { m_location.setX(x); } void setY(int y) { m_location.setY(y); } void setWidth(int width) { m_size.setWidth(width); } void setHeight(int height) { m_size.setHeight(height); } // Be careful with these functions. The point is considered to be to the right and below. These are not // substitutes for right() and bottom(). IntPoint topLeft() const { return m_location; } IntPoint topRight() const { return IntPoint(right() - 1, y()); } IntPoint bottomLeft() const { return IntPoint(x(), bottom() - 1); } IntPoint bottomRight() const { return IntPoint(right() - 1, bottom() - 1); } bool isEmpty() const { return m_size.isEmpty(); } int right() const { return x() + width(); } int bottom() const { return y() + height(); } void move(const IntSize& s) { m_location += s; } void move(int dx, int dy) { m_location.move(dx, dy); } bool intersects(const IntRect&) const; bool contains(const IntRect&) const; // This checks to see if the rect contains x,y in the traditional sense. // Equivalent to checking if the rect contains a 1x1 rect below and to the right of (px,py). bool contains(int px, int py) const { return px >= x() && px < right() && py >= y() && py < bottom(); } bool contains(const IntPoint& point) const { return contains(point.x(), point.y()); } void intersect(const IntRect&); void unite(const IntRect&); void inflateX(int dx) { m_location.setX(m_location.x() - dx); m_size.setWidth(m_size.width() + dx + dx); } void inflateY(int dy) { m_location.setY(m_location.y() - dy); m_size.setHeight(m_size.height() + dy + dy); } void inflate(int d) { inflateX(d); inflateY(d); } void scale(float s); #if PLATFORM(WX) IntRect(const wxRect&); operator wxRect() const; #endif #if PLATFORM(WIN) IntRect(const RECT&); operator RECT() const; #elif PLATFORM(QT) IntRect(const QRect&); operator QRect() const; #elif PLATFORM(GTK) IntRect(const GdkRectangle&); operator GdkRectangle() const; #endif #if PLATFORM(SYMBIAN) IntRect(const TRect&); operator TRect() const; TRect Rect() const; #endif #if PLATFORM(CG) operator CGRect() const; #endif #if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES) operator NSRect() const; #endif private: IntPoint m_location; IntSize m_size; }; inline IntRect intersection(const IntRect& a, const IntRect& b) { IntRect c = a; c.intersect(b); return c; } inline IntRect unionRect(const IntRect& a, const IntRect& b) { IntRect c = a; c.unite(b); return c; } inline bool operator==(const IntRect& a, const IntRect& b) { return a.location() == b.location() && a.size() == b.size(); } inline bool operator!=(const IntRect& a, const IntRect& b) { return a.location() != b.location() || a.size() != b.size(); } #if PLATFORM(CG) IntRect enclosingIntRect(const CGRect&); #endif #if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES) IntRect enclosingIntRect(const NSRect&); #endif } // namespace WebCore #endif // IntRect_h
[ "sroret@a3cd4a6d-042f-0410-9b26-d8d12826d3fb" ]
sroret@a3cd4a6d-042f-0410-9b26-d8d12826d3fb
0a53e613cecf1e5ca7ee48b8a5f830fae0c544eb
03a975e0188b19d3d3d32d37b27651285dc5412e
/tools/topology_tools.cpp
859928b64d5d27fb769f4cc3a649b42ec0ebc4f7
[]
no_license
UG4/plugin_ProMesh
30b42eaaa7698d61aeee8076d9fe1940b5aa1d33
df97012b1c204b9f8ff01d49932da715e741e58f
refs/heads/master
2021-06-14T15:50:52.279213
2021-03-20T22:06:10
2021-03-20T22:06:10
47,968,484
4
10
null
2021-03-20T22:06:10
2015-12-14T10:39:25
C++
UTF-8
C++
false
false
13,672
cpp
/* * Copyright (c) 2013-2017: G-CSC, Goethe University Frankfurt * Author: Sebastian Reiter * * This file is part of UG4. * * UG4 is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License version 3 (as published by the * Free Software Foundation) with the following additional attribution * requirements (according to LGPL/GPL v3 ยง7): * * (1) The following notice must be displayed in the Appropriate Legal Notices * of covered and combined works: "Based on UG4 (www.ug4.org/license)". * * (2) The following notice must be displayed at a prominent place in the * terminal output of covered works: "Based on UG4 (www.ug4.org/license)". * * (3) The following bibliography is recommended for citation and must be * preserved in all covered files: * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively * parallel geometric multigrid solver on hierarchically distributed grids. * Computing and visualization in science 16, 4 (2013), 151-164" * "Vogel, A., Reiter, S., Rupp, M., Nรคgel, A., and Wittum, G. UG4 -- a novel * flexible software system for simulating pde based models on high performance * computers. Computing and visualization in science 16, 4 (2013), 165-179" * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. */ #include <vector> #include "topology_tools.h" #include "lib_grid/algorithms/hexahedron_util.h" #include "lib_grid/callbacks/selection_callbacks.h" using namespace std; namespace ug{ namespace promesh{ void EraseSelectedElements( Mesh* obj, bool eraseUnusedVrts, bool eraseUnusedEdges, bool eraseUnusedFaces) { // adjust selection Selector& sel = obj->selector(); SelectAssociatedEdges(sel, sel.begin<Vertex>(), sel.end<Vertex>()); SelectAssociatedFaces(sel, sel.begin<Edge>(), sel.end<Edge>()); SelectAssociatedVolumes(sel, sel.begin<Face>(), sel.end<Face>()); if(eraseUnusedFaces) SelectInnerSelectionFaces(sel); if(eraseUnusedEdges) SelectInnerSelectionEdges(sel); if(eraseUnusedVrts) SelectInnerSelectionVertices(sel); // erase selected elements Grid& grid = obj->grid(); grid.erase(sel.begin<Volume>(), sel.end<Volume>()); grid.erase(sel.begin<Face>(), sel.end<Face>()); grid.erase(sel.begin<Edge>(), sel.end<Edge>()); grid.erase(sel.begin<Vertex>(), sel.end<Vertex>()); } /// returns the number of removed vertices size_t RemoveDoubles(Mesh* obj, number threshold) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); size_t numVrts = grid.num<Vertex>(); ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(), obj->position_attachment(), threshold); return numVrts - grid.num<Vertex>(); } size_t RemoveDoubleEdges(Mesh* obj) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); size_t numEdges= grid.num<Edge>(); RemoveDuplicates(grid, sel.begin<Edge>(), sel.end<Edge>()); return numEdges - grid.num<Edge>(); } size_t RemoveDoubleFaces(Mesh* obj) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); size_t numFaces= grid.num<Face>(); RemoveDuplicates(grid, sel.begin<Face>(), sel.end<Face>()); return numFaces - grid.num<Face>(); } void MergeAtFirst(Mesh* obj) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); Mesh::position_accessor_t& aaPos = obj->position_accessor(); SelectAssociatedGridObjects(sel); vector3 first = aaPos[*sel.vertices_begin()]; Vertex* vrt = MergeMultipleVertices(grid, sel.vertices_begin(), sel.vertices_end()); if(vrt) aaPos[vrt] = first; } void MergeAtCenter(Mesh* obj) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); Mesh::position_accessor_t& aaPos = obj->position_accessor(); SelectAssociatedGridObjects(sel); vector3 center; CalculateCenter(center, sel, aaPos); Vertex* vrt = MergeMultipleVertices(grid, sel.vertices_begin(), sel.vertices_end()); if(vrt) aaPos[vrt] = center; } void MergeAtLast(Mesh* obj) { Mesh::position_accessor_t& aaPos = obj->position_accessor(); Grid& grid = obj->grid(); Selector& sel = obj->selector(); SelectAssociatedGridObjects(sel); // todo: This iteration shouldn't be necessary! VertexIterator vrtIter = sel.begin<Vertex>(); Vertex* lastVrt = *vrtIter; for(; vrtIter != sel.end<Vertex>(); ++vrtIter) lastVrt = *vrtIter; vector3 last = aaPos[lastVrt]; Vertex* vrt = MergeMultipleVertices(grid, sel.vertices_begin(), sel.vertices_end()); if(vrt) aaPos[vrt] = last; } void CollapseEdge(Mesh* obj) { using namespace std; Grid& grid = obj->grid(); Selector& sel = obj->selector(); Mesh::position_accessor_t& aaPos = obj->position_accessor(); vector<Face*> vFaces; vector<Edge*> vEdges; while(sel.num<Edge>() > 0){ Edge* e = *sel.begin<Edge>(); // to make sure that all selected edges are collapsed, // we have to check the adjacent triangles CollectFaces(vFaces, grid, e); for(size_t i = 0; i < vFaces.size(); ++i){ Face* f = vFaces[i]; if(f->num_edges() == 3){ CollectEdges(vEdges, grid, f); int counter = 0; for(size_t j = 0; j < 3; ++j){ if(sel.is_selected(vEdges[j])) ++counter; } // if two edges are selected, we have // to mark the unselected edge, too (since we // don't know which will be removed). if(counter == 2){ for(size_t j = 0; j < 3; ++j) sel.select(vEdges[j]); } } } // calculate the center VecAdd(aaPos[e->vertex(0)], aaPos[e->vertex(0)], aaPos[e->vertex(1)]); VecScale(aaPos[e->vertex(0)], aaPos[e->vertex(0)], 0.5); // perform collapse CollapseEdge(grid, e, e->vertex(0)); } } void SplitEdge(Mesh* obj) { using namespace std; // collect all edges that shall be splitted in a vector // since new edges will be automatically selected again. Grid& grid = obj->grid(); Selector& sel = obj->selector(); Mesh::position_accessor_t& aaPos = obj->position_accessor(); vector<Edge*> vEdges; for(EdgeIterator iter = sel.begin<Edge>(); iter != sel.end<Edge>(); ++iter) { vEdges.push_back(*iter); } // iterate through all edges in the vector and split them for(size_t i = 0; i < vEdges.size(); ++i){ vector3 center = CalculateCenter(vEdges[i], aaPos); RegularVertex* vrt = ug::SplitEdge<RegularVertex>(grid, vEdges[i]); aaPos[vrt] = center; } } void SwapEdge(Mesh* obj) { using namespace std; // collect all edges that shall be swapped in a vector // since new edges will be automatically selected again. Grid& grid = obj->grid(); Selector& sel = obj->selector(); vector<Edge*> vEdges; for(EdgeIterator iter = sel.begin<Edge>(); iter != sel.end<Edge>(); ++iter) { vEdges.push_back(*iter); } // iterate through all edges in the vector and swap them // if they are adjacent to two triangles Face* faces[2]; for(size_t i = 0; i < vEdges.size(); ++i){ int numFaces = GetAssociatedFaces(faces, grid, vEdges[i], 2); if(numFaces == 2){ if(faces[0]->num_vertices() == 3 && faces[1]->num_vertices() == 3){ SwapEdge(grid, vEdges[i]); } } } } void PlaneCut(Mesh* obj, const vector3& p, const vector3& n) { Selector& sel = obj->selector(); CutEdgesWithPlane(sel, p, n); } void AdjustEdgeOrientation(Mesh* obj) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); AdjustEdgeOrientationToFaceOrientation( grid, sel.begin<Edge>(), sel.end<Edge>(), IsSelected(sel)); } void FixFaceOrientation(Mesh* obj) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); FixFaceOrientation(grid, sel.begin<Face>(), sel.end<Face>()); } void FixFaceSubsetOrientations(Mesh* obj) { Grid& grid = obj->grid(); SubsetHandler& sh = obj->subset_handler(); for(int i = 0; i < sh.num_subsets(); ++i){ FixFaceOrientation(grid, sh.begin<Face>(i), sh.end<Face>(i)); } } int FixVolumeOrientation(Mesh* obj) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); Mesh::position_accessor_t& aaPos = obj->position_accessor(); return FixOrientation(grid, sel.begin<Volume>(), sel.end<Volume>(), aaPos); } void InvertFaceOrientation(Mesh* obj) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); InvertOrientation(grid, sel.begin<Face>(), sel.end<Face>()); } void ResolveEdgeIntersection(Mesh* obj, number snapThreshold) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); Mesh::position_accessor_t& aaPos = obj->position_accessor(); // the grid may now contain some degenerated triangles. We'll try to // remove most of them by projecting vertices onto close edges SelectAssociatedVertices(sel, sel.begin<Edge>(), sel.end<Edge>()); ProjectVerticesToCloseEdges(grid, sel.get_grid_objects(), obj->position_attachment(), snapThreshold); IntersectCloseEdges(grid, sel, aaPos, snapThreshold); // remove doubles now ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(), obj->position_attachment(), snapThreshold); } void ResolveTriangleIntersections(Mesh* obj, number snapThreshold) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); // Mesh::position_accessor_t& aaPos = obj->position_accessor(); // first we'll resolve triangle-triangle intersections ug::ResolveTriangleIntersections(grid, sel.begin<Triangle>(), sel.end<Triangle>(), snapThreshold, obj->position_attachment()); // the grid may now contain some degenerated triangles. We'll try to // remove most of them by projecting vertices onto close edges SelectAssociatedVertices(sel, sel.begin<Triangle>(), sel.end<Triangle>()); SelectAssociatedEdges(sel, sel.begin<Triangle>(), sel.end<Triangle>()); ProjectVerticesToCloseEdges(grid, sel.get_grid_objects(), obj->position_attachment(), snapThreshold); // remove doubles now ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(), obj->position_attachment(), snapThreshold); } void ProjectVerticesToCloseEdges(Mesh* obj, number snapThreshold) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); // Mesh::position_accessor_t& aaPos = obj->position_accessor(); ProjectVerticesToCloseEdges(grid, sel.get_grid_objects(), obj->position_attachment(), snapThreshold); // remove doubles now ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(), obj->position_attachment(), snapThreshold); } void ProjectVerticesToCloseFaces(Mesh* obj, number snapThreshold) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); //Mesh::position_accessor_t& aaPos = obj->position_accessor(); ProjectVerticesToCloseFaces(grid, sel, obj->position_attachment(), snapThreshold); // remove doubles now ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(), obj->position_attachment(), snapThreshold); } void IntersectCloseEdges(Mesh* obj, number snapThreshold) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); Mesh::position_accessor_t& aaPos = obj->position_accessor(); IntersectCloseEdges(grid, sel, aaPos, snapThreshold); } void ResolveSelfIntersections(Mesh* obj, number snapThreshold) { Grid& grid = obj->grid(); Selector& sel = obj->selector(); Mesh::position_accessor_t& aaPos = obj->position_accessor(); Triangulate(grid, sel.begin<Quadrilateral>(), sel.end<Quadrilateral>(), &aaPos); bool intersectFaces = sel.num<Face>() > 0; SelectAssociatedEdges(sel, sel.begin<Face>(), sel.end<Face>()); SelectAssociatedVertices(sel, sel.begin<Face>(), sel.end<Face>()); // remove doubles again ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(), obj->position_attachment(), snapThreshold); if(intersectFaces) ProjectVerticesToCloseFaces(grid, sel, obj->position_attachment(), snapThreshold); ProjectVerticesToCloseEdges(grid, sel.get_grid_objects(), obj->position_attachment(), snapThreshold); // resolve face intersections if(intersectFaces){ ug::ResolveTriangleIntersections(grid, sel.begin<Triangle>(), sel.end<Triangle>(), snapThreshold, obj->position_attachment()); // the grid may now contain some degenerated Faces. We'll try to // remove most of them by projecting vertices onto close edges SelectAssociatedEdges(sel, sel.begin<Face>(), sel.end<Face>()); SelectAssociatedVertices(sel, sel.begin<Face>(), sel.end<Face>()); ProjectVerticesToCloseEdges(grid, sel.get_grid_objects(), obj->position_attachment(), snapThreshold); } else{ Mesh::position_accessor_t& aaPos = obj->position_accessor(); IntersectCloseEdges(grid, sel, aaPos, snapThreshold); } // remove doubles again ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(), obj->position_attachment(), snapThreshold); } void CreateHexahedraFromSelectedPrisms(Mesh* obj) { // todo: better worst case performance vector<Volume*> delVols; vector<Volume*> newVols; Grid& grid = obj->grid(); Selector& sel = obj->selector(); for(PrismIterator iprism = sel.begin<Prism>(); iprism != sel.end<Prism>(); ++iprism) { Prism* p0 = *iprism; PrismIterator iOtherPrism = iprism; ++iOtherPrism; for(;iOtherPrism != sel.end<Prism>(); ++iOtherPrism) { Prism* p1 = *iOtherPrism; Hexahedron* hex = CreateHexahedronFromPrisms(grid, p0, p1); if(hex){ newVols.push_back(hex); delVols.push_back(p0); delVols.push_back(p1); sel.deselect(p1); break; } } } sel.clear(); if(!delVols.empty()){ sel.select(delVols.begin(), delVols.end()); EraseSelectedElements(obj, true, true, true); } if(!newVols.empty()) sel.select(newVols.begin(), newVols.end()); } }}// end of namespace
[ "s.b.reiter@gmail.com" ]
s.b.reiter@gmail.com
8afb4ddcb87e6dde70b25838afb89860ae1935bb
18aeeee08da1ca1ec2f68e73510e39630f662635
/src/ConstanzeComponent.hpp
460f1d03e681d40904bf89de0058b8097385fea2
[]
no_license
openwns/constanze
bcac826526c845cd9f844c2c4f019cc234a14bf0
1804214f71552744ca2ec719fcb250df289d8725
refs/heads/master
2016-08-07T18:00:44.409415
2014-06-29T23:28:28
2014-06-29T23:28:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,297
hpp
/******************************************************************************* * This file is part of openWNS (open Wireless Network Simulator) * _____________________________________________________________________________ * * Copyright (C) 2004-2007 * Chair of Communication Networks (ComNets) * Kopernikusstr. 16, D-52074 Aachen, Germany * phone: ++49-241-80-27910, * fax: ++49-241-80-22242 * email: info@openwns.org * www: http://www.openwns.org * _____________________________________________________________________________ * * openWNS is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License version 2 as published by the * Free Software Foundation; * * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ #ifndef CONSTANZE_COMPONENT_HPP #define CONSTANZE_COMPONENT_HPP #include <CONSTANZE/Generator.hpp> #include <WNS/node/component/Component.hpp> #include <WNS/logger/Logger.hpp> #include <list> namespace constanze { class GeneratorBase; class Binding; class Listener; /** * @brief Constanze Component (layer above IP,UDP,TCP,SimpleTL,Glue) */ class ConstanzeComponent : virtual public wns::node::component::Component { public: /** * @brief ConstanzeComponent constructor * * @param[in] _node The parent node. * * @param[in] _pyco Component configuration of type * constanze.ConstanzeComponent */ ConstanzeComponent( wns::node::Interface* _node, const wns::pyconfig::View& _pyco); /** * @brief ConstanzeComponent destructor */ virtual ~ConstanzeComponent(); /** * @brief Connect to required components within the same node. */ virtual void onNodeCreated(); /** * @brief Connect to components in other nodes */ virtual void onWorldCreated(); /** * @brief Clean up before EventScheduler really stops */ virtual void onShutdown(); private: /** * @brief Services are added here */ virtual void doStartup(); /** * @brief All generators created are put to this list. */ std::list<constanze::GeneratorBase*> listOfGenerators; /** * @brief Bindings created for the generators. */ std::list<constanze::Binding*> listOfGeneratorBindings; /** * @brief All listeners created are put to this list. */ std::list<constanze::Listener*> listOfListeners; /** * @brief Bindings created for the listeners. */ std::list<constanze::Binding*> listOfListenerBindings; /** * @brief The components configuration. */ wns::pyconfig::View pyco; /** * @brief The Logger instance. */ wns::logger::Logger log; }; } #endif // _CONSTANZE_COMPONENT_HPP /* Local Variables: mode: c++ fill-column: 80 c-basic-offset: 8 c-comment-only-line-offset: 0 c-tab-always-indent: t indent-tabs-mode: t tab-width: 8 End: */
[ "mue@comnets.rwth-aachen.de" ]
mue@comnets.rwth-aachen.de
df8eaca34063fbe0ef0b9d725745533a3520138a
e8193b586e3376e6de82392aac66eb2feee4f7f7
/src/GafferSceneBindings/OptionsBinding.cpp
10e4c194e6d08138a4d7a49ec6905445a707a6a4
[ "BSD-3-Clause" ]
permissive
PaulDoessel/gaffer-play
eb31f4917f40b4815c12984f55e3aeba60b8dd8f
8b72dabb388e12424c230acfb0bd209049b01bd6
refs/heads/master
2021-01-12T15:18:35.508661
2016-10-22T00:07:02
2016-10-22T00:07:02
71,752,516
0
1
null
null
null
null
UTF-8
C++
false
false
2,465
cpp
////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2013, Image Engine Design Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above // copyright notice, this list of conditions and the following // disclaimer. // // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided with // the distribution. // // * Neither the name of John Haddon nor the names of // any other contributors to this software may be used to endorse or // promote products derived from this software without specific prior // written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////// #include "boost/python.hpp" #include "GafferBindings/DependencyNodeBinding.h" #include "GafferScene/StandardOptions.h" #include "GafferScene/CustomOptions.h" #include "GafferScene/DeleteOptions.h" #include "GafferScene/CopyOptions.h" #include "GafferSceneBindings/OptionsBinding.h" using namespace GafferScene; void GafferSceneBindings::bindOptions() { GafferBindings::DependencyNodeClass<Options>(); GafferBindings::DependencyNodeClass<StandardOptions>(); GafferBindings::DependencyNodeClass<CustomOptions>(); GafferBindings::DependencyNodeClass<DeleteOptions>(); GafferBindings::DependencyNodeClass<CopyOptions>(); }
[ "thehaddonyoof@gmail.com" ]
thehaddonyoof@gmail.com
0c49d36631f18dca9d1ba0f34e5c19440d8bc231
d555c767df66a7b3bde1eab92dc5d55c25973762
/internal/catch_list.hpp
85e19345a4d9fef457a5a417ba299aa0854a5300
[ "BSL-1.0" ]
permissive
Tryneus/Catch
c32c3ee4387722a897aa73ec74a352b0764b9149
52926d8f989cd2401d88c3892bb1ed1a56f1a698
refs/heads/master
2021-01-16T00:17:11.145192
2011-02-09T20:11:13
2011-02-09T20:11:13
1,343,925
0
0
null
null
null
null
UTF-8
C++
false
false
2,351
hpp
/* * catch_list.hpp * Catch * * Created by Phil on 5/11/2010. * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. * * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ #ifndef TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED #define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED #include "catch_commandline.hpp" #include <limits> namespace Catch { /////////////////////////////////////////////////////////////////////////// inline int List ( const Config& config ) { if( config.listWhat() & Config::List::Reports ) { std::cout << "Available reports:\n"; IReporterRegistry::FactoryMap::const_iterator it = Hub::getReporterRegistry().getFactories().begin(); IReporterRegistry::FactoryMap::const_iterator itEnd = Hub::getReporterRegistry().getFactories().end(); for(; it != itEnd; ++it ) { // !TBD: consider listAs() std::cout << "\t" << it->first << "\n\t\t'" << it->second->getDescription() << "'\n"; } std::cout << std::endl; } if( config.listWhat() & Config::List::Tests ) { std::cout << "Available tests:\n"; std::vector<TestCaseInfo>::const_iterator it = Hub::getTestCaseRegistry().getAllTests().begin(); std::vector<TestCaseInfo>::const_iterator itEnd = Hub::getTestCaseRegistry().getAllTests().end(); for(; it != itEnd; ++it ) { // !TBD: consider listAs() std::cout << "\t" << it->getName() << "\n\t\t '" << it->getDescription() << "'\n"; } std::cout << std::endl; } if( ( config.listWhat() & Config::List::All ) == 0 ) { std::cerr << "Unknown list type" << std::endl; return std::numeric_limits<int>::max(); } if( config.getReporter() ) { std::cerr << "Reporters ignored when listing" << std::endl; } if( !config.testsSpecified() ) { std::cerr << "Test specs ignored when listing" << std::endl; } return 0; } } // end namespace Catch #endif // TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
[ "phil@twobluecubes.com" ]
phil@twobluecubes.com
dd29684e3e8874a1c605e53236e39a52a5b3fe58
d6e3150e58f78ef0c2c08f5ef4493b9951c8bb7d
/Chapter12/Practice12_1/Practice12_1.cpp
24431c7965910eac2b5a5a820e9d1be93c95a94c
[]
no_license
SuperNova911/MFC-Class
fdba15bc6c456322bd6b758de397cebd4f305f7c
02d53bc34626f6991ea89ce4eb6c341574a5498a
refs/heads/master
2021-04-15T15:37:15.289858
2018-06-15T03:29:58
2018-06-15T03:29:58
126,199,036
0
0
null
null
null
null
UHC
C++
false
false
5,943
cpp
// Practice12_1.cpp : ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์— ๋Œ€ํ•œ ํด๋ž˜์Šค ๋™์ž‘์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. // #include "stdafx.h" #include "afxwinappex.h" #include "afxdialogex.h" #include "Practice12_1.h" #include "MainFrm.h" #include "Practice12_1Doc.h" #include "Practice12_1View.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CPractice12_1App BEGIN_MESSAGE_MAP(CPractice12_1App, CWinAppEx) ON_COMMAND(ID_APP_ABOUT, &CPractice12_1App::OnAppAbout) // ํ‘œ์ค€ ํŒŒ์ผ์„ ๊ธฐ์ดˆ๋กœ ํ•˜๋Š” ๋ฌธ์„œ ๋ช…๋ น์ž…๋‹ˆ๋‹ค. ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) END_MESSAGE_MAP() // CPractice12_1App ์ƒ์„ฑ CPractice12_1App::CPractice12_1App() { m_bHiColorIcons = TRUE; // ๋‹ค์‹œ ์‹œ์ž‘ ๊ด€๋ฆฌ์ž ์ง€์› m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS; #ifdef _MANAGED // ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์„ ๊ณต์šฉ ์–ธ์–ด ๋Ÿฐํƒ€์ž„ ์ง€์›์„ ์‚ฌ์šฉํ•˜์—ฌ ๋นŒ๋“œํ•œ ๊ฒฝ์šฐ(/clr): // 1) ์ด ์ถ”๊ฐ€ ์„ค์ •์€ ๋‹ค์‹œ ์‹œ์ž‘ ๊ด€๋ฆฌ์ž ์ง€์›์ด ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š” ๋ฐ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. // 2) ํ”„๋กœ์ ํŠธ์—์„œ ๋นŒ๋“œํ•˜๋ ค๋ฉด System.Windows.Forms์— ๋Œ€ํ•œ ์ฐธ์กฐ๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException); #endif // TODO: ์•„๋ž˜ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ID ๋ฌธ์ž์—ด์„ ๊ณ ์œ  ID ๋ฌธ์ž์—ด๋กœ ๋ฐ”๊พธ์‹ญ์‹œ์˜ค(๊ถŒ์žฅ). // ๋ฌธ์ž์—ด์— ๋Œ€ํ•œ ์„œ์‹: CompanyName.ProductName.SubProduct.VersionInformation SetAppID(_T("Practice12_1.AppID.NoVersion")); // TODO: ์—ฌ๊ธฐ์— ์ƒ์„ฑ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. // InitInstance์— ๋ชจ๋“  ์ค‘์š”ํ•œ ์ดˆ๊ธฐํ™” ์ž‘์—…์„ ๋ฐฐ์น˜ํ•ฉ๋‹ˆ๋‹ค. } // ์œ ์ผํ•œ CPractice12_1App ๊ฐœ์ฒด์ž…๋‹ˆ๋‹ค. CPractice12_1App theApp; // CPractice12_1App ์ดˆ๊ธฐํ™” BOOL CPractice12_1App::InitInstance() { // ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ๋งค๋‹ˆํŽ˜์ŠคํŠธ๊ฐ€ ComCtl32.dll ๋ฒ„์ „ 6 ์ด์ƒ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋น„์ฃผ์–ผ ์Šคํƒ€์ผ์„ // ์‚ฌ์šฉํ•˜๋„๋ก ์ง€์ •ํ•˜๋Š” ๊ฒฝ์šฐ, Windows XP ์ƒ์—์„œ ๋ฐ˜๋“œ์‹œ InitCommonControlsEx()๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. // InitCommonControlsEx()๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฉด ์ฐฝ์„ ๋งŒ๋“ค ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์—์„œ ์‚ฌ์šฉํ•  ๋ชจ๋“  ๊ณต์šฉ ์ปจํŠธ๋กค ํด๋ž˜์Šค๋ฅผ ํฌํ•จํ•˜๋„๋ก // ์ด ํ•ญ๋ชฉ์„ ์„ค์ •ํ•˜์‹ญ์‹œ์˜ค. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); // OLE ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค. if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // RichEdit ์ปจํŠธ๋กค์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด AfxInitRichEdit2()๊ฐ€ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. // AfxInitRichEdit2(); // ํ‘œ์ค€ ์ดˆ๊ธฐํ™” // ์ด๋“ค ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์ตœ์ข… ์‹คํ–‰ ํŒŒ์ผ์˜ ํฌ๊ธฐ๋ฅผ ์ค„์ด๋ ค๋ฉด // ์•„๋ž˜์—์„œ ํ•„์š” ์—†๋Š” ํŠน์ • ์ดˆ๊ธฐํ™” // ๋ฃจํ‹ด์„ ์ œ๊ฑฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. // ํ•ด๋‹น ์„ค์ •์ด ์ €์žฅ๋œ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ํ‚ค๋ฅผ ๋ณ€๊ฒฝํ•˜์‹ญ์‹œ์˜ค. // TODO: ์ด ๋ฌธ์ž์—ด์„ ํšŒ์‚ฌ ๋˜๋Š” ์กฐ์ง์˜ ์ด๋ฆ„๊ณผ ๊ฐ™์€ // ์ ์ ˆํ•œ ๋‚ด์šฉ์œผ๋กœ ์ˆ˜์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. SetRegistryKey(_T("๋กœ์ปฌ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ๋งˆ๋ฒ•์‚ฌ์—์„œ ์ƒ์„ฑ๋œ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ")); LoadStdProfileSettings(4); // MRU๋ฅผ ํฌํ•จํ•˜์—ฌ ํ‘œ์ค€ INI ํŒŒ์ผ ์˜ต์…˜์„ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค. InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์˜ ๋ฌธ์„œ ํ…œํ”Œ๋ฆฟ์„ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค. ๋ฌธ์„œ ํ…œํ”Œ๋ฆฟ์€ // ๋ฌธ์„œ, ํ”„๋ ˆ์ž„ ์ฐฝ ๋ฐ ๋ทฐ ์‚ฌ์ด์˜ ์—ฐ๊ฒฐ ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CPractice12_1Doc), RUNTIME_CLASS(CMainFrame), // ์ฃผ SDI ํ”„๋ ˆ์ž„ ์ฐฝ์ž…๋‹ˆ๋‹ค. RUNTIME_CLASS(CPractice12_1View)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // ํ‘œ์ค€ ์…ธ ๋ช…๋ น, DDE, ํŒŒ์ผ ์—ด๊ธฐ์— ๋Œ€ํ•œ ๋ช…๋ น์ค„์„ ๊ตฌ๋ฌธ ๋ถ„์„ํ•ฉ๋‹ˆ๋‹ค. CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // ๋ช…๋ น์ค„์— ์ง€์ •๋œ ๋ช…๋ น์„ ๋””์ŠคํŒจ์น˜ํ•ฉ๋‹ˆ๋‹ค. // ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์ด /RegServer, /Register, /Unregserver ๋˜๋Š” /Unregister๋กœ ์‹œ์ž‘๋œ ๊ฒฝ์šฐ FALSE๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. if (!ProcessShellCommand(cmdInfo)) return FALSE; // ์ฐฝ ํ•˜๋‚˜๋งŒ ์ดˆ๊ธฐํ™”๋˜์—ˆ์œผ๋ฏ€๋กœ ์ด๋ฅผ ํ‘œ์‹œํ•˜๊ณ  ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; } int CPractice12_1App::ExitInstance() { //TODO: ์ถ”๊ฐ€ํ•œ ์ถ”๊ฐ€ ๋ฆฌ์†Œ์Šค๋ฅผ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. AfxOleTerm(FALSE); return CWinAppEx::ExitInstance(); } // CPractice12_1App ๋ฉ”์‹œ์ง€ ์ฒ˜๋ฆฌ๊ธฐ // ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ์ •๋ณด์— ์‚ฌ์šฉ๋˜๋Š” CAboutDlg ๋Œ€ํ™” ์ƒ์ž์ž…๋‹ˆ๋‹ค. class CAboutDlg : public CDialogEx { public: CAboutDlg(); // ๋Œ€ํ™” ์ƒ์ž ๋ฐ์ดํ„ฐ์ž…๋‹ˆ๋‹ค. #ifdef AFX_DESIGN_TIME enum { IDD = IDD_ABOUTBOX }; #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ์ง€์›์ž…๋‹ˆ๋‹ค. // ๊ตฌํ˜„์ž…๋‹ˆ๋‹ค. protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) END_MESSAGE_MAP() // ๋Œ€ํ™” ์ƒ์ž๋ฅผ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ๋ช…๋ น์ž…๋‹ˆ๋‹ค. void CPractice12_1App::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } // CPractice12_1App ์‚ฌ์šฉ์ž ์ง€์ • ๋กœ๋“œ/์ €์žฅ ๋ฉ”์„œ๋“œ void CPractice12_1App::PreLoadState() { BOOL bNameValid; CString strName; bNameValid = strName.LoadString(IDS_EDIT_MENU); ASSERT(bNameValid); GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT); } void CPractice12_1App::LoadCustomState() { } void CPractice12_1App::SaveCustomState() { } // CPractice12_1App ๋ฉ”์‹œ์ง€ ์ฒ˜๋ฆฌ๊ธฐ
[ "suwhan77@naver.com" ]
suwhan77@naver.com
3954dabd846b8f2cbc36366dfda6169fb4d952be
2c20040abf2996ba02858ce47a661b7ce280583c
/Benchmark/IsaMubuf.h
de59f0c2bc805e2956f7f793d61d4899a8028398
[]
no_license
carlushuang/auto_gen
0157c2bb93f94a1ed446b13f0f3f293b9ad9fa75
7e5e0e27cc7e0a7403c0afcca02c69caef07d6cd
refs/heads/master
2020-04-04T18:54:30.023997
2018-11-20T05:13:10
2018-11-20T05:13:10
156,184,552
0
0
null
2018-11-05T08:30:05
2018-11-05T08:30:04
null
GB18030
C++
false
false
3,411
h
#pragma once #include "SampleConfig.h" #include "ProblemControl.h" #include "IsaMubufKernelWriter.h" /************************************************************************/ /* solutionๆŽงๅˆถ */ /************************************************************************/ class MubufSolution : public SolutionCtrlBase { private: T_KernelArgu d_a, d_b, d_c; public: /************************************************************************/ /* ๆ นๆฎproblemๅ‚ๆ•ฐๆˆsolutionๅ‚ๆ•ฐ็ฉบ้—ด */ /************************************************************************/ E_ReturnState GenerateSolutionConfigs(); /************************************************************************/ /* ็”ณ่ฏทๆ˜พๅญ˜ */ /************************************************************************/ E_ReturnState InitDev(); /************************************************************************/ /* ่ฟ”ๅ›ž็ป“ๆžœ */ /************************************************************************/ E_ReturnState GetBackResult(); /************************************************************************/ /* ้‡Šๆ”พๆ˜พๅญ˜ */ /************************************************************************/ void ReleaseDev(); /************************************************************************/ /* ๆ นๆฎsolutionๅ‚ๆ•ฐ็”Ÿๆˆsource, complierๅ’Œworksize */ /************************************************************************/ E_ReturnState GenerateSolution(); }; /************************************************************************/ /* ้—ฎ้ข˜ๆŽงๅˆถ */ /************************************************************************/ class MubufProblem : public ProblemCtrlBase { public: MubufProblem(std::string name) :ProblemCtrlBase(name) { Solution = new MubufSolution(); } public: /************************************************************************/ /* ็”Ÿๆˆ้—ฎ้ข˜็ฉบ้—ด */ /************************************************************************/ E_ReturnState GenerateProblemConfigs(); /************************************************************************/ /* ๅ‚ๆ•ฐๅˆๅง‹ๅŒ– */ /************************************************************************/ E_ReturnState InitHost(); /************************************************************************/ /* HOST็ซฏ */ /************************************************************************/ E_ReturnState Host(); /************************************************************************/ /* ๆ ก้ชŒ */ /************************************************************************/ E_ReturnState Verify(); /************************************************************************/ /* ้‡Šๆ”พ */ /************************************************************************/ void ReleaseHost(); };
[ "Fei.Wang@amd.com" ]
Fei.Wang@amd.com
21165d044c9b53913d573784e471a4217dd29b2f
04c203b271bf5532632a356bc8168c5c7c320f40
/lecture08/exercise08-A/template.cpp
6b1475a52c9558a38136e534302d5a7d538b6a10
[ "MIT" ]
permissive
leahhealy/cse-30872-fa21-examples
af30878a1594d5a69ee48b9edf25a89c46df7b5f
0ec31cdf9df7aefa3a708a95d49b129022495596
refs/heads/master
2023-08-25T14:13:33.946240
2021-11-07T18:43:07
2021-11-07T18:43:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
561
cpp
// Exercise 08-A: Largest Number #include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; // Functions bool read_numbers(vector<string> &numbers) { numbers.clear(); string line; if (getline(cin, line)) { stringstream ss(line); string n; while (ss >> n) { numbers.push_back(n); } } return numbers.size(); } // Main Execution int main(int argc, char *argv[]) { vector<string> numbers; // TODO: Read numbers, sort, and print return 0; }
[ "pbui@nd.edu" ]
pbui@nd.edu
93fe847067c9bea99f6d82f7592bba9253d7d12c
615c7f3cb391f9bb1b8a9b3fe2dcfc238d4956e5
/136/136/closest.cpp
b3df16a8824810e62ac95448014e5ec8e6be7a48
[]
no_license
HelpEverywhere/Phrase1
0f07d1d362a63b114cf4eec742d698b872401bb7
1120d7a2a546230731e2c7b54812619102795121
refs/heads/master
2021-01-10T17:46:32.489717
2016-02-11T14:53:20
2016-02-11T14:53:20
50,866,705
0
0
null
null
null
null
UTF-8
C++
false
false
507
cpp
#include "stdafx.h" int abs(int n){ if (n >= 0) return n; return -n; } void closest() { int n; //n = readnat(); scanf("%d", &n); if (0 == n) { printf("%d", n); } else { while (true) { int m, x = -1, i = 0; //m = readnat(); scanf("%d", &m); if (0 == m) { break; } else { while (i < m) { int p; //p = readnat(); scanf("%d", &p); if (-1 == x || abs(p - n) < abs(x - n)) x = p; ++i; } printf("%d\n",x); } } } }
[ "Mike.Zhang@maplesfs.com" ]
Mike.Zhang@maplesfs.com
312981ac31fb76117fc883ebf8ff5da9b0afc76e
0e5835408690913eb8b30c2cd81bb07f7e0cddc5
/Server/database.h
49b4dc3392052a41b356b0a23fa63fde5044a7ee
[]
no_license
Karaylev96/ChatApp
5bae0e2da843c3a6ae0553f0ba470d2ac0d0f978
1709685b0fe454fb8222b4bc34c107d19c34208e
refs/heads/master
2021-09-06T21:58:38.796904
2018-02-12T09:04:54
2018-02-12T09:04:54
115,921,677
0
0
null
null
null
null
UTF-8
C++
false
false
566
h
#ifndef DATABASE_H #define DATABASE_H #include <stdio.h> #include <QDebug> #include <QSqlDatabase> #include <QSqlQuery> #include <QSqlQueryModel> #include <QtSql/QSqlDatabase> #include <QtDebug> //#include <QtGui/QApplication> #include <QtSql> #include <QMessageLogger> #include <QTcpSocket> class Database { public: Database(); QSqlDatabase addQry(); bool findUser(const QString& user); void addToDataBase(const QString & user,const QString& ipAdres); private: QSqlDatabase m_db; int rc; }; #endif // DATABASE_H
[ "karailev96@gmail.com" ]
karailev96@gmail.com
c4f401c6eaeb7dc454c09a3e0267e4aa30eed420
2a9213024770a6c6c6b305bf3cf45f44e6398d47
/TestClient/GlobalInstance.cpp
f2c419561a9e8e958b9422e286fcfd2c295fcfc2
[ "Unlicense" ]
permissive
wissunpower/WeizenbierGame
195d36e7a32485dc76f06c2b0d5c11ee6d5b4a60
34f027c43055dfa6b05e62ca0b6c31271af013f3
refs/heads/main
2023-08-06T06:44:36.240176
2021-09-29T07:34:29
2021-09-29T07:34:29
390,057,582
0
0
Unlicense
2021-09-26T16:22:57
2021-07-27T16:43:06
C++
UTF-8
C++
false
false
179
cpp
#include "ResponseIntervalCollector.h" #include "GlobalInstance.h" ResponseIntervalCollector* ResponseIntervalCollectorInstance = Singleton<ResponseIntervalCollector>::Get();
[ "30381759+wissunpower@users.noreply.github.com" ]
30381759+wissunpower@users.noreply.github.com
c8e3734adfecfce28189617605e1de41c9588907
214355db2ebb44a0c63a993d96cd759e0061a33b
/EmptyProject/GameClear.h
a989b7c44cda67d38aa8285ce98eb95ee6006997
[]
no_license
JeongTaeLee/Gleise-518D
b59e24a2f5722155c732adc346ace087cd66c691
b9f69cb33b63f4a4e25e6399d8915e35daf95df9
refs/heads/master
2020-05-02T21:31:55.350658
2019-04-02T05:47:45
2019-04-02T05:47:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
230
h
#pragma once #include "GameObject.h" class GameClear : public GameObject { public: bool bCompleteProcess = false; public: GameClear(); virtual ~GameClear(); virtual void Init() override; virtual void Update() override; };
[ "jeongtae8633@gmail.com" ]
jeongtae8633@gmail.com
545b0594e58252eec1b81ba91f6ba1b7ca7b00b3
b65acdd4e28bac5b0b0cc088bded08cc80437ad8
/MVSProg/Task18/Project4/Project4/Source.cpp
392ac0723636cdcdd4d6ca1efd01d18bac93b562
[]
no_license
YulianStrus/Examples-of-academic-homeworks
44794bb234626319810f444a3115557b4e59d54f
f2fb2b5e02f069ff8f0cbc1a95c472ad2becad4c
refs/heads/master
2023-05-27T16:09:41.220326
2021-06-02T10:04:07
2021-06-02T10:04:07
313,245,187
0
0
null
null
null
null
UTF-8
C++
false
false
859
cpp
#include "iostream" #include "stdlib.h" #include "time.h" using namespace std; void main() { const int size = 20; int arr[size]; int Sum = 0; int x = 15, y = -15, srand(time(NULL)); for (int i = 0; i < size; i++) { arr[i] = rand() % (x - y) + y; cout << arr[i] << " "; } cout << endl; int tmp; bool change = true; while (change) { change = false; for (int i = 0; i < size - 1; ++i) { if (arr[i] > arr[i + 1]) { tmp = arr[i]; arr[i] = arr[i + 1]; arr[i + 1] = tmp; change = true; } } } change = true; while (change) { change = false; for (int i = 1; i < size - 1; i+=2) { if (arr[i] < arr[i + 2]) { tmp = arr[i]; arr[i] = arr[i + 2]; arr[i + 2] = tmp; change = true; } } } for (int i = 0; i < size; i++) cout << arr[i] << " "; cout << endl << endl; system("pause"); }
[ "stryulvas@ukr.net" ]
stryulvas@ukr.net
806927871fe91078c42527e503c28aa857d5ac52
961f6147855cb608eefd2ccb7927e65311133efa
/util/stream/aligned_ut.cpp
0aeb1a4aa422858d6f46961fc5d3a945be8816a2
[ "Apache-2.0" ]
permissive
kyper999/catboost_yandex
55a79890be28d46748cb4f55dd7a8ad24ab7b354
91c41df3d4997dbab57fc1b8a990017270da47c6
refs/heads/master
2022-10-31T11:21:22.438222
2017-07-18T10:25:29
2017-07-18T10:25:29
97,590,200
0
1
NOASSERTION
2022-10-23T09:35:09
2017-07-18T11:27:38
C
UTF-8
C++
false
false
1,296
cpp
#include "aligned.h" #include <library/unittest/registar.h> class TNastyInputStream: public TInputStream { public: TNastyInputStream() : Pos_(0) { } protected: size_t DoRead(void* buf, size_t len) override { if (len == 0) return 0; *static_cast<unsigned char*>(buf) = static_cast<unsigned char>(Pos_); ++Pos_; return 1; } size_t DoSkip(size_t len) override { if (len == 0) return 0; ++Pos_; return 1; } private: size_t Pos_; }; SIMPLE_UNIT_TEST_SUITE(TAlignedTest) { SIMPLE_UNIT_TEST(AlignInput) { TNastyInputStream input0; TAlignedInput alignedInput(&input0); char c = '\1'; alignedInput.Align(2); alignedInput.ReadChar(c); UNIT_ASSERT_VALUES_EQUAL(c, '\x0'); alignedInput.Align(2); alignedInput.ReadChar(c); UNIT_ASSERT_VALUES_EQUAL(c, '\x2'); alignedInput.Align(4); alignedInput.ReadChar(c); UNIT_ASSERT_VALUES_EQUAL(c, '\x4'); alignedInput.Align(16); alignedInput.ReadChar(c); UNIT_ASSERT_VALUES_EQUAL(c, '\x10'); alignedInput.Align(128); alignedInput.ReadChar(c); UNIT_ASSERT_VALUES_EQUAL(c, '\x80'); } }
[ "exprmntr@pepe.search.yandex.net" ]
exprmntr@pepe.search.yandex.net
8ce53c78d3aea48229b4cfa0000961e3a9290b9d
71beff3e20a58fdfeefb5590bba7082fe0bc8292
/src/GUI/Screen/ScreenHighscores.cpp
7c4776defe0303ac1416417df17dbce52a732b00
[]
no_license
milandamen/grimwall
351ea51f2018fdb8d4f388c682eca818344f7aec
04156b9d5c3bf8f4c31fdb282c6bccbd7e13ea8a
refs/heads/master
2021-06-15T15:38:33.057796
2017-01-17T13:55:23
2017-01-17T13:55:23
70,218,635
1
0
null
null
null
null
UTF-8
C++
false
false
2,151
cpp
#include "ScreenHighscores.h" ScreenHighscores::ScreenHighscores(IGame* game,AGUIManager* manager) : GUI(manager), game(game) { this->imgBg = manager->addImage("assets/gui/backgroundMenu.png", 0, 0, 1024, 768); this->lblSlot1 = manager->addLabel("", 172, 300); this->lblSlot1->setWidth(200); this->lblSlot1->setHeight(100); this->lblSlot1->setAlignment(GUITextAlignment::Center); this->lblSlot2 = manager->addLabel("", 402, 300); this->lblSlot2->setWidth(200); this->lblSlot2->setHeight(100); this->lblSlot2->setAlignment(GUITextAlignment::Center); this->lblSlot3 = manager->addLabel("", 632, 300); this->lblSlot3->setWidth(200); this->lblSlot3->setHeight(100); this->lblSlot3->setAlignment(GUITextAlignment::Center); this->btnReturn = manager->addImageButton("", "assets/gui/settingReturn.png", 172, 650, 680, 100); this->btnReturn->setForegroundColor(255, 255, 255, 255); this->btnReturn->setBackgroundColor(0, 0, 0, 0); this->btnReturn->onClick([&]() { this->game->setUI("MainMenu"); }); } ScreenHighscores::~ScreenHighscores() { delete this->imgBg; delete this->btnReturn; } void ScreenHighscores::hasBecomeActive() { if(!this->loaded) { this->loaded = true; try { SaveGame *s1 = this->game->getSaveGameManager()->load("slot1.sav"); this->lblSlot1->setCaption("Score: " + (s1 != nullptr ? s1->score : 0)); delete s1; } catch(...) { this->lblSlot1->setCaption("Score: 0"); } try { SaveGame *s2 = this->game->getSaveGameManager()->load("slot2.sav"); this->lblSlot2->setCaption("Score: " + (s2 != nullptr ? s2->score : 0)); delete s2; } catch (...) { this->lblSlot2->setCaption("Score: 0"); } try { SaveGame *s3 = this->game->getSaveGameManager()->load("slot3.sav"); this->lblSlot3->setCaption("Score: " + (s3 != nullptr ? s3->score : 0)); delete s3; } catch(...) { this->lblSlot3->setCaption("Score: 0"); } } }
[ "sromer@avans.nl" ]
sromer@avans.nl
b53c9d277d602579eb1577da2575c4600f90b298
6b5bddc107b800f7fd658413cf626ed6f801ed36
/funcs/debug.cpp
911394790a325948e6fdf6e8c8f6abdb04a44e6e
[ "CC0-1.0", "LicenseRef-scancode-public-domain" ]
permissive
ashr/notes
6c5cc00c1b0a2e30e87755b6f5ee32d463f28ed5
c449d10374b0bded8177e318892fdd58bcce3524
refs/heads/master
2021-05-11T04:39:22.877171
2018-01-17T15:01:05
2018-01-17T15:01:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
261
cpp
// address: 0x4086F4 // // debug_load_graphics loads debugging graphics. void debug_load_graphics(); // address: 0x40870F // // debug_cleanup releases the resources used for debugging. void debug_cleanup(); // address: 0x408721 // // TODO: add documentation.
[ "rnd0x00@gmail.com" ]
rnd0x00@gmail.com
bd01faf30f3a2293c8ea359f8e548081ead6d39d
9da7b17ab5b601735a8ec1a97853945185b76e7f
/olfaction-demo/src/ptu/ptu_control/src/ptu_control.cpp
e69b649ec582353abb9b5062015c8bcd3b77b4e5
[]
no_license
AsifArain/ros-catkin-ws
137556337b7ed08d23bbfd48dc52bc376d85fe2d
75c75075138eeae2ba50076bb3f2007dd6735570
refs/heads/master
2023-03-09T10:24:10.824014
2018-07-03T16:32:20
2018-07-03T16:32:20
342,039,263
0
0
null
null
null
null
UTF-8
C++
false
false
19,040
cpp
//============================================================= // Node Name: ptu_control.cpp // Version: 01 // Date: August 12th, 2013 // Description: Integrates joystick ptu control // as well as service requests from other modules //============================================================== #include "ptu_control.h" //------------------------------------------------------- // Joystick callback //------------------------------------------------------- void joyCallback(const sensor_msgs::Joy::ConstPtr& joy) { if (joy->buttons[reset_button]==1 && (!is_scan_ptu_requested && !is_gas_scan_requested)){ is_reset_ptu_requested=true; ROS_INFO("Here"); } else if (joy->buttons[scan_button]==1 && (!is_scan_ptu_requested && !is_gas_scan_requested)){ is_scan_ptu_requested=true; } else if (joy->buttons[gas_scan_button]==1 && (!is_scan_ptu_requested && !is_gas_scan_requested)){ is_gas_scan_requested=true; } else { if ((lock_trigger && joy->axes[lock_button] > 0 && is_lock_ptu_requested) || (!lock_trigger && joy->buttons[lock_button]==0 && is_lock_ptu_requested) ) is_lock_ptu_requested=false; else if((lock_trigger && joy->axes[lock_button] <=0) || (!lock_trigger && joy->buttons[lock_button]==1 ) ){ is_lock_ptu_requested=true; ptu_horizontal_request=joy->axes[3]; ptu_vertical_request=joy->axes[4]; } } } //------------------------------------------------------- // Pan callback //------------------------------------------------------- void panCallback(const amtec::AmtecState::ConstPtr& data_in) { pan_location_deg=rad2deg(data_in->position); } //------------------------------------------------------- // tilt callback //------------------------------------------------------- void tiltCallback(const amtec::AmtecState::ConstPtr& data_in) { tilt_location_deg=rad2deg(data_in->position); } //------------------------------------------------------- // Service callback //------------------------------------------------------- bool sweepRequestCallback(ptu_control::commandSweep::Request &req, ptu_control::commandSweep::Response& resp) { min_pan_srv= req.min_pan; min_tilt_srv=req.min_tilt; max_pan_srv=req.max_pan; max_tilt_srv=req.max_tilt; n_pan_srv=req.n_pan; n_tilt_srv=req.n_tilt; samp_delay_srv=req.samp_delay; service_running=true; return true; } //****************************************************************** //****************************************************************** //* Main Function * //****************************************************************** //****************************************************************** int main(int argc, char **argv) { ROS_INFO("*****************************************************"); ROS_INFO(" %s Node starting...",DEVICE_NAME); ROS_INFO("*****************************************************"); ros::init(argc, argv, DEVICE_NAME); ros::NodeHandle n; ros::Publisher state_pub = n.advertise<std_msgs::Int16>("/ptu_control/state", 1000); ros::ServiceServer service = n.advertiseService("/ptu_control/sweep", sweepRequestCallback); retrieveLaunchParameters(n); ros::Subscriber sub1 = n.subscribe(joystick_topic.c_str(), 1000, joyCallback); ros::Subscriber sub2 = n.subscribe("/amtec/pan_state", 1000, panCallback); ros::Subscriber sub3 = n.subscribe("/amtec/tilt_state", 1000, tiltCallback); ros::ServiceClient client = n.serviceClient<amtec::SetPosition>("/amtec/set_position"); ros::ServiceClient clientStatus = n.serviceClient<amtec::GetStatus>("/amtec/get_status"); amtec::SetPosition srv; ros::Rate loop_rate(10); service_running=false; is_gas_scan_requested=false; is_lock_ptu_requested=false; is_reset_ptu_requested=false; is_scan_ptu_requested=false; amtec::GetStatus srvState; controller_state=IDLE; resetPTUPosition(state_pub, client,clientStatus); while (ros::ok()){ if(joystick_control_enabled && !service_running) { //Joystick requests if(is_reset_ptu_requested){ ROS_INFO("Going to (0,0) position"); resetPTUPosition(state_pub, client,clientStatus); is_reset_ptu_requested=false; } else if(is_gas_scan_requested){ ROS_INFO("Scanning for gas"); //AZIF: if condition to perform or not the initian scan if (enable_environment_scan){ performSceneScan(state_pub, scan_min_tilt_deg, scan_max_tilt_deg, client,clientStatus); } sleep(1); performGasScan(state_pub, scan_min_tilt_deg, scan_max_tilt_deg, scan_min_pan_deg, scan_max_pan_deg, n_pan_joy, n_tilt_joy,samp_delay_joy,client,clientStatus); sleep(1); resetPTUPosition(state_pub, client,clientStatus); is_gas_scan_requested=false; } else if(is_scan_ptu_requested){ ROS_INFO("Scene scanning"); performSceneScan(state_pub, scan_min_tilt_deg, scan_max_tilt_deg, client,clientStatus); is_scan_ptu_requested=false; } else if(is_lock_ptu_requested){ bool info_received=false; double target_pan_deg=0; double target_tilt_deg=0; amtec::GetStatus srvState; do{ if(clientStatus.call(srvState)){ info_received=true; target_pan_deg=rad2deg(srvState.response.position_pan); target_tilt_deg=rad2deg(srvState.response.position_tilt); } else{ info_received=false; } sleep(0.1); }while(!info_received); //ROS_INFO("--- PTU locked, position %f,%f",target_pan_deg,target_tilt_deg); if (ptu_horizontal_request > 0){ target_pan_deg = target_pan_deg + interp(angle_increments_deg,fabs(ptu_horizontal_request),N_DELTA_DEG); //target_pan_deg=deg2rad(target_pan_deg); //target_tilt_deg=deg2rad(target_tilt_deg); srv.request.position_pan=deg2rad(target_pan_deg); srv.request.position_tilt=deg2rad(target_tilt_deg); client.call(srv); sleep(JOYSTICK_CONTROL_DELAY); } if(ptu_horizontal_request < 0){ target_pan_deg = target_pan_deg - interp(angle_increments_deg,fabs(ptu_horizontal_request),N_DELTA_DEG); //target_pan_deg=deg2rad(target_pan_deg); //target_tilt_deg=deg2rad(target_tilt_deg); srv.request.position_pan=deg2rad(target_pan_deg); srv.request.position_tilt=deg2rad(target_tilt_deg); client.call(srv); sleep(JOYSTICK_CONTROL_DELAY); } if (ptu_vertical_request > 0){ target_tilt_deg = target_tilt_deg - interp(angle_increments_deg,fabs(ptu_vertical_request),N_DELTA_DEG); //target_pan_deg=deg2rad(target_pan_deg); //target_tilt_deg=deg2rad(target_tilt_deg); srv.request.position_pan=deg2rad(target_pan_deg); srv.request.position_tilt=deg2rad(target_tilt_deg); client.call(srv); sleep(JOYSTICK_CONTROL_DELAY); } if(ptu_vertical_request < 0){ target_tilt_deg = target_tilt_deg + interp(angle_increments_deg,fabs(ptu_vertical_request),N_DELTA_DEG); //target_pan_deg=deg2rad(target_pan_deg); //target_tilt_deg=deg2rad(target_tilt_deg); srv.request.position_pan=deg2rad(target_pan_deg); srv.request.position_tilt=deg2rad(target_tilt_deg); client.call(srv); sleep(JOYSTICK_CONTROL_DELAY); } //ROS_INFO("Requested PTU LOCATION %f,%f",target_pan_deg,target_tilt_deg); } } //Service requestes// else if(service_running) { ROS_INFO("Service requested"); ROS_INFO("Pan %f,%f,%d",min_pan_srv,max_pan_srv,n_pan_srv); ROS_INFO("Tilt %f,%f,%d",min_tilt_srv,max_tilt_srv,n_tilt_srv); //AZIF: if condition here if (enable_environment_scan){ performSceneScan(state_pub, min_tilt_srv, max_tilt_srv, client,clientStatus); } sleep(0.5); performGasScan(state_pub, min_tilt_srv, max_tilt_srv, min_pan_srv, max_pan_srv, n_pan_srv, n_tilt_srv, samp_delay_srv,client,clientStatus); sleep(0.5); resetPTUPosition(state_pub, client,clientStatus); service_running=false; } std_msgs::Int16 msg_state; msg_state.data=controller_state; state_pub.publish(msg_state); ros::spinOnce(); loop_rate.sleep(); } } //------------------------------------------------------- // Parameter retrieval //------------------------------------------------------- void retrieveLaunchParameters(ros::NodeHandle n){ char param_name[100]; std::string param_string; double param_double; int param_int; bool param_bool; // AZIF: Set a parameter to enable/disable the environment scan /enable_environment_scan //---- Enable/disable Environment Scan ----// sprintf(param_name,"%s/enable_environment_scan",DEVICE_NAME); if(n.getParam(param_name,param_bool)) { enable_environment_scan=param_double; } else { enable_environment_scan=DEFAULT_ENABLE_ENV_SCAN; } //---- min tilt scan ----// sprintf(param_name,"%s/min_tilt_scan",DEVICE_NAME); if(n.getParam(param_name,param_double)) { scan_min_tilt_deg=param_double; } else { scan_min_tilt_deg=DEFAULT_SCAN_MIN_TILT_DEG; } //---- max tilt scan ----// sprintf(param_name,"%s/max_tilt_scan",DEVICE_NAME); if(n.getParam(param_name,param_double)) { scan_max_tilt_deg=param_double; } else { scan_max_tilt_deg=DEFAULT_SCAN_MAX_TILT_DEG; } //---- min pan scan ----// sprintf(param_name,"%s/min_pan_scan",DEVICE_NAME); if(n.getParam(param_name,param_double)) { scan_min_pan_deg=param_double; } else { scan_min_pan_deg=DEFAULT_SCAN_MIN_PAN_DEG; } //---- max pan scan ----// sprintf(param_name,"%s/max_pan_scan",DEVICE_NAME); if(n.getParam(param_name,param_double)) { scan_max_pan_deg=param_double; } else { scan_max_pan_deg=DEFAULT_SCAN_MAX_PAN_DEG; } //---- scan button ----// sprintf(param_name,"%s/scan_button",DEVICE_NAME); if(n.getParam(param_name,param_int)) { scan_button=param_int; } else { scan_button=DEFAULT_SCAN_BUTTON; } //---- reset button ----// sprintf(param_name,"%s/reset_button",DEVICE_NAME); if(n.getParam(param_name,param_int)) { reset_button=param_int; } else { reset_button=DEFAULT_RESET_BUTTON; } //---- gas scan button ----// sprintf(param_name,"%s/gas_button",DEVICE_NAME); if(n.getParam(param_name,param_int)) { gas_scan_button=param_int; } else { gas_scan_button=DEFAULT_GAS_SCAN_BUTTON; } //---- lock button ----// sprintf(param_name,"%s/lock_button",DEVICE_NAME); if(n.getParam(param_name,param_int)) { lock_button=param_int; } else { lock_button=DEFAULT_LOCK_BUTTON; } //---- lock trigger ----// sprintf(param_name,"%s/lock_trigger",DEVICE_NAME); if(n.getParam(param_name,param_bool)) { lock_trigger=param_bool; } else { lock_trigger=DEFAULT_LOCK_TRIGGER; } //---- joystick topic ----// sprintf(param_name,"%s/joystick_topic",DEVICE_NAME); if(n.getParam(param_name,param_string)) { joystick_topic=param_string; } else { joystick_topic=DEFAULT_JOYSTICK_TOPIC; } //---- Joystick enabled ----// sprintf(param_name,"%s/joystick_control",DEVICE_NAME); if(n.getParam(param_name,param_bool)) { joystick_control_enabled=param_bool; } else { joystick_control_enabled=DEFAULT_JOYSTICK_ENABLED; } //---- pan points ----// sprintf(param_name,"%s/n_pan_points",DEVICE_NAME); if(n.getParam(param_name,param_int)) { n_pan_joy=param_int; } else { n_pan_joy=DEFAULT_N_PAN; } //---- tilt points ----// sprintf(param_name,"%s/n_tilt_points",DEVICE_NAME); if(n.getParam(param_name,param_int)) { n_tilt_joy=param_int; } else { n_tilt_joy=DEFAULT_N_TILT; } //---- sample delay ----// sprintf(param_name,"%s/samp_delay",DEVICE_NAME); if(n.getParam(param_name,param_double)) { samp_delay_joy=param_double; } else { samp_delay_joy=GAS_SWEEP_DELAY; } } //------------------------------------------------------- // Scene Scan //------------------------------------------------------- void performSceneScan(ros::Publisher state_pub,double min_tilt_deg, double max_tilt_deg, ros::ServiceClient client,ros::ServiceClient clientStatus) { amtec::SetPosition srv; amtec::GetStatus srvState; ROS_INFO("Scan sweep requested"); int tilt_i=0; int retry_count=0; bool pos_reached=false; //Just for the demo ocasion min_tilt_deg=-5; max_tilt_deg=10; /////////////////////////// int increments_tilt=20; double delta_tilt_deg=(max_tilt_deg-min_tilt_deg+10)/increments_tilt; //ROS_INFO("%f,%f",max_tilt_deg,min_tilt_deg); srv.request.position_pan=0; srv.request.position_tilt=deg2rad(max_tilt_deg+5); client.call(srv); do{ sleep(0.5); if(clientStatus.call(srvState)) { retry_count++; ROS_INFO("Moving"); if(fabs(rad2deg(srvState.response.position_tilt)-max_tilt_deg) <= 0.8 && fabs(rad2deg(srvState.response.position_pan)) <= 0.8) { pos_reached=true; } else if (retry_count>20) { ROS_INFO("Warning: PTU not responding. Retrying"); srv.request.position_pan=0; srv.request.position_tilt=deg2rad(max_tilt_deg); client.call(srv); sleep(1); retry_count=0; } } else { ROS_INFO("Warning: PTU not responding. Retrying"); srv.request.position_pan=0; srv.request.position_tilt=deg2rad(max_tilt_deg); client.call(srv); sleep(1); } }while(!pos_reached); double target_tilt_deg=0;//max_tilt_deg; do{ target_tilt_deg=target_tilt_deg-delta_tilt_deg; srv.request.position_pan=0; srv.request.position_tilt=deg2rad(target_tilt_deg); client.call(srv); tilt_i=tilt_i+1; std_msgs::Int16 msg_state; msg_state.data=SCANNING_MODEL; state_pub.publish(msg_state); //ROS_INFO("Requested tilt %f",target_tilt_deg); sleep(0.1); }while (tilt_i<=increments_tilt); do{ clientStatus.call(srvState); sleep(0.5); }while(fabs(srvState.response.velocity_tilt) > 0.01); std_msgs::Int16 msg_state; msg_state.data=IDLE; state_pub.publish(msg_state); } //------------------------------------------------------- // Gas Scan //------------------------------------------------------- void performGasScan(ros::Publisher state_pub, double min_tilt_deg, double max_tilt_deg, double min_pan_deg, double max_pan_deg, int n_pan, int n_tilt, double samp_delay,ros::ServiceClient client,ros::ServiceClient clientStatus) { bool pos_reached=false; int retry_count=0; amtec::SetPosition srv; amtec::GetStatus srvState; srv.request.position_pan=deg2rad(min_pan_deg); srv.request.position_tilt=deg2rad(min_tilt_deg); client.call(srv); do{ sleep(0.5); if(clientStatus.call(srvState)) { retry_count++; //ROS_INFO("Moving"); if(fabs(rad2deg(srvState.response.position_tilt)-min_tilt_deg) <= 0.8 && fabs(rad2deg(srvState.response.position_pan)-min_pan_deg) <= 0.8) { pos_reached=true; } else if (retry_count>20) { ROS_INFO("Warning: PTU not responding 1st. Retrying"); srv.request.position_pan=deg2rad(min_pan_deg); srv.request.position_tilt=deg2rad(min_tilt_deg); client.call(srv); sleep(1); retry_count=0; } } else { ROS_INFO("Warning: PTU not responding 2nd. Retrying"); srv.request.position_pan=deg2rad(min_pan_deg); srv.request.position_tilt=deg2rad(min_tilt_deg); client.call(srv); sleep(1); } }while(!pos_reached); int tilt_i=0; int pan_i=0; int current_movement=TO_RIGHT; double requested_pan_deg; double requested_tilt_deg; requested_pan_deg=min_pan_deg; requested_tilt_deg=min_tilt_deg; float delta_pan_deg=fabs(max_pan_deg-min_pan_deg)/n_pan; float delta_tilt_deg=fabs(max_tilt_deg-min_tilt_deg)/n_tilt; //AZIF: Changes might go here if(n_tilt=1 && n_pan==1) do{ if(current_movement==TO_RIGHT){ srv.request.position_pan=deg2rad(requested_pan_deg); srv.request.position_tilt=deg2rad(requested_tilt_deg); client.call(srv); do{ clientStatus.call(srvState); sleep(0.1); }while(fabs(srvState.response.velocity_tilt) > 0.0 || fabs(srvState.response.velocity_pan) > 0.0); //ROS_INFO("Scanning at %f,%f",requested_pan_deg,requested_tilt_deg); requested_pan_deg=requested_pan_deg+delta_pan_deg; pan_i=pan_i+1; if (pan_i > n_pan) { current_movement=TO_LEFT; requested_pan_deg=requested_pan_deg-delta_pan_deg; requested_tilt_deg=requested_tilt_deg+delta_tilt_deg; tilt_i=tilt_i+1; } std_msgs::Int16 msg_state; msg_state.data=SCANNING_GAS; state_pub.publish(msg_state); sleep(samp_delay); } else{ srv.request.position_pan=deg2rad(requested_pan_deg); srv.request.position_tilt=deg2rad(requested_tilt_deg); client.call(srv); do{ clientStatus.call(srvState); sleep(0.1); }while(fabs(srvState.response.velocity_tilt) > 0.0 || fabs(srvState.response.velocity_pan) > 0.0); //ROS_INFO("Scanning at %f,%f",requested_pan_deg,requested_tilt_deg); requested_pan_deg=requested_pan_deg-delta_pan_deg; pan_i=pan_i-1; if (pan_i <= 0) { current_movement=TO_RIGHT; requested_pan_deg=requested_pan_deg+delta_pan_deg; requested_tilt_deg=requested_tilt_deg+delta_tilt_deg; tilt_i=tilt_i+1; } std_msgs::Int16 msg_state; msg_state.data=SCANNING_GAS; state_pub.publish(msg_state); sleep(samp_delay); } }while (tilt_i<=n_tilt); do{ clientStatus.call(srvState); sleep(0.5); }while(fabs(srvState.response.velocity_tilt) > 0.01); std_msgs::Int16 msg_state; msg_state.data=SCANNING_GAS; state_pub.publish(msg_state); } //------------------------------------------------------- // PTU reset position //------------------------------------------------------- void resetPTUPosition(ros::Publisher state_pub, ros::ServiceClient client,ros::ServiceClient clientStatus) { amtec::SetPosition srv; amtec::GetStatus srvState; srv.request.position_pan=0; srv.request.position_tilt=0; client.call(srv); int retry_count=0; bool pos_reached=false; do{ sleep(0.5); if (clientStatus.call(srvState)){ //ROS_INFO("Gotcha %f,%f",rad2deg(srvState.response.position_tilt),rad2deg(srvState.response.position_pan)); retry_count++; if(fabs(rad2deg(srvState.response.position_tilt)) <= 0.8 && fabs(rad2deg(srvState.response.position_pan)) <= 0.8){ pos_reached=true; } else if (retry_count>20) { ROS_INFO("Warning: PTU not responding Marco thinks we are here. Retrying"); srv.request.position_pan=0; srv.request.position_tilt=0; client.call(srv); sleep(1); retry_count=0; } } else{ ROS_INFO("Warning: PTU not responding Ricarrdo thinks we are here. Retrying"); srv.request.position_pan=0; srv.request.position_tilt=0; client.call(srv); sleep(1); } std_msgs::Int16 msg_state; msg_state.data=RESET; state_pub.publish(msg_state); ROS_INFO("To reset position"); } while(!pos_reached); } /**************************************************** * Interpolation function ****************************************************/ double interp( lookup_table* c, double x, int n ) { int i; for( i = 0; i < n-1; i++ ) { if ( c[i].x <= x && c[i+1].x >= x ) { double diffx = x - c[i].x; double diffn = c[i+1].x - c[i].x; return c[i].y + ( c[i+1].y - c[i].y ) * diffx / diffn; } } return 0; // Not in Range }
[ "asif.arain@oru.se" ]
asif.arain@oru.se
a06765545826fc0499576c0069ce91f54a36790c
4ceb431679147aedd57c04308f769a2521b1a9e4
/Problems and Solutions/10812 - Beat the Spread!.cpp
636c1b5b747f9bdef146229df738bc4294d1753b
[]
no_license
tushar20008/Competitive-Coding
188797383cfa4f3b722543f5a999847c0756388b
9ec0891d6023029590cb096417b6477a011f3d61
refs/heads/master
2021-01-18T18:51:57.586151
2018-05-01T10:59:30
2018-05-01T10:59:30
86,875,720
3
1
null
null
null
null
UTF-8
C++
false
false
259
cpp
#include <iostream> using namespace std; int main() { int T; cin>>T; while(T--) { long s,d; cin>>s>>d; long a = (s+d)/2; long b = s-a; if(b<0 || a+b != s || a-b != d) cout<<"impossible"<<endl; else cout<<a<<" "<<b<<endl; } return 0; }
[ "tusharanand20008@gmail.com" ]
tusharanand20008@gmail.com
f991129b23eca7d31f3244b1cf151accf89e5f48
c74e5e9b6cddbe7abbf92b69a813aff38e580b79
/src/casecostview.cpp
b6554ac970facba8d1564a070df77a9e107df3dd
[]
no_license
damaro05/LawFirmPlatform
19981236300cbd2adc154e63e0c3f7298aed7ad4
f28dbb8a46b3d80314803ff264cd9b65dca06671
refs/heads/master
2021-03-24T13:57:03.049933
2017-05-25T11:42:10
2017-05-25T11:42:10
80,528,474
0
0
null
null
null
null
UTF-8
C++
false
false
2,993
cpp
#include "casecostview.h" #include "ui_tableviewtemplate.h" #include "models/cmodeltableview.h" #include "models/cases.h" #include "models/qjsontablemodel.h" #include "globals.h" CaseCostView::CaseCostView() { std::cout << "Constractor " << typeid(this).name() << std::endl; model = new CModelTableView(this); initializeModel( model, "CostTest" ); setupView(); } CaseCostView::~CaseCostView() { std::cout << "Destructor " << typeid(this).name() << std::endl; delete model; } void CaseCostView::setupView() { //Define title and column to be calculated ui->labelTitle->setText( "Listado de costes" ); sumColumn = 2; sumColumnType = QString(" โ‚ฌ"); ui->tableView->setMinimumWidth( 800 ); ui->tableView->setModel( model ); ui->tableView->resizeColumnsToContents(); ui->tableView->setColumnWidth( 0, (ui->tableView->width()/10) * 2.5 ); ui->tableView->setColumnWidth( 1, (ui->tableView->width()/10) * 5.3 ); ui->tableView->setColumnWidth( 2, (ui->tableView->width()/10) * 1 ); ui->tableView->setColumnWidth( 3, (ui->tableView->width()/10) * 0.5 ); ui->tableView->setColumnWidth( 4, (ui->tableView->width()/10) * 0.5 ); ui->tableView->horizontalHeader()->setStretchLastSection( true ); ui->pushBtnRevert->hide(); ui->pushBtnSubmit->hide(); updateTotalLabel(); } void CaseCostView::setupData( const Cases& currentCase ) { RestClient* rc = RestClient::getInstance(); QString url = "cases/" + QString::number( currentCase.idcase() ) + "/cost"; rc->getRequest( url ); QJsonTableModel::Header header; header.push_back( QJsonTableModel::Heading( {{"title", "Fecha de creaciรณn"},{"index","entrydate"}} ) ); header.push_back( QJsonTableModel::Heading( {{"title", "Concepto"},{"index","concept"}} ) ); header.push_back( QJsonTableModel::Heading( {{"title", "Importe"},{"index","amount"}} ) ); header.push_back( QJsonTableModel::Heading( {{"title", "Doc"},{"index","doc"}} ) ); header.push_back( QJsonTableModel::Heading( {{"title", "Estado"},{"index","state"}} ) ); QJsonTableModel* hoursModel = new QJsonTableModel( header, this ); ui->tableView->setModel( hoursModel ); bool hourscases = false; if( rc->isFinished ) if( rc->isCorrect ) hourscases = true; if( hourscases ){ QJsonDocument jsonDResponse = QJsonDocument::fromJson( rc->response ); hoursModel->setJson( jsonDResponse ); } } void CaseCostView::initializeModel( QSqlTableModel *model, const QString &tablename ) { model->setTable( tablename ); model->setEditStrategy( QSqlTableModel::OnManualSubmit ); model->select(); model->setHeaderData( 0, Qt::Horizontal, "Fecha" ); model->setHeaderData( 1, Qt::Horizontal, "Concepto" ); model->setHeaderData( 2, Qt::Horizontal, "Importe" ); model->setHeaderData( 3, Qt::Horizontal, "Doc" ); model->setHeaderData( 4, Qt::Horizontal, "Estado" ); newDefaultRow( 0, 1 ); }
[ "scmh05@gmail.com" ]
scmh05@gmail.com
af24f473cf2766bb59d207fa4296a652398f5e2b
1a562c8e43247097582e0089d386eed5b450ed49
/Interpreter/DataTypes.h
c5b4b66eb5452cf12cb8e09ebca51b0d2d1c6604
[]
no_license
baniuk/RadiographySoftware
89c202496f4f318005e0459575f29d8928053d99
c0efc3b842d56dc19975c213f654299829931e5e
refs/heads/master
2020-04-29T04:27:32.174950
2019-03-15T15:43:17
2019-03-15T15:43:17
175,847,643
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
829
h
#pragma once #define IMAGE 0x00000010 #define STRING 0x00000100 #define MATRIX 0x00001000 #define NUMBER MATRIX #define DT UINT #define maxline 256 // maksymalna ilosc znakow w linii #define CHARNOEXIST 32000 #define maxnameofleftparametr 256 #define maxwindows 256; #define maxbuffor 50 // ilosc komend #define maxvar 1024 // ilosc zmiennych w programie (te parmaetry okreล›lane w fazie init bฤ™dฤ…) #define maxlines 512 // maksymlana iloล›ฤ‡ linii #define maxerror 512 #define MAXSIZE 25 // maks nazwa funkcji #define MAX_GLOBALS 25 // max ilosc zmiennych globalnych #define maxthreads 8 // maxymalna ilosc watkow /* class C_MATRIX { public: C_MATRIX(int rows, int cols); void SetValue(int row, int col,int value); int GetValue(int row, int col); unsigned int rows, cols; int* data; public: ~C_MATRIX(void); }; */
[ "P.Baniukiewicz@warwick.ac.uk" ]
P.Baniukiewicz@warwick.ac.uk
0ac00b6f5b2fae467c144232dd57a365ad29c740
f0983a84dd46f5ea7dd43a08fb11fc7d15912988
/Classes/QuadTree.cpp
a0431129757b90ea98005fa1286177443ad07384
[]
no_license
acmersch/Fighter
bff6241a767cd1582e73c35a4a20dd69ae3f7566
b2ed033d077ebe9f55bf1f206266ed503fe52560
refs/heads/master
2020-04-29T14:51:42.753321
2014-04-15T15:35:15
2014-04-15T15:35:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,826
cpp
// // QuadTree.cpp // Card // // Created by Roton_Lin on 14-3-20. // // #include "QuadTree.h" #include "lifeObj.h" //build the tree QuadTree::QuadTree(int deep, Rect rect) { mRect = rect; mObjArray = CCArray::create(); mObjArray->retain(); initChild(deep, rect); } QuadTree::~QuadTree() { mObjArray->removeAllObjects(); mObjArray->release(); deleteTree(); } void QuadTree::deleteTree() { for (int i = 0; i < BRANCH; i++) { if (mChild[i] != NULL) { delete mChild[i]; } } } void QuadTree::initChild(int deep, Rect rect) { for (int i = 0; i < BRANCH; i ++) { mChild[i] = NULL; } if (deep == 1) { return; } float width = rect.size.width / 2; float height = rect.size.height / 2; int curdeep = deep - 1; mChild[0] = new QuadTree(curdeep, Rect(rect.origin.x, rect.origin.y, width, height)); mChild[1] = new QuadTree(curdeep, Rect(rect.origin.x + width, rect.origin.y, width, height)); mChild[2] = new QuadTree(curdeep, Rect(rect.origin.x, rect.origin.y + height, width, height)); mChild[3] = new QuadTree(curdeep, Rect(rect.origin.x + width, rect.origin.y + height, width, height)); } void QuadTree::clear() { clearTree(this); } void QuadTree::clearTree(QuadTree *tree) { for (int i = 0; i < BRANCH; i ++) { if (tree->mChild[i] != NULL) { clearTree(tree->mChild[i]); } } (tree->mObjArray)->removeAllObjects(); } bool QuadTree::addObject(Node* node) { lifeObj* obj = (lifeObj*)node; Rect rec = obj->getShadowRect(); bool isInsert = false; if (isRecAContainsRecB(mRect, rec)) { for (int i = 0 ; i < BRANCH; i++) { if (mChild[i] == NULL) { break; } isInsert |= (mChild[i]->addObject(node)); } if (!isInsert) { mObjArray->addObject(node); isInsert = true; } } return isInsert; } bool QuadTree::isRecAContainsRecB(Rect recA, Rect recB) { bool withFit = recB.origin.x + recB.size.width <= recA.origin.x + recA.size.width; bool heightFit = recB.origin.y + recB.size.height <= recA.origin.y + recA.size.height; if (withFit && heightFit && recA.origin.x <= recB.origin.x && recB.origin.y >= recA.origin.y) { return true; } return false; } void QuadTree::getCollisionObjects(Node *node, __Array *result) { lifeObj* obj = (lifeObj*)node; Rect rec = obj->getShadowRect(); //CCRect rec = node->boundingBox(); if (isRecAContainsRecB(mRect, rec)) { result->addObjectsFromArray(mObjArray); for (int i = 0; i < BRANCH; i++) { if (mChild[i] == NULL) { break; } mChild[i]->getCollisionObjects(node, result); } } }
[ "acmercyj@gmail.com" ]
acmercyj@gmail.com
13ae85161fadd329013a6759366be23458b9d8d9
6058aac649d539ffc4102d64fecc0b397cf014bc
/include/Menu.hpp
269b3baec6f9d49397eb97bfce2f1652ed9e3b19
[ "MIT" ]
permissive
Kirthos/Aerria
bb00b1a9fbb32891837d7b9adcb80a53e20539aa
ec9eb6c78690838ba5a3509369e2c4d8428b4dc2
refs/heads/master
2020-04-02T06:33:52.656726
2018-10-22T14:37:08
2018-10-22T14:37:08
154,156,565
0
0
null
null
null
null
UTF-8
C++
false
false
1,272
hpp
#ifndef MENU_HPP_INCLUDED #define MENU_HPP_INCLUDED #include <SFML/Graphics.hpp> #include <SFML/Audio.hpp> #include "Game.hpp" #include "SingletonWindow.h" #include <iostream> using namespace std; class Menu { public: Menu(); void run(); protected: void update(); const void render(); int checkBox(float x, float y); void updateCloud(); void updateSM(); bool cacheActivated; sf::RectangleShape cache; //son sf::Music fond; //textures sf::Texture cursorT; sf::Texture backPlanT; sf::Sprite backPlan; sf::Texture bouton1T; //comande normal sf::Texture bouton2T; //option sf::Texture bouton3T; //quit sf::Texture boutonMultiT; sf::Sprite cursor; sf::Sprite bouton1; sf::Sprite bouton3; sf::Sprite bouton2; sf::Sprite boutonMulti; //cloud sf::Texture cloudT; sf::Sprite cloud; sf::Vector2f cloudPos; sf::Sprite cloud2; sf::Vector2f cloud2Pos; //moon / sun sf::Vector2f sunPos; sf::Vector2f moonPos; sf::Texture sunT; sf::Texture moonT; sf::Sprite sun; sf::Sprite moon; // sf::Mouse mouse; sf::Vector2i MousePos; sf::Vector2f MousePosCoo; sf::View mainView; //temp int tempCache; }; #endif // MENU_HPP_INCLUDED
[ "gm.kirthos@gmail.com" ]
gm.kirthos@gmail.com
dc6fc7d52e1327e08dc3d486c97b81134e83df99
23e393f8c385a4e0f8f3d4b9e2d80f98657f4e1f
/ไปŽ็ฎ—ๆณ•ๅˆฐ็จ‹ๅบ(็ฌฌ2็‰ˆ)/Chapter11/hdu1521.cpp
9e77f4ea6add52f8b41c10a993a633d50da3d006
[]
no_license
IgorYunusov/Mega-collection-cpp-1
c7c09e3c76395bcbf95a304db6462a315db921ba
42d07f16a379a8093b6ddc15675bf777eb10d480
refs/heads/master
2020-03-24T10:20:15.783034
2018-06-12T13:19:05
2018-06-12T13:19:05
142,653,486
3
1
null
2018-07-28T06:36:35
2018-07-28T06:36:35
null
UTF-8
C++
false
false
877
cpp
#include<stdio.h> #include<string.h> int main() { int i; double a[15]; a[0] = a[1] = 1; for (i = 2; i <= 10; i++) a[i] = i * a[i - 1]; int n, m; while (scanf("%d%d", &n, &m) != EOF) { int num[15]; double c1[15], c2[15]; for (i = 1; i <= n; i++) scanf("%d", &num[i]); memset(c1, 0, sizeof(c1)); memset(c2, 0, sizeof(c2)); for (i = 0; i <= num[1]; i++) c1[i] = 1.0 / a[i]; int j, k; for (i = 2; i <= n; i++) { for (j = 0; j <= m; j++) for (k = 0; k <= num[i] && j + k <= m; k++) c2[j + k] += c1[j] / a[k]; memcpy(c1, c2, sizeof(c2)); memset(c2, 0, sizeof(c2)); } printf("%.0lf\n", c1[m]*a[m]); } return 0; }
[ "wyrover@gmail.com" ]
wyrover@gmail.com
1fe170cef447c0f76fba91fe15ec4b6177b34114
46e2c94c7b5691432716d618beda6f5075b76754
/sln/019RemoveNthNodeFromEndofList_v3.cpp
b8bea9d8ce68c0900b7600d3fbfc38f6c7138a4a
[]
no_license
Starxyz/leetCodeRecord
6fc52205130e94b21739c60e068eba7b0067badb
ed41d3db46bb1ef8082867483a85bb73f35ae07d
refs/heads/master
2021-06-29T00:59:46.018955
2020-10-04T10:15:06
2020-10-04T10:15:06
151,848,728
1
0
null
null
null
null
UTF-8
C++
false
false
1,285
cpp
/* Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. Note: Given n will always be valid. Follow up: Could you do this in one pass? */ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode* dummyHead = new ListNode(0); dummyHead->next = head; ListNode* p = dummyHead; ListNode* q = dummyHead; for (int i=0; i<n+1; i++) { p = p->next; } while (p != NULL) { q = q->next; p = p->next; } // delete node ListNode* delNode = q->next; q->next = delNode->next; ListNode* relNode = dummyHead->next; delete dummyHead; return relNode; } };
[ "a136009394@163.com" ]
a136009394@163.com
ced72451d22b4a11f97a3d80f55f95207d5a2bb9
c4cfc213646bd5d5dcc637b37e80e35318eb3a40
/KOCOM/src/context_elevator.cpp
1b7b095a2ca9c7c2335f60675ddacbf44e8fafb2
[]
no_license
gandy555/MTM_V3
ff90e70b525bd88c6d25756f4de7b21b2b5d0d61
abc012b1663b412cca26c5ffb3073bbfd57550c2
refs/heads/master
2021-01-20T06:59:40.596104
2015-10-14T14:30:31
2015-10-14T14:30:31
42,117,534
0
0
null
null
null
null
UHC
C++
false
false
12,890
cpp
/* */ #include "common.h" #include "context_elevator.h" #include "main.h" #define ELEVATOR_STAT_REQ (1<<0) #define ELEVATOR_STAT_RES_WAIT (1<<1) #define ELEVATOR_STAT_RES_TIMEOUT (1<<2) #define ELEVATOR_CALL_REQ (1<<3) #define ELEVATOR_CALL_RES_WAIT (1<<4) #define ELEVATOR_CALL_RES_TIMEOUT (1<<5) UCHAR g_ElevatorTimerParam = 0; UCHAR g_ElevatorStatResTimeout = 0; UCHAR g_ElevatorCallResTimeout = 0; #if 0 //์—˜๋ฆฌ๋ฒ ์ดํ„ฐ ํƒ€์ด๋จธ ํ•ธ๋“ค๋Ÿฌ : 1์ดˆ void elevator_timer_handler(void *pParam) { UCHAR* pucParam = (UCHAR *)pParam; if(g_state.GetState() != STATE_ELEVATOR) { g_timer.KillTimer(ELEVATOR_TIMER); return; } if(*pucParam & ELEVATOR_STAT_REQ) { if(*pucParam & ELEVATOR_STAT_RES_WAIT) { *pucParam |= ELEVATOR_STAT_RES_TIMEOUT; g_ElevatorStatResTimeout += ELEVATOR_REQ_TIME; if(g_ElevatorStatResTimeout >= ELEVATOR_RES_TIMEOUT) { printf("Elevator Stat Response Timeout!\r\n"); g_timer.KillTimer(ELEVATOR_TIMER); } } else { *pucParam |= ELEVATOR_STAT_RES_WAIT; g_ElevatorStatResTimeout = 0; // g_wallpad_sns.RequestReserve(SNS_CMD_ELEVATOR_STAT_REQ); if(g_pWallPad) { g_pWallPad->RequestElevatorStatus(); } } } if(*pucParam & ELEVATOR_CALL_RES_WAIT) { *pucParam |= ELEVATOR_CALL_RES_TIMEOUT; } // g_wallpad_sns.RequestReserve(SNS_CMD_ELEVATOR_STAT_REQ); if(g_pWallPad) { g_pWallPad->RequestElevatorStatus(); } } #endif // // Construction/Destruction // CContextElevator::CContextElevator(GR_WINDOW_ID wid, GR_GC_ID gc) : CContext(wid, gc) { m_isElevatorStatusSuccess = FALSE; m_isElevatorCalled = FALSE; m_isElevatorCallSuccess = FALSE; m_isElevatorArrive = FALSE; m_nElevatorDir = 0; m_nElevatorFloor = 0; m_pObjectIcon = NULL; } CContextElevator::~CContextElevator() { } // // Member Function // void CContextElevator::Init() { CObject* pObject; CObjectIcon* pObjectIcon; UINT id; CContext::Init(); // Blank ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ pObject = new CObjectImage(m_wid_parent, m_gc, 0, 0, g_scr_info.cols, g_scr_info.rows); if(pObject) { pObject->LoadImage(IMG_BACKGROUND, "/app/img/blank_bg.png"); id = m_ObjectList.AddObject(pObject); } // ์•„์ด์ฝ˜ ์ด๋ฏธ์ง€ pObject = new CObjectImage(m_wid_parent, m_gc, 58, 50, 158, 158); if(pObject) { pObject->LoadImage(IMG_BACKGROUND, "/app/img/icon_elevator.png"); id = m_ObjectList.AddObject(pObject); } // ์—˜๋ ˆ๋ฒ ์ดํ„ฐ ์ด๋ฏธ์ง€ pObject = new CObjectImage(m_wid_parent, m_gc, 510, 175, 207, 258); if(pObject) { pObject->LoadImage(IMG_BACKGROUND, "/app/img/elevator_image.png"); id = m_ObjectList.AddObject(pObject); } // ์—˜๋ ˆ๋ฒ ์ดํ„ฐ ์ธตํ‘œ์‹œ ๋ฐ•์Šค ์ด๋ฏธ์ง€ pObject = new CObjectImage(m_wid_parent, m_gc, 339, 240, 143, 127); if(pObject) { pObject->LoadImage(IMG_BACKGROUND, "/app/img/elevator_display.png"); id = m_ObjectList.AddObject(pObject); } // ์—˜๋ ˆ๋ฒ ์ดํ„ฐ ํ™”์‚ดํ‘œ // pObject = new CObjectIcon(m_wid_parent, m_gc, 336, 245, 137, 137); pObject = new CObjectIcon(m_wid_parent, m_gc, 232, 210, 86, 190); if(pObject) { pObjectIcon = (CObjectIcon*)pObject; pObjectIcon->AllocImageCount(IMG_ENUM_ARROW_COUNT); pObject->LoadImage(IMG_ENUM_ARROW_BLANK, "/app/img/el_png/arrow_back.png"); pObject->LoadImage(IMG_ENUM_ARROW_UP_1, "/app/img/el_png/arrow_up_1.png"); pObject->LoadImage(IMG_ENUM_ARROW_UP_2, "/app/img/el_png/arrow_up_2.png"); pObject->LoadImage(IMG_ENUM_ARROW_UP_3, "/app/img/el_png/arrow_up_3.png"); pObject->LoadImage(IMG_ENUM_ARROW_DOWN_1, "/app/img/el_png/arrow_down_1.png"); pObject->LoadImage(IMG_ENUM_ARROW_DOWN_2, "/app/img/el_png/arrow_down_2.png"); pObject->LoadImage(IMG_ENUM_ARROW_DOWN_3, "/app/img/el_png/arrow_down_3.png"); id = m_ObjectList.AddObject(pObject); } } void CContextElevator::DeInit() { CContext::DeInit(); m_ObjectList.RemoveAll(); } void CContextElevator::Draw(UINT nContextNum) { CObjectIcon* pObjectIcon = NULL; if(m_gc==0) return; DBGMSGC(DBG_ELEVATOR, "++ [%d]\r\n", nContextNum); //๋ฐฐ๊ฒฝ m_ObjectList.Draw(ELEVATOR_OBJ_BG); //์•„์ด์ฝ˜ m_ObjectList.Draw(ELEVATOR_OBJ_ICON); //ํ…์ŠคํŠธ // DrawText("์—˜๋ ˆ๋ฒ ์ดํ„ฐ๋ฅผ ํ˜ธ์ถœํ•˜์˜€์Šต๋‹ˆ๋‹ค", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); //์—˜๋ ˆ๋ฒ ์ดํ„ฐ ์ด๋ฏธ์ง€ m_ObjectList.Draw(ELEVATOR_OBJ_IMAGE); //์—˜๋ ˆ๋ฒ ์ดํ„ฐ ์ธตํ‘œ์‹œ ๋ฐ•์Šค m_ObjectList.Draw(ELEVATOR_OBJ_DISPLAY); switch(nContextNum) { case 0: if(g_setup_data.m_SetupData.wallpad_type == WALLPAD_TYPE_SHN) { DrawText("์—˜๋ ˆ๋ฒ ์ดํ„ฐ ์ƒํƒœ ํ™•์ธ์ค‘ ์ž…๋‹ˆ๋‹ค", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); } else { DrawText("์—˜๋ ˆ๋ฒ ์ดํ„ฐ๋ฅผ ํ˜ธ์ถœํ•˜์˜€์Šต๋‹ˆ๋‹ค", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); } break; case 1: if(g_setup_data.m_SetupData.wallpad_type == WALLPAD_TYPE_KCM) { DrawText("์—˜๋ ˆ๋ฒ ์ดํ„ฐ ์‘๋‹ต์ด ์—†์Šต๋‹ˆ๋‹ค", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); } break; case 2: if(g_setup_data.m_SetupData.wallpad_type == WALLPAD_TYPE_KCM) { switch(m_nElevatorDir) { case MTM_DATA_EV_STATUS_STOP: DrawText("์—˜๋ ˆ๋ฒ ์ดํ„ฐ๊ฐ€ ์ •์ง€ํ•ด ์žˆ์Šต๋‹ˆ๋‹ค", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); break; case MTM_DATA_EV_STATUS_UP: case MTM_DATA_EV_STATUS_DOWN: DrawText("์—˜๋ ˆ๋ฒ ์ดํ„ฐ๊ฐ€ ์ด๋™์ค‘ ์ž…๋‹ˆ๋‹ค", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); break; case MTM_DATA_EV_STATUS_ARRIVE: DrawText("์—˜๋ ˆ๋ฒ ์ดํ„ฐ๊ฐ€ ๋„์ฐฉ ํ•˜์˜€์Šต๋‹ˆ๋‹ค", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); break; } } break; } DBGMSGC(DBG_ELEVATOR, "--\r\n"); } void CContextElevator::Proc(UINT nContextNum) { DBGMSGC(DBG_ELEVATOR, "++ [%d]\r\n", nContextNum); switch(nContextNum) { case 0: m_nElevatorDir = 0; m_nElevatorFloor = 0; m_pObjectIcon = (CObjectIcon*)m_ObjectList.FindObjectByID(ELEVATOR_OBJ_ARROW); m_nThreadStep = 0; if (g_pWallPad) { g_pWallPad->RequestElevatorCall(); PlayWavFile("/app/sound/elevator.wav\0"); // g_timer.KillTimer(BACK_LIGHT_TIMER); // ๋ฐฑ๋ผ์ดํŠธ ํƒ€์ด๋จธ : 5๋ถ„ g_timer.SetTimer(BACK_LIGHT_TIMER, ELEVATOR_CALL_WAIT_TIME, NULL, "LCD BackLight Timer"); } break; case 1: // PlayWavFile("/app/sound/elevator.wav\0"); break; } DBGMSGC(DBG_ELEVATOR, "--\r\n"); } void CContextElevator::TimerProc(UINT idTimer) { switch(idTimer) { case RESPONSE_TIMER: if(g_pWallPad) g_pWallPad->RequestElevatorCall(); break; case RETRY_TIMEOUT: ChangeContext(1); break; } } void CContextElevator::RecvProc(UCHAR *pPacket) { PMTM_HEADER pHdr = (PMTM_HEADER)pPacket; PMTM_DATA_ELEVATOR pElevatorInfo; if(pPacket == NULL) return; DBGMSGC(DBG_WEATHER, "++\r\n"); switch(pHdr->type) { case MTM_DATA_TYPE_WEATHER: break; case MTM_DATA_TYPE_PARKING: break; case MTM_DATA_TYPE_ELEVATOR: if(g_isBackLightOn) { pElevatorInfo = (PMTM_DATA_ELEVATOR)&pPacket[sizeof(MTM_HEADER)]; switch(pElevatorInfo->status) { case MTM_DATA_EV_STATUS_STOP: case MTM_DATA_EV_STATUS_UP: case MTM_DATA_EV_STATUS_DOWN: case MTM_DATA_EV_STATUS_ARRIVE: m_isElevatorStatusSuccess = (pElevatorInfo->status != MTM_DATA_EV_STATUS_ERROR) ? TRUE : FALSE; m_nElevatorDir = pElevatorInfo->status; m_nElevatorFloor = pElevatorInfo->floor; m_nContextNum = 2; //ํ™”๋ฉด๊ฐฑ์‹ ์—†์ด ContextNum๋งŒ ๋ฐ”๊ฟˆ. ThreadProc์—์„œ ์ฒ˜๋ฆฌ๋ชฉ์  // ChangeContext(2); break; } //๋„์ฐฉํ•˜๋ฉด ๋ฐฑ๋ผ์ดํŠธ ํƒ€์ด๋ฒ„ ๋ณต๊ท€ : 10์ดˆ if(pElevatorInfo->status == MTM_DATA_EV_STATUS_ARRIVE) { g_timer.SetTimer(BACK_LIGHT_TIMER, BACK_LIGHT_TIME, NULL, "LCD BackLight Timer"); } } break; case MTM_DATA_TYPE_GAS: break; case MTM_DATA_TYPE_LIGHT: break; case MTM_DATA_TYPE_SECURITY: break; } DBGMSGC(DBG_WEATHER, "--\r\n"); } void CContextElevator::ThreadProc() { static int nArrowStep; static ULONG ulTickDraw; char szText[32] = {0,}; //ํ˜ธ์ถœ์ด ์„ฑ๊ณตํ•˜๊ณ  ์—˜๋ฆฌ๋ฒ ์ดํ„ฐ ์ƒํƒœ๋ฅผ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•˜๋Š” ๋™์•ˆ ๋™์ž‘ํ•จ // if(m_nContextNum==0) return; switch(m_nThreadStep) { case 0: nArrowStep = 0; m_nThreadStep++; break; case 1: if( m_pObjectIcon && (m_nContextNum==2)) { RedrawImage(m_wid_parent, m_gc, 245, 89, 500, 32, 245, 89, 500, 32, ELEVATOR_OBJ_BG); switch(m_nElevatorDir) { case MTM_DATA_EV_STATUS_STOP: DrawText("์—˜๋ ˆ๋ฒ ์ดํ„ฐ๊ฐ€ ์ •์ง€ํ•ด ์žˆ์Šต๋‹ˆ๋‹ค", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); break; case MTM_DATA_EV_STATUS_UP: case MTM_DATA_EV_STATUS_DOWN: DrawText("์—˜๋ ˆ๋ฒ ์ดํ„ฐ๊ฐ€ ์ด๋™์ค‘ ์ž…๋‹ˆ๋‹ค", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); break; case MTM_DATA_EV_STATUS_ARRIVE: DrawText("์—˜๋ ˆ๋ฒ ์ดํ„ฐ๊ฐ€ ๋„์ฐฉ ํ•˜์˜€์Šต๋‹ˆ๋‹ค", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); break; } //๋ฐฉํ–ฅํ‘œ์‹œ if( (m_nElevatorDir == MTM_DATA_EV_STATUS_STOP) || (m_nElevatorDir == MTM_DATA_EV_STATUS_ARRIVE) ) { m_pObjectIcon->Draw(IMG_ENUM_ARROW_BLANK); nArrowStep = 0; } else if(m_nElevatorDir == MTM_DATA_EV_STATUS_DOWN) { switch(nArrowStep) { case 0: m_pObjectIcon->Draw(IMG_ENUM_ARROW_DOWN_1); break; case 1: m_pObjectIcon->Draw(IMG_ENUM_ARROW_DOWN_2); break; default: m_pObjectIcon->Draw(IMG_ENUM_ARROW_DOWN_3); break; } nArrowStep++; if(nArrowStep==5) nArrowStep=0; } else if(m_nElevatorDir == MTM_DATA_EV_STATUS_UP) { switch(nArrowStep) { case 0: m_pObjectIcon->Draw(IMG_ENUM_ARROW_UP_1); break; case 1: m_pObjectIcon->Draw(IMG_ENUM_ARROW_UP_2); break; default: m_pObjectIcon->Draw(IMG_ENUM_ARROW_UP_3); break; } nArrowStep++; if(nArrowStep==5) nArrowStep=0; } //์ธตํ‘œ์‹œ if(m_nElevatorFloor > 0) { if(m_nElevatorFloor >= 128) sprintf(szText, "B%2d\0", 256-m_nElevatorFloor); else sprintf(szText, "%3d\0", m_nElevatorFloor); } else if(m_nElevatorFloor < 0) { sprintf(szText, "B%2d\0", m_nElevatorFloor*(-1)); } // else // { // sprintf(szText, "L\0"); // } #if 0 DrawText(szText, m_wid_parent, m_gc, 339+13, 240+13, 143-26, 127-26, g_font, 72, WHITE, TXT_HALIGN_CENTER|TXT_VALIGN_MIDDLE); #else RedrawImage(m_wid_parent, m_gc, 352, 253, 117, 101, 12, 12, 117, 101, ELEVATOR_OBJ_DISPLAY); DrawText(szText, m_wid_parent, m_gc, 352, 253, 117, 101, g_font, 72, WHITE, TXT_HALIGN_CENTER|TXT_VALIGN_MIDDLE); #endif ulTickDraw = GetTickCount(); m_nThreadStep++; } break; case 2: if(GetElapsedTick(ulTickDraw) >= 500) { m_nThreadStep--; } break; } } void CContextElevator::ButtonDown(UINT usGpioFlag, UINT usEventEnum) { DBGMSGC(DBG_ELEVATOR, "++\r\n"); if(usEventEnum == MTM_GPIO_BUTTON_DOWN) { } else if(usEventEnum == MTM_GPIO_BUTTON_LONG) { #if 0 if( CHK_FLAG(usGpioFlag, BIT_FLAG(GPIO_FRONT_RIGHT_TOP)|BIT_FLAG(GPIO_FRONT_RIGHT_BOTTOM)) || CHK_FLAG(usGpioFlag, BIT_FLAG(GPIO_REAR_VOL_UP)|BIT_FLAG(GPIO_REAR_VOL_DOWN)) ) { g_state.ChangeState(STATE_SETUP); } #endif } DBGMSGC(DBG_ELEVATOR, "--\r\n"); } void CContextElevator::ButtonUp(UINT usGpioFlag, UINT usEventEnum) { DBGMSGC(DBG_ELEVATOR, "++\r\n"); if(usEventEnum == MTM_GPIO_BUTTON_UP) { switch(usGpioFlag) { case GPIO_FLAG_FRONT_LEFT_TOP: //Weather g_state.ChangeState(STATE_WEATHER); break; case GPIO_FLAG_FRONT_LEFT_MIDDLE: //Elevator ChangeContext(0); break; case GPIO_FLAG_FRONT_LEFT_BOTTOM: //Parking g_state.ChangeState(STATE_PARKING); break; case GPIO_FLAG_FRONT_RIGHT_TOP: //Gas g_state.ChangeState(STATE_GAS); break; case GPIO_FLAG_FRONT_RIGHT_MIDDLE: //Light g_state.ChangeState(STATE_LIGHT); break; case GPIO_FLAG_FRONT_RIGHT_BOTTOM: //Security g_state.ChangeState(STATE_SECURITY); break; } //๋ฐฑ๋ผ์ดํŠธ ํƒ€์ด๋จธ ์›์ƒ๋ณต๊ท€ : 10์ดˆ if(usGpioFlag != GPIO_FLAG_FRONT_LEFT_MIDDLE) { g_timer.SetTimer(BACK_LIGHT_TIMER, BACK_LIGHT_TIME, NULL, "LCD BackLight Timer"); } } DBGMSGC(DBG_ELEVATOR, "--\r\n"); }
[ "freejack@ubuntu.(none)" ]
freejack@ubuntu.(none)
58bbb6a913c062b39f9d0eaf9ff6eb0effe5717c
753ed389484c2bbb5d26c21f3c944471a8d704fd
/cv2/streamcypher.cpp
27e49f739ba6161a6ed1ab12d0d4b5dd10b7cf70
[]
no_license
jhrach/BEZ
ee86f0ac1f985dc8830db98834e5e69c5eb8dbbe
ff04cb9e5b87854762954ff585115a74c839cb06
refs/heads/master
2021-01-12T21:17:57.541026
2014-03-26T16:58:20
2014-03-26T16:58:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,779
cpp
#include <stdlib.h> #include <openssl/evp.h> #include <string.h> #include <fstream> using namespace std; int main(void) { unsigned char known[1024] = "abcdefghijklmnopqrstuvwxyz0123"; unsigned char knownst[1024]; int knownstlen = 0; unsigned char ot[1024] = "Supertajna zprava z BEZ supert"; // open text unsigned char st[1024]; // sifrovany text unsigned char key[EVP_MAX_KEY_LENGTH] = "SuperTajnyKlic"; // klic pro sifrovani unsigned char iv[EVP_MAX_IV_LENGTH] = "SuperTajneIV"; // inicializacni vektor unsigned char coleaguest[1024]; ofstream outFile; int colotLength = 0; int colstLength = 0; int colkeylength = 0; unsigned char coleagueot[1024]; unsigned char coleaguekey[1024]; int otLength = strlen((const char*) ot); int stLength = 0; int tmpLength = 0; EVP_CIPHER_CTX ctx; // struktura pro kontext printf("OT: %s\n", ot); /* Sifrovani */ EVP_EncryptInit(&ctx, EVP_rc4(), key, iv); // nastaveni kontextu pro sifrovani EVP_EncryptUpdate(&ctx, st, &stLength, ot, otLength); // sifrovani ot EVP_EncryptFinal(&ctx, &st[stLength], &tmpLength); // ziskani sifrovaneho textu z kontextu printf ("Zasifrovano %d znaku.\nMY_ST:", stLength); for(int i=0; i < stLength ; i++){ printf ("%02x", st[i]); } outFile.open("mycyphed.bin"); outFile.write((char *)st,stLength); outFile.close(); puts("\n"); EVP_EncryptInit(&ctx, EVP_rc4(), key, iv); // nastaveni kontextu pro sifrovani EVP_EncryptUpdate(&ctx, knownst, &knownstlen, known, (int)strlen((const char *)known)); // sifrovani ot EVP_EncryptFinal(&ctx, &knownst[knownstlen], &tmpLength); // ziskani sifrovaneho textu z kontextu printf("KNOWN:%s\n", known); printf ("Zasifrovano %d znaku.\nKNOWNST:", knownstlen); for(int i=0; i < knownstlen ; i++){ printf ("%02x", knownst[i]); } outFile.open("known.bin"); outFile.write((char*)knownst,knownstlen); outFile.close(); outFile.open("known.txt"); outFile << known; outFile.close(); printf("\n"); for(int i=0 ; i < stLength; i++){ coleagueot[i] = (st[i] ^ knownst[i] ^ known[i]); } /* EVP_EncryptInit(&ctx, EVP_rc4(),knownst,coleaguest); // nastaveni kontextu pro sifrovani EVP_EncryptUpdate(&ctx, coleagueiv, &colivlength, known, strlen((const char*)known)); // sifrovani ot EVP_EncryptFinal(&ctx, &coleagueiv[colivlength], &tmpLength); // ziskani sifrovaneho textu z kontextu puts("\nIV:"); //printf("IV:%s\n", coleagueiv); for(int i=0; i < colivlength ; i++){ printf ("%02x", coleagueiv[i]); } puts("\n"); // */ /* printf("IV:%s\n",coleagueiv); EVP_EncryptInit(&ctx, EVP_rc4(), coleagueiv,coleagueiv); // nastaveni kontextu pro sifrovani EVP_EncryptUpdate(&ctx, coleaguekey, &colkeylength, known, strlen((char *)known)); // sifrovani ot EVP_EncryptFinal(&ctx, &coleaguekey[colkeylength], &tmpLength); // ziskani sifrovaneho textu z kontextu /* puts("KEY:"); for(int i=0; i < colkeylength ; i++){ printf ("%02x", coleaguekey[i]); } puts("\n"); // */ // printf("KEY:%s\n", coleaguekey); /* EVP_EncryptInit(&ctx, EVP_rc4(), coleaguekey, 0); // nastaveni kontextu pro sifrovani EVP_EncryptUpdate(&ctx, coleagueot, &colotLength, st, stLength); // sifrovani ot EVP_EncryptFinal(&ctx, &coleagueot[colotLength], &tmpLength); // ziskani sifrovaneho textu z kontextu */ printf("OT:%s\n", coleagueot); // /* Desifrovani */ // EVP_DecryptInit(&ctx, EVP_rc4(), key, iv); // nastaveni kontextu pro desifrovani // EVP_DecryptUpdate(&ctx, ot, &otLength, st, stLength); // desifrovani st // EVP_DecryptFinal(&ctx, &ot[otLength], &tmpLength); // ziskani desifrovaneho textu z kontextu // /* Vypsani zasifrovaneho a rozsifrovaneho textu. */ // printf("DT: %s\n", ot); exit(0); }
[ "shadow.to.root@gmail.com" ]
shadow.to.root@gmail.com
a592addea95811bc23a8550cb3cd4dadbf43e160
41098b8eb7a50a0cbc8ce9973eb7840f5d5fa87e
/Implementation/id_002/id_002b.cc
3dbfe8a85637b921bf3ed353374630494ace53a2
[]
no_license
RexusWolf/IS
f119bddc372b25ec3c4dea66e72254097f4a1cb3
80e11fde39bfbe72cfae17e77a4af822d582ffd5
refs/heads/master
2021-08-04T17:10:14.810359
2019-01-10T19:54:18
2019-01-10T19:54:18
149,256,650
14
1
null
null
null
null
UTF-8
C++
false
false
391
cc
// ID_0002a: Remove all Student #include <cstdlib> #include <fstream> #include <iostream> #include <list> #include "id_002b.h" #include "../classes/student.h" using std::list; void deleteAll(list<Student> students){ list<Student>::iterator b = students.begin(); list<Student>::iterator e = students.end(); students.erase(b,e); cout << "All students has been removed." << endl; }
[ "francisjmp99@gmail.com" ]
francisjmp99@gmail.com
4706be939cc1ffea406f473d6d30f8ddf8fed52b
b50e21a9d46169930957fc43ce589b60631e3365
/OpenGLTutorial/WindowEx.cpp
ccbb587d5a50148dcd82f0a7312ee76242f19733
[]
no_license
YMMH/OpenGLTutorial
05b3ea4118ca306eb62920a815cb958458ac6b39
7338c130b8943a727f52310082dec59c35bdac75
refs/heads/master
2020-06-20T07:39:30.925647
2019-07-15T17:59:54
2019-07-15T17:59:54
197,045,944
0
0
null
null
null
null
UHC
C++
false
false
1,863
cpp
#include <glad/glad.h> #include <GLFW/glfw3.h> #include <iostream> #define WIN_HEIGHT 600 #define WIN_WIDTH 800 void framebuffer_size_callback(GLFWwindow *window, int width, int height); void processInput(GLFWwindow* window); int main() { glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); //์œˆ๋„์šฐ ์„ค์ • GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); //OpenGL ํ•จ์ˆ˜ ํ˜ธ์ถœ ์ „ GLAD ์ดˆ๊ธฐํ™” if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { std::cout << "Failed to initialize GLAD" << std::endl; return -1; } //OpenGL์— rendering window size noti glViewport(0, 0, WIN_WIDTH, WIN_HEIGHT);//Screen ์ขŒํ‘œ๋ฅผ 2D ์ขŒํ‘œ๋กœ ๋ณ€ํ™˜ //๋ชจ๋“  ์ฐฝ์˜ ํฌ๊ธฐ๊ฐ€ ๋ณ€๊ฒฝ ๋  ๋•Œ๋งˆ๋‹ค ์ž‘์„ฑํ•œ ์‚ฌ์ด์ฆˆ ๋ณ€๊ฒฝ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๊ฒ ๋‹ค๊ณ  GLFW์— noti glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); //ํ”„๋กœ๊ทธ๋žจ์ด ๊ณ„์† ์‹คํ–‰๋  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” render loop while (!glfwWindowShouldClose(window)) { //์ž…๋ ฅ์ฒ˜๋ฆฌ processInput(window); //๋ Œ๋”๋ง ๋ช…๋ น glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); //์ด๋ฒคํŠธ ํ™•์ธ, ๋ฒ„ํผ ๊ต์ฒด glfwSwapBuffers(window); glfwPollEvents(); } glfwTerminate();//๋ชจ๋“  ์ž์› ์ •๋ฆฌ/์‚ญ์ œ return 0; } void framebuffer_size_callback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); } void processInput(GLFWwindow* window) { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) { glfwSetWindowShouldClose(window, true); } }
[ "sftwrmstr@gmail.com" ]
sftwrmstr@gmail.com
a33349a5bf841e95739bd23a0ea0b7b16690b2af
24411a9cfe06f4e52ff4f7689ee09ebdadebb863
/ToDoList/tdccustomattribdata.h
621e55e70c085cde5fa64e2d9d67e80d2fff54c0
[]
no_license
JohnnyXiaoYang/ToDoList_7.2
6371a2d24f86e6781566ba0a86b43c3a2d57a97f
7f0f14a49b55304b71b257c0086fbb179c12dbc7
refs/heads/master
2022-11-30T23:55:53.309392
2020-08-16T01:22:04
2020-08-16T01:22:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,693
h
#if !defined(AFX_TDCCDATA_H__5951FDE6_508A_4A9D_A55D_D16EB026AEF7__INCLUDED_) #define AFX_TDCCDATA_H__5951FDE6_508A_4A9D_A55D_D16EB026AEF7__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 ///////////////////////////////////////////////////////////////////////////////////////////// #include "..\interfaces\ITaskList.h" #include <afxtempl.h> ///////////////////////////////////////////////////////////////////////////////////////////// struct TDCCADATA { TDCCADATA(const CString& sValue = _T(""), TCHAR cSep = 0); TDCCADATA(LPCTSTR szValue, TCHAR cSep = 0); TDCCADATA(double dValue); TDCCADATA(double dValue, TDC_UNITS nUnits); TDCCADATA(const CStringArray& aValues); TDCCADATA(const CStringArray& aValues, const CStringArray& aExtra); TDCCADATA(int nValue); TDCCADATA(const COleDateTime& dtValue); TDCCADATA(bool bValue); TDCCADATA(const TDCCADATA& data); TDCCADATA& operator=(const TDCCADATA& data); BOOL operator==(const TDCCADATA& data) const; BOOL operator!=(const TDCCADATA& data) const; BOOL HasExtra() const; BOOL IsEmpty() const; void Clear(); const CString& AsString() const; double AsDouble() const; int AsInteger() const; COleDateTime AsDate() const; bool AsBool() const; int AsArray(CStringArray& aValues) const; int AsArrays(CStringArray& aValues, CStringArray& aExtra) const; double AsTimePeriod(TDC_UNITS& nUnits) const; TDC_UNITS GetTimeUnits() const; void Set(double dValue); void Set(int nValue); void Set(const COleDateTime& dtValue); void Set(const CString& sValue, TCHAR cSep = 0); void Set(double dValue, TDC_UNITS nUnits); void Set(bool bValue, TCHAR nChar = 0); void Set(const CStringArray& aValues); void Set(const CStringArray& aValues, const CStringArray& aExtra); CString FormatAsArray(TCHAR cSep = 0) const; CString FormatAsDate(BOOL bISO = FALSE) const; CString FormatAsTimePeriod(int nDecimalPlaces = 2) const; protected: CString sData, sExtra; protected: static void Set(const CStringArray& aValues, CString& sValue); static int AsArray(const CString& sValue, CStringArray& aValues); }; ///////////////////////////////////////////////////////////////////////////// class CTDCCustomAttributeDataMap : public CMap<CString, LPCTSTR, TDCCADATA, TDCCADATA&> { public: BOOL Lookup(LPCTSTR key, TDCCADATA& rValue) const; void SetAt(LPCTSTR key, const TDCCADATA& newValue); void Copy(const CTDCCustomAttributeDataMap& mapData); BOOL MatchAll(const CTDCCustomAttributeDataMap& mapData) const; TDCCADATA& operator[](LPCTSTR key); }; ///////////////////////////////////////////////////////////////////////////// #endif // AFX_TDCCDATA_H__5951FDE6_508A_4A9D_A55D_D16EB026AEF7__INCLUDED_
[ "daniel.godson@gmail.com" ]
daniel.godson@gmail.com