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 "mythconfig.h"
28 #include "mythtvexp.h"
29 #include <cstdint>
30 
31 /*
32  * Macros and definitions used internally to RTjpeg
33  */
34 
35 #define RTJPEG_FILE_VERSION 0
36 #define RTJPEG_HEADER_SIZE 12
37 
38 #if HAVE_BIGENDIAN
39 #define RTJPEG_SWAP_WORD(a) ( ((a) << 24) | \
40  (((a) << 8) & 0x00ff0000) | \
41  (((a) >> 8) & 0x0000ff00) | \
42  ((unsigned long)(a) >>24) )
43 #define RTJPEG_SWAP_HALFWORD(a) ( (((a) << 8) & 0xff00) | \
44  (((a) >> 8) & 0x00ff) )
45 #else
46 #define RTJPEG_SWAP_WORD(a) (a)
47 #define RTJPEG_SWAP_HALFWORD(a) (a)
48 #endif
49 
50 #if HAVE_STDINT_H
51 #include <cstdint>
52 #endif
53 
54 #ifdef MMX
55 #include "ffmpeg-mmx.h"
56 #endif
57 
58 /* Format definitions */
59 
60 #define RTJ_YUV420 0
61 #define RTJ_YUV422 1
62 #define RTJ_RGB8 2
63 
64 class RTjpeg
65 {
66  public:
67  RTjpeg();
68  ~RTjpeg();
69 
70  int SetQuality(int *quality);
71  int SetFormat(const int *fmt);
72  int SetSize(const int *w, const int *h);
73  int SetIntra(int *key, int *lm, int *cm);
74 
75  int Compress(int8_t *sp, uint8_t **planes);
76  void Decompress(int8_t *sp, uint8_t **planes);
77 
78  void SetNextKey(void);
79 
80 private:
81  static int b2s(const int16_t *data, int8_t *strm, uint8_t bt8);
82  static int s2b(int16_t *data, const int8_t *strm, uint8_t bt8, int32_t *qtbla);
83 
84  void QuantInit(void);
85  static void Quant(int16_t *block, int32_t *qtbl);
86 
87  void DctInit(void);
88  void DctY(uint8_t *idata, int rskip);
89 
90  void IdctInit(void);
91  void Idct(uint8_t *odata, int16_t *data, int rskip);
92 
93  void CalcTbls(void);
94 
95  inline int compressYUV420(int8_t *sp, uint8_t **planes);
96  inline int compressYUV422(int8_t *sp, uint8_t **planes);
97  inline int compress8(int8_t *sp, uint8_t **planes);
98 
99  int mcompressYUV420(int8_t *sp, uint8_t **planes);
100  int mcompressYUV422(int8_t *sp, uint8_t **planes);
101  int mcompress8(int8_t *sp, uint8_t **planes);
102 
103  void decompressYUV422(int8_t *sp, uint8_t **planes);
104  void decompressYUV420(int8_t *sp, uint8_t **planes);
105  void decompress8(int8_t *sp, uint8_t **planes);
106 
107 #ifdef MMX
108  static int bcomp(int16_t *rblock, int16_t *old, mmx_t *mask);
109 #else
110  static int bcomp(int16_t *rblock, int16_t *old, uint16_t *mask);
111 #endif
112 
113  int16_t m_block[64] MALIGN32 {0};
114  int32_t m_ws[64*4] MALIGN32 {0};
115  int32_t m_lqt[64] MALIGN32 {0};
116  int32_t m_cqt[64] MALIGN32 {0};
117  int32_t m_liqt[64] MALIGN32 {0};
118  int32_t m_ciqt[64] MALIGN32 {0};
119  int32_t m_lB8 {0};
120  int32_t m_cB8 {0};
121  int32_t m_yWidth {0};
122  int32_t m_cWidth {0};
123  int32_t m_ySize {0};
124  int32_t m_cSize {0};
125  int16_t *m_old {nullptr};
126  int16_t *m_oldStart {nullptr};
127  int m_keyCount {0};
128 
129  int m_width {0};
130  int m_height {0};
131  int m_q {0};
132  int m_f {0};
133 #ifdef MMX
134  mmx_t m_lMask {};
135  mmx_t m_cMask {};
136 #else
137  uint16_t m_lMask {0};
138  uint16_t m_cMask {0};
139 #endif
140  int m_keyRate {0};
141 };
142 
144  uint32_t framesize;
145  uint8_t headersize;
146  uint8_t version;
149  uint8_t quality;
150  uint8_t key;
151  uint8_t data;
152 };
153 
154 #endif
void decompress8(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3016
int mcompressYUV420(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3097
uint8_t version
Definition: RTjpegN.h:146
int32_t m_cWidth
Definition: RTjpegN.h:122
void SetNextKey(void)
Definition: RTjpegN.cpp:3264
int compressYUV420(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2784
void decompressYUV420(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2954
int SetIntra(int *key, int *lm, int *cm)
Definition: RTjpegN.cpp:2724
~RTjpeg()
Definition: RTjpegN.cpp:2779
int16_t * m_old
Definition: RTjpegN.h:125
int compressYUV422(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2835
uint16_t width
Definition: RTjpegN.h:147
int SetSize(const int *w, const int *h)
Definition: RTjpegN.cpp:2689
int32_t m_cSize
Definition: RTjpegN.h:124
static uint planes(VideoFrameType Type)
Definition: mythframe.h:567
int32_t m_lB8
Definition: RTjpegN.h:119
static void Quant(int16_t *block, int32_t *qtbl)
Definition: RTjpegN.cpp:527
mmx_t m_lMask
Definition: RTjpegN.h:134
int compress8(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2878
int m_f
Definition: RTjpegN.h:132
int16_t * m_oldStart
Definition: RTjpegN.h:126
int m_width
Definition: RTjpegN.h:129
uint16_t height
Definition: RTjpegN.h:148
int Compress(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3269
int SetFormat(const int *fmt)
Definition: RTjpegN.cpp:2683
void Idct(uint8_t *odata, int16_t *data, int rskip)
Definition: RTjpegN.cpp:1517
int32_t m_cB8
Definition: RTjpegN.h:120
RTjpeg()
Definition: RTjpegN.cpp:2766
uint8_t headersize
Definition: RTjpegN.h:145
int mcompressYUV422(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3179
void decompressYUV422(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2906
mmx_t m_cMask
Definition: RTjpegN.h:135
uint8_t quality
Definition: RTjpegN.h:149
Definition: RTjpegN.h:64
int m_q
Definition: RTjpegN.h:131
int32_t m_ySize
Definition: RTjpegN.h:123
unsigned short uint16_t
Definition: iso6937tables.h:1
int32_t m_yWidth
Definition: RTjpegN.h:121
int SetQuality(int *quality)
Definition: RTjpegN.cpp:2666
static int b2s(const int16_t *data, int8_t *strm, uint8_t bt8)
Definition: RTjpegN.cpp:110
int m_height
Definition: RTjpegN.h:130
uint32_t framesize
Definition: RTjpegN.h:144
void DctInit(void)
Definition: RTjpegN.cpp:587
int16_t m_block [64] MALIGN32
Definition: RTjpegN.h:113
static int bcomp(int16_t *rblock, int16_t *old, mmx_t *mask)
Definition: RTjpegN.cpp:3042
void DctY(uint8_t *idata, int rskip)
Definition: RTjpegN.cpp:596
int m_keyRate
Definition: RTjpegN.h:140
static int s2b(int16_t *data, const int8_t *strm, uint8_t bt8, int32_t *qtbla)
Definition: RTjpegN.cpp:278
void CalcTbls(void)
Definition: RTjpegN.cpp:2635
void IdctInit(void)
Definition: RTjpegN.cpp:1508
int m_keyCount
Definition: RTjpegN.h:127
void QuantInit(void)
Definition: RTjpegN.cpp:512
void Decompress(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3306
int mcompress8(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3238