Revision db4fac64 libavcodec/dvdsubenc.c

View differences:

libavcodec/dvdsubenc.c
108 108
        cmap[i] = 0;
109 109
    }
110 110
    for (object_id = 0; object_id < rects; object_id++)
111
        for (i=0; i<h->rects[object_id].w*h->rects[object_id].h; ++i) {
112
            color = h->rects[object_id].bitmap[i];
111
        for (i=0; i<h->rects[object_id]->w*h->rects[object_id]->h; ++i) {
112
            color = h->rects[object_id]->bitmap[i];
113 113
            // only count non-transparent pixels
114
            alpha = h->rects[object_id].rgba_palette[color] >> 24;
114
            alpha = h->rects[object_id]->rgba_palette[color] >> 24;
115 115
            hist[color] += alpha;
116 116
        }
117 117
    for (color=3;; --color) {
......
138 138
    for (object_id = 0; object_id < rects; object_id++) {
139 139
        offset1[object_id] = q - outbuf;
140 140
        // worst case memory requirement: 1 nibble per pixel..
141
        if ((q - outbuf) + h->rects[object_id].w*h->rects[object_id].h/2
141
        if ((q - outbuf) + h->rects[object_id]->w*h->rects[object_id]->h/2
142 142
            + 17*rects + 21 > outbuf_size) {
143 143
            av_log(NULL, AV_LOG_ERROR, "dvd_subtitle too big\n");
144 144
            return -1;
145 145
        }
146
        dvd_encode_rle(&q, h->rects[object_id].bitmap,
147
                       h->rects[object_id].w*2,
148
                       h->rects[object_id].w, h->rects[object_id].h >> 1,
146
        dvd_encode_rle(&q, h->rects[object_id]->bitmap,
147
                       h->rects[object_id]->w*2,
148
                       h->rects[object_id]->w, h->rects[object_id]->h >> 1,
149 149
                       cmap);
150 150
        offset2[object_id] = q - outbuf;
151
        dvd_encode_rle(&q, h->rects[object_id].bitmap + h->rects[object_id].w,
152
                       h->rects[object_id].w*2,
153
                       h->rects[object_id].w, h->rects[object_id].h >> 1,
151
        dvd_encode_rle(&q, h->rects[object_id]->bitmap + h->rects[object_id]->w,
152
                       h->rects[object_id]->w*2,
153
                       h->rects[object_id]->w, h->rects[object_id]->h >> 1,
154 154
                       cmap);
155 155
    }
156 156

  
......
170 170
    // XXX not sure if more than one rect can really be encoded..
171 171
    // 12 bytes per rect
172 172
    for (object_id = 0; object_id < rects; object_id++) {
173
        int x2 = h->rects[object_id].x + h->rects[object_id].w - 1;
174
        int y2 = h->rects[object_id].y + h->rects[object_id].h - 1;
173
        int x2 = h->rects[object_id]->x + h->rects[object_id]->w - 1;
174
        int y2 = h->rects[object_id]->y + h->rects[object_id]->h - 1;
175 175

  
176 176
        *q++ = 0x05;
177 177
        // x1 x2 -> 6 nibbles
178
        *q++ = h->rects[object_id].x >> 4;
179
        *q++ = (h->rects[object_id].x << 4) | ((x2 >> 8) & 0xf);
178
        *q++ = h->rects[object_id]->x >> 4;
179
        *q++ = (h->rects[object_id]->x << 4) | ((x2 >> 8) & 0xf);
180 180
        *q++ = x2;
181 181
        // y1 y2 -> 6 nibbles
182
        *q++ = h->rects[object_id].y >> 4;
183
        *q++ = (h->rects[object_id].y << 4) | ((y2 >> 8) & 0xf);
182
        *q++ = h->rects[object_id]->y >> 4;
183
        *q++ = (h->rects[object_id]->y << 4) | ((y2 >> 8) & 0xf);
184 184
        *q++ = y2;
185 185

  
186 186
        *q++ = 0x06;

Also available in: Unified diff