Skip to content

Commit 49faa16

Browse files
committed
upipe-modules: add interlacing pipe
Add upipe_interlace pipe to preform temporal field interlacing.
1 parent 62591d4 commit 49faa16

5 files changed

Lines changed: 1230 additions & 0 deletions

File tree

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* Copyright (C) 2026 EasyTools
3+
*
4+
* Authors: Arnaud de Turckheim
5+
*
6+
* SPDX-License-Identifier: MIT
7+
*/
8+
9+
/** @file
10+
* @short Upipe interlacing module
11+
*/
12+
13+
#ifndef _UPIPE_MODULES_UPIPE_INTERLACE_H_
14+
/** @hidden */
15+
#define _UPIPE_MODULES_UPIPE_INTERLACE_H_
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
#include "upipe/upipe.h"
21+
22+
#define UPIPE_INTERLACE_SIGNATURE UBASE_FOURCC('i','n','t','l')
23+
24+
/** @This extends upipe_command with specific commands for interlace pipes. */
25+
enum upipe_interlace_command {
26+
UPIPE_INTERLACE_SENTINEL = UPIPE_CONTROL_LOCAL,
27+
28+
/** set top field first output (bool) */
29+
UPIPE_INTERLACE_SET_TFF,
30+
/** get the configured value for top field first output (bool *) */
31+
UPIPE_INTERLACE_GET_TFF,
32+
/** set field drop (bool) */
33+
UPIPE_INTERLACE_SET_DROP,
34+
/** get the configured value for field drop (bool *) */
35+
UPIPE_INTERLACE_GET_DROP,
36+
};
37+
38+
/** @This converts @ref upipe_interlace_command to a string.
39+
*
40+
* @param command command to convert
41+
* @return a string or NULL if invalid
42+
*/
43+
static inline const char *upipe_interlace_command_str(int command)
44+
{
45+
switch ((enum upipe_interlace_command)command) {
46+
UBASE_CASE_TO_STR(UPIPE_INTERLACE_SET_TFF);
47+
UBASE_CASE_TO_STR(UPIPE_INTERLACE_GET_TFF);
48+
UBASE_CASE_TO_STR(UPIPE_INTERLACE_SET_DROP);
49+
UBASE_CASE_TO_STR(UPIPE_INTERLACE_GET_DROP);
50+
case UPIPE_INTERLACE_SENTINEL: break;
51+
}
52+
return NULL;
53+
}
54+
55+
/** @This sets the top field first output.
56+
*
57+
* @param upipe description structure of the pipe
58+
* @param tff true for top field first, false for bottom field first
59+
* @return an error code
60+
*/
61+
static inline int upipe_interlace_set_tff(struct upipe *upipe, bool tff)
62+
{
63+
return upipe_control(upipe, UPIPE_INTERLACE_SET_TFF,
64+
UPIPE_INTERLACE_SIGNATURE, tff ? 1 : 0);
65+
}
66+
67+
/** @This gets the top field first output configuration.
68+
*
69+
* @param upipe description structure of the pipe
70+
* @param tff filled with the configured value
71+
* @return an error code
72+
*/
73+
static inline int upipe_interlace_get_tff(struct upipe *upipe, bool *tff)
74+
{
75+
return upipe_control(upipe, UPIPE_INTERLACE_GET_TFF,
76+
UPIPE_INTERLACE_SIGNATURE, tff);
77+
}
78+
79+
/** @This sets field drop.
80+
*
81+
* If set to true, two frames are merged into one, keeping one field
82+
* of each, so the output frame rate will be divided by two.
83+
*
84+
* 1111 2222 3333 4444 -> 1111 3333
85+
* 1111 2222 3333 4444 2222 4444
86+
* 1111 2222 3333 4444 1111 3333
87+
* 1111 2222 3333 4444 2222 4444
88+
*
89+
* If set to false, each frame is merged with the previous and the
90+
* next so the output frame rate is unchanged.
91+
*
92+
* 1111 2222 3333 4444 -> 1111 2222 3333 4444
93+
* 1111 2222 3333 4444 2222 3333 4444 5555
94+
* 1111 2222 3333 4444 1111 2222 3333 4444
95+
* 1111 2222 3333 4444 2222 3333 4444 5555
96+
*
97+
* @param upipe description structure of the pipe
98+
* @param drop true for dropping field
99+
* @return an error code
100+
*/
101+
static inline int upipe_interlace_set_drop(struct upipe *upipe, bool drop)
102+
{
103+
return upipe_control(upipe, UPIPE_INTERLACE_SET_DROP,
104+
UPIPE_INTERLACE_SIGNATURE, drop ? 1 : 0);
105+
}
106+
107+
/** @This gets the field drop configuration.
108+
*
109+
* @param upipe description structure of the pipe
110+
* @param drop filled with the configured value
111+
* @return an error code
112+
*/
113+
static inline int upipe_interlace_get_drop(struct upipe *upipe, bool *drop)
114+
{
115+
return upipe_control(upipe, UPIPE_INTERLACE_GET_DROP,
116+
UPIPE_INTERLACE_SIGNATURE, drop);
117+
}
118+
119+
/** @This returns the management structure for all interlace pipes.
120+
*
121+
* @return pointer to manager
122+
*/
123+
struct upipe_mgr *upipe_interlace_mgr_alloc(void);
124+
125+
#ifdef __cplusplus
126+
}
127+
#endif
128+
#endif

lib/upipe-modules/Build.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ libupipe_modules-includes = \
3535
upipe_htons.h \
3636
upipe_http_source.h \
3737
upipe_idem.h \
38+
upipe_interlace.h \
3839
upipe_m3u_reader.h \
3940
upipe_match_attr.h \
4041
upipe_multicat_probe.h \
@@ -116,6 +117,7 @@ libupipe_modules-src = \
116117
upipe_htons.c \
117118
upipe_http_source.c \
118119
upipe_idem.c \
120+
upipe_interlace.c \
119121
upipe_m3u_reader.c \
120122
upipe_match_attr.c \
121123
upipe_multicat_probe.c \

0 commit comments

Comments
 (0)