Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/pr/146' into gopro-vc5-decompr…
Browse files Browse the repository at this point in the history
…essor

Refs. darktable-org#146
Refs. darktable-org#40
Refs. https://redmine.darktable.org/issues/11466

Initial performance numbers:

$ ~/rawspeed/build-Clang-Release/src/utilities/rsbench/rsbench --benchmark_display_aggregates_only=true --benchmark_counters_tabular=true --benchmark_repetitions=100 GOPR9172.GPR
2018-10-09 13:34:47
Running /home/lebedevri/rawspeed/build-Clang-Release/src/utilities/rsbench/rsbench
Run on (8 X 4000 MHz CPU s)
CPU Caches:
  L1 Data 16K (x8)
  L1 Instruction 64K (x4)
  L2 Unified 2048K (x4)
  L3 Unified 8192K (x1)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Benchmark                                        Time           CPU Iterations  CPUTime,s CPUTime/WallTime     Pixels Pixels/CPUTime Pixels/WallTime Raws/CPUTime Raws/WallTime WallTime,s
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GOPR9172.GPR/threads:8/real_time_mean          334 ms        334 ms          2   0.333654         0.999958        12M       35.9684M        35.9669M      2.99737       2.99724   0.333668
GOPR9172.GPR/threads:8/real_time_median        334 ms        334 ms          2   0.334033                1        12M       35.9246M        35.9213M      2.99372       2.99344   0.334064
GOPR9172.GPR/threads:8/real_time_stddev          3 ms          3 ms          2   3.05262m         73.7799u          0        329.75k        330.147k    0.0274792     0.0275122   3.05653m


* upstream/pr/146:
  Misc comment cleanup in VC5Decompressor
  Simplify GoPro entries in cameras.xml
  clang-format VC5Decompressor and related changes
  Add support for GoPro Fusion and Hero7
  Fix some bit clamping issues in the VC5 decompressor + misc cleanup
  Fix typo and rounding errors in VC5Decompressor
  Fix several clang warnings in VC5Decompressor
  Update table17.inc with new upstream version
  Add support for GoPro's .GPR file format
  • Loading branch information
