X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fencode.c;h=0ebd8dd6a55ea99bf7a4012df918a4e9ca537cbe;hb=0c71c6d66f9ae8265158181e5b1cbc5c63525fde;hp=71b1b14afc029dfb5ea61afc22a668bbc0b02e46;hpb=0cc8e34a94c84132cf5b0f6472c5f61c8a66cee1;p=ffmpeg diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 71b1b14afc0..0ebd8dd6a55 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -135,7 +135,6 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) { av_packet_unref(avpkt); - av_init_packet(avpkt); return 0; } @@ -223,12 +222,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_refcounted(avpkt); if (ret < 0) goto end; - *avpkt = tmp; } } @@ -244,7 +240,6 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, if (ret < 0 || !*got_packet_ptr) { av_packet_unref(avpkt); - av_init_packet(avpkt); goto end; } @@ -285,8 +280,6 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) { av_packet_unref(avpkt); - av_init_packet(avpkt); - avpkt->size = 0; return 0; } @@ -318,12 +311,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_refcounted(avpkt); if (ret < 0) return ret; - *avpkt = tmp; } }