1 /*
2 * Microsoft RLE video decoder
3 * Copyright (C) 2003 the ffmpeg project
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * MS RLE video decoder by Mike Melanson (melanson@pcisys.net)
25 * For more information about the MS RLE format, visit:
26 * http://www.pcisys.net/~melanson/codecs/
27 *
28 * The MS RLE decoder outputs PAL8 colorspace data.
29 */
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34
39
43
45 const unsigned char *
buf;
47
50
52 {
54 int i;
55
57
59 case 1:
61 break;
62 case 4:
63 case 8:
65 break;
66 case 24:
68 break;
69 default:
72 }
73
77
81
82 return 0;
83 }
84
86 void *
data,
int *got_frame,
88 {
90 int buf_size = avpkt->
size;
94
97
100
103
104 if (pal) {
107 }
108 /* make the palette available */
110 }
111
112 /* FIXME how to correctly detect RLE ??? */
113 if (avctx->
height * istride == avpkt->
size) {
/* assume uncompressed */
117 int i, j;
118
119 if (linesize < 0)
120 return linesize;
121
122 for (i = 0; i < avctx->
height; i++) {
124 for (j = 0; j < avctx->
width - 1; j += 2) {
125 ptr[j+0] = buf[j>>1] >> 4;
126 ptr[j+1] = buf[j>>1] & 0xF;
127 }
128 if (avctx->
width & 1)
129 ptr[j+0] = buf[j>>1] >> 4;
130 } else {
131 memcpy(ptr, buf, linesize);
132 }
133 buf -= istride;
135 }
136 } else {
139 }
140
143
144 *got_frame = 1;
145
146 /* report that the buffer was completely consumed */
147 return buf_size;
148 }
149
151 {
153
154 /* release the last frame */
156
157 return 0;
158 }
159
170 };