Ticket #2089: fix_negative_bitrates.patch

File fix_negative_bitrates.patch, 12.2 KB (added by Steve Swanson, 14 years ago)

reasonably straightforward conversion from int to int64_t

  • ffserver.c

    diff --git a/ffserver.c b/ffserver.c
    index f2cf67f..096c160 100644
    a b static void compute_status(HTTPContext *c)  
    20952095                default:
    20962096                    abort();
    20972097                }
    2098                 avio_printf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n",
     2098                avio_printf(pb, "<tr><td align=right>%d<td>%s<td align=right>%lld<td>%s<td>%s\n",
    20992099                        i, type, st->codec->bit_rate/1000, codec ? codec->name : "", parameters);
    21002100            }
    21012101            avio_printf(pb, "</table>\n");
  • libavcodec/avcodec.h

    diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
    index 012a31c..af10e55 100644
    a b typedef struct AVCodecContext {  
    16051605     * - encoding: Set by user; unused for constant quantizer encoding.
    16061606     * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
    16071607     */
    1608     int bit_rate;
     1608    int64_t bit_rate;
    16091609
    16101610    /**
    16111611     * number of bits the bitstream is allowed to diverge from the reference.
    typedef struct AVCodecContext {  
    16131613     * - encoding: Set by user; unused for constant quantizer encoding.
    16141614     * - decoding: unused
    16151615     */
    1616     int bit_rate_tolerance;
     1616    int64_t bit_rate_tolerance;
    16171617
    16181618    /**
    16191619     * Global quality for codecs which cannot change it per frame.
  • libavcodec/pcm-mpeg.c

    diff --git a/libavcodec/pcm-mpeg.c b/libavcodec/pcm-mpeg.c
    index fe7c4a7..0f5c9a2 100644
    a b static int pcm_bluray_parse_header(AVCodecContext *avctx,  
    116116
    117117    if (avctx->debug & FF_DEBUG_PICT_INFO)
    118118        av_dlog(avctx,
    119                 "pcm_bluray_parse_header: %d channels, %d bits per sample, %d Hz, %d bit/s\n",
     119                "pcm_bluray_parse_header: %d channels, %d bits per sample, %d Hz, %lld bit/s\n",
    120120                avctx->channels, avctx->bits_per_coded_sample,
    121121                avctx->sample_rate, avctx->bit_rate);
    122122    return 0;
  • libavcodec/sipr.c

    diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c
    index 06b22c0..708e2fc 100644
    a b static av_cold int sipr_decoder_init(AVCodecContext * avctx)  
    492492        else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
    493493        else                              ctx->mode = MODE_5k0;
    494494        av_log(avctx, AV_LOG_WARNING,
    495                "Invalid block_align: %d. Mode %s guessed based on bitrate: %d\n",
     495               "Invalid block_align: %d. Mode %s guessed based on bitrate: %lld\n",
    496496               avctx->block_align, modes[ctx->mode].mode_name, avctx->bit_rate);
    497497    }
    498498
  • libavcodec/utils.c

    diff --git a/libavcodec/utils.c b/libavcodec/utils.c
    index f5ceae4..5467db5 100644
    a b static void avcodec_get_subtitle_defaults(AVSubtitle *sub)  
    738738    sub->pts = AV_NOPTS_VALUE;
    739739}
    740740
    741 static int get_bit_rate(AVCodecContext *ctx)
     741static int64_t get_bit_rate(AVCodecContext *ctx)
    742742{
    743     int bit_rate;
     743    int64_t bit_rate;
    744744    int bits_per_sample;
    745745
    746746    switch (ctx->codec_type) {
    int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code  
    10161016        }
    10171017        if (   (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO)
    10181018            && avctx->bit_rate>0 && avctx->bit_rate<1000) {
    1019             av_log(avctx, AV_LOG_WARNING, "Bitrate %d is extreemly low, did you mean %dk\n", avctx->bit_rate, avctx->bit_rate);
     1019            av_log(avctx, AV_LOG_WARNING, "Bitrate %lld is extreemly low, did you mean %lldk\n", avctx->bit_rate, avctx->bit_rate);
    10201020        }
    10211021    }
    10221022
    void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)  
    20392039    const char *codec_name;
    20402040    const char *profile = NULL;
    20412041    const AVCodec *p;
    2042     int bitrate;
     2042    int64_t bitrate;
    20432043    AVRational display_aspect_ratio;
    20442044
    20452045    if (!buf || buf_size <= 0)
    void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)  
    21312131    bitrate = get_bit_rate(enc);
    21322132    if (bitrate != 0) {
    21332133        snprintf(buf + strlen(buf), buf_size - strlen(buf),
    2134                  ", %d kb/s", bitrate / 1000);
     2134                 ", %lld kb/s", bitrate / 1000);
    21352135    }
    21362136}
    21372137
  • libavcodec/wma.c

    diff --git a/libavcodec/wma.c b/libavcodec/wma.c
    index d0c0b34..077c547 100644
    a b int ff_wma_init(AVCodecContext *avctx, int flags2)  
    181181        }
    182182    }
    183183    av_dlog(s->avctx, "flags2=0x%x\n", flags2);
    184     av_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
     184    av_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%lld block_align=%d\n",
    185185            s->version, avctx->channels, avctx->sample_rate, avctx->bit_rate,
    186186            avctx->block_align);
    187187    av_dlog(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
  • libavcodec/wmaenc.c

    diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
    index 5aebe81..590d561 100644
    a b static int encode_init(AVCodecContext * avctx){  
    4545    }
    4646
    4747    if(avctx->bit_rate < 24*1000) {
    48         av_log(avctx, AV_LOG_ERROR, "bitrate too low: got %i, need 24000 or higher\n",
     48        av_log(avctx, AV_LOG_ERROR, "bitrate too low: got %lli, need 24000 or higher\n",
    4949               avctx->bit_rate);
    5050        return AVERROR(EINVAL);
    5151    }
  • libavformat/avformat.h

    diff --git a/libavformat/avformat.h b/libavformat/avformat.h
    index c907d4e..0a6f496 100644
    a b typedef struct AVFormatContext {  
    10081008     * available. Never set it directly if the file_size and the
    10091009     * duration are known as FFmpeg can compute it automatically.
    10101010     */
    1011     int bit_rate;
     1011    int64_t bit_rate;
    10121012
    10131013    unsigned int packet_size;
    10141014    int max_delay;
  • libavformat/g729dec.c

    diff --git a/libavformat/g729dec.c b/libavformat/g729dec.c
    index 794558e..39c12c4 100644
    a b static int g729_read_header(AVFormatContext *s)  
    5757    } else if (s->bit_rate == 8000) {
    5858        st->codec->block_align = 10;
    5959    } else {
    60         av_log(s, AV_LOG_ERROR, "Only 8000 b/s and 6400 b/s bitrates are supported. Provided: %d b/s\n", s->bit_rate);
     60        av_log(s, AV_LOG_ERROR, "Only 8000 b/s and 6400 b/s bitrates are supported. Provided: %lld b/s\n", s->bit_rate);
    6161        return AVERROR_INVALIDDATA;
    6262    }
    6363
  • libavformat/movenc.c

    diff --git a/libavformat/movenc.c b/libavformat/movenc.c
    index f08aa7e..a8705ca 100644
    a b static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov)  
    24162416        } else {
    24172417            continue;
    24182418        }
    2419         avio_printf(pb, "<%s systemBitrate=\"%d\">\n", type,
     2419        avio_printf(pb, "<%s systemBitrate=\"%lld\">\n", type,
    24202420                                                       track->enc->bit_rate);
    24212421        param_write_int(pb, "systemBitrate", track->enc->bit_rate);
    24222422        param_write_int(pb, "trackID", track_id);
  • libavformat/rdt.c

    diff --git a/libavformat/rdt.c b/libavformat/rdt.c
    index 695323a..6f88059 100644
    a b real_parse_asm_rule(AVStream *st, const char *p, const char *end)  
    443443{
    444444    do {
    445445        /* can be either averagebandwidth= or AverageBandwidth= */
    446         if (sscanf(p, " %*1[Aa]verage%*1[Bb]andwidth=%d", &st->codec->bit_rate) == 1)
     446        if (sscanf(p, " %*1[Aa]verage%*1[Bb]andwidth=%lld", &st->codec->bit_rate) == 1)
    447447            break;
    448448        if (!(p = strchr(p, ',')) || p > end)
    449449            p = end;
  • libavformat/sdp.c

    diff --git a/libavformat/sdp.c b/libavformat/sdp.c
    index cdc3e21..6a0cc93 100644
    a b void ff_sdp_write_media(char *buff, int size, AVStream *st, int idx,  
    624624    av_strlcatf(buff, size, "m=%s %d RTP/AVP %d\r\n", type, port, payload_type);
    625625    sdp_write_address(buff, size, dest_addr, dest_type, ttl);
    626626    if (c->bit_rate) {
    627         av_strlcatf(buff, size, "b=AS:%d\r\n", c->bit_rate / 1000);
     627        av_strlcatf(buff, size, "b=AS:%lld\r\n", c->bit_rate / 1000);
    628628    }
    629629
    630630    sdp_write_media_attributes(buff, size, c, payload_type, fmt);
  • libavformat/smoothstreamingenc.c

    diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
    index 096bf79..ac82259 100644
    a b static int write_manifest(AVFormatContext *s, int final)  
    255255            if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO)
    256256                continue;
    257257            last = i;
    258             avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%d\" FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" CodecPrivateData=\"%s\" />\n", index, s->streams[i]->codec->bit_rate, os->fourcc, s->streams[i]->codec->width, s->streams[i]->codec->height, os->private_str);
     258            avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%lld\" FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" CodecPrivateData=\"%s\" />\n", index, s->streams[i]->codec->bit_rate, os->fourcc, s->streams[i]->codec->width, s->streams[i]->codec->height, os->private_str);
    259259            index++;
    260260        }
    261261        output_chunk_list(&c->streams[last], out, final, c->lookahead_count, c->window_size);
    static int write_manifest(AVFormatContext *s, int final)  
    269269            if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
    270270                continue;
    271271            last = i;
    272             avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%d\" FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" BitsPerSample=\"16\" PacketSize=\"%d\" AudioTag=\"%d\" CodecPrivateData=\"%s\" />\n", index, s->streams[i]->codec->bit_rate, os->fourcc, s->streams[i]->codec->sample_rate, s->streams[i]->codec->channels, os->packet_size, os->audio_tag, os->private_str);
     272            avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%lld\" FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" BitsPerSample=\"16\" PacketSize=\"%d\" AudioTag=\"%d\" CodecPrivateData=\"%s\" />\n", index, s->streams[i]->codec->bit_rate, os->fourcc, s->streams[i]->codec->sample_rate, s->streams[i]->codec->channels, os->packet_size, os->audio_tag, os->private_str);
    273273            index++;
    274274        }
    275275        output_chunk_list(&c->streams[last], out, final, c->lookahead_count, c->window_size);
    static int ism_write_header(AVFormatContext *s)  
    317317            ret = AVERROR(EINVAL);
    318318            goto fail;
    319319        }
    320         snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%d)", s->filename, s->streams[i]->codec->bit_rate);
     320        snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%lld)", s->filename, s->streams[i]->codec->bit_rate);
    321321        if (mkdir(os->dirname, 0777) < 0) {
    322322            ret = AVERROR(errno);
    323323            av_log(s, AV_LOG_ERROR, "mkdir failed\n");
  • libavformat/utils.c

    diff --git a/libavformat/utils.c b/libavformat/utils.c
    index a78da36..4bcae7f 100644
    a b static void estimate_timings(AVFormatContext *ic, int64_t old_offset)  
    23742374                    (double) st->start_time / AV_TIME_BASE,
    23752375                    (double) st->duration   / AV_TIME_BASE);
    23762376        }
    2377         av_dlog(ic, "stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n",
     2377        av_dlog(ic, "stream: start_time: %0.3f duration: %0.3f bitrate=%lld kb/s\n",
    23782378                (double) ic->start_time / AV_TIME_BASE,
    23792379                (double) ic->duration   / AV_TIME_BASE,
    23802380                ic->bit_rate / 1000);
    void av_dump_format(AVFormatContext *ic,  
    35163516        }
    35173517        av_log(NULL, AV_LOG_INFO, ", bitrate: ");
    35183518        if (ic->bit_rate) {
    3519             av_log(NULL, AV_LOG_INFO,"%d kb/s", ic->bit_rate / 1000);
     3519            av_log(NULL, AV_LOG_INFO,"%lld kb/s", ic->bit_rate / 1000);
    35203520        } else {
    35213521            av_log(NULL, AV_LOG_INFO, "N/A");
    35223522        }
  • libavformat/vqf.c

    diff --git a/libavformat/vqf.c b/libavformat/vqf.c
    index f1e6aaf..0ffb7cc 100644
    a b static int vqf_read_header(AVFormatContext *s)  
    200200        size = 2048;
    201201        break;
    202202    default:
    203         av_log(s, AV_LOG_ERROR, "Mode not suported: %d Hz, %d kb/s.\n",
     203        av_log(s, AV_LOG_ERROR, "Mode not suported: %d Hz, %lld kb/s.\n",
    204204               st->codec->sample_rate, st->codec->bit_rate);
    205205        return -1;
    206206    }