~ubuntu-branches/debian/sid/mplayer/sid

« back to all changes in this revision

Viewing changes to libavcodec/tiertexseqv.c

  • Committer: Bazaar Package Importer
  • Author(s): A Mennucc1
  • Date: 2009-03-23 10:05:45 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090323100545-x8h79obawnnte7kk
Tags: 1.0~rc2+svn20090303-5
debian/control : move docbook-xml,docbook-xsl,xsltproc from 
Build-Depends-Indep to Build-Depends, since they are needed to run
configure

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
/**
23
 
 * @file tiertexseqv.c
 
23
 * @file libavcodec/tiertexseqv.c
24
24
 * Tiertex Limited SEQ video decoder
25
25
 */
26
26
 
32
32
typedef struct SeqVideoContext {
33
33
    AVCodecContext *avctx;
34
34
    AVFrame frame;
35
 
    unsigned int palette[256];
36
 
    unsigned char block[8 * 8];
37
35
} SeqVideoContext;
38
36
 
39
37
 
40
 
static unsigned char *seq_unpack_rle_block(unsigned char *src, unsigned char *dst, int dst_size)
 
38
static const unsigned char *seq_unpack_rle_block(const unsigned char *src, unsigned char *dst, int dst_size)
41
39
{
42
40
    int i, len, sz;
43
41
    GetBitContext gb;
67
65
    return src;
68
66
}
69
67
 
70
 
static unsigned char *seq_decode_op1(SeqVideoContext *seq, unsigned char *src, unsigned char *dst)
 
68
static const unsigned char *seq_decode_op1(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
71
69
{
72
 
    unsigned char *color_table;
 
70
    const unsigned char *color_table;
73
71
    int b, i, len, bits;
74
72
    GetBitContext gb;
 
73
    unsigned char block[8 * 8];
75
74
 
76
75
    len = *src++;
77
76
    if (len & 0x80) {
78
77
        switch (len & 3) {
79
78
        case 1:
80
 
            src = seq_unpack_rle_block(src, seq->block, sizeof(seq->block));
 
79
            src = seq_unpack_rle_block(src, block, sizeof(block));
81
80
            for (b = 0; b < 8; b++) {
82
 
                memcpy(dst, &seq->block[b * 8], 8);
 
81
                memcpy(dst, &block[b * 8], 8);
83
82
                dst += seq->frame.linesize[0];
84
83
            }
85
84
            break;
86
85
        case 2:
87
 
            src = seq_unpack_rle_block(src, seq->block, sizeof(seq->block));
 
86
            src = seq_unpack_rle_block(src, block, sizeof(block));
88
87
            for (i = 0; i < 8; i++) {
89
88
                for (b = 0; b < 8; b++)
90
 
                    dst[b * seq->frame.linesize[0]] = seq->block[i * 8 + b];
 
89
                    dst[b * seq->frame.linesize[0]] = block[i * 8 + b];
91
90
                ++dst;
92
91
            }
93
92
            break;
107
106
    return src;
108
107
}
109
108
 
110
 
static unsigned char *seq_decode_op2(SeqVideoContext *seq, unsigned char *src, unsigned char *dst)
 
109
static const unsigned char *seq_decode_op2(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
111
110
{
112
111
    int i;
113
112
 
120
119
    return src;
121
120
}
122
121
 
123
 
static unsigned char *seq_decode_op3(SeqVideoContext *seq, unsigned char *src, unsigned char *dst)
 
122
static const unsigned char *seq_decode_op3(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
124
123
{
125
124
    int pos, offset;
126
125
 
133
132
    return src;
134
133
}
135
134
 
136
 
static void seqvideo_decode(SeqVideoContext *seq, unsigned char *data, int data_size)
 
135
static void seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size)
137
136
{
138
137
    GetBitContext gb;
139
138
    int flags, i, j, x, y, op;
140
139
    unsigned char c[3];
141
140
    unsigned char *dst;
 
141
    uint32_t *palette;
142
142
 
143
143
    flags = *data++;
144
144
 
145
145
    if (flags & 1) {
 
146
        palette = (uint32_t *)seq->frame.data[1];
146
147
        for (i = 0; i < 256; i++) {
147
148
            for (j = 0; j < 3; j++, data++)
148
149
                c[j] = (*data << 2) | (*data >> 4);
149
 
            seq->palette[i] = AV_RB24(c);
 
150
            palette[i] = AV_RB24(c);
150
151
        }
151
 
        memcpy(seq->frame.data[1], seq->palette, sizeof(seq->palette));
152
152
        seq->frame.palette_has_changed = 1;
153
153
    }
154
154
 
173
173
    }
174
174
}
175
175
 
176
 
static int seqvideo_decode_init(AVCodecContext *avctx)
 
176
static av_cold int seqvideo_decode_init(AVCodecContext *avctx)
177
177
{
178
178
    SeqVideoContext *seq = avctx->priv_data;
179
179
 
187
187
 
188
188
static int seqvideo_decode_frame(AVCodecContext *avctx,
189
189
                                 void *data, int *data_size,
190
 
                                 uint8_t *buf, int buf_size)
 
190
                                 const uint8_t *buf, int buf_size)
191
191
{
192
192
 
193
193
    SeqVideoContext *seq = avctx->priv_data;
207
207
    return buf_size;
208
208
}
209
209
 
210
 
static int seqvideo_decode_end(AVCodecContext *avctx)
 
210
static av_cold int seqvideo_decode_end(AVCodecContext *avctx)
211
211
{
212
212
    SeqVideoContext *seq = avctx->priv_data;
213
213
 
227
227
    seqvideo_decode_end,
228
228
    seqvideo_decode_frame,
229
229
    CODEC_CAP_DR1,
 
230
    .long_name = NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ video"),
230
231
};