Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions YUViewLib/src/video/yuv/videoHandlerYUV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3151,6 +3151,14 @@ void videoHandlerYUV::setFormatFromCorrelation(const QByteArray &rawYUVData, int
}
}

std::optional<std::string> videoHandlerYUV::getFormatAsString() const
{
const auto frameFormat = FrameHandler::getFormatAsString();
if (!frameFormat)
return {};
return *frameFormat + ";YUV;" + this->srcPixelFormat.getName();
}

bool videoHandlerYUV::setFormatFromString(const std::string_view format)
{
DEBUG_YUV("videoHandlerYUV::setFormatFromString " << format << "\n");
Expand Down
6 changes: 1 addition & 5 deletions YUViewLib/src/video/yuv/videoHandlerYUV.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,7 @@ class videoHandlerYUV : public videoHandler
virtual void setFormatFromCorrelation(const QByteArray &rawYUVData,
int64_t fileSize = -1) override;

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

// Create the YUV controls and return a pointer to the layout.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@

#include "VideoHandlerRawTestDataLoader.h"

#include <video/rgb/videoHandlerRGB.h>
#include <video/videoHandler.h>

namespace video::rgb::test
namespace video::test
{

videoHandlerDataLoadingTest::videoHandlerDataLoadingTest(video::videoHandler *video) : video(video)
Expand Down Expand Up @@ -79,4 +79,4 @@ void videoHandlerDataLoadingTest::loadRawTestData(int frameIdx, bool forceDecodi
video->rawData_frameIndex = frameIdx;
}

} // namespace video::rgb::test
} // namespace video::test
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace video
class videoHandler;
}

namespace video::rgb::test
namespace video::test
{

class videoHandlerDataLoadingTest : public QObject
Expand All @@ -64,4 +64,4 @@ public slots:
std::queue<LoadingRequest> expectedLoadingRequests;
};

} // namespace video::rgb::test
} // namespace video::test
3 changes: 2 additions & 1 deletion YUViewUnitTest/video/rgb/videoHandlerRGBTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
#include <common/Testing.h>
#include <video/rgb/videoHandlerRGB.h>

#include "VideoHandlerRawTestDataLoader.h"
#include "../VideoHandlerRawTestDataLoader.h"

namespace video::rgb::test
{

using namespace std::string_literals;
using video::test::videoHandlerDataLoadingTest;

namespace
{
Expand Down
69 changes: 69 additions & 0 deletions YUViewUnitTest/video/yuv/PixelFormatYUVHelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* This file is part of YUView - The YUV player with advanced analytics toolset
* <https://github.com/IENT/YUView>
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
*
* 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 3 of the License, or
* (at your option) any later version.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*
* You must obey the GNU General Public License in all respects for all
* of the code used other than OpenSSL. If you modify file(s) with this
* exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do
* so, delete this exception statement from your version. If you delete
* this exception statement from all source files in the program, then
* also delete it here.
*
* 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 "PixelFormatYUVHelper.h"

namespace video::yuv::test
{

std::vector<PixelFormatYUV> getAllPixelFormats()
{
std::vector<PixelFormatYUV> allFormats;

for (const auto subsampling : SubsamplingMapper.getValues())
{
for (const auto bitsPerSample : BitDepthList)
{
const auto endianList =
(bitsPerSample > 8) ? std::vector<bool>({false, true}) : std::vector<bool>({false});

// Planar
for (const auto planeOrder : PlaneOrderMapper.getValues())
for (const auto bigEndian : endianList)
allFormats.push_back(PixelFormatYUV(subsampling, bitsPerSample, planeOrder, bigEndian));

// Packet
for (const auto packingOrder : getSupportedPackingFormats(subsampling))
for (const auto bytePacking : {false, true})
for (const auto bigEndian : endianList)
allFormats.push_back(
PixelFormatYUV(subsampling, bitsPerSample, packingOrder, bytePacking, bigEndian));
}
}

for (auto predefinedFormat : PredefinedPixelFormatMapper.getValues())
allFormats.push_back(PixelFormatYUV(predefinedFormat));

return allFormats;
}

} // namespace video::yuv::test
42 changes: 42 additions & 0 deletions YUViewUnitTest/video/yuv/PixelFormatYUVHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* This file is part of YUView - The YUV player with advanced analytics toolset
* <https://github.com/IENT/YUView>
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
*
* 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 3 of the License, or
* (at your option) any later version.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*
* You must obey the GNU General Public License in all respects for all
* of the code used other than OpenSSL. If you modify file(s) with this
* exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do
* so, delete this exception statement from your version. If you delete
* this exception statement from all source files in the program, then
* also delete it here.
*
* 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 <video/yuv/PixelFormatYUV.h>

#include <vector>

namespace video::yuv::test
{

std::vector<PixelFormatYUV> getAllPixelFormats();

}
40 changes: 3 additions & 37 deletions YUViewUnitTest/video/yuv/PixelFormatYUVTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,48 +34,14 @@

#include <video/yuv/PixelFormatYUV.h>

namespace video::yuv::test
{

namespace
{
#include "PixelFormatYUVHelper.h"

std::vector<PixelFormatYUV> getAllFormats()
namespace video::yuv::test
{
std::vector<PixelFormatYUV> allFormats;

for (const auto subsampling : SubsamplingMapper.getValues())
{
for (const auto bitsPerSample : BitDepthList)
{
const auto endianList =
(bitsPerSample > 8) ? std::vector<bool>({false, true}) : std::vector<bool>({false});

// Planar
for (const auto planeOrder : PlaneOrderMapper.getValues())
for (const auto bigEndian : endianList)
allFormats.push_back(PixelFormatYUV(subsampling, bitsPerSample, planeOrder, bigEndian));

// Packet
for (const auto packingOrder : getSupportedPackingFormats(subsampling))
for (const auto bytePacking : {false, true})
for (const auto bigEndian : endianList)
allFormats.push_back(
PixelFormatYUV(subsampling, bitsPerSample, packingOrder, bytePacking, bigEndian));
}
}

for (auto predefinedFormat : PredefinedPixelFormatMapper.getValues())
allFormats.push_back(PixelFormatYUV(predefinedFormat));

return allFormats;
}

} // namespace

TEST(PixelFormatYUVTest, testFormatFromToString)
{
for (const auto fmt : getAllFormats())
for (const auto fmt : getAllPixelFormats())
{
const auto name = fmt.getName();
EXPECT_TRUE(fmt.isValid()) << "Format " << name << " is invalid.";
Expand Down
Loading
Loading