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
4 changes: 2 additions & 2 deletions doc/tutorials.mkdoc
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ static int avcdec_catch(struct uprobe *uprobe, struct upipe *upipe,
return UBASE_ERR_UNHANDLED;
}
wanted_hsize = (hsize * sar.num / sar.den / 2) * 2;
progressive = ubase_check(uref_pic_get_progressive(flow_def));
progressive = uref_pic_check_progressive(flow_def);

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

if (!progressive) {
uref_pic_set_progressive(flow_def2);
uref_pic_set_progressive(flow_def2, true);
struct upipe *deint = upipe_void_alloc_output(upipe,
upipe_filter_blend_mgr,
uprobe_pfx_alloc(uprobe_use(logger),
Expand Down
4 changes: 2 additions & 2 deletions examples/extract_pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static int avcdec_catch(struct uprobe *uprobe, struct upipe *upipe,
return UBASE_ERR_UNHANDLED;
}
wanted_hsize = (hsize * sar.num / sar.den / 2) * 2;
progressive = ubase_check(uref_pic_get_progressive(flow_def));
progressive = uref_pic_check_progressive(flow_def);

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

uref_pic_set_progressive(flow_def2);
uref_pic_set_progressive(flow_def2, true);
uref_pic_flow_set_hsize(flow_def2, wanted_hsize);
if (!supported)
uref_pic_flow_set_format(flow_def2,
Expand Down
22 changes: 22 additions & 0 deletions include/upipe/uref_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,17 @@ static inline int uref_##group##_get_##attr(struct uref *uref, bool *p) \
{ \
return uref_attr_get_bool(uref, p, UDICT_TYPE_BOOL, name); \
} \
/** @This checks if the desc attribute of a uref is set and true. \
* \
* @param uref pointer to the uref \
* @return true is the attribute is set and true \
*/ \
static inline bool uref_##group##_check_##attr(struct uref *uref) \
{ \
bool v = false; \
int ret = uref_##group##_get_##attr(uref, &v); \
return ubase_check(ret) && v == true; \
} \
/** @This sets the desc attribute of a uref. \
* \
* @param uref pointer to the uref \
Expand Down Expand Up @@ -1084,6 +1095,17 @@ static inline int uref_##group##_get_##attr(struct uref *uref, bool *p) \
{ \
return uref_attr_get_bool(uref, p, type, NULL); \
} \
/** @This checks if the desc attribute of a uref is set and true. \
* \
* @param uref pointer to the uref \
* @return true is the attribute is set and true \
*/ \
static inline bool uref_##group##_check_##attr(struct uref *uref) \
{ \
bool v = false; \
int ret = uref_##group##_get_##attr(uref, &v); \
return ubase_check(ret) && v == true; \
} \
/** @This sets the desc attribute of a uref. \
* \
* @param uref pointer to the uref \
Expand Down
5 changes: 3 additions & 2 deletions include/upipe/uref_pic.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012-2016 OpenHeadend S.A.R.L.
* Copyright (C) 2026 EasyTools
*
* Authors: Christophe Massiot
*
Expand Down Expand Up @@ -34,10 +35,10 @@ UREF_ATTR_UNSIGNED_SH(pic, lpadding, UDICT_TYPE_PIC_LPADDING, left padding)
UREF_ATTR_UNSIGNED_SH(pic, rpadding, UDICT_TYPE_PIC_RPADDING, right padding)
UREF_ATTR_UNSIGNED_SH(pic, tpadding, UDICT_TYPE_PIC_TPADDING, top padding)
UREF_ATTR_UNSIGNED_SH(pic, bpadding, UDICT_TYPE_PIC_BPADDING, bottom padding)
UREF_ATTR_VOID_SH(pic, progressive, UDICT_TYPE_PIC_PROGRESSIVE, progressive)
UREF_ATTR_BOOL_SH(pic, progressive, UDICT_TYPE_PIC_PROGRESSIVE, progressive)
UREF_ATTR_VOID_SH(pic, tf, UDICT_TYPE_PIC_TF, top field present)
UREF_ATTR_VOID_SH(pic, bf, UDICT_TYPE_PIC_BF, bottom field present)
UREF_ATTR_VOID_SH(pic, tff, UDICT_TYPE_PIC_TFF, top field first)
UREF_ATTR_BOOL_SH(pic, tff, UDICT_TYPE_PIC_TFF, top field first)
UREF_ATTR_SMALL_UNSIGNED_SH(pic, afd, UDICT_TYPE_PIC_AFD, active format description)
UREF_ATTR_OPAQUE_SH(pic, cea_708, UDICT_TYPE_PIC_CEA_708, cea-708 captions)
UREF_ATTR_OPAQUE_SH(pic, bar_data, UDICT_TYPE_PIC_BAR_DATA, afd bar data)
Expand Down
8 changes: 4 additions & 4 deletions lib/upipe-av/upipe_av.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ int upipe_av_set_frame_properties(struct upipe *upipe,
{
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58, 7, 100)
frame->key_frame = ubase_check(uref_pic_get_key(uref));
frame->interlaced_frame = !ubase_check(uref_pic_get_progressive(uref));
frame->top_field_first = ubase_check(uref_pic_get_tff(uref));
frame->interlaced_frame = !uref_pic_check_progressive(uref);
frame->top_field_first = uref_pic_check_tff(uref);
#else
if (ubase_check(uref_pic_get_key(uref)))
frame->flags |= AV_FRAME_FLAG_KEY;
else
frame->flags &= ~AV_FRAME_FLAG_KEY;
if (!ubase_check(uref_pic_get_progressive(uref)))
if (!uref_pic_check_progressive(uref))
frame->flags |= AV_FRAME_FLAG_INTERLACED;
else
frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
if (ubase_check(uref_pic_get_tff(uref)))
if (uref_pic_check_tff(uref))
frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
else
frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
Expand Down
11 changes: 5 additions & 6 deletions lib/upipe-av/upipe_avcodec_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ static void upipe_avcdec_output_sub(struct upipe *upipe, AVSubtitle *sub,
!ubase_check(uref_pic_flow_set_bgra(flow_def_attr)) ||
#endif
!ubase_check(uref_flow_set_def(flow_def_attr, UREF_PIC_SUB_FLOW_DEF)) ||
!ubase_check(uref_pic_set_progressive(flow_def_attr)) ||
!ubase_check(uref_pic_set_progressive(flow_def_attr, true)) ||
!ubase_check(uref_pic_flow_set_full_range(flow_def_attr))))
{
uref_free(flow_def_attr);
Expand Down Expand Up @@ -1191,7 +1191,7 @@ static void upipe_avcdec_output_sub(struct upipe *upipe, AVSubtitle *sub,
return;
}

uref_pic_set_progressive(uref);
uref_pic_set_progressive(uref, true);
ubuf_pic_clear(ubuf, 0, 0, -1, -1, 1);

uref_attach_ubuf(uref, ubuf);
Expand Down Expand Up @@ -1351,10 +1351,9 @@ static void upipe_avcdec_output_pic(struct upipe *upipe, struct upump **upump_p)

UBASE_FATAL(upipe, uref_pic_set_tf(uref))
UBASE_FATAL(upipe, uref_pic_set_bf(uref))
if (!interlaced_frame)
UBASE_FATAL(upipe, uref_pic_set_progressive(uref))
else if (top_field_first)
UBASE_FATAL(upipe, uref_pic_set_tff(uref))
UBASE_FATAL(upipe, uref_pic_set_progressive(uref, !interlaced_frame))
if (interlaced_frame)
UBASE_FATAL(upipe, uref_pic_set_tff(uref, top_field_first))

uint64_t duration = 0;
AVRational uclock_time_base = av_make_q(1, UCLOCK_FREQ);
Expand Down
4 changes: 2 additions & 2 deletions lib/upipe-av/upipe_avcodec_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,10 +1538,10 @@ static int upipe_avcenc_set_flow_def(struct upipe *upipe, struct uref *flow_def)
uref_pic_flow_get_matrix_coefficients_val(flow_def, &val)))
context->colorspace = val;

if (!ubase_check(uref_pic_get_progressive(flow_def))) {
if (!uref_pic_check_progressive(flow_def)) {
context->flags |= AV_CODEC_FLAG_INTERLACED_DCT |
AV_CODEC_FLAG_INTERLACED_ME;
if (ubase_check(uref_pic_get_tff(flow_def)))
if (uref_pic_check_tff(flow_def))
context->field_order = AV_FIELD_TT;
else
context->field_order = AV_FIELD_BB;
Expand Down
18 changes: 8 additions & 10 deletions lib/upipe-av/upipe_avfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,7 @@ static int build_video_flow_def(struct uref *flow_def,
bool interlaced_frame = frame->flags & AV_FRAME_FLAG_INTERLACED;
#endif

if (!interlaced_frame)
UBASE_RETURN(uref_pic_set_progressive(flow_def))
UBASE_RETURN(uref_pic_set_progressive(flow_def, !interlaced_frame))
if (color_range == AVCOL_RANGE_JPEG)
UBASE_RETURN(uref_pic_flow_set_full_range(flow_def))

Expand Down Expand Up @@ -577,10 +576,9 @@ upipe_avfilt_sub_frame_to_uref(struct upipe *upipe, AVFrame *frame)
bool top_field_first = frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST;
#endif

if (!interlaced_frame)
UBASE_ERROR(upipe, uref_pic_set_progressive(uref))
else if (top_field_first)
UBASE_ERROR(upipe, uref_pic_set_tff(uref))
UBASE_ERROR(upipe, uref_pic_set_progressive(uref, !interlaced_frame));
if (interlaced_frame)
UBASE_ERROR(upipe, uref_pic_set_tff(uref, top_field_first))

if (key_frame)
UBASE_ERROR(upipe, uref_pic_set_key(uref))
Expand Down Expand Up @@ -1992,10 +1990,10 @@ static void upipe_avfilt_output_frame(struct upipe *upipe,
bool top_field_first = frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST;
#endif

if (!interlaced_frame)
UBASE_ERROR(upipe, uref_pic_set_progressive(uref))
else if (top_field_first)
UBASE_ERROR(upipe, uref_pic_set_tff(uref))
UBASE_ERROR(upipe,
uref_pic_set_progressive(uref, !interlaced_frame))
if (interlaced_frame)
UBASE_ERROR(upipe, uref_pic_set_tff(uref, top_field_first))

if (key_frame)
UBASE_ERROR(upipe, uref_pic_set_key(uref))
Expand Down
2 changes: 1 addition & 1 deletion lib/upipe-blackmagic/upipe_blackmagic_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ uint32_t upipe_bmd_mode_from_flow_def(struct upipe *upipe, struct uref *flow_def
return bmdModeUnknown;
}

bool interlaced = !ubase_check(uref_pic_get_progressive(flow_def));
bool interlaced = !uref_pic_check_progressive(flow_def);

upipe_notice_va(upipe, "%" PRIu64"x%" PRIu64" %" PRId64"/%" PRIu64" interlaced %d",
hsize, vsize, fps.num, fps.den, interlaced);
Expand Down
17 changes: 8 additions & 9 deletions lib/upipe-blackmagic/upipe_blackmagic_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,24 +353,24 @@ static int upipe_bmd_src_build_video(struct upipe *upipe,
BMDFieldDominance field = mode->GetFieldDominance();
switch (field) {
case bmdLowerFieldFirst:
uref_pic_delete_tff(flow_def);
uref_pic_delete_progressive(flow_def);
UBASE_RETURN(uref_pic_set_tff(flow_def, false));
UBASE_RETURN(uref_pic_set_progressive(flow_def, false));
upipe_bmd_src->tff = false;
upipe_bmd_src->progressive = false;
break;
default:
case bmdUnknownFieldDominance:
/* sensible defaults */
case bmdUpperFieldFirst:
UBASE_RETURN(uref_pic_set_tff(flow_def));
uref_pic_delete_progressive(flow_def);
UBASE_RETURN(uref_pic_set_tff(flow_def, true));
UBASE_RETURN(uref_pic_set_progressive(flow_def, false));
upipe_bmd_src->tff = true;
upipe_bmd_src->progressive = false;
break;
case bmdProgressiveFrame:
case bmdProgressiveSegmentedFrame:
uref_pic_delete_tff(flow_def);
UBASE_RETURN(uref_pic_set_progressive(flow_def));
UBASE_RETURN(uref_pic_set_progressive(flow_def, true));
upipe_bmd_src->tff = false;
upipe_bmd_src->progressive = true;
break;
Expand Down Expand Up @@ -530,10 +530,9 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(
uref_clock_set_dts_pts_delay(uref, 0);
uref_clock_set_duration(uref, FrameDuration);

if (upipe_bmd_src->progressive)
uref_pic_set_progressive(uref);
else if (upipe_bmd_src->tff)
uref_pic_set_tff(uref);
uref_pic_set_progressive(uref, upipe_bmd_src->progressive);
if (!upipe_bmd_src->progressive)
uref_pic_set_tff(uref, upipe_bmd_src->tff);

if (!uqueue_push(&upipe_bmd_src->uqueue, uref))
uref_free(uref);
Expand Down
2 changes: 1 addition & 1 deletion lib/upipe-filters/upipe_audio_bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ static int upipe_audiobar_set_flow_def(struct upipe *upipe,
UBASE_FATAL(upipe, uref_pic_flow_add_plane(flow_def, 2, 1, 1, "u8"))
UBASE_FATAL(upipe, uref_pic_flow_add_plane(flow_def, 2, 1, 1, "v8"))
UBASE_FATAL(upipe, uref_pic_flow_add_plane(flow_def, 1, 1, 1, "a8"))
UBASE_FATAL(upipe, uref_pic_set_progressive(flow_def))
UBASE_FATAL(upipe, uref_pic_set_progressive(flow_def, true))
uref_dump(flow_def, upipe->uprobe);
upipe_audiobar->hsize = upipe_audiobar->vsize =
upipe_audiobar->sep_width = upipe_audiobar->pad_width = UINT64_MAX;
Expand Down
4 changes: 2 additions & 2 deletions lib/upipe-filters/upipe_audio_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static bool upipe_agraph_handle(struct upipe *upipe, struct uref *uref,
uref_attr_import(uref, upipe_agraph->flow_def_config))
uref_pic_flow_clear_format(uref);
UBASE_FATAL(upipe, uref_pic_flow_set_yuv420p(uref));
UBASE_FATAL(upipe, uref_pic_set_progressive(uref))
UBASE_FATAL(upipe, uref_pic_set_progressive(uref, true))

upipe_agraph->hsize = upipe_agraph->vsize =
upipe_agraph->sep_width = upipe_agraph->pad_width = UINT64_MAX;
Expand Down Expand Up @@ -371,7 +371,7 @@ static bool upipe_agraph_handle(struct upipe *upipe, struct uref *uref,
if (dst[i])
ubuf_pic_plane_unmap(ubuf, chroma[i], 0, 0, -1, -1);

uref_pic_set_progressive(uref);
uref_pic_set_progressive(uref, true);
upipe_agraph_output(upipe, uref, upump_p);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/upipe-filters/upipe_filter_blend.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static bool upipe_filter_blend_handle(struct upipe *upipe, struct uref *uref,

// Attach new ubuf and output frame
uref_attach_ubuf(uref, ubuf_deint);
uref_pic_set_progressive(uref);
uref_pic_set_progressive(uref, true);
uref_pic_delete_tff(uref);

upipe_filter_blend_output(upipe, uref, upump_p);
Expand Down Expand Up @@ -327,7 +327,7 @@ static int upipe_filter_blend_set_flow_def(struct upipe *upipe,
upipe_throw_fatal(upipe, UBASE_ERR_ALLOC);
return UBASE_ERR_ALLOC;
}
UBASE_RETURN(uref_pic_set_progressive(flow_def_dup))
UBASE_RETURN(uref_pic_set_progressive(flow_def_dup, true))
upipe_input(upipe, flow_def_dup, NULL);
return UBASE_ERR_NONE;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/upipe-filters/upipe_filter_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ static int upipe_ffmt_check_flow_format(struct upipe *upipe,
surface_type_out = "";

bool need_deint = ffmt_mgr->deint_mgr &&
!ubase_check(uref_pic_get_progressive(flow_def)) &&
ubase_check(uref_pic_get_progressive(flow_def_dup));
!uref_pic_check_progressive(flow_def) &&
uref_pic_check_progressive(flow_def_dup);
bool need_scale =
uref_pic_flow_cmp_hsize(flow_def, flow_def_dup) ||
uref_pic_flow_cmp_vsize(flow_def, flow_def_dup);
Expand Down
21 changes: 15 additions & 6 deletions lib/upipe-framers/upipe_h264_framer.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,14 @@ static bool upipe_h264f_activate_sps(struct upipe *upipe, uint32_t sps_id)
upipe_h264f->frame_mbs_only = !!ubuf_block_stream_show_bits(s, 1);
ubuf_block_stream_skip_bits(s, 1);
uint64_t vsize;
UBASE_FATAL(upipe, uref_pic_set_progressive(flow_def,
!!upipe_h264f->frame_mbs_only))
if (!upipe_h264f->frame_mbs_only) {
vsize = map_height * 16 * 2;
ubuf_block_stream_skip_bits(s, 1); /* mb_adaptive_frame_field */
} else {
UBASE_FATAL(upipe, uref_pic_set_progressive(flow_def))
vsize = map_height * 16;
}
else
vsize = map_height * 16;
ubuf_block_stream_skip_bits(s, 1); /* direct8x8_inference */

bool frame_cropping = !!ubuf_block_stream_show_bits(s, 1);
Expand Down Expand Up @@ -1841,35 +1842,43 @@ static int upipe_h264f_prepare_au(struct upipe *upipe, struct uref *uref)

switch (upipe_h264f->pic_struct) {
case H264SEI_STRUCT_FRAME:
UBASE_RETURN(uref_pic_set_progressive(uref))
UBASE_RETURN(uref_pic_set_progressive(uref, true))
duration *= 2;
break;
case H264SEI_STRUCT_TOP:
UBASE_RETURN(uref_pic_set_progressive(uref, false))
UBASE_RETURN(uref_pic_set_tf(uref))
break;
case H264SEI_STRUCT_BOT:
UBASE_RETURN(uref_pic_set_progressive(uref, false))
UBASE_RETURN(uref_pic_set_bf(uref))
break;
case H264SEI_STRUCT_TOP_BOT:
UBASE_RETURN(uref_pic_set_progressive(uref, false))
UBASE_RETURN(uref_pic_set_tf(uref))
UBASE_RETURN(uref_pic_set_bf(uref))
UBASE_RETURN(uref_pic_set_tff(uref))
UBASE_RETURN(uref_pic_set_tff(uref, true))
duration *= 2;
break;
case H264SEI_STRUCT_BOT_TOP:
UBASE_RETURN(uref_pic_set_progressive(uref, false))
UBASE_RETURN(uref_pic_set_tf(uref))
UBASE_RETURN(uref_pic_set_bf(uref))
UBASE_RETURN(uref_pic_set_tff(uref, false))
duration *= 2;
break;
case H264SEI_STRUCT_TOP_BOT_TOP:
UBASE_RETURN(uref_pic_set_progressive(uref, false))
UBASE_RETURN(uref_pic_set_tf(uref))
UBASE_RETURN(uref_pic_set_bf(uref))
UBASE_RETURN(uref_pic_set_tff(uref))
UBASE_RETURN(uref_pic_set_tff(uref, true))
duration *= 3;
break;
case H264SEI_STRUCT_BOT_TOP_BOT:
UBASE_RETURN(uref_pic_set_progressive(uref, false))
UBASE_RETURN(uref_pic_set_tf(uref))
UBASE_RETURN(uref_pic_set_bf(uref))
UBASE_RETURN(uref_pic_set_tff(uref, false))
duration *= 3;
break;
case H264SEI_STRUCT_DOUBLE:
Expand Down
Loading
Loading