Revision d08d7142

View differences:

Changelog
1 1
version <next>
2 2
- TechSmith Camtasia (TSCC) video decoder
3 3
- IBM Ultimotion (ULTI) video decoder
4
- Sierra Online audio file demuxer and decoder
5
- Apple QuickDraw (qdrw) video decoder
4 6

  
5 7
version 0.4.9-pre1:
6 8

  
doc/ffmpeg-doc.texi
676 676
@tab .fli/.flc files
677 677
@item Sierra VMD       @tab    @tab X
678 678
@tab used in Sierra CD-ROM games
679
@item Sierra Online    @tab    @tab X
680
@tab .sol files used in Sierra Online games
679 681
@item Matroska         @tab    @tab X
680 682
@end multitable
681 683

  
......
742 744
@item Apple Animation        @tab     @tab  X @tab fourcc: 'rle '
743 745
@item Apple Graphics         @tab     @tab  X @tab fourcc: 'smc '
744 746
@item Apple Video            @tab     @tab  X @tab fourcc: rpza
747
@item Apple QuickDraw        @tab     @tab  X @tab fourcc: qdrw
745 748
@item Cinepak                @tab     @tab  X
746 749
@item Microsoft RLE          @tab     @tab  X
747 750
@item Microsoft Video-1      @tab     @tab  X
......
812 815
@tab used in various Interplay computer games
813 816
@item Xan DPCM               @tab      @tab X
814 817
@tab used in Origin's Wing Commander IV AVI files
818
@item Sierra Online DPCM     @tab      @tab X
819
@tab used in Sierra Online game audio files
815 820
@item Apple MACE 3           @tab      @tab X
816 821
@item Apple MACE 6           @tab      @tab X
817 822
@item FLAC                   @tab      @tab X
libavcodec/Makefile
20 20
      roqvideo.o dpcm.o interplayvideo.o xan.o rpza.o cinepak.o msrle.o \
21 21
      msvideo1.o vqavideo.o idcinvideo.o adx.o rational.o faandct.o 8bps.o \
22 22
      smc.o parser.o flicvideo.o truemotion1.o vmdav.o lcl.o qtrle.o g726.o \
23
      flac.o vp3dsp.o integer.o snow.o tscc.o sonic.o ulti.o h264idct.o
23
      flac.o vp3dsp.o integer.o snow.o tscc.o sonic.o ulti.o h264idct.o \
24
      qdrw.o
24 25

  
25 26
ifeq ($(AMR_NB),yes)
26 27
ifeq ($(AMR_NB_FIXED),yes)
libavcodec/allcodecs.c
108 108
    register_avcodec(&indeo3_decoder);
109 109
    register_avcodec(&tscc_decoder);
110 110
    register_avcodec(&ulti_decoder);
111
    register_avcodec(&qdraw_decoder);
111 112
#ifdef CONFIG_FAAD
112 113
    register_avcodec(&aac_decoder);
113 114
    register_avcodec(&mpeg4aac_decoder);
......
169 170
    register_avcodec(&roq_dpcm_decoder);
170 171
    register_avcodec(&interplay_dpcm_decoder);
171 172
    register_avcodec(&xan_dpcm_decoder);
173
    register_avcodec(&sol_dpcm_decoder);
172 174
    register_avcodec(&qtrle_decoder);
173 175
    register_avcodec(&flac_decoder);
174 176
#endif /* CONFIG_DECODERS */
libavcodec/avcodec.h
103 103
    CODEC_ID_SNOW,
104 104
    CODEC_ID_TSCC,
105 105
    CODEC_ID_ULTI,
106
    CODEC_ID_QDRAW,
106 107

  
107 108
    /* various pcm "codecs" */
108 109
    CODEC_ID_PCM_S16LE,
......
140 141
    CODEC_ID_ROQ_DPCM,
141 142
    CODEC_ID_INTERPLAY_DPCM,
142 143
    CODEC_ID_XAN_DPCM,
144
    CODEC_ID_SOL_DPCM,
143 145
    
144 146
    CODEC_ID_FLAC,
145 147
    
......
1878 1880
extern AVCodec roq_dpcm_decoder;
1879 1881
extern AVCodec interplay_dpcm_decoder;
1880 1882
extern AVCodec xan_dpcm_decoder;
1883
extern AVCodec sol_dpcm_decoder;
1881 1884
extern AVCodec sonic_decoder;
1882 1885
extern AVCodec qtrle_decoder;
1883 1886
extern AVCodec flac_decoder;
1884 1887
extern AVCodec tscc_decoder;
1885 1888
extern AVCodec ulti_decoder;
1889
extern AVCodec qdraw_decoder;
1886 1890

  
1887 1891
/* pcm codecs */
1888 1892
#define PCM_CODEC(id, name) \
libavcodec/dpcm.c
24 24
 * Xan DPCM decoder by Mario Brito (mbrito@student.dei.uc.pt)
