Skip to content

Commit

Permalink
Slowly fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFeldmann committed Oct 5, 2023
1 parent d146bb2 commit 70580b2
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 300 deletions.
15 changes: 14 additions & 1 deletion YUViewLib/externalLibs/LibFFmpeg++/common/FFMpegLibrariesTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,20 @@
namespace LibFFmpeg
{

using Log = std::vector<std::string>;
struct Size
{
int width{};
int height{};
};

struct Ratio
{
int num{};
int den{};
};

using ByteVector = std::vector<std::byte>;
using Log = std::vector<std::string>;

// Some structs/enums which actual definition does not interest us.
struct AVFormatContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
*/

#include "AVCodecContextWrapper.h"
#include <stdexcept>

#include "Functions.h"

namespace LibFFmpeg
{
Expand Down Expand Up @@ -468,7 +469,7 @@ AVRational AVCodecContextWrapper::getTimeBase()
return this->time_base;
}

QByteArray AVCodecContextWrapper::getExtradata()
ByteVector AVCodecContextWrapper::getExtradata()
{
this->update();
return this->extradata;
Expand All @@ -483,7 +484,7 @@ void AVCodecContextWrapper::update()
{
auto p = reinterpret_cast<AVCodecContext_56 *>(this->codec);
this->codec_type = p->codec_type;
this->codec_name = QString(p->codec_name);
this->codec_name = std::string(p->codec_name);
this->codec_id = p->codec_id;
this->codec_tag = p->codec_tag;
this->stream_codec_tag = p->stream_codec_tag;
Expand All @@ -493,7 +494,7 @@ void AVCodecContextWrapper::update()
this->compression_level = p->compression_level;
this->flags = p->flags;
this->flags2 = p->flags2;
this->extradata = QByteArray((const char *)p->extradata, p->extradata_size);
this->extradata = copyDataFromRawArray(p->extradata, p->extradata_size);
this->time_base = p->time_base;
this->ticks_per_frame = p->ticks_per_frame;
this->delay = p->delay;
Expand Down Expand Up @@ -567,7 +568,7 @@ void AVCodecContextWrapper::update()
{
auto p = reinterpret_cast<AVCodecContext_57 *>(this->codec);
this->codec_type = p->codec_type;
this->codec_name = QString(p->codec_name);
this->codec_name = std::string(p->codec_name);
this->codec_id = p->codec_id;
this->codec_tag = p->codec_tag;
this->stream_codec_tag = p->stream_codec_tag;
Expand All @@ -577,7 +578,7 @@ void AVCodecContextWrapper::update()
this->compression_level = p->compression_level;
this->flags = p->flags;
this->flags2 = p->flags2;
this->extradata = QByteArray((const char *)p->extradata, p->extradata_size);
this->extradata = copyDataFromRawArray(p->extradata, p->extradata_size);
this->time_base = p->time_base;
this->ticks_per_frame = p->ticks_per_frame;
this->delay = p->delay;
Expand Down Expand Up @@ -651,7 +652,7 @@ void AVCodecContextWrapper::update()
{
auto p = reinterpret_cast<AVCodecContext_58 *>(this->codec);
this->codec_type = p->codec_type;
this->codec_name = QString("Not supported in AVCodec >= 58");
this->codec_name = std::string("Not supported in AVCodec >= 58");
this->codec_id = p->codec_id;
this->codec_tag = p->codec_tag;
this->stream_codec_tag = -1;
Expand All @@ -661,7 +662,7 @@ void AVCodecContextWrapper::update()
this->compression_level = p->compression_level;
this->flags = p->flags;
this->flags2 = p->flags2;
this->extradata = QByteArray((const char *)p->extradata, p->extradata_size);
this->extradata = copyDataFromRawArray(p->extradata, p->extradata_size);
this->time_base = p->time_base;
this->ticks_per_frame = p->ticks_per_frame;
this->delay = p->delay;
Expand Down Expand Up @@ -736,7 +737,7 @@ void AVCodecContextWrapper::update()
{
auto p = reinterpret_cast<AVCodecContext_59_60 *>(this->codec);
this->codec_type = p->codec_type;
this->codec_name = QString("Not supported in AVCodec >= 58");
this->codec_name = std::string("Not supported in AVCodec >= 58");
this->codec_id = p->codec_id;
this->codec_tag = p->codec_tag;
this->stream_codec_tag = -1;
Expand All @@ -746,7 +747,7 @@ void AVCodecContextWrapper::update()
this->compression_level = p->compression_level;
this->flags = p->flags;
this->flags2 = p->flags2;
this->extradata = QByteArray((const char *)p->extradata, p->extradata_size);
this->extradata = copyDataFromRawArray(p->extradata, p->extradata_size);
this->time_base = p->time_base;
this->ticks_per_frame = p->ticks_per_frame;
this->delay = p->delay;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class AVCodecContextWrapper
Size getSize();
AVColorSpace getColorspace();
AVRational getTimeBase();
QByteArray getExtradata();
ByteVector getExtradata();

private:
void update();

// These are private. Use "update" to update them from the AVCodecContext
AVMediaType codec_type{};
QString codec_name{};
std::string codec_name{};
AVCodecID codec_id{};
unsigned int codec_tag{};
unsigned int stream_codec_tag{};
Expand All @@ -69,7 +69,7 @@ class AVCodecContextWrapper
int compression_level{};
int flags{};
int flags2{};
QByteArray extradata{};
ByteVector extradata{};
AVRational time_base{};
int ticks_per_frame{};
int delay{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include "AVCodecParametersWrapper.h"

#include <common/Functions.h>
#include "Functions.h"
namespace LibFFmpeg
{

Expand Down Expand Up @@ -89,7 +89,7 @@ AVCodecID AVCodecParametersWrapper::getCodecID()
return this->codec_id;
}

QByteArray AVCodecParametersWrapper::getExtradata()
ByteVector AVCodecParametersWrapper::getExtradata()
{
this->update();
return this->extradata;
Expand All @@ -98,7 +98,7 @@ QByteArray AVCodecParametersWrapper::getExtradata()
Size AVCodecParametersWrapper::getSize()
{
this->update();
return Size(this->width, this->height);
return Size({this->width, this->height});
}

AVColorSpace AVCodecParametersWrapper::getColorspace()
Expand All @@ -119,115 +119,6 @@ Ratio AVCodecParametersWrapper::getSampleAspectRatio()
return {this->sample_aspect_ratio.num, this->sample_aspect_ratio.den};
}

QStringPairList AVCodecParametersWrapper::getInfoText()
{
QStringPairList info;

if (this->param == nullptr)
{
info.append(QStringPair("Codec parameters are nullptr", ""));
return info;
}
this->update();

info.append({"Codec Tag", QString::number(this->codec_tag)});
info.append({"Format", QString::number(this->format)});
info.append({"Bitrate", QString::number(this->bit_rate)});
info.append({"Bits per coded sample", QString::number(this->bits_per_coded_sample)});
info.append({"Bits per Raw sample", QString::number(this->bits_per_raw_sample)});
info.append({"Profile", QString::number(this->profile)});
info.append({"Level", QString::number(this->level)});
info.append({"Width/Height", QString("%1/%2").arg(this->width).arg(this->height)});
info.append(
{"Sample aspect ratio",
QString("%1:%2").arg(this->sample_aspect_ratio.num).arg(this->sample_aspect_ratio.den)});
auto fieldOrders = QStringList() << "Unknown"
<< "Progressive"
<< "Top coded_first, top displayed first"
<< "Bottom coded first, bottom displayed first"
<< "Top coded first, bottom displayed first"
<< "Bottom coded first, top displayed first";
info.append(
{"Field Order",
fieldOrders.at(functions::clip(int(this->codec_type), 0, int(fieldOrders.count())))});
auto colorRanges = QStringList() << "Unspecified"
<< "The normal 219*2^(n-8) MPEG YUV ranges"
<< "The normal 2^n-1 JPEG YUV ranges"
<< "Not part of ABI";
info.append(
{"Color Range",
colorRanges.at(functions::clip(int(this->color_range), 0, int(colorRanges.count())))});
auto colorPrimaries =
QStringList()
<< "Reserved"
<< "BT709 / ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B"
<< "Unspecified"
<< "Reserved"
<< "BT470M / FCC Title 47 Code of Federal Regulations 73.682 (a)(20)"
<< "BT470BG / ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM"
<< "SMPTE170M / also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC"
<< "SMPTE240M"
<< "FILM - colour filters using Illuminant C"
<< "ITU-R BT2020"
<< "SMPTE ST 428-1 (CIE 1931 XYZ)"
<< "SMPTE ST 431-2 (2011)"
<< "SMPTE ST 432-1 D65 (2010)"
<< "Not part of ABI";
info.append(QStringPair("Color Primaries", colorPrimaries.at((int)this->color_primaries)));
auto colorTransfers =
QStringList()
<< "Reserved"
<< "BT709 / ITU-R BT1361"
<< "Unspecified"
<< "Reserved"
<< "Gamma22 / ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM"
<< "Gamma28 / ITU-R BT470BG"
<< "SMPTE170M / ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC"
<< "SMPTE240M"
<< "Linear transfer characteristics"
<< "Logarithmic transfer characteristic (100:1 range)"
<< "Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
<< "IEC 61966-2-4"
<< "ITU-R BT1361 Extended Colour Gamut"
<< "IEC 61966-2-1 (sRGB or sYCC)"
<< "ITU-R BT2020 for 10-bit system"
<< "ITU-R BT2020 for 12-bit system"
<< "SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems"
<< "SMPTE ST 428-1"
<< "ARIB STD-B67, known as Hybrid log-gamma"
<< "Not part of ABI";
info.append({"Color Transfer", colorTransfers.at((int)this->color_trc)});
auto colorSpaces = QStringList()
<< "RGB - order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)"
<< "BT709 / ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B"
<< "Unspecified"
<< "Reserved"
<< "FCC Title 47 Code of Federal Regulations 73.682 (a)(20)"
<< "BT470BG / ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & "
"SECAM / IEC 61966-2-4 xvYCC601"
<< "SMPTE170M / ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC"
<< "SMPTE240M"
<< "YCOCG - Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16"
<< "ITU-R BT2020 non-constant luminance system"
<< "ITU-R BT2020 constant luminance system"
<< "SMPTE 2085, Y'D'zD'x"
<< "Not part of ABI";
info.append({"Color Space", colorSpaces.at((int)this->color_space)});
auto chromaLocations = QStringList()
<< "Unspecified"
<< "Left / MPEG-2/4 4:2:0, H.264 default for 4:2:0"
<< "Center / MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0"
<< "Top Left / ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2"
<< "Top"
<< "Bottom Left"
<< "Bottom"
<< "Not part of ABI";
info.append({"Chroma Location", chromaLocations.at((int)this->chroma_location)});
info.append({"Video Delay", QString::number(this->video_delay)});

return info;
}

void AVCodecParametersWrapper::setClearValues()
{
if (this->libraryVersions.avformat.major == 57 || //
Expand Down Expand Up @@ -292,7 +183,7 @@ void AVCodecParametersWrapper::setAVCodecID(AVCodecID id)
}
}

void AVCodecParametersWrapper::setExtradata(QByteArray data)
void AVCodecParametersWrapper::setExtradata(const ByteVector &data)
{
if (this->libraryVersions.avformat.major == 57 || //
this->libraryVersions.avformat.major == 58 || //
Expand All @@ -302,7 +193,7 @@ void AVCodecParametersWrapper::setExtradata(QByteArray data)
this->extradata = data;
auto p = reinterpret_cast<AVCodecParameters_57_58_59_60 *>(this->param);
p->extradata = reinterpret_cast<uint8_t *>(this->extradata.data());
p->extradata_size = this->extradata.length();
p->extradata_size = static_cast<int>(this->extradata.size());
}
}

Expand Down Expand Up @@ -385,7 +276,7 @@ void AVCodecParametersWrapper::update()
this->codec_type = p->codec_type;
this->codec_id = p->codec_id;
this->codec_tag = p->codec_tag;
this->extradata = QByteArray((const char *)p->extradata, p->extradata_size);
this->extradata = copyDataFromRawArray(p->extradata, p->extradata_size);
this->format = p->format;
this->bit_rate = p->bit_rate;
this->bits_per_coded_sample = p->bits_per_coded_sample;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ class AVCodecParametersWrapper
public:
AVCodecParametersWrapper() = default;
AVCodecParametersWrapper(AVCodecParameters *p, const LibraryVersions &libraryVersions);
explicit operator bool() const { return this->param != nullptr; }
QStringPairList getInfoText();
explicit operator bool() const { return this->param != nullptr; }

AVMediaType getCodecType();
AVCodecID getCodecID();
QByteArray getExtradata();
ByteVector getExtradata();
Size getSize();
AVColorSpace getColorspace();
AVPixelFormat getPixelFormat();
Expand All @@ -57,7 +56,7 @@ class AVCodecParametersWrapper

void setAVMediaType(AVMediaType type);
void setAVCodecID(AVCodecID id);
void setExtradata(QByteArray extradata);
void setExtradata(const ByteVector &extradata);
void setSize(Size size);
void setAVPixelFormat(AVPixelFormat f);
void setProfileLevel(int profile, int level);
Expand All @@ -73,7 +72,7 @@ class AVCodecParametersWrapper
AVMediaType codec_type{};
AVCodecID codec_id{};
uint32_t codec_tag{};
QByteArray extradata{};
ByteVector extradata{};
int format{};
int64_t bit_rate{};
int bits_per_coded_sample{};
Expand Down
Loading

0 comments on commit 70580b2

Please sign in to comment.