From 393815ffb09ff68ec704a60439b26d186979402d Mon Sep 17 00:00:00 2001 From: Christoph Hasse Date: Mon, 22 Aug 2022 15:39:15 +0200 Subject: [PATCH] fix(video) filetype detection: handle video via quicktimevideo.cpp and other ftyp files in bmffimage --- src/bmffimage.cpp | 7 +------ src/image.cpp | 4 +++- src/quicktimevideo.cpp | 47 ++++++++++++++++++++---------------------- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/bmffimage.cpp b/src/bmffimage.cpp index 534770fd..b84d5de0 100644 --- a/src/bmffimage.cpp +++ b/src/bmffimage.cpp @@ -681,12 +681,7 @@ bool isBmffType(BasicIo& iIo, bool advance) { // jxl files have a special start indicator of "JXL " bool const is_jxl = (buf[4] == 'J' && buf[5] == 'X' && buf[6] == 'L' && buf[7] == ' '); - // MOV(quicktime) files seem to also start with ftyp, but we don't want to process them - // so check that we don't encounter "qt " - // FIXME what others types can we abort early here? - bool const is_video = (buf[8] == 'm' && buf[9] == 'p' && buf[10] == '4' && buf[11] == '2') || - (buf[8] == 'q' && buf[9] == 't' && buf[10] == ' ' && buf[11] == ' '); - bool matched = is_jxl || (is_ftyp && !is_video); + bool matched = is_jxl || is_ftyp; if (!advance || !matched) { iIo.seek(0, BasicIo::beg); } diff --git a/src/image.cpp b/src/image.cpp index 6784b89b..f83f67a3 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -97,10 +97,12 @@ constexpr auto registry = std::array{ Registry{ImageType::tga, newTgaInstance, isTgaType, amNone, amNone, amNone, amNone}, Registry{ImageType::bmp, newBmpInstance, isBmpType, amNone, amNone, amNone, amNone}, Registry{ImageType::jp2, newJp2Instance, isJp2Type, amReadWrite, amReadWrite, amReadWrite, amNone}, + // needs to be before bmff because some ftyp files are handled as qt and + // the rest should fall through to bmff + Registry{ ImageType::qtime,newQTimeInstance,isQTimeType,amRead,amNone, amRead, amNone}, #ifdef EXV_ENABLE_BMFF Registry{ImageType::bmff, newBmffInstance, isBmffType, amRead, amRead, amRead, amNone}, #endif // EXV_ENABLE_BMFF - Registry{ ImageType::qtime,newQTimeInstance,isQTimeType,amRead,amNone, amRead, amNone}, }; std::string pathOfFileUrl(const std::string& url) { diff --git a/src/quicktimevideo.cpp b/src/quicktimevideo.cpp index be96e253..5c4cd482 100644 --- a/src/quicktimevideo.cpp +++ b/src/quicktimevideo.cpp @@ -30,6 +30,8 @@ // + standard includes #include #include +#include +#include // ***************************************************************************** // class member definitions namespace Exiv2 { @@ -575,25 +577,6 @@ namespace Exiv2 { return temp; } - /*! - @brief Function used to quicktime files, by checking the - the tags at the start of the file. If the Tag is any one - of the tags listed below, then it is of Quicktime Type. - @param a, b, c, d - characters used to compare - @return Returns true, if Tag is found in the list qTimeTags - */ - bool isQuickTimeType (char a, char b, char c, char d) { - char qTimeTags[][5] = { - "PICT", "free", "ftyp", "junk", "mdat", - "moov", "pict", "pnot", "skip", "uuid", "wide" - }; - - for(int i = 0; i <= 10; i++) - if(a == qTimeTags[i][0] && b == qTimeTags[i][1] && c == qTimeTags[i][2] && d == qTimeTags[i][3]) - return true; - return false; - } - }} // namespace Internal, Exiv2 namespace Exiv2 { @@ -666,7 +649,7 @@ namespace Exiv2 { if(size < 8) return; - std::cerr<<"\nTag=>"<"<"<"<(0), BasicIo::beg); }