Skip to content
Open
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
160 changes: 160 additions & 0 deletions include/upipe-modules/upipe_interlace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
* Copyright (C) 2026 EasyTools
*
* Authors: Arnaud de Turckheim
*
* SPDX-License-Identifier: MIT
*/

/** @file
* @short Upipe interlacing module
*/

#ifndef _UPIPE_MODULES_UPIPE_INTERLACE_H_
/** @hidden */
#define _UPIPE_MODULES_UPIPE_INTERLACE_H_
#ifdef __cplusplus
extern "C" {
#endif

#include "upipe/upipe.h"

#define UPIPE_INTERLACE_SIGNATURE UBASE_FOURCC('i','n','t','l')

/** @This extends upipe_command with specific commands for interlace pipes. */
enum upipe_interlace_command {
UPIPE_INTERLACE_SENTINEL = UPIPE_CONTROL_LOCAL,

/** set top field first output (bool) */
UPIPE_INTERLACE_SET_TFF,
/** get the configured value for top field first output (bool *) */
UPIPE_INTERLACE_GET_TFF,
/** set field drop (bool) */
UPIPE_INTERLACE_SET_DROP,
/** get the configured value for field drop (bool *) */
UPIPE_INTERLACE_GET_DROP,
/** set low pass filter (bool) */
UPIPE_INTERLACE_SET_LOWPASS,
/** get the configured value for low pass filter (bool *) */
UPIPE_INTERLACE_GET_LOWPASS,
};

/** @This converts @ref upipe_interlace_command to a string.
*
* @param command command to convert
* @return a string or NULL if invalid
*/
static inline const char *upipe_interlace_command_str(int command)
{
switch ((enum upipe_interlace_command)command) {
UBASE_CASE_TO_STR(UPIPE_INTERLACE_SET_TFF);
UBASE_CASE_TO_STR(UPIPE_INTERLACE_GET_TFF);
UBASE_CASE_TO_STR(UPIPE_INTERLACE_SET_DROP);
UBASE_CASE_TO_STR(UPIPE_INTERLACE_GET_DROP);
UBASE_CASE_TO_STR(UPIPE_INTERLACE_SET_LOWPASS);
UBASE_CASE_TO_STR(UPIPE_INTERLACE_GET_LOWPASS);
case UPIPE_INTERLACE_SENTINEL: break;
}
return NULL;
}

/** @This sets the top field first output.
*
* @param upipe description structure of the pipe
* @param tff true for top field first, false for bottom field first
* @return an error code
*/
static inline int upipe_interlace_set_tff(struct upipe *upipe, bool tff)
{
return upipe_control(upipe, UPIPE_INTERLACE_SET_TFF,
UPIPE_INTERLACE_SIGNATURE, tff ? 1 : 0);
}

/** @This gets the top field first output configuration.
*
* @param upipe description structure of the pipe
* @param tff filled with the configured value
* @return an error code
*/
static inline int upipe_interlace_get_tff(struct upipe *upipe, bool *tff)
{
return upipe_control(upipe, UPIPE_INTERLACE_GET_TFF,
UPIPE_INTERLACE_SIGNATURE, tff);
}

/** @This sets field drop.
*
* If set to true, two frames are merged into one, keeping one field
* of each, so the output frame rate will be divided by two.
*
* 1111 2222 3333 4444 -> 1111 3333
* 1111 2222 3333 4444 2222 4444
* 1111 2222 3333 4444 1111 3333
* 1111 2222 3333 4444 2222 4444
*
* If set to false, each frame is merged with the previous and the
* next so the output frame rate is unchanged.
*
* 1111 2222 3333 4444 -> 1111 2222 3333 4444
* 1111 2222 3333 4444 2222 3333 4444 5555
* 1111 2222 3333 4444 1111 2222 3333 4444
* 1111 2222 3333 4444 2222 3333 4444 5555
*
* @param upipe description structure of the pipe
* @param drop true for dropping field
* @return an error code
*/
static inline int upipe_interlace_set_drop(struct upipe *upipe, bool drop)
{
return upipe_control(upipe, UPIPE_INTERLACE_SET_DROP,
UPIPE_INTERLACE_SIGNATURE, drop ? 1 : 0);
}

/** @This gets the field drop configuration.
*
* @param upipe description structure of the pipe
* @param drop filled with the configured value
* @return an error code
*/
static inline int upipe_interlace_get_drop(struct upipe *upipe, bool *drop)
{
return upipe_control(upipe, UPIPE_INTERLACE_GET_DROP,
UPIPE_INTERLACE_SIGNATURE, drop);
}

/** @This sets low pass filter.
*
* @param upipe description structure of the pipe
* @param lowpass true to enable low pass filter
* @return an error code
*/
static inline int upipe_interlace_set_lowpass(struct upipe *upipe, bool lowpass)
{
return upipe_control(upipe, UPIPE_INTERLACE_SET_LOWPASS,
UPIPE_INTERLACE_SIGNATURE, lowpass ? 1 : 0);
}

/** @This gets the configured value for low pass filter.
*
* @param upipe description structure of the pipe
* @param lowpass filled with the configured value
* @return an error code
*/
static inline int upipe_interlace_get_lowpass(struct upipe *upipe,
bool *lowpass)
{
return upipe_control(upipe, UPIPE_INTERLACE_GET_LOWPASS,
UPIPE_INTERLACE_SIGNATURE, lowpass);
}

/** @This returns the management structure for all interlace pipes.
*
* @return pointer to manager
*/
struct upipe_mgr *
upipe_interlace_mgr_alloc(void);
Comment on lines +154 to +155
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct upipe_mgr *
upipe_interlace_mgr_alloc(void);
struct upipe_mgr *upipe_interlace_mgr_alloc(void);


#ifdef __cplusplus
}
#endif
#endif
2 changes: 2 additions & 0 deletions lib/upipe-modules/Build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ libupipe_modules-includes = \
upipe_htons.h \
upipe_http_source.h \
upipe_idem.h \
upipe_interlace.h \
upipe_m3u_reader.h \
upipe_match_attr.h \
upipe_multicat_probe.h \
Expand Down Expand Up @@ -116,6 +117,7 @@ libupipe_modules-src = \
upipe_htons.c \
upipe_http_source.c \
upipe_idem.c \
upipe_interlace.c \
upipe_m3u_reader.c \
upipe_match_attr.c \
upipe_multicat_probe.c \
Expand Down
Loading
Loading