Skip to content

Commit

Permalink
don't store SimpleBlock specific fields in a Block
Browse files Browse the repository at this point in the history
This will avoid some confusion on whether it makes sense there or not.
  • Loading branch information
robUx4 committed Jan 21, 2024
1 parent 570f079 commit 65f7277
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions matroska/KaxBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ class MATROSKA_DLL_API KaxInternalBlock : public libebml::EbmlBinary {

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,13 +270,15 @@ 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) {}

Expand Down
15 changes: 9 additions & 6 deletions src/KaxBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,10 @@ filepos_t KaxInternalBlock::RenderData(IOCallback & output, bool /* bForceRender
*cursor = 0x08;

if (bIsSimple) {
if (bIsKeyframe)
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

0 comments on commit 65f7277

Please sign in to comment.