From c54714efc0e73b458c961a551eb5b708eb012951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Fri, 11 Jan 2019 14:42:54 +0100 Subject: [PATCH 1/2] h264f: clear next_uref of nal offsets This avoid outputting wrong offsets if the next frame has less NALs --- lib/upipe-framers/upipe_h264_framer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/upipe-framers/upipe_h264_framer.c b/lib/upipe-framers/upipe_h264_framer.c index 84bd8ef26..9c5a17353 100644 --- a/lib/upipe-framers/upipe_h264_framer.c +++ b/lib/upipe-framers/upipe_h264_framer.c @@ -2028,6 +2028,9 @@ static void upipe_h264f_output_au(struct upipe *upipe, struct uref *uref, upipe_throw_error(upipe, err); } + if (upipe_h264f->next_uref) + uref_h26x_delete_nal_offsets(upipe_h264f->next_uref); + upipe_h264f_output(upipe, uref, upump_p); } From 59c587716cead8bd49bb842f498896bb791930e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Fri, 11 Jan 2019 14:43:45 +0100 Subject: [PATCH 2/2] avcdec: only store uref when needed This is needed if several input urefs are needed to output a frame, for example when settings flags2 to chunks with h264 --- lib/upipe-av/upipe_avcodec_decode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/upipe-av/upipe_avcodec_decode.c b/lib/upipe-av/upipe_avcodec_decode.c index e1263a0b8..5553983c4 100644 --- a/lib/upipe-av/upipe_avcodec_decode.c +++ b/lib/upipe-av/upipe_avcodec_decode.c @@ -1116,6 +1116,8 @@ static void upipe_avcdec_output_pic(struct upipe *upipe, struct upump **upump_p) } } + uref_free(upipe_avcdec->uref); + upipe_avcdec->uref = NULL; upipe_avcdec_output(upipe, uref, upump_p); } @@ -1198,6 +1200,8 @@ static void upipe_avcdec_output_sound(struct upipe *upipe, } } + uref_free(upipe_avcdec->uref); + upipe_avcdec->uref = NULL; upipe_avcdec_output(upipe, uref, upump_p); } @@ -1291,7 +1295,6 @@ static void upipe_avcdec_store_uref(struct upipe *upipe, struct uref *uref) struct upipe_avcdec *upipe_avcdec = upipe_avcdec_from_upipe(upipe); if (upipe_avcdec->uref != NULL && upipe_avcdec->uref->uchain.next != NULL) uref_free(uref_from_uchain(upipe_avcdec->uref->uchain.next)); - uref_free(upipe_avcdec->uref); upipe_avcdec->uref = uref; } @@ -1348,7 +1351,10 @@ static bool upipe_avcdec_decode(struct upipe *upipe, struct uref *uref, upipe_avcdec->input_dts_sys = input_dts_sys; } - upipe_avcdec_store_uref(upipe, uref); + if (!upipe_avcdec->uref) + upipe_avcdec_store_uref(upipe, uref); + else + uref_free(uref); upipe_avcdec_decode_avpkt(upipe, &avpkt, upump_p); free(avpkt.data);