demux/packet: replace deprecated av_init_packet()

This commit is contained in:
sfan5 2021-12-13 16:12:45 +01:00
parent 8b4a613c54
commit b1bf4393a8
1 changed files with 5 additions and 7 deletions

View File

@ -39,9 +39,7 @@ void demux_packet_unref_contents(struct demux_packet *dp)
{ {
if (dp->avpacket) { if (dp->avpacket) {
assert(!dp->is_cached); assert(!dp->is_cached);
av_packet_unref(dp->avpacket); av_packet_free(&dp->avpacket);
talloc_free(dp->avpacket);
dp->avpacket = NULL;
dp->buffer = NULL; dp->buffer = NULL;
dp->len = 0; dp->len = 0;
} }
@ -70,11 +68,12 @@ struct demux_packet *new_demux_packet_from_avpacket(struct AVPacket *avpkt)
.start = MP_NOPTS_VALUE, .start = MP_NOPTS_VALUE,
.end = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE,
.stream = -1, .stream = -1,
.avpacket = talloc_zero(dp, AVPacket), .avpacket = av_packet_alloc(),
}; };
av_init_packet(dp->avpacket);
int r = -1; int r = -1;
if (avpkt->data) { if (!dp->avpacket) {
// error
} else if (avpkt->data) {
// We hope that this function won't need/access AVPacket input padding, // We hope that this function won't need/access AVPacket input padding,
// because otherwise new_demux_packet_from() wouldn't work. // because otherwise new_demux_packet_from() wouldn't work.
r = av_packet_ref(dp->avpacket, avpkt); r = av_packet_ref(dp->avpacket, avpkt);
@ -82,7 +81,6 @@ struct demux_packet *new_demux_packet_from_avpacket(struct AVPacket *avpkt)
r = av_new_packet(dp->avpacket, avpkt->size); r = av_new_packet(dp->avpacket, avpkt->size);
} }
if (r < 0) { if (r < 0) {
*dp->avpacket = (AVPacket){0};
talloc_free(dp); talloc_free(dp);
return NULL; return NULL;
} }