25 25
 * for more information on the specific data formats, visit:
26 26
 *   http://www.pcisys.net/~melanson/codecs/simpleaudio.html
27
 * SOL DPCMs implemented by Konstantin Shishkov
27 28
 *
28 29
 * Note about using the Xan DPCM decoder: Xan DPCM is used in AVI files
29 30
 * found in the Wing Commander IV computer game. These AVI files contain
......
39 40
typedef struct DPCMContext {
40 41
    int channels;
41 42
    short roq_square_array[256];
43
    long sample[2];//for SOL_DPCM
44
    int *sol_table;//for SOL_DPCM
42 45
} DPCMContext;
43 46

  
44 47
#define SATURATE_S16(x)  if (x < -32768) x = -32768; \
......
81 84

  
82 85
};
83 86

  
87
static int sol_table_old[16] =
88
    { 0x0,  0x1,  0x2 , 0x3,  0x6,  0xA,  0xF, 0x15,
89
    -0x15, -0xF, -0xA, -0x6, -0x3, -0x2, -0x1, 0x0};
90

  
91
static int sol_table_new[16] =
92
    { 0x0,  0x1,  0x2,  0x3,  0x6,  0xA,  0xF,  0x15,
93
      0x0, -0x1, -0x2, -0x3, -0x6, -0xA, -0xF, -0x15};
94
    
95
static int sol_table_16[128] = {
96
    0x000, 0x008, 0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070, 0x080,
97
    0x090, 0x0A0, 0x0B0, 0x0C0, 0x0D0, 0x0E0, 0x0F0, 0x100, 0x110, 0x120,
98
    0x130, 0x140, 0x150, 0x160, 0x170, 0x180, 0x190, 0x1A0, 0x1B0, 0x1C0,
99
    0x1D0, 0x1E0, 0x1F0, 0x200, 0x208, 0x210, 0x218, 0x220, 0x228, 0x230,
100
    0x238, 0x240, 0x248, 0x250, 0x258, 0x260, 0x268, 0x270, 0x278, 0x280,
101
    0x288, 0x290, 0x298, 0x2A0, 0x2A8, 0x2B0, 0x2B8, 0x2C0, 0x2C8, 0x2D0,
102
    0x2D8, 0x2E0, 0x2E8, 0x2F0, 0x2F8, 0x300, 0x308, 0x310, 0x318, 0x320,
103
    0x328, 0x330, 0x338, 0x340, 0x348, 0x350, 0x358, 0x360, 0x368, 0x370,
104
    0x378, 0x380, 0x388, 0x390, 0x398, 0x3A0, 0x3A8, 0x3B0, 0x3B8, 0x3C0,
105
    0x3C8, 0x3D0, 0x3D8, 0x3E0, 0x3E8, 0x3F0, 0x3F8, 0x400, 0x440, 0x480,
106
    0x4C0, 0x500, 0x540, 0x580, 0x5C0, 0x600, 0x640, 0x680, 0x6C0, 0x700,
107
    0x740, 0x780, 0x7C0, 0x800, 0x900, 0xA00, 0xB00, 0xC00, 0xD00, 0xE00,
108
    0xF00, 0x1000, 0x1400, 0x1800, 0x1C00, 0x2000, 0x3000, 0x4000
109
};
110

  
111

  
112

  
84 113
static int dpcm_decode_init(AVCodecContext *avctx)
85 114
{
86 115
    DPCMContext *s = avctx->priv_data;
......
88 117
    short square;
89 118

  
90 119
    s->channels = avctx->channels;
120
    s->sample[0] = s->sample[1] = 0;
91 121

  
92 122
    switch(avctx->codec->id) {
93 123

  
......
100 130
        }
101 131
        break;
102 132

  
133
        
134
    case CODEC_ID_SOL_DPCM:
135
        switch(avctx->codec_tag){
136
        case 1:
137
            s->sol_table=sol_table_old;
138
            s->sample[0] = s->sample[1] = 0x80;
139
            break;
140
        case 2:
141
            s->sol_table=sol_table_new;
142
            s->sample[0] = s->sample[1] = 0x80;
143
            break;
144
        case 3:
145
            s->sol_table=sol_table_16;
146
            break;
147
        default:
148
            av_log(avctx, AV_LOG_ERROR, "Unknown SOL subcodec\n");
149
            return -1;
150
        }
151
        break;
152
     
103 153
    default:
104 154
        break;
105 155
    }