LebedevRI committed Oct 9, 2018
2 parents 27808d5 + 6b76969 commit 7bc7e11
Show file tree
Hide file tree
Showing 9 changed files with 1,145 additions and 0 deletions.
12 changes: 12 additions & 0 deletions data/cameras.xml
Expand Up @@ -2066,6 +2066,18 @@
<Hint name="wb_offset" value="142"/>
</Hints>
</Camera>
<Camera make="GoPro" model="FUSION" mode="dng">
<ID make="GoPro" model="FUSION">GoPro FUSION</ID>
</Camera>
<Camera make="GoPro" model="HERO5 Black" mode="dng">
<ID make="GoPro" model="HERO5 Black">GoPro HERO5 Black</ID>
</Camera>
<Camera make="GoPro" model="HERO6 Black" mode="dng">
<ID make="GoPro" model="HERO6 Black">GoPro HERO6 Black</ID>
</Camera>
<Camera make="GoPro" model="HERO7 Black" mode="dng">
<ID make="GoPro" model="HERO7 Black">GoPro HERO7 Black</ID>
</Camera>
<Camera make="NIKON CORPORATION" model="NIKON D100" mode="12bit-compressed">
<ID make="Nikon" model="D100">Nikon D100</ID>
<CFA width="2" height="2">
Expand Down
2 changes: 2 additions & 0 deletions data/cameras.xsd
Expand Up @@ -25,6 +25,7 @@
<xs:enumeration value="Epson"/>
<xs:enumeration value="Fujifilm"/>
<xs:enumeration value="GITUP"/>
<xs:enumeration value="GoPro"/>
<xs:enumeration value="Hasselblad"/>
<xs:enumeration value="Kodak"/>
<xs:enumeration value="LG"/>
Expand Down Expand Up @@ -375,6 +376,7 @@
<xs:enumeration value="Foculus"/>
<xs:enumeration value="GITUP"/>
<xs:enumeration value="Generic"/>
<xs:enumeration value="GoPro"/>
<xs:enumeration value="Hasselblad"/>
<xs:enumeration value="KODAK"/>
<xs:enumeration value="KONICA MINOLTA"/>
Expand Down
1 change: 1 addition & 0 deletions src/librawspeed/common/CMakeLists.txt
Expand Up @@ -20,6 +20,7 @@ FILE(GLOB SOURCES
"RawImageDataU16.cpp"
"RawspeedException.h"
"Spline.h"
"table17.inc"
"TableLookUp.cpp"
"TableLookUp.h"
"Threading.h"
Expand Down
291 changes: 291 additions & 0 deletions src/librawspeed/common/table17.inc
@@ -0,0 +1,291 @@
// Taken from https://github.com/gopro/gpr/raw/d2d78d1b236a278a13ed5abee6870af2b490c89f/source/lib/vc5_common/table17.inc
/*! @ file bitstream.h
*
* @brief Declaration of the bitstream data structure.
*
* @version 1.0.0
*
* (C) Copyright 2018 GoPro Inc (http://gopro.com/).
*
* Licensed under either:
* - Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0
* - MIT license, http://opensource.org/licenses/MIT
* at your option.
*
* 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.
*/

RLVTABLE(264) table17 =
{
264,
{
{1, 0x00000000, 1, 0}, // m0
{2, 0x00000002, 1, 1}, // m1
{3, 0x00000007, 1, 2}, // m2
{5, 0x00000019, 1, 3}, // m3
{6, 0x00000030, 1, 4}, // m4
{6, 0x00000036, 1, 5}, // m5
{7, 0x0000006F, 1, 8}, // m8
{7, 0x00000063, 1, 6}, // m6
{7, 0x00000069, 12, 0}, // z12
{7, 0x0000006B, 1, 7}, // m7
{8, 0x000000D1, 20, 0}, // z20
{8, 0x000000D4, 1, 9}, // m9
{8, 0x000000DC, 1, 10}, // m10
{9, 0x00000189, 1, 11}, // m11
{9, 0x0000018A, 32, 0}, // z32
{9, 0x000001A0, 1, 12}, // m12
{9, 0x000001AB, 1, 13}, // m13
{10, 0x00000377, 1, 18}, // m18
{10, 0x00000310, 1, 14}, // m14
{10, 0x00000316, 1, 15}, // m15
{10, 0x00000343, 60, 0}, // z60
{10, 0x00000354, 1, 16}, // m16
{10, 0x00000375, 1, 17}, // m17
{11, 0x00000623, 1, 19}, // m19
{11, 0x00000684, 1, 20}, // m20
{11, 0x00000685, 100, 0}, // z100
{11, 0x000006AB, 1, 21}, // m21
{11, 0x000006EC, 1, 22}, // m22
{12, 0x00000DDB, 1, 29}, // m29
{12, 0x00000C5C, 1, 24}, // m24
{12, 0x00000C5E, 1, 25}, // m25
{12, 0x00000C44, 1, 23}, // m23
{12, 0x00000D55, 1, 26}, // m26
{12, 0x00000DD1, 1, 27}, // m27
{12, 0x00000DD3, 1, 28}, // m28
{13, 0x00001BB5, 1, 35}, // m35
{13, 0x0000188B, 1, 30}, // m30
{13, 0x000018BB, 1, 31}, // m31
{13, 0x000018BF, 180, 0}, // z180
{13, 0x00001AA8, 1, 32}, // m32
{13, 0x00001BA0, 1, 33}, // m33
{13, 0x00001BA5, 320, 0}, // z320
{13, 0x00001BA4, 1, 34}, // m34
{14, 0x00003115, 1, 36}, // m36
{14, 0x00003175, 1, 37}, // m37
{14, 0x0000317D, 1, 38}, // m38
{14, 0x00003553, 1, 39}, // m39
{14, 0x00003768, 1, 40}, // m40
{15, 0x00006E87, 1, 46}, // m46
{15, 0x00006ED3, 1, 47}, // m47
{15, 0x000062E8, 1, 42}, // m42
{15, 0x000062F8, 1, 43}, // m43
{15, 0x00006228, 1, 41}, // m41
{15, 0x00006AA4, 1, 44}, // m44
{15, 0x00006E85, 1, 45}, // m45
{16, 0x0000C453, 1, 48}, // m48
{16, 0x0000C5D3, 1, 49}, // m49
{16, 0x0000C5F3, 1, 50}, // m50
{16, 0x0000DDA4, 1, 53}, // m53
{16, 0x0000DD08, 1, 51}, // m51
{16, 0x0000DD0C, 1, 52}, // m52
{17, 0x0001BB4B, 1, 61}, // m61
{17, 0x0001BB4A, 1, 60}, // m60
{17, 0x00018BA5, 1, 55}, // m55
{17, 0x00018BE5, 1, 56}, // m56
{17, 0x0001AA95, 1, 57}, // m57
{17, 0x0001AA97, 1, 58}, // m58
{17, 0x000188A4, 1, 54}, // m54
{17, 0x0001BA13, 1, 59}, // m59
{18, 0x00031748, 1, 62}, // m62
{18, 0x000317C8, 1, 63}, // m63
{18, 0x00035528, 1, 64}, // m64
{18, 0x0003552C, 1, 65}, // m65
{18, 0x00037424, 1, 66}, // m66
{18, 0x00037434, 1, 67}, // m67
{18, 0x00037436, 1, 68}, // m68
{19, 0x00062294, 1, 69}, // m69
{19, 0x00062E92, 1, 70}, // m70
{19, 0x00062F92, 1, 71}, // m71
{19, 0x0006AA52, 1, 72}, // m72
{19, 0x0006AA5A, 1, 73}, // m73
{19, 0x0006E86A, 1, 75}, // m75
{19, 0x0006E86E, 1, 76}, // m76
{19, 0x0006E84A, 1, 74}, // m74
{20, 0x000C452A, 1, 77}, // m77
{20, 0x000C5D27, 1, 78}, // m78
{20, 0x000C5F26, 1, 79}, // m79
{20, 0x000D54A6, 1, 80}, // m80
{20, 0x000D54B6, 1, 81}, // m81
{20, 0x000DD096, 1, 82}, // m82
{20, 0x000DD0D6, 1, 83}, // m83
{20, 0x000DD0DE, 1, 84}, // m84
{21, 0x00188A56, 1, 85}, // m85
{21, 0x0018BA4D, 1, 86}, // m86
{21, 0x0018BE4E, 1, 87}, // m87
{21, 0x0018BE4F, 1, 88}, // m88
{21, 0x001AA96E, 1, 89}, // m89
{21, 0x001BA12E, 1, 90}, // m90
{21, 0x001BA12F, 1, 91}, // m91
{21, 0x001BA1AF, 1, 92}, // m92
{21, 0x001BA1BF, 1, 93}, // m93
{22, 0x0037435D, 1, 99}, // m99
{22, 0x0037437D, 1, 100}, // m100
{22, 0x00317498, 1, 94}, // m94
{22, 0x0035529C, 1, 95}, // m95
{22, 0x0035529D, 1, 96}, // m96
{22, 0x003552DE, 1, 97}, // m97
{22, 0x003552DF, 1, 98}, // m98
{23, 0x0062E933, 1, 102}, // m102
{23, 0x0062295D, 1, 101}, // m101
{23, 0x006AA53D, 1, 103}, // m103
{23, 0x006AA53F, 1, 105}, // m105
{23, 0x006AA53E, 1, 104}, // m104
{23, 0x006E86B9, 1, 106}, // m106
{23, 0x006E86F8, 1, 107}, // m107
{24, 0x00D54A79, 1, 111}, // m111
{24, 0x00C5D265, 1, 109}, // m109
{24, 0x00C452B8, 1, 108}, // m108
{24, 0x00DD0D71, 1, 113}, // m113
{24, 0x00D54A78, 1, 110}, // m110
{24, 0x00DD0D70, 1, 112}, // m112
{24, 0x00DD0DF2, 1, 114}, // m114
{24, 0x00DD0DF3, 1, 115}, // m115
{25, 0x0188A5F6, 1, 225}, // m225
{25, 0x0188A5F5, 1, 189}, // m189
{25, 0x0188A5F4, 1, 188}, // m188
{25, 0x0188A5F3, 1, 203}, // m203
{25, 0x0188A5F2, 1, 202}, // m202
{25, 0x0188A5F1, 1, 197}, // m197
{25, 0x0188A5F0, 1, 207}, // m207
{25, 0x0188A5EF, 1, 169}, // m169
{25, 0x0188A5EE, 1, 223}, // m223
{25, 0x0188A5ED, 1, 159}, // m159
{25, 0x0188A5AA, 1, 235}, // m235
{25, 0x0188A5E3, 1, 152}, // m152
{25, 0x0188A5DF, 1, 192}, // m192
{25, 0x0188A589, 1, 179}, // m179
{25, 0x0188A5DD, 1, 201}, // m201
{25, 0x0188A578, 1, 172}, // m172
{25, 0x0188A5E0, 1, 149}, // m149
{25, 0x0188A588, 1, 178}, // m178
{25, 0x0188A5D6, 1, 120}, // m120
{25, 0x0188A5DB, 1, 219}, // m219
{25, 0x0188A5E1, 1, 150}, // m150
{25, 0x0188A587, 1, 127}, // m127
{25, 0x0188A59A, 1, 211}, // m211
{25, 0x0188A5C4, 1, 125}, // m125
{25, 0x0188A5EC, 1, 158}, // m158
{25, 0x0188A586, 1, 247}, // m247
{25, 0x0188A573, 1, 238}, // m238
{25, 0x0188A59C, 1, 163}, // m163
{25, 0x0188A5C8, 1, 228}, // m228
{25, 0x0188A5FB, 1, 183}, // m183
{25, 0x0188A5A1, 1, 217}, // m217
{25, 0x0188A5EB, 1, 168}, // m168
{25, 0x0188A5A8, 1, 122}, // m122
{25, 0x0188A584, 1, 128}, // m128
{25, 0x0188A5D2, 1, 249}, // m249
{25, 0x0188A599, 1, 187}, // m187
{25, 0x0188A598, 1, 186}, // m186
{25, 0x0188A583, 1, 136}, // m136
{25, 0x018BA4C9, 1, 181}, // m181
{25, 0x0188A5D0, 1, 255}, // m255
{25, 0x0188A594, 1, 230}, // m230
{25, 0x0188A582, 1, 135}, // m135
{25, 0x0188A5CB, 1, 233}, // m233
{25, 0x0188A5D8, 1, 222}, // m222
{25, 0x0188A5E7, 1, 145}, // m145
{25, 0x0188A581, 1, 134}, // m134
{25, 0x0188A5EA, 1, 167}, // m167
{25, 0x0188A5A9, 1, 248}, // m248
{25, 0x0188A5A6, 1, 209}, // m209
{25, 0x0188A580, 1, 243}, // m243
{25, 0x0188A5A0, 1, 216}, // m216
{25, 0x0188A59D, 1, 164}, // m164
{25, 0x0188A5C3, 1, 140}, // m140
{25, 0x0188A57F, 1, 157}, // m157
{25, 0x0188A5C0, 1, 239}, // m239
{25, 0x0188A5DE, 1, 191}, // m191
{25, 0x0188A5D4, 1, 251}, // m251
{25, 0x0188A57E, 1, 156}, // m156
{25, 0x0188A5C2, 1, 139}, // m139
{25, 0x0188A592, 1, 242}, // m242
{25, 0x0188A5CD, 1, 133}, // m133
{25, 0x0188A57D, 1, 162}, // m162
{25, 0x0188A5A3, 1, 213}, // m213
{25, 0x0188A5E8, 1, 165}, // m165
{25, 0x0188A5A2, 1, 212}, // m212
{25, 0x0188A57C, 1, 227}, // m227
{25, 0x0188A58E, 1, 198}, // m198
{25, 0x0188A5B3, 1, 236}, // m236
{25, 0x0188A5B2, 1, 234}, // m234
{25, 0x0188A5B1, 1, 117}, // m117
{25, 0x0188A5B0, 1, 215}, // m215
{25, 0x0188A5AF, 1, 124}, // m124
{25, 0x0188A5AE, 1, 123}, // m123
{25, 0x0188A5AD, 1, 254}, // m254
{25, 0x0188A5AC, 1, 253}, // m253
{25, 0x0188A5AB, 1, 148}, // m148
{25, 0x0188A5DA, 1, 218}, // m218
{25, 0x0188A5E4, 1, 146}, // m146
{25, 0x0188A5E5, 1, 147}, // m147
{25, 0x0188A5D9, 1, 224}, // m224
{25, 0x0188A5B5, 1, 143}, // m143
{25, 0x0188A5BC, 1, 184}, // m184
{25, 0x0188A5BD, 1, 185}, // m185
{25, 0x0188A5E9, 1, 166}, // m166
{25, 0x0188A5CC, 1, 132}, // m132
{25, 0x0188A585, 1, 129}, // m129
{25, 0x0188A5D3, 1, 250}, // m250
{25, 0x0188A5E2, 1, 151}, // m151
{25, 0x0188A595, 1, 119}, // m119
{25, 0x0188A596, 1, 193}, // m193
{25, 0x0188A5B8, 1, 176}, // m176
{25, 0x0188A590, 1, 245}, // m245
{25, 0x0188A5C9, 1, 229}, // m229
{25, 0x0188A5A4, 1, 206}, // m206
{25, 0x0188A5E6, 1, 144}, // m144
{25, 0x0188A5A5, 1, 208}, // m208
{25, 0x0188A5CE, 1, 137}, // m137
{25, 0x0188A5BF, 1, 241}, // m241
{25, 0x0188A572, 1, 237}, // m237
{25, 0x0188A59B, 1, 190}, // m190
{25, 0x0188A5BE, 1, 240}, // m240
{25, 0x0188A5C7, 1, 131}, // m131
{25, 0x0188A5CA, 1, 232}, // m232
{25, 0x0188A5D5, 1, 252}, // m252
{25, 0x0188A57B, 1, 171}, // m171
{25, 0x0188A58D, 1, 205}, // m205
{25, 0x0188A58C, 1, 204}, // m204
{25, 0x0188A58B, 1, 118}, // m118
{25, 0x0188A58A, 1, 214}, // m214
{25, 0x018BA4C8, 1, 180}, // m180
{25, 0x0188A5C5, 1, 126}, // m126
{25, 0x0188A5FA, 1, 182}, // m182
{25, 0x0188A5BB, 1, 175}, // m175
{25, 0x0188A5C1, 1, 141}, // m141
{25, 0x0188A5CF, 1, 138}, // m138
{25, 0x0188A5B9, 1, 177}, // m177
{25, 0x0188A5B6, 1, 153}, // m153
{25, 0x0188A597, 1, 194}, // m194
{25, 0x0188A5FE, 1, 160}, // m160
{25, 0x0188A5D7, 1, 121}, // m121
{25, 0x0188A5BA, 1, 174}, // m174
{25, 0x0188A591, 1, 246}, // m246
{25, 0x0188A5C6, 1, 130}, // m130
{25, 0x0188A5DC, 1, 200}, // m200
{25, 0x0188A57A, 1, 170}, // m170
{25, 0x0188A59F, 1, 221}, // m221
{25, 0x0188A5F9, 1, 196}, // m196
{25, 0x0188A5B4, 1, 142}, // m142
{25, 0x0188A5A7, 1, 210}, // m210
{25, 0x0188A58F, 1, 199}, // m199
{25, 0x0188A5FD, 1, 155}, // m155
{25, 0x0188A5B7, 1, 154}, // m154
{25, 0x0188A593, 1, 244}, // m244
{25, 0x0188A59E, 1, 220}, // m220
{25, 0x0188A5F8, 1, 195}, // m195
{25, 0x0188A5FF, 1, 161}, // m161
{25, 0x0188A5FC, 1, 231}, // m231
{25, 0x0188A579, 1, 173}, // m173
{25, 0x0188A5F7, 1, 226}, // m226
{26, 0x03114BA2, 1, 116}, // m116
{26, 0x03114BA3, 0, 1}, // c256
}
};
8 changes: 8 additions & 0 deletions src/librawspeed/decoders/DngDecoder.cpp
Expand Up @@ -109,6 +109,7 @@ void DngDecoder::dropUnsuportedChunks(std::vector<const TiffIFD*>* data) {
#ifdef HAVE_ZLIB
case 8: // deflate
#endif
case 9: // VC-5 as used by GoPro
#ifdef HAVE_JPEG
case 0x884c: // lossy JPEG
#endif
Expand Down Expand Up @@ -280,6 +281,13 @@ void DngDecoder::decodeData(const TiffIFD* raw, uint32 sample_format) {
if (raw->hasEntry(PREDICTOR))
predictor = raw->getEntry(PREDICTOR)->getU32();

// Some decompressors (such as VC5) may depend on the white point
if (raw->hasEntry(WHITELEVEL)) {
TiffEntry* whitelevel = raw->getEntry(WHITELEVEL);
if (whitelevel->isInt())
mRaw->whitePoint = whitelevel->getU32();
}

AbstractDngDecompressor slices(mRaw, getTilingDescription(raw), compression,
mFixLjpeg, bps, predictor);

Expand Down
14 changes: 14 additions & 0 deletions src/librawspeed/decompressors/AbstractDngDecompressor.cpp
Expand Up @@ -28,6 +28,7 @@
#include "decompressors/JpegDecompressor.h" // for JpegDecompressor
#include "decompressors/LJpegDecompressor.h" // for LJpegDecompressor
#include "decompressors/UncompressedDecompressor.h" // for UncompressedDeco...
#include "decompressors/VC5Decompressor.h" // for VC5Decompressor
#include "io/ByteStream.h" // for ByteStream
#include "io/Endianness.h" // for Endianness, Endi...
#include "io/IOException.h" // for IOException, Thr...
Expand Down Expand Up @@ -128,6 +129,19 @@ void AbstractDngDecompressor::decompressThreaded(
"ZLIB is not present! Deflate compression will not be supported!"
ThrowRDE("deflate support is disabled.");
#endif
/* VC-5 */
} else if (compression == 9) {
for (size_t i = t->start; i < t->end && i < slices.size(); i++) {
auto e = &slices[i];
VC5Decompressor d(e->bs, mRaw);
try {
d.decode(e->offX, e->offY);
} catch (RawDecoderException& err) {
mRaw->setError(err.what());
} catch (IOException& err) {
mRaw->setError(err.what());
}
}
/* Lossy DNG */
} else if (compression == 0x884c) {
#ifdef HAVE_JPEG
Expand Down
2 changes: 2 additions & 0 deletions src/librawspeed/decompressors/CMakeLists.txt
Expand Up @@ -54,6 +54,8 @@ FILE(GLOB SOURCES
"SonyArw2Decompressor.h"
"UncompressedDecompressor.cpp"
"UncompressedDecompressor.h"
"VC5Decompressor.cpp"
"VC5Decompressor.h"
)

target_sources(rawspeed PRIVATE
Expand Down

0 comments on commit 7bc7e11

Please sign in to comment.