Skip to content

Commit af9cb5d

Browse files
Merge pull request #691 from IENT/pr/dereferenceFrameFormat
Pr/dereference frame format
2 parents 8a69530 + 49e2ab9 commit af9cb5d

9 files changed

Lines changed: 292 additions & 48 deletions

YUViewLib/src/video/yuv/videoHandlerYUV.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,6 +3151,14 @@ void videoHandlerYUV::setFormatFromCorrelation(const QByteArray &rawYUVData, int
31513151
}
31523152
}
31533153

3154+
std::optional<std::string> videoHandlerYUV::getFormatAsString() const
3155+
{
3156+
const auto frameFormat = FrameHandler::getFormatAsString();
3157+
if (!frameFormat)
3158+
return {};
3159+
return *frameFormat + ";YUV;" + this->srcPixelFormat.getName();
3160+
}
3161+
31543162
bool videoHandlerYUV::setFormatFromString(const std::string_view format)
31553163
{
31563164
DEBUG_YUV("videoHandlerYUV::setFormatFromString " << format << "\n");

YUViewLib/src/video/yuv/videoHandlerYUV.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,7 @@ class videoHandlerYUV : public videoHandler
134134
virtual void setFormatFromCorrelation(const QByteArray &rawYUVData,
135135
int64_t fileSize = -1) override;
136136

137-
virtual std::optional<std::string> getFormatAsString() const override
138-
{
139-
const auto frameFormat = FrameHandler::getFormatAsString();
140-
return *frameFormat + ";YUV;" + this->srcPixelFormat.getName();
141-
}
137+
virtual std::optional<std::string> getFormatAsString() const override;
142138
virtual bool setFormatFromString(const std::string_view format) override;
143139

144140
// Create the YUV controls and return a pointer to the layout.

YUViewUnitTest/video/rgb/VideoHandlerRawTestDataLoader.cpp renamed to YUViewUnitTest/video/VideoHandlerRawTestDataLoader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
#include "VideoHandlerRawTestDataLoader.h"
3434

35-
#include <video/rgb/videoHandlerRGB.h>
35+
#include <video/videoHandler.h>
3636

37-
namespace video::rgb::test
37+
namespace video::test
3838
{
3939

4040
videoHandlerDataLoadingTest::videoHandlerDataLoadingTest(video::videoHandler *video) : video(video)
@@ -79,4 +79,4 @@ void videoHandlerDataLoadingTest::loadRawTestData(int frameIdx, bool forceDecodi
7979
video->rawData_frameIndex = frameIdx;
8080
}
8181

82-
} // namespace video::rgb::test
82+
} // namespace video::test

YUViewUnitTest/video/rgb/VideoHandlerRawTestDataLoader.h renamed to YUViewUnitTest/video/VideoHandlerRawTestDataLoader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace video
3838
class videoHandler;
3939
}
4040

41-
namespace video::rgb::test
41+
namespace video::test
4242
{
4343

4444
class videoHandlerDataLoadingTest : public QObject
@@ -64,4 +64,4 @@ public slots:
6464
std::queue<LoadingRequest> expectedLoadingRequests;
6565
};
6666

67-
} // namespace video::rgb::test
67+
} // namespace video::test

YUViewUnitTest/video/rgb/videoHandlerRGBTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@
3333
#include <common/Testing.h>
3434
#include <video/rgb/videoHandlerRGB.h>
3535

36-
#include "VideoHandlerRawTestDataLoader.h"
36+
#include "../VideoHandlerRawTestDataLoader.h"
3737

