Skip to content

Commit b2461b6

Browse files
committed
Make progressive and tff attribute a boolean
1 parent cfd0ebe commit b2461b6

31 files changed

+94
-67
lines changed

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
@@ -170,7 +170,7 @@ static int avcdec_catch(struct uprobe *uprobe, struct upipe *upipe,
170170
return UBASE_ERR_UNHANDLED;
171171
}
172172
wanted_hsize = (hsize * sar.num / sar.den / 2) * 2;
173-
progressive = ubase_check(uref_pic_get_progressive(flow_def));
173+
progressive = ubase_check(uref_pic_check_progressive(flow_def));
174174

175175
/* supported format of the jpeg encoder */
176176
const struct uref_pic_flow_format *supported_formats[] = {
@@ -190,7 +190,7 @@ static int avcdec_catch(struct uprobe *uprobe, struct upipe *upipe,
190190
struct uref *flow_def2 = uref_dup(flow_def);
191191
upipe_use(upipe);
192192

193-
uref_pic_set_progressive(flow_def2);
193+
uref_pic_set_progressive(flow_def2, true);
194194
uref_pic_flow_set_hsize(flow_def2, wanted_hsize);
195195
if (!supported)
196196
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
*
@@ -1033,6 +1034,18 @@ static inline int uref_##group##_get_##attr(struct uref *uref, bool *p) \
10331034
{ \
10341035
return uref_attr_get_bool(uref, p, UDICT_TYPE_BOOL, name); \
10351036
} \
1037+
/** @This checks if the desc attribute of a uref is set and true. \
1038+
* \
1039+
* @param uref pointer to the uref \
1040+
* @return an error code \
1041+
*/ \
1042+
static inline int uref_##group##_check_##attr(struct uref *uref) \
1043+
{ \
1044+
bool v = false; \
1045+
int ret = uref_##group##_get_##attr(uref, &v); \
1046+
return ubase_check(ret) ? \
1047+
(v == true ? UBASE_ERR_NONE : UBASE_ERR_INVALID) : ret; \
1048+
} \
10361049
/** @This sets the desc attribute of a uref. \
10371050
* \
10381051
* @param uref pointer to the uref \
@@ -1100,6 +1113,18 @@ static inline int uref_##group##_get_##attr(struct uref *uref, bool *p) \
11001113
{ \
11011114
return uref_attr_get_bool(uref, p, type, NULL); \
11021115
} \
1116+
/** @This checks if the desc attribute of a uref is set and true. \
1117+
* \
1118+
* @param uref pointer to the uref \
1119+
* @return an error code \
1120+
*/ \
1121+
static inline int uref_##group##_check_##attr(struct uref *uref) \
1122+
{ \
1123+
bool v = false; \
1124+
int ret = uref_##group##_get_##attr(uref, &v); \
1125+
return ubase_check(ret) ? \
1126+
(v == true ? UBASE_ERR_NONE : UBASE_ERR_INVALID) : ret; \
1127+
} \
11031128
/** @This sets the desc attribute of a uref. \
11041129
* \
11051130
* @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
*
@@ -51,10 +52,10 @@ UREF_ATTR_UNSIGNED_SH(pic, lpadding, UDICT_TYPE_PIC_LPADDING, left padding)
5152
UREF_ATTR_UNSIGNED_SH(pic, rpadding, UDICT_TYPE_PIC_RPADDING, right padding)
5253
UREF_ATTR_UNSIGNED_SH(pic, tpadding, UDICT_TYPE_PIC_TPADDING, top padding)
5354
UREF_ATTR_UNSIGNED_SH(pic, bpadding, UDICT_TYPE_PIC_BPADDING, bottom padding)
54-
UREF_ATTR_VOID_SH(pic, progressive, UDICT_TYPE_PIC_PROGRESSIVE, progressive)
55+
UREF_ATTR_BOOL_SH(pic, progressive, UDICT_TYPE_PIC_PROGRESSIVE, progressive)
5556
UREF_ATTR_VOID_SH(pic, tf, UDICT_TYPE_PIC_TF, top field present)
5657
UREF_ATTR_VOID_SH(pic, bf, UDICT_TYPE_PIC_BF, bottom field present)
57-
UREF_ATTR_VOID_SH(pic, tff, UDICT_TYPE_PIC_TFF, top field first)
58+
UREF_ATTR_BOOL_SH(pic, tff, UDICT_TYPE_PIC_TFF, top field first)
5859
UREF_ATTR_SMALL_UNSIGNED_SH(pic, afd, UDICT_TYPE_PIC_AFD, active format description)
5960
UREF_ATTR_OPAQUE_SH(pic, cea_708, UDICT_TYPE_PIC_CEA_708, cea-708 captions)
6061
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
@@ -139,18 +139,18 @@ int upipe_av_set_frame_properties(struct upipe *upipe,
139139
{
140140
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58, 7, 100)
141141
frame->key_frame = ubase_check(uref_pic_get_key(uref));
142-
frame->interlaced_frame = !ubase_check(uref_pic_get_progressive(uref));
143-
frame->top_field_first = ubase_check(uref_pic_get_tff(uref));
142+
frame->interlaced_frame = !ubase_check(uref_pic_check_progressive(uref));
143+
frame->top_field_first = ubase_check(uref_pic_check_tff(uref));
144144
#else
145145
if (ubase_check(uref_pic_get_key(uref)))
146146
frame->flags |= AV_FRAME_FLAG_KEY;
147147
else
148148
frame->flags &= ~AV_FRAME_FLAG_KEY;
149-
if (!ubase_check(uref_pic_get_progressive(uref)))
149+
if (!ubase_check(uref_pic_check_progressive(uref)))
150150
frame->flags |= AV_FRAME_FLAG_INTERLACED;
151151
else
152152
frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
153-
if (ubase_check(uref_pic_get_tff(uref)))
153+
if (ubase_check(uref_pic_check_tff(uref)))
154154
frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
155155
else
156156
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
@@ -1127,7 +1127,7 @@ static void upipe_avcdec_output_sub(struct upipe *upipe, AVSubtitle *sub,
11271127
!ubase_check(uref_pic_flow_set_bgra(flow_def_attr)) ||
11281128
#endif
11291129
!ubase_check(uref_flow_set_def(flow_def_attr, UREF_PIC_SUB_FLOW_DEF)) ||
1130-
!ubase_check(uref_pic_set_progressive(flow_def_attr)) ||
1130+
!ubase_check(uref_pic_set_progressive(flow_def_attr, true)) ||
11311131
!ubase_check(uref_pic_flow_set_full_range(flow_def_attr))))
11321132
{
11331133
uref_free(flow_def_attr);
@@ -1208,7 +1208,7 @@ static void upipe_avcdec_output_sub(struct upipe *upipe, AVSubtitle *sub,
12081208
return;
12091209
}
12101210

1211-
uref_pic_set_progressive(uref);
1211+
uref_pic_set_progressive(uref, true);
12121212
ubuf_pic_clear(ubuf, 0, 0, -1, -1, 1);
12131213

12141214
uref_attach_ubuf(uref, ubuf);
@@ -1369,9 +1369,9 @@ static void upipe_avcdec_output_pic(struct upipe *upipe, struct upump **upump_p)
13691369
UBASE_FATAL(upipe, uref_pic_set_tf(uref))
13701370
UBASE_FATAL(upipe, uref_pic_set_bf(uref))
13711371
if (!interlaced_frame)
1372-
UBASE_FATAL(upipe, uref_pic_set_progressive(uref))
1372+
UBASE_FATAL(upipe, uref_pic_set_progressive(uref, true))
13731373
else if (top_field_first)
1374-
UBASE_FATAL(upipe, uref_pic_set_tff(uref))
1374+
UBASE_FATAL(upipe, uref_pic_set_tff(uref, true))
13751375

13761376
uint64_t duration = 0;
13771377
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
@@ -1555,10 +1555,10 @@ static int upipe_avcenc_set_flow_def(struct upipe *upipe, struct uref *flow_def)
15551555
uref_pic_flow_get_matrix_coefficients_val(flow_def, &val)))
15561556
context->colorspace = val;
15571557

1558-
if (!ubase_check(uref_pic_get_progressive(flow_def))) {
1558+
if (!ubase_check(uref_pic_check_progressive(flow_def))) {
15591559
context->flags |= AV_CODEC_FLAG_INTERLACED_DCT |
15601560
AV_CODEC_FLAG_INTERLACED_ME;
1561-
if (ubase_check(uref_pic_get_tff(flow_def)))
1561+
if (ubase_check(uref_pic_check_tff(flow_def)))
15621562
context->field_order = AV_FIELD_TT;
15631563
else
15641564
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
@@ -327,7 +327,7 @@ static int build_video_flow_def(struct uref *flow_def,
327327
#endif
328328

329329
if (!interlaced_frame)
330-
UBASE_RETURN(uref_pic_set_progressive(flow_def))
330+
UBASE_RETURN(uref_pic_set_progressive(flow_def, true))
331331
if (color_range == AVCOL_RANGE_JPEG)
332332
UBASE_RETURN(uref_pic_flow_set_full_range(flow_def))
333333

@@ -595,9 +595,9 @@ upipe_avfilt_sub_frame_to_uref(struct upipe *upipe, AVFrame *frame)
595595
#endif
596596

597597
if (!interlaced_frame)
598-
UBASE_ERROR(upipe, uref_pic_set_progressive(uref))
598+
UBASE_ERROR(upipe, uref_pic_set_progressive(uref, true))
599599
else if (top_field_first)
600-
UBASE_ERROR(upipe, uref_pic_set_tff(uref))
600+
UBASE_ERROR(upipe, uref_pic_set_tff(uref, true))
601601

602602
if (key_frame)
603603
UBASE_ERROR(upipe, uref_pic_set_key(uref))
@@ -2010,9 +2010,9 @@ static void upipe_avfilt_output_frame(struct upipe *upipe,
20102010
#endif
20112011

20122012
if (!interlaced_frame)
2013-
UBASE_ERROR(upipe, uref_pic_set_progressive(uref))
2013+
UBASE_ERROR(upipe, uref_pic_set_progressive(uref, true))
20142014
else if (top_field_first)
2015-
UBASE_ERROR(upipe, uref_pic_set_tff(uref))
2015+
UBASE_ERROR(upipe, uref_pic_set_tff(uref, true))
20162016

20172017
if (key_frame)
20182018
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
@@ -1235,7 +1235,7 @@ uint32_t upipe_bmd_mode_from_flow_def(struct upipe *upipe, struct uref *flow_def
12351235
return bmdModeUnknown;
12361236
}
12371237

1238-
bool interlaced = !ubase_check(uref_pic_get_progressive(flow_def));
1238+
bool interlaced = !ubase_check(uref_pic_check_progressive(flow_def));
12391239

12401240
upipe_notice_va(upipe, "%" PRIu64"x%" PRIu64" %" PRId64"/%" PRIu64" interlaced %d",
12411241
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
@@ -372,15 +372,15 @@ static int upipe_bmd_src_build_video(struct upipe *upipe,
372372
case bmdUnknownFieldDominance:
373373
/* sensible defaults */
374374
case bmdUpperFieldFirst:
375-
UBASE_RETURN(uref_pic_set_tff(flow_def));
375+
UBASE_RETURN(uref_pic_set_tff(flow_def, true));
376376
uref_pic_delete_progressive(flow_def);
377377
upipe_bmd_src->tff = true;
378378
upipe_bmd_src->progressive = false;
379379
break;
380380
case bmdProgressiveFrame:
381381
case bmdProgressiveSegmentedFrame:
382382
uref_pic_delete_tff(flow_def);
383-
UBASE_RETURN(uref_pic_set_progressive(flow_def));
383+
UBASE_RETURN(uref_pic_set_progressive(flow_def, true));
384384
upipe_bmd_src->tff = false;
385385
upipe_bmd_src->progressive = true;
386386
break;
@@ -541,9 +541,9 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(
541541
uref_clock_set_duration(uref, FrameDuration);
542542

543543
if (upipe_bmd_src->progressive)
544-
uref_pic_set_progressive(uref);
544+
uref_pic_set_progressive(uref, true);
545545
else if (upipe_bmd_src->tff)
546-
uref_pic_set_tff(uref);
546+
uref_pic_set_tff(uref, true);
547547

548548
if (!uqueue_push(&upipe_bmd_src->uqueue, uref))
549549
uref_free(uref);

0 commit comments

Comments
 (0)