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  int b2s(const int16_t *data, int8_t *strm, uint8_t bt8);
82  int s2b(int16_t *data, const int8_t *strm, uint8_t bt8, int32_t *qtbla);
83 
84  void QuantInit(void);
85  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  int bcomp(int16_t *rblock, int16_t *old, mmx_t *mask);
109 #else
110  int bcomp(int16_t *rblock, int16_t *old, uint16_t *mask);
111 #endif
112 
113  int16_t block[64] MALIGN32 {0};
114  int32_t ws[64*4] MALIGN32 {0};
115  int32_t lqt[64] MALIGN32 {0};
116  int32_t cqt[64] MALIGN32 {0};
117  int32_t liqt[64] MALIGN32 {0};
118  int32_t ciqt[64] MALIGN32 {0};
119  int32_t lb8 {0};
120  int32_t cb8 {0};
121  int32_t Ywidth {0};
122  int32_t Cwidth {0};
123  int32_t Ysize {0};
124  int32_t Csize {0};
125  int16_t *old {nullptr};
126  int16_t *old_start {nullptr};
127  int key_count {0};
128 
129  int width {0};
130  int height {0};
131  int Q {0};
132  int f {0};
133 #ifdef MMX
136 #else
137  uint16_t lmask {0};
138  uint16_t cmask {0};
139 #endif
140  int key_rate {0};
141 };
142 
143 typedef struct {
144  uint32_t framesize;
145  uint8_t headersize;
146  uint8_t version;
149  uint8_t quality;
150  uint8_t key;
151  uint8_t data;
153 
154 #endif
void decompress8(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3051
int mcompressYUV420(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3134
uint8_t version
Definition: RTjpegN.h:146
int height
Definition: RTjpegN.h:130
int32_t lb8
Definition: RTjpegN.h:119
int f
Definition: RTjpegN.h:132
void SetNextKey(void)
Definition: RTjpegN.cpp:3310
int key_count
Definition: RTjpegN.h:127
int compressYUV420(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2812
void decompressYUV420(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2988
int SetIntra(int *key, int *lm, int *cm)
Definition: RTjpegN.cpp:2750
mmx_t lmask
Definition: RTjpegN.h:134
~RTjpeg()
Definition: RTjpegN.cpp:2807
int Q
Definition: RTjpegN.h:131
int16_t * old
Definition: RTjpegN.h:125
int compressYUV422(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2865
uint16_t width
Definition: RTjpegN.h:147
int SetSize(const int *w, const int *h)
Definition: RTjpegN.cpp:2714
int key_rate
Definition: RTjpegN.h:140
int32_t Csize
Definition: RTjpegN.h:124
void Quant(int16_t *block, int32_t *qtbl)
Definition: RTjpegN.cpp:534
int compress8(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2910
uint16_t height
Definition: RTjpegN.h:148
int Compress(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3315
int16_t block [64] MALIGN32
Definition: RTjpegN.h:113
int SetFormat(const int *fmt)
Definition: RTjpegN.cpp:2708
int32_t Cwidth
Definition: RTjpegN.h:122
void Idct(uint8_t *odata, int16_t *data, int rskip)
Definition: RTjpegN.cpp:1539
unsigned short uint16_t
Definition: iso6937tables.h:1
RTjpeg()
Definition: RTjpegN.cpp:2794
uint8_t headersize
Definition: RTjpegN.h:145
int mcompressYUV422(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3219
int16_t * old_start
Definition: RTjpegN.h:126
void decompressYUV422(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:2939
#define mmx_t
uint8_t quality
Definition: RTjpegN.h:149
Definition: RTjpegN.h:64
int32_t Ysize
Definition: RTjpegN.h:123
int SetQuality(int *quality)
Definition: RTjpegN.cpp:2691
int b2s(const int16_t *data, int8_t *strm, uint8_t bt8)
Definition: RTjpegN.cpp:110
int width
Definition: RTjpegN.h:129
uint32_t framesize
Definition: RTjpegN.h:144
void DctInit(void)
Definition: RTjpegN.cpp:598
int32_t cb8
Definition: RTjpegN.h:120
int bcomp(int16_t *rblock, int16_t *old, mmx_t *mask)
Definition: RTjpegN.cpp:3076
int32_t Ywidth
Definition: RTjpegN.h:121
void DctY(uint8_t *idata, int rskip)
Definition: RTjpegN.cpp:609
int s2b(int16_t *data, const int8_t *strm, uint8_t bt8, int32_t *qtbla)
Definition: RTjpegN.cpp:281
void CalcTbls(void)
Definition: RTjpegN.cpp:2657
void IdctInit(void)
Definition: RTjpegN.cpp:1528
void QuantInit(void)
Definition: RTjpegN.cpp:518
void Decompress(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3352
int mcompress8(int8_t *sp, uint8_t **planes)
Definition: RTjpegN.cpp:3281
mmx_t cmask
Definition: RTjpegN.h:135