[FFmpeg-devel] [PATCH 3/6] avcodec/encode: use av_packet_make_ref to ensure packets are ref counted
James Almer
jamrial at gmail.com
Sun Mar 25 07:03:36 EEST 2018
Simplifies code.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavcodec/encode.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 71b1b14afc..9dbdf4f5d9 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -223,12 +223,9 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
avpkt->buf = user_pkt.buf;
avpkt->data = user_pkt.data;
} else if (!avpkt->buf) {
- AVPacket tmp = { 0 };
- ret = av_packet_ref(&tmp, avpkt);
- av_packet_unref(avpkt);
+ ret = av_packet_make_ref(avpkt);
if (ret < 0)
goto end;
- *avpkt = tmp;
}
}
@@ -318,12 +315,9 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
avpkt->buf = user_pkt.buf;
avpkt->data = user_pkt.data;
} else if (!avpkt->buf) {
- AVPacket tmp = { 0 };
- ret = av_packet_ref(&tmp, avpkt);
- av_packet_unref(avpkt);
+ ret = av_packet_make_ref(avpkt);
if (ret < 0)
return ret;
- *avpkt = tmp;
}
}
--
2.16.2
More information about the ffmpeg-devel
mailing list