Commit a22c6a47 authored by James Almer's avatar James Almer

avcodec/encode: remove usage of av_dup_packet()

Reviewed-by: 's avatarwm4 <nfxjfg@googlemail.com>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent cf3d2d52
...@@ -222,10 +222,12 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, ...@@ -222,10 +222,12 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
} }
avpkt->buf = user_pkt.buf; avpkt->buf = user_pkt.buf;
avpkt->data = user_pkt.data; avpkt->data = user_pkt.data;
} else { } else if (!avpkt->buf) {
if (av_dup_packet(avpkt) < 0) { AVPacket tmp = { 0 };
ret = AVERROR(ENOMEM); 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, ...@@ -318,10 +320,12 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
} }
avpkt->buf = user_pkt.buf; avpkt->buf = user_pkt.buf;
avpkt->data = user_pkt.data; avpkt->data = user_pkt.data;
} else { } else if (!avpkt->buf) {
if (av_dup_packet(avpkt) < 0) { AVPacket tmp = { 0 };
ret = AVERROR(ENOMEM); ret = av_packet_ref(&tmp, avpkt);
} if (ret < 0)
return ret;
*avpkt = tmp;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment