avtools/avconv.c:2567: error: Integer Overflow L2
  ([1, 2147483616] + 32):signed32 by call to `process_input_packet`.

avtools/avconv.c:2568:13: Call
2566.         if (ist->decoding_needed) {
2567.             process_input_packet(ist, NULL, 1);
2568.             avcodec_flush_buffers(avctx);
                  ^
2569.         }
2570. 

libavcodec/decode.c:1417:5: Call
  1415.         avctx->codec->flush(avctx);
  1416. 
  1417.     bsfs_flush(avctx);
            ^
  1418. 
  1419.     if (!avctx->refcounted_frames)

libavcodec/decode.c:1397:10: Assignment
    1395.     DecodeFilterContext *s = &avctx->internal->filter;
    1396. 
    1397.     for (int i = 0; i < s->nb_bsfs; i++)
                   ^
    1398.         av_bsf_flush(s->bsfs[i]);
    1399. }

avtools/avconv.c:2567:13: Call
2565.         // flush decoders
2566.         if (ist->decoding_needed) {
2567.             process_input_packet(ist, NULL, 1);
                  ^
2568.             avcodec_flush_buffers(avctx);
2569.         }

avtools/avconv.c:1495:1: Parameter `ist->decoded_frame->nb_samples`
  1493. 
  1494. /* pkt = NULL means EOF (needed to flush decoder buffers) */
  1495. static void process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
        ^
  1496. {
  1497.     int i;

avtools/avconv.c:1527:19: Call
  1525.         switch (ist->dec_ctx->codec_type) {
  1526.         case AVMEDIA_TYPE_AUDIO:
  1527.             ret = decode_audio    (ist, repeating ? NULL : &avpkt, &got_output,
                          ^
  1528.                                    &decode_failed);
  1529.             break;

avtools/avconv.c:1346:1: Parameter `ist->decoded_frame->nb_samples`
    1344. }
    1345. 
    1346. static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output,
          ^
    1347.                         int *decode_failed)
    1348. {

avtools/avconv.c:1384:19: Call
    1382.         if (i < ist->nb_filters - 1) {
    1383.             f = ist->filter_frame;
    1384.             err = av_frame_ref(f, decoded_frame);
                            ^
    1385.             if (err < 0)
    1386.                 break;

libavutil/frame.c:192:1: Parameter `src->nb_samples`
      190. }
      191. 
      192. int av_frame_ref(AVFrame *dst, const AVFrame *src)
           ^
      193. {
      194.     int i, ret = 0;

libavutil/frame.c:200:5: Assignment
      198.     dst->height         = src->height;
      199.     dst->channel_layout = src->channel_layout;
      200.     dst->nb_samples     = src->nb_samples;
               ^
      201. 
      202.     ret = av_frame_copy_props(dst, src);

libavutil/frame.c:208:15: Call
      206.     /* duplicate the frame data if it's not refcounted */
      207.     if (!src->buf[0]) {
      208.         ret = av_frame_get_buffer(dst, 32);
                         ^
      209.         if (ret < 0)
      210.             return ret;

libavutil/frame.c:179:1: Parameter `frame->nb_samples`
        177. }
        178. 
        179. int av_frame_get_buffer(AVFrame *frame, int align)
             ^
        180. {
        181.     if (frame->format < 0)

libavutil/frame.c:187:16: Call
        185.         return get_video_buffer(frame, align);
        186.     else if (frame->nb_samples > 0 && frame->channel_layout)
        187.         return get_audio_buffer(frame, align);
                            ^
        188. 
        189.     return AVERROR(EINVAL);

libavutil/frame.c:130:1: Parameter `frame->nb_samples`
          128. }
          129. 
          130. static int get_audio_buffer(AVFrame *frame, int align)
               ^
          131. {
          132.     int channels = av_get_channel_layout_nb_channels(frame->channel_layout);

libavutil/frame.c:138:15: Call
          136. 
          137.     if (!frame->linesize[0]) {
          138.         ret = av_samples_get_buffer_size(&frame->linesize[0], channels,
                             ^
          139.                                          frame->nb_samples, frame->format,
          140.                                          align);

libavutil/samplefmt.c:108:1: <LHS trace>
106. }
107. 
108. int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
     ^
109.                                enum AVSampleFormat sample_fmt, int align)
110. {

libavutil/samplefmt.c:108:1: Parameter `nb_samples`
            106. }
            107. 
            108. int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
                 ^
            109.                                enum AVSampleFormat sample_fmt, int align)
            110. {

libavutil/samplefmt.c:124:9: Binary operation: ([1, 2147483616] + 32):signed32 by call to `process_input_packet` 
            122.             return AVERROR(EINVAL);
            123.         align = 1;
            124.         nb_samples = FFALIGN(nb_samples, 32);
                         ^
            125.     }
            126. 

int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
                               enum AVSampleFormat sample_fmt, int align)
{
    int line_size;
    int sample_size = av_get_bytes_per_sample(sample_fmt);
    int planar      = av_sample_fmt_is_planar(sample_fmt);
    if (!sample_size || nb_samples <= 0 || nb_channels <= 0)
        return AVERROR(EINVAL);
    if (!align) {
        if (nb_samples > INT_MAX - 31)
            return AVERROR(EINVAL);
        align = 1;
        nb_samples = FFALIGN(nb_samples, 32);
    }
    if (nb_channels > INT_MAX / align ||
        (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)
        return AVERROR(EINVAL);
    line_size = planar ? FFALIGN(nb_samples * sample_size,               align) :
                         FFALIGN(nb_samples * sample_size * nb_channels, align);
    if (linesize)
        *linesize = line_size;
    return planar ? line_size * nb_channels : line_size;
}
['static int seek_to_start(InputFile *ifile, AVFormatContext *is)\n{\n    InputStream *ist;\n    AVCodecContext *avctx;\n    int i, ret, has_audio = 0;\n    int64_t duration = 0;\n    ret = av_seek_frame(is, -1, is->start_time, 0);\n    if (ret < 0)\n        return ret;\n    for (i = 0; i < ifile->nb_streams; i++) {\n        ist   = input_streams[ifile->ist_index + i];\n        avctx = ist->dec_ctx;\n        if (ist->decoding_needed) {\n            process_input_packet(ist, NULL, 1);\n            avcodec_flush_buffers(avctx);\n        }\n        if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && ist->nb_samples)\n            has_audio = 1;\n    }\n    for (i = 0; i < ifile->nb_streams; i++) {\n        ist   = input_streams[ifile->ist_index + i];\n        avctx = ist->dec_ctx;\n        if (has_audio) {\n            if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && ist->nb_samples) {\n                AVRational sample_rate = {1, avctx->sample_rate};\n                duration = av_rescale_q(ist->nb_samples, sample_rate, ist->st->time_base);\n            } else\n                continue;\n        } else {\n            if (ist->framerate.num) {\n                duration = FFMAX(av_rescale_q(1, av_inv_q(ist->framerate), ist->st->time_base), 1);\n            } else if (ist->st->avg_frame_rate.num) {\n                duration = FFMAX(av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate), ist->st->time_base), 1);\n            } else duration = 1;\n        }\n        if (!ifile->duration)\n            ifile->time_base = ist->st->time_base;\n        duration += ist->max_pts - ist->min_pts;\n        ifile->time_base = duration_max(duration, &ifile->duration, ist->st->time_base,\n                                        ifile->time_base);\n    }\n    if (ifile->loop > 0)\n        ifile->loop--;\n    return ret;\n}', 'void avcodec_flush_buffers(AVCodecContext *avctx)\n{\n    avctx->internal->draining      = 0;\n    avctx->internal->draining_done = 0;\n    av_frame_unref(avctx->internal->buffer_frame);\n    av_frame_unref(avctx->internal->compat_decode_frame);\n    av_packet_unref(avctx->internal->buffer_pkt);\n    avctx->internal->buffer_pkt_valid = 0;\n    av_packet_unref(avctx->internal->ds.in_pkt);\n    if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)\n        ff_thread_flush(avctx);\n    else if (avctx->codec->flush)\n        avctx->codec->flush(avctx);\n    bsfs_flush(avctx);\n    if (!avctx->refcounted_frames)\n        av_frame_unref(avctx->internal->to_free);\n}', 'static void bsfs_flush(AVCodecContext *avctx)\n{\n    DecodeFilterContext *s = &avctx->internal->filter;\n    for (int i = 0; i < s->nb_bsfs; i++)\n        av_bsf_flush(s->bsfs[i]);\n}', 'static void process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)\n{\n    int i;\n    int repeating = 0;\n    AVPacket avpkt;\n    if (ist->next_dts == AV_NOPTS_VALUE)\n        ist->next_dts = ist->last_dts;\n    if (!pkt) {\n        av_init_packet(&avpkt);\n        avpkt.data = NULL;\n        avpkt.size = 0;\n    } else {\n        avpkt = *pkt;\n    }\n    if (pkt && pkt->dts != AV_NOPTS_VALUE)\n        ist->next_dts = ist->last_dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);\n    while (ist->decoding_needed && (!pkt || avpkt.size > 0)) {\n        int ret = 0;\n        int got_output = 0;\n        int decode_failed = 0;\n        if (!repeating)\n            ist->last_dts = ist->next_dts;\n        switch (ist->dec_ctx->codec_type) {\n        case AVMEDIA_TYPE_AUDIO:\n            ret = decode_audio    (ist, repeating ? NULL : &avpkt, &got_output,\n                                   &decode_failed);\n            break;\n        case AVMEDIA_TYPE_VIDEO:\n            ret = decode_video    (ist, repeating ? NULL : &avpkt, &got_output,\n                                   &decode_failed);\n            if (repeating && !got_output)\n                ;\n            else if (pkt && pkt->duration)\n                ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);\n            else if (ist->st->avg_frame_rate.num)\n                ist->next_dts += av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate),\n                                              AV_TIME_BASE_Q);\n            else if (ist->dec_ctx->framerate.num != 0) {\n                int ticks      = ist->st->parser ? ist->st->parser->repeat_pict + 1 :\n                                                   ist->dec_ctx->ticks_per_frame;\n                ist->next_dts += av_rescale_q(ticks, ist->dec_ctx->framerate, AV_TIME_BASE_Q);\n            }\n            break;\n        case AVMEDIA_TYPE_SUBTITLE:\n            if (repeating)\n                break;\n            ret = transcode_subtitles(ist, &avpkt, &got_output, &decode_failed);\n            break;\n        default:\n            return;\n        }\n        if (ret < 0) {\n            if (decode_failed) {\n                av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\\n",\n                       ist->file_index, ist->st->index);\n            } else {\n                av_log(NULL, AV_LOG_FATAL, "Error while processing the decoded "\n                       "data for stream #%d:%d\\n", ist->file_index, ist->st->index);\n            }\n            if (!decode_failed || exit_on_error)\n                exit_program(1);\n            break;\n        }\n        if (!got_output)\n            break;\n        repeating = 1;\n    }\n    if (!pkt && ist->decoding_needed && !no_eof) {\n        int ret = send_filter_eof(ist);\n        if (ret < 0) {\n            av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\\n");\n            exit_program(1);\n        }\n    }\n    if (!ist->decoding_needed) {\n        ist->last_dts = ist->next_dts;\n        switch (ist->dec_ctx->codec_type) {\n        case AVMEDIA_TYPE_AUDIO:\n            ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) /\n                             ist->dec_ctx->sample_rate;\n            break;\n        case AVMEDIA_TYPE_VIDEO:\n            if (ist->dec_ctx->framerate.num != 0) {\n                int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame;\n                ist->next_dts += ((int64_t)AV_TIME_BASE *\n                                  ist->dec_ctx->framerate.den * ticks) /\n                                  ist->dec_ctx->framerate.num;\n            }\n            break;\n        }\n    }\n    for (i = 0; i < nb_output_streams; i++) {\n        OutputStream *ost = output_streams[i];\n        if (!check_output_constraints(ist, ost) || ost->encoding_needed)\n            continue;\n        do_streamcopy(ist, ost, pkt);\n    }\n    return;\n}', 'static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output,\n                        int *decode_failed)\n{\n    AVFrame *decoded_frame, *f;\n    AVCodecContext *avctx = ist->dec_ctx;\n    int i, ret, err = 0;\n    if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))\n        return AVERROR(ENOMEM);\n    if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc()))\n        return AVERROR(ENOMEM);\n    decoded_frame = ist->decoded_frame;\n    ret = decode(avctx, decoded_frame, got_output, pkt);\n    if (ret < 0)\n        *decode_failed = 1;\n    if (!*got_output || ret < 0)\n        return ret;\n    ist->samples_decoded += decoded_frame->nb_samples;\n    ist->frames_decoded++;\n    if (decoded_frame->pts != AV_NOPTS_VALUE)\n        ist->next_dts = av_rescale_q(decoded_frame->pts, ist->st->time_base, AV_TIME_BASE_Q);\n    else if (pkt && pkt->pts != AV_NOPTS_VALUE) {\n        decoded_frame->pts = pkt->pts;\n    }\n    if (decoded_frame->pts != AV_NOPTS_VALUE)\n        decoded_frame->pts = av_rescale_q(decoded_frame->pts,\n                                          ist->st->time_base,\n                                          (AVRational){1, avctx->sample_rate});\n    ist->nb_samples = decoded_frame->nb_samples;\n    for (i = 0; i < ist->nb_filters; i++) {\n        if (i < ist->nb_filters - 1) {\n            f = ist->filter_frame;\n            err = av_frame_ref(f, decoded_frame);\n            if (err < 0)\n                break;\n        } else\n            f = decoded_frame;\n        err = ifilter_send_frame(ist->filters[i], f);\n        if (err < 0)\n            break;\n    }\n    av_frame_unref(ist->filter_frame);\n    av_frame_unref(decoded_frame);\n    return err < 0 ? err : ret;\n}', 'int av_frame_ref(AVFrame *dst, const AVFrame *src)\n{\n    int i, ret = 0;\n    dst->format         = src->format;\n    dst->width          = src->width;\n    dst->height         = src->height;\n    dst->channel_layout = src->channel_layout;\n    dst->nb_samples     = src->nb_samples;\n    ret = av_frame_copy_props(dst, src);\n    if (ret < 0)\n        return ret;\n    if (!src->buf[0]) {\n        ret = av_frame_get_buffer(dst, 32);\n        if (ret < 0)\n            return ret;\n        ret = av_frame_copy(dst, src);\n        if (ret < 0)\n            av_frame_unref(dst);\n        return ret;\n    }\n    for (i = 0; i < FF_ARRAY_ELEMS(src->buf) && src->buf[i]; i++) {\n        dst->buf[i] = av_buffer_ref(src->buf[i]);\n        if (!dst->buf[i]) {\n            ret = AVERROR(ENOMEM);\n            goto fail;\n        }\n    }\n    if (src->extended_buf) {\n        dst->extended_buf = av_mallocz(sizeof(*dst->extended_buf) *\n                                       src->nb_extended_buf);\n        if (!dst->extended_buf) {\n            ret = AVERROR(ENOMEM);\n            goto fail;\n        }\n        dst->nb_extended_buf = src->nb_extended_buf;\n        for (i = 0; i < src->nb_extended_buf; i++) {\n            dst->extended_buf[i] = av_buffer_ref(src->extended_buf[i]);\n            if (!dst->extended_buf[i]) {\n                ret = AVERROR(ENOMEM);\n                goto fail;\n            }\n        }\n    }\n    if (src->hw_frames_ctx) {\n        dst->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);\n        if (!dst->hw_frames_ctx) {\n            ret = AVERROR(ENOMEM);\n            goto fail;\n        }\n    }\n    if (src->extended_data != src->data) {\n        int ch = av_get_channel_layout_nb_channels(src->channel_layout);\n        if (!ch) {\n            ret = AVERROR(EINVAL);\n            goto fail;\n        }\n        dst->extended_data = av_malloc(sizeof(*dst->extended_data) * ch);\n        if (!dst->extended_data) {\n            ret = AVERROR(ENOMEM);\n            goto fail;\n        }\n        memcpy(dst->extended_data, src->extended_data, sizeof(*src->extended_data) * ch);\n    } else\n        dst->extended_data = dst->data;\n    memcpy(dst->data,     src->data,     sizeof(src->data));\n    memcpy(dst->linesize, src->linesize, sizeof(src->linesize));\n    return 0;\nfail:\n    av_frame_unref(dst);\n    return ret;\n}', 'int av_frame_get_buffer(AVFrame *frame, int align)\n{\n    if (frame->format < 0)\n        return AVERROR(EINVAL);\n    if (frame->width > 0 && frame->height > 0)\n        return get_video_buffer(frame, align);\n    else if (frame->nb_samples > 0 && frame->channel_layout)\n        return get_audio_buffer(frame, align);\n    return AVERROR(EINVAL);\n}', 'static int get_audio_buffer(AVFrame *frame, int align)\n{\n    int channels = av_get_channel_layout_nb_channels(frame->channel_layout);\n    int planar   = av_sample_fmt_is_planar(frame->format);\n    int planes   = planar ? channels : 1;\n    int ret, i;\n    if (!frame->linesize[0]) {\n        ret = av_samples_get_buffer_size(&frame->linesize[0], channels,\n                                         frame->nb_samples, frame->format,\n                                         align);\n        if (ret < 0)\n            return ret;\n    }\n    if (planes > AV_NUM_DATA_POINTERS) {\n        frame->extended_data = av_mallocz(planes *\n                                          sizeof(*frame->extended_data));\n        frame->extended_buf  = av_mallocz((planes - AV_NUM_DATA_POINTERS) *\n                                          sizeof(*frame->extended_buf));\n        if (!frame->extended_data || !frame->extended_buf) {\n            av_freep(&frame->extended_data);\n            av_freep(&frame->extended_buf);\n            return AVERROR(ENOMEM);\n        }\n        frame->nb_extended_buf = planes - AV_NUM_DATA_POINTERS;\n    } else\n        frame->extended_data = frame->data;\n    for (i = 0; i < FFMIN(planes, AV_NUM_DATA_POINTERS); i++) {\n        frame->buf[i] = av_buffer_alloc(frame->linesize[0]);\n        if (!frame->buf[i]) {\n            av_frame_unref(frame);\n            return AVERROR(ENOMEM);\n        }\n        frame->extended_data[i] = frame->data[i] = frame->buf[i]->data;\n    }\n    for (i = 0; i < planes - AV_NUM_DATA_POINTERS; i++) {\n        frame->extended_buf[i] = av_buffer_alloc(frame->linesize[0]);\n        if (!frame->extended_buf[i]) {\n            av_frame_unref(frame);\n            return AVERROR(ENOMEM);\n        }\n        frame->extended_data[i + AV_NUM_DATA_POINTERS] = frame->extended_buf[i]->data;\n    }\n    return 0;\n}', 'int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,\n                               enum AVSampleFormat sample_fmt, int align)\n{\n    int line_size;\n    int sample_size = av_get_bytes_per_sample(sample_fmt);\n    int planar      = av_sample_fmt_is_planar(sample_fmt);\n    if (!sample_size || nb_samples <= 0 || nb_channels <= 0)\n        return AVERROR(EINVAL);\n    if (!align) {\n        if (nb_samples > INT_MAX - 31)\n            return AVERROR(EINVAL);\n        align = 1;\n        nb_samples = FFALIGN(nb_samples, 32);\n    }\n    if (nb_channels > INT_MAX / align ||\n        (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)\n        return AVERROR(EINVAL);\n    line_size = planar ? FFALIGN(nb_samples * sample_size,               align) :\n                         FFALIGN(nb_samples * sample_size * nb_channels, align);\n    if (linesize)\n        *linesize = line_size;\n    return planar ? line_size * nb_channels : line_size;\n}']