Hi, Cyril,

> any reasons not to upload it to unstable as-is? Should I?

Sure, I'm NMUing it. I delayed because I was unsure of the patch, but it
seems to have weathered well in Ubuntu :)

> (Assuming the patch still applies for libav 0.8)

It appears to.


Dear maintainer,

I've prepared an NMU for avbin (versioned as 7-1.2). The diff
is attached to this message.

Regards.

SR
diff -u avbin-7/debian/changelog avbin-7/debian/changelog
--- avbin-7/debian/changelog
+++ avbin-7/debian/changelog
@@ -1,3 +1,11 @@
+avbin (7-1.2) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Remove usage of deprecated APIs to work with Libav >= 0.7. Thanks to
+    Reinhard Tartler for the first part of this. (Closes: #632133)
+
+ -- Stefano Rivera <stefa...@debian.org>  Sat, 03 Mar 2012 18:15:31 +0000
+
 avbin (7-1.1) unstable; urgency=low
 
   * Non-maintainer upload.
diff -u avbin-7/src/avbin.c avbin-7/src/avbin.c
--- avbin-7/src/avbin.c
+++ avbin-7/src/avbin.c
@@ -29,6 +29,7 @@
 #include <avcodec.h>
 #include <avutil.h>
 #include <swscale.h>
+#include <libavutil/dict.h>
 
 struct _AVbinFile {
     AVFormatContext *context;
@@ -122,7 +123,8 @@
 AVbinFile *avbin_open_filename(const char *filename)
 {
     AVbinFile *file = malloc(sizeof *file);
-    if (av_open_input_file(&file->context, filename, NULL, 0, NULL) != 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)
@@ -168,20 +170,46 @@
 
 AVbinResult avbin_file_info(AVbinFile *file, AVbinFileInfo *info)
 {
+    AVDictionaryEntry *result;
+
     if (info->structure_size < sizeof *info)
         return AVBIN_RESULT_ERROR;
 
     info->n_streams = file->context->nb_streams;
     info->start_time = file->context->start_time;
     info->duration = file->context->duration;
-    memcpy(info->title, file->context->title, sizeof(info->title));
-    memcpy(info->author, file->context->author, sizeof(info->author));
-    memcpy(info->copyright, file->context->copyright, sizeof(info->copyright));
-    memcpy(info->comment, file->context->comment, sizeof(info->comment));
-    memcpy(info->album, file->context->album, sizeof(info->album));
-    info->year = file->context->year;
-    info->track = file->context->track;
-    memcpy(info->genre, file->context->genre, sizeof(info->genre));
+
+    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->context->metadata, "artist", NULL, 0);
+    if (result)
+        strncpy(info->author, result->value, sizeof(info->author));
+
+    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->context->metadata, "comment", NULL, 0);
+    if (result)
+        strncpy(info->comment, result->value, sizeof(info->comment));
+
+    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->context->metadata, "year", NULL, 0);
+    if (result)
+        info->year = 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->context->metadata, "genre", NULL, 0);
+    if (result)
+        strncpy(info->genre, result->value, sizeof(info->genre));
 
     return AVBIN_RESULT_OK;
 }
@@ -197,14 +225,14 @@
 
     switch (context->codec_type)
     {
-        case CODEC_TYPE_VIDEO:
+        case AVMEDIA_TYPE_VIDEO:
             info->type = AVBIN_STREAM_TYPE_VIDEO;
             info->video.width = context->width;
             info->video.height = context->height;
             info->video.sample_aspect_num = context->sample_aspect_ratio.num;
             info->video.sample_aspect_den = context->sample_aspect_ratio.den;
             break;
-        case CODEC_TYPE_AUDIO:
+        case AVMEDIA_TYPE_AUDIO:
             info->type = AVBIN_STREAM_TYPE_AUDIO;
             info->audio.sample_rate = context->sample_rate;
             info->audio.channels = context->channels;
@@ -256,7 +284,7 @@
     stream->format_context = file->context;
     stream->codec_context = codec_context;
     stream->type = codec_context->codec_type;
-    if (stream->type == CODEC_TYPE_VIDEO)
+    if (stream->type == AVMEDIA_TYPE_VIDEO)
         stream->frame = avcodec_alloc_frame();
     else
         stream->frame = NULL;
@@ -298,12 +326,16 @@
                        uint8_t *data_out, int *size_out)
 {
     int used;
-    if (stream->type != CODEC_TYPE_AUDIO)
+    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;
@@ -321,12 +353,18 @@
     int height = stream->codec_context->height;
     int used;
 
-    if (stream->type != CODEC_TYPE_VIDEO)
+    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