Skip to content

Commit b6066bf

Browse files
committed
Make progressive and tff attribute a boolean
Change uref_pic_progressive and uref_pic_tff attributes from void to boolean. With void attribute, there is no possibility to explicitly set interlaced or bottom field first on a flow definition packet.
1 parent 4798c26 commit b6066bf

31 files changed

Lines changed: 94 additions & 67 deletions

doc/tutorials.mkdoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ static int avcdec_catch(struct uprobe *uprobe, struct upipe *upipe,
154154
return UBASE_ERR_UNHANDLED;
155155
}
156156
wanted_hsize = (hsize * sar.num / sar.den / 2) * 2;
157-
progressive = ubase_check(uref_pic_get_progressive(flow_def));
157+
progressive = ubase_check(uref_pic_check_progressive(flow_def));
158158

159159
struct uref *flow_def2 = uref_dup(flow_def);
160160
upipe_use(upipe);
161161

162162
if (!progressive) {
163-
uref_pic_set_progressive(flow_def2);
163+
uref_pic_set_progressive(flow_def2, true);
164164
struct upipe *deint = upipe_void_alloc_output(upipe,
165165
upipe_filter_blend_mgr,
166166
uprobe_pfx_alloc(uprobe_use(logger),

examples/extract_pic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int avcdec_catch(struct uprobe *uprobe, struct upipe *upipe,
153153
return UBASE_ERR_UNHANDLED;
154154
}
155155
wanted_hsize = (hsize * sar.num / sar.den / 2) * 2;
156-
progressive = ubase_check(uref_pic_get_progressive(flow_def));
156+
progressive = ubase_check(uref_pic_check_progressive(flow_def));
157157

158158
/* supported format of the jpeg encoder */
159159
const struct uref_pic_flow_format *supported_formats[] = {
@@ -173,7 +173,7 @@ static int avcdec_catch(struct uprobe *uprobe, struct upipe *upipe,
173173
struct uref *flow_def2 = uref_dup(flow_def);
174174
upipe_use(upipe);
175175

176-
uref_pic_set_progressive(flow_def2);
176+
uref_pic_set_progressive(flow_def2, true);
177177
uref_pic_flow_set_hsize(flow_def2, wanted_hsize);
178178
if (!supported)
179179
uref_pic_flow_set_format(flow_def2,

include/upipe/uref_attr.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (C) 2012-2016 OpenHeadend S.A.R.L.
3+
* Copyright (C) 2026 EasyTools
34
*
45
* Authors: Christophe Massiot
56
*
@@ -1016,6 +1017,18 @@ static inline int uref_##group##_get_##attr(struct uref *uref, bool *p) \
10161017
{ \
10171018
return uref_attr_get_bool(uref, p, UDICT_TYPE_BOOL, name); \
10181019
} \
1020+
/** @This checks if the desc attribute of a uref is set and true. \
1021+
* \
1022+
* @param uref pointer to the uref \
1023+
* @return an error code \
1024+
*/ \
1025+
static inline int uref_##group##_check_##attr(struct uref *uref) \
1026+
{ \
1027+
bool v = false; \
1028+
int ret = uref_##group##_get_##attr(uref, &v); \
1029+
return ubase_check(ret) ? \
1030+
(v == true ? UBASE_ERR_NONE : UBASE_ERR_INVALID) : ret; \
1031+
} \
10191032
/** @This sets the desc attribute of a uref. \
10201033
* \
10211034
* @param uref pointer to the uref \
@@ -1083,6 +1096,18 @@ static inline int uref_##group##_get_##attr(struct uref *uref, bool *p) \
10831096
{ \
10841097
return uref_attr_get_bool(uref, p, type, NULL); \
10851098
} \
1099+
/** @This checks if the desc attribute of a uref is set and true. \
1100+
* \
1101+
* @param uref pointer to the uref \
1102+
* @return an error code \
1103+
*/ \
1104+
static inline int uref_##group##_check_##attr(struct uref *uref) \
1105+
{ \
1106+
bool v = false; \
1107+
int ret = uref_##group##_get_##attr(uref, &v); \
1108+
return ubase_check(ret) ? \
1109+
(v == true ? UBASE_ERR_NONE : UBASE_ERR_INVALID) : ret; \
1110+
} \
10861111
/** @This sets the desc attribute of a uref. \
10871112
* \
10881113
* @param uref pointer to the uref \

include/upipe/uref_pic.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (C) 2012-2016 OpenHeadend S.A.R.L.
3+
* Copyright (C) 2026 EasyTools
34
*
45
* Authors: Christophe Massiot
56
*
@@ -34,10 +35,10 @@ UREF_ATTR_UNSIGNED_SH(pic, lpadding, UDICT_TYPE_PIC_LPADDING, left padding)
3435
UREF_ATTR_UNSIGNED_SH(pic, rpadding, UDICT_TYPE_PIC_RPADDING, right padding)
3536
UREF_ATTR_UNSIGNED_SH(pic, tpadding, UDICT_TYPE_PIC_TPADDING, top padding)
3637
UREF_ATTR_UNSIGNED_SH(pic, bpadding, UDICT_TYPE_PIC_BPADDING, bottom padding)
37-
UREF_ATTR_VOID_SH(pic, progressive, UDICT_TYPE_PIC_PROGRESSIVE, progressive)
38+
UREF_ATTR_BOOL_SH(pic, progressive, UDICT_TYPE_PIC_PROGRESSIVE, progressive)
3839
UREF_ATTR_VOID_SH(pic, tf, UDICT_TYPE_PIC_TF, top field present)
3940
UREF_ATTR_VOID_SH(pic, bf, UDICT_TYPE_PIC_BF, bottom field present)
40-
UREF_ATTR_VOID_SH(pic, tff, UDICT_TYPE_PIC_TFF, top field first)
41+
UREF_ATTR_BOOL_SH(pic, tff, UDICT_TYPE_PIC_TFF, top field first)
4142
UREF_ATTR_SMALL_UNSIGNED_SH(pic, afd, UDICT_TYPE_PIC_AFD, active format description)
4243
UREF_ATTR_OPAQUE_SH(pic, cea_708, UDICT_TYPE_PIC_CEA_708, cea-708 captions)
4344
UREF_ATTR_OPAQUE_SH(pic, bar_data, UDICT_TYPE_PIC_BAR_DATA, afd bar data)

lib/upipe-av/upipe_av.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,18 @@ int upipe_av_set_frame_properties(struct upipe *upipe,
122122
{
123123
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58, 7, 100)
124124
frame->key_frame = ubase_check(uref_pic_get_key(uref));
125-
frame->interlaced_frame = !ubase_check(uref_pic_get_progressive(uref));
126-
frame->top_field_first = ubase_check(uref_pic_get_tff(uref));
125+
frame->interlaced_frame = !ubase_check(uref_pic_check_progressive(uref));
126+
frame->top_field_first = ubase_check(uref_pic_check_tff(uref));
127127
#else
128128
if (ubase_check(uref_pic_get_key(uref)))
129129
frame->flags |= AV_FRAME_FLAG_KEY;
130130
else
131131
frame->flags &= ~AV_FRAME_FLAG_KEY;
132-
if (!ubase_check(uref_pic_get_progressive(uref)))
132+
if (!ubase_check(uref_pic_check_progressive(uref)))
133133
frame->flags |= AV_FRAME_FLAG_INTERLACED;
134134
else
135135
frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
136-
if (ubase_check(uref_pic_get_tff(uref)))
136+
if (ubase_check(uref_pic_check_tff(uref)))
137137
frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
138138
else
139139
frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;

lib/upipe-av/upipe_avcodec_decode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ static void upipe_avcdec_output_sub(struct upipe *upipe, AVSubtitle *sub,
11101110
!ubase_check(uref_pic_flow_set_bgra(flow_def_attr)) ||
11111111
#endif
11121112
!ubase_check(uref_flow_set_def(flow_def_attr, UREF_PIC_SUB_FLOW_DEF)) ||
1113-
!ubase_check(uref_pic_set_progressive(flow_def_attr)) ||
1113+
!ubase_check(uref_pic_set_progressive(flow_def_attr, true)) ||
11141114
!ubase_check(uref_pic_flow_set_full_range(flow_def_attr))))
11151115
{
11161116
uref_free(flow_def_attr);
@@ -1191,7 +1191,7 @@ static void upipe_avcdec_output_sub(struct upipe *upipe, AVSubtitle *sub,
11911191
return;
11921192
}
11931193

1194-
uref_pic_set_progressive(uref);
1194+
uref_pic_set_progressive(uref, true);
11951195
ubuf_pic_clear(ubuf, 0, 0, -1, -1, 1);
11961196

11971197
uref_attach_ubuf(uref, ubuf);
@@ -1352,9 +1352,9 @@ static void upipe_avcdec_output_pic(struct upipe *upipe, struct upump **upump_p)
13521352
UBASE_FATAL(upipe, uref_pic_set_tf(uref))
13531353
UBASE_FATAL(upipe, uref_pic_set_bf(uref))
13541354
if (!interlaced_frame)
1355-
UBASE_FATAL(upipe, uref_pic_set_progressive(uref))
1355+
UBASE_FATAL(upipe, uref_pic_set_progressive(uref, true))
13561356
else if (top_field_first)
1357-
UBASE_FATAL(upipe, uref_pic_set_tff(uref))
1357+
UBASE_FATAL(upipe, uref_pic_set_tff(uref, true))
13581358

13591359
uint64_t duration = 0;
13601360
AVRational uclock_time_base = av_make_q(1, UCLOCK_FREQ);

lib/upipe-av/upipe_avcodec_encode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,10 +1538,10 @@ static int upipe_avcenc_set_flow_def(struct upipe *upipe, struct uref *flow_def)
15381538
uref_pic_flow_get_matrix_coefficients_val(flow_def, &val)))
15391539
context->colorspace = val;
15401540

1541-
if (!ubase_check(uref_pic_get_progressive(flow_def))) {
1541+
if (!ubase_check(uref_pic_check_progressive(flow_def))) {
15421542
context->flags |= AV_CODEC_FLAG_INTERLACED_DCT |
15431543
AV_CODEC_FLAG_INTERLACED_ME;
1544-
if (ubase_check(uref_pic_get_tff(flow_def)))
1544+
if (ubase_check(uref_pic_check_tff(flow_def)))
15451545
context->field_order = AV_FIELD_TT;
15461546
else
15471547
context->field_order = AV_FIELD_BB;

lib/upipe-av/upipe_avfilter.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ static int build_video_flow_def(struct uref *flow_def,
310310
#endif
311311

312312
if (!interlaced_frame)
313-
UBASE_RETURN(uref_pic_set_progressive(flow_def))
313+
UBASE_RETURN(uref_pic_set_progressive(flow_def, true))
314314
if (color_range == AVCOL_RANGE_JPEG)
315315
UBASE_RETURN(uref_pic_flow_set_full_range(flow_def))
316316

@@ -578,9 +578,9 @@ upipe_avfilt_sub_frame_to_uref(struct upipe *upipe, AVFrame *frame)
578578
#endif
579579

580580
if (!interlaced_frame)
581-
UBASE_ERROR(upipe, uref_pic_set_progressive(uref))
581+
UBASE_ERROR(upipe, uref_pic_set_progressive(uref, true))
582582
else if (top_field_first)
583-
UBASE_ERROR(upipe, uref_pic_set_tff(uref))
583+
UBASE_ERROR(upipe, uref_pic_set_tff(uref, true))
584584

585585
if (key_frame)
586586
UBASE_ERROR(upipe, uref_pic_set_key(uref))
@@ -1993,9 +1993,9 @@ static void upipe_avfilt_output_frame(struct upipe *upipe,
19931993
#endif
19941994

19951995
if (!interlaced_frame)
1996-
UBASE_ERROR(upipe, uref_pic_set_progressive(uref))
1996+
UBASE_ERROR(upipe, uref_pic_set_progressive(uref, true))
19971997
else if (top_field_first)
1998-
UBASE_ERROR(upipe, uref_pic_set_tff(uref))
1998+
UBASE_ERROR(upipe, uref_pic_set_tff(uref, true))
19991999

20002000
if (key_frame)
20012001
UBASE_ERROR(upipe, uref_pic_set_key(uref))

lib/upipe-blackmagic/upipe_blackmagic_sink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ uint32_t upipe_bmd_mode_from_flow_def(struct upipe *upipe, struct uref *flow_def
12231223
return bmdModeUnknown;
12241224
}
12251225

1226-
bool interlaced = !ubase_check(uref_pic_get_progressive(flow_def));
1226+
bool interlaced = !ubase_check(uref_pic_check_progressive(flow_def));
12271227

12281228
upipe_notice_va(upipe, "%" PRIu64"x%" PRIu64" %" PRId64"/%" PRIu64" interlaced %d",
12291229
hsize, vsize, fps.num, fps.den, interlaced);

lib/upipe-blackmagic/upipe_blackmagic_source.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,15 +360,15 @@ static int upipe_bmd_src_build_video(struct upipe *upipe,
360360
case bmdUnknownFieldDominance:
361361
/* sensible defaults */
362362
case bmdUpperFieldFirst:
363-
UBASE_RETURN(uref_pic_set_tff(flow_def));
363+
UBASE_RETURN(uref_pic_set_tff(flow_def, true));
364364
uref_pic_delete_progressive(flow_def);
365365
upipe_bmd_src->tff = true;
366366
upipe_bmd_src->progressive = false;
367367
break;
368368
case bmdProgressiveFrame:
369369
case bmdProgressiveSegmentedFrame:
370370
uref_pic_delete_tff(flow_def);
371-
UBASE_RETURN(uref_pic_set_progressive(flow_def));
371+
UBASE_RETURN(uref_pic_set_progressive(flow_def, true));
372372
upipe_bmd_src->tff = false;
373373
upipe_bmd_src->progressive = true;
374374
break;
@@ -529,9 +529,9 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(
529529
uref_clock_set_duration(uref, FrameDuration);
530530

531531
if (upipe_bmd_src->progressive)
532-
uref_pic_set_progressive(uref);
532+
uref_pic_set_progressive(uref, true);
533533
else if (upipe_bmd_src->tff)
534-
uref_pic_set_tff(uref);
534+
uref_pic_set_tff(uref, true);
535535

536536
if (!uqueue_push(&upipe_bmd_src->uqueue, uref))
537537
uref_free(uref);

0 commit comments

Comments
 (0)