Skip to content

Commit

Permalink
[ffmpeg-vaapi] add b_depth test options for h264 cqp encode
Browse files Browse the repository at this point in the history
Signed-off-by: Wang Hangjie <[email protected]>
  • Loading branch information
Hangjie22Coder committed Aug 20, 2024
1 parent d9af754 commit 934603b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
3 changes: 2 additions & 1 deletion lib/ffmpeg/encoderbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions lib/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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", [])):
Expand Down Expand Up @@ -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

Expand Down
22 changes: 12 additions & 10 deletions test/ffmpeg-vaapi/encode/avc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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()

Expand Down

0 comments on commit 934603b

Please sign in to comment.