+++ /dev/null
-diff --git a/ffserver.c b/ffserver.c
-index 8b819b6..2732d7f 100644
---- a/ffserver.c
-+++ b/ffserver.c
-@@ -1914,9 +1914,9 @@ static inline void print_stream_params(AVIOContext *pb, FFServerStream *stream)
-             abort();
-         }
- 
--        avio_printf(pb, "<tr><td>%d<td>%s<td>%"PRId64
-+        avio_printf(pb, "<tr><td>%d<td>%s<td>%d"
-                         "<td>%s<td>%s\n",
--                    i, type, (int64_t)st->codecpar->bit_rate/1000,
-+                    i, type, st->codecpar->bit_rate/1000,
-                     codec ? codec->name : "", parameters);
-      }
- 
-diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
-index 35df4f6..34363a7 100644
---- a/libavcodec/avcodec.h
-+++ b/libavcodec/avcodec.h
-@@ -1794,7 +1794,7 @@ typedef struct AVCodecContext {
-      * - decoding: Set by user, may be overwritten by libavcodec
-      *             if this info is available in the stream
-      */
--    int64_t bit_rate;
-+    int bit_rate;
- 
-     /**
-      * number of bits the bitstream is allowed to diverge from the reference.
-@@ -2729,14 +2729,14 @@ typedef struct AVCodecContext {
-      * - encoding: Set by user.
-      * - decoding: Set by user, may be overwritten by libavcodec.
-      */
--    int64_t rc_max_rate;
-+    int rc_max_rate;
- 
-     /**
-      * minimum bitrate
-      * - encoding: Set by user.
-      * - decoding: unused
-      */
--    int64_t rc_min_rate;
-+    int rc_min_rate;
- 
- #if FF_API_MPV_OPT
-     /**
-diff --git a/libavcodec/cook.c b/libavcodec/cook.c
-index 53cb8385..2cd96cf 100644
---- a/libavcodec/cook.c
-+++ b/libavcodec/cook.c
-@@ -1035,7 +1035,7 @@ static void dump_cook_context(COOKContext *q)
-     }
-     ff_dlog(q->avctx, "COOKContext\n");
-     PRINT("nb_channels", q->avctx->channels);
--    PRINT("bit_rate", (int)q->avctx->bit_rate);
-+    PRINT("bit_rate", q->avctx->bit_rate);
-     PRINT("sample_rate", q->avctx->sample_rate);
-     PRINT("samples_per_channel", q->subpacket[0].samples_per_channel);
-     PRINT("subbands", q->subpacket[0].subbands);
-diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
-index 3c5c33c..28ab9b2 100644
---- a/libavcodec/dcaenc.c
-+++ b/libavcodec/dcaenc.c
-@@ -161,7 +161,7 @@ static int encode_init(AVCodecContext *avctx)
-     c->samplerate_index = i;
- 
-     if (avctx->bit_rate < 32000 || avctx->bit_rate > 3840000) {
--        av_log(avctx, AV_LOG_ERROR, "Bit rate %"PRId64" not supported.", (int64_t)avctx->bit_rate);
-+        av_log(avctx, AV_LOG_ERROR, "Bit rate %i not supported.", avctx->bit_rate);
-         return AVERROR(EINVAL);
-     }
-     for (i = 0; ff_dca_bit_rates[i] < avctx->bit_rate; i++)
-diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
-index 98a817b..5df0c90 100644
---- a/libavcodec/libfdk-aacenc.c
-+++ b/libavcodec/libfdk-aacenc.c
-@@ -215,8 +215,8 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
-         }
-         if ((err = aacEncoder_SetParam(s->handle, AACENC_BITRATE,
-                                        avctx->bit_rate)) != AACENC_OK) {
--            av_log(avctx, AV_LOG_ERROR, "Unable to set the bitrate %"PRId64": %s\n",
--                   (int64_t)avctx->bit_rate, aac_get_error(err));
-+            av_log(avctx, AV_LOG_ERROR, "Unable to set the bitrate %d: %s\n",
-+                   avctx->bit_rate, aac_get_error(err));
-             goto error;
-         }
-     }
-diff --git a/libavcodec/libgsmenc.c b/libavcodec/libgsmenc.c
-index 69ce439..45fdb8e 100644
---- a/libavcodec/libgsmenc.c
-+++ b/libavcodec/libgsmenc.c
-@@ -62,8 +62,8 @@ static av_cold int libgsm_encode_init(AVCodecContext *avctx) {
-     if (avctx->bit_rate != 13000 /* Official */ &&
-         avctx->bit_rate != 13200 /* Very common */ &&
-         avctx->bit_rate != 0 /* Unknown; a.o. mov does not set bitrate when decoding */ ) {
--        av_log(avctx, AV_LOG_ERROR, "Bitrate 13000bps required for GSM, got %"PRId64"bps\n",
--               (int64_t)avctx->bit_rate);
-+        av_log(avctx, AV_LOG_ERROR, "Bitrate 13000bps required for GSM, got %dbps\n",
-+               avctx->bit_rate);
-         if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL)
-             return -1;
-     }
-diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
-index c40fcde..cab7e3a 100644
---- a/libavcodec/libopusenc.c
-+++ b/libavcodec/libopusenc.c
-@@ -351,12 +351,12 @@ static av_cold int libopus_encode_init(AVCodecContext *avctx)
-         avctx->bit_rate = 64000 * opus->stream_count +
-                           32000 * coupled_stream_count;
-         av_log(avctx, AV_LOG_WARNING,
--               "No bit rate set. Defaulting to %"PRId64" bps.\n", (int64_t)avctx->bit_rate);
-+               "No bit rate set. Defaulting to %d bps.\n", avctx->bit_rate);
-     }
- 
-     if (avctx->bit_rate < 500 || avctx->bit_rate > 256000 * avctx->channels) {
--        av_log(avctx, AV_LOG_ERROR, "The bit rate %"PRId64" bps is unsupported. "
--               "Please choose a value between 500 and %d.\n", (int64_t)avctx->bit_rate,
-+        av_log(avctx, AV_LOG_ERROR, "The bit rate %d bps is unsupported. "
-+               "Please choose a value between 500 and %d.\n", avctx->bit_rate,
-                256000 * avctx->channels);
-         ret = AVERROR(EINVAL);
-         goto fail;
-diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c
-index 4bdb961..b96b217 100644
---- a/libavcodec/libspeexenc.c
-+++ b/libavcodec/libspeexenc.c
-@@ -125,10 +125,10 @@ static av_cold void print_enc_params(AVCodecContext *avctx,
-         av_log(avctx, AV_LOG_DEBUG, "  quality: %f\n", s->vbr_quality);
-     } else if (s->abr) {
-         av_log(avctx, AV_LOG_DEBUG, "rate control: ABR\n");
--        av_log(avctx, AV_LOG_DEBUG, "  bitrate: %"PRId64" bps\n", (int64_t)avctx->bit_rate);
-+        av_log(avctx, AV_LOG_DEBUG, "  bitrate: %d bps\n", avctx->bit_rate);
-     } else {
-         av_log(avctx, AV_LOG_DEBUG, "rate control: CBR\n");
--        av_log(avctx, AV_LOG_DEBUG, "  bitrate: %"PRId64" bps\n", (int64_t)avctx->bit_rate);
-+        av_log(avctx, AV_LOG_DEBUG, "  bitrate: %d bps\n", avctx->bit_rate);
-     }
-     av_log(avctx, AV_LOG_DEBUG, "complexity: %d\n",
-            avctx->compression_level);
-diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
-index db241c8..46ee6a4 100644
---- a/libavcodec/mpegvideo_enc.c
-+++ b/libavcodec/mpegvideo_enc.c
-@@ -506,7 +506,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
-         avctx->bit_rate * av_q2d(avctx->time_base) >
-             avctx->bit_rate_tolerance) {
-         av_log(avctx, AV_LOG_WARNING,
--               "bitrate tolerance %d too small for bitrate %"PRId64", overriding\n", avctx->bit_rate_tolerance, (int64_t)avctx->bit_rate);
-+               "bitrate tolerance %d too small for bitrate %d, overriding\n", avctx->bit_rate_tolerance, avctx->bit_rate);
-         avctx->bit_rate_tolerance = 5 * avctx->bit_rate * av_q2d(avctx->time_base);
-     }
- 
-diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
-index 022cb1d..14dc914 100644
---- a/libavcodec/options_table.h
-+++ b/libavcodec/options_table.h
-@@ -42,8 +42,8 @@
- #define AV_CODEC_DEFAULT_BITRATE 200*1000
- 
- static const AVOption avcodec_options[] = {
--{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT64, {.i64 = AV_CODEC_DEFAULT_BITRATE }, 0, INT64_MAX, A|V|E},
--{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT64, {.i64 = 128*1000 }, 0, INT_MAX, A|E},
-+{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT, {.i64 = AV_CODEC_DEFAULT_BITRATE }, 0, INT64_MAX, A|V|E},
-+{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT, {.i64 = 128*1000 }, 0, INT_MAX, A|E},
- {"bt", "Set video bitrate tolerance (in bits/s). In 1-pass mode, bitrate tolerance specifies how far "
-        "ratecontrol is willing to deviate from the target average bitrate value. This is not related "
-        "to minimum/maximum bitrate. Lowering tolerance too much has an adverse effect on quality.",
-@@ -194,9 +194,9 @@ static const AVOption avcodec_options[] = {
- #if FF_API_MPV_OPT
- {"rc_eq", "deprecated, use encoder private options instead", OFFSET(rc_eq), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, V|E},
- #endif
--{"maxrate", "maximum bitrate (in bits/s). Used for VBV together with bufsize.", OFFSET(rc_max_rate), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, INT_MAX, V|A|E},
-+{"maxrate", "maximum bitrate (in bits/s). Used for VBV together with bufsize.", OFFSET(rc_max_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, V|A|E},
- {"minrate", "minimum bitrate (in bits/s). Most useful in setting up a CBR encode. It is of little use otherwise.",
--            OFFSET(rc_min_rate), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
-+            OFFSET(rc_min_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
- {"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|V|E},
- #if FF_API_MPV_OPT
- {"rc_buf_aggressivity", "deprecated, use encoder private options instead", OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, V|E},
-diff --git a/libavcodec/pcm-bluray.c b/libavcodec/pcm-bluray.c
-index 22c1c08..e7f9ee4 100644
---- a/libavcodec/pcm-bluray.c
-+++ b/libavcodec/pcm-bluray.c
-@@ -117,9 +117,9 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
- 
-     if (avctx->debug & FF_DEBUG_PICT_INFO)
-         ff_dlog(avctx,
--                "pcm_bluray_parse_header: %d channels, %d bits per sample, %d Hz, %"PRId64" bit/s\n",
-+                "pcm_bluray_parse_header: %d channels, %d bits per sample, %d Hz, %d bit/s\n",
-                 avctx->channels, avctx->bits_per_coded_sample,
--                avctx->sample_rate, (int64_t)avctx->bit_rate);
-+                avctx->sample_rate, avctx->bit_rate);
-     return 0;
- }
- 
-diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
-index 04c321e..46f730d 100644
---- a/libavcodec/pcm-dvd.c
-+++ b/libavcodec/pcm-dvd.c
-@@ -140,9 +140,9 @@ static int pcm_dvd_parse_header(AVCodecContext *avctx, const uint8_t *header)
- 
-     if (avctx->debug & FF_DEBUG_PICT_INFO)
-         ff_dlog(avctx,
--                "pcm_dvd_parse_header: %d channels, %d bits per sample, %d Hz, %"PRId64" bit/s\n",
-+                "pcm_dvd_parse_header: %d channels, %d bits per sample, %d Hz, %d bit/s\n",
-                 avctx->channels, avctx->bits_per_coded_sample,
--                avctx->sample_rate, (int64_t)avctx->bit_rate);
-+                avctx->sample_rate, avctx->bit_rate);
- 
-     s->last_header = header_int;
- 
-diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c
-index 70d460a..5e428ef 100644
---- a/libavcodec/sipr.c
-+++ b/libavcodec/sipr.c
-@@ -493,8 +493,8 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx)
-         else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
-         else                              ctx->mode = MODE_5k0;
-         av_log(avctx, AV_LOG_WARNING,
--               "Invalid block_align: %d. Mode %s guessed based on bitrate: %"PRId64"\n",
--               avctx->block_align, modes[ctx->mode].mode_name, (int64_t)avctx->bit_rate);
-+               "Invalid block_align: %d. Mode %s guessed based on bitrate: %d\n",
-+               avctx->block_align, modes[ctx->mode].mode_name, avctx->bit_rate);
-     }
- 
-     av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name);
-diff --git a/libavcodec/utils.c b/libavcodec/utils.c
-index 1336e92..7877488 100644
---- a/libavcodec/utils.c
-+++ b/libavcodec/utils.c
-@@ -967,7 +967,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
-         }
-         if (   (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO)
-             && avctx->bit_rate>0 && avctx->bit_rate<1000) {
--            av_log(avctx, AV_LOG_WARNING, "Bitrate %"PRId64" is extremely low, maybe you mean %"PRId64"k\n", (int64_t)avctx->bit_rate, (int64_t)avctx->bit_rate);
-+            av_log(avctx, AV_LOG_WARNING, "Bitrate %d is extremely low, maybe you mean %dk\n", avctx->bit_rate, avctx->bit_rate);
-         }
- 
-         if (!avctx->rc_initial_buffer_occupancy)
-@@ -1522,7 +1522,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
-                  ", %"PRId64" kb/s", bitrate / 1000);
-     } else if (enc->rc_max_rate > 0) {
-         snprintf(buf + strlen(buf), buf_size - strlen(buf),
--                 ", max. %"PRId64" kb/s", (int64_t)enc->rc_max_rate / 1000);
-+                 ", max. %d kb/s", enc->rc_max_rate / 1000);
-     }
- }
- 
-diff --git a/libavcodec/wma.c b/libavcodec/wma.c
-index f70937f..717f950 100644
---- a/libavcodec/wma.c
-+++ b/libavcodec/wma.c
-@@ -185,8 +185,8 @@ av_cold int ff_wma_init(AVCodecContext *avctx, int flags2)
-             high_freq = high_freq * 0.5;
-     }
-     ff_dlog(s->avctx, "flags2=0x%x\n", flags2);
--    ff_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%"PRId64" block_align=%d\n",
--            s->version, avctx->channels, avctx->sample_rate, (int64_t)avctx->bit_rate,
-+    ff_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
-+            s->version, avctx->channels, avctx->sample_rate, avctx->bit_rate,
-             avctx->block_align);
-     ff_dlog(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
-             bps, bps1, high_freq, s->byte_offset_bits);
-diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
-index c68babd..765f570 100644
---- a/libavcodec/wmaenc.c
-+++ b/libavcodec/wmaenc.c
-@@ -52,8 +52,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
- 
-     if (avctx->bit_rate < 24 * 1000) {
-         av_log(avctx, AV_LOG_ERROR,
--               "bitrate too low: got %"PRId64", need 24000 or higher\n",
--               (int64_t)avctx->bit_rate);
-+               "bitrate too low: got %i, need 24000 or higher\n",
-+               avctx->bit_rate);
-         return AVERROR(EINVAL);
-     }
- 
-diff --git a/libavdevice/fbdev_dec.c b/libavdevice/fbdev_dec.c
-index 3b31373..33a2054 100644
---- a/libavdevice/fbdev_dec.c
-+++ b/libavdevice/fbdev_dec.c
-@@ -136,11 +136,11 @@ static av_cold int fbdev_read_header(AVFormatContext *avctx)
-         fbdev->width * fbdev->height * fbdev->bytes_per_pixel * av_q2d(fbdev->framerate_q) * 8;
- 
-     av_log(avctx, AV_LOG_INFO,
--           "w:%d h:%d bpp:%d pixfmt:%s fps:%d/%d bit_rate:%"PRId64"\n",
-+           "w:%d h:%d bpp:%d pixfmt:%s fps:%d/%d bit_rate:%d\n",
-            fbdev->width, fbdev->height, fbdev->varinfo.bits_per_pixel,
-            av_get_pix_fmt_name(pix_fmt),
-            fbdev->framerate_q.num, fbdev->framerate_q.den,
--           (int64_t)st->codecpar->bit_rate);
-+           st->codecpar->bit_rate);
-     return 0;
- 
- fail:
-diff --git a/libavformat/movenc.c b/libavformat/movenc.c
-index d20d272..9adf08f 100644
---- a/libavformat/movenc.c
-+++ b/libavformat/movenc.c
-@@ -3897,7 +3897,7 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat
-             manifest_bit_rate = props->max_bitrate;
-         }
- 
--        avio_printf(pb, "<%s systemBitrate=\"%"PRId64"\">\n", type,
-+        avio_printf(pb, "<%s systemBitrate=\"%d\">\n", type,
-                     manifest_bit_rate);
-         param_write_int(pb, "systemBitrate", manifest_bit_rate);
-         param_write_int(pb, "trackID", track_id);
-diff --git a/libavformat/rdt.c b/libavformat/rdt.c
-index 8670ead..57ee07e 100644
---- a/libavformat/rdt.c
-+++ b/libavformat/rdt.c
-@@ -448,7 +448,7 @@ real_parse_asm_rule(AVStream *st, const char *p, const char *end)
- {
-     do {
-         /* can be either averagebandwidth= or AverageBandwidth= */
--        if (sscanf(p, " %*1[Aa]verage%*1[Bb]andwidth=%"SCNd64, &st->codecpar->bit_rate) == 1)
-+        if (sscanf(p, " %*1[Aa]verage%*1[Bb]andwidth=%d", &st->codecpar->bit_rate) == 1)
-             break;
-         if (!(p = strchr(p, ',')) || p > end)
-             p = end;
-diff --git a/libavformat/sdp.c b/libavformat/sdp.c
-index 4e37f65..df2cb43 100644
---- a/libavformat/sdp.c
-+++ b/libavformat/sdp.c
-@@ -748,7 +748,7 @@ void ff_sdp_write_media(char *buff, int size, AVStream *st, int idx,
-     av_strlcatf(buff, size, "m=%s %d RTP/AVP %d\r\n", type, port, payload_type);
-     sdp_write_address(buff, size, dest_addr, dest_type, ttl);
-     if (p->bit_rate) {
--        av_strlcatf(buff, size, "b=AS:%"PRId64"\r\n", (int64_t)p->bit_rate / 1000);
-+        av_strlcatf(buff, size, "b=AS:%d\r\n", p->bit_rate / 1000);
-     }
- 
-     sdp_write_media_attributes(buff, size, st, payload_type, fmt);
-diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
-index dabd1ea..6d126e9 100644
---- a/libavformat/smoothstreamingenc.c
-+++ b/libavformat/smoothstreamingenc.c
-@@ -263,7 +263,7 @@ static int write_manifest(AVFormatContext *s, int final)
-             if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
-                 continue;
-             last = i;
--            avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%"PRId64"\" FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" CodecPrivateData=\"%s\" />\n", index, (int64_t)s->streams[i]->codecpar->bit_rate, os->fourcc, s->streams[i]->codecpar->width, s->streams[i]->codecpar->height, os->private_str);
-+            avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%d\" FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" CodecPrivateData=\"%s\" />\n", index, s->streams[i]->codecpar->bit_rate, os->fourcc, s->streams[i]->codecpar->width, s->streams[i]->codecpar->height, os->private_str);
-             index++;
-         }
-         output_chunk_list(&c->streams[last], out, final, c->lookahead_count, c->window_size);
-@@ -277,7 +277,7 @@ static int write_manifest(AVFormatContext *s, int final)
-             if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
-                 continue;
-             last = i;
--            avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%"PRId64"\" FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" BitsPerSample=\"16\" PacketSize=\"%d\" AudioTag=\"%d\" CodecPrivateData=\"%s\" />\n", index, (int64_t)s->streams[i]->codecpar->bit_rate, os->fourcc, s->streams[i]->codecpar->sample_rate, s->streams[i]->codecpar->channels, os->packet_size, os->audio_tag, os->private_str);
-+            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]->codecpar->bit_rate, os->fourcc, s->streams[i]->codecpar->sample_rate, s->streams[i]->codecpar->channels, os->packet_size, os->audio_tag, os->private_str);
-             index++;
-         }
-         output_chunk_list(&c->streams[last], out, final, c->lookahead_count, c->window_size);
-@@ -324,7 +324,7 @@ static int ism_write_header(AVFormatContext *s)
-             ret = AVERROR(EINVAL);
-             goto fail;
-         }
--        snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%"PRId64")", s->filename, (int64_t)s->streams[i]->codecpar->bit_rate);
-+        snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%d)", s->filename, s->streams[i]->codecpar->bit_rate);
-         if (mkdir(os->dirname, 0777) == -1 && errno != EEXIST) {
-             ret = AVERROR(errno);
-             av_log(s, AV_LOG_ERROR, "mkdir failed\n");
-diff --git a/libavformat/vqf.c b/libavformat/vqf.c
-index 841840e..b5cdb78 100644
---- a/libavformat/vqf.c
-+++ b/libavformat/vqf.c
-@@ -211,8 +211,8 @@ static int vqf_read_header(AVFormatContext *s)
-         size = 2048;
-         break;
-     default:
--        av_log(s, AV_LOG_ERROR, "Mode not supported: %d Hz, %"PRId64" kb/s.\n",
--               st->codecpar->sample_rate, (int64_t)st->codecpar->bit_rate);
-+        av_log(s, AV_LOG_ERROR, "Mode not supported: %d Hz, %d kb/s.\n",
-+               st->codecpar->sample_rate, st->codecpar->bit_rate);
-         return -1;
-     }
-     c->frame_bit_len = st->codecpar->bit_rate*size/st->codecpar->sample_rate;
 
