libavformat/mpegtsenc.c:962: error: Uninitialized Value
  The value read from buf[_] was never initialized.

libavformat/mpegtsenc.c:962:17: 
960.                 /* add stuffing */
961.                 memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4);
962.                 buf[3] |= 0x20;
                     ^
963.                 buf[4]  = stuffing_len - 1;
964.                 if (stuffing_len >= 2) {

static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
                             const uint8_t *payload, int payload_size,
                             int64_t pts, int64_t dts, int key)
{
    MpegTSWriteStream *ts_st = st->priv_data;
    MpegTSWrite *ts = s->priv_data;
    uint8_t buf[TS_PACKET_SIZE];
    uint8_t *q;
    int val, is_start, len, header_len, write_pcr, private_code, flags;
    int afc_len, stuffing_len;
    int64_t pcr = -1;
    int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
    is_start = 1;
    while (payload_size > 0) {
        retransmit_si_info(s);
        write_pcr = 0;
        if (ts_st->pid == ts_st->service->pcr_pid) {
            if (ts->mux_rate > 1 || is_start)
                ts_st->service->pcr_packet_count++;
            if (ts_st->service->pcr_packet_count >=
                ts_st->service->pcr_packet_period) {
                ts_st->service->pcr_packet_count = 0;
                write_pcr = 1;
            }
        }
        if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE &&
            (dts - get_pcr(ts, s->pb) / 300) > delay) {
            if (write_pcr)
                mpegts_insert_pcr_only(s, st);
            else
                mpegts_insert_null_packet(s);
            continue;
        }
        q    = buf;
        *q++ = 0x47;
        val  = ts_st->pid >> 8;
        if (is_start)
            val |= 0x40;
        *q++      = val;
        *q++      = ts_st->pid;
        ts_st->cc = ts_st->cc + 1 & 0xf;
        *q++      = 0x10 | ts_st->cc;
        if (key && is_start && pts != AV_NOPTS_VALUE) {
            if (ts_st->pid == ts_st->service->pcr_pid)
                write_pcr = 1;
            set_af_flag(buf, 0x40);
            q = get_ts_payload_start(buf);
        }
        if (write_pcr) {
            set_af_flag(buf, 0x10);
            q = get_ts_payload_start(buf);
            if (ts->mux_rate > 1)
                pcr = get_pcr(ts, s->pb);
            else
                pcr = (dts - delay) * 300;
            if (dts != AV_NOPTS_VALUE && dts < pcr / 300)
                av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\n");
            extend_af(buf, write_pcr_bits(q, pcr));
            q = get_ts_payload_start(buf);
        }
        if (is_start) {
            int pes_extension = 0;
            *q++ = 0x00;
            *q++ = 0x00;
            *q++ = 0x01;
            private_code = 0;
            if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
                if (st->codec->codec_id == AV_CODEC_ID_DIRAC)
                    *q++ = 0xfd;
                else
                    *q++ = 0xe0;
            } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
                       (st->codec->codec_id == AV_CODEC_ID_MP2 ||
                        st->codec->codec_id == AV_CODEC_ID_MP3 ||
                        st->codec->codec_id == AV_CODEC_ID_AAC)) {
                *q++ = 0xc0;
            } else {
                *q++ = 0xbd;
                if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
                    private_code = 0x20;
            }
            header_len = 0;
            flags      = 0;
            if (pts != AV_NOPTS_VALUE) {
                header_len += 5;
                flags      |= 0x80;
            }
            if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
                header_len += 5;
                flags      |= 0x40;
            }
            if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
                st->codec->codec_id == AV_CODEC_ID_DIRAC) {
                pes_extension = 1;
                flags        |= 0x01;
                header_len += 3;
            }
            len = payload_size + header_len + 3;
            if (private_code != 0)
                len++;
            if (len > 0xffff)
                len = 0;
            *q++ = len >> 8;
            *q++ = len;
            val  = 0x80;
            if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
                val |= 0x04;
            *q++ = val;
            *q++ = flags;
            *q++ = header_len;
            if (pts != AV_NOPTS_VALUE) {
                write_pts(q, flags >> 6, pts);
                q += 5;
            }
            if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
                write_pts(q, 1, dts);
                q += 5;
            }
            if (pes_extension && st->codec->codec_id == AV_CODEC_ID_DIRAC) {
                flags = 0x01;
                *q++  = flags;
                *q++  = 0x80 | 0x01;
                *q++ = 0x00 | 0x60;
            }
            if (private_code != 0)
                *q++ = private_code;
            is_start = 0;
        }
        header_len = q - buf;
        len = TS_PACKET_SIZE - header_len;
        if (len > payload_size)
            len = payload_size;
        stuffing_len = TS_PACKET_SIZE - header_len - len;
        if (stuffing_len > 0) {
            if (buf[3] & 0x20) {
                afc_len = buf[4] + 1;
                memmove(buf + 4 + afc_len + stuffing_len,
                        buf + 4 + afc_len,
                        header_len - (4 + afc_len));
                buf[4] += stuffing_len;
                memset(buf + 4 + afc_len, 0xff, stuffing_len);
            } else {
                memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4);
                buf[3] |= 0x20;
                buf[4]  = stuffing_len - 1;
                if (stuffing_len >= 2) {
                    buf[5] = 0x00;
                    memset(buf + 6, 0xff, stuffing_len - 2);
                }
            }
        }
        memcpy(buf + TS_PACKET_SIZE - len, payload, len);
        payload      += len;
        payload_size -= len;
        avio_write(s->pb, buf, TS_PACKET_SIZE);
    }
    avio_flush(s->pb);
}
['static void mpegts_write_pes(AVFormatContext *s, AVStream *st,\n                             const uint8_t *payload, int payload_size,\n                             int64_t pts, int64_t dts, int key)\n{\n    MpegTSWriteStream *ts_st = st->priv_data;\n    MpegTSWrite *ts = s->priv_data;\n    uint8_t buf[TS_PACKET_SIZE];\n    uint8_t *q;\n    int val, is_start, len, header_len, write_pcr, private_code, flags;\n    int afc_len, stuffing_len;\n    int64_t pcr = -1;\n    int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);\n    is_start = 1;\n    while (payload_size > 0) {\n        retransmit_si_info(s);\n        write_pcr = 0;\n        if (ts_st->pid == ts_st->service->pcr_pid) {\n            if (ts->mux_rate > 1 || is_start)\n                ts_st->service->pcr_packet_count++;\n            if (ts_st->service->pcr_packet_count >=\n                ts_st->service->pcr_packet_period) {\n                ts_st->service->pcr_packet_count = 0;\n                write_pcr = 1;\n            }\n        }\n        if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE &&\n            (dts - get_pcr(ts, s->pb) / 300) > delay) {\n            if (write_pcr)\n                mpegts_insert_pcr_only(s, st);\n            else\n                mpegts_insert_null_packet(s);\n            continue;\n        }\n        q    = buf;\n        *q++ = 0x47;\n        val  = ts_st->pid >> 8;\n        if (is_start)\n            val |= 0x40;\n        *q++      = val;\n        *q++      = ts_st->pid;\n        ts_st->cc = ts_st->cc + 1 & 0xf;\n        *q++      = 0x10 | ts_st->cc;\n        if (key && is_start && pts != AV_NOPTS_VALUE) {\n            if (ts_st->pid == ts_st->service->pcr_pid)\n                write_pcr = 1;\n            set_af_flag(buf, 0x40);\n            q = get_ts_payload_start(buf);\n        }\n        if (write_pcr) {\n            set_af_flag(buf, 0x10);\n            q = get_ts_payload_start(buf);\n            if (ts->mux_rate > 1)\n                pcr = get_pcr(ts, s->pb);\n            else\n                pcr = (dts - delay) * 300;\n            if (dts != AV_NOPTS_VALUE && dts < pcr / 300)\n                av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\\n");\n            extend_af(buf, write_pcr_bits(q, pcr));\n            q = get_ts_payload_start(buf);\n        }\n        if (is_start) {\n            int pes_extension = 0;\n            *q++ = 0x00;\n            *q++ = 0x00;\n            *q++ = 0x01;\n            private_code = 0;\n            if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {\n                if (st->codec->codec_id == AV_CODEC_ID_DIRAC)\n                    *q++ = 0xfd;\n                else\n                    *q++ = 0xe0;\n            } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&\n                       (st->codec->codec_id == AV_CODEC_ID_MP2 ||\n                        st->codec->codec_id == AV_CODEC_ID_MP3 ||\n                        st->codec->codec_id == AV_CODEC_ID_AAC)) {\n                *q++ = 0xc0;\n            } else {\n                *q++ = 0xbd;\n                if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)\n                    private_code = 0x20;\n            }\n            header_len = 0;\n            flags      = 0;\n            if (pts != AV_NOPTS_VALUE) {\n                header_len += 5;\n                flags      |= 0x80;\n            }\n            if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {\n                header_len += 5;\n                flags      |= 0x40;\n            }\n            if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&\n                st->codec->codec_id == AV_CODEC_ID_DIRAC) {\n                pes_extension = 1;\n                flags        |= 0x01;\n                header_len += 3;\n            }\n            len = payload_size + header_len + 3;\n            if (private_code != 0)\n                len++;\n            if (len > 0xffff)\n                len = 0;\n            *q++ = len >> 8;\n            *q++ = len;\n            val  = 0x80;\n            if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)\n                val |= 0x04;\n            *q++ = val;\n            *q++ = flags;\n            *q++ = header_len;\n            if (pts != AV_NOPTS_VALUE) {\n                write_pts(q, flags >> 6, pts);\n                q += 5;\n            }\n            if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {\n                write_pts(q, 1, dts);\n                q += 5;\n            }\n            if (pes_extension && st->codec->codec_id == AV_CODEC_ID_DIRAC) {\n                flags = 0x01;\n                *q++  = flags;\n                *q++  = 0x80 | 0x01;\n                *q++ = 0x00 | 0x60;\n            }\n            if (private_code != 0)\n                *q++ = private_code;\n            is_start = 0;\n        }\n        header_len = q - buf;\n        len = TS_PACKET_SIZE - header_len;\n        if (len > payload_size)\n            len = payload_size;\n        stuffing_len = TS_PACKET_SIZE - header_len - len;\n        if (stuffing_len > 0) {\n            if (buf[3] & 0x20) {\n                afc_len = buf[4] + 1;\n                memmove(buf + 4 + afc_len + stuffing_len,\n                        buf + 4 + afc_len,\n                        header_len - (4 + afc_len));\n                buf[4] += stuffing_len;\n                memset(buf + 4 + afc_len, 0xff, stuffing_len);\n            } else {\n                memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4);\n                buf[3] |= 0x20;\n                buf[4]  = stuffing_len - 1;\n                if (stuffing_len >= 2) {\n                    buf[5] = 0x00;\n                    memset(buf + 6, 0xff, stuffing_len - 2);\n                }\n            }\n        }\n        memcpy(buf + TS_PACKET_SIZE - len, payload, len);\n        payload      += len;\n        payload_size -= len;\n        avio_write(s->pb, buf, TS_PACKET_SIZE);\n    }\n    avio_flush(s->pb);\n}']