Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old unused SSE code #605

Merged
merged 1 commit into from
Dec 6, 2024
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
84 changes: 0 additions & 84 deletions YUViewLib/src/common/Typedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,90 +84,6 @@ const bool is_Q_OS_LINUX = false;
// However, it is not yet clear what to do if the user wants/needs a second instance.
#define WIN_LINUX_SINGLE_INSTANCE 0

// Activate SSE YUV conversion
// Do not activate. This is not supported right now.
#define SSE_CONVERSION 0
#if SSE_CONVERSION

#define HAVE_SSE4_1 1
#define SSE_CONVERSION_420_ALT 1 // Alternate method for SSE Conversion, Testing only

#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif

#ifdef HAVE_SSE4_1
#define MEMORY_PADDING 8
#else
#define MEMORY_PADDING 0
#endif

#define STANDARD_ALIGNMENT 16

#ifdef HAVE___MINGW_ALIGNED_MALLOC
#define ALLOC_ALIGNED(alignment, size) __mingw_aligned_malloc((size), (alignment))
#define FREE_ALIGNED(mem) __mingw_aligned_free((mem))
#elif _WIN32
#define ALLOC_ALIGNED(alignment, size) _aligned_malloc((size), (alignment))
#define FREE_ALIGNED(mem) _aligned_free((mem))
#elif defined(HAVE_POSIX_MEMALIGN)
static inline void *ALLOC_ALIGNED(size_t alignment, size_t size)
{
void *mem = NULL;
if (posix_memalign(&mem, alignment, size) != 0)
{
return NULL;
}
return mem;
};
#define FREE_ALIGNED(mem) free((mem))
#else
#define ALLOC_ALIGNED(alignment, size) memalign((alignment), (size))
#define FREE_ALIGNED(mem) free((mem))
#endif

#define ALLOC_ALIGNED_16(size) ALLOC_ALIGNED(16, size)

// A small class comparable to QByteArray but aligned to 16 byte addresses
class byteArrayAligned
{
public:
byteArrayAligned() : _data(NULL), _size(-1) {}
~byteArrayAligned()
{
if (_size != -1)
{
assert(_data != NULL);
FREE_ALIGNED(_data);
}
}
int size() { return _size; }
int capacity() { return _size; }
char *data() { return _data; }
bool isEmpty() { return _size <= 0 ? true : false; }
void resize(int size)
{
if (_size != -1)
{
// The array has been allocated before. Free it.
assert(_data != NULL);
FREE_ALIGNED(_data);
_data = NULL;
_size = -1;
}
// Allocate a new array of sufficient size
assert(_size == -1);
assert(_data == NULL);
_data = (char *)ALLOC_ALIGNED_16(size + MEMORY_PADDING);
_size = size;
}

private:
char *_data;
int _size;
};
#endif // SSE_CONVERSION

// The default frame rate that will be used when we could not guess it.
#define DEFAULT_FRAMERATE 24.0

Expand Down
10 changes: 3 additions & 7 deletions YUViewLib/src/decoder/decoderDav1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ bool decoderDav1d::pushData(QByteArray &data)
// Since dav1d consumes the data (takes ownership), we need to copy it to a new buffer from
// dav1d
Dav1dData *dav1dData = new Dav1dData;
uint8_t * rawDataPointer = this->lib.dav1d_data_create(dav1dData, data.size());
uint8_t *rawDataPointer = this->lib.dav1d_data_create(dav1dData, data.size());
memcpy(rawDataPointer, data.data(), data.size());

int err = this->lib.dav1d_send_data(decoder, dav1dData);
Expand All @@ -476,11 +476,7 @@ bool decoderDav1d::pushData(QByteArray &data)
return true;
}

