Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upipe_ffmt: add support for filters options #1054

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion include/upipe-av/upipe_avfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ enum upipe_avfilt_mgr_command {
UPIPE_AVFILT_MGR_SENTINEL = UPIPE_MGR_CONTROL_LOCAL,

/** gets the pixel format name from flow def (struct uref *, const char **, bool) */
UPIPE_AVFILT_MGR_GET_PIXFMT_NAME
UPIPE_AVFILT_MGR_GET_PIXFMT_NAME,
/** gets the color primaries name (int, const char **) */
UPIPE_AVFILT_MGR_GET_COLOR_PRIMARIES_NAME,
/** gets the color transfer characteristics name (int, const char **) */
UPIPE_AVFILT_MGR_GET_COLOR_TRANSFER_NAME,
/** gets the color space name (int, const char **) */
UPIPE_AVFILT_MGR_GET_COLOR_SPACE_NAME,
};

/** @This returns the pixel format name for the given flow definition.
Expand All @@ -125,6 +131,48 @@ static inline int upipe_avfilt_mgr_get_pixfmt_name(struct upipe_mgr *mgr,
UPIPE_AVFILT_SIGNATURE, flow_def, name, software);
}

/** @This returns the color primaries name for the given value.
*
* @param mgr pointer to manager
* @param color_primaries color primaries value
* @param name color primaries name
* @return an error code
*/
static inline int upipe_avfilt_mgr_get_color_primaries_name(
struct upipe_mgr *mgr, int color_primaries, const char **name)
{
return upipe_mgr_control(mgr, UPIPE_AVFILT_MGR_GET_COLOR_PRIMARIES_NAME,
UPIPE_AVFILT_SIGNATURE, color_primaries, name);
}

/** @This returns the color transfer name for the given value.
*
* @param mgr pointer to manager
* @param color_transfer color transfer characteristics value
* @param name color transfer characteristics name
* @return an error code
*/
static inline int upipe_avfilt_mgr_get_color_transfer_name(
struct upipe_mgr *mgr, int color_transfer, const char **name)
{
return upipe_mgr_control(mgr, UPIPE_AVFILT_MGR_GET_COLOR_TRANSFER_NAME,
UPIPE_AVFILT_SIGNATURE, color_transfer, name);
}

/** @This returns the color space name for the given value.
*
* @param mgr pointer to manager
* @param color_space color space value
* @param name color space name
* @return an error code
*/
static inline int upipe_avfilt_mgr_get_color_space_name(
struct upipe_mgr *mgr, int color_space, const char **name)
{
return upipe_mgr_control(mgr, UPIPE_AVFILT_MGR_GET_COLOR_SPACE_NAME,
UPIPE_AVFILT_SIGNATURE, color_space, name);
}

#ifdef __cplusplus
}
#endif
Expand Down
37 changes: 37 additions & 0 deletions lib/upipe-av/upipe_avfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2609,6 +2609,43 @@ static int upipe_avfilt_mgr_control(struct upipe_mgr *mgr,
bool software = va_arg(args, int);
return _upipe_avfilt_mgr_get_pixfmt_name(flow_def, name_p,
software);

case UPIPE_AVFILT_MGR_GET_COLOR_PRIMARIES_NAME: {
UBASE_SIGNATURE_CHECK(args, UPIPE_AVFILT_SIGNATURE)
int color_primaries = va_arg(args, int);
const char **name_p = va_arg(args, const char **);
const char *name = av_color_primaries_name(color_primaries);
if (!name)
return UBASE_ERR_INVALID;
if (name_p)
*name_p = name;
return UBASE_ERR_NONE;
}

case UPIPE_AVFILT_MGR_GET_COLOR_TRANSFER_NAME: {
UBASE_SIGNATURE_CHECK(args, UPIPE_AVFILT_SIGNATURE)
int color_transfer = va_arg(args, int);
const char **name_p = va_arg(args, const char **);
const char *name = av_color_transfer_name(color_transfer);
if (!name)
return UBASE_ERR_INVALID;
if (name_p)
*name_p = name;
return UBASE_ERR_NONE;
}

case UPIPE_AVFILT_MGR_GET_COLOR_SPACE_NAME: {
UBASE_SIGNATURE_CHECK(args, UPIPE_AVFILT_SIGNATURE)
int color_space = va_arg(args, int);
const char **name_p = va_arg(args, const char **);
const char *name = av_color_space_name(color_space);
if (!name)
return UBASE_ERR_INVALID;
if (name_p)
*name_p = name;
return UBASE_ERR_NONE;
}

default:
return UBASE_ERR_UNHANDLED;
}
Expand Down
Loading
Loading