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

Move the element size check in EbmlCallbacks #187

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion matroska/KaxBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class MATROSKA_DLL_API KaxInternalBlock : public libebml::EbmlBinary {
{}
KaxInternalBlock(const KaxInternalBlock & ElementToClone);
~KaxInternalBlock() override;
bool SizeIsValid(std::uint64_t size) const override
static inline bool SizeIsValid(std::uint64_t size)
{
return size >= 4; /// for the moment
}
Expand Down
8 changes: 4 additions & 4 deletions matroska/KaxDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ class MATROSKA_DLL_API MatroskaProfile : public libebml::EbmlDocVersion
#define DEFINE_MKX_STRING_DEF(a,b,d,e,versions,v) DEFINE_xxx_STRING_DEF(a,b,d,e,versions,GetKaxGlobal_Context,v)
#define DEFINE_MKX_STRING(a,b,d,e,versions) DEFINE_xxx_STRING(a,b,d,e,versions,GetKaxGlobal_Context)
#define DEFINE_MKX_UNISTRING(a,b,d,e,versions) DEFINE_xxx_UNISTRING(a,b,d,e,versions,GetKaxGlobal_Context)
#define DEFINE_MKX_BINARY(a,b,d,e,versions) DEFINE_xxx_BINARY(a,b,d,e,versions,GetKaxGlobal_Context)
#define DEFINE_MKX_BINARY(a,b,d,e,valid,versions) DEFINE_xxx_BINARY(a,b,d,e,valid,versions,GetKaxGlobal_Context)
#define DEFINE_MKX_FLOAT_DEF(a,b,d,e,versions,v) DEFINE_xxx_FLOAT_DEF(a,b,d,e,versions,GetKaxGlobal_Context,v)
#define DEFINE_MKX_FLOAT(a,b,d,e,versions) DEFINE_xxx_FLOAT(a,b,d,e,versions,GetKaxGlobal_Context)
#define DEFINE_MKX_DATE(a,b,d,e,versions) DEFINE_xxx_DATE(a,b,d,e,versions,GetKaxGlobal_Context)
#define DEFINE_MKX_BINARY_CONS(a,b,d,e,versions) DEFINE_xxx_CLASS_CONS(a,b,d,e,GetKaxGlobal_Context) \
constexpr const libebml::EbmlCallbacks a::ClassInfos(a::Create, Id_##a, false, false, e, Context_##a, versions);
#define DEFINE_MKX_BINARY_CONS(a,b,d,e,valid,versions) DEFINE_xxx_CLASS_CONS(a,b,d,e,GetKaxGlobal_Context) \
constexpr const libebml::EbmlCallbacks a::ClassInfos(a::Create, Id_##a, false, false, e, Context_##a, versions, valid);
#define DEFINE_MKX_SINTEGER_CONS(a,b,d,e,versions) DEFINE_xxx_CLASS_CONS(a,b,d,e,GetKaxGlobal_Context) \
const libebml::EbmlCallbacksDefault<std::int64_t> a::ClassInfos(a::Create, Id_##a, e, Context_##a, versions);
const libebml::EbmlCallbacksDefault<std::int64_t> a::ClassInfos(a::Create, Id_##a, e, Context_##a, versions, libebml::EbmlSInteger::SizeIsValid);

#define MATROSKA_CLASS_BODY(x) \
EBML_CONCRETE_CLASS(x)
Expand Down
29 changes: 19 additions & 10 deletions matroska/KaxSemantic.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#include "matroska/KaxDefines.h"

namespace libmatroska {
DECLARE_MKX_BINARY_LENGTH(KaxSeekID, 4)
DECLARE_MKX_BINARY(KaxSeekID)
static inline bool SizeIsValid(std::uint64_t Size) {return Size == 4;}
};

DECLARE_MKX_UINTEGER(KaxSeekPosition)
Expand All @@ -31,25 +32,29 @@ DECLARE_MKX_UINTEGER(KaxSeekPosition)
DECLARE_MKX_MASTER(KaxInfo)
};

DECLARE_MKX_BINARY_LENGTH(KaxSegmentUID, 16)
DECLARE_MKX_BINARY(KaxSegmentUID)
static inline bool SizeIsValid(std::uint64_t Size) {return Size == 16;}
};

DECLARE_MKX_UNISTRING(KaxSegmentFilename)
};

DECLARE_MKX_BINARY_LENGTH(KaxPrevUID, 16)
DECLARE_MKX_BINARY(KaxPrevUID)
static inline bool SizeIsValid(std::uint64_t Size) {return Size == 16;}
};

DECLARE_MKX_UNISTRING(KaxPrevFilename)
};

