strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.71k stars 298 forks source link

ctuSize in heif_compression_HEVC encoder #1138

Closed keni7385 closed 7 months ago

keni7385 commented 7 months ago

Hello,

How can I set the ctuSize when using heif_compression_HEVC as heif::Encoder?

Is the parameter already exposed to libheif users? Or does the codebase require changes?

Thank you!

silverbacknet commented 7 months ago

For x265, you're looking for set_parameter_integer("ctu",x);. (set_parameter_string for string parameters)

bradh commented 7 months ago

For x265, you're looking for set_parameter_integer("ctu",x);. (set_parameter_string for string parameters)

You can also use the command line tool. The man page (https://github.com/strukturag/libheif/blob/master/examples/heif-enc.1#L71-L74) says:

When using the x265 encoder, you may pass it any of its parameters by
prefixing the parameter name with x265:.
Hence, to set the ctu parameter, you will have to set x265:ctu
in libheif (e.g.: -p x265:ctu=64).
keni7385 commented 7 months ago

Thank you to both of you.

String parameter solved my issue:

encoder.set_string_parameter("x265:ctu", "16");

I was trying encoder.set_integer_parameter("x265:ctu", 16), which didn't work. Indeed, only x265_set_parameter_string has the logic to handle parameters prefixed by "x265:"

https://github.com/strukturag/libheif/blob/33e00a4ec54e6fffca3febe3054017b1b81a0c49/libheif/plugins/encoder_x265.cc#L513-L515