Motivated by a desire to use vf_libplacebo as a GPU-accelerated
cropping/padding/zooming filter. This commit adds support for setting
the `input/target.crop` fields as dynamic expressions.
Re-use the same generic variables available to other scale and crop type
filters, and also add some more that we can afford as a result of being
able to set these properties dynamically.
It's worth pointing out that `out_t/ot` is currently redundant with
`in_t/t` since it will always contain the same PTS values, but I plan on
changing this in the near future.
I decided to also expose `crop_w/crop_h` and `pos_w/pos_h` as variables
in the expression parser itself, since this enables the fairly common
use case of determining dimensions first and then placing the image
appropriately, such as is done in the default behavior (which centers
the cropped/placed region by default).
{"w","Output video width",OFFSET(w_expr),AV_OPT_TYPE_STRING,{.str="iw"},.flags=STATIC},
{"h","Output video height",OFFSET(h_expr),AV_OPT_TYPE_STRING,{.str="ih"},.flags=STATIC},
{"w","Output video frame width",OFFSET(w_expr),AV_OPT_TYPE_STRING,{.str="iw"},.flags=STATIC},
{"h","Output video frame height",OFFSET(h_expr),AV_OPT_TYPE_STRING,{.str="ih"},.flags=STATIC},
{"crop_x","Input video crop x",OFFSET(crop_x_expr),AV_OPT_TYPE_STRING,{.str="(iw-cw)/2"},.flags=DYNAMIC},
{"crop_y","Input video crop y",OFFSET(crop_y_expr),AV_OPT_TYPE_STRING,{.str="(ih-ch)/2"},.flags=DYNAMIC},
{"crop_w","Input video crop w",OFFSET(crop_w_expr),AV_OPT_TYPE_STRING,{.str="iw"},.flags=DYNAMIC},
{"crop_h","Input video crop h",OFFSET(crop_h_expr),AV_OPT_TYPE_STRING,{.str="ih"},.flags=DYNAMIC},
{"pos_x","Output video placement x",OFFSET(pos_x_expr),AV_OPT_TYPE_STRING,{.str="(ow-pw)/2"},.flags=DYNAMIC},
{"pos_y","Output video placement y",OFFSET(pos_y_expr),AV_OPT_TYPE_STRING,{.str="(oh-ph)/2"},.flags=DYNAMIC},
{"pos_w","Output video placement w",OFFSET(pos_w_expr),AV_OPT_TYPE_STRING,{.str="ow"},.flags=DYNAMIC},
{"pos_h","Output video placement h",OFFSET(pos_h_expr),AV_OPT_TYPE_STRING,{.str="oh"},.flags=DYNAMIC},
{"format","Output video format",OFFSET(out_format_string),AV_OPT_TYPE_STRING,.flags=STATIC},
{"force_original_aspect_ratio","decrease or increase w/h if necessary to keep the original AR",OFFSET(force_original_aspect_ratio),AV_OPT_TYPE_INT,{.i64=0},0,2,STATIC,"force_oar"},
{"force_divisible_by","enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used",OFFSET(force_divisible_by),AV_OPT_TYPE_INT,{.i64=1},1,256,STATIC},
{"normalize_sar","force SAR normalization to 1:1",OFFSET(normalize_sar),AV_OPT_TYPE_BOOL,{.i64=0},0,1,STATIC},
{"normalize_sar","force SAR normalization to 1:1 by adjusting pos_x/y/w/h",OFFSET(normalize_sar),AV_OPT_TYPE_BOOL,{.i64=0},0,1,STATIC},
{"pad_crop_ratio","ratio between padding and cropping when normalizing SAR (0=pad, 1=crop)",OFFSET(pad_crop_ratio),AV_OPT_TYPE_FLOAT,{.dbl=0.0},0.0,1.0,DYNAMIC},
{"fillcolor","Background fill color",OFFSET(fillcolor),AV_OPT_TYPE_STRING,{.str="black"},.flags=DYNAMIC},