Mercurial > libavcodec.hg
annotate rtjpeg.c @ 3416:fb9d94637fb2 libavcodec
#define SBUTTERFLY outside CONFIG_ENCODERS
author | mru |
---|---|
date | Wed, 05 Jul 2006 19:31:01 +0000 |
parents | 28aaf0a0135e |
children | c8c591fe26f8 |
rev | line source |
---|---|
3224
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
1 /* |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
2 * RTJpeg decoding functions |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
3 * Copyright (c) 2006 Reimar Doeffinger |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
4 * |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
9 * |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
14 * |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
18 */ |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
19 #include "common.h" |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
20 #include "bitstream.h" |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
21 #include "dsputil.h" |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
22 #include "rtjpeg.h" |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
23 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
24 #define PUT_COEFF(c) \ |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
25 i = scan[coeff--]; \ |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
26 block[i] = (c) * quant[i]; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
27 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
28 //! aligns the bitstream to the give power of two |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
29 #define ALIGN(a) \ |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
30 n = (-get_bits_count(gb)) & (a - 1); \ |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
31 if (n) {skip_bits(gb, n);} |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
32 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
33 /** |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
34 * \brief read one block from stream |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
35 * \param gb contains stream data |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
36 * \param block where data is written to |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
37 * \param scan array containing the mapping stream address -> block position |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
38 * \param quant quantization factors |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
39 * |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
40 * Note: GetBitContext is used to make the code simpler, since all data is |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
41 * aligned this could be done faster in a different way, e.g. as it is done |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
42 * in MPlayer libmpcodecs/native/RTjpegN.c |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
43 */ |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
44 static inline int get_block(GetBitContext *gb, DCTELEM *block, uint8_t *scan, |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
45 uint32_t *quant) { |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
46 int coeff, i, n; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
47 int8_t ac; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
48 uint8_t dc = get_bits(gb, 8); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
49 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
50 // block not coded |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
51 if (dc == 255) |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
52 return 0; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
53 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
54 // number of non-zero coefficients |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
55 coeff = get_bits(gb, 6); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
56 // normally we would only need to clear the (63 - coeff) last values, |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
57 // but since we do not know where they are we just clear the whole block |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
58 memset(block, 0, 64 * sizeof(DCTELEM)); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
59 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
60 // 2 bits per coefficient |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
61 while (coeff) { |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
62 ac = get_sbits(gb, 2); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
63 if (ac == -2) |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
64 break; // continue with more bits |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
65 PUT_COEFF(ac); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
66 } |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
67 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
68 // 4 bits per coefficient |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
69 ALIGN(4); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
70 while (coeff) { |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
71 ac = get_sbits(gb, 4); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
72 if (ac == -8) |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
73 break; // continue with more bits |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
74 PUT_COEFF(ac); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
75 } |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
76 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
77 // 8 bits per coefficient |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
78 ALIGN(8); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
79 while (coeff) { |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
80 ac = get_sbits(gb, 8); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
81 PUT_COEFF(ac); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
82 } |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
83 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
84 PUT_COEFF(dc); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
85 return 1; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
86 } |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
87 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
88 /** |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
89 * \brief decode one rtjpeg YUV420 frame |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
90 * \param c context, must be initialized via rtjpeg_decode_init |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
91 * \param f AVFrame to place decoded frame into. If parts of the frame |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
92 * are not coded they are left unchanged, so consider initializing it |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
93 * \param buf buffer containing input data |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
94 * \param buf_size length of input data in bytes |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
95 * \return number of bytes consumed from the input buffer |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
96 */ |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
97 int rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f, |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
98 uint8_t *buf, int buf_size) { |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
99 GetBitContext gb; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
100 int w = c->w / 16, h = c->h / 16; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
101 int x, y; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
102 void *y1 = f->data[0], *y2 = f->data[0] + 8 * f->linesize[0]; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
103 void *u = f->data[1], *v = f->data[2]; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
104 init_get_bits(&gb, buf, buf_size * 8); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
105 for (y = 0; y < h; y++) { |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
106 for (x = 0; x < w; x++) { |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
107 if (get_block(&gb, c->block, c->scan, c->lquant)) |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
108 c->dsp->idct_put(y1, f->linesize[0], c->block); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
109 y1 += 8; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
110 if (get_block(&gb, c->block, c->scan, c->lquant)) |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
111 c->dsp->idct_put(y1, f->linesize[0], c->block); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
112 y1 += 8; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
113 if (get_block(&gb, c->block, c->scan, c->lquant)) |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
114 c->dsp->idct_put(y2, f->linesize[0], c->block); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
115 y2 += 8; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
116 if (get_block(&gb, c->block, c->scan, c->lquant)) |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
117 c->dsp->idct_put(y2, f->linesize[0], c->block); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
118 y2 += 8; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
119 if (get_block(&gb, c->block, c->scan, c->cquant)) |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
120 c->dsp->idct_put(u, f->linesize[1], c->block); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
121 u += 8; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
122 if (get_block(&gb, c->block, c->scan, c->cquant)) |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
123 c->dsp->idct_put(v, f->linesize[2], c->block); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
124 v += 8; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
125 } |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
126 y1 += 2 * 8 * (f->linesize[0] - w); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
127 y2 += 2 * 8 * (f->linesize[0] - w); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
128 u += 8 * (f->linesize[1] - w); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
129 v += 8 * (f->linesize[2] - w); |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
130 } |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
131 return get_bits_count(&gb) / 8; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
132 } |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
133 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
134 /** |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
135 * \brief initialize an RTJpegContext, may be called multiple times |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
136 * \param c context to initialize |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
137 * \param dsp specifies the idct to use for decoding |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
138 * \param width width of image, will be rounded down to the nearest multiple |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
139 * of 16 for decoding |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
140 * \param height height of image, will be rounded down to the nearest multiple |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
141 * of 16 for decoding |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
142 * \param lquant luma quantization table to use |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
143 * \param cquant chroma quantization table to use |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
144 */ |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
145 void rtjpeg_decode_init(RTJpegContext *c, DSPContext *dsp, |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
146 int width, int height, |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
147 uint32_t *lquant, uint32_t *cquant) { |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
148 int i; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
149 c->dsp = dsp; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
150 for (i = 0; i < 64; i++) { |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
151 int z = ff_zigzag_direct[i]; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
152 int p = c->dsp->idct_permutation[i]; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
153 z = ((z << 3) | (z >> 3)) & 63; // rtjpeg uses a transposed variant |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
154 |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
155 // permute the scan and quantization tables for the chosen idct |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
156 c->scan[i] = c->dsp->idct_permutation[z]; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
157 c->lquant[p] = lquant[i]; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
158 c->cquant[p] = cquant[i]; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
159 } |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
160 c->w = width; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
161 c->h = height; |
28aaf0a0135e
NuppelVideo/MythTVVideo support, including rtjpeg decoder
reimar
parents:
diff
changeset
|
162 } |