Mercurial > libavcodec.hg
annotate xl.c @ 12431:9f8d9abd7984 libavcodec
cosmetic
author | aurel |
---|---|
date | Sat, 28 Aug 2010 14:07:16 +0000 |
parents | 7dd2a45249a9 |
children |
rev | line source |
---|---|
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
1 /* |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
2 * Miro VideoXL codec |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
3 * Copyright (c) 2004 Konstantin Shishkov |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
4 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
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:
3036
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
16 * |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
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:
3036
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 |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
20 */ |
2967 | 21 |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
22 /** |
11644
7dd2a45249a9
Remove explicit filename from Doxygen @file commands.
diego
parents:
11560
diff
changeset
|
23 * @file |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
24 * Miro VideoXL codec. |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
25 */ |
2967 | 26 |
8573
2acf0ae7b041
Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents:
7040
diff
changeset
|
27 #include "libavutil/intreadwrite.h" |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
28 #include "avcodec.h" |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
29 |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
30 typedef struct VideoXLContext{ |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
31 AVCodecContext *avctx; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
32 AVFrame pic; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
33 } VideoXLContext; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
34 |
4170 | 35 static const int xl_table[32] = { |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
36 0, 1, 2, 3, 4, 5, 6, 7, |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
37 8, 9, 12, 15, 20, 25, 34, 46, |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
38 64, 82, 94, 103, 108, 113, 116, 119, |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
39 120, 121, 122, 123, 124, 125, 126, 127}; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
40 |
2967 | 41 static int decode_frame(AVCodecContext *avctx, |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
42 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8726
diff
changeset
|
43 AVPacket *avpkt) |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
44 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8726
diff
changeset
|
45 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8726
diff
changeset
|
46 int buf_size = avpkt->size; |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
47 VideoXLContext * const a = avctx->priv_data; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
48 AVFrame * const p= (AVFrame*)&a->pic; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
49 uint8_t *Y, *U, *V; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
50 int i, j; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
51 int stride; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
52 uint32_t val; |
8726 | 53 int y0, y1, y2, y3 = 0, c0 = 0, c1 = 0; |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
54 |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
55 if(p->data[0]) |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
56 avctx->release_buffer(avctx, p); |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
57 |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
58 p->reference = 0; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
59 if(avctx->get_buffer(avctx, p) < 0){ |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
60 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
61 return -1; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
62 } |
6450 | 63 p->pict_type= FF_I_TYPE; |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
64 p->key_frame= 1; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
65 |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
66 Y = a->pic.data[0]; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
67 U = a->pic.data[1]; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
68 V = a->pic.data[2]; |
2967 | 69 |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
70 stride = avctx->width - 4; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
71 for (i = 0; i < avctx->height; i++) { |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
72 /* lines are stored in reversed order */ |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
73 buf += stride; |
2967 | 74 |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
75 for (j = 0; j < avctx->width; j += 4) { |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
76 /* value is stored in LE dword with word swapped */ |
4364 | 77 val = AV_RL32(buf); |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
78 buf -= 4; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
79 val = ((val >> 16) & 0xFFFF) | ((val & 0xFFFF) << 16); |
2967 | 80 |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
81 if(!j) |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
82 y0 = (val & 0x1F) << 2; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
83 else |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
84 y0 = y3 + xl_table[val & 0x1F]; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
85 val >>= 5; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
86 y1 = y0 + xl_table[val & 0x1F]; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
87 val >>= 5; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
88 y2 = y1 + xl_table[val & 0x1F]; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
89 val >>= 6; /* align to word */ |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
90 y3 = y2 + xl_table[val & 0x1F]; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
91 val >>= 5; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
92 if(!j) |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
93 c0 = (val & 0x1F) << 2; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
94 else |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
95 c0 += xl_table[val & 0x1F]; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
96 val >>= 5; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
97 if(!j) |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
98 c1 = (val & 0x1F) << 2; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
99 else |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
100 c1 += xl_table[val & 0x1F]; |
2967 | 101 |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
102 Y[j + 0] = y0 << 1; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
103 Y[j + 1] = y1 << 1; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
104 Y[j + 2] = y2 << 1; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
105 Y[j + 3] = y3 << 1; |
2967 | 106 |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
107 U[j >> 2] = c0 << 1; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
108 V[j >> 2] = c1 << 1; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
109 } |
2967 | 110 |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
111 buf += avctx->width + 4; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
112 Y += a->pic.linesize[0]; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
113 U += a->pic.linesize[1]; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
114 V += a->pic.linesize[2]; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
115 } |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
116 |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
117 *data_size = sizeof(AVFrame); |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
118 *(AVFrame*)data = a->pic; |
2967 | 119 |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
120 return buf_size; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
121 } |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
122 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6450
diff
changeset
|
123 static av_cold int decode_init(AVCodecContext *avctx){ |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
124 // VideoXLContext * const a = avctx->priv_data; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
125 |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
126 avctx->pix_fmt= PIX_FMT_YUV411P; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
127 |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
128 return 0; |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
129 } |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
130 |
10399 | 131 static av_cold int decode_end(AVCodecContext *avctx){ |
132 VideoXLContext * const a = avctx->priv_data; | |
133 AVFrame *pic = &a->pic; | |
134 | |
135 if (pic->data[0]) | |
136 avctx->release_buffer(avctx, pic); | |
137 | |
138 return 0; | |
139 } | |
140 | |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
141 AVCodec xl_decoder = { |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
142 "xl", |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
10413
diff
changeset
|
143 AVMEDIA_TYPE_VIDEO, |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
144 CODEC_ID_VIXL, |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
145 sizeof(VideoXLContext), |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
146 decode_init, |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
147 NULL, |
10399 | 148 decode_end, |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
149 decode_frame, |
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
150 CODEC_CAP_DR1, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
151 .long_name = NULL_IF_CONFIG_SMALL("Miro VideoXL"), |
2325
1180a04d64c5
Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff
changeset
|
152 }; |