~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/tiertexseqv.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 */
26
26
 
27
27
#include "avcodec.h"
28
 
#define ALT_BITSTREAM_READER_LE
 
28
#define BITSTREAM_READER_LE
29
29
#include "get_bits.h"
30
30
 
31
31
 
35
35
} SeqVideoContext;
36
36
 
37
37
 
38
 
static const unsigned char *seq_unpack_rle_block(const unsigned char *src, unsigned char *dst, int dst_size)
 
38
static const unsigned char *seq_unpack_rle_block(const unsigned char *src,
 
39
                                                 const unsigned char *src_end,
 
40
                                                 unsigned char *dst, int dst_size)
39
41
{
40
42
    int i, len, sz;
41
43
    GetBitContext gb;
42
44
    int code_table[64];
43
45
 
44
 
    /* get the rle codes (at most 64 bytes) */
45
 
    init_get_bits(&gb, src, 64 * 8);
 
46
    /* get the rle codes */
 
47
    init_get_bits(&gb, src, (src_end - src) * 8);
46
48
    for (i = 0, sz = 0; i < 64 && sz < dst_size; i++) {
 
49
        if (get_bits_left(&gb) < 4)
 
50
            return NULL;
47
51
        code_table[i] = get_sbits(&gb, 4);
48
52
        sz += FFABS(code_table[i]);
49
53
    }
54
58
        len = code_table[i];
55
59
        if (len < 0) {
56
60
            len = -len;
 
61
            if (src_end - src < 1)
 
62
                return NULL;
57
63
            memset(dst, *src++, FFMIN(len, dst_size));
58
64
        } else {
 
65
            if (src_end - src < len)
 
66
                return NULL;
59
67
            memcpy(dst, src, FFMIN(len, dst_size));
60
68
            src += len;
61
69
        }
65
73
    return src;
66
74
}
67
75
 
68
 
