diff --git a/YUViewLib/externalLibs/LibFFmpeg++/common/FFMpegLibrariesTypes.h b/YUViewLib/externalLibs/LibFFmpeg++/common/FFMpegLibrariesTypes.h index 0026d9145..450a0c319 100644 --- a/YUViewLib/externalLibs/LibFFmpeg++/common/FFMpegLibrariesTypes.h +++ b/YUViewLib/externalLibs/LibFFmpeg++/common/FFMpegLibrariesTypes.h @@ -47,7 +47,20 @@ namespace LibFFmpeg { -using Log = std::vector; +struct Size +{ + int width{}; + int height{}; +}; + +struct Ratio +{ + int num{}; + int den{}; +}; + +using ByteVector = std::vector; +using Log = std::vector; // Some structs/enums which actual definition does not interest us. struct AVFormatContext; diff --git a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecContextWrapper.cpp b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecContextWrapper.cpp index 98b51c624..36325f677 100644 --- a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecContextWrapper.cpp +++ b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecContextWrapper.cpp @@ -31,7 +31,8 @@ */ #include "AVCodecContextWrapper.h" -#include + +#include "Functions.h" namespace LibFFmpeg { @@ -468,7 +469,7 @@ AVRational AVCodecContextWrapper::getTimeBase() return this->time_base; } -QByteArray AVCodecContextWrapper::getExtradata() +ByteVector AVCodecContextWrapper::getExtradata() { this->update(); return this->extradata; @@ -483,7 +484,7 @@ void AVCodecContextWrapper::update() { auto p = reinterpret_cast(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; @@ -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; @@ -567,7 +568,7 @@ void AVCodecContextWrapper::update() { auto p = reinterpret_cast(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; @@ -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; @@ -651,7 +652,7 @@ void AVCodecContextWrapper::update() { auto p = reinterpret_cast(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; @@ -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; @@ -736,7 +737,7 @@ void AVCodecContextWrapper::update() { auto p = reinterpret_cast(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; @@ -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; diff --git a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecContextWrapper.h b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecContextWrapper.h index 6ad720f14..ef16f9aaa 100644 --- a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecContextWrapper.h +++ b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecContextWrapper.h @@ -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{}; @@ -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{}; diff --git a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecParametersWrapper.cpp b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecParametersWrapper.cpp index 661130bb5..0693d8325 100644 --- a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecParametersWrapper.cpp +++ b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecParametersWrapper.cpp @@ -32,7 +32,7 @@ #include "AVCodecParametersWrapper.h" -#include +#include "Functions.h" namespace LibFFmpeg { @@ -89,7 +89,7 @@ AVCodecID AVCodecParametersWrapper::getCodecID() return this->codec_id; } -QByteArray AVCodecParametersWrapper::getExtradata() +ByteVector AVCodecParametersWrapper::getExtradata() { this->update(); return this->extradata; @@ -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() @@ -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 || // @@ -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 || // @@ -302,7 +193,7 @@ void AVCodecParametersWrapper::setExtradata(QByteArray data) this->extradata = data; auto p = reinterpret_cast(this->param); p->extradata = reinterpret_cast(this->extradata.data()); - p->extradata_size = this->extradata.length(); + p->extradata_size = static_cast(this->extradata.size()); } } @@ -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; diff --git a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecParametersWrapper.h b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecParametersWrapper.h index e639e4c41..2aab2e70a 100644 --- a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecParametersWrapper.h +++ b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVCodecParametersWrapper.h @@ -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(); @@ -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); @@ -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{}; diff --git a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFormatContextWrapper.cpp b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFormatContextWrapper.cpp index ce2953e03..4c6a3923c 100644 --- a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFormatContextWrapper.cpp +++ b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFormatContextWrapper.cpp @@ -259,8 +259,8 @@ void AVFormatContextWrapper::update() this->ctx_flags = p->ctx_flags; this->nb_streams = p->nb_streams; for (unsigned i = 0; i < this->nb_streams; i++) - this->streams.append(AVStreamWrapper(p->streams[i], this->libraryVersions)); - this->filename = QString(p->filename); + this->streams.push_back(AVStreamWrapper(p->streams[i], this->libraryVersions)); + this->filename = std::string(p->filename); this->start_time = p->start_time; this->duration = p->duration; this->bit_rate = p->bit_rate; @@ -269,7 +269,7 @@ void AVFormatContextWrapper::update() this->flags = p->flags; this->probesize = p->probesize; this->max_analyze_duration = p->max_analyze_duration; - this->key = QString::fromLatin1((const char *)p->key, p->keylen); + this->key = std::string((const char *)p->key, p->keylen); this->nb_programs = p->nb_programs; this->video_codec_id = p->video_codec_id; this->audio_codec_id = p->audio_codec_id; @@ -287,8 +287,8 @@ void AVFormatContextWrapper::update() this->ctx_flags = p->ctx_flags; this->nb_streams = p->nb_streams; for (unsigned i = 0; i < nb_streams; i++) - this->streams.append(AVStreamWrapper(p->streams[i], this->libraryVersions)); - this->filename = QString(p->filename); + this->streams.push_back(AVStreamWrapper(p->streams[i], this->libraryVersions)); + this->filename = std::string(p->filename); this->start_time = p->start_time; this->duration = p->duration; this->bit_rate = p->bit_rate; @@ -297,7 +297,7 @@ void AVFormatContextWrapper::update() this->flags = p->flags; this->probesize = p->probesize; this->max_analyze_duration = p->max_analyze_duration; - this->key = QString::fromLatin1((const char *)p->key, p->keylen); + this->key = std::string((const char *)p->key, p->keylen); this->nb_programs = p->nb_programs; this->video_codec_id = p->video_codec_id; this->audio_codec_id = p->audio_codec_id; @@ -315,8 +315,8 @@ void AVFormatContextWrapper::update() this->ctx_flags = p->ctx_flags; this->nb_streams = p->nb_streams; for (unsigned i = 0; i < nb_streams; i++) - this->streams.append(AVStreamWrapper(p->streams[i], this->libraryVersions)); - this->filename = QString(p->filename); + this->streams.push_back(AVStreamWrapper(p->streams[i], this->libraryVersions)); + this->filename = std::string(p->filename); this->start_time = p->start_time; this->duration = p->duration; this->bit_rate = p->bit_rate; @@ -325,7 +325,7 @@ void AVFormatContextWrapper::update() this->flags = p->flags; this->probesize = p->probesize; this->max_analyze_duration = p->max_analyze_duration; - this->key = QString::fromLatin1((const char *)p->key, p->keylen); + this->key = std::string((const char *)p->key, p->keylen); this->nb_programs = p->nb_programs; this->video_codec_id = p->video_codec_id; this->audio_codec_id = p->audio_codec_id; @@ -344,8 +344,8 @@ void AVFormatContextWrapper::update() this->ctx_flags = p->ctx_flags; this->nb_streams = p->nb_streams; for (unsigned i = 0; i < nb_streams; i++) - this->streams.append(AVStreamWrapper(p->streams[i], this->libraryVersions)); - this->filename = QString(p->url); + this->streams.push_back(AVStreamWrapper(p->streams[i], this->libraryVersions)); + this->filename = std::string(p->url); this->start_time = p->start_time; this->duration = p->duration; this->bit_rate = p->bit_rate; @@ -354,7 +354,7 @@ void AVFormatContextWrapper::update() this->flags = p->flags; this->probesize = p->probesize; this->max_analyze_duration = p->max_analyze_duration; - this->key = QString::fromLatin1((const char *)p->key, p->keylen); + this->key = std::string((const char *)p->key, p->keylen); this->nb_programs = p->nb_programs; this->video_codec_id = p->video_codec_id; this->audio_codec_id = p->audio_codec_id; @@ -370,45 +370,4 @@ void AVFormatContextWrapper::update() throw std::runtime_error("Invalid library version"); } -QStringPairList AVFormatContextWrapper::getInfoText() -{ - if (this->ctx == nullptr) - return {QStringPair("Format context not initialized", "")}; - - this->update(); - - QStringPairList info; - if (this->ctx_flags != 0) - { - QString flags; - if (this->ctx_flags & 1) - flags += QString("No-Header"); - if (this->ctx_flags & 2) - flags += QString("Un-seekable"); - info.append(QStringPair("Flags", flags)); - } - - AVRational time_base; - time_base.num = 1; - time_base.den = AV_TIME_BASE; - - info.append(QStringPair("Number streams", QString::number(this->nb_streams))); - info.append(QStringPair("File name", this->filename)); - info.append(QStringPair("Start time", - QString("%1 (%2)") - .arg(this->start_time) - .arg(timestampToString(this->start_time, time_base)))); - info.append(QStringPair( - "Duration", - QString("%1 (%2)").arg(this->duration).arg(timestampToString(duration, time_base)))); - if (bit_rate > 0) - info.append(QStringPair("Bitrate", QString::number(this->bit_rate))); - info.append(QStringPair("Packet size", QString::number(this->packet_size))); - info.append(QStringPair("Max delay", QString::number(this->max_delay))); - info.append(QStringPair("Number programs", QString::number(this->nb_programs))); - info.append(QStringPair("Number chapters", QString::number(this->nb_chapters))); - - return info; -} - -} // namespace LibFFmpeg \ No newline at end of file +} // namespace LibFFmpeg diff --git a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFormatContextWrapper.h b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFormatContextWrapper.h index e09b0a76c..d7d926484 100644 --- a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFormatContextWrapper.h +++ b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFormatContextWrapper.h @@ -48,9 +48,8 @@ class AVFormatContextWrapper AVFormatContextWrapper() = default; AVFormatContextWrapper(AVFormatContext *c, const LibraryVersions &libraryVersions); - void updateFrom(AVFormatContext *c); - explicit operator bool() const; - QStringPairList getInfoText(); + void updateFrom(AVFormatContext *c); + explicit operator bool() const; unsigned int getNbStreams(); AVStreamWrapper getStream(int idx); @@ -67,20 +66,20 @@ class AVFormatContextWrapper AVInputFormatWrapper iformat{}; // These are private. Use "update" to update them from the AVFormatContext - int ctx_flags{0}; - unsigned int nb_streams{0}; - QList streams; - QString filename{}; - int64_t start_time{-1}; - int64_t duration{-1}; - int bit_rate{0}; - unsigned int packet_size{0}; - int max_delay{0}; - int flags{0}; + int ctx_flags{0}; + unsigned int nb_streams{0}; + std::vector streams; + std::string filename{}; + int64_t start_time{-1}; + int64_t duration{-1}; + int bit_rate{0}; + unsigned int packet_size{0}; + int max_delay{0}; + int flags{0}; unsigned int probesize{0}; int max_analyze_duration{0}; - QString key{}; + std::string key{}; unsigned int nb_programs{0}; AVCodecID video_codec_id{AV_CODEC_ID_NONE}; AVCodecID audio_codec_id{AV_CODEC_ID_NONE}; diff --git a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFrameWrapper.cpp b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFrameWrapper.cpp index 8d5aacfc8..55bdb21df 100644 --- a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFrameWrapper.cpp +++ b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVFrameWrapper.cpp @@ -171,7 +171,7 @@ int AVFrameWrapper::getHeight() Size AVFrameWrapper::getSize() { this->update(); - return Size(width, height); + return Size({width, height}); } int AVFrameWrapper::getPTS() diff --git a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVStreamWrapper.cpp b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVStreamWrapper.cpp index ef655530f..4b749a6f1 100644 --- a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVStreamWrapper.cpp +++ b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVStreamWrapper.cpp @@ -246,20 +246,28 @@ AVMediaType AVStreamWrapper::getCodecType() return this->codecpar.getCodecType(); } -QString AVStreamWrapper::getCodecTypeName() +std::string AVStreamWrapper::getCodecTypeName() { auto type = this->codecpar.getCodecType(); - if (type > AVMEDIA_TYPE_NB) - return {}; - auto names = QStringList() << "Unknown" - << "Video" - << "Audio" - << "Data" - << "Subtitle" - << "Attachment" - << "NB"; - return names[type + 1]; + switch (type) + { + case -1: + return "Unknown"; + case 0: + return "Video"; + case 1: + return "Audio"; + case 2: + return "Data"; + case 3: + return "Subtitle"; + case 4: + return "Attachment"; + + default: + return {}; + } } AVCodecID AVStreamWrapper::getCodecID() @@ -319,7 +327,7 @@ AVPixelFormat AVStreamWrapper::getPixelFormat() return this->codecpar.getPixelFormat(); } -QByteArray AVStreamWrapper::getExtradata() +ByteVector AVStreamWrapper::getExtradata() { this->update(); if (this->libraryVersions.avformat.major <= 56 || !this->codecpar) @@ -436,85 +444,4 @@ void AVStreamWrapper::update() throw std::runtime_error("Invalid library version"); } -QStringPairList AVStreamWrapper::getInfoText(AVCodecIDWrapper &codecIdWrapper) -{ - if (this->stream == nullptr) - return {QStringPair("Error stream is null", "")}; - - this->update(); - - QStringPairList info; - info.append(QStringPair("Index", QString::number(this->index))); - info.append(QStringPair("ID", QString::number(this->id))); - - info.append(QStringPair("Codec Type", getCodecTypeName())); - info.append(QStringPair("Codec ID", QString::number((int)getCodecID()))); - info.append(QStringPair("Codec Name", QString::fromStdString(codecIdWrapper.getCodecName()))); - info.append( - QStringPair("Time base", QString("%1/%2").arg(this->time_base.num).arg(this->time_base.den))); - info.append(QStringPair("Start Time", - QString("%1 (%2)") - .arg(this->start_time) - .arg(timestampToString(this->start_time, this->time_base)))); - info.append(QStringPair("Duration", - QString("%1 (%2)") - .arg(this->duration) - .arg(timestampToString(this->duration, this->time_base)))); - info.append(QStringPair("Number Frames", QString::number(this->nb_frames))); - - if (this->disposition != 0) - { - QString dispText; - if (this->disposition & 0x0001) - dispText += QString("Default "); - if (this->disposition & 0x0002) - dispText += QString("Dub "); - if (this->disposition & 0x0004) - dispText += QString("Original "); - if (this->disposition & 0x0008) - dispText += QString("Comment "); - if (this->disposition & 0x0010) - dispText += QString("Lyrics "); - if (this->disposition & 0x0020) - dispText += QString("Karaoke "); - if (this->disposition & 0x0040) - dispText += QString("Forced "); - if (this->disposition & 0x0080) - dispText += QString("Hearing_Imparied "); - if (this->disposition & 0x0100) - dispText += QString("Visual_Impaired "); - if (this->disposition & 0x0200) - dispText += QString("Clean_Effects "); - if (this->disposition & 0x0400) - dispText += QString("Attached_Pic "); - if (this->disposition & 0x0800) - dispText += QString("Timed_Thumbnails "); - if (this->disposition & 0x1000) - dispText += QString("Captions "); - if (this->disposition & 0x2000) - dispText += QString("Descriptions "); - if (this->disposition & 0x4000) - dispText += QString("Metadata "); - if (this->disposition & 0x8000) - dispText += QString("Dependent "); - info.append(QStringPair("Disposition", dispText)); - } - - info.append(QStringPair( - "Sample Aspect Ratio", - QString("%1:%2").arg(this->sample_aspect_ratio.num).arg(this->sample_aspect_ratio.den))); - - auto divFrameRate = 0.0; - if (this->avg_frame_rate.den > 0) - divFrameRate = double(this->avg_frame_rate.num) / double(this->avg_frame_rate.den); - info.append(QStringPair("Average Frame Rate", - QString("%1/%2 (%3)") - .arg(this->avg_frame_rate.num) - .arg(this->avg_frame_rate.den) - .arg(divFrameRate, 0, 'f', 2))); - - info += this->codecpar.getInfoText(); - return info; -} - } // namespace LibFFmpeg diff --git a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVStreamWrapper.h b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVStreamWrapper.h index 1eb15261a..21d7bba11 100644 --- a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVStreamWrapper.h +++ b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/AVStreamWrapper.h @@ -47,11 +47,10 @@ class AVStreamWrapper AVStreamWrapper() {} AVStreamWrapper(AVStream *src_str, const LibraryVersions &libraryVersions); - explicit operator bool() const { return this->stream != nullptr; }; - QStringPairList getInfoText(AVCodecIDWrapper &codecIdWrapper); + explicit operator bool() const { return this->stream != nullptr; }; AVMediaType getCodecType(); - QString getCodecTypeName(); + std::string getCodecTypeName(); AVCodecID getCodecID(); AVCodecContextWrapper & getCodec(); AVRational getAvgFrameRate(); @@ -59,7 +58,7 @@ class AVStreamWrapper Size getFrameSize(); AVColorSpace getColorspace(); AVPixelFormat getPixelFormat(); - QByteArray getExtradata(); + ByteVector getExtradata(); int getIndex(); AVCodecParametersWrapper getCodecpar(); diff --git a/YUViewLib/externalLibs/LibFFmpeg++/wrappers/Functions.h b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/Functions.h new file mode 100644 index 000000000..899f9233a --- /dev/null +++ b/YUViewLib/externalLibs/LibFFmpeg++/wrappers/Functions.h @@ -0,0 +1,52 @@ +/* This file is part of YUView - The YUV player with advanced analytics toolset + * + * 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 . + */ + +#pragma once + +#include + +namespace LibFFmpeg +{ + +inline ByteVector copyDataFromRawArray(const uint8_t *inputData, const int inputDataSize) +{ + assert(inputDataSize >= 0); + + ByteVector data; + data.resize(inputDataSize); + + const auto inputDataAsBytes = reinterpret_cast(inputData); + std::copy(inputDataAsBytes, inputDataAsBytes + inputDataSize, data.begin()); + return data; +} + +} // namespace LibFFmpeg