--- /dev/null
+mpeg mpeg2video
+sc_threshold=-30000
+dc=11
+bf=2
+trellis=2
+mbd=rd
+cmp=2
+subcmp=2
+b=4000000
--- /dev/null
+mpeg mpeg2video
+# pass 1 of 2, you must render the 2nd pass using pass2of2...
+flags +pass1
+cin_stats_filename /tmp/2passes_mpeg2.log
+b=3600k
+dc 10
+g 12
+maxrate 8000k
+q:v 2
+b_strategy 2
+brd_scale 2
+bf 2
+profile:v 4
+pass=1
+intra_matrix="8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27,29,32,35,40,48,26,27,29,32,35,40,48,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83"
+inter_matrix="16,17,18,19,20,21,22,23,17,18,19,20,21,22,23,24,18,19,20,21,22,23,24,25,19,20,21,22,23,24,26,27,20,21,22,23,25,26,27,28,21,22,23,24,26,27,28,30,22,23,24,26,27,28,30,31,23,24,25,27,28,30,31,33"
--- /dev/null
+mpeg mpeg2video
+# 2nd pass, you must render first with pass1of2...
+flags +pass2
+cin_stats_filename /tmp/2passes_mpeg2.log
+b=3600k
+dc 10
+g 12
+lmin 0.75
+mblmin 50
+qmin 1
+qmax 31
+maxrate 8000k
+bf 2
+pre_dia_size 5
+dia_size 5
+qcomp 0.7
+qblur 0
+preme 2
+me_method dia
+sc_threshold 0
+sc_factor 4
+bidir_refine 4
+profile:v 4
+mbd rd
+mbcmp satd
+precmp satd
+cmp satd
+subcmp satd
+skipcmp satd
+pass=2
+intra_matrix="8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27,29,32,35,40,48,26,27,29,32,35,40,48,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83"
+inter_matrix="16,17,18,19,20,21,22,23,17,18,19,20,21,22,23,24,18,19,20,21,22,23,24,25,19,20,21,22,23,24,26,27,20,21,22,23,25,26,27,28,21,22,23,24,26,27,28,30,22,23,24,26,27,28,30,31,23,24,25,27,28,30,31,33"
--- /dev/null
+--- a/libavcodec/wrapped_avframe.c.orig 2021-06-15 22:37:02.955552877 +0300
++++ b/libavcodec/wrapped_avframe.c 2021-06-15 23:50:34.439553140 +0300
+@@ -109,6 +109,36 @@
+ return 0;
+ }
+
++
++
++static const enum AVPixelFormat pix_fmts_all[] = {
++ AV_PIX_FMT_YUV411P,
++ AV_PIX_FMT_YUV420P,
++ AV_PIX_FMT_YUVJ420P,
++ AV_PIX_FMT_YUV422P,
++ AV_PIX_FMT_YUVJ422P,
++ AV_PIX_FMT_YUV444P,
++ AV_PIX_FMT_YUVJ444P,
++ AV_PIX_FMT_YUV420P10,
++ AV_PIX_FMT_YUV422P10,
++ AV_PIX_FMT_YUV444P10,
++ AV_PIX_FMT_YUV420P12,
++ AV_PIX_FMT_YUV422P12,
++ AV_PIX_FMT_YUV444P12,
++ AV_PIX_FMT_YUV420P14,
++ AV_PIX_FMT_YUV422P14,
++ AV_PIX_FMT_YUV444P14,
++ AV_PIX_FMT_YUV420P16,
++ AV_PIX_FMT_YUV422P16,
++ AV_PIX_FMT_YUV444P16,
++ AV_PIX_FMT_GRAY8,
++ AV_PIX_FMT_GRAY9,
++ AV_PIX_FMT_GRAY10,
++ AV_PIX_FMT_GRAY12,
++ AV_PIX_FMT_GRAY16,
++ AV_PIX_FMT_NONE
++};
++
+ AVCodec ff_wrapped_avframe_encoder = {
+ .name = "wrapped_avframe",
+ .long_name = NULL_IF_CONFIG_SMALL("AVFrame to AVPacket passthrough"),
+@@ -116,6 +146,7 @@
+ .id = AV_CODEC_ID_WRAPPED_AVFRAME,
+ .encode2 = wrapped_avframe_encode,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
++ .pix_fmts = pix_fmts_all,
+ };
+
+ AVCodec ff_wrapped_avframe_decoder = {
--- /dev/null
+--- a/libavformat/yuv4mpegenc.c.orig 2021-06-15 23:40:32.239553104 +0300
++++ b/libavformat/yuv4mpegenc.c 2021-06-15 23:40:40.851553105 +0300
+@@ -313,7 +313,7 @@
+ av_log(s, AV_LOG_ERROR, "'%s' is not an official yuv4mpegpipe pixel format. "
+ "Use '-strict -1' to encode to this pixel format.\n",
+ av_get_pix_fmt_name(s->streams[0]->codecpar->format));
+- return AVERROR(EINVAL);
++ //return AVERROR(EINVAL);
+ }
+ av_log(s, AV_LOG_WARNING, "Warning: generating non standard YUV stream. "
+ "Mjpegtools will not work.\n");
--- /dev/null
+diff --git a/libavformat/avidec.c b/libavformat/avidec.c
+index 5cf67a4771..5bd2372c27 100644
+--- a/libavformat/avidec.c
++++ b/libavformat/avidec.c
+@@ -1942,6 +1942,7 @@ AVInputFormat ff_avi_demuxer = {
+ .long_name = NULL_IF_CONFIG_SMALL("AVI (Audio Video Interleaved)"),
+ .priv_data_size = sizeof(AVIContext),
+ .extensions = "avi",
++ .flags = AVFMT_SEEK_NOSTREAMS,
+ .read_probe = avi_probe,
+ .read_header = avi_read_header,
+ .read_packet = avi_read_packet,
--- /dev/null
+--- ffmpeg-4.4/libavcodec/aaccoder.c.orig 2021-05-08 11:52:41.824074401 +0300
++++ ffmpeg-4.4/libavcodec/aaccoder.c 2021-05-08 11:55:06.868074410 +0300
+@@ -800,7 +800,7 @@
+
+ for (sid_sf_boost = 0; sid_sf_boost < 4; sid_sf_boost++) {
+ float dist1 = 0.0f, dist2 = 0.0f;
+- int B0 = 0, B1 = 0;
++ int B0_ = 0, B1 = 0;
+ int minidx;
+ int mididx, sididx;
+ int midcb, sidcb;
+@@ -862,12 +862,12 @@
+ sididx,
+ sidcb,
+ mslambda / (minthr * bmax), INFINITY, &b4, NULL, 0);
+- B0 += b1+b2;
++ B0_ += b1+b2;
+ B1 += b3+b4;
+ dist1 -= b1+b2;
+ dist2 -= b3+b4;
+ }
+- cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0;
++ cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0_;
+ if (cpe->ms_mask[w*16+g]) {
+ if (sce0->band_type[w*16+g] != NOISE_BT && sce1->band_type[w*16+g] != NOISE_BT) {
+ sce0->sf_idx[w*16+g] = mididx;
+@@ -879,7 +879,7 @@
+ cpe->ms_mask[w*16+g] = 0;
+ }
+ break;
+- } else if (B1 > B0) {
++ } else if (B1 > B0_) {
+ /* More boost won't fix this */
+ break;
+ }
--- /dev/null
+--- ffmpeg-4.4/libavcodec/hevc_mvs.c.orig 2021-05-08 12:22:19.580985429 +0300
++++ ffmpeg-4.4/libavcodec/hevc_mvs.c 2021-05-08 12:29:05.340985454 +0300
+@@ -307,8 +307,8 @@
+ const int xB1 = x0 + nPbW - 1;
+ const int yB1 = y0 - 1;
+
+- const int xB0 = x0 + nPbW;
+- const int yB0 = y0 - 1;
++ const int xB0_ = x0 + nPbW;
++ const int yB0_ = y0 - 1;
+
+ const int xA0 = x0 - 1;
+ const int yA0 = y0 + nPbH;
+@@ -365,14 +365,14 @@
+ }
+
+ // above right spatial merge candidate
+- is_available_b0 = AVAILABLE(cand_up_right, B0) &&
+- xB0 < s->ps.sps->width &&
+- PRED_BLOCK_AVAILABLE(B0) &&
+- !is_diff_mer(s, xB0, yB0, x0, y0);
++ is_available_b0 = AVAILABLE(cand_up_right, B0_) &&
++ xB0_ < s->ps.sps->width &&
++ PRED_BLOCK_AVAILABLE(B0_) &&
++ !is_diff_mer(s, xB0_, yB0_, x0, y0);
+
+ if (is_available_b0 &&
+- !(is_available_b1 && COMPARE_MV_REFIDX(B0, B1))) {
+- mergecandlist[nb_merge_cand] = TAB_MVF_PU(B0);
++ !(is_available_b1 && COMPARE_MV_REFIDX(B0_, B1))) {
++ mergecandlist[nb_merge_cand] = TAB_MVF_PU(B0_);
+ if (merge_idx == nb_merge_cand)
+ return;
+ nb_merge_cand++;
+@@ -588,7 +588,7 @@
+ MvField *tab_mvf = s->ref->tab_mvf;
+ int isScaledFlag_L0 = 0;
+ int availableFlagLXA0 = 1;
+- int availableFlagLXB0 = 1;
++ int availableFlagLXB0_ = 1;
+ int numMVPCandLX = 0;
+ int min_pu_width = s->ps.sps->min_pu_width;
+
+@@ -596,7 +596,7 @@
+ int is_available_a0;
+ int xA1, yA1;
+ int is_available_a1;
+- int xB0, yB0;
++ int xB0_, yB0_;
+ int is_available_b0;
+ int xB1, yB1;
+ int is_available_b1;
+@@ -677,12 +677,12 @@
+ b_candidates:
+ // B candidates
+ // above right spatial merge candidate
+- xB0 = x0 + nPbW;
+- yB0 = y0 - 1;
++ xB0_ = x0 + nPbW;
++ yB0_ = y0 - 1;
+
+- is_available_b0 = AVAILABLE(cand_up_right, B0) &&
+- xB0 < s->ps.sps->width &&
+- PRED_BLOCK_AVAILABLE(B0);
++ is_available_b0 = AVAILABLE(cand_up_right, B0_) &&
++ xB0_ < s->ps.sps->width &&
++ PRED_BLOCK_AVAILABLE(B0_);
+
+ // above spatial merge candidate
+ xB1 = x0 + nPbW - 1;
+@@ -696,10 +696,10 @@
+
+ // above right spatial merge candidate
+ if (is_available_b0) {
+- if (MP_MX(B0, pred_flag_index_l0, mxB)) {
++ if (MP_MX(B0_, pred_flag_index_l0, mxB)) {
+ goto scalef;
+ }
+- if (MP_MX(B0, pred_flag_index_l1, mxB)) {
++ if (MP_MX(B0_, pred_flag_index_l1, mxB)) {
+ goto scalef;
+ }
+ }
+@@ -723,40 +723,40 @@
+ goto scalef;
+ }
+ }
+- availableFlagLXB0 = 0;
++ availableFlagLXB0_ = 0;
+
+ scalef:
+ if (!isScaledFlag_L0) {
+- if (availableFlagLXB0) {
++ if (availableFlagLXB0_) {
+ availableFlagLXA0 = 1;
+ mxA = mxB;
+ }
+- availableFlagLXB0 = 0;
++ availableFlagLXB0_ = 0;
+
+ // XB0 and L1
+ if (is_available_b0) {
+- availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l0, mxB);
+- if (!availableFlagLXB0)
+- availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l1, mxB);
++ availableFlagLXB0_ = MP_MX_LT(B0_, pred_flag_index_l0, mxB);
++ if (!availableFlagLXB0_)
++ availableFlagLXB0_ = MP_MX_LT(B0_, pred_flag_index_l1, mxB);
+ }
+
+- if (is_available_b1 && !availableFlagLXB0) {
+- availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l0, mxB);
+- if (!availableFlagLXB0)
+- availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l1, mxB);
++ if (is_available_b1 && !availableFlagLXB0_) {
++ availableFlagLXB0_ = MP_MX_LT(B1, pred_flag_index_l0, mxB);
++ if (!availableFlagLXB0_)
++ availableFlagLXB0_ = MP_MX_LT(B1, pred_flag_index_l1, mxB);
+ }
+
+- if (is_available_b2 && !availableFlagLXB0) {
+- availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l0, mxB);
+- if (!availableFlagLXB0)
+- availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l1, mxB);
++ if (is_available_b2 && !availableFlagLXB0_) {
++ availableFlagLXB0_ = MP_MX_LT(B2, pred_flag_index_l0, mxB);
++ if (!availableFlagLXB0_)
++ availableFlagLXB0_ = MP_MX_LT(B2, pred_flag_index_l1, mxB);
+ }
+ }
+
+ if (availableFlagLXA0)
+ mvpcand_list[numMVPCandLX++] = mxA;
+
+- if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y))
++ if (availableFlagLXB0_ && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y))
+ mvpcand_list[numMVPCandLX++] = mxB;
+
+ //temporal motion vector prediction candidate
--- /dev/null
+--- ffmpeg-4.4/libavcodec/opus_pvq.c.orig 2021-05-08 12:19:49.996985421 +0300
++++ ffmpeg-4.4/libavcodec/opus_pvq.c 2021-05-08 12:21:12.440985425 +0300
+@@ -495,12 +495,12 @@
+ uint32_t N0 = N;
+ int N_B = N / blocks;
+ int N_B0 = N_B;
+- int B0 = blocks;
++ int B0_ = blocks;
+ int time_divide = 0;
+ int recombine = 0;
+ int inv = 0;
+ float mid = 0, side = 0;
+- int longblocks = (B0 == 1);
++ int longblocks = (B0_ == 1);
+ uint32_t cm = 0;
+
+ if (N == 1) {
+@@ -532,7 +532,7 @@
+ /* Band recombining to increase frequency resolution */
+
+ if (lowband &&
+- (recombine || ((N_B & 1) == 0 && tf_change < 0) || B0 > 1)) {
++ (recombine || ((N_B & 1) == 0 && tf_change < 0) || B0_ > 1)) {
+ for (i = 0; i < N; i++)
+ lowband_scratch[i] = lowband[i];
+ lowband = lowband_scratch;
+@@ -556,13 +556,13 @@
+ time_divide++;
+ tf_change++;
+ }
+- B0 = blocks;
++ B0_ = blocks;
+ N_B0 = N_B;
+
+ /* Reorganize the samples in time order instead of frequency order */
+- if (B0 > 1 && (quant || lowband))
++ if (B0_ > 1 && (quant || lowband))
+ celt_deinterleave_hadamard(pvq->hadamard_tmp, quant ? X : lowband,
+- N_B >> recombine, B0 << recombine,
++ N_B >> recombine, B0_ << recombine,
+ longblocks);
+ }
+
+@@ -604,7 +604,7 @@
+ if (quant) {
+ if (stereo && N > 2)
+ ff_opus_rc_enc_uint_step(rc, itheta, qn / 2);
+- else if (stereo || B0 > 1)
++ else if (stereo || B0_ > 1)
+ ff_opus_rc_enc_uint(rc, itheta, qn + 1);
+ else
+ ff_opus_rc_enc_uint_tri(rc, itheta, qn);
+@@ -619,7 +619,7 @@
+ } else {
+ if (stereo && N > 2)
+ itheta = ff_opus_rc_dec_uint_step(rc, qn / 2);
+- else if (stereo || B0 > 1)
++ else if (stereo || B0_ > 1)
+ itheta = ff_opus_rc_dec_uint(rc, qn+1);
+ else
+ itheta = ff_opus_rc_dec_uint_tri(rc, qn);
+@@ -725,7 +725,7 @@
+
+ /* Give more bits to low-energy MDCTs than they would
+ * otherwise deserve */
+- if (B0 > 1 && !stereo && (itheta & 0x3fff)) {
++ if (B0_ > 1 && !stereo && (itheta & 0x3fff)) {
+ if (itheta > 8192)
+ /* Rough approximation for pre-echo masking */
+ delta -= delta >> (4 - duration);
+@@ -764,14 +764,14 @@
+ cmt = pvq->quant_band(pvq, f, rc, band, Y, NULL, N, sbits, blocks,
+ next_lowband2, duration, NULL, next_level,
+ gain * side, NULL, fill >> blocks);
+- cm |= cmt << ((B0 >> 1) & (stereo - 1));
++ cm |= cmt << ((B0_ >> 1) & (stereo - 1));
+ } else {
+ /* For a stereo split, the high bits of fill are always zero,
+ * so no folding will be done to the side. */
+ cm = pvq->quant_band(pvq, f, rc, band, Y, NULL, N, sbits, blocks,
+ next_lowband2, duration, NULL, next_level,
+ gain * side, NULL, fill >> blocks);
+- cm <<= ((B0 >> 1) & (stereo - 1));
++ cm <<= ((B0_ >> 1) & (stereo - 1));
+ rebalance = sbits - (rebalance - f->remaining2);
+ if (rebalance > 3 << 3 && itheta != 16384)
+ mbits += rebalance - (3 << 3);
+@@ -842,13 +842,13 @@
+ int k;
+
+ /* Undo the sample reorganization going from time order to frequency order */
+- if (B0 > 1)
++ if (B0_ > 1)
+ celt_interleave_hadamard(pvq->hadamard_tmp, X, N_B >> recombine,
+- B0 << recombine, longblocks);
++ B0_ << recombine, longblocks);
+
+ /* Undo time-freq changes that we did earlier */
+ N_B = N_B0;
+- blocks = B0;
++ blocks = B0_;
+ for (k = 0; k < time_divide; k++) {
+ blocks >>= 1;
+ N_B <<= 1;
--- /dev/null
+--- ffmpeg-4.4/libavcodec/libx264.c.orig
++++ ffmpeg-4.4/libavcodec/libx264.c
+@@ -790,6 +790,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
+ av_log(avctx, AV_LOG_ERROR,
+ "x264 too old for AVC Intra, at least version 142 needed\n");
+ #endif
++
++ if (x4->avcintra_class > 200) {
++#if X264_BUILD < 164
++ av_log(avctx, AV_LOG_ERROR,
++ "x264 too old for AVC Intra 300/480, at least version 164 needed\n");
++ return AVERROR(EINVAL);
++#else
++ /* AVC-Intra 300/480 only supported by Sony XAVC flavor */
++ x4->params.i_avcintra_flavor = X264_AVCINTRA_FLAVOR_SONY;
++#endif
++ }
++
+ if (x4->b_bias != INT_MIN)
+ x4->params.i_bframe_bias = x4->b_bias;
+ if (x4->b_pyramid >= 0)
+@@ -921,6 +933,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
+ }
+ }
+
++#if X264_BUILD >= 142
++ /* Separate headers not supported in AVC-Intra mode */
++ if (x4->params.i_avcintra_class >= 0)
++ x4->params.b_repeat_headers = 1;
++#endif
+
+ {
+ AVDictionaryEntry *en = NULL;
+@@ -1123,7 +1140,7 @@ static const AVOption options[] = {
+ { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_NONE}, INT_MIN, INT_MAX, VE, "nal-hrd" },
+ { "vbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_VBR}, INT_MIN, INT_MAX, VE, "nal-hrd" },
+ { "cbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_CBR}, INT_MIN, INT_MAX, VE, "nal-hrd" },
+- { "avcintra-class","AVC-Intra class 50/100/200", OFFSET(avcintra_class),AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 200 , VE},
++ { "avcintra-class","AVC-Intra class 50/100/200/300/480", OFFSET(avcintra_class),AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 480 , VE},
+ { "me_method", "Set motion estimation method", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA, VE, "motion-est"},
+ { "motion-est", "Set motion estimation method", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA, VE, "motion-est"},
+ { "dia", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_DIA }, INT_MIN, INT_MAX, VE, "motion-est" },