Skip to content
Draft
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 = ubase_check(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 = ubase_check(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
33 changes: 33 additions & 0 deletions include/upipe-modules/upipe_interlace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 returns the management structure for all interlace pipes.
*
* @return pointer to manager
*/
struct upipe_mgr *upipe_interlace_mgr_alloc(void);

#ifdef __cplusplus
}
#endif
#endif
25 changes: 25 additions & 0 deletions include/upipe/uref_attr.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 @@ -1016,6 +1017,18 @@ 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 an error code \
*/ \
static inline int uref_##group##_check_##attr(struct uref *uref) \
{ \
bool v = false; \
int ret = uref_##group##_get_##attr(uref, &v); \
return ubase_check(ret) ? \
(v == true ? UBASE_ERR_NONE : UBASE_ERR_INVALID) : ret; \
} \
/** @This sets the desc attribute of a uref. \
* \
* @param uref pointer to the uref \
Expand Down Expand Up @@ -1083,6 +1096,18 @@ 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 an error code \
*/ \
static inline int uref_##group##_check_##attr(struct uref *uref) \
{ \
bool v = false; \
int ret = uref_##group##_get_##attr(uref, &v); \
return ubase_check(ret) ? \
(v == true ? UBASE_ERR_NONE : UBASE_ERR_INVALID) : ret; \
} \
/** @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 = !ubase_check(uref_pic_check_progressive(uref));
frame->top_field_first = ubase_check(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 (!ubase_check(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 (ubase_check(uref_pic_check_tff(uref)))
frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
else
frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
Expand Down
8 changes: 4 additions & 4 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 @@ -1352,9 +1352,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))
UBASE_FATAL(upipe, uref_pic_set_progressive(uref, true))
else if (top_field_first)
UBASE_FATAL(upipe, uref_pic_set_tff(uref))
UBASE_FATAL(upipe, uref_pic_set_tff(uref, true))

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 (!ubase_check(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 (ubase_check(uref_pic_check_tff(flow_def)))
context->field_order = AV_FIELD_TT;
else
context->field_order = AV_FIELD_BB;
Expand Down
10 changes: 5 additions & 5 deletions lib/upipe-av/upipe_avfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static int build_video_flow_def(struct uref *flow_def,
#endif

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

Expand Down Expand Up @@ -578,9 +578,9 @@ upipe_avfilt_sub_frame_to_uref(struct upipe *upipe, AVFrame *frame)
#endif

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

if (key_frame)
UBASE_ERROR(upipe, uref_pic_set_key(uref))
Expand Down Expand Up @@ -1993,9 +1993,9 @@ static void upipe_avfilt_output_frame(struct upipe *upipe,
#endif

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

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 @@ -1223,7 +1223,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 = !ubase_check(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
8 changes: 4 additions & 4 deletions lib/upipe-blackmagic/upipe_blackmagic_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,15 @@ static int upipe_bmd_src_build_video(struct upipe *upipe,
case bmdUnknownFieldDominance:
/* sensible defaults */
case bmdUpperFieldFirst:
UBASE_RETURN(uref_pic_set_tff(flow_def));
UBASE_RETURN(uref_pic_set_tff(flow_def, true));
uref_pic_delete_progressive(flow_def);
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 @@ -529,9 +529,9 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(
uref_clock_set_duration(uref, FrameDuration);

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

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 @@ -248,7 +248,7 @@ static bool upipe_audiobar_handle(struct upipe *upipe, struct uref *uref,
UBASE_FATAL(upipe, uref_pic_flow_add_plane(uref, 2, 1, 1, "u8"))
UBASE_FATAL(upipe, uref_pic_flow_add_plane(uref, 2, 1, 1, "v8"))
UBASE_FATAL(upipe, uref_pic_flow_add_plane(uref, 1, 1, 1, "a8"))
UBASE_FATAL(upipe, uref_pic_set_progressive(uref))
UBASE_FATAL(upipe, uref_pic_set_progressive(uref, true))

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));
!ubase_check(uref_pic_check_progressive(flow_def)) &&
ubase_check(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
8 changes: 4 additions & 4 deletions lib/upipe-framers/upipe_h264_framer.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ static bool upipe_h264f_activate_sps(struct upipe *upipe, uint32_t sps_id)
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))
UBASE_FATAL(upipe, uref_pic_set_progressive(flow_def, true))
vsize = map_height * 16;
}
ubuf_block_stream_skip_bits(s, 1); /* direct8x8_inference */
Expand Down Expand Up @@ -1841,7 +1841,7 @@ 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:
Expand All @@ -1853,7 +1853,7 @@ static int upipe_h264f_prepare_au(struct upipe *upipe, struct uref *uref)
case H264SEI_STRUCT_TOP_BOT:
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:
Expand All @@ -1864,7 +1864,7 @@ static int upipe_h264f_prepare_au(struct upipe *upipe, struct uref *uref)
case H264SEI_STRUCT_TOP_BOT_TOP:
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:
Expand Down
8 changes: 4 additions & 4 deletions lib/upipe-framers/upipe_h265_framer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ static bool upipe_h265f_activate_sps(struct upipe *upipe, uint32_t sps_id)
if (field_seq_flag)
frame_rate.den *= 2;
else
uref_pic_set_progressive(flow_def);
uref_pic_set_progressive(flow_def, true);

urational_simplify(&frame_rate);
UBASE_FATAL(upipe, uref_pic_flow_set_fps(flow_def, frame_rate))
Expand Down Expand Up @@ -2082,7 +2082,7 @@ static int upipe_h265f_prepare_au(struct upipe *upipe, struct uref *uref)

switch (upipe_h265f->pic_struct) {
case H265SEI_STRUCT_FRAME:
UBASE_FATAL(upipe, uref_pic_set_progressive(uref))
UBASE_FATAL(upipe, uref_pic_set_progressive(uref, true))
duration *= 2;
break;
case H265SEI_STRUCT_TOP:
Expand All @@ -2098,7 +2098,7 @@ static int upipe_h265f_prepare_au(struct upipe *upipe, struct uref *uref)
case H265SEI_STRUCT_TOP_BOT:
UBASE_FATAL(upipe, uref_pic_set_tf(uref))
UBASE_FATAL(upipe, uref_pic_set_bf(uref))
UBASE_FATAL(upipe, uref_pic_set_tff(uref))
UBASE_FATAL(upipe, uref_pic_set_tff(uref, true))
duration *= 2;
break;
case H265SEI_STRUCT_BOT_TOP:
Expand All @@ -2109,7 +2109,7 @@ static int upipe_h265f_prepare_au(struct upipe *upipe, struct uref *uref)
case H265SEI_STRUCT_TOP_BOT_TOP:
UBASE_FATAL(upipe, uref_pic_set_tf(uref))
UBASE_FATAL(upipe, uref_pic_set_bf(uref))
UBASE_FATAL(upipe, uref_pic_set_tff(uref))
UBASE_FATAL(upipe, uref_pic_set_tff(uref, true))
duration *= 3;
break;
case H265SEI_STRUCT_BOT_TOP_BOT:
Expand Down
Loading
Loading