Skip to content

Commit

Permalink
Switch to the ShouldWrite API to select which elements to write
Browse files Browse the repository at this point in the history
  • Loading branch information
robUx4 committed Dec 19, 2023
1 parent 5b8dbaf commit 1f08f90
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 107 deletions.
8 changes: 4 additions & 4 deletions matroska/KaxBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class MATROSKA_DLL_API KaxInternalBlock : public EbmlBinary {
/*!
\note override this function to generate the Data/Size on the fly, unlike the usual binary elements
*/
filepos_t UpdateSize(bool bSaveDefault = false, bool bForceRender = false) override;
filepos_t UpdateSize(ShouldWrite writeFilter = WriteSkipDefault, bool bForceRender = false) override;
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) override;

/*!
Expand Down Expand Up @@ -262,7 +262,7 @@ class MATROSKA_DLL_API KaxInternalBlock : public EbmlBinary {
bool bIsKeyframe{true};
bool bIsDiscardable{false};

filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault = false) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter = WriteSkipDefault) override;
};

DECLARE_MKX_CONTEXT(KaxBlock)
Expand Down Expand Up @@ -334,11 +334,11 @@ DECLARE_MKX_BINARY_CONS(KaxBlockVirtual)
/*!
\note override this function to generate the Data/Size on the fly, unlike the usual binary elements
*/
filepos_t UpdateSize(bool bSaveDefault = false, bool bForceRender = false) override;
filepos_t UpdateSize(ShouldWrite writeFilter = WriteSkipDefault, bool bForceRender = false) override;

void SetParent(const KaxCluster & aParentCluster) {ParentCluster = &aParentCluster;}

filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;

filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) override;

Expand Down
2 changes: 1 addition & 1 deletion matroska/KaxBlockData.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DECLARE_MKX_SINTEGER_CONS(KaxReferenceBlock)
/*!
\brief override this method to compute the timecode value
*/
filepos_t UpdateSize(bool bSaveDefault = false, bool bForceRender = false) override;
filepos_t UpdateSize(ShouldWrite writeFilter = WriteSkipDefault, bool bForceRender = false) override;

const KaxBlockBlob & RefBlock() const;
void SetReferencedBlock(const KaxBlockBlob * aRefdBlock);
Expand Down
2 changes: 1 addition & 1 deletion matroska/KaxCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ DECLARE_MKX_MASTER_CONS(KaxCluster)
/*!
\brief Render the data to the stream and retrieve the position of BlockGroups for later cue entries
*/
filepos_t Render(IOCallback & output, KaxCues & CueToUpdate, bool bSaveDefault = false);
filepos_t Render(IOCallback & output, KaxCues & CueToUpdate, ShouldWrite writeFilter = WriteSkipDefault);

/*!
\return the global timecode of this Cluster
Expand Down
4 changes: 2 additions & 2 deletions matroska/KaxCues.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ DECLARE_MKX_MASTER(KaxCues)
/*!
\brief override to sort by timecode/track
*/
filepos_t Render(IOCallback & output, bool bSaveDefault = false) {
filepos_t Render(IOCallback & output, ShouldWrite writeFilter = WriteSkipDefault) {
Sort();
return EbmlMaster::Render(output, bSaveDefault);
return EbmlMaster::Render(output, writeFilter);
}

std::uint64_t GetTimecodePosition(std::uint64_t aTimecode) const;
Expand Down
90 changes: 45 additions & 45 deletions matroska/KaxSemantic.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ DECLARE_MKX_UINTEGER(KaxClusterTimecode)

DECLARE_MKX_MASTER(KaxClusterSilentTracks)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxClusterSilentTrackNumber)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxClusterPosition)
Expand Down Expand Up @@ -123,7 +123,7 @@ DECLARE_MKX_UINTEGER(KaxReferencePriority)

DECLARE_MKX_SINTEGER(KaxReferenceVirtual)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxCodecState)
Expand All @@ -134,57 +134,57 @@ DECLARE_MKX_SINTEGER(KaxDiscardPadding)

DECLARE_MKX_MASTER(KaxSlices)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxTimeSlice)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxSliceLaceNumber)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxSliceFrameNumber)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxSliceBlockAddID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxSliceDelay)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxSliceDuration)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxReferenceFrame)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxReferenceOffset)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxReferenceTimeCode)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxEncryptedBlock)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxTracks)
Expand Down Expand Up @@ -228,12 +228,12 @@ DECLARE_MKX_UINTEGER(KaxTrackFlagLacing)

DECLARE_MKX_UINTEGER(KaxTrackMinCache)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxTrackMaxCache)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxTrackDefaultDuration)
Expand All @@ -244,12 +244,12 @@ DECLARE_MKX_UINTEGER(KaxTrackDefaultDecodedFieldDuration)

DECLARE_MKX_FLOAT(KaxTrackTimecodeScale)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_SINTEGER(KaxTrackOffset)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxMaxBlockAdditionID)
Expand Down Expand Up @@ -290,27 +290,27 @@ DECLARE_MKX_UNISTRING(KaxCodecName)

DECLARE_MKX_UINTEGER(KaxTrackAttachmentLink)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UNISTRING(KaxCodecSettings)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_STRING(KaxCodecInfoURL)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_STRING(KaxCodecDownloadURL)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxCodecDecodeAll)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxTrackOverlay)
Expand Down Expand Up @@ -351,7 +351,7 @@ DECLARE_MKX_UINTEGER(KaxVideoAlphaMode)

DECLARE_MKX_UINTEGER(KaxOldStereoMode)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxVideoPixelWidth)
Expand Down Expand Up @@ -383,7 +383,7 @@ DECLARE_MKX_UINTEGER(KaxVideoDisplayUnit)

DECLARE_MKX_UINTEGER(KaxVideoAspectRatio)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxVideoColourSpace)
Expand All @@ -393,12 +393,12 @@ DECLARE_MKX_BINARY (KaxVideoColourSpace)

DECLARE_MKX_FLOAT(KaxVideoGamma)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_FLOAT(KaxVideoFrameRate)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxVideoColour)
Expand Down Expand Up @@ -508,7 +508,7 @@ DECLARE_MKX_UINTEGER(KaxAudioChannels)

DECLARE_MKX_BINARY (KaxAudioPosition)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxAudioBitDepth)
Expand Down Expand Up @@ -540,28 +540,28 @@ DECLARE_MKX_UINTEGER(KaxTrackJoinUID)

DECLARE_MKX_UINTEGER(KaxTrickTrackUID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxTrickTrackSegmentUID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
bool ValidateSize() const override {return IsFiniteSize() && GetSize() == 16;}
};

DECLARE_MKX_UINTEGER(KaxTrickTrackFlag)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxTrickMasterTrackUID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxTrickMasterTrackSegmentUID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
bool ValidateSize() const override {return IsFiniteSize() && GetSize() == 16;}
};

Expand Down Expand Up @@ -606,22 +606,22 @@ DECLARE_MKX_UINTEGER(KaxAESSettingsCipherMode)

DECLARE_MKX_BINARY (KaxContentSignature)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxContentSigKeyID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxContentSigAlgo)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxContentSigHashAlgo)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxCueTime)
Expand Down Expand Up @@ -650,17 +650,17 @@ DECLARE_MKX_UINTEGER(KaxCueRefTime)

DECLARE_MKX_UINTEGER(KaxCueRefCluster)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxCueRefNumber)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxCueRefCodecState)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxAttachments)
Expand All @@ -686,17 +686,17 @@ DECLARE_MKX_UINTEGER(KaxFileUID)

DECLARE_MKX_BINARY (KaxFileReferral)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxFileUsedStartTime)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxFileUsedEndTime)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxChapters)
Expand Down Expand Up @@ -844,7 +844,7 @@ DECLARE_MKX_UINTEGER(KaxTagDefault)

DECLARE_MKX_UINTEGER(KaxTagDefaultBogus)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UNISTRING(KaxTagString)
Expand Down Expand Up @@ -1170,7 +1170,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

0 comments on commit 1f08f90

Please sign in to comment.