cscore: Support multiple levels of JPEG compression (#1223)

This allows two streams with different compression levels, and also allows
a stream to receive a different compression level than provided by a JPEG
camera (decompress and recompress).
This commit is contained in:
Peter Johnson
2018-07-27 21:51:40 -07:00
committed by GitHub
parent 04ee8dbe79
commit c9a75a119a
4 changed files with 89 additions and 27 deletions

View File

@@ -79,6 +79,14 @@ class Image {
bool Is(int width_, int height_, VideoMode::PixelFormat pixelFormat_) {
return width == width_ && height == height_ && pixelFormat == pixelFormat_;
}
bool Is(int width_, int height_, VideoMode::PixelFormat pixelFormat_,
int jpegQuality_) {
// Consider +/-5 on JPEG quality to be "close enough"
return width == width_ && height == height_ &&
pixelFormat == pixelFormat_ &&
(pixelFormat != VideoMode::kMJPEG || jpegQuality_ == -1 ||
(jpegQuality != -1 && std::abs(jpegQuality - jpegQuality_) <= 5));
}
bool IsLarger(int width_, int height_) {
return width >= width_ && height >= height_;
}
@@ -95,6 +103,7 @@ class Image {
VideoMode::PixelFormat pixelFormat{VideoMode::kUnknown};
int width{0};
int height{0};
int jpegQuality{-1};
};
} // namespace cs