From 934603b39df29f1b8016e972f73d0d5ee454794a Mon Sep 17 00:00:00 2001 From: Wang Hangjie Date: Mon, 29 Jul 2024 21:57:30 -0700 Subject: [PATCH] [ffmpeg-vaapi] add b_depth test options for h264 cqp encode Signed-off-by: Wang Hangjie --- lib/ffmpeg/encoderbase.py | 3 ++- lib/parameters.py | 11 ++++++----- test/ffmpeg-vaapi/encode/avc.py | 22 ++++++++++++---------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/ffmpeg/encoderbase.py b/lib/ffmpeg/encoderbase.py index 9c58ecd8..1b6013e0 100755 --- a/lib/ffmpeg/encoderbase.py +++ b/lib/ffmpeg/encoderbase.py @@ -65,6 +65,7 @@ def hwformat(self): roi = property(lambda s: s.ifprop("roi", ",addroi=0:0:{width}/2:{height}/2:-1/3")) strict = property(lambda s: s.ifprop("strict", " -strict {strict}")) seek = property(lambda s: s.ifprop("seek", " -ss {seek}")) + bdepth = property(lambda s: s.ifprop("bdepth", " -b_depth {bdepth}")) hwupload = property(lambda s: ",hwupload") @property @@ -109,7 +110,7 @@ def encparams(self): f"{self.bframes}{self.slices}{self.minrate}{self.maxrate}{self.refs}" f"{self.extbrc}{self.loopshp}{self.looplvl}{self.tilecols}{self.tilerows}" f"{self.level}{self.ladepth}{self.forced_idr}{self.intref}{self.lowpower}" - f"{self.maxframesize}{self.pict}{self.rqp}{self.strict}{self.seek}" + f"{self.maxframesize}{self.pict}{self.rqp}{self.strict}{self.seek}{self.bdepth}" ) @property diff --git a/lib/parameters.py b/lib/parameters.py index d390c3e9..3bcd3c60 100755 --- a/lib/parameters.py +++ b/lib/parameters.py @@ -26,7 +26,7 @@ def gen_avc_cqp_variants(spec, profiles): for case, params in spec.items(): variants = copy.deepcopy(params.get("variants", dict()).get("cqp", None)) if variants is None: - keys = ["gop", "slices", "bframes", "qp", "quality", "profile"] + keys = ["gop", "slices", "bframes", "qp", "quality", "profile", "bdepth"] product = list(itertools.product([1], [1], [0], [14, 28], [1, 4, 7], profiles)) # I, single-slice product += list(itertools.product([30], [1], [0], [14, 28], [1, 4, 7], profiles)) # IP, single-slice product += list(itertools.product([30], [4], [2], [14, 28], [1, 4, 7], profiles)) # IPB, multi-slice @@ -50,14 +50,15 @@ def gen_avc_cqp_variants(spec, profiles): for profile in cprofiles: yield [ case, variant["gop"], variant["slices"], variant["bframes"], - variant["qp"], variant["quality"], profile + variant["qp"], variant["quality"], profile, variant.get("bdepth", 0) ] def gen_avc_cqp_parameters(spec, profiles): - keys = ("case", "gop", "slices", "bframes", "qp", "quality", "profile") + keys = ("case", "gop", "slices", "bframes", "qp", "quality", "profile", "bdepth") params = gen_avc_cqp_variants(spec, profiles) return keys, params + def gen_avc_cbr_variants(spec, profiles): for case, params in spec.items(): for variant in copy.deepcopy(params.get("variants", dict()).get("cbr", [])): @@ -127,11 +128,11 @@ def gen_avc_cqp_lp_variants(spec, profiles): for profile in cprofiles: yield [ case, variant["gop"], variant["slices"], variant["bframes"], variant["qp"], - variant["quality"], profile + variant["quality"], profile, variant.get("bdepth", 0) ] def gen_avc_cqp_lp_parameters(spec, profiles): - keys = ("case", "gop", "slices", "bframes", "qp", "quality", "profile") + keys = ("case", "gop", "slices", "bframes", "qp", "quality", "profile", "bdepth") params = gen_avc_cqp_lp_variants(spec, profiles) return keys, params diff --git a/test/ffmpeg-vaapi/encode/avc.py b/test/ffmpeg-vaapi/encode/avc.py index d3c42149..d781f97d 100755 --- a/test/ffmpeg-vaapi/encode/avc.py +++ b/test/ffmpeg-vaapi/encode/avc.py @@ -12,7 +12,7 @@ spec_r2r = load_test_spec("avc", "encode", "r2r") class cqp(AVCEncoderTest): - def init(self, tspec, case, gop, slices, bframes, qp, quality, profile): + def init(self, tspec, case, gop, slices, bframes, qp, quality, profile, bdepth): vars(self).update(tspec[case].copy()) vars(self).update( bframes = bframes, @@ -23,21 +23,22 @@ def init(self, tspec, case, gop, slices, bframes, qp, quality, profile): quality = quality, rcmode = "cqp", slices = slices, + bdepth = bdepth, ) @slash.parametrize(*gen_avc_cqp_parameters(spec, ['high', 'main'])) - def test(self, case, gop, slices, bframes, qp, quality, profile): - self.init(spec, case, gop, slices, bframes, qp, quality, profile) + def test(self, case, gop, slices, bframes, qp, quality, profile, bdepth): + self.init(spec, case, gop, slices, bframes, qp, quality, profile, bdepth) self.encode() @slash.parametrize(*gen_avc_cqp_parameters(spec_r2r, ['high', 'main'])) - def test_r2r(self, case, gop, slices, bframes, qp, quality, profile): - self.init(spec_r2r, case, gop, slices, bframes, qp, quality, profile) + def test_r2r(self, case, gop, slices, bframes, qp, quality, profile, bdepth): + self.init(spec_r2r, case, gop, slices, bframes, qp, quality, profile, bdepth) vars(self).setdefault("r2r", 5) self.encode() class cqp_lp(AVCEncoderLPTest): - def init(self, tspec, case, gop, slices, bframes, qp, quality, profile): + def init(self, tspec, case, gop, slices, bframes, qp, quality, profile, bdepth): vars(self).update(tspec[case].copy()) vars(self).update( bframes = bframes, @@ -48,16 +49,17 @@ def init(self, tspec, case, gop, slices, bframes, qp, quality, profile): quality = quality, rcmode = "cqp", slices = slices, + bdepth = bdepth, ) @slash.parametrize(*gen_avc_cqp_lp_parameters(spec, ['high', 'main'])) - def test(self, case, gop, slices, bframes, qp, quality, profile): - self.init(spec, case, gop, slices, bframes, qp, quality, profile) + def test(self, case, gop, slices, bframes, qp, quality, profile, bdepth): + self.init(spec, case, gop, slices, bframes, qp, quality, profile, bdepth) self.encode() @slash.parametrize(*gen_avc_cqp_lp_parameters(spec_r2r, ['high', 'main'])) - def test_r2r(self, case, gop, slices, bframes, qp, quality, profile): - self.init(spec_r2r, case, gop, slices, bframes, qp, quality, profile) + def test_r2r(self, case, gop, slices, bframes, qp, quality, profile, bdepth): + self.init(spec_r2r, case, gop, slices, bframes, qp, quality, profile, bdepth) vars(self).setdefault("r2r", 5) self.encode()