Skip to content

Commit 2b2bb2a

Browse files
author
Christian Feldmann
committed
Just fix spelling of endianness and some minor things.
1 parent 5847a6d commit 2b2bb2a

17 files changed

+80
-74
lines changed

YUViewLib/src/video/PixelFormat.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ enum class Endianness
5151
Little
5252
};
5353

54-
constexpr EnumMapper<Endianness, 2> EndianessMapper = {std::make_pair(Endianness::Little, "Little"),
55-
std::make_pair(Endianness::Big, "Big")};
54+
constexpr EnumMapper<Endianness, 2> EndiannessMapper = {
55+
std::make_pair(Endianness::Little, "Little"), std::make_pair(Endianness::Big, "Big")};
5656

5757
enum class DataLayout
5858
{
@@ -61,7 +61,7 @@ enum class DataLayout
6161
};
6262

6363
constexpr EnumMapper<DataLayout, 2> DataLayoutMapper = {
64-
std::make_pair(DataLayout::Packed, "Packed"), std::make_pair(DataLayout::Planar, "Planar")};
64+
std::make_pair(DataLayout::Packed, "Packed"), std::make_pair(DataLayout::Planar, "Planar")};
6565

6666
enum class TextRendering
6767
{

YUViewLib/src/video/rgb/ConversionDifferenceRGB.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ std::pair<QImage, MSE>
8787
calculateDifferencePredefinedPixelFormat(const InputFrameParameters &frame1,
8888
const InputFrameParameters &frame2,
8989
const PredefinedPixelFormat predefinedPixelFormat,
90-
const Endianness endianess,
90+
const Endianness endianness,
9191
const int amplificationFactor,
9292
const bool markDifference)
9393
{
@@ -108,8 +108,8 @@ calculateDifferencePredefinedPixelFormat(const InputFrameParameters &frame1,
108108

109109
for (unsigned i = 0; i < frameSize.width * frameSize.height; ++i)
110110
{
111-
const auto rgb1 = extractRGB565Value(rawData1, endianess);
112-
const auto rgb2 = extractRGB565Value(rawData2, endianess);
111+
const auto rgb1 = extractRGB565Value(rawData1, endianness);
112+
const auto rgb2 = extractRGB565Value(rawData2, endianness);
113113

114114
const auto delta = rgb1 - rgb2;
115115

@@ -128,7 +128,7 @@ calculateDifferencePredefinedPixelFormat(const InputFrameParameters &frame1,
128128
}
129129

130130
template <typename T>
131-
rgba_t getRGBAndConvertEndianess(const DataPointers<T> dataPointers, const Endianness endianess)
131+
rgba_t getRGBAndConvertEndianness(const DataPointers<T> dataPointers, const Endianness endianness)
132132
{
133133
constexpr auto bitDepth =
134134
(std::is_same_v<T, uint8_t> ? 8 : (std::is_same_v<T, uint16_t> ? 16 : 32));
@@ -137,11 +137,11 @@ rgba_t getRGBAndConvertEndianess(const DataPointers<T> dataPointers, const Endia
137137
auto g = *dataPointers.g;
138138
auto b = *dataPointers.b;
139139

140-
if (endianess == Endianness::Big)
140+
if (endianness == Endianness::Big)
141141
{
142-
r = swapBytesEndianess<bitDepth>(r);
143-
g = swapBytesEndianess<bitDepth>(g);
144-
b = swapBytesEndianess<bitDepth>(b);
142+
r = swapBytesEndianness<bitDepth>(r);
143+
g = swapBytesEndianness<bitDepth>(g);
144+
b = swapBytesEndianness<bitDepth>(b);
145145
}
146146

147147
return rgba_t({.r = static_cast<int>(r), .g = static_cast<int>(g), .b = static_cast<int>(b)});
@@ -174,8 +174,8 @@ std::pair<QImage, MSE> calculateDifferenceAndMSE(const InputFrameParameters &fra
174174

175175
for (unsigned i = 0; i < frameSize.width * frameSize.height; ++i)
176176
{
177-
const auto rgb1 = getRGBAndConvertEndianess(dataPointers1, pixelFormat.getEndianess());
178-
const auto rgb2 = getRGBAndConvertEndianess(dataPointers2, pixelFormat.getEndianess());
177+
const auto rgb1 = getRGBAndConvertEndianness(dataPointers1, pixelFormat.getEndianness());
178+
const auto rgb2 = getRGBAndConvertEndianness(dataPointers2, pixelFormat.getEndianness());
179179

180180
const auto delta = rgb1 - rgb2;
181181

@@ -205,7 +205,7 @@ std::pair<QImage, MSE> calculateDifferenceAndMSE(const InputFrameParameters &fra
205205
return calculateDifferencePredefinedPixelFormat(frame1,
206206
frame2,
207207
*pixelFormat.getPredefinedPixelFormat(),
208-
pixelFormat.getEndianess(),
208+
pixelFormat.getEndianness(),
209209
amplificationFactor,
210210
markDifference);
211211

YUViewLib/src/video/rgb/ConversionFunctions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ DataPointers<T> calculatePointersToStartOfComponents(const QByteArray &rawFr
8484
return {.r = castDataPointer + posR, .g = castDataPointer + posG, .b = castDataPointer + posB};
8585
}
8686

87-
inline rgba_t extractRGB565Value(const unsigned char *data, const Endianness endianess)
87+
inline rgba_t extractRGB565Value(const unsigned char *data, const Endianness endianness)
8888
{
8989
int byte1 = *data;
9090
int byte2 = *(data + 1);
9191

92-
if (endianess == Endianness::Big)
92+
if (endianness == Endianness::Big)
9393
std::swap(byte1, byte2);
9494

9595
const auto value = byte1 + (byte2 << 8);

YUViewLib/src/video/rgb/ConversionRGB.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ void convertRGB565ToARGB(const QByteArray &sourceBuffer,
6666
const int componentScale[4],
6767
const bool limitedRange)
6868
{
69-
auto rawData = reinterpret_cast<const unsigned char *>(sourceBuffer.data());
70-
const auto endianess = srcPixelFormat.getEndianess();
69+
auto rawData = reinterpret_cast<const unsigned char *>(sourceBuffer.data());
70+
const auto endianness = srcPixelFormat.getEndianness();
7171

7272
for (unsigned i = 0; i < frameSize.width * frameSize.height; i++)
7373
{
74-
auto [r, g, b, a] = extractRGB565Value(rawData, endianess);
74+
auto [r, g, b, a] = extractRGB565Value(rawData, endianness);
7575

7676
// Scale from 565 to 8 bit
7777
r = r << 3;
@@ -142,15 +142,15 @@ void convertRGBToARGB(const QByteArray &sourceBuffer,
142142
srcA = ((InValueType)sourceBuffer.data()) + offsetA;
143143
}
144144

145-
const auto isBigEndian = bitDepth > 8 && srcPixelFormat.getEndianess() == Endianness::Big;
145+
const auto isBigEndian = bitDepth > 8 && srcPixelFormat.getEndianness() == Endianness::Big;
146146
for (unsigned i = 0; i < frameSize.width * frameSize.height; i++)
147147
{
148148
auto convertValue =
149149
[&isBigEndian, &rightShift](const InValueType sourceData, const int scale, const bool invert)
150150
{
151151
auto value = static_cast<int64_t>(sourceData[0]);
152152
if (isBigEndian)
153-
value = swapBytesEndianess<bitDepth>(value);
153+
value = swapBytesEndianness<bitDepth>(value);
154154
value = ((value * scale) >> rightShift);
155155
value = functions::clip(value, 0, 255);
156156
if (invert)
@@ -213,7 +213,7 @@ void convertPredefinedPixelFormatRGBPlaneToARGB(const QByteArray &sourceBuff
213213
int byte1 = *rawData;
214214
int byte2 = *(rawData + 1);
215215

216-
if (srcPixelFormat.getEndianess() == Endianness::Big)
216+
if (srcPixelFormat.getEndianness() == Endianness::Big)
217217
std::swap(byte1, byte2);
218218

219219
const auto value = byte1 + (byte2 << 8);
@@ -270,8 +270,8 @@ void convertRGBPlaneToARGB(const QByteArray &sourceBuffer,
270270
for (size_t i = 0; i < frameSize.width * frameSize.height; i++)
271271
{
272272
auto val = static_cast<int64_t>(src[0]);
273-
if (bitDepth > 8 && srcPixelFormat.getEndianess() == Endianness::Big)
274-
val = swapBytesEndianess<bitDepth>(val);
273+
if (bitDepth > 8 && srcPixelFormat.getEndianness() == Endianness::Big)
274+
val = swapBytesEndianness<bitDepth>(val);
275275
val = (val * scale) >> shiftTo8Bit;
276276
val = functions::clip(val, 0, 255);
277277
if (invert)
@@ -301,7 +301,7 @@ rgba_t getPixelValueForPredefiendFormat(const QByteArray &sourceBuffer,
301301
int byte1 = *rawData;
302302
int byte2 = *(rawData + 1);
303303

304-
if (srcPixelFormat.getEndianess() == Endianness::Big)
304+
if (srcPixelFormat.getEndianness() == Endianness::Big)
305305
std::swap(byte1, byte2);
306306

307307
const auto value = byte1 + (byte2 << 8);
@@ -338,8 +338,8 @@ rgba_t getPixelValue(const QByteArray &sourceBuffer,
338338

339339
auto src = srcPixel + offset;
340340
auto val = (unsigned)src[0];
341-
if (bitDepth > 8 && srcPixelFormat.getEndianess() == Endianness::Big)
342-
val = swapBytesEndianess<bitDepth>(val);
341+
if (bitDepth > 8 && srcPixelFormat.getEndianness() == Endianness::Big)
342+
val = swapBytesEndianness<bitDepth>(val);
343343
value[channel] = val;
344344
}
345345

YUViewLib/src/video/rgb/ConversionRGB.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
namespace video::rgb
4040
{
4141

42-
template <int bitDepth, typename T> T swapBytesEndianess(const T &val)
42+
template <int bitDepth, typename T> T swapBytesEndianness(const T &val)
4343
{
4444
if (bitDepth <= 8)
4545
return val;

YUViewLib/src/video/rgb/PixelFormatRGB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ AlphaMode PixelFormatRGB::getAlphaMode() const
171171
return this->alphaMode;
172172
}
173173

174-
Endianness PixelFormatRGB::getEndianess() const
174+
Endianness PixelFormatRGB::getEndianness() const
175175
{
176176
return this->endianness;
177177
}

YUViewLib/src/video/rgb/PixelFormatRGB.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ struct rgba_t
104104
}
105105
};
106106

107-
template <typename T> inline T convertBitness(T value, unsigned src_bitness, unsigned dst_bitness)
107+
template <typename T>
108+
inline T convertBitness(const T &value, const unsigned src_bitness, const unsigned dst_bitness)
108109
{
109110
if (src_bitness == dst_bitness)
110111
return value;
@@ -114,7 +115,7 @@ template <typename T> inline T convertBitness(T value, unsigned src_bitness, uns
114115
return value << (dst_bitness - src_bitness);
115116
}
116117

117-
inline rgba_t convertBitness(rgba_t value, unsigned src_bitness, unsigned dst_bitness)
118+
inline rgba_t convertBitness(const rgba_t &value, unsigned src_bitness, unsigned dst_bitness)
118119
{
119120
return rgba_t({convertBitness(value.r, src_bitness, dst_bitness),
120121
convertBitness(value.g, src_bitness, dst_bitness),
@@ -187,7 +188,7 @@ class PixelFormatRGB
187188
[[nodiscard]] DataLayout getDataLayout() const;
188189
[[nodiscard]] ChannelOrder getChannelOrder() const;
189190
[[nodiscard]] AlphaMode getAlphaMode() const;
190-
[[nodiscard]] Endianness getEndianess() const;
191+
[[nodiscard]] Endianness getEndianness() const;
191192
[[nodiscard]] std::optional<PredefinedPixelFormat> getPredefinedPixelFormat() const;
192193

193194
[[nodiscard]] int getNrChannels() const;
@@ -204,9 +205,9 @@ class PixelFormatRGB
204205
private:
205206
// If this is set, the format is defined according to a specific standard and does not
206207
// conform to the definition below (using
207-
// dataLayout/bitsPerSample/ChannelOder/alphaMode/Endianess). If this is set, none of the values
208-
// below matter.
209-
std::optional<PredefinedPixelFormat> predefinedPixelFormat;
208+
// dataLayout/bitsPerSample/ChannelOder/alphaMode/Endianness). If this is set, only the endianness
209+
// value matters.
210+
std::optional<PredefinedPixelFormat> predefinedPixelFormat{};
210211

211212
int bitsPerComponent{0};
212213
DataLayout dataLayout{DataLayout::Packed};

YUViewLib/src/video/rgb/PixelFormatRGBGuess.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ std::optional<PixelFormatRGB> checkForPixelFormatIndicatorInName(
152152
dataLayout,
153153
format.getChannelOrder(),
154154
format.getAlphaMode(),
155-
format.getEndianess());
155+
format.getEndianness());
156156
}
157157

158158
return {};
@@ -175,7 +175,7 @@ std::optional<PixelFormatRGB> checkForPixelFormatIndicatorInFileExtension(
175175
dataLayout,
176176
format.getChannelOrder(),
177177
format.getAlphaMode(),
178-
format.getEndianess());
178+
format.getEndianness());
179179
}
180180
}
181181
}

YUViewLib/src/video/rgb/videoHandlerRGBCustomFormatDialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ videoHandlerRGBCustomFormatDialog::videoHandlerRGBCustomFormatDialog(
6565
const auto bitDepth = rgbFormat.getBitsPerComponent();
6666
this->ui.bitDepthSpinBox->setValue(bitDepth);
6767
this->ui.comboBoxEndianness->setEnabled(bitDepth > 8);
68-
this->ui.comboBoxEndianness->setCurrentIndex(rgbFormat.getEndianess() == Endianness::Big ? 0 : 1);
68+
this->ui.comboBoxEndianness->setCurrentIndex(rgbFormat.getEndianness() == Endianness::Big ? 0
69+
: 1);
6970

7071
this->ui.planarCheckBox->setChecked(rgbFormat.getDataLayout() == DataLayout::Planar);
7172
}

YUViewLib/ui/videoHandlerRGB_CustomFormatDialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</widget>
5858
</item>
5959
<item row="2" column="0">
60-
<widget class="QLabel" name="labelEndianess">
60+
<widget class="QLabel" name="labelEndianness">
6161
<property name="text">
6262
<string>Endianness</string>
6363
</property>

0 commit comments

Comments
 (0)