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 some SimpleBlock flags inside SimpleBlock #162

Merged
merged 2 commits into from
Jan 24, 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
14 changes: 6 additions & 8 deletions matroska/KaxBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,8 @@ DECLARE_MKX_MASTER(KaxBlockGroup)

class MATROSKA_DLL_API KaxInternalBlock : public libebml::EbmlBinary {
public:
KaxInternalBlock(const libebml::EbmlCallbacks & classInfo, bool bSimple)
:libebml::EbmlBinary(classInfo),
bIsSimple(bSimple)
KaxInternalBlock(const libebml::EbmlCallbacks & classInfo)
:libebml::EbmlBinary(classInfo)
{}
KaxInternalBlock(const KaxInternalBlock & ElementToClone);
~KaxInternalBlock() override;
Expand Down Expand Up @@ -261,9 +260,6 @@ class MATROSKA_DLL_API KaxInternalBlock : public libebml::EbmlBinary {
std::uint64_t FirstFrameLocation;

KaxCluster *ParentCluster{nullptr};
bool bIsSimple;
bool bIsKeyframe{true};
bool bIsDiscardable{false};

libebml::filepos_t RenderData(libebml::IOCallback & output, bool bForceRender, ShouldWrite writeFilter = WriteSkipDefault) override;
};
Expand All @@ -272,15 +268,17 @@ class MATROSKA_DLL_API KaxBlock : public KaxInternalBlock {
private:
static const libebml::EbmlCallbacks ClassInfos;
public:
KaxBlock() :KaxInternalBlock(KaxBlock::ClassInfos, false) {}
KaxBlock() :KaxInternalBlock(KaxBlock::ClassInfos) {}
MATROSKA_CLASS_BODY(KaxBlock)
};

class MATROSKA_DLL_API KaxSimpleBlock : public KaxInternalBlock {
private:
static const libebml::EbmlCallbacks ClassInfos;
bool bIsKeyframe{true};
bool bIsDiscardable{false};
public:
KaxSimpleBlock() :KaxInternalBlock(KaxSimpleBlock::ClassInfos, true) {}
KaxSimpleBlock() :KaxInternalBlock(KaxSimpleBlock::ClassInfos) {}

void SetKeyframe(bool b_keyframe) { bIsKeyframe = b_keyframe; }
void SetDiscardable(bool b_discard) { bIsDiscardable = b_discard; }
Expand Down
17 changes: 10 additions & 7 deletions src/KaxBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,11 @@ filepos_t KaxInternalBlock::RenderData(IOCallback & output, bool /* bForceRender
if (mInvisible)
*cursor = 0x08;

if (bIsSimple) {
if (bIsKeyframe)
if (EbmlId(*this) == EBML_ID(KaxSimpleBlock)) {
auto *s = reinterpret_cast<const KaxSimpleBlock*>(this);
if (s->IsKeyframe())
*cursor |= 0x80;
if (bIsDiscardable)
if (s->IsDiscardable())
*cursor |= 0x01;
}

Expand Down Expand Up @@ -517,8 +518,9 @@ filepos_t KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully)

const std::uint8_t Flags = Mem.GetUInt8();
if (EbmlId(*this) == EBML_ID(KaxSimpleBlock)) {
bIsKeyframe = (Flags & 0x80) != 0;
bIsDiscardable = (Flags & 0x01) != 0;
auto *s = reinterpret_cast<KaxSimpleBlock*>(this);
s->SetKeyframe( (Flags & 0x80) != 0 );
s->SetDiscardable( (Flags & 0x01) != 0 );
}
mInvisible = (Flags & 0x08) >> 3;
mLacing = static_cast<LacingType>((Flags & 0x06) >> 1);
Expand Down Expand Up @@ -642,8 +644,9 @@ filepos_t KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully)
cursor += 2;

if (EbmlId(*this) == EBML_ID(KaxSimpleBlock)) {
bIsKeyframe = (*cursor & 0x80) != 0;
bIsDiscardable = (*cursor & 0x01) != 0;
auto *s = reinterpret_cast<KaxSimpleBlock*>(this);
s->SetKeyframe( (*cursor & 0x80) != 0 );
s->SetDiscardable( (*cursor & 0x01) != 0 );
}
mInvisible = (*cursor & 0x08) >> 3;
mLacing = static_cast<LacingType>((*cursor++ & 0x06) >> 1);
Expand Down