Skip to content
Merged
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
3 changes: 1 addition & 2 deletions .github/workflows/test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
rm -f /usr/local/bin/idle3*
rm -f /usr/local/bin/pydoc3*
rm -f /usr/local/bin/python3*
brew install autoconf automake libtool pkg-config nasm ffmpeg@7 \
brew install autoconf automake libtool pkg-config nasm ffmpeg \
freetype libebur128 libev libgcrypt libtasn1 speex x264 x265 luajit
BREW_PREFIX="$(brew --prefix)"
set-env HOST_CC "clang"
Expand All @@ -154,7 +154,6 @@ jobs:
set-env DISABLE_VALGRIND "1"
set-env INSERT_LIBRARIES "$(clang -print-search-dirs | sed -n 's/^libraries: =//p')/lib/darwin/libclang_rt.asan_osx_dynamic.dylib"
set-env UBSAN_OPTIONS "print_stacktrace=1"
set-env PKG_CONFIG_PATH "$BREW_PREFIX/opt/ffmpeg@7/lib/pkgconfig"

- name: Install bitstream
run: |
Expand Down
15 changes: 15 additions & 0 deletions lib/upipe-av/upipe_av.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,24 @@ int upipe_av_set_frame_properties(struct upipe *upipe,
struct uref *flow_def,
struct uref *uref)
{
#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));
#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)))
frame->flags |= AV_FRAME_FLAG_INTERLACED;
else
frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
if (ubase_check(uref_pic_get_tff(uref)))
frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
else
frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
#endif
frame->color_range = ubase_check(uref_pic_flow_get_full_range(
flow_def)) ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;

Expand Down
42 changes: 32 additions & 10 deletions lib/upipe-av/upipe_avcodec_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ static int upipe_avcdec_get_buffer_pic(struct AVCodecContext *context,
if (context->color_range == AVCOL_RANGE_JPEG)
uref_pic_flow_set_full_range(flow_def_attr);

#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58, 7, 100)
bool key_frame = frame->key_frame;
#else
bool key_frame = frame->flags & AV_FRAME_FLAG_KEY;
#endif

AVFrameSideData *sd = av_frame_get_side_data(
frame, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
if (sd) {
Expand All @@ -404,7 +410,7 @@ static int upipe_avcdec_get_buffer_pic(struct AVCodecContext *context,
flow_def_attr, clm->MaxCLL))
UBASE_FATAL(upipe, uref_pic_flow_set_max_fall(
flow_def_attr, clm->MaxFALL))
} else if (!frame->key_frame && upipe_avcdec->flow_def_format) {
} else if (!key_frame && upipe_avcdec->flow_def_format) {
uint64_t max_cll;
if (ubase_check(uref_pic_flow_get_max_cll(
upipe_avcdec->flow_def_format, &max_cll))) {
Expand Down Expand Up @@ -439,7 +445,7 @@ static int upipe_avcdec_get_buffer_pic(struct AVCodecContext *context,
.min_luminance = av_rescale_q(1, mdcv->min_luminance, luma),
.max_luminance = av_rescale_q(1, mdcv->max_luminance, luma),
}))
} else if (!frame->key_frame && upipe_avcdec->flow_def_format) {
} else if (!key_frame && upipe_avcdec->flow_def_format) {
const uint8_t *mdcv;
size_t size;
if (ubase_check(uref_pic_flow_get_mdcv(upipe_avcdec->flow_def_format,
Expand Down Expand Up @@ -766,7 +772,9 @@ static bool upipe_avcdec_do_av_deal(struct upipe *upipe)
upipe_notice_va(upipe, "codec %s (%s) %d closed", context->codec->name,
context->codec->long_name, context->codec->id);

#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 40, 100)
avcodec_close(context);
#endif
return false;
}

Expand Down Expand Up @@ -1344,11 +1352,21 @@ static void upipe_avcdec_output_pic(struct upipe *upipe, struct upump **upump_p)
upipe_throw_error(upipe, UBASE_ERR_EXTERNAL);
}

#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58, 7, 100)
bool key_frame = frame->key_frame;
bool interlaced_frame = frame->interlaced_frame;
bool top_field_first = frame->top_field_first;
#else
bool key_frame = frame->flags & AV_FRAME_FLAG_KEY;
bool interlaced_frame = frame->flags & AV_FRAME_FLAG_INTERLACED;
bool top_field_first = frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST;
#endif

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

uint64_t duration = 0;
Expand All @@ -1359,15 +1377,22 @@ static void upipe_avcdec_output_pic(struct upipe *upipe, struct upump **upump_p)
duration = av_rescale_q(1, time_base, uclock_time_base);
}

#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 15, 100)
int ticks_per_frame = context->ticks_per_frame;
#else
int ticks_per_frame = (context->codec_descriptor->props &
AV_CODEC_PROP_FIELDS) ? 2 : 1;
#endif

if (!duration && frame->time_base.den)
duration = (uint64_t)(2 + frame->repeat_pict) *
context->ticks_per_frame * UCLOCK_FREQ * frame->time_base.num /
ticks_per_frame * UCLOCK_FREQ * frame->time_base.num /
(2 * frame->time_base.den);

if (duration)
UBASE_FATAL(upipe, uref_clock_set_duration(uref, duration))

if (frame->key_frame)
if (key_frame)
uref_pic_set_key(uref);

side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_AFD);
Expand Down Expand Up @@ -1961,10 +1986,7 @@ static void upipe_avcdec_free(struct upipe *upipe)
{
struct upipe_avcdec *upipe_avcdec = upipe_avcdec_from_upipe(upipe);

if (upipe_avcdec->context != NULL) {
free(upipe_avcdec->context->extradata);
av_free(upipe_avcdec->context);
}
avcodec_free_context(&upipe_avcdec->context);
av_frame_free(&upipe_avcdec->frame);
av_packet_free(&upipe_avcdec->avpkt);
free(upipe_avcdec->hw_device);
Expand Down
5 changes: 3 additions & 2 deletions lib/upipe-av/upipe_avcodec_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ static bool upipe_avcenc_do_av_deal(struct upipe *upipe)
if (upipe_avcenc->close) {
upipe_notice_va(upipe, "codec %s (%s) %d closed", context->codec->name,
context->codec->long_name, context->codec->id);
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 40, 100)
avcodec_close(context);
#endif
return false;
}

Expand Down Expand Up @@ -1997,8 +1999,7 @@ static void upipe_avcenc_free(struct upipe *upipe)
{
struct upipe_avcenc *upipe_avcenc = upipe_avcenc_from_upipe(upipe);

if (upipe_avcenc->context != NULL)
avcodec_free_context(&upipe_avcenc->context);
avcodec_free_context(&upipe_avcenc->context);
av_frame_free(&upipe_avcenc->frame);
av_packet_free(&upipe_avcenc->avpkt);

Expand Down
40 changes: 33 additions & 7 deletions lib/upipe-av/upipe_avfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,13 @@ static int build_video_flow_def(struct uref *flow_def,
UBASE_RETURN(uref_pic_flow_set_fps(flow_def, urational(fps)))
UBASE_RETURN(uref_pic_flow_set_sar(flow_def, urational(sar)))

if (!frame->interlaced_frame)
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58, 7, 100)
bool interlaced_frame = frame->interlaced_frame;
#else
bool interlaced_frame = frame->flags & AV_FRAME_FLAG_INTERLACED;
#endif

if (!interlaced_frame)
UBASE_RETURN(uref_pic_set_progressive(flow_def))
if (color_range == AVCOL_RANGE_JPEG)
UBASE_RETURN(uref_pic_flow_set_full_range(flow_def))
Expand Down Expand Up @@ -578,12 +584,22 @@ upipe_avfilt_sub_frame_to_uref(struct upipe *upipe, AVFrame *frame)
duration = av_rescale_q(frame->pkt_duration, time_base,
av_make_q(1, UCLOCK_FREQ));

if (!frame->interlaced_frame)
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58, 7, 100)
bool key_frame = frame->key_frame;
bool interlaced_frame = frame->interlaced_frame;
bool top_field_first = frame->top_field_first;
#else
bool key_frame = frame->flags & AV_FRAME_FLAG_KEY;
bool interlaced_frame = frame->flags & AV_FRAME_FLAG_INTERLACED;
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 (frame->top_field_first)
else if (top_field_first)
UBASE_ERROR(upipe, uref_pic_set_tff(uref))

if (frame->key_frame)
if (key_frame)
UBASE_ERROR(upipe, uref_pic_set_key(uref))

break;
Expand Down Expand Up @@ -1983,12 +1999,22 @@ static void upipe_avfilt_output_frame(struct upipe *upipe,
duration = av_rescale_q(frame->pkt_duration, time_base,
av_make_q(1, UCLOCK_FREQ));

if (!frame->interlaced_frame)
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58, 7, 100)
bool key_frame = frame->key_frame;
bool interlaced_frame = frame->interlaced_frame;
bool top_field_first = frame->top_field_first;
#else
bool key_frame = frame->flags & AV_FRAME_FLAG_KEY;
bool interlaced_frame = frame->flags & AV_FRAME_FLAG_INTERLACED;
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 (frame->top_field_first)
else if (top_field_first)
UBASE_ERROR(upipe, uref_pic_set_tff(uref))

if (frame->key_frame)
if (key_frame)
UBASE_ERROR(upipe, uref_pic_set_key(uref))

break;
Expand Down
Loading