Skip to content

Commit

Permalink
Make HDR side data unique pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
CrendKing committed Jun 30, 2021
1 parent a690e21 commit 567f713
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions avisynth_filter/src/frame_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ auto FrameHandler::AddInputSample(IMediaSample *inputSample) -> HRESULT {

const PVideoFrame frame = Format::CreateFrame(_filter._inputVideoFormat, sampleBuffer);

std::shared_ptr<HDRSideData> hdrSideData = std::make_shared<HDRSideData>();
std::unique_ptr<HDRSideData> hdrSideData = std::make_unique<HDRSideData>();
{
if (const ATL::CComQIPtr<IMediaSideData> inputSampleSideData(inputSample); inputSampleSideData != nullptr) {
hdrSideData->ReadFrom(inputSampleSideData);
Expand All @@ -89,7 +89,7 @@ auto FrameHandler::AddInputSample(IMediaSample *inputSample) -> HRESULT {

_sourceFrames.emplace(std::piecewise_construct,
std::forward_as_tuple(_nextSourceFrameNb),
std::forward_as_tuple(frame, inputSampleStartTime, hdrSideData));
std::forward_as_tuple(frame, inputSampleStartTime, std::move(hdrSideData)));
}
_newSourceFrameCv.notify_all();

Expand Down
2 changes: 1 addition & 1 deletion avisynth_filter/src/frame_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FrameHandler {
struct SourceFrameInfo {
PVideoFrame frame;
REFERENCE_TIME startTime;
std::shared_ptr<HDRSideData> hdrSideData;
std::unique_ptr<HDRSideData> hdrSideData;
};

static auto RefreshFrameRatesTemplate(int sampleNb, int &checkpointSampleNb, DWORD &checkpointTime, int &currentFrameRate) -> void;
Expand Down
4 changes: 2 additions & 2 deletions vapoursynth_filter/src/frame_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ auto FrameHandler::AddInputSample(IMediaSample *inputSample) -> HRESULT {
AVSF_VS_API->propSetInt(frameProps, "_SARDen", _filter._inputVideoFormat.pixelAspectRatioDen, paReplace);
AVSF_VS_API->propSetInt(frameProps, VS_PROP_NAME_SOURCE_FRAME_NB, _nextSourceFrameNb, paReplace);

std::shared_ptr<HDRSideData> hdrSideData = std::make_shared<HDRSideData>();
std::unique_ptr<HDRSideData> hdrSideData = std::make_unique<HDRSideData>();
{
if (const ATL::CComQIPtr<IMediaSideData> inputSampleSideData(inputSample); inputSampleSideData != nullptr) {
hdrSideData->ReadFrom(inputSampleSideData);
Expand All @@ -93,7 +93,7 @@ auto FrameHandler::AddInputSample(IMediaSample *inputSample) -> HRESULT {

_sourceFrames.emplace(std::piecewise_construct,
std::forward_as_tuple(_nextSourceFrameNb),
std::forward_as_tuple(frame, inputSampleStartTime, hdrSideData));
std::forward_as_tuple(frame, inputSampleStartTime, std::move(hdrSideData)));
}

Environment::GetInstance().Log(L"Stored source frame: %6i at %10lli ~ %10lli duration(literal) %10lli, last_used %6i, extra_buffer %6i",
Expand Down
2 changes: 1 addition & 1 deletion vapoursynth_filter/src/frame_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FrameHandler {

VSFrameRef *frame;
REFERENCE_TIME startTime;
std::shared_ptr<HDRSideData> hdrSideData;
std::unique_ptr<HDRSideData> hdrSideData;
};

static auto VS_CC VpsGetFrameCallback(void *userData, const VSFrameRef *f, int n, VSNodeRef *node, const char *errorMsg) -> void;
Expand Down

2 comments on commit 567f713

@ssssssbbb
Copy link

@ssssssbbb ssssssbbb commented on 567f713 Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VPSF Video random freeze since this version or maybe the last one, it's too random to be sure.

And it's hard to capture a freezing log, once I have one I'll open a new issue.

@CrendKing
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do.

Please sign in to comment.