DECLARE_MKX_BINARY_LENGTH(KaxNextUID, 16)
DECLARE_MKX_BINARY(KaxNextUID)
static inline bool SizeIsValid(std::uint64_t Size) {return Size == 16;}
};

DECLARE_MKX_UNISTRING(KaxNextFilename)
};

DECLARE_MKX_BINARY_LENGTH(KaxSegmentFamily, 16)
DECLARE_MKX_BINARY(KaxSegmentFamily)
static inline bool SizeIsValid(std::uint64_t Size) {return Size == 16;}
};

DECLARE_MKX_MASTER(KaxChapterTranslate)
Expand Down Expand Up @@ -386,7 +391,8 @@ DECLARE_MKX_UINTEGER_DEF(KaxVideoAspectRatio)
libebml::filepos_t RenderData(libebml::IOCallback & output, bool bForceRender, const ShouldWrite & writeFilter) override;
};

DECLARE_MKX_BINARY_LENGTH(KaxVideoColourSpace, 4)
DECLARE_MKX_BINARY(KaxVideoColourSpace)
static inline bool SizeIsValid(std::uint64_t Size) {return Size == 4;}
};

DECLARE_MKX_FLOAT(KaxVideoGamma)
Expand Down Expand Up @@ -541,9 +547,10 @@ DECLARE_MKX_UINTEGER(KaxTrickTrackUID)
libebml::filepos_t RenderData(libebml::IOCallback & output, bool bForceRender, const ShouldWrite & writeFilter) override;
};

DECLARE_MKX_BINARY_LENGTH(KaxTrickTrackSegmentUID, 16)
DECLARE_MKX_BINARY(KaxTrickTrackSegmentUID)
public:
libebml::filepos_t RenderData(libebml::IOCallback & output, bool bForceRender, const ShouldWrite & writeFilter) override;
static inline bool SizeIsValid(std::uint64_t Size) {return Size == 16;}
};

DECLARE_MKX_UINTEGER_DEF(KaxTrickTrackFlag)
Expand All @@ -556,9 +563,10 @@ DECLARE_MKX_UINTEGER(KaxTrickMasterTrackUID)
libebml::filepos_t RenderData(libebml::IOCallback & output, bool bForceRender, const ShouldWrite & writeFilter) override;
};

DECLARE_MKX_BINARY_LENGTH(KaxTrickMasterTrackSegmentUID, 16)
DECLARE_MKX_BINARY(KaxTrickMasterTrackSegmentUID)
public:
libebml::filepos_t RenderData(libebml::IOCallback & output, bool bForceRender, const ShouldWrite & writeFilter) override;
static inline bool SizeIsValid(std::uint64_t Size) {return Size == 16;}
};

DECLARE_MKX_MASTER(KaxContentEncodings)
Expand Down Expand Up @@ -743,7 +751,8 @@ DECLARE_MKX_UINTEGER_DEF(KaxChapterFlagHidden)
DECLARE_MKX_UINTEGER_DEF(KaxChapterFlagEnabled)
};

DECLARE_MKX_BINARY_LENGTH(KaxChapterSegmentUID, 16)
DECLARE_MKX_BINARY(KaxChapterSegmentUID)
static inline bool SizeIsValid(std::uint64_t Size) {return Size == 16;}
};

DECLARE_MKX_UINTEGER(KaxChapterSkipType)
Expand Down Expand Up @@ -1164,7 +1173,7 @@ typedef enum {
*Indicate what type of content the ChapterAtom contains and might be skipped. It can be used to automatically skip content based on the type.
If a `ChapterAtom` is inside a `ChapterAtom` that has a `ChapterSkipType` set, it **MUST NOT** have a `ChapterSkipType` or have a `ChapterSkipType` with the same value as it's parent `ChapterAtom`.
If the `ChapterAtom` doesn't contain a `ChapterTimeEnd`, the value of the `ChapterSkipType` is only valid until the next `ChapterAtom` with a `ChapterSkipType` value or the end of the file.

*/
typedef enum {
MATROSKA_CHAPTERSKIPTYPE_NO_SKIPPING = 0, // Content which should not be skipped.
Expand Down
Loading
Loading