]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/encode.c
lavc/qsvenc: assert uninitialized pict_type
[ffmpeg] / libavcodec / encode.c
index 71b1b14afc029dfb5ea61afc22a668bbc0b02e46..d12c42526be5b94eac158752a8041f06aaa61278 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;
         }
     }
 
@@ -238,13 +234,12 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
             if (ret >= 0)
                 avpkt->data = avpkt->buf->data;
         }
-
-        avctx->frame_number++;
+        if (frame)
+            avctx->frame_number++;
     }
 
     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;
         }
     }
 
@@ -339,7 +329,8 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
                 avpkt->data = avpkt->buf->data;
         }
 
-        avctx->frame_number++;
+        if (frame)
+            avctx->frame_number++;
     }
 
     if (ret < 0 || !*got_packet_ptr)