--- /dev/null
+From c6f8769255ec6c4bb4ce02879d2332461ef1e24e Mon Sep 17 00:00:00 2001
+From: Jacek Jendrzej <satbaby@kawaii.com>
+Date: Sat, 12 Aug 2017 17:05:08 +0200
+Subject: [PATCH 7/7] add ASF VC1 Annex-G and RCV bitstream filters. Originally
+ done by Google but modified by us to convert certain VC1 in MKV without
+ startcodes. port fot 3.x
+
+Signed-off-by: Jacek Jendrzej <satbaby@kawaii.com>
+---
+ libavcodec/Makefile              |   2 +
+ libavcodec/bitstream_filters.c   |   2 +
+ libavcodec/vc1_asftoannexg_bsf.c | 182 +++++++++++++++++++++++++++++++++++++++
+ libavcodec/vc1_asftorcv_bsf.c    |  95 ++++++++++++++++++++
+ 4 files changed, 281 insertions(+)
+ create mode 100644 libavcodec/vc1_asftoannexg_bsf.c
+ create mode 100644 libavcodec/vc1_asftorcv_bsf.c
+
+diff --git a/libavcodec/Makefile b/libavcodec/Makefile
+index 982d7f5179..1ea13ddb01 100644
+--- a/libavcodec/Makefile
++++ b/libavcodec/Makefile
+@@ -1003,6 +1003,8 @@ OBJS-$(CONFIG_TEXT2MOVSUB_BSF)            += movsub_bsf.o
+ OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)        += vp9_raw_reorder_bsf.o
+ OBJS-$(CONFIG_VP9_SUPERFRAME_BSF)         += vp9_superframe_bsf.o
+ OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF)   += vp9_superframe_split_bsf.o
++OBJS-$(CONFIG_VC1_ASFTORCV_BSF)           += vc1_asftorcv_bsf.o
++OBJS-$(CONFIG_VC1_ASFTOANNEXG_BSF)        += vc1_asftoannexg_bsf.o vc1.o \
+ 
+ # thread libraries
+ OBJS-$(HAVE_LIBC_MSVCRT)               += file_open.o
+diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
+index ce34de640d..e1c5c0a848 100644
+--- a/libavcodec/bitstream_filters.c
++++ b/libavcodec/bitstream_filters.c
+@@ -44,6 +44,8 @@ extern const AVBitStreamFilter ff_text2movsub_bsf;
+ extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf;
+ extern const AVBitStreamFilter ff_vp9_superframe_bsf;
+ extern const AVBitStreamFilter ff_vp9_superframe_split_bsf;
++extern const AVBitStreamFilter ff_vc1_asftoannexg_bsf;
++extern const AVBitStreamFilter ff_vc1_asftorcv_bsf;
+ 
+ #include "libavcodec/bsf_list.c"
+ 
+diff --git a/libavcodec/vc1_asftoannexg_bsf.c b/libavcodec/vc1_asftoannexg_bsf.c
+new file mode 100644
+index 0000000000..83a31591be
+--- /dev/null
++++ b/libavcodec/vc1_asftoannexg_bsf.c
+@@ -0,0 +1,182 @@
++/*
++ * copyright (c) 2010 Google Inc.
++ * copyright (c) 2013 CoolStream International Ltd.
++ * copyright (c) 2017 Jacek Jendrzej port to 3.x
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include "avcodec.h"
++#include "bytestream.h"
++#include "vc1.h"
++#include "bsf.h"
++
++// An arbitrary limit in bytes greater than the current bytes used.
++#define MAX_SEQ_HEADER_SIZE 50
++
++typedef struct ASFTOANNEXGBSFContext {
++    int frames;
++    uint8_t *seq_header;
++    int seq_header_size;
++    uint8_t *ep_header;
++    int ep_header_size;
++} ASFTOANNEXGBSFContext;
++
++static int find_codec_data(ASFTOANNEXGBSFContext *ctx, uint8_t *data, int data_size, int keyframe) {
++    const uint8_t *start = data;
++    const uint8_t *end = data + data_size;
++    const uint8_t *next;
++    int size;
++    int has_seq_header = 0;
++    int has_ep_header = 0;
++    int has_frame_header = 0;
++
++    start = find_next_marker(start, end);
++    next = start;
++    for(; next < end; start = next){
++        next = find_next_marker(start + 4, end);
++        size = next - start;
++        if(size <= 0) continue;
++        switch(AV_RB32(start)){
++        case VC1_CODE_SEQHDR:
++            has_seq_header = 1;
++            break;
++        case VC1_CODE_ENTRYPOINT:
++            has_ep_header = 1;
++            break;
++        case VC1_CODE_FRAME:
++            has_frame_header = 1;
++            break;
++        default:
++            break;
++        }
++    }
++
++    if((has_seq_header && has_ep_header && has_frame_header && keyframe) ||
++       (!has_seq_header && !has_ep_header && has_frame_header) ) return 0;
++
++    return -1;
++}
++
++static int parse_extradata(ASFTOANNEXGBSFContext *ctx, uint8_t *extradata, int extradata_size) {
++    const uint8_t *start = extradata;
++    const uint8_t *end = extradata + extradata_size;
++    const uint8_t *next;
++    int size;
++
++    start = find_next_marker(start, end);
++    next = start;
++    for(; next < end; start = next){
++        next = find_next_marker(start + 4, end);
++        size = next - start;
++        if(size <= 0) continue;
++        switch(AV_RB32(start)){
++        case VC1_CODE_SEQHDR:
++            ctx->seq_header = av_mallocz(size);
++            ctx->seq_header_size = size;
++            memcpy(ctx->seq_header, start, size);
++            break;
++        case VC1_CODE_ENTRYPOINT:
++            ctx->ep_header = av_malloc(size);
++            ctx->ep_header_size = size;
++            memcpy(ctx->ep_header, start, size);
++            break;
++        default:
++            break;
++        }
++    }
++
++    if(!ctx->seq_header || !ctx->ep_header) {
++        av_log(NULL, AV_LOG_ERROR, "Incomplete extradata\n");
++        return -1;
++    }
++    return 0;
++}
++
++static int asftoannexg_filter(AVBSFContext *ctx, AVPacket *out)
++{
++    ASFTOANNEXGBSFContext* bsfctx = ctx->priv_data;
++    AVPacket *in;
++    int keyframe = 0;
++    int ret = 0;
++    uint8_t* bs = NULL;
++
++    ret = ff_bsf_get_packet(ctx, &in);
++    if (ret < 0)
++        return ret;
++
++    keyframe = in->flags & AV_PKT_FLAG_KEY;
++    if(in->size >= 1 && !find_codec_data(bsfctx, in->data, in->size, keyframe)) {
++//         av_log(NULL, AV_LOG_INFO, "Nothing to do: %i\n",in->size);
++        out->data = in->data;
++        out->size = in->size;
++        return 0;
++    }
++
++    if(!ctx->par_in->extradata || ctx->par_in->extradata_size < 16) {
++        av_log(NULL, AV_LOG_INFO, "Extradata size too small: %i\n", ctx->par_in->extradata_size);
++        out->data = in->data;
++        out->size = in->size;
++        return 0;
++    }
++
++    if (!bsfctx->frames && parse_extradata(bsfctx, ctx->par_in->extradata , ctx->par_in->extradata_size ) < 0) {
++       av_freep(in);
++        av_log(NULL, AV_LOG_ERROR, "Cannot parse extra data!\n");
++        return -1;
++    }
++
++    if (keyframe) {
++        // If this is the keyframe, need to put sequence header and entry point header.
++        out->size = bsfctx->seq_header_size + bsfctx->ep_header_size + 4 + in->size;
++        out->data = av_malloc(out->size);
++        bs = out->data;
++
++        memcpy(bs, bsfctx->seq_header, bsfctx->seq_header_size);
++        bs += bsfctx->seq_header_size;
++        memcpy(bs, bsfctx->ep_header, bsfctx->ep_header_size);
++        bs += bsfctx->ep_header_size;
++    } else {
++        out->size = 4 + in->size;
++        out->data = av_malloc(out->size);
++        bs = out->data;
++    }
++
++    // Put the frame start code and frame data.
++    bytestream_put_be32(&bs, VC1_CODE_FRAME);
++    memcpy(bs, in->data, in->size);
++    ++bsfctx->frames;
++    return 1;
++
++ }
++
++static void asftoannexg_close(AVBSFContext *bsfc) {
++    ASFTOANNEXGBSFContext *bsfctx = bsfc->priv_data;
++    av_freep(&bsfctx->seq_header);
++    av_freep(&bsfctx->ep_header);
++}
++
++static const enum AVCodecID codec_ids[] = {
++    AV_CODEC_ID_VC1, AV_CODEC_ID_NONE,
++};
++
++AVBitStreamFilter ff_vc1_asftoannexg_bsf = {
++    .name           = "vc1_asftoannexg",
++    .priv_data_size = sizeof(ASFTOANNEXGBSFContext),
++    .filter         = asftoannexg_filter,
++    .close          = asftoannexg_close,
++    .codec_ids      = codec_ids
++};
+diff --git a/libavcodec/vc1_asftorcv_bsf.c b/libavcodec/vc1_asftorcv_bsf.c
+new file mode 100644
+index 0000000000..ee338d384c
+--- /dev/null
++++ b/libavcodec/vc1_asftorcv_bsf.c
+@@ -0,0 +1,95 @@
++/*
++ * copyright (c) 2010 Google Inc.
++ * copyright (c) 2017 Jacek Jendrzej port to 3.x
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include "avcodec.h"
++#include "bytestream.h"
++#include "bsf.h"
++
++#define RCV_STREAM_HEADER_SIZE 36
++#define RCV_PICTURE_HEADER_SIZE 8
++
++typedef struct ASFTORCVBSFContext {
++    int frames;
++} ASFTORCVBSFContext;
++
++static int asftorcv_filter(AVBSFContext *ctx, AVPacket *out){
++    ASFTORCVBSFContext* bsfctx = ctx->priv_data;
++    AVPacket *in;
++    int keyframe = 0;
++    int ret = 0;
++    uint8_t* bs = NULL;
++
++    ret = ff_bsf_get_packet(ctx, &in);
++    if (ret < 0)
++        return ret;
++
++    keyframe = in->flags & AV_PKT_FLAG_KEY;
++
++    if (!bsfctx->frames) {
++        // Write the header if this is the first frame.
++        out->data = av_malloc(RCV_STREAM_HEADER_SIZE + RCV_PICTURE_HEADER_SIZE + in->size);
++        out->size = RCV_STREAM_HEADER_SIZE + RCV_PICTURE_HEADER_SIZE + in->size;
++        bs = out->data;
++
++        // The following structure of stream header comes from libavformat/vc1testenc.c.
++        bytestream_put_le24(&bs, 0);  // Frame count. 0 for streaming.
++        bytestream_put_byte(&bs, 0xC5);
++        bytestream_put_le32(&bs, 4);  // 4 bytes of extra data.
++        bytestream_put_byte(&bs, ctx->par_in->extradata[0]);
++        bytestream_put_byte(&bs, ctx->par_in->extradata[1]);
++        bytestream_put_byte(&bs, ctx->par_in->extradata[2]);
++        bytestream_put_byte(&bs, ctx->par_in->extradata[3]);
++        bytestream_put_le32(&bs, ctx->par_in->height);
++        bytestream_put_le32(&bs, ctx->par_in->width);
++        bytestream_put_le32(&bs, 0xC);
++        bytestream_put_le24(&bs, 0);  // hrd_buffer
++        bytestream_put_byte(&bs, 0x80);  // level|cbr|res1
++        bytestream_put_le32(&bs, 0);  // hrd_rate
++
++        // The following LE32 describes the frame rate. Since we don't care so fill
++        // it with 0xFFFFFFFF which means variable framerate.
++        // See: libavformat/vc1testenc.c
++        bytestream_put_le32(&bs, 0xFFFFFFFF);
++    } else {
++        out->data = av_malloc(RCV_PICTURE_HEADER_SIZE + in->size);
++        out->size = RCV_PICTURE_HEADER_SIZE + in->size;
++        bs = out->data;
++    }
++
++    // Write the picture header.
++    bytestream_put_le32(&bs, in->size | (keyframe ? 0x80000000 : 0));
++
++    //  The following LE32 describes the pts. Since we don't care so fill it with 0.
++    bytestream_put_le32(&bs, 0);
++    memcpy(bs, in->data, in->size);
++
++    ++bsfctx->frames;
++    return 0;
++}
++
++static const enum AVCodecID codec_ids[] = {
++    AV_CODEC_ID_WMV3, AV_CODEC_ID_NONE,
++};
++
++AVBitStreamFilter ff_vc1_asftorcv_bsf = {
++    .name         = "vc1_asftorcv",
++    .priv_data_size = sizeof(ASFTORCVBSFContext),
++    .filter         = asftorcv_filter
++};
+-- 
+2.14.1
+