Package: amide
Followup-For: Bug #739211

An internal review by the libav developer resulted in suggestions how to
simplify the API usage of avcodec_encode_video2. Please consider this updated 
patch.

Best,
Reinhard



-- System Information:
Debian Release: 7.4
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.11.0-17-generic (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Description: Fix compilation against libav 10
Author: Reinhard Tartler <siret...@tauware.de>
Bug-Debian: http://bugs.debian.org/739211

--- a/src/mpeg_encode.c
+++ b/src/mpeg_encode.c
@@ -142,6 +142,7 @@ static void convert_rgb_pixbuf_to_yuv(yu
 #ifdef AMIDE_FFMPEG_SUPPORT
 
 #include <libavcodec/avcodec.h>
+#include <libavutil/frame.h>
 
 
 typedef struct {
@@ -234,11 +235,11 @@ gpointer mpeg_encode_setup(gchar * outpu
 
   switch(type) {
   case ENCODE_MPEG4:
-    codec_type = CODEC_ID_MPEG4;
+    codec_type = AV_CODEC_ID_MPEG4;
     break;
   case ENCODE_MPEG1:
   default:
-    codec_type=CODEC_ID_MPEG1VIDEO;
+    codec_type=AV_CODEC_ID_MPEG1VIDEO;
     break;
   }
 
@@ -268,7 +269,7 @@ gpointer mpeg_encode_setup(gchar * outpu
     return NULL;
   }
 
-  encode->picture= avcodec_alloc_frame();
+  encode->picture= av_frame_alloc();
   if (!encode->picture) {
     g_warning("couldn't allocate memory for encode->picture");
     encode_free(encode);
@@ -359,15 +360,19 @@ gpointer mpeg_encode_setup(gchar * outpu
 
 gboolean mpeg_encode_frame(gpointer data, GdkPixbuf * pixbuf) {
   encode_t * encode = data;
-  gint out_size;
+  AVPacket pkt = { 0 };
+  int ret, got_packet = 0;
 
   convert_rgb_pixbuf_to_yuv(encode->yuv, pixbuf);
 
   /* encode the image */
-  out_size = avcodec_encode_video(encode->context, encode->output_buffer, encode->output_buffer_size, encode->picture);
-  fwrite(encode->output_buffer, 1, out_size, encode->output_file);
+  ret = avcodec_encode_video2(encode->context, &pkt, encode->picture, &got_packet);
 
-  return TRUE;
+  if (ret >= 0 && got_packet) {
+      fwrite(pkt.data, 1, pkt.size, encode->output_file);
+      av_free_packet(&pkt);
+  }
+  return (ret >= 0) ? TRUE : FALSE;
 };
 
 /* close everything up */
_______________________________________________
pkg-multimedia-maintainers mailing list
pkg-multimedia-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-multimedia-maintainers

Reply via email to