[gegl] ff-save: use avcodec_encode_video2 instead of avcodec_encode_video



commit e26d6deace3587ca404044fc5e4ed61086fe15fb
Author: Øyvind Kolås <pippin gimp org>
Date:   Tue Feb 16 20:30:01 2016 +0100

    ff-save: use avcodec_encode_video2 instead of avcodec_encode_video

 operations/external/ff-save.c |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/operations/external/ff-save.c b/operations/external/ff-save.c
index d327b6b..846033d 100644
--- a/operations/external/ff-save.c
+++ b/operations/external/ff-save.c
@@ -813,10 +813,33 @@ write_video_frame (GeglProperties *o,
   else
     {
       /* encode the image */
-      out_size =
-        avcodec_encode_video (c,
-                              p->video_outbuf,
-                              p->video_outbuf_size, picture_ptr);
+      AVPacket pkt2;
+      int got_packet = 0;
+      av_init_packet(&pkt2);
+      pkt2.data = p->video_outbuf;
+      pkt2.size = p->video_outbuf_size;
+
+      out_size = avcodec_encode_video2(c, &pkt2, picture_ptr, &got_packet);
+    
+      if (!out_size && got_packet && c->coded_frame)
+        {
+          c->coded_frame->pts       = pkt2.pts;
+          c->coded_frame->key_frame = !!(pkt2.flags & AV_PKT_FLAG_KEY);
+          if (c->codec->capabilities & AV_CODEC_CAP_INTRA_ONLY)
+              c->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+        }
+
+      if (pkt2.side_data_elems > 0)
+        {
+          int i;
+          for (i = 0; i < pkt2.side_data_elems; i++)
+            av_free(pkt2.side_data[i].data);
+          av_freep(&pkt2.side_data);
+          pkt2.side_data_elems = 0;
+        }
+
+      if (!out_size)
+        out_size = pkt2.size;
 
       /* if zero size, it means the image was buffered */
       if (out_size != 0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]