Revision e0f80bd7

View differences:

configure
67 67
echo "  --disable-dv1394         disable DV1394 grabbing [default=no]"
68 68
echo "  --disable-network        disable network support [default=no]"
69 69
echo "  --disable-zlib           disable zlib [default=no]"
70
echo "  --disable-lzo            disable lzo [default=no]"
70 71
echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
71 72
echo "  --disable-vhook          disable video hooking support"
72 73
echo "  --enable-gprof           enable profiling with gprof [$gprof]"
......
185 186
dc1394="no"
186 187
network="yes"
187 188
zlib="yes"
189
lzo="yes"
188 190
libgsm="no"
189 191
mp3lame="no"
190 192
libogg="no"
......
485 487
  ;;
486 488
  --disable-zlib) zlib="no"
487 489
  ;;
490
  --disable-lzo) lzo="no"
491
  ;;
488 492
  --enable-a52) a52="yes"
489 493
  ;;
490 494
  --enable-a52bin) a52bin="yes"
......
985 989
extralibs="$extralibs -lz"
986 990
fi
987 991

  
992
if test "$lzo" = "yes" -a "$gpl" = "yes"; then
993
# check for liblzo
994
cat > $TMPC << EOF
995
#include <lzo1x.h>
996
int main ( void ) {
997
lzo_init();
998
return 0;
999
}
1000
EOF
1001
$cc $CFLAGS $LDFLAGS -o $TMPE $TMPC -llzo 2> /dev/null || lzo="no"
1002
else
1003
lzo="no"
1004
fi
1005
if test "$lzo" = "yes"; then
1006
extralibs="$extralibs -llzo"
1007
fi
1008

  
988 1009
# test for lrintf in math.h
989 1010
cat > $TMPC << EOF
990 1011
#define _ISOC9X_SOURCE  1
......
1245 1266
fi
1246 1267
echo "gprof enabled    $gprof"
1247 1268
echo "zlib enabled     $zlib"
1269
echo "lzo enabled      $lzo"
1248 1270
echo "libgsm enabled   $libgsm"
1249 1271
echo "mp3lame enabled  $mp3lame"
1250 1272
echo "libogg enabled   $libogg"
......
1592 1614
  echo "CONFIG_ZLIB=yes" >> config.mak
1593 1615
fi
1594 1616

  
1617
if test "$lzo" = "yes" ; then
1618
  echo "#define CONFIG_LZO 1" >> $TMPH
1619
  echo "CONFIG_LZO=yes" >> config.mak
1620
fi
1621

  
1595 1622
if test "$libgsm" = "yes" ; then
1596 1623
  echo "#define CONFIG_LIBGSM 1" >> $TMPH
1597 1624
  echo "CONFIG_LIBGSM=yes" >> config.mak
libavcodec/Makefile
167 167
ifeq ($(CONFIG_TSCC_DECODER),yes)
168 168
    OBJS+= tscc.o
169 169
endif
170
ifeq ($(CONFIG_CSCD_DECODER),yes)
171
    OBJS+= cscd.o
172
endif
170 173
ifeq ($(CONFIG_ULTI_DECODER),yes)
171 174
    OBJS+= ulti.o
172 175
endif
libavcodec/allcodecs.c
264 264
#ifdef CONFIG_TSCC_DECODER
265 265
    register_avcodec(&tscc_decoder);
266 266
#endif //CONFIG_TSCC_DECODER
267
#ifdef CONFIG_CSCD_DECODER
268
    register_avcodec(&cscd_decoder);
269
#endif //CONFIG_CSCD_DECODER
267 270
#ifdef CONFIG_ULTI_DECODER
268 271
    register_avcodec(&ulti_decoder);
269 272
#endif //CONFIG_ULTI_DECODER
libavcodec/avcodec.h
114 114
    CODEC_ID_FRAPS,
115 115
    CODEC_ID_TRUEMOTION2,
116 116
    CODEC_ID_BMP,
117
    CODEC_ID_CSCD,
117 118

  
118 119
    /* various pcm "codecs" */
119 120
    CODEC_ID_PCM_S16LE= 0x10000,