3838
namespace video::rgb::test
3939
{
4040

4141
using namespace std::string_literals;
42+
using video::test::videoHandlerDataLoadingTest;
4243

4344
namespace
4445
{
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* This file is part of YUView - The YUV player with advanced analytics toolset
2+
* <https://github.com/IENT/YUView>
3+
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* In addition, as a special exception, the copyright holders give
11+
* permission to link the code of portions of this program with the
12+
* OpenSSL library under certain conditions as described in each
13+
* individual source file, and distribute linked combinations including
14+
* the two.
15+
*
16+
* You must obey the GNU General Public License in all respects for all
17+
* of the code used other than OpenSSL. If you modify file(s) with this
18+
* exception, you may extend this exception to your version of the
19+
* file(s), but you are not obligated to do so. If you do not wish to do
20+
* so, delete this exception statement from your version. If you delete
21+
* this exception statement from all source files in the program, then
22+
* also delete it here.
23+
*
24+
* This program is distributed in the hope that it will be useful,
25+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+
* GNU General Public License for more details.
28+
*
29+
* You should have received a copy of the GNU General Public License
30+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
31+
*/
32+
33+
#include "PixelFormatYUVHelper.h"
34+
35+
namespace video::yuv::test
36+
{
37+
38+
std::vector<PixelFormatYUV> getAllPixelFormats()
39+
{
40+
std::vector<PixelFormatYUV> allFormats;
41+
42+
for (const auto subsampling : SubsamplingMapper.getValues())
43+
{
44+
for (const auto bitsPerSample : BitDepthList)
45+
{
46+
const auto endianList =
47+
(bitsPerSample > 8) ? std::vector<bool>({false, true}) : std::vector<bool>({false});
48+
49+
// Planar
50+
for (const auto planeOrder : PlaneOrderMapper.getValues())
51+
for (const auto bigEndian : endianList)
52+
allFormats.push_back(PixelFormatYUV(subsampling, bitsPerSample, planeOrder, bigEndian));
53+
54+
// Packet
55+
for (const auto packingOrder : getSupportedPackingFormats(subsampling))
56+
for (const auto bytePacking : {false, true})
57+
for (const auto bigEndian : endianList)
58+
allFormats.push_back(
59+
PixelFormatYUV(subsampling, bitsPerSample, packingOrder, bytePacking, bigEndian));
60+
}
61+
}
62+
63+
for (auto predefinedFormat : PredefinedPixelFormatMapper.getValues())
64+
allFormats.push_back(PixelFormatYUV(predefinedFormat));
65+
66+
return allFormats;
67+
}
68+
69+
} // namespace video::yuv::test
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* This file is part of YUView - The YUV player with advanced analytics toolset
2+
* <https://github.com/IENT/YUView>
3+
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* In addition, as a special exception, the copyright holders give
11+
* permission to link the code of portions of this program with the
12+
* OpenSSL library under certain conditions as described in each
13+
* individual source file, and distribute linked combinations including
14+
* the two.
15+
*
16+
* You must obey the GNU General Public License in all respects for all
17+
* of the code used other than OpenSSL. If you modify file(s) with this
18+
* exception, you may extend this exception to your version of the
19+
* file(s), but you are not obligated to do so. If you do not wish to do
20+
* so, delete this exception statement from your version. If you delete
21+
* this exception statement from all source files in the program, then
22+
* also delete it here.
23+
*
24+
* This program is distributed in the hope that it will be useful,
25+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+
* GNU General Public License for more details.
28+
*
29+
* You should have received a copy of the GNU General Public License
30+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
31+
*/
32+
33+
#include <video/yuv/PixelFormatYUV.h>
34+
35+
#include <vector>
36+
37+
namespace video::yuv::test
38+
{
39+
40+
std::vector<PixelFormatYUV> getAllPixelFormats();
41+
42+
}

YUViewUnitTest/video/yuv/PixelFormatYUVTest.cpp

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,48 +34,14 @@
3434

3535
#include <video/yuv/PixelFormatYUV.h>
3636

37-
namespace video::yuv::test
38-
{
39-
40-
namespace
41-
{
37+
#include "PixelFormatYUVHelper.h"
4238

43-
std::vector<PixelFormatYUV> getAllFormats()
39+
namespace video::yuv::test
4440
{
45-
std::vector<PixelFormatYUV> allFormats;
46-
47-
for (const auto subsampling : SubsamplingMapper.getValues())
48-
{
49-
for (const auto bitsPerSample : BitDepthList)
50-
{
51-
const auto endianList =
52-
(bitsPerSample > 8) ? std::vector<bool>({false, true}) : std::vector<bool>({false});
53-
54-
// Planar
55-
for (const auto planeOrder : PlaneOrderMapper.getValues())
56-
for (const auto bigEndian : endianList)
57-
allFormats.push_back(PixelFormatYUV(subsampling, bitsPerSample, planeOrder, bigEndian));
58-
59-
// Packet
60-
for (const auto packingOrder : getSupportedPackingFormats(subsampling))
61-
for (const auto bytePacking : {false, true})
62-
for (const auto bigEndian : endianList)
63-
allFormats.push_back(
64-
PixelFormatYUV(subsampling, bitsPerSample, packingOrder, bytePacking, bigEndian));
65-
}
66-
}
67-
68-
for (auto predefinedFormat : PredefinedPixelFormatMapper.getValues())
69-
allFormats.push_back(PixelFormatYUV(predefinedFormat));
70-
71-
return allFormats;
72-
}
73-
74-
} // namespace
7541

7642
TEST(PixelFormatYUVTest, testFormatFromToString)
7743
{
78-
for (const auto fmt : getAllFormats())
44+
for (const auto fmt : getAllPixelFormats())
7945
{
8046
const auto name = fmt.getName();
8147
EXPECT_TRUE(fmt.isValid()) << "Format " << name << " is invalid.";

0 commit comments

Comments
 (0)