Skip to content

Commit 59c5877

Browse files
committed
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
1 parent c54714e commit 59c5877

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/upipe-av/upipe_avcodec_decode.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,8 @@ static void upipe_avcdec_output_pic(struct upipe *upipe, struct upump **upump_p)
11161116
}
11171117
}
11181118

1119+
uref_free(upipe_avcdec->uref);
1120+
upipe_avcdec->uref = NULL;
11191121
upipe_avcdec_output(upipe, uref, upump_p);
11201122
}
11211123

@@ -1198,6 +1200,8 @@ static void upipe_avcdec_output_sound(struct upipe *upipe,
11981200
}
11991201
}
12001202

1203+
uref_free(upipe_avcdec->uref);
1204+
upipe_avcdec->uref = NULL;
12011205
upipe_avcdec_output(upipe, uref, upump_p);
12021206
}
12031207

@@ -1291,7 +1295,6 @@ static void upipe_avcdec_store_uref(struct upipe *upipe, struct uref *uref)
12911295
struct upipe_avcdec *upipe_avcdec = upipe_avcdec_from_upipe(upipe);
12921296
if (upipe_avcdec->uref != NULL && upipe_avcdec->uref->uchain.next != NULL)
12931297
uref_free(uref_from_uchain(upipe_avcdec->uref->uchain.next));
1294-
uref_free(upipe_avcdec->uref);
12951298
upipe_avcdec->uref = uref;
12961299
}
12971300

@@ -1348,7 +1351,10 @@ static bool upipe_avcdec_decode(struct upipe *upipe, struct uref *uref,
13481351
upipe_avcdec->input_dts_sys = input_dts_sys;
13491352
}
13501353

1351-
upipe_avcdec_store_uref(upipe, uref);
1354+
if (!upipe_avcdec->uref)
1355+
upipe_avcdec_store_uref(upipe, uref);
1356+
else
1357+
uref_free(uref);
13521358
upipe_avcdec_decode_avpkt(upipe, &avpkt, upump_p);
13531359

13541360
free(avpkt.data);

0 commit comments

Comments
 (0)