static const unsigned char *seq_decode_op1(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
 
76
static const unsigned char *seq_decode_op1(SeqVideoContext *seq,
 
77
                                           const unsigned char *src,
 
78
                                           const unsigned char *src_end,
 
79
                                           unsigned char *dst)
69
80
{
70
81
    const unsigned char *color_table;
71
82
    int b, i, len, bits;
72
83
    GetBitContext gb;
73
84
    unsigned char block[8 * 8];
74
85
 
 
86
    if (src_end - src < 1)
 
87
        return NULL;
75
88
    len = *src++;
76
89
    if (len & 0x80) {
77
90
        switch (len & 3) {
78
91
        case 1:
79
 
            src = seq_unpack_rle_block(src, block, sizeof(block));
 
92
            src = seq_unpack_rle_block(src, src_end, block, sizeof(block));
80
93
            for (b = 0; b < 8; b++) {
81
94
                memcpy(dst, &block[b * 8], 8);
82
95
                dst += seq->frame.linesize[0];
83
96
            }
84
97
            break;
85
98
        case 2:
86
 
            src = seq_unpack_rle_block(src, block, sizeof(block));
 
99
            src = seq_unpack_rle_block(src, src_end, block, sizeof(block));
87
100
            for (i = 0; i < 8; i++) {
88
101
                for (b = 0; b < 8; b++)
89
102
                    dst[b * seq->frame.linesize[0]] = block[i * 8 + b];
92
105
            break;
93
106
        }
94
107
    } else {
 
108
        if (len <= 0)
 
109
            return NULL;
 
110
        bits = ff_log2_tab[len - 1] + 1;
 
111
        if (src_end - src < len + 8 * bits)
 
112
            return NULL;
95
113
        color_table = src;
96
114
        src += len;
97
 
        bits = ff_log2_tab[len - 1] + 1;
98
115
        init_get_bits(&gb, src, bits * 8 * 8); src += bits * 8;
99
116
        for (b = 0; b < 8; b++) {
100
117
            for (i = 0; i < 8; i++)
106
123
    return src;
107
124
}
108
125
 
109
 
static const unsigned char *seq_decode_op2(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
 
126
static const unsigned char *seq_decode_op2(SeqVideoContext *seq,
 
127
                                           const unsigned char *src,
 
128
                                           const unsigned char *src_end,
 
129
                                           unsigned char *dst)
110
130
{
111
131
    int i;
112
132
 
 
133
    if (src_end - src < 8 * 8)
 
134
        return NULL;
 
135
 
113
136
    for (i = 0; i < 8; i++) {
114
137
        memcpy(dst, src, 8);
115
138
        src += 8;
119
142
    return src;
120
143
}
121
144
 
122
 
static const unsigned char *seq_decode_op3(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
 
145
static const unsigned char *seq_decode_op3(SeqVideoContext *seq,
 
146
                                           const unsigned char *src,
 
147
                                           const unsigned char *src_end,
 
148
                                           unsigned char *dst)
123
149
{
124
150
    int pos, offset;
125
151
 
126
152
    do {
 
153
        if (src_end - src < 2)
 
154
            return NULL;
127
155
        pos = *src++;
128
156
        offset = ((pos >> 3) & 7) * seq->frame.linesize[0] + (pos & 7);
129
157
        dst[offset] = *src++;
132
160
    return src;
133
161
}
134
162
 
135
 
static void seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size)
 
163
static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size)
136
164
{
 
165
    const unsigned char *data_end = data + data_size;
137
166
    GetBitContext gb;
138
167
    int flags, i, j, x, y, op;
139
168
    unsigned char c[3];
144
173
 
145
174
    if (flags & 1) {
146
175
        palette = (uint32_t *)seq->frame.data[1];
 
176
        if (data_end - data < 256 * 3)
 
177
            return AVERROR_INVALIDDATA;
147
178
        for (i = 0; i < 256; i++) {
148
179
            for (j = 0; j < 3; j++, data++)
149
180
                c[j] = (*data << 2) | (*data >> 4);
153
184
    }
154
185
 
155
186
    if (flags & 2) {
 
187
        if (data_end - data < 128)
 
188
            return AVERROR_INVALIDDATA;
156
189
        init_get_bits(&gb, data, 128 * 8); data += 128;
157
190
        for (y = 0; y < 128; y += 8)
158
191
            for (x = 0; x < 256; x += 8) {
160
193
                op = get_bits(&gb, 2);
161
194
                switch (op) {
162
195
                case 1:
163
 
                    data = seq_decode_op1(seq, data, dst);
 
196
                    data = seq_decode_op1(seq, data, data_end, dst);
164
197
                    break;
165
198
                case 2:
166
 
                    data = seq_decode_op2(seq, data, dst);
 
199
                    data = seq_decode_op2(seq, data, data_end, dst);
167
200
                    break;
168
201
                case 3:
169
 
                    data = seq_decode_op3(seq, data, dst);
 
202
                    data = seq_decode_op3(seq, data, data_end, dst);
170
203
                    break;
171
204
                }
 
205
                if (!data)
 
206
                    return AVERROR_INVALIDDATA;
172
207
            }
173
208
    }
 
209
    return 0;
174
210
}
175
211
 
176
212
static av_cold int seqvideo_decode_init(AVCodecContext *avctx)
201
237
        return -1;
202
238
    }
203
239
 
204
 
    seqvideo_decode(seq, buf, buf_size);
 
240
    if (seqvideo_decode(seq, buf, buf_size))
 
241
        return AVERROR_INVALIDDATA;
205
242
 
206
243
    *data_size = sizeof(AVFrame);
207
244
    *(AVFrame *)data = seq->frame;
220
257
}
221
258
 
222
259
AVCodec ff_tiertexseqvideo_decoder = {
223
 
    "tiertexseqvideo",
224
 
    AVMEDIA_TYPE_VIDEO,
225
 
    CODEC_ID_TIERTEXSEQVIDEO,
226
 
    sizeof(SeqVideoContext),
227
 
    seqvideo_decode_init,
228
 
    NULL,
229
 
    seqvideo_decode_end,
230
 
    seqvideo_decode_frame,
231
 
    CODEC_CAP_DR1,
 
260
    .name           = "tiertexseqvideo",
 
261
    .type           = AVMEDIA_TYPE_VIDEO,
 
262
    .id             = CODEC_ID_TIERTEXSEQVIDEO,
 
263
    .priv_data_size = sizeof(SeqVideoContext),
 
264
    .init           = seqvideo_decode_init,
 
265
    .close          = seqvideo_decode_end,
 
266
    .decode         = seqvideo_decode_frame,
 
267
    .capabilities   = CODEC_CAP_DR1,
232
268
    .long_name = NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ video"),
233
269
};