~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/qdrw.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc, Andrew Starr-Bochicchio, Lionel Le Folgoc
  • Date: 2008-12-26 00:10:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081226001006-2040ls9680bd1blt
Tags: 1.1.7-0.2ubuntu1
[ Andrew Starr-Bochicchio ]
* Merge from debian-multimedia (LP: #298547), Ubuntu Changes:
 - For ffmpeg-related build-deps, fix versionized dependencies
   as the ubuntu versioning is different than debian-multimedia's.

[ Lionel Le Folgoc ]
* LP: #311412 is fixed since the 1.1.7~rc1-0.1 revision.
* debian/patches/03_ffmpeg.diff: updated to fix FTBFS due to libswscale API
  change (cherry-pick from Gentoo #234383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * You should have received a copy of the GNU Lesser General Public
18
18
 * License along with FFmpeg; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 
 *
21
20
 */
22
21
 
23
22
/**
26
25
 */
27
26
 
28
27
#include "avcodec.h"
29
 
#include "mpegvideo.h"
30
28
 
31
29
typedef struct QdrawContext{
32
30
    AVCodecContext *avctx;
33
31
    AVFrame pic;
34
 
    uint8_t palette[256*3];
35
32
} QdrawContext;
36
33
 
37
34
static int decode_frame(AVCodecContext *avctx,
38
35
                        void *data, int *data_size,
39
 
                        uint8_t *buf, int buf_size)
 
36
                        const uint8_t *buf, int buf_size)
40
37
{
41
38
    QdrawContext * const a = avctx->priv_data;
42
39
    AVFrame * const p= (AVFrame*)&a->pic;
43
40
    uint8_t* outdata;
44
41
    int colors;
45
42
    int i;
 
43
    uint32_t *pal;
 
44
    int r, g, b;
46
45
 
47
46
    if(p->data[0])
48
47
        avctx->release_buffer(avctx, p);
52
51
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
53
52
        return -1;
54
53
    }
55
 
    p->pict_type= I_TYPE;
 
54
    p->pict_type= FF_I_TYPE;
56
55
    p->key_frame= 1;
57
56
 
58
57
    outdata = a->pic.data[0];
66
65
        return -1;
67
66
    }
68
67
 
 
68
    pal = (uint32_t*)p->data[1];
69
69
    for (i = 0; i <= colors; i++) {
70
70
        unsigned int idx;
71
71
        idx = AV_RB16(buf); /* color index */
76
76
            buf += 6;
77
77
            continue;
78
78
        }
79
 
        a->palette[idx * 3 + 0] = *buf++;
80
 
        buf++;
81
 
        a->palette[idx * 3 + 1] = *buf++;
82
 
        buf++;
83
 
        a->palette[idx * 3 + 2] = *buf++;
84
 
        buf++;
 
79
        r = *buf++;
 
80
        buf++;
 
81
        g = *buf++;
 
82
        buf++;
 
83
        b = *buf++;
 
84
        buf++;
 
85
        pal[idx] = (r << 16) | (g << 8) | b;
85
86
    }
 
87
    p->palette_has_changed = 1;
86
88
 
87
89
    buf += 18; /* skip unneeded data */
88
90
    for (i = 0; i < avctx->height; i++) {
89
91
        int size, left, code, pix;
90
 
        uint8_t *next;
 
92
        const uint8_t *next;
91
93
        uint8_t *out;
92
94
        int tsize = 0;
93
95
 
100
102
        while (left > 0) {
101
103
            code = *buf++;
102
104
            if (code & 0x80 ) { /* run */
103
 
                int i;
104
105
                pix = *buf++;
105
 
                if ((out + (257 - code) * 3) > (outdata +  a->pic.linesize[0]))
 
106
                if ((out + (257 - code)) > (outdata +  a->pic.linesize[0]))
106
107
                    break;
107
 
                for (i = 0; i < 257 - code; i++) {
108
 
                    *out++ = a->palette[pix * 3 + 0];
109
 
                    *out++ = a->palette[pix * 3 + 1];
110
 
                    *out++ = a->palette[pix * 3 + 2];
111
 
                }
 
108
                memset(out, pix, 257 - code);
 
109
                out += 257 - code;
112
110
                tsize += 257 - code;
113
111
                left -= 2;
114
112
            } else { /* copy */
115
 
                int i, pix;
116
 
                if ((out + code * 3) > (outdata +  a->pic.linesize[0]))
 
113
                if ((out + code) > (outdata +  a->pic.linesize[0]))
117
114
                    break;
118
 
                for (i = 0; i <= code; i++) {
119
 
                    pix = *buf++;
120
 
                    *out++ = a->palette[pix * 3 + 0];
121
 
                    *out++ = a->palette[pix * 3 + 1];
122
 
                    *out++ = a->palette[pix * 3 + 2];
123
 
                }
 
115
                memcpy(out, buf, code + 1);
 
116
                out += code + 1;
 
117
                buf += code + 1;
124
118
                left -= 2 + code;
125
119
                tsize += code + 1;
126
120
            }
135
129
    return buf_size;
136
130
}
137
131
 
138
 
static int decode_init(AVCodecContext *avctx){
 
132
static av_cold int decode_init(AVCodecContext *avctx){
139
133
//    QdrawContext * const a = avctx->priv_data;
140
134
 
141
135
    if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
142
136
        return 1;
143
137
    }
144
138
 
145
 
    avctx->pix_fmt= PIX_FMT_RGB24;
 
139
    avctx->pix_fmt= PIX_FMT_PAL8;
146
140
 
147
141
    return 0;
148
142
}
157
151
    NULL,
158
152
    decode_frame,
159
153
    CODEC_CAP_DR1,
 
154
    .long_name = "Apple QuickDraw",
160
155
};