Constantin Kaplinsky | 39e31a1 | 2007-12-13 19:16:33 +0000 | [diff] [blame^] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <string.h> |
| 4 | #include <sys/poll.h> |
| 5 | |
| 6 | #include <rfb/IrixCLJpegCompressor.h> |
| 7 | |
| 8 | using namespace rfb; |
| 9 | |
| 10 | const int IrixCLJpegCompressor::DEFAULT_QUALITY = 75; |
| 11 | |
| 12 | // |
| 13 | // Constructor and destructor. |
| 14 | // |
| 15 | |
| 16 | IrixCLJpegCompressor::IrixCLJpegCompressor() |
| 17 | : m_quality(DEFAULT_QUALITY), |
| 18 | m_compressedData(0), |
| 19 | m_compressedLength(0) |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | IrixCLJpegCompressor::~IrixCLJpegCompressor() |
| 24 | { |
| 25 | if (m_compressedData) |
| 26 | delete[] m_compressedData; |
| 27 | } |
| 28 | |
| 29 | // |
| 30 | // Set JPEG quality level (1..99) |
| 31 | // |
| 32 | |
| 33 | void |
| 34 | IrixCLJpegCompressor::setQuality(int level) |
| 35 | { |
| 36 | if (level < 1) { |
| 37 | level = 1; |
| 38 | } else if (level > 99) { |
| 39 | level = 99; |
| 40 | } |
| 41 | if (level != m_quality) { |
| 42 | m_quality = level; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // |
| 47 | // Perform JPEG compression. |
| 48 | // |
| 49 | // FIXME: This function assumes that pixel format is 32-bit XBGR |
| 50 | // (depth 24), compatible with IRIX Digital Media libraries. |
| 51 | // |
| 52 | |
| 53 | void |
| 54 | IrixCLJpegCompressor::compress(const rdr::U32 *buf, |
| 55 | const PixelFormat *fmt, |
| 56 | int w, int h, int stride) |
| 57 | { |
| 58 | // Discard previous compression results. |
| 59 | if (m_compressedData) { |
| 60 | delete[] m_compressedData; |
| 61 | m_compressedData = 0; |
| 62 | } |
| 63 | m_compressedLength = 0; |
| 64 | |
| 65 | // FIXME: Do something. |
| 66 | } |
| 67 | |