aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2025-01-06 14:43:57 +0100
committerPierre Ossman <ossman@cendio.se>2025-01-10 17:02:11 +0100
commit784897bbac9382a6398ee87b99e0b27b6fa5c8b8 (patch)
treee0ee4cbff47045f4e5d1b5d6ce3f442ea9439851
parentf57dddb6143257d185ed665b7cfd24364db574dc (diff)
downloadtigervnc-784897bbac9382a6398ee87b99e0b27b6fa5c8b8.tar.gz
tigervnc-784897bbac9382a6398ee87b99e0b27b6fa5c8b8.zip
Always reset H.264 contexts the same way
Reset individual contexts the same way we reset all contexts, i.e. by deleting and recreating them. Avoids surprises by having a consistent method.
-rw-r--r--common/rfb/H264Decoder.cxx9
-rw-r--r--common/rfb/H264Decoder.h4
-rw-r--r--common/rfb/H264DecoderContext.cxx6
-rw-r--r--common/rfb/H264DecoderContext.h1
4 files changed, 8 insertions, 12 deletions
diff --git a/common/rfb/H264Decoder.cxx b/common/rfb/H264Decoder.cxx
index 44c0848d..9b630045 100644
--- a/common/rfb/H264Decoder.cxx
+++ b/common/rfb/H264Decoder.cxx
@@ -114,6 +114,12 @@ 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)
{
if (contexts.size() >= MAX_H264_INSTANCES)
@@ -131,9 +137,6 @@ void H264Decoder::decodeRect(const Rect& r, const uint8_t* buffer,
if (!ctx->isReady())
throw std::runtime_error("H264Decoder: Context is not ready");
- if (reset & resetContext)
- ctx->reset();
-
if (!len)
return;
diff --git a/common/rfb/H264Decoder.h b/common/rfb/H264Decoder.h
index 46d25e33..6f2dabfb 100644
--- a/common/rfb/H264Decoder.h
+++ b/common/rfb/H264Decoder.h
@@ -21,7 +21,7 @@
#ifndef __RFB_H264DECODER_H__
#define __RFB_H264DECODER_H__
-#include <deque>
+#include <list>
#include <rfb/Decoder.h>
@@ -43,7 +43,7 @@ namespace rfb {
void resetContexts();
H264DecoderContext* findContext(const Rect& r);
- std::deque<H264DecoderContext*> contexts;
+ std::list<H264DecoderContext*> contexts;
};
}
diff --git a/common/rfb/H264DecoderContext.cxx b/common/rfb/H264DecoderContext.cxx
index 8d7a6a7b..ced3188e 100644
--- a/common/rfb/H264DecoderContext.cxx
+++ b/common/rfb/H264DecoderContext.cxx
@@ -53,9 +53,3 @@ bool H264DecoderContext::isReady()
{
return initialized;
}
-
-void H264DecoderContext::reset()
-{
- freeCodec();
- initCodec();
-}
diff --git a/common/rfb/H264DecoderContext.h b/common/rfb/H264DecoderContext.h
index aa1931c8..0b9dce82 100644
--- a/common/rfb/H264DecoderContext.h
+++ b/common/rfb/H264DecoderContext.h
@@ -36,7 +36,6 @@ namespace rfb {
virtual void decode(const uint8_t* /*h264_buffer*/,
uint32_t /*len*/,
ModifiablePixelBuffer* /*pb*/) {}
- void reset();
inline bool isEqualRect(const Rect &r) const { return r == rect; }
bool isReady();