aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-09-26 00:24:29 -0300
committerJames Almer <jamrial@gmail.com>2017-10-02 11:14:57 -0300
commita22c6a4796ca1f2cbee6784262515da876fbec22 (patch)
treedaa8116b4f030860f784cd0ae10cdade414189af
parentcf3d2d52b59ddfc2a7c65a8e66f7698c4b837e51 (diff)
downloadffmpeg-a22c6a4796ca1f2cbee6784262515da876fbec22.tar.gz
avcodec/encode: remove usage of av_dup_packet()
Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/encode.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 525ee1f5d6..dd50486bcf 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;
}
}