......
203 253
            channel_number ^= s->channels - 1;
204 254
        }
205 255
        break;
256
    case CODEC_ID_SOL_DPCM:
257
        in = 0;
258
        if (avctx->codec_tag != 3) {
259
            while (in < buf_size) {
260
                int n1, n2;
261
                n1 = (buf[in] >> 4) & 0xF;
262
                n2 = buf[in++] & 0xF;
263
                s->sample[0] += s->sol_table[n1];
264
                 if (s->sample[0] < 0) s->sample[0] = 0;
265
                if (s->sample[0] > 255) s->sample[0] = 255;
266
                output_samples[out++] = (s->sample[0] - 128) << 8;
267
                s->sample[s->channels - 1] += s->sol_table[n2];
268
                if (s->sample[s->channels - 1] < 0) s->sample[s->channels - 1] = 0;
269
                if (s->sample[s->channels - 1] > 255) s->sample[s->channels - 1] = 255;
270
                output_samples[out++] = (s->sample[s->channels - 1] - 128) << 8;
271
            }
272
        } else {
273
            while (in < buf_size) {
274
                int n;
275
                n = buf[in++];
276
                if (n & 0x80) s->sample[channel_number] -= s->sol_table[n & 0x7F];
277
                else s->sample[channel_number] += s->sol_table[n & 0x7F];
278
                SATURATE_S16(s->sample[channel_number]);
279
                output_samples[out++] = s->sample[channel_number];
280
                /* toggle channel */
281
                channel_number ^= s->channels - 1;
282
            }
283
        }
284
        break;
206 285
    }
207 286

  
208 287
    *data_size = out * sizeof(short);
......
241 320
    NULL,
242 321
    dpcm_decode_frame,
243 322
};
323

  
324
AVCodec sol_dpcm_decoder = {
325
    "sol_dpcm",
326
    CODEC_TYPE_AUDIO,
327
    CODEC_ID_SOL_DPCM,
328
    sizeof(DPCMContext),
329
    dpcm_decode_init,
330
    NULL,
331
    NULL,
332
    dpcm_decode_frame,
333
};
libavcodec/qdrw.c
1
/*
2
 * QuickDraw (qdrw) codec
3
 * Copyright (c) 2004 Konstantin Shishkov
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
 */
20
 
21
/**
22
 * @file qdrw.c
23
 * Apple QuickDraw codec.
24
 */
25
 
26
#include "avcodec.h"
27
#include "mpegvideo.h"
28

  
29
typedef struct QdrawContext{
30
    AVCodecContext *avctx;
31
    AVFrame pic;
32
    uint8_t palette[256*3];
33
} QdrawContext;
34

  
35
static int decode_frame(AVCodecContext *avctx, 
36
                        void *data, int *data_size,
37
                        uint8_t *buf, int buf_size)
38
{
39
    QdrawContext * const a = avctx->priv_data;
40
    AVFrame * const p= (AVFrame*)&a->pic;
41
    uint8_t* outdata;
42
    int colors;
43
    int i;
44
    
45
    /* special case for last picture */
46
    if (buf_size == 0) {
47
        return 0;
48
    }
49

  
50
    if(p->data[0])
51
        avctx->release_buffer(avctx, p);
52

  
53
    p->reference= 0;
54
    if(avctx->get_buffer(avctx, p) < 0){
55
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
56
        return -1;
57
    }
58
    p->pict_type= I_TYPE;
59
    p->key_frame= 1;
60

  
61
    outdata = a->pic.data[0];
62
    
63
    buf += 0x68; /* jump to palette */
64
    colors = BE_32(buf);
65
    buf += 4;
66
    
67
    if(colors < 0 || colors > 256) {
68
        av_log(avctx, AV_LOG_ERROR, "Error color count - %i(0x%X)\n", colors, colors);
69
        return -1;
70
    }
71
    
72
    for (i = 0; i <= colors; i++) {
73
        int idx;
74
        idx = BE_16(buf); /* color index */
75
        buf += 2;
76
        
77
        a->palette[idx * 3 + 0] = *buf++;
78
        buf++;
79
        a->palette[idx * 3 + 1] = *buf++;
80
        buf++;
81
        a->palette[idx * 3 + 2] = *buf++;
82
        buf++;
83
    }
84

  
85
    if (colors)
86
        a->pic.palette_has_changed = 1;
87

  
88
    buf += 18; /* skip unneeded data */
89
    for (i = 0; i < avctx->height; i++) {
90
        int size, left, code, pix;
91
        uint8_t *next;
92
        uint8_t *out;
93
        int tsize = 0;
94
        
95
        /* decode line */
96
        out = outdata;
97
        size = BE_16(buf); /* size of packed line */
98
        buf += 2;
99
        left = size;
100
        next = buf + size;
101
        while (left > 0) {
102
            code = *buf++;
103
            if (code & 0x80 ) { /* run */
104
                int i;
105
                pix = *buf++;
106
                for (i = 0; i < 257 - code; i++) {
107
                    *out++ = a->palette[pix * 3 + 0];
108
                    *out++ = a->palette[pix * 3 + 1];
109
                    *out++ = a->palette[pix * 3 + 2];
110
                }
111
                tsize += 257 - code;
112
                left -= 2;
113
            } else { /* copy */
114
                int i, pix;
115
                for (i = 0; i <= code; i++) {
116
                    pix = *buf++;
117
                    *out++ = a->palette[pix * 3 + 0];
118
                    *out++ = a->palette[pix * 3 + 1];
119
                    *out++ = a->palette[pix * 3 + 2];
120
                }
121
                left -= 2 + code;
122
                tsize += code + 1;
123
            }
124
        }
125
        buf = next;
126
        outdata += a->pic.linesize[0];
127
    }
128

  
129
    *data_size = sizeof(AVFrame);
130
    *(AVFrame*)data = a->pic;
131
    
132
    return buf_size;
133
}
134

  
135
static int decode_init(AVCodecContext *avctx){
136
//    QdrawContext * const a = avctx->priv_data;
137

  
138
    avctx->pix_fmt= PIX_FMT_RGB24;
139

  
140
    return 0;
141
}
142

  
143
AVCodec qdraw_decoder = {
144
    "qdraw",
145
    CODEC_TYPE_VIDEO,
146
    CODEC_ID_QDRAW,
147
    sizeof(QdrawContext),
148
    decode_init,
149
    NULL,
150
    NULL,
151
    decode_frame,
152
    CODEC_CAP_DR1,
153
};
libavformat/Makefile
16 16
      avienc.o avidec.o wav.o swf.o au.o gif.o mov.o mpjpeg.o dv.o \
17 17
      yuv4mpeg.o 4xm.o flvenc.o flvdec.o movenc.o psxstr.o idroq.o ipmovie.o \
18 18
      nut.o wc3movie.o mp3.o westwood.o segafilm.o idcin.o flic.o \
19
      sierravmd.o matroska.o
19
      sierravmd.o matroska.o sol.o
20 20

  
21 21
ifeq ($(CONFIG_RISKY),yes)
22 22
OBJS+= asf.o
libavformat/allformats.c
98 98

  
99 99
    nut_init();
100 100
    matroska_init();
101
    sol_init();
101 102

  
102 103
#ifdef CONFIG_ENCODERS
103 104
    /* image formats */
libavformat/avformat.h
487 487
/* matroska.c */
488 488
int matroska_init(void);
489 489

  
490
/* sol.c */
491
int sol_init(void);
492

  
490 493
#include "rtp.h"
491 494

  
492 495
#include "rtsp.h"
libavformat/mov.c
115 115
    { CODEC_ID_8BPS, MKTAG('8', 'B', 'P', 'S') }, /* Planar RGB (8BPS) */
116 116
    { CODEC_ID_SMC, MKTAG('s', 'm', 'c', ' ') }, /* Apple Graphics (SMC) */
117 117
    { CODEC_ID_QTRLE, MKTAG('r', 'l', 'e', ' ') }, /* Apple Animation (RLE) */
118
    { CODEC_ID_QDRAW, MKTAG('q', 'd', 'r', 'w') }, /* QuickDraw */
118 119
    { CODEC_ID_NONE, 0 },
119 120
};
120 121

  
libavformat/sol.c
1
/* 
2
 * Sierra SOL decoder
3
 * Copyright Konstantin Shishkov.
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

  
20
/* 
21
 * Based on documents from Game Audio Player and own research
22
 */
