Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit 38dd7fb

Browse files
committed
Initial source and xcode build.
1 parent bcbc9f3 commit 38dd7fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+22549
-265
lines changed

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2015 Etc2Comp Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
x64/
15+
Release/
16+
Debug/
17+
ipch/
18+
*.sdf
19+
.vs/
20+
*Debug/
21+
*Release/
22+
*debug*/
23+
*release*/
24+
*.db
25+
Analysis/
26+
CMakeFiles/
27+
*.vcxproj*
28+
*.sln
29+
*.cmake
30+
CmakeCache.txt
31+
build_*/*
32+
!build_*/gen_xcode.sh

AUTHORS

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# This is the list of Etc2Comp authors for copyright purposes.
2-
#
3-
# This does not necessarily list everyone who has contributed code, since in
4-
# some cases, their employer may be the copyright holder. To see the full list
5-
# of contributors, see the revision history in source control.
6-
Google Inc.
7-
Blue Shift Inc.
1+
# This is the list of Etc2Comp authors for copyright purposes.
2+
#
3+
# This does not necessarily list everyone who has contributed code, since in
4+
# some cases, their employer may be the copyright holder. To see the full list
5+
# of contributors, see the revision history in source control.
6+
Google Inc.
7+
Blue Shift Inc.

CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2015 Etc2Comp Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
cmake_minimum_required(VERSION 2.8.9)
16+
project(EtcTest)
17+
18+
set (CMAKE_CXX_STANDARD 11)
19+
IF (APPLE)
20+
set (CMAKE_CXX_FLAGS "-I/usr/include/i386-linux-gnu/c++/4.8 -I/usr/include/c++/4.8 -std=c++11 -g3 -Wall -O3")
21+
ELSE ()
22+
IF (WIN32)
23+
set (CMAKE_CXX_FLAGS "-I/usr/include/i386-linux-gnu/c++/4.8 -I/usr/include/c++/4.8 -W4 /EHsc")
24+
ELSE()
25+
set (CMAKE_CXX_FLAGS "-I/usr/include/i386-linux-gnu/c++/4.8 -I/usr/include/c++/4.8 -std=c++11 -pthread -g3 -Wall -O2")
26+
ENDIF()
27+
ENDIF ()
28+
ADD_SUBDIRECTORY(EtcLib)
29+
ADD_SUBDIRECTORY(EtcTool)

