Skip to content

Commit

Permalink
linux: fmpeg patching support (#1415)
Browse files Browse the repository at this point in the history
batteries included!
updates ffmepg too
  • Loading branch information
Vixea authored Jan 25, 2023
1 parent 8f5d28c commit c3cf129
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
8 changes: 6 additions & 2 deletions alvr/xtask/src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ pub fn build_ffmpeg_linux(nvenc_flag: bool) {
let download_path = afs::deps_dir().join("linux");
command::download_and_extract_zip(
&sh,
"https://codeload.github.com/FFmpeg/FFmpeg/zip/n4.4",
"https://codeload.github.com/FFmpeg/FFmpeg/zip/n5.1",
&download_path,
)
.unwrap();

let final_path = download_path.join("ffmpeg");

fs::rename(download_path.join("FFmpeg-n4.4"), &final_path).unwrap();
fs::rename(download_path.join("FFmpeg-n5.1"), &final_path).unwrap();

let flags = [
"--enable-gpl",
Expand Down Expand Up @@ -205,6 +205,10 @@ pub fn build_ffmpeg_linux(nvenc_flag: bool) {
.unwrap();
}

// Patches ffmpeg for workarounds and patches that have yet to be unstreamed
let ffmpeg_command = "for p in ../../../patches/*; do patch -p1 < $p; done";
cmd!(sh, "bash -c {ffmpeg_command}").run().unwrap();

let nproc = cmd!(sh, "nproc").read().unwrap();
cmd!(sh, "make -j{nproc}").run().unwrap();
cmd!(sh, "make install").run().unwrap();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index f15bcc6..de0951f 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -361,8 +361,10 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
sps->chroma_format_idc = 1;

sps->log2_max_frame_num_minus4 = 4;
- sps->pic_order_cnt_type = 0;
- sps->log2_max_pic_order_cnt_lsb_minus4 = 4;
+ sps->pic_order_cnt_type = ctx->max_b_depth ? 0 : 2;
+ if (sps->pic_order_cnt_type == 0) {
+ sps->log2_max_pic_order_cnt_lsb_minus4 = 4;
+ }

sps->max_num_ref_frames = priv->dpb_frames;

@@ -643,6 +645,10 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
}
}
hpic->pic_order_cnt = pic->display_order - hpic->last_idr_frame;
+ if (priv->raw_sps.pic_order_cnt_type == 2) {
+ hpic->pic_order_cnt *= 2;
+ }
+
hpic->dpb_delay = pic->display_order - pic->encode_order + ctx->max_b_depth;
hpic->cpb_delay = pic->encode_order - hpic->last_idr_frame;

0 comments on commit c3cf129

Please sign in to comment.