Browse Source

avcodec/encode: use av_packet_make_refcounted to ensure packets are ref counted

Simplifies code.

Signed-off-by: James Almer <jamrial@gmail.com>
tags/n4.0
James Almer 8 years ago
parent
commit
e61d8b82a2
1 changed files with 2 additions and 8 deletions
  1. +2
    -8
      libavcodec/encode.c

+ 2
- 8
libavcodec/encode.c View File

@@ -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_refcounted(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_refcounted(avpkt);
if (ret < 0)
return ret;
*avpkt = tmp;
}
}



Loading…
Cancel
Save