CONTRIBUTING.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
# Contributing | Etc2Comp
2-
3-
Thank you for contributing to the Etc2Comp community!
4-
5-
- [Have a usage question?](#question)
6-
- [Think you found a bug?](#issue)
7-
- [Have a feature request?](#feature)
8-
- [Want to submit a pull request?](#submit)
9-
- [Small print](#smallprint)
10-
11-
## <a name="question"></a> Have a usage question?
12-
13-
- Review the README.md to make sure you're building the binary correctly.
14-
- Execute the binary with -h to show the usage help.
15-
- Search through [old issues](https://github.com/google/etc2comp/issues)
16-
for an answer to your question.
17-
- If you still haven't found an answer to your question, [open a new issue](https://github.com/google/etc2comp/issues/new).
18-
Please use the provided bug report template and include a minimal repro.
19-
20-
## <a name="issue"></a> Think you found a bug?
21-
22-
The library is experimental so that's highly likely. Follow the same
23-
procedure above for questions. If you are up to the challenge,
24-
[submit a Pull Request](#submit) with a fix!
25-
26-
## <a name="feature"></a> Have a feature request?
27-
28-
Great! Make sure the feature request isn't already listed in
29-
[existing issues](https://github.com/google/etc2comp/issues),
30-
then go ahead and [open a new issue](https://github.com/google/etc2comp/issues/new).
31-
Remove the default template information and specify what you are requesting
32-
technically, as well as, specifying what use cases it supports.
33-
34-
## <a name="submit"></a> Want to submit a pull request?
35-
36-
Sweet, we'd love to accept your contribution! [Open a new pull request](https://github.com/google/etc2comp/compare).
37-
38-
If you want to implement a new feature, please open an issue with a
39-
proposal first to discuss the change.
40-
41-
You will need to sign our [Contributor License Agreement](https://cla.developers.google.com/about/google-individual)
42-
before we can accept your pull request.
43-
44-
## <a name="smallprint"></a> The small print
45-
Contributions made by corporations are covered by a different
46-
agreement than the one above, the
47-
[Software Grant and Corporate Contributor License Agreement]
1+
# Contributing | Etc2Comp
2+
3+
Thank you for contributing to the Etc2Comp community!
4+
5+
- [Have a usage question?](#question)
6+
- [Think you found a bug?](#issue)
7+
- [Have a feature request?](#feature)
8+
- [Want to submit a pull request?](#submit)
9+
- [Small print](#smallprint)
10+
11+
## <a name="question"></a> Have a usage question?
12+
13+
- Review the README.md to make sure you're building the binary correctly.
14+
- Execute the binary with -h to show the usage help.
15+
- Search through [old issues](https://github.com/google/etc2comp/issues)
16+
for an answer to your question.
17+
- If you still haven't found an answer to your question, [open a new issue](https://github.com/google/etc2comp/issues/new).
18+
Please use the provided bug report template and include a minimal repro.
19+
20+
## <a name="issue"></a> Think you found a bug?
21+
22+
The library is experimental so that's highly likely. Follow the same
23+
procedure above for questions. If you are up to the challenge,
24+
[submit a Pull Request](#submit) with a fix!
25+
26+
## <a name="feature"></a> Have a feature request?
27+
28+
Great! Make sure the feature request isn't already listed in
29+
[existing issues](https://github.com/google/etc2comp/issues),
30+
then go ahead and [open a new issue](https://github.com/google/etc2comp/issues/new).
31+
Remove the default template information and specify what you are requesting
32+
technically, as well as, specifying what use cases it supports.
33+
34+
## <a name="submit"></a> Want to submit a pull request?
35+
36+
Sweet, we'd love to accept your contribution! [Open a new pull request](https://github.com/google/etc2comp/compare).
37+
38+
If you want to implement a new feature, please open an issue with a
39+
proposal first to discuss the change.
40+
41+
You will need to sign our [Contributor License Agreement](https://cla.developers.google.com/about/google-individual)
42+
before we can accept your pull request.
43+
44+
## <a name="smallprint"></a> The small print
45+
Contributions made by corporations are covered by a different
46+
agreement than the one above, the
47+
[Software Grant and Corporate Contributor License Agreement]
4848
(https://cla.developers.google.com/about/google-corporate).

EtcLib/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2015 The Etc2Comp Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
project(EtcLib)
16+
include_directories(./Etc)
17+
include_directories(./EtcCodec)
18+
19+
file(GLOB SOURCES
20+
${PROJECT_SOURCE_DIR}/Etc/*.h
21+
${PROJECT_SOURCE_DIR}/EtcCodec/*.h
22+
${PROJECT_SOURCE_DIR}/Etc/*.cpp
23+
${PROJECT_SOURCE_DIR}/EtcCodec/*.cpp)
24+
ADD_LIBRARY(EtcLib ${SOURCES})

EtcLib/Etc/Etc.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2015 The Etc2Comp Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "EtcConfig.h"
18+
#include "Etc.h"
19+
20+
#include <string.h>
21+
22+
namespace Etc
23+
{
24+
// ----------------------------------------------------------------------------------------------------
25+
// C-style inteface to the encoder
26+
//
27+
void Encode(float *a_pafSourceRGBA,
28+
unsigned int a_uiSourceWidth,
29+
unsigned int a_uiSourceHeight,
30+
Image::Format a_format,
31+
ErrorMetric a_eErrMetric,
32+
float a_fEffort,
33+
unsigned int a_uiJobs,
34+
unsigned int a_uiMaxJobs,
35+
unsigned char **a_ppaucEncodingBits,
36+
unsigned int *a_puiEncodingBitsBytes,
37+
unsigned int *a_puiExtendedWidth,
38+
unsigned int *a_puiExtendedHeight,
39+
int *a_piEncodingTime_ms, bool a_bVerboseOutput)
40+
{
41+
42+
Image image(a_pafSourceRGBA, a_uiSourceWidth,
43+
a_uiSourceHeight,
44+
a_eErrMetric);
45+
image.m_bVerboseOutput = a_bVerboseOutput;
46+
image.Encode(a_format, a_eErrMetric, a_fEffort, a_uiJobs, a_uiMaxJobs);
47+
48+
*a_ppaucEncodingBits = image.GetEncodingBits();
49+
*a_puiEncodingBitsBytes = image.GetEncodingBitsBytes();
50+
*a_puiExtendedWidth = image.GetExtendedWidth();
51+
*a_puiExtendedHeight = image.GetExtendedHeight();
52+
*a_piEncodingTime_ms = image.GetEncodingTimeMs();
53+
}
54+
55+
// ----------------------------------------------------------------------------------------------------
56+
//
57+
58+
}

EtcLib/Etc/Etc.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2015 The Etc2Comp Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#include "EtcConfig.h"
20+
#include "EtcImage.h"
21+
#include "EtcColor.h"
22+
#include "EtcErrorMetric.h"
23+
24+
namespace Etc
25+
{
26+
class Block4x4EncodingBits;
27+
28+
// C-style inteface to the encoder
29+
void Encode(float *a_pafSourceRGBA,
30+
unsigned int a_uiSourceWidth,
31+
unsigned int a_uiSourceHeight,
32+
Image::Format a_format,
33+
ErrorMetric a_eErrMetric,
34+
float a_fEffort,
35+
unsigned int a_uiJobs,
36+
unsigned int a_uimaxJobs,
37+
unsigned char **a_ppaucEncodingBits,
38+
unsigned int *a_puiEncodingBitsBytes,
39+
unsigned int *a_puiExtendedWidth,
40+
unsigned int *a_puiExtendedHeight,
41+
int *a_piEncodingTime_ms, bool a_bVerboseOutput = false);
42+
43+
}

EtcLib/Etc/EtcColor.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2015 The Etc2Comp Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#include <math.h>
20+
21+
namespace Etc
22+
{
23+
24+
inline float LogToLinear(float a_fLog)
25+
{
26+
static const float ALPHA = 0.055f;
27+
static const float ONE_PLUS_ALPHA = 1.0f + ALPHA;
28+
29+
if (a_fLog <= 0.04045f)
30+
{
31+
return a_fLog / 12.92f;
32+
}
33+
else
34+
{
35+
return powf((a_fLog + ALPHA) / ONE_PLUS_ALPHA, 2.4f);
36+
}
37+
}
38+
39+
inline float LinearToLog(float &a_fLinear)
40+
{
41+
static const float ALPHA = 0.055f;
42+
static const float ONE_PLUS_ALPHA = 1.0f + ALPHA;
43+
44+
if (a_fLinear <= 0.0031308f)
45+
{
46+
return 12.92f * a_fLinear;
47+
}
48+
else
49+
{
50+
return ONE_PLUS_ALPHA * powf(a_fLinear, (1.0f/2.4f)) - ALPHA;
51+
}
52+
}
53+
54+
class ColorR8G8B8A8
55+
{
56+
public:
57+
58+
unsigned char ucR;
59+
unsigned char ucG;
60+
unsigned char ucB;
61+
unsigned char ucA;
62+
63+
};
64+
}

0 commit comments

Comments
 (0)