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