Mercurial > libavcodec.hg
annotate indeo2.c @ 6346:11a44fc273a5 libavcodec
Add 'reservoir' flag to lavc's flags2 controlling whether or not codes may
utilize a bit reservoir. Also, make the lame encoder utilize this flag.
patch by Paul Kelly, paul a stjohnspoint d co d uk
author | andoma |
---|---|
date | Mon, 11 Feb 2008 08:01:07 +0000 |
parents | dfdff1ca78a7 |
children | 48759bfbd073 |
rev | line source |
---|---|
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
1 /* |
3724 | 2 * Intel Indeo 2 codec |
2618
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 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3724
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3724
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3724
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
8 * 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
|
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:
3724
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3724
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
16 * |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
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:
3724
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2967
diff
changeset
|
19 * 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
|
20 */ |
2967 | 21 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
22 /** |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
23 * @file indeo2.c |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
24 * Intel Indeo 2 decoder. |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
25 */ |
2664
f20c1cdfce76
support the LE reader, so it can be tested a little
michael
parents:
2621
diff
changeset
|
26 #define ALT_BITSTREAM_READER_LE |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
27 #include "avcodec.h" |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
28 #include "bitstream.h" |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
29 #include "indeo2data.h" |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
30 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
31 typedef struct Ir2Context{ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
32 AVCodecContext *avctx; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
33 AVFrame picture; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
34 GetBitContext gb; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
35 int decode_delta; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
36 } Ir2Context; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
37 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
38 #define CODE_VLC_BITS 14 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
39 static VLC ir2_vlc; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
40 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
41 /* 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
|
42 static inline int ir2_get_code(GetBitContext *gb) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
43 { |
2621 | 44 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
|
45 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
46 |
2619 | 47 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
|
48 const uint8_t *table) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
49 { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
50 int i; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
51 int j; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
52 int out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
53 int c; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
54 int t; |
2967 | 55 |
2619 | 56 if(width&1) |
57 return -1; | |
58 | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
59 /* first line contain absolute values, other lines contain deltas */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
60 while (out < width){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
61 c = ir2_get_code(&ctx->gb); |
2621 | 62 if(c >= 0x80) { /* we have a run */ |
63 c -= 0x7F; | |
2619 | 64 if(out + c*2 > width) |
65 return -1; | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
66 for (i = 0; i < c * 2; i++) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
67 dst[out++] = 0x80; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
68 } else { /* copy two values from table */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
69 dst[out++] = table[c * 2]; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
70 dst[out++] = table[(c * 2) + 1]; |
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 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
73 dst += stride; |
2967 | 74 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
75 for (j = 1; j < height; j++){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
76 out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
77 while (out < width){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
78 c = ir2_get_code(&ctx->gb); |
2621 | 79 if(c >= 0x80) { /* we have a skip */ |
80 c -= 0x7F; | |
2619 | 81 if(out + c*2 > width) |
82 return -1; | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
83 for (i = 0; i < c * 2; i++) { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
84 dst[out] = dst[out - stride]; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
85 out++; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
86 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
87 } else { /* add two deltas from table */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
88 t = dst[out - stride] + (table[c * 2] - 128); |
4594 | 89 t= av_clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
90 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
91 out++; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
92 t = dst[out - stride] + (table[(c * 2) + 1] - 128); |
4594 | 93 t= av_clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
94 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
95 out++; |
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 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
98 dst += stride; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
99 } |
2619 | 100 return 0; |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
101 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
102 |
2619 | 103 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
|
104 const uint8_t *table) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
105 { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
106 int j; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
107 int out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
108 int c; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
109 int t; |
2619 | 110 |
111 if(width&1) | |
112 return -1; | |
113 | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
114 for (j = 0; j < height; j++){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
115 out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
116 while (out < width){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
117 c = ir2_get_code(&ctx->gb); |
2621 | 118 if(c >= 0x80) { /* we have a skip */ |
119 c -= 0x7F; | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
120 out += c * 2; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
121 } else { /* add two deltas from table */ |
2783
7a411f408d74
Here is the patch suggested by: unkaggregate, users sf net
michael
parents:
2664
diff
changeset
|
122 t = dst[out] + (((table[c * 2] - 128)*3) >> 2); |
4594 | 123 t= av_clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
124 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
125 out++; |
2783
7a411f408d74
Here is the patch suggested by: unkaggregate, users sf net
michael
parents:
2664
diff
changeset
|
126 t = dst[out] + (((table[(c * 2) + 1] - 128)*3) >> 2); |
4594 | 127 t= av_clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
128 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
129 out++; |
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 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
132 dst += stride; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
133 } |
2619 | 134 return 0; |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
135 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
136 |
2967 | 137 static int ir2_decode_frame(AVCodecContext *avctx, |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
138 void *data, int *data_size, |
6218 | 139 const uint8_t *buf, int buf_size) |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
140 { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
141 Ir2Context * const s = avctx->priv_data; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
142 AVFrame *picture = data; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
143 AVFrame * const p= (AVFrame*)&s->picture; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
144 int start; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
145 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
146 if(p->data[0]) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
147 avctx->release_buffer(avctx, p); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
148 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
149 p->reference = 1; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
150 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
|
151 if (avctx->reget_buffer(avctx, p)) { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
152 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
|
153 return -1; |
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 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
156 s->decode_delta = buf[18]; |
2967 | 157 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
158 /* decide whether frame uses deltas or not */ |
2967 | 159 #ifndef ALT_BITSTREAM_READER_LE |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
160 for (i = 0; i < buf_size; i++) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
161 buf[i] = ff_reverse[buf[i]]; |
2664
f20c1cdfce76
support the LE reader, so it can be tested a little
michael
parents:
2621
diff
changeset
|
162 #endif |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
163 start = 48; /* hardcoded for now */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
164 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
165 init_get_bits(&s->gb, buf + start, buf_size - start); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
166 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
167 if (s->decode_delta) { /* intraframe */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
168 ir2_decode_plane(s, avctx->width, avctx->height, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
169 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
|
170 /* swapped U and V */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
171 ir2_decode_plane(s, avctx->width >> 2, avctx->height >> 2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
172 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
|
173 ir2_decode_plane(s, avctx->width >> 2, avctx->height >> 2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
174 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
|
175 } else { /* interframe */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
176 ir2_decode_plane_inter(s, avctx->width, avctx->height, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
177 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
|
178 /* swapped U and V */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
179 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
|
180 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
|
181 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
|
182 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
|
183 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
184 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
185 *picture= *(AVFrame*)&s->picture; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
186 *data_size = sizeof(AVPicture); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
187 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
188 return buf_size; |
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 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
191 static int ir2_decode_init(AVCodecContext *avctx){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
192 Ir2Context * const ic = avctx->priv_data; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
193 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
194 ic->avctx = avctx; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
195 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
196 avctx->pix_fmt= PIX_FMT_YUV410P; |
2967 | 197 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
198 if (!ir2_vlc.table) |
5096
1210710a6c6a
fix error: indeo2.c:202:1: directives may not be used inside a macro argument,
gpoirier
parents:
4594
diff
changeset
|
199 #ifdef ALT_BITSTREAM_READER_LE |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
200 init_vlc(&ir2_vlc, CODE_VLC_BITS, IR2_CODES, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
201 &ir2_codes[0][1], 4, 2, |
2967 | 202 &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
|
203 #else |
5096
1210710a6c6a
fix error: indeo2.c:202:1: directives may not be used inside a macro argument,
gpoirier
parents:
4594
diff
changeset
|
204 init_vlc(&ir2_vlc, CODE_VLC_BITS, IR2_CODES, |
1210710a6c6a
fix error: indeo2.c:202:1: directives may not be used inside a macro argument,
gpoirier
parents:
4594
diff
changeset
|
205 &ir2_codes[0][1], 4, 2, |
2967 | 206 &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
|
207 #endif |
2967 | 208 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
209 return 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
210 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
211 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
212 AVCodec indeo2_decoder = { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
213 "indeo2", |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
214 CODEC_TYPE_VIDEO, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
215 CODEC_ID_INDEO2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
216 sizeof(Ir2Context), |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
217 ir2_decode_init, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
218 NULL, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
219 NULL, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
220 ir2_decode_frame, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
221 CODEC_CAP_DR1, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
222 }; |