#if SSE_CONVERSION
void decoderDav1d::copyImgToByteArray(const Dav1dPictureWrapper &src, byteArrayAligned &dst)
#else
void decoderDav1d::copyImgToByteArray(const Dav1dPictureWrapper &src, QByteArray &dst)
#endif
{
// How many image planes are there?
int nrPlanes = (src.getSubsampling() == Subsampling::YUV_400) ? 1 : 3;
Expand Down Expand Up @@ -789,7 +785,7 @@ void decoderDav1d::cacheStatistics(const Dav1dPictureWrapper &img)

DEBUG_DAV1D("decoderDav1d::cacheStatistics");

Av1Block * blockData = img.getBlockData();
Av1Block *blockData = img.getBlockData();
Dav1dFrameHeader *frameHeader = img.getFrameHeader();
if (frameHeader == nullptr)
return;
Expand Down Expand Up @@ -904,7 +900,7 @@ void decoderDav1d::parseBlockRecursive(
}
}

void decoderDav1d::parseBlockPartition(Av1Block * blockData,
void decoderDav1d::parseBlockPartition(Av1Block *blockData,
unsigned x,
unsigned y,
unsigned blockWidth4,
Expand Down
21 changes: 8 additions & 13 deletions YUViewLib/src/decoder/decoderDav1d.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ class Dav1dPictureWrapper

void clear() { memset(&curPicture, 0, sizeof(Dav1dPicture)); }
Size getFrameSize() const;
Dav1dPicture * getPicture() const { return (Dav1dPicture *)(&curPicture); }
Dav1dPicture *getPicture() const { return (Dav1dPicture *)(&curPicture); }
video::yuv::Subsampling getSubsampling() const;
int getBitDepth() const { return curPicture.p.bpc; }
uint8_t * getData(int component) const { return (uint8_t *)curPicture.data[component]; }
uint8_t *getData(int component) const { return (uint8_t *)curPicture.data[component]; }
ptrdiff_t getStride(int component) const { return curPicture.stride[component]; }
uint8_t * getDataPrediction(int component) const
uint8_t *getDataPrediction(int component) const
{
return internalsSupported ? (uint8_t *)curPicture.pred[component] : nullptr;
}
Expand All @@ -89,7 +89,7 @@ class Dav1dPictureWrapper
}

Dav1dSequenceHeader *getSequenceHeader() const { return curPicture.seq_hdr; }
Dav1dFrameHeader * getFrameHeader() const { return curPicture.frame_hdr; }
Dav1dFrameHeader *getFrameHeader() const { return curPicture.frame_hdr; }

private:
Dav1dPicture curPicture;
Expand Down Expand Up @@ -135,7 +135,7 @@ class decoderDav1d : public decoderBaseSingleLib
private:
// A private constructor that creates an uninitialized decoder library.
// Used by checkLibraryFile to check if a file can be used as a hevcDecoderLibde265.
decoderDav1d() : decoderBaseSingleLib(){};
decoderDav1d() : decoderBaseSingleLib() {};

// Try to resolve all the required function pointers from the library
void resolveLibraryFunctionPointers() override;
Expand All @@ -150,7 +150,7 @@ class decoderDav1d : public decoderBaseSingleLib

void allocateNewDecoder();

Dav1dContext * decoder{};
Dav1dContext *decoder{};
Dav1dSettings settings;
Dav1dAnalyzerFlags analyzerSettings;

Expand All @@ -170,22 +170,17 @@ class decoderDav1d : public decoderBaseSingleLib

// We buffer the current image as a QByteArray so you can call getYUVFrameData as often as
// necessary without invoking the copy operation from the libde265 buffer to the QByteArray again.
#if SSE_CONVERSION
byteArrayAligned currentOutputBuffer;
void copyImgToByteArray(const Dav1dPictureWrapper &src, byteArrayAligned &dst);
#else
QByteArray currentOutputBuffer;
void copyImgToByteArray(
const Dav1dPictureWrapper &src,
QByteArray & dst); // Copy the raw data from the Dav1dPicture source *src to the byte array
#endif
QByteArray &dst); // Copy the raw data from the Dav1dPicture source *src to the byte array