23

  
24
#include "avformat.h"
25
#include "avi.h"
26
#include "bswap.h"
27

  
28
/* if we don't know the size in advance */
29
#define AU_UNKOWN_SIZE ((uint32_t)(~0))
30

  
31
static int sol_probe(AVProbeData *p)
32
{
33
    /* check file header */
34
    uint16_t magic;
35
    if (p->buf_size <= 14)
36
        return 0;
37
    magic=le2me_16(*((uint16_t*)p->buf));
38
    if ((magic == 0x0B8D || magic == 0x0C0D || magic == 0x0C8D) &&
39
        p->buf[2] == 'S' && p->buf[3] == 'O' &&
40
        p->buf[4] == 'L' && p->buf[5] == 0)
41
        return AVPROBE_SCORE_MAX;
42
    else
43
        return 0;
44
}
45

  
46
#define SOL_DPCM    1
47
#define SOL_16BIT   4
48
#define SOL_STEREO 16
49

  
50
static int sol_codec_id(int magic, int type)
51
{
52
    if (magic == 0x0B8D)
53
    {
54
        if (type & SOL_DPCM) return CODEC_ID_SOL_DPCM;
55
        else return CODEC_ID_PCM_U8;
56
    }
57
    if (type & SOL_DPCM)
58
    {
59
        if (type & SOL_16BIT) return CODEC_ID_SOL_DPCM;
60
        else if (magic == 0x0C8D) return CODEC_ID_SOL_DPCM;
61
        else return CODEC_ID_SOL_DPCM;
62
    }
63
    if (type & SOL_16BIT) return CODEC_ID_PCM_S16LE;
64
    return CODEC_ID_PCM_U8;
65
}
66

  
67
static int sol_codec_type(int magic, int type)
68
{
69
    if (magic == 0x0B8D) return 1;//SOL_DPCM_OLD;
70
    if (type & SOL_DPCM)
71
    {
72
        if (type & SOL_16BIT) return 3;//SOL_DPCM_NEW16;
73
        else if (magic == 0x0C8D) return 1;//SOL_DPCM_OLD;
74
        else return 2;//SOL_DPCM_NEW8;
75
    }
76
    return -1;
77
}
78

  
79
static int sol_channels(int magic, int type)
80
{
81
    if (magic == 0x0B8D || !(type & SOL_STEREO)) return 1;
82
    return 2;
83
}
84
    
85
static int sol_read_header(AVFormatContext *s,
86
                          AVFormatParameters *ap)
87
{
88
    int size;
89
    unsigned int magic,tag;
90
    ByteIOContext *pb = &s->pb;
91
    unsigned int id, codec, channels, rate, type;
92
    AVStream *st;
93

  
94
    /* check ".snd" header */
95
    magic = get_le16(pb);
96
    tag = get_le32(pb);
97
    if (tag != MKTAG('S', 'O', 'L', 0))
98
        return -1;
99
    rate = get_le16(pb);
100
    type = get_byte(pb);
101
    size = get_le32(pb);
102
    if (magic != 0x0B8D)
103
        get_byte(pb); /* newer SOLs contain padding byte */
104
    
105
    codec = sol_codec_id(magic, type);
106
    channels = sol_channels(magic, type);
107
    
108
    if (codec == CODEC_ID_SOL_DPCM)
109
        id = sol_codec_type(magic, type);
110
    else id = 0;
111
    
112
    /* now we are ready: build format streams */
113
    st = av_new_stream(s, 0);
114
    if (!st)
115
        return -1;
116
    st->codec.codec_type = CODEC_TYPE_AUDIO;
117
    st->codec.codec_tag = id;
118
    st->codec.codec_id = codec;
119
    st->codec.channels = channels;
120
    st->codec.sample_rate = rate;
121
    return 0;
122
}
123

  
124
#define MAX_SIZE 4096
125

  
126
static int sol_read_packet(AVFormatContext *s,
127
                          AVPacket *pkt)
128
{
129
    int ret;
130

  
131
    if (url_feof(&s->pb))
132
        return -EIO;
133
    if (av_new_packet(pkt, MAX_SIZE))
134
        return -EIO;
135
    pkt->stream_index = 0;
136

  
137
    ret = get_buffer(&s->pb, pkt->data, pkt->size);
138
    if (ret < 0)
139
        av_free_packet(pkt);
140
    /* note: we need to modify the packet size here to handle the last
141
       packet */
142
    pkt->size = ret;
143
    return 0;
144
}
145

  
146
static int sol_read_close(AVFormatContext *s)
147
{
148
    return 0;
149
}
150

  
151
static AVInputFormat sol_iformat = {
152
    "sol",
153
    "Sierra SOL Format",
154
    0,
155
    sol_probe,
156
    sol_read_header,
157
    sol_read_packet,
158
    sol_read_close,
159
    pcm_read_seek,
160
};
161

  
162
int sol_init(void)
163
{
164
    av_register_input_format(&sol_iformat);
165
    return 0;
166
}

Also available in: Unified diff