summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-12-13 16:12:45 +0100
committersfan5 <sfan5@live.de>2022-01-10 22:56:52 +0100
commitb1bf4393a85f70ae7b54afdeff1af41c6937acf2 (patch)
treee16f9220e0b80908c7a31c14ca675dc3cbd7bea0
parent8b4a613c54de038bcf0dd710563059a03968d82b (diff)
downloadmpv-b1bf4393a85f70ae7b54afdeff1af41c6937acf2.tar.bz2
mpv-b1bf4393a85f70ae7b54afdeff1af41c6937acf2.tar.xz
demux/packet: replace deprecated av_init_packet()
-rw-r--r--demux/packet.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/demux/packet.c b/demux/packet.c
index 1a460b0ccb..39697c19b9 100644
--- a/demux/packet.c
+++ b/demux/packet.c
@@ -39,9 +39,7 @@ void demux_packet_unref_contents(struct demux_packet *dp)
{
if (dp->avpacket) {
assert(!dp->is_cached);
- av_packet_unref(dp->avpacket);
- talloc_free(dp->avpacket);
- dp->avpacket = NULL;
+ av_packet_free(&dp->avpacket);
dp->buffer = NULL;
dp->len = 0;
}
@@ -70,11 +68,12 @@ struct demux_packet *new_demux_packet_from_avpacket(struct AVPacket *avpkt)
.start = MP_NOPTS_VALUE,
.end = MP_NOPTS_VALUE,
.stream = -1,
- .avpacket = talloc_zero(dp, AVPacket),
+ .avpacket = av_packet_alloc(),
};
- av_init_packet(dp->avpacket);
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,
// because otherwise new_demux_packet_from() wouldn't work.
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);
}
if (r < 0) {
- *dp->avpacket = (AVPacket){0};
talloc_free(dp);
return NULL;
}