]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/encode.c
avcodec/utils: document allocation requirement of extradata
[ffmpeg] / libavcodec / encode.c
index 71b1b14afc029dfb5ea61afc22a668bbc0b02e46..0ebd8dd6a55ea99bf7a4012df918a4e9ca537cbe 100644 (file)
@@ -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;
         }
     }