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 <string.h>
32
38
42
44
47
49 {
52
54
56 case 1:
58 break;
59 case 4:
60 case 8:
62 break;
63 case 24:
65 break;
66 default:
69 }
70
74
78
79 return 0;
80 }
81
84 {
85 const uint8_t *buf = avpkt->
data;
86 int buf_size = avpkt->
size;
90
91 if (buf_size < 2) //Minimally a end of picture code should be there
93
96
99
100 /* make the palette available */
102 }
103
104 /* FIXME how to correctly detect RLE ??? */
105 if (avctx->
height * istride == avpkt->
size) {
/* assume uncompressed */
107 uint8_t *ptr =
s->frame->data[0];
108 const uint8_t *buf = avpkt->
data + (avctx->
height-1)*istride;
110
111 if (linesize < 0)
112 return linesize;
113
116 for (j = 0; j < avctx->
width - 1; j += 2) {
117 ptr[j+0] = buf[j>>1] >> 4;
118 ptr[j+1] = buf[j>>1] & 0xF;
119 }
120 if (avctx->
width & 1)
121 ptr[j+0] = buf[j>>1] >> 4;
122 } else {
123 memcpy(ptr, buf, linesize);
124 }
125 buf -= istride;
126 ptr +=
s->frame->linesize[0];
127 }
128 } else {
131 }
132
135
136 *got_frame = 1;
137
138 /* report that the buffer was completely consumed */
139 return buf_size;
140 }
141
143 {
145
147 }
148
150 {
152
153 /* release the last frame */
155
156 return 0;
157 }
158
170 };