Mercurial > libavcodec.hg
annotate indeo2.c @ 11599:192399381906 libavcodec
Doxument ff_free_expr().
author | stefano |
---|---|
date | Sun, 11 Apr 2010 14:15:32 +0000 |
parents | 8a4984c5cacc |
children | 7dd2a45249a9 |
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 /** |
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
7040
diff
changeset
|
23 * @file libavcodec/indeo2.c |
2618
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" |
9428 | 28 #include "get_bits.h" |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
29 #include "indeo2data.h" |
10501
bdf4a9ca162a
Move ff_reverse in libavcodec to av_reverse in libavutil.
cehoyos
parents:
10413
diff
changeset
|
30 #include "libavutil/common.h" |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
31 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
32 typedef struct Ir2Context{ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
33 AVCodecContext *avctx; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
34 AVFrame picture; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
35 GetBitContext gb; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
36 int decode_delta; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
37 } Ir2Context; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
38 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
39 #define CODE_VLC_BITS 14 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
40 static VLC ir2_vlc; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
41 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
42 /* 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
|
43 static inline int ir2_get_code(GetBitContext *gb) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
44 { |
2621 | 45 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
|
46 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
47 |
2619 | 48 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
|
49 const uint8_t *table) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
50 { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
51 int i; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
52 int j; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
53 int out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
54 int c; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
55 int t; |
2967 | 56 |
2619 | 57 if(width&1) |
58 return -1; | |
59 | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
60 /* first line contain absolute values, other lines contain deltas */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
61 while (out < width){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
62 c = ir2_get_code(&ctx->gb); |
2621 | 63 if(c >= 0x80) { /* we have a run */ |
64 c -= 0x7F; | |
2619 | 65 if(out + c*2 > width) |
66 return -1; | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
67 for (i = 0; i < c * 2; i++) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
68 dst[out++] = 0x80; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
69 } else { /* copy two values from table */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
70 dst[out++] = table[c * 2]; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
71 dst[out++] = table[(c * 2) + 1]; |
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 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
74 dst += stride; |
2967 | 75 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
76 for (j = 1; j < height; j++){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
77 out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
78 while (out < width){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
79 c = ir2_get_code(&ctx->gb); |
2621 | 80 if(c >= 0x80) { /* we have a skip */ |
81 c -= 0x7F; | |
2619 | 82 if(out + c*2 > width) |
83 return -1; | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
84 for (i = 0; i < c * 2; i++) { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
85 dst[out] = dst[out - stride]; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
86 out++; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
87 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
88 } else { /* add two deltas from table */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
89 t = dst[out - stride] + (table[c * 2] - 128); |
4594 | 90 t= av_clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
91 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
92 out++; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
93 t = dst[out - stride] + (table[(c * 2) + 1] - 128); |
4594 | 94 t= av_clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
95 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
96 out++; |
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 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
99 dst += stride; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
100 } |
2619 | 101 return 0; |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
102 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
103 |
2619 | 104 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
|
105 const uint8_t *table) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
106 { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
107 int j; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
108 int out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
109 int c; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
110 int t; |
2619 | 111 |
112 if(width&1) | |
113 return -1; | |
114 | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
115 for (j = 0; j < height; j++){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
116 out = 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
117 while (out < width){ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
118 c = ir2_get_code(&ctx->gb); |
2621 | 119 if(c >= 0x80) { /* we have a skip */ |
120 c -= 0x7F; | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
121 out += c * 2; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
122 } else { /* add two deltas from table */ |
2783
7a411f408d74
Here is the patch suggested by: unkaggregate, users sf net
michael
parents:
2664
diff
changeset
|
123 t = dst[out] + (((table[c * 2] - 128)*3) >> 2); |
4594 | 124 t= av_clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
125 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
126 out++; |
2783
7a411f408d74
Here is the patch suggested by: unkaggregate, users sf net
michael
parents:
2664
diff
changeset
|
127 t = dst[out] + (((table[(c * 2) + 1] - 128)*3) >> 2); |
4594 | 128 t= av_clip_uint8(t); |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
129 dst[out] = t; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
130 out++; |
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 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
133 dst += stride; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
134 } |
2619 | 135 return 0; |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
136 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
137 |
2967 | 138 static int ir2_decode_frame(AVCodecContext *avctx, |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
139 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
140 AVPacket *avpkt) |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
141 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
142 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
143 int buf_size = avpkt->size; |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
144 Ir2Context * const s = avctx->priv_data; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
145 AVFrame *picture = data; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
146 AVFrame * const p= (AVFrame*)&s->picture; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
147 int start; |
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 if(p->data[0]) |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
150 avctx->release_buffer(avctx, p); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
151 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
152 p->reference = 1; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
153 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
|
154 if (avctx->reget_buffer(avctx, p)) { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
155 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
|
156 return -1; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
157 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
158 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
159 s->decode_delta = buf[18]; |
2967 | 160 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
161 /* decide whether frame uses deltas or not */ |
2967 | 162 #ifndef ALT_BITSTREAM_READER_LE |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
163 for (i = 0; i < buf_size; i++) |
10501
bdf4a9ca162a
Move ff_reverse in libavcodec to av_reverse in libavutil.
cehoyos
parents:
10413
diff
changeset
|
164 buf[i] = av_reverse[buf[i]]; |
2664
f20c1cdfce76
support the LE reader, so it can be tested a little
michael
parents:
2621
diff
changeset
|
165 #endif |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
166 start = 48; /* hardcoded for now */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
167 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
168 init_get_bits(&s->gb, buf + start, buf_size - start); |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
169 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
170 if (s->decode_delta) { /* intraframe */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
171 ir2_decode_plane(s, avctx->width, avctx->height, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
172 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
|
173 /* swapped U and V */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
174 ir2_decode_plane(s, avctx->width >> 2, avctx->height >> 2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
175 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
|
176 ir2_decode_plane(s, avctx->width >> 2, avctx->height >> 2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
177 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
|
178 } else { /* interframe */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
179 ir2_decode_plane_inter(s, avctx->width, avctx->height, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
180 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
|
181 /* swapped U and V */ |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
182 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
|
183 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
|
184 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
|
185 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
|
186 } |
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 *picture= *(AVFrame*)&s->picture; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
189 *data_size = sizeof(AVPicture); |
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 return buf_size; |
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 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6218
diff
changeset
|
194 static av_cold int ir2_decode_init(AVCodecContext *avctx){ |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
195 Ir2Context * const ic = avctx->priv_data; |
9463
d719a2711c64
Use new static VLC scheme in Indeo2, Musepack and WNV1 decoders
kostya
parents:
9428
diff
changeset
|
196 static VLC_TYPE vlc_tables[1 << CODE_VLC_BITS][2]; |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
197 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
198 ic->avctx = avctx; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
199 |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
200 avctx->pix_fmt= PIX_FMT_YUV410P; |
2967 | 201 |
9463
d719a2711c64
Use new static VLC scheme in Indeo2, Musepack and WNV1 decoders
kostya
parents:
9428
diff
changeset
|
202 ir2_vlc.table = vlc_tables; |
d719a2711c64
Use new static VLC scheme in Indeo2, Musepack and WNV1 decoders
kostya
parents:
9428
diff
changeset
|
203 ir2_vlc.table_allocated = 1 << CODE_VLC_BITS; |
5096
1210710a6c6a
fix error: indeo2.c:202:1: directives may not be used inside a macro argument,
gpoirier
parents:
4594
diff
changeset
|
204 #ifdef ALT_BITSTREAM_READER_LE |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
205 init_vlc(&ir2_vlc, CODE_VLC_BITS, IR2_CODES, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
206 &ir2_codes[0][1], 4, 2, |
9463
d719a2711c64
Use new static VLC scheme in Indeo2, Musepack and WNV1 decoders
kostya
parents:
9428
diff
changeset
|
207 &ir2_codes[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC | INIT_VLC_LE); |
2664
f20c1cdfce76
support the LE reader, so it can be tested a little
michael
parents:
2621
diff
changeset
|
208 #else |
5096
1210710a6c6a
fix error: indeo2.c:202:1: directives may not be used inside a macro argument,
gpoirier
parents:
4594
diff
changeset
|
209 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
|
210 &ir2_codes[0][1], 4, 2, |
9463
d719a2711c64
Use new static VLC scheme in Indeo2, Musepack and WNV1 decoders
kostya
parents:
9428
diff
changeset
|
211 &ir2_codes[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC); |
2664
f20c1cdfce76
support the LE reader, so it can be tested a little
michael
parents:
2621
diff
changeset
|
212 #endif |
2967 | 213 |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
214 return 0; |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
215 } |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
216 |
10399 | 217 static av_cold int ir2_decode_end(AVCodecContext *avctx){ |
218 Ir2Context * const ic = avctx->priv_data; | |
219 AVFrame *pic = &ic->picture; | |
220 | |
221 if (pic->data[0]) | |
222 avctx->release_buffer(avctx, pic); | |
223 | |
224 return 0; | |
225 } | |
226 | |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
227 AVCodec indeo2_decoder = { |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
228 "indeo2", |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
10501
diff
changeset
|
229 AVMEDIA_TYPE_VIDEO, |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
230 CODEC_ID_INDEO2, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
231 sizeof(Ir2Context), |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
232 ir2_decode_init, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
233 NULL, |
10399 | 234 ir2_decode_end, |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
235 ir2_decode_frame, |
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
236 CODEC_CAP_DR1, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
237 .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 2"), |
2618
fc91ca5b9066
Indeo 2 decoder by (Kostya <> kostya.shishkov gmail com)
michael
parents:
diff
changeset
|
238 }; |