Mercurial > libavcodec.hg
annotate indeo2.c @ 3541:3fbddeb13686 libavcodec
10l, vorbis_inverse_coupling_sse() was really 3dnow
author | lorenm |
---|---|
date | Thu, 03 Aug 2006 07:09:29 +0000 |
parents | 0b546eab515d |
children | 42b08e756c3b |
rev | line source |
---|---|
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
1 /* |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
2 * Indel Indeo 2 codec |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
3 * Copyright (c) 2005 Konstantin Shishkov |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
4 * |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
9 * |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
14 * |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2967
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
18 * |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
19 */ |
2967 | 20 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
21 /** |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
22 * @file indeo2.c |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
23 * Intel Indeo 2 decoder. |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
24 */ |
2664
f20c1cdfce76
support the LE reader, so it can be tested a little
michael
parents:
2621
diff
changeset
|
25 #define ALT_BITSTREAM_READER_LE |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
26 #include "avcodec.h" |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
27 #include "bitstream.h" |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
28 #include "indeo2data.h" |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
29 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
30 typedef struct Ir2Context{ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
31 AVCodecContext *avctx; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
32 AVFrame picture; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
33 GetBitContext gb; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
34 int decode_delta; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
35 } Ir2Context; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
36 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
37 #define CODE_VLC_BITS 14 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
38 static VLC ir2_vlc; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
39 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
40 /* Indeo 2 codes are in range 0x01..0x7F and 0x81..0x90 */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
41 static inline int ir2_get_code(GetBitContext *gb) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
42 { |
2621 | 43 return get_vlc2(gb, ir2_vlc.table, CODE_VLC_BITS, 1) + 1; |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
44 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
45 |
2619 | 46 static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
47 const uint8_t *table) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
48 { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
49 int i; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
50 int j; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
51 int out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
52 int c; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
53 int t; |
2967 | 54 |
2619 | 55 if(width&1) |
56 return -1; | |
57 | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
58 /* first line contain absolute values, other lines contain deltas */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
59 while (out < width){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
60 c = ir2_get_code(&ctx->gb); |
2621 | 61 if(c >= 0x80) { /* we have a run */ |
62 c -= 0x7F; | |
2619 | 63 if(out + c*2 > width) |
64 return -1; | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
65 for (i = 0; i < c * 2; i++) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
66 dst[out++] = 0x80; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
67 } else { /* copy two values from table */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
68 dst[out++] = table[c * 2]; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
69 dst[out++] = table[(c * 2) + 1]; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
70 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
71 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
72 dst += stride; |
2967 | 73 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
74 for (j = 1; j < height; j++){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
75 out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
76 while (out < width){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
77 c = ir2_get_code(&ctx->gb); |
2621 | 78 if(c >= 0x80) { /* we have a skip */ |
79 c -= 0x7F; | |
2619 | 80 if(out + c*2 > width) |
81 return -1; | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
82 for (i = 0; i < c * 2; i++) { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
83 dst[out] = dst[out - stride]; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
84 out++; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
85 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
86 } else { /* add two deltas from table */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
87 t = dst[out - stride] + (table[c * 2] - 128); |
2621 | 88 t= clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
89 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
90 out++; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
91 t = dst[out - stride] + (table[(c * 2) + 1] - 128); |
2621 | 92 t= clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
93 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
94 out++; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
95 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
96 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
97 dst += stride; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
98 } |
2619 | 99 return 0; |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
100 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
101 |
2619 | 102 static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
103 const uint8_t *table) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
104 { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
105 int j; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
106 int out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
107 int c; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
108 int t; |
2619 | 109 |
110 if(width&1) | |
111 return -1; | |
112 | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
113 for (j = 0; j < height; j++){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
114 out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
115 while (out < width){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
116 c = ir2_get_code(&ctx->gb); |
2621 | 117 if(c >= 0x80) { /* we have a skip */ |
118 c -= 0x7F; | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
119 out += c * 2; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
120 } else { /* add two deltas from table */ |
2783
7a411f408d74
Here is the patch suggested by: unkaggregate, users sf net
michael
parents:
2664
diff
changeset
|
121 t = dst[out] + (((table[c * 2] - 128)*3) >> 2); |
2621 | 122 t= clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
123 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
124 out++; |
2783
7a411f408d74
Here is the patch suggested by: unkaggregate, users sf net
michael
parents:
2664
diff
changeset
|
125 t = dst[out] + (((table[(c * 2) + 1] - 128)*3) >> 2); |
2621 | 126 t= clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
127 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
128 out++; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
129 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
130 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
131 dst += stride; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
132 } |
2619 | 133 return 0; |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
134 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
135 |
2967 | 136 static int ir2_decode_frame(AVCodecContext *avctx, |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
137 void *data, int *data_size, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
138 uint8_t *buf, int buf_size) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
139 { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
140 Ir2Context * const s = avctx->priv_data; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
141 AVFrame *picture = data; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
142 AVFrame * const p= (AVFrame*)&s->picture; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
143 int start; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
144 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
145 if(p->data[0]) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
146 avctx->release_buffer(avctx, p); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
147 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
148 p->reference = 1; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
149 p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
150 if (avctx->reget_buffer(avctx, p)) { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
151 av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
152 return -1; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
153 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
154 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
155 s->decode_delta = buf[18]; |
2967 | 156 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
157 /* decide whether frame uses deltas or not */ |
2967 | 158 #ifndef ALT_BITSTREAM_READER_LE |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
159 for (i = 0; i < buf_size; i++) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
160 buf[i] = ff_reverse[buf[i]]; |
2664
f20c1cdfce76
support the LE reader, so it can be tested a little
michael
parents:
2621
diff
changeset
|
161 #endif |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
162 start = 48; /* hardcoded for now */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
163 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
164 init_get_bits(&s->gb, buf + start, buf_size - start); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
165 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
166 if (s->decode_delta) { /* intraframe */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
167 ir2_decode_plane(s, avctx->width, avctx->height, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
168 s->picture.data[0], s->picture.linesize[0], ir2_luma_table); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
169 /* swapped U and V */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
170 ir2_decode_plane(s, avctx->width >> 2, avctx->height >> 2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
171 s->picture.data[2], s->picture.linesize[2], ir2_luma_table); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
172 ir2_decode_plane(s, avctx->width >> 2, avctx->height >> 2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
173 s->picture.data[1], s->picture.linesize[1], ir2_luma_table); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
174 } else { /* interframe */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
175 ir2_decode_plane_inter(s, avctx->width, avctx->height, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
176 s->picture.data[0], s->picture.linesize[0], ir2_luma_table); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
177 /* swapped U and V */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
178 ir2_decode_plane_inter(s, avctx->width >> 2, avctx->height >> 2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
179 s->picture.data[2], s->picture.linesize[2], ir2_luma_table); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
180 ir2_decode_plane_inter(s, avctx->width >> 2, avctx->height >> 2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
181 s->picture.data[1], s->picture.linesize[1], ir2_luma_table); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
182 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
183 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
184 *picture= *(AVFrame*)&s->picture; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
185 *data_size = sizeof(AVPicture); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
186 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
187 return buf_size; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
188 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
189 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
190 static int ir2_decode_init(AVCodecContext *avctx){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
191 Ir2Context * const ic = avctx->priv_data; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
192 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
193 ic->avctx = avctx; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
194 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
195 avctx->pix_fmt= PIX_FMT_YUV410P; |
2967 | 196 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
197 if (!ir2_vlc.table) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
198 init_vlc(&ir2_vlc, CODE_VLC_BITS, IR2_CODES, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
199 &ir2_codes[0][1], 4, 2, |
2664
f20c1cdfce76
support the LE reader, so it can be tested a little
michael
parents:
2621
diff
changeset
|
200 #ifdef ALT_BITSTREAM_READER_LE |
2967 | 201 &ir2_codes[0][0], 4, 2, INIT_VLC_USE_STATIC | INIT_VLC_LE); |
2664
f20c1cdfce76
support the LE reader, so it can be tested a little
michael
parents:
2621
diff
changeset
|
202 #else |
2967 | 203 &ir2_codes[0][0], 4, 2, INIT_VLC_USE_STATIC); |
2664
f20c1cdfce76
support the LE reader, so it can be tested a little
michael
parents:
2621
diff
changeset
|
204 #endif |
2967 | 205 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
206 return 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
207 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
208 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
209 AVCodec indeo2_decoder = { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
210 "indeo2", |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
211 CODEC_TYPE_VIDEO, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
212 CODEC_ID_INDEO2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
213 sizeof(Ir2Context), |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
214 ir2_decode_init, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
215 NULL, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
216 NULL, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
217 ir2_decode_frame, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
218 CODEC_CAP_DR1, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
219 }; |