MythTV  master
RTjpegN.h
Go to the documentation of this file.
1 /*
2  RTjpeg (C) Justin Schoeman 1998 (justin@suntiger.ee.up.ac.za)
3 
4  With modifications by:
5  (c) 1998, 1999 by Joerg Walter <trouble@moes.pmnet.uni-oldenburg.de>
6  and
7  (c) 1999 by Wim Taymans <wim.taymans@tvd.be>
8 
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13 
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18 
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 
24 #ifndef RTJPEG_H
25 #define RTJPEG_H
26 
27 #include "mythtvexp.h"
29 #include <cstdint>
30 
31 /*
32  * Macros and definitions used internally to RTjpeg
33  */
34 
35 static constexpr uint8_t RTJPEG_FILE_VERSION { 0 };
36 static constexpr uint8_t RTJPEG_HEADER_SIZE { 12 };
37 
38 using RTjpegData16 = std::array<int16_t,64>;
39 using RTjpegData32 = std::array<int32_t,64>;
40 
41 #ifdef MMX
42 #include "libmythbase/ffmpeg-mmx.h"
43 #endif
44 
45 /* Format definitions */
46 
47 enum RTJFormat {
51 };
52 
53 class RTjpeg
54 {
55  public:
56  RTjpeg();
57  ~RTjpeg();
58 
59  int SetQuality(int *quality);
60  int SetFormat(const int *fmt);
61  int SetSize(const int *w, const int *h);
62  int SetIntra(int *key, int *lm, int *cm);
63 
64  int Compress(int8_t *sp, uint8_t **planes);
65  void Decompress(int8_t *sp, uint8_t **planes);
66 
67  void SetNextKey(void);
68 
69 private:
70  static int b2s(const RTjpegData16 &data, int8_t *strm, uint8_t bt8);
71  static int s2b(RTjpegData16 &data, const int8_t *strm, uint8_t bt8, RTjpegData32 &qtbla);
72 
73  void QuantInit(void);
74  static void Quant(RTjpegData16 &block, RTjpegData32 &qtbl);
75 
76  void DctInit(void);
77  void DctY(uint8_t *idata, int rskip);
78 
79  void IdctInit(void);
80  void Idct(uint8_t *odata, RTjpegData16 &data, int rskip);
81 
82  void CalcTbls(void);
83 
84  inline int compressYUV420(int8_t *sp, uint8_t **planes);
85  inline int compressYUV422(int8_t *sp, uint8_t **planes);
86  inline int compress8(int8_t *sp, uint8_t **planes);
87 
88  int mcompressYUV420(int8_t *sp, uint8_t **planes);
89  int mcompressYUV422(int8_t *sp, uint8_t **planes);
90  int mcompress8(int8_t *sp, uint8_t **planes);
91 
92  void decompressYUV422(int8_t *sp, uint8_t **planes);
93  void decompressYUV420(int8_t *sp, uint8_t **planes);
94  void decompress8(int8_t *sp, uint8_t **planes);
95 
96 #ifdef MMX
97  static int bcomp(RTjpegData16 &rblock, int16_t *old, mmx_t *mask);
98 #else
99  static int bcomp(RTjpegData16 &rblock, int16_t *old, uint16_t *mask);
100 #endif
101 
102  alignas(32) RTjpegData16 m_block {0};
103  alignas(32) std::array<int32_t,64_UZ * 4> m_ws {0};
104  alignas(32) RTjpegData32 m_lqt {0};
105  alignas(32) RTjpegData32 m_cqt {0};
106  alignas(32) RTjpegData32 m_liqt {0};
107  alignas(32) RTjpegData32 m_ciqt {0};
108  int32_t m_lB8 {0};
109  int32_t m_cB8 {0};
110  int32_t m_yWidth {0};
111  int32_t m_cWidth {0};
112  int32_t m_ySize {0};
113  int32_t m_cSize {0};
114  int16_t *m_old {nullptr};
115  int m_keyCount {0};
116 
117  int m_width {0};
118  int m_height {0};
119  int m_q {0};
120  int m_f {0};
121 #ifdef MMX
122  mmx_t m_lMask {};
123  mmx_t m_cMask {};
124 #else
125  uint16_t m_lMask {0};
126  uint16_t m_cMask {0};
127 #endif
128  int m_keyRate {0};
129 };
130 
132  uint32_t framesize;
133  uint8_t headersize;
134  uint8_t version;
137  uint8_t quality;
138  uint8_t key;
139  uint8_t data;
140 };
141 
142 #endif // RTJPEG_H
RTjpeg_frameheader::headersize
uint8_t headersize
Definition: RTjpegN.h:133
RTjpeg::mcompressYUV422
int mcompressYUV422(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3176
RTjpeg::s2b
static int s2b(RTjpegData16 &data, const int8_t *strm, uint8_t bt8, RTjpegData32 &qtbla)
Definition: RTjpegN.cpp:284
RTjpeg::DctY
void DctY(uint8_t *idata, int rskip)
Definition: RTjpegN.cpp:602
RTjpeg_frameheader::key
uint8_t key
Definition: RTjpegN.h:138
RTjpegData16
std::array< int16_t, 64 > RTjpegData16
Definition: RTjpegN.h:38
RTjpeg::m_lB8
int32_t m_lB8
Definition: RTjpegN.h:108
RTjpeg::m_yWidth
int32_t m_yWidth
Definition: RTjpegN.h:110
RTjpeg::compress8
int compress8(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2875
mythtvexp.h
RTjpeg::m_lMask
mmx_t m_lMask
Definition: RTjpegN.h:122
RTjpeg::m_ySize
int32_t m_ySize
Definition: RTjpegN.h:112
RTjpeg::b2s
static int b2s(const RTjpegData16 &data, int8_t *strm, uint8_t bt8)
Definition: RTjpegN.cpp:116
RTjpeg::SetNextKey
void SetNextKey(void)
Definition: RTjpegN.cpp:3261
RTjpeg::m_q
int m_q
Definition: RTjpegN.h:119
RTjpeg_frameheader
Definition: RTjpegN.h:131
RTJ_RGB8
@ RTJ_RGB8
Definition: RTjpegN.h:50
RTjpeg_frameheader::width
uint16_t width
Definition: RTjpegN.h:135
RTjpeg::m_height
int m_height
Definition: RTjpegN.h:118
RTjpeg_frameheader::quality
uint8_t quality
Definition: RTjpegN.h:137
RTjpeg::m_cB8
int32_t m_cB8
Definition: RTjpegN.h:109
RTjpeg::DctInit
void DctInit(void)
Definition: RTjpegN.cpp:593
RTjpeg::CalcTbls
void CalcTbls(void)
Definition: RTjpegN.cpp:2644
RTjpeg::QuantInit
void QuantInit(void)
Definition: RTjpegN.cpp:518
RTJPEG_FILE_VERSION
static constexpr uint8_t RTJPEG_FILE_VERSION
Definition: RTjpegN.h:35
RTjpeg::bcomp
static int bcomp(RTjpegData16 &rblock, int16_t *old, mmx_t *mask)
Definition: RTjpegN.cpp:3039
RTJ_YUV420
@ RTJ_YUV420
Definition: RTjpegN.h:48
RTjpeg::mcompress8
int mcompress8(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3235
ffmpeg-mmx.h
RTjpeg::mcompressYUV420
int mcompressYUV420(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3094
RTjpeg::compressYUV420
int compressYUV420(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2781
RTjpeg::decompress8
void decompress8(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3013
RTjpeg::m_cWidth
int32_t m_cWidth
Definition: RTjpegN.h:111
RTJFormat
RTJFormat
Definition: RTjpegN.h:47
sizetliteral.h
RTJ_YUV422
@ RTJ_YUV422
Definition: RTjpegN.h:49
RTjpeg::Idct
void Idct(uint8_t *odata, RTjpegData16 &data, int rskip)
Definition: RTjpegN.cpp:1526
RTjpeg::m_width
int m_width
Definition: RTjpegN.h:117
RTjpeg::~RTjpeg
~RTjpeg()
Definition: RTjpegN.cpp:2776
RTjpeg::m_ws
std::array< int32_t, 64_UZ *4 > m_ws
Definition: RTjpegN.h:103
RTjpeg
Definition: RTjpegN.h:53
RTjpeg::Quant
static void Quant(RTjpegData16 &block, RTjpegData32 &qtbl)
Definition: RTjpegN.cpp:533
RTjpeg::m_block
RTjpegData16 m_block
Definition: RTjpegN.h:102
RTjpeg::decompressYUV420
void decompressYUV420(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2951
RTjpeg::SetIntra
int SetIntra(int *key, int *lm, int *cm)
Definition: RTjpegN.cpp:2726
RTjpeg::m_lqt
RTjpegData32 m_lqt
Definition: RTjpegN.h:104
RTjpeg_frameheader::version
uint8_t version
Definition: RTjpegN.h:134
RTjpeg::m_keyCount
int m_keyCount
Definition: RTjpegN.h:115
RTjpeg_frameheader::height
uint16_t height
Definition: RTjpegN.h:136
RTjpeg::SetFormat
int SetFormat(const int *fmt)
Definition: RTjpegN.cpp:2692
RTjpeg::m_ciqt
RTjpegData32 m_ciqt
Definition: RTjpegN.h:107
RTjpeg::m_old
int16_t * m_old
Definition: RTjpegN.h:114
RTjpeg::m_keyRate
int m_keyRate
Definition: RTjpegN.h:128
RTjpeg::SetSize
int SetSize(const int *w, const int *h)
Definition: RTjpegN.cpp:2698
RTjpeg::IdctInit
void IdctInit(void)
Definition: RTjpegN.cpp:1517
RTjpeg::decompressYUV422
void decompressYUV422(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2903
RTjpeg::Decompress
void Decompress(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3303
RTjpeg_frameheader::framesize
uint32_t framesize
Definition: RTjpegN.h:132
RTjpeg::compressYUV422
int compressYUV422(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2832
RTjpeg_frameheader::data
uint8_t data
Definition: RTjpegN.h:139
uint16_t
unsigned short uint16_t
Definition: iso6937tables.h:3
RTjpeg::m_cSize
int32_t m_cSize
Definition: RTjpegN.h:113
RTjpeg::m_cMask
mmx_t m_cMask
Definition: RTjpegN.h:123
RTjpeg::m_cqt
RTjpegData32 m_cqt
Definition: RTjpegN.h:105
RTjpeg::m_liqt
RTjpegData32 m_liqt
Definition: RTjpegN.h:106
RTjpeg::SetQuality
int SetQuality(int *quality)
Definition: RTjpegN.cpp:2675
RTjpeg::Compress
int Compress(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3266
RTjpegData32
std::array< int32_t, 64 > RTjpegData32
Definition: RTjpegN.h:39
RTjpeg::m_f
int m_f
Definition: RTjpegN.h:120
RTJPEG_HEADER_SIZE
static constexpr uint8_t RTJPEG_HEADER_SIZE
Definition: RTjpegN.h:36
RTjpeg::RTjpeg
RTjpeg()
Definition: RTjpegN.cpp:2763