From: Pierre Ossman Date: Wed, 15 Jan 2014 12:44:04 +0000 (+0100) Subject: Clean up the encoding parser in ConnParams X-Git-Tag: v1.3.90~48^2~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6bcf137779ee884f27d53d667558524d3413812e;p=tigervnc.git Clean up the encoding parser in ConnParams --- diff --git a/common/rfb/ConnParams.cxx b/common/rfb/ConnParams.cxx index 4d14dac5..be9d48c0 100644 --- a/common/rfb/ConnParams.cxx +++ b/common/rfb/ConnParams.cxx @@ -104,66 +104,73 @@ void ConnParams::setEncodings(int nEncodings, const rdr::S32* encodings) currentEncoding_ = encodingRaw; for (int i = nEncodings-1; i >= 0; i--) { - if (encodings[i] == encodingCopyRect) + switch (encodings[i]) { + case encodingCopyRect: useCopyRect = true; - else if (encodings[i] == pseudoEncodingCursor) + break; + case pseudoEncodingCursor: supportsLocalCursor = true; - else if (encodings[i] == pseudoEncodingXCursor) + break; + case pseudoEncodingXCursor: supportsLocalXCursor = true; - else if (encodings[i] == pseudoEncodingDesktopSize) + break; + case pseudoEncodingDesktopSize: supportsDesktopResize = true; - else if (encodings[i] == pseudoEncodingExtendedDesktopSize) + break; + case pseudoEncodingExtendedDesktopSize: supportsExtendedDesktopSize = true; - else if (encodings[i] == pseudoEncodingDesktopName) + break; + case pseudoEncodingDesktopName: supportsDesktopRename = true; - else if (encodings[i] == pseudoEncodingLastRect) + break; + case pseudoEncodingLastRect: supportsLastRect = true; - else if (encodings[i] == pseudoEncodingFence) + break; + case pseudoEncodingFence: supportsFence = true; - else if (encodings[i] == pseudoEncodingContinuousUpdates) + break; + case pseudoEncodingContinuousUpdates: supportsContinuousUpdates = true; - else if (encodings[i] >= pseudoEncodingCompressLevel0 && - encodings[i] <= pseudoEncodingCompressLevel9) { - customCompressLevel = true; + break; + case pseudoEncodingSubsamp1X: + subsampling = subsampleNone; + break; + case pseudoEncodingSubsampGray: + subsampling = subsampleGray; + break; + case pseudoEncodingSubsamp2X: + subsampling = subsample2X; + break; + case pseudoEncodingSubsamp4X: + subsampling = subsample4X; + break; + case pseudoEncodingSubsamp8X: + subsampling = subsample8X; + break; + case pseudoEncodingSubsamp16X: + subsampling = subsample16X; + break; + } + + if (encodings[i] >= pseudoEncodingCompressLevel0 && + encodings[i] <= pseudoEncodingCompressLevel9) compressLevel = encodings[i] - pseudoEncodingCompressLevel0; - } else if (encodings[i] >= pseudoEncodingQualityLevel0 && - encodings[i] <= pseudoEncodingQualityLevel9) { - noJpeg = false; + + if (encodings[i] >= pseudoEncodingQualityLevel0 && + encodings[i] <= pseudoEncodingQualityLevel9) qualityLevel = encodings[i] - pseudoEncodingQualityLevel0; - } else if (Encoder::supported(encodings[i])) - currentEncoding_ = encodings[i]; - } - // If the TurboVNC fine quality/subsampling encodings exist, let them - // override the coarse TightVNC quality level - for (int i = nEncodings-1; i >= 0; i--) { - if (encodings[i] >= pseudoEncodingFineQualityLevel0 + 1 && - encodings[i] <= pseudoEncodingFineQualityLevel100) { - noJpeg = false; + if (encodings[i] >= pseudoEncodingFineQualityLevel0 && + encodings[i] <= pseudoEncodingFineQualityLevel100) fineQualityLevel = encodings[i] - pseudoEncodingFineQualityLevel0; - } else if (encodings[i] >= pseudoEncodingSubsamp1X && - encodings[i] <= pseudoEncodingSubsamp16X) { - noJpeg = false; - switch (encodings[i]) { - case pseudoEncodingSubsamp1X: - subsampling = subsampleNone; - break; - case pseudoEncodingSubsampGray: - subsampling = subsampleGray; - break; - case pseudoEncodingSubsamp2X: - subsampling = subsample2X; - break; - case pseudoEncodingSubsamp4X: - subsampling = subsample4X; - break; - case pseudoEncodingSubsamp8X: - subsampling = subsample8X; - break; - case pseudoEncodingSubsamp16X: - subsampling = subsample16X; - break; - } - } + + if (Encoder::supported(encodings[i])) + currentEncoding_ = encodings[i]; } + + if (compressLevel != -1) + customCompressLevel = true; + if ((qualityLevel != -1) || (fineQualityLevel != -1) || + (subsampling != subsampleUndefined)) + noJpeg = false; }