Hi Stefano (2011.09.25_22:33:46_+0200)
> Anyway, here are my incomplete and totally untested additions

Had some more time to look at it. Final version, as uploaded to Ubuntu,
attached.

SR

-- 
Stefano Rivera
  http://tumbleweed.org.za/
  H: +27 21 465 6908 C: +27 72 419 8559  UCT: x3127
diff --git a/debian/changelog b/debian/changelog
index af5f478..288e3b2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+avbin (7-1.1ubuntu2) oneiric; urgency=low
+
+  * Further libav 0.7 deprecated API removal (LP: #859189)
+
+ -- Stefano Rivera <stefa...@ubuntu.com>  Mon, 26 Sep 2011 16:24:22 +0200
+
 avbin (7-1.1ubuntu1) oneiric; urgency=low
 
   * Remove usage of deprecated APIs to work with Libav 0.7
diff --git a/src/avbin.c b/src/avbin.c
index 1e26831..cbe76e4 100644
--- a/src/avbin.c
+++ b/src/avbin.c
@@ -33,7 +33,6 @@
 
 struct _AVbinFile {
     AVFormatContext *context;
-    AVDictionary *format_options;
     AVPacket *packet;
 };
 
@@ -124,7 +123,8 @@ AVbinResult avbin_set_log_callback(AVbinLogCallback callback)
 AVbinFile *avbin_open_filename(const char *filename)
 {
     AVbinFile *file = malloc(sizeof *file);
-    if (av_open_input(&file->context, filename, NULL, &file->format_options) != 0)
+    file->context = avformat_alloc_context();
+    if (avformat_open_input(&file->context, filename, NULL, NULL) < 0)
         goto error;
 
     if (av_find_stream_info(file->context) < 0)
@@ -179,29 +179,37 @@ AVbinResult avbin_file_info(AVbinFile *file, AVbinFileInfo *info)
     info->start_time = file->context->start_time;
     info->duration = file->context->duration;
 
-    result = av_dict_get(file->format_options, "title", NULL, 0);
-    strncpy(info->title, result->value, sizeof(info->title));
+    result = av_dict_get(file->context->metadata, "title", NULL, 0);
+    if (result)
+        strncpy(info->title, result->value, sizeof(info->title));
 
-    result = av_dict_get(file->format_options, "artist", NULL, 0);
-    strncpy(info->author, result->value, sizeof(info->author));
+    result = av_dict_get(file->context->metadata, "artist", NULL, 0);
+    if (result)
+        strncpy(info->author, result->value, sizeof(info->author));
 
-    result = av_dict_get(file->format_options, "copyright", NULL, 0);
-    strncpy(info->copyright, result->value, sizeof(info->copyright));
+    result = av_dict_get(file->context->metadata, "copyright", NULL, 0);
+    if (result)
+        strncpy(info->copyright, result->value, sizeof(info->copyright));
 
-    result = av_dict_get(file->format_options, "comment", NULL, 0);
-    strncpy(info->comment, result->value, sizeof(info->comment));
+    result = av_dict_get(file->context->metadata, "comment", NULL, 0);
+    if (result)
+        strncpy(info->comment, result->value, sizeof(info->comment));
 
-    result = av_dict_get(file->format_options, "album", NULL, 0);
-    strncpy(info->album, result->value, sizeof(info->album));
+    result = av_dict_get(file->context->metadata, "album", NULL, 0);
+    if (result)
+        strncpy(info->album, result->value, sizeof(info->album));
 
-    result = av_dict_get(file->format_options, "year", NULL, 0);
-    info->year = strtol(result->value, NULL, 10);
+    result = av_dict_get(file->context->metadata, "year", NULL, 0);
+    if (result)
+        info->year = strtol(result->value, NULL, 10);
 
-    result = av_dict_get(file->format_options, "track", NULL, 0);
-    info->track = strtol(result->value, NULL, 10);
+    result = av_dict_get(file->context->metadata, "track", NULL, 0);
+    if (result)
+        info->track = strtol(result->value, NULL, 10);
 
-    result = av_dict_get(file->format_options, "genre", NULL, 0);
-    strncpy(info->genre, result->value, sizeof(info->genre));
+    result = av_dict_get(file->context->metadata, "genre", NULL, 0);
+    if (result)
+        strncpy(info->genre, result->value, sizeof(info->genre));
 
     return AVBIN_RESULT_OK;
 }
@@ -321,9 +329,13 @@ int avbin_decode_audio(AVbinStream *stream,
     if (stream->type != AVMEDIA_TYPE_AUDIO)
         return AVBIN_RESULT_ERROR;
 
-    used = avcodec_decode_audio2(stream->codec_context, 
+    AVPacket avpkt;
+    av_init_packet(&avpkt);
+    avpkt.data = data_in;
+    avpkt.size = size_in;
+    used = avcodec_decode_audio3(stream->codec_context, 
                                  (int16_t *) data_out, size_out,
-                                 data_in, size_in);
+                                 &avpkt);
 
     if (used < 0)
         return AVBIN_RESULT_ERROR;
@@ -344,9 +356,15 @@ int avbin_decode_video(AVbinStream *stream,
     if (stream->type != AVMEDIA_TYPE_VIDEO)
         return AVBIN_RESULT_ERROR;
 
-    used = avcodec_decode_video(stream->codec_context, 
-                                stream->frame, &got_picture,
-                                data_in, size_in);
+    AVPacket avpkt;
+    av_init_packet(&avpkt);
+    avpkt.data = data_in;
+    avpkt.size = size_in;
+    // HACK for CorePNG to decode as normal PNG by default
+    avpkt.flags = AV_PKT_FLAG_KEY;
+    used = avcodec_decode_video2(stream->codec_context, 
+                                 stream->frame, &got_picture,
+                                 &avpkt);
     if (!got_picture)
         return AVBIN_RESULT_ERROR;
 

Reply via email to