X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fencode.c;h=dd50486bcfeb8614881e34cddf35a191839de9a6;hb=a22c6a4796ca1f2cbee6784262515da876fbec22;hp=525ee1f5d64b6ceac4ce28d8073ef809f0dc0b8b;hpb=1a115a31d430b71973b1e1556fcf767417449f09;p=ffmpeg diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 525ee1f5d64..dd50486bcfe 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -222,10 +222,12 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, } avpkt->buf = user_pkt.buf; avpkt->data = user_pkt.data; - } else { - if (av_dup_packet(avpkt) < 0) { - ret = AVERROR(ENOMEM); - } + } else if (!avpkt->buf) { + AVPacket tmp = { 0 }; + ret = av_packet_ref(&tmp, avpkt); + if (ret < 0) + return ret; + *avpkt = tmp; } } @@ -318,10 +320,12 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, } avpkt->buf = user_pkt.buf; avpkt->data = user_pkt.data; - } else { - if (av_dup_packet(avpkt) < 0) { - ret = AVERROR(ENOMEM); - } + } else if (!avpkt->buf) { + AVPacket tmp = { 0 }; + ret = av_packet_ref(&tmp, avpkt); + if (ret < 0) + return ret; + *avpkt = tmp; } }