libavcodec/dvdsubenc.c:189: error: Uninitialized Value
  The value read from offset2[_] was never initialized.

libavcodec/dvdsubenc.c:189:9: 
187.         // offset1, offset2
188.         bytestream_put_be16(&q, offset1[object_id]);
189.         bytestream_put_be16(&q, offset2[object_id]);
             ^
190.     }
191.     *q++ = 0x01; // start command

static int encode_dvd_subtitles(uint8_t *outbuf, int outbuf_size,
                                const AVSubtitle *h)
{
    uint8_t *q, *qq;
    int object_id;
    int offset1[20], offset2[20];
    int i, imax, color, alpha, rects = h->num_rects;
    unsigned long hmax;
    unsigned long hist[256];
    int           cmap[256];
    if (rects == 0 || h->rects == NULL)
        return -1;
    if (rects > 20)
        rects = 20;
    for (i=0; i<256; ++i) {
        hist[i] = 0;
        cmap[i] = 0;
    }
    for (object_id = 0; object_id < rects; object_id++)
        for (i=0; i<h->rects[object_id].w*h->rects[object_id].h; ++i) {
            color = h->rects[object_id].bitmap[i];
            alpha = h->rects[object_id].rgba_palette[color] >> 24;
            hist[color] += alpha;
        }
    for (color=3;; --color) {
        hmax = 0;
        imax = 0;
        for (i=0; i<256; ++i)
            if (hist[i] > hmax) {
                imax = i;
                hmax = hist[i];
            }
        if (hmax == 0)
            break;
        if (color == 0)
            color = 3;
        av_log(NULL, AV_LOG_DEBUG, "dvd_subtitle hist[%d]=%ld -> col %d\n",
               imax, hist[imax], color);
        cmap[imax] = color;
        hist[imax] = 0;
    }
    q = outbuf + 4;
    for (object_id = 0; object_id < rects; object_id++) {
        offset1[object_id] = q - outbuf;
        if ((q - outbuf) + h->rects[object_id].w*h->rects[object_id].h/2
            + 17*rects + 21 > outbuf_size) {
            av_log(NULL, AV_LOG_ERROR, "dvd_subtitle too big\n");
            return -1;
        }
        dvd_encode_rle(&q, h->rects[object_id].bitmap,
                       h->rects[object_id].w*2,
                       h->rects[object_id].w, h->rects[object_id].h >> 1,
                       cmap);
        offset2[object_id] = q - outbuf;
        dvd_encode_rle(&q, h->rects[object_id].bitmap + h->rects[object_id].w,
                       h->rects[object_id].w*2,
                       h->rects[object_id].w, h->rects[object_id].h >> 1,
                       cmap);
    }
    qq = outbuf + 2;
    bytestream_put_be16(&qq, q - outbuf);
    bytestream_put_be16(&q, (h->start_display_time*90) >> 10);
    bytestream_put_be16(&q, (q - outbuf)   + 8 + 12*rects + 2);
    *q++ = 0x03;
    *q++ = 0x03; *q++ = 0x7f;
    *q++ = 0x04;
    *q++ = 0xf0; *q++ = 0x00;
    for (object_id = 0; object_id < rects; object_id++) {
        int x2 = h->rects[object_id].x + h->rects[object_id].w - 1;
        int y2 = h->rects[object_id].y + h->rects[object_id].h - 1;
        *q++ = 0x05;
        *q++ = h->rects[object_id].x >> 4;
        *q++ = (h->rects[object_id].x << 4) | ((x2 >> 8) & 0xf);
        *q++ = x2;
        *q++ = h->rects[object_id].y >> 4;
        *q++ = (h->rects[object_id].y << 4) | ((y2 >> 8) & 0xf);
        *q++ = y2;
        *q++ = 0x06;
        bytestream_put_be16(&q, offset1[object_id]);
        bytestream_put_be16(&q, offset2[object_id]);
    }
    *q++ = 0x01;
    *q++ = 0xff;
    bytestream_put_be16(&q, (h->end_display_time*90) >> 10);
    bytestream_put_be16(&q, (q - outbuf) - 2  );
    *q++ = 0x02;
    *q++ = 0xff;
    qq = outbuf;
    bytestream_put_be16(&qq, q - outbuf);
    av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%td\n", q - outbuf);
    return q - outbuf;
}
['static int encode_dvd_subtitles(uint8_t *outbuf, int outbuf_size,\n                                const AVSubtitle *h)\n{\n    uint8_t *q, *qq;\n    int object_id;\n    int offset1[20], offset2[20];\n    int i, imax, color, alpha, rects = h->num_rects;\n    unsigned long hmax;\n    unsigned long hist[256];\n    int           cmap[256];\n    if (rects == 0 || h->rects == NULL)\n        return -1;\n    if (rects > 20)\n        rects = 20;\n    for (i=0; i<256; ++i) {\n        hist[i] = 0;\n        cmap[i] = 0;\n    }\n    for (object_id = 0; object_id < rects; object_id++)\n        for (i=0; i<h->rects[object_id].w*h->rects[object_id].h; ++i) {\n            color = h->rects[object_id].bitmap[i];\n            alpha = h->rects[object_id].rgba_palette[color] >> 24;\n            hist[color] += alpha;\n        }\n    for (color=3;; --color) {\n        hmax = 0;\n        imax = 0;\n        for (i=0; i<256; ++i)\n            if (hist[i] > hmax) {\n                imax = i;\n                hmax = hist[i];\n            }\n        if (hmax == 0)\n            break;\n        if (color == 0)\n            color = 3;\n        av_log(NULL, AV_LOG_DEBUG, "dvd_subtitle hist[%d]=%ld -> col %d\\n",\n               imax, hist[imax], color);\n        cmap[imax] = color;\n        hist[imax] = 0;\n    }\n    q = outbuf + 4;\n    for (object_id = 0; object_id < rects; object_id++) {\n        offset1[object_id] = q - outbuf;\n        if ((q - outbuf) + h->rects[object_id].w*h->rects[object_id].h/2\n            + 17*rects + 21 > outbuf_size) {\n            av_log(NULL, AV_LOG_ERROR, "dvd_subtitle too big\\n");\n            return -1;\n        }\n        dvd_encode_rle(&q, h->rects[object_id].bitmap,\n                       h->rects[object_id].w*2,\n                       h->rects[object_id].w, h->rects[object_id].h >> 1,\n                       cmap);\n        offset2[object_id] = q - outbuf;\n        dvd_encode_rle(&q, h->rects[object_id].bitmap + h->rects[object_id].w,\n                       h->rects[object_id].w*2,\n                       h->rects[object_id].w, h->rects[object_id].h >> 1,\n                       cmap);\n    }\n    qq = outbuf + 2;\n    bytestream_put_be16(&qq, q - outbuf);\n    bytestream_put_be16(&q, (h->start_display_time*90) >> 10);\n    bytestream_put_be16(&q, (q - outbuf)   + 8 + 12*rects + 2);\n    *q++ = 0x03;\n    *q++ = 0x03; *q++ = 0x7f;\n    *q++ = 0x04;\n    *q++ = 0xf0; *q++ = 0x00;\n    for (object_id = 0; object_id < rects; object_id++) {\n        int x2 = h->rects[object_id].x + h->rects[object_id].w - 1;\n        int y2 = h->rects[object_id].y + h->rects[object_id].h - 1;\n        *q++ = 0x05;\n        *q++ = h->rects[object_id].x >> 4;\n        *q++ = (h->rects[object_id].x << 4) | ((x2 >> 8) & 0xf);\n        *q++ = x2;\n        *q++ = h->rects[object_id].y >> 4;\n        *q++ = (h->rects[object_id].y << 4) | ((y2 >> 8) & 0xf);\n        *q++ = y2;\n        *q++ = 0x06;\n        bytestream_put_be16(&q, offset1[object_id]);\n        bytestream_put_be16(&q, offset2[object_id]);\n    }\n    *q++ = 0x01;\n    *q++ = 0xff;\n    bytestream_put_be16(&q, (h->end_display_time*90) >> 10);\n    bytestream_put_be16(&q, (q - outbuf) - 2  );\n    *q++ = 0x02;\n    *q++ = 0xff;\n    qq = outbuf;\n    bytestream_put_be16(&qq, q - outbuf);\n    av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%td\\n", q - outbuf);\n    return q - outbuf;\n}']