// Statistics
void fillStatisticList(stats::StatisticsData &) const override;
void cacheStatistics(const Dav1dPictureWrapper &img);
void parseBlockRecursive(
Av1Block *blockData, unsigned x, unsigned y, BlockLevel level, dav1dFrameInfo &frameInfo);
void parseBlockPartition(Av1Block * blockData,
void parseBlockPartition(Av1Block *blockData,
unsigned x,
unsigned y,
unsigned blockWidth4,
Expand Down
4 changes: 0 additions & 4 deletions YUViewLib/src/decoder/decoderHM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,7 @@ QByteArray decoderHM::getRawFrameData()
return currentOutputBuffer;
}

#if SSE_CONVERSION
void decoderHM::copyImgToByteArray(libHMDec_picture *src, byteArrayAligned &dst)
#else
void decoderHM::copyImgToByteArray(libHMDec_picture *src, QByteArray &dst)
#endif
{
// How many image planes are there?
auto fmt = this->lib.libHMDEC_get_chroma_format(src);
Expand Down
5 changes: 0 additions & 5 deletions YUViewLib/src/decoder/decoderHM.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,10 @@ class decoderHM : public decoderBaseSingleLib

// We buffer the current image as a QByteArray so you can call getYUVFrameData as often as
// necessary without invoking the copy operation from the hm image buffer to the QByteArray again.
#if SSE_CONVERSION
byteArrayAligned currentOutputBuffer;
void copyImgToByteArray(libHMDec_picture *src, byteArrayAligned &dst);
#else
QByteArray currentOutputBuffer;
void copyImgToByteArray(
libHMDec_picture *src,
QByteArray &dst); // Copy the raw data from the de265_image source *src to the byte array
#endif

LibraryFunctionsHM lib;
};
Expand Down
10 changes: 3 additions & 7 deletions YUViewLib/src/decoder/decoderLibde265.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,7 @@ bool decoderLibde265::pushData(QByteArray &data)
return true;
}

#if SSE_CONVERSION
void decoderLibde265::copyImgToByteArray(const de265_image *src, byteArrayAligned &dst)
#else
void decoderLibde265::copyImgToByteArray(const de265_image *src, QByteArray &dst)
#endif
{
// How many image planes are there?
auto cMode = this->lib.de265_get_chroma_format(src);
Expand Down Expand Up @@ -967,9 +963,9 @@ void decoderLibde265::fillStatisticList(stats::StatisticsData &statisticsData) c

stats::StatisticsType intraDirC(
10, "Intra Dir Chroma", ColorMapper({0, 34}, PredefinedType::Jet));
intraDirC.description = "The intra mode for the chroma component per TU (intra prediction is "
"performed on a TU level)";
intraDirC.hasVectorData = true;
intraDirC.description = "The intra mode for the chroma component per TU (intra prediction is "
"performed on a TU level)";
intraDirC.hasVectorData = true;
intraDirC.renderVectorData = true;
intraDirC.renderVectorDataValues = false;
intraDirC.vectorScale = 32;
Expand Down
11 changes: 3 additions & 8 deletions YUViewLib/src/decoder/decoderLibde265.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct LibraryFunctionsDe265
const uint8_t *(*de265_internals_get_image_plane)(const struct de265_image *img,
de265_internals_param signal,
int channel,
int * out_stride){};
int *out_stride){};
void (*de265_internals_set_parameter_bool)(de265_decoder_context *,
enum de265_internals_param param,
int value){};
Expand Down Expand Up @@ -124,7 +124,7 @@ class decoderLibde265 : public decoderBaseSingleLib
private:
// A private constructor that creates an uninitialized decoder library.
// Used by checkLibraryFile to check if a file can be used as a hevcDecoderLibde265.
decoderLibde265() : decoderBaseSingleLib(){};
decoderLibde265() : decoderBaseSingleLib() {};

// Try to resolve all the required function pointers from the library
void resolveLibraryFunctionPointers() override;
Expand Down Expand Up @@ -175,15 +175,10 @@ class decoderLibde265 : public decoderBaseSingleLib

// We buffer the current image as a QByteArray so you can call getYUVFrameData as often as
// necessary without invoking the copy operation from the libde265 buffer to the QByteArray again.
#if SSE_CONVERSION
byteArrayAligned currentOutputBuffer;
void copyImgToByteArray(const de265_image *src, byteArrayAligned &dst);
#else
QByteArray currentOutputBuffer;
void copyImgToByteArray(
const de265_image *src,
QByteArray & dst); // Copy the raw data from the de265_image source *src to the byte array
#endif
QByteArray &dst); // Copy the raw data from the de265_image source *src to the byte array

LibraryFunctionsDe265 lib;
};
Expand Down
4 changes: 0 additions & 4 deletions YUViewLib/src/decoder/decoderVTM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,7 @@ QByteArray decoderVTM::getRawFrameData()
return currentOutputBuffer;
}

#if SSE_CONVERSION
void decoderVTM::copyImgToByteArray(libVTMDec_picture *src, byteArrayAligned &dst)
#else
void decoderVTM::copyImgToByteArray(libVTMDec_picture *src, QByteArray &dst)
#endif
{
// How many image planes are there?
auto fmt = this->lib.libVTMDec_get_chroma_format(src);
Expand Down
15 changes: 5 additions & 10 deletions YUViewLib/src/decoder/decoderVTM.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ struct LibraryFunctionsVTM
void (*libVTMDec_set_SEI_Check)(libVTMDec_context *, bool check_hash){};
void (*libVTMDec_set_max_temporal_layer)(libVTMDec_context *, int max_layer){};
libVTMDec_error (*libVTMDec_push_nal_unit)(libVTMDec_context *decCtx,
const void * data8,
const void *data8,
int length,
bool eof,
bool & bNewPicture,
bool & checkOutputPictures){};
bool &bNewPicture,
bool &checkOutputPictures){};

// Get a picture and retrive information on the picture
libVTMDec_picture *(*libVTMDec_get_picture)(libVTMDec_context *){};
Expand Down Expand Up @@ -93,7 +93,7 @@ class decoderVTM : public decoderBaseSingleLib
private:
// A private constructor that creates an uninitialized decoder library.
// Used by checkLibraryFile to check if a file can be used as this type of decoder.
decoderVTM(){};
decoderVTM() {};

// Return the possible names of the HM library
QStringList getLibraryNames() const override;
Expand Down Expand Up @@ -130,15 +130,10 @@ class decoderVTM : public decoderBaseSingleLib

// We buffer the current image as a QByteArray so you can call getYUVFrameData as often as
// necessary without invoking the copy operation from the hm image buffer to the QByteArray again.
#if SSE_CONVERSION
byteArrayAligned currentOutputBuffer;
void copyImgToByteArray(libVTMDec_picture *src, byteArrayAligned &dst);
#else
QByteArray currentOutputBuffer;
void copyImgToByteArray(
libVTMDec_picture *src,
QByteArray & dst); // Copy the raw data from the de265_image source *src to the byte array
#endif
QByteArray &dst); // Copy the raw data from the de265_image source *src to the byte array

LibraryFunctionsVTM lib;
};
Expand Down
15 changes: 0 additions & 15 deletions YUViewLib/src/filesource/FileSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,6 @@ bool FileSource::openFile(const std::filesystem::path &filePath)
return true;
}

#if SSE_CONVERSION
// Resize the target array if necessary and read the given number of bytes to the data array
void FileSource::readBytes(byteArrayAligned &targetBuffer, int64_t startPos, int64_t nrBytes)
{
if (!isOk())
return;

if (targetBuffer.size() < nrBytes)
targetBuffer.resize(nrBytes);

srcFile.seek(startPos);
srcFile.read(targetBuffer.data(), nrBytes);
}
#endif

// Resize the target array if necessary and read the given number of bytes to the data array
int64_t FileSource::readBytes(QByteArray &targetBuffer, int64_t startPos, int64_t nrBytes)
{
Expand Down
3 changes: 0 additions & 3 deletions YUViewLib/src/filesource/FileSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ class FileSource : public QObject
// Read the given number of bytes starting at startPos into the QByteArray out
// Resize the QByteArray if necessary. Return how many bytes were read.
int64_t readBytes(QByteArray &targetBuffer, int64_t startPos, int64_t nrBytes);
#if SSE_CONVERSION
void readBytes(byteArrayAligned &data, int64_t startPos, int64_t nrBytes);
#endif

void updateFileWatchSetting();
void clearFileCache();
Expand Down
Loading
Loading