aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/H264Decoder.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/rfb/H264Decoder.cxx')
-rw-r--r--common/rfb/H264Decoder.cxx24
1 files changed, 9 insertions, 15 deletions
diff --git a/common/rfb/H264Decoder.cxx b/common/rfb/H264Decoder.cxx
index 89850ba4..d0d9b4df 100644
--- a/common/rfb/H264Decoder.cxx
+++ b/common/rfb/H264Decoder.cxx
@@ -29,14 +29,11 @@
#include <rdr/MemInStream.h>
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
-#include <rfb/LogWriter.h>
#include <rfb/H264Decoder.h>
#include <rfb/H264DecoderContext.h>
using namespace rfb;
-static LogWriter vlog("H264Decoder");
-
enum rectFlags {
resetContext = 0x1,
resetAllContexts = 0x2,
@@ -53,22 +50,20 @@ H264Decoder::~H264Decoder()
void H264Decoder::resetContexts()
{
- os::AutoMutex lock(&mutex);
for (H264DecoderContext* context : contexts)
delete context;
contexts.clear();
}
-H264DecoderContext* H264Decoder::findContext(const Rect& r)
+H264DecoderContext* H264Decoder::findContext(const core::Rect& r)
{
- os::AutoMutex m(&mutex);
for (H264DecoderContext* context : contexts)
if (context->isEqualRect(r))
return context;
return nullptr;
}
-bool H264Decoder::readRect(const Rect& /*r*/,
+bool H264Decoder::readRect(const core::Rect& /*r*/,
rdr::InStream* is,
const ServerParams& /*server*/,
rdr::OutStream* os)
@@ -96,7 +91,7 @@ bool H264Decoder::readRect(const Rect& /*r*/,
return true;
}
-void H264Decoder::decodeRect(const Rect& r, const uint8_t* buffer,
+void H264Decoder::decodeRect(const core::Rect& r, const uint8_t* buffer,
size_t buflen,
const ServerParams& /*server*/,
ModifiablePixelBuffer* pb)
@@ -116,9 +111,14 @@ void H264Decoder::decodeRect(const Rect& r, const uint8_t* buffer,
ctx = findContext(r);
}
+ if (ctx && (reset & resetContext)) {
+ contexts.remove(ctx);
+ delete ctx;
+ ctx = nullptr;
+ }
+
if (!ctx)
{
- os::AutoMutex lock(&mutex);
if (contexts.size() >= MAX_H264_INSTANCES)
{
H264DecoderContext* excess_ctx = contexts.front();
@@ -131,12 +131,6 @@ void H264Decoder::decodeRect(const Rect& r, const uint8_t* buffer,
contexts.push_back(ctx);
}
- if (!ctx->isReady())
- throw std::runtime_error("H264Decoder: Context is not ready");
-
- if (reset & resetContext)
- ctx->reset();
-
if (!len)
return;