Skip to content

Commit

Permalink
upipe_ffmt: add range conversion for hardware surfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
nto authored and cmassiot committed Sep 25, 2024
1 parent 68fcc52 commit 6cefb88
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions lib/upipe-filters/upipe_filter_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static int upipe_ffmt_check_flow_format(struct upipe *upipe,
bool need_derive = pic_vaapi_in && pic_qsv_out;
bool need_avfilter = ffmt_mgr->avfilter_mgr && hw &&
(need_deint || need_scale || need_format || need_hw_transfer ||
need_derive);
need_derive || need_range);

if (need_avfilter) {
if (need_format) {
Expand Down Expand Up @@ -414,6 +414,16 @@ static int upipe_ffmt_check_flow_format(struct upipe *upipe,
" → %" PRIu64 "x%" PRIu64,
hsize_in, vsize_in, hsize_out, vsize_out);
}
if (need_range) {
const char *from =
ubase_check(uref_pic_flow_get_full_range(flow_def)) ?
"full" : "limited";
const char *to =
ubase_check(uref_pic_flow_get_full_range(flow_def_dup)) ?
"full" : "limited";
upipe_notice_va(upipe, "need range conversion %s → %s",
from, to);
}
if (need_derive)
upipe_notice(upipe, "need hw surface mapping vaapi → qsv");

Expand All @@ -433,18 +443,26 @@ static int upipe_ffmt_check_flow_format(struct upipe *upipe,

#define str_cat(fmt, ...) pos += sprintf(filters + pos, fmt, ##__VA_ARGS__)

if (!pic_vaapi_in)
if (!hw_in)
str_cat("scale,format=nv12,hwupload,");
if (need_deint)
str_cat("deinterlace_vaapi=auto=1,");
if (need_scale || need_format) {
if (need_scale || need_format || need_range) {
str_cat("scale_vaapi=");
if (need_scale)
str_cat("w=%"PRIu64":h=%"PRIu64, hsize, vsize);
if (need_scale && need_format)
str_cat(":");
if (need_format)
if (need_format) {
if (need_scale)
str_cat(":");
str_cat("format=%s", pix_fmt_sw);
}
if (need_range) {
if (need_scale || need_format)
str_cat(":");
str_cat("out_range=%s",
ubase_check(uref_pic_flow_get_full_range(flow_def_dup)) ?
"full" : "limited");
}
str_cat(",");
}
if (!hw_out) {
Expand Down

0 comments on commit 6cefb88

Please sign in to comment.