......
2190 2191
extern AVCodec qtrle_decoder;
2191 2192
extern AVCodec flac_decoder;
2192 2193
extern AVCodec tscc_decoder;
2194
extern AVCodec cscd_decoder;
2193 2195
extern AVCodec ulti_decoder;
2194 2196
extern AVCodec qdraw_decoder;
2195 2197
extern AVCodec xl_decoder;
libavcodec/cscd.c
1
/*
2
 * CamStudio decoder
3
 * Copyright (c) 2006 Reimar Doeffinger
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 */
19
#include <stdio.h>
20
#include <stdlib.h>
21

  
22
#include "common.h"
23
#include "avcodec.h"
24

  
25
#ifdef CONFIG_ZLIB
26
#include <zlib.h>
27
#endif
28
#ifdef CONFIG_LZO
29
#include <lzo1x.h>
30
#endif
31

  
32
typedef struct {
33
    AVFrame pic;
34
    int linelen, height, bpp;
35
    unsigned int decomp_size;
36
    unsigned char* decomp_buf;
37
} CamStudioContext;
38

  
39
static void copy_frame_default(AVFrame *f, uint8_t *src,
40
                               int linelen, int height) {
41
    int i;
42
    uint8_t *dst = f->data[0];
43
    dst += (height - 1) * f->linesize[0];
44
    for (i = height; i; i--) {
45
        memcpy(dst, src, linelen);
46
        src += linelen;
47
        dst -= f->linesize[0];
48
    }
49
}
50

  
51
static void add_frame_default(AVFrame *f, uint8_t *src,
52
                              int linelen, int height) {
53
    int i, j;
54
    uint8_t *dst = f->data[0];
55
    dst += (height - 1) * f->linesize[0];
56
    for (i = height; i; i--) {
57
        for (j = linelen; j; j--)
58
            *dst++ += *src++;
59
        dst -= f->linesize[0] + linelen;
60
    }
61
}
62

  
63
#ifndef WORDS_BIGENDIAN
64
#define copy_frame_16 copy_frame_default
65
#define copy_frame_32 copy_frame_default
66
#define add_frame_16 add_frame_default
67
#define add_frame_32 add_frame_default
68
#else
69
static void copy_frame_16(AVFrame *f, uint8_t *src,
70
                          int linelen, int height) {
71
    int i, j;
72
    uint8_t *dst = f->data[0];
73
    dst += (height - 1) * f->linesize[0];
74
    for (i = height; i; i--) {
75
        for (j = linelen / 2; j; j--) {
76
          dst[0] = src[1];
77
          dst[1] = src[0];
78
          src += 2;
79
          dst += 2;
80
        }
81
        dst -= f->linesize[0] + linelen;
82
    }
83
}
84

  
85
static void copy_frame_32(AVFrame *f, uint8_t *src,
86
                          int linelen, int height) {
87
    int i, j;
88
    uint8_t *dst = f->data[0];
89
    dst += (height - 1) * f->linesize[0];
90
    for (i = height; i; i--) {
91
        for (j = linelen / 4; j; j--) {
92
          dst[0] = src[3];
93
          dst[1] = src[2];
94
          dst[2] = src[1];
95
          dst[3] = src[0];
96
          src += 4;
97
          dst += 4;
98
        }
99
        dst -= f->linesize[0] + linelen;
100
    }
101
}
102

  
103
static void add_frame_16(AVFrame *f, uint8_t *src,
104
                         int linelen, int height) {
105
    int i, j;
106
    uint8_t *dst = f->data[0];
107
    dst += (height - 1) * f->linesize[0];
108
    for (i = height; i; i--) {
109
        for (j = linelen / 2; j; j--) {
110
          dst[0] += src[1];
111
          dst[1] += src[0];
112
          src += 2;
113
          dst += 2;
114
        }
115
        dst -= f->linesize[0] + linelen;
116
    }
117
}
118

  
119
static void add_frame_32(AVFrame *f, uint8_t *src,
120
                         int linelen, int height) {
121
    int i, j;
122
    uint8_t *dst = f->data[0];
123
    dst += (height - 1) * f->linesize[0];
124
    for (i = height; i; i--) {
125
        for (j = linelen / 4; j; j--) {
126
          dst[0] += src[3];
127
          dst[1] += src[2];
128
          dst[2] += src[1];
129
          dst[3] += src[0];
130
          src += 4;
131
          dst += 4;
132
        }
133
        dst -= f->linesize[0] + linelen;
134
    }
135
}
136
#endif
137

  
138
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
139
                        uint8_t *buf, int buf_size) {
140
    CamStudioContext *c = (CamStudioContext *)avctx->priv_data;
141
    AVFrame *picture = data;
142

  
143
    if (buf_size < 2) {
144
        av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
145
        return -1;
146
    }
147

  
148
    if (c->pic.data[0])
149
        avctx->release_buffer(avctx, &c->pic);
150
    c->pic.reference = 1;
151
    c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
152
                          FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
153
    if (avctx->get_buffer(avctx, &c->pic) < 0) {
154
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
155
        return -1;
156
    }
157

  
158
    // decompress data
159
    switch ((buf[0] >> 1) & 7) {
160
        case 0: { // lzo compression
161
#ifdef CONFIG_LZO
162
            unsigned int dlen = c->decomp_size;
163
            if (lzo1x_decompress_safe(&buf[2], buf_size - 2,
164
                       c->decomp_buf, &dlen, NULL) != LZO_E_OK)
165
                av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
166
            break;
167
#else
168
            av_log(avctx, AV_LOG_ERROR, "compiled without lzo (GPL) support\n");
169
            return -1;
170
#endif
171
        }
172
        case 1: { // zlib compression
173
#ifdef CONFIG_ZLIB
174
            unsigned long dlen = c->decomp_size;
175
            if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK)
176
                av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
177
            break;
178
#else
179
            av_log(avctx, AV_LOG_ERROR, "compiled without zlib support\n");
180
            return -1;
181
#endif
182
        }
183
        default:
184
            av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
185
            return -1;
186
    }
187

  
188
    // flip upside down, add difference frame
189
    if (buf[0] & 1) { // keyframe
190
        c->pic.pict_type = FF_I_TYPE;
191
        c->pic.key_frame = 1;
192
        switch (c->bpp) {
193
          case 16:
194
              copy_frame_16(&c->pic, c->decomp_buf, c->linelen, c->height);
195
              break;
196
          case 32:
197
              copy_frame_32(&c->pic, c->decomp_buf, c->linelen, c->height);
198
              break;
199
          default:
200
              copy_frame_default(&c->pic, c->decomp_buf, c->linelen, c->height);
201
        }
202
    } else {
203
        c->pic.pict_type = FF_P_TYPE;
204
        c->pic.key_frame = 0;
205
        switch (c->bpp) {
206
          case 16:
207
              add_frame_16(&c->pic, c->decomp_buf, c->linelen, c->height);
208
              break;
209
          case 32:
210
              add_frame_32(&c->pic, c->decomp_buf, c->linelen, c->height);
211
              break;
212
          default:
213
              add_frame_default(&c->pic, c->decomp_buf, c->linelen, c->height);
214
        }
215
    }
216

  
217
    *picture = c->pic;
218
    *data_size = sizeof(AVFrame);
219
    return buf_size;
220
}
221

  
222
static int decode_init(AVCodecContext *avctx) {
223
    CamStudioContext *c = (CamStudioContext *)avctx->priv_data;
224
    if (avcodec_check_dimensions(avctx, avctx->height, avctx->width) < 0) {
225
        return 1;
226
    }
227
    avctx->has_b_frames = 0;
228
    switch (avctx->bits_per_sample) {
229
        case 16: avctx->pix_fmt = PIX_FMT_RGB565; break;
230
        case 24: avctx->pix_fmt = PIX_FMT_BGR24; break;
231
        case 32: avctx->pix_fmt = PIX_FMT_RGBA32; break;
232
        default:
233
            av_log(avctx, AV_LOG_ERROR,
234
                   "CamStudio codec error: unvalid depth %i bpp\n",
235
                   avctx->bits_per_sample);
236
             return 1;
237
    }
238
    c->bpp = avctx->bits_per_sample;
239
    c->pic.data[0] = NULL;
240
    c->linelen = avctx->width * avctx->bits_per_sample / 8;
241
    c->height = avctx->height;
242
    c->decomp_size = c->height * c->linelen;
243
    c->decomp_buf = av_malloc(c->decomp_size);
244
    if (!c->decomp_buf) {
245
        av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
246
        return 1;
247
    }
248
    return 0;
249
}
250

  
251
static int decode_end(AVCodecContext *avctx) {
252
    CamStudioContext *c = (CamStudioContext *)avctx->priv_data;
253
    av_freep(&c->decomp_buf);
254
    if (c->pic.data[0])
255
        avctx->release_buffer(avctx, &c->pic);
256
    return 0;
257
}
258

  
259
AVCodec cscd_decoder = {
260
    "camstudio",
261
    CODEC_TYPE_VIDEO,
262
    CODEC_ID_CSCD,
263
    sizeof(CamStudioContext),
264
    decode_init,
265
    NULL,
266
    decode_end,
267
    decode_frame,
268
    CODEC_CAP_DR1,
269
};
270

  
libavformat/avienc.c
193 193
    { CODEC_ID_FRAPS, MKTAG('F', 'P', 'S', '1') },
194 194
    { CODEC_ID_THEORA, MKTAG('t', 'h', 'e', 'o') },
195 195
    { CODEC_ID_TRUEMOTION2, MKTAG('T', 'M', '2', '0') },
196
    { CODEC_ID_CSCD, MKTAG('C', 'S', 'C', 'D') },
196 197
    { CODEC_ID_RAWVIDEO, 0 },
197 198
    { 0, 0 },
198 199
};

Also available in: Unified diff