--- avbin-7.orig/src/avbin.c +++ avbin-7/src/avbin.c @@ -25,9 +25,11 @@ #include /* ffmpeg */ -#include -#include -#include +#include +#include +#include +#include +#include struct _AVbinFile { AVFormatContext *context; @@ -42,6 +44,7 @@ }; static AVbinLogCallback user_log_callback = NULL; +static int av_log_level; /** * Format log messages and call the user log callback. Essentially a @@ -90,8 +93,9 @@ AVbinResult avbin_init() { - avcodec_init(); - av_register_all(); + avcodec_register_all(); + av_register_all(); + av_log_level = av_log_get_level(); return AVBIN_RESULT_OK; } @@ -119,10 +123,11 @@ 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) + if (avformat_find_stream_info(file->context, NULL) < 0) goto error; file->packet = NULL; @@ -140,7 +145,7 @@ av_free_packet(file->packet); free(file->packet); } - av_close_input_file(file->context); + avformat_close_input(&file->context); } AVbinResult avbin_seek_file(AVbinFile *file, AVbinTimestamp timestamp) @@ -165,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; } @@ -194,36 +225,32 @@ 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; switch (context->sample_fmt) { - case SAMPLE_FMT_U8: + case AV_SAMPLE_FMT_U8: info->audio.sample_rate = AVBIN_SAMPLE_FORMAT_U8; info->audio.sample_bits = 8; break; - case SAMPLE_FMT_S16: + case AV_SAMPLE_FMT_S16: info->audio.sample_format = AVBIN_SAMPLE_FORMAT_S16; info->audio.sample_bits = 16; break; - case SAMPLE_FMT_S24: - info->audio.sample_format = AVBIN_SAMPLE_FORMAT_S24; - info->audio.sample_bits = 24; - break; - case SAMPLE_FMT_S32: + case AV_SAMPLE_FMT_S32: info->audio.sample_format = AVBIN_SAMPLE_FORMAT_S32; info->audio.sample_bits = 32; break; - case SAMPLE_FMT_FLT: + case AV_SAMPLE_FMT_FLT: info->audio.sample_format = AVBIN_SAMPLE_FORMAT_FLOAT; info->audio.sample_bits = 32; break; @@ -250,14 +277,14 @@ if (!codec) return NULL; - if (avcodec_open(codec_context, codec) < 0) + if (avcodec_open2(codec_context, codec, NULL) < 0) return NULL; AVbinStream *stream = malloc(sizeof *stream); 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; @@ -299,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; @@ -322,25 +353,45 @@ 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; avpicture_fill(&picture_rgb, data_out, PIX_FMT_RGB24, width, height); - /* img_convert is marked deprecated in favour of swscale, don't - * be surprised if this stops working the next time the ffmpeg version - * is pushed. Example use of the new API is in ffplay.c. */ - img_convert(&picture_rgb, PIX_FMT_RGB24, - (AVPicture *) stream->frame, stream->codec_context->pix_fmt, - width, height); + static int sws_flags = SWS_BICUBIC; + static struct SwsContext *img_convert_ctx; + img_convert_ctx = sws_getContext( width, + height, + stream->codec_context->pix_fmt, + width, + height, + PIX_FMT_RGB24, + sws_flags, NULL, NULL, NULL); + + sws_scale( img_convert_ctx, + stream->frame->data, + stream->frame->linesize, + 0, + height, + picture_rgb.data, + picture_rgb.linesize); + + sws_freeContext(img_convert_ctx); + return used; } --- avbin-7.orig/debian/copyright +++ avbin-7/debian/copyright @@ -0,0 +1,32 @@ +avbin was downloaded from http://code.google.com/p/avbin/downloads/list + +Copyright (c) 2007 Alex Holkner + +From avbin/README: + + | Due to the linkage between AVbin and FFmpeg, AVbin must be licensed under the + | LGPL or GPL. Currently all GPL features of the FFmpeg configuration are + | disabled, permitting LGPL use. + +Thus, the code is licensed under the GNU LGPL: + + | This library is free software; you can redistribute it and/or + | modify it under the terms of the GNU Lesser General Public License as + | published by the Free Software Foundation; either version 2.1 of + | the License, or (at your option) any later version. + | + | This library is distributed in the hope that it will be useful, + | but WITHOUT ANY WARRANTY; without even the implied warranty of + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + | Lesser General Public License for more details. + | + | You should have received a copy of the GNU General Public License + | along with this program; if not, write to the Free Software + | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +The Debian packaging is Copyright (c) 2009 Andrew Straw and Matthew Johnson +and is also distributed under the terms of the GNU LGPL. + +On Debian GNU/Linux systems, the complete text of the GNU General Public +License can be found in `/usr/share/common-licenses/GPL' and the text of the +GNU Lesser General Public License is in `/usr/share/common-licenses/LGPL'. --- avbin-7.orig/debian/libavbin-dev.install +++ avbin-7/debian/libavbin-dev.install @@ -0,0 +1,4 @@ +usr/lib/libavbin.a +usr/lib/libavbin.so +include/avbin.h usr/include +doc/html usr/share/doc/libavbin-dev --- avbin-7.orig/debian/changelog +++ avbin-7/debian/changelog @@ -0,0 +1,64 @@ +avbin (7-1.4build1) trusty; urgency=low + + * No change rebuild against libav 9. + + -- Dmitrijs Ledkovs Tue, 05 Nov 2013 01:22:02 +0000 + +avbin (7-1.4) unstable; urgency=low + + * Non-maintainer upload. + * Separate upstream's and Debian's build system. Running targets in + upstream's Makefile causes build failures. (Closes: #721164) + + Move Debian's build system to debian/build and invoke dh with + --sourcedirectory=debian/build. + + Fix some warnings in Debian's build system: + - configure.ac: fix deprecated call of AM_INIT. + - Makefile.am: move -I and -D to CPPFLAGS. INCLUDES is deprecated and -D + is supposed to be in CPPFLAGS, not in CFLAGS. + + debian/rules: Use dh-autoreconf to generate the build system and get rid + of the manual removal of an incomplete list of files generated by the + build system. + + debian/control: Add dh-autoreconf to Build-Depends. + * debian/control: Remove unnecessary dependency on ffmpeg. (Closes: #721160) + * src/avbin.c: Port to libav 9 API. + + -- Sebastian Ramacher Thu, 05 Sep 2013 14:50:27 +0200 + +avbin (7-1.3) unstable; urgency=low + + * Non-maintainer upload. + * debian/rules: + - Replace deprecated dh --after and dh --before calls with overrides + (Closes: #666284). + - Remove m4 to be able to build twice. + * debian/control: Bump debhelper Buil-Dep to 7.0.50~ for overrides support. + + -- Sebastian Ramacher Sun, 08 Apr 2012 19:22:38 +0200 + +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 Sat, 03 Mar 2012 18:15:31 +0000 + +avbin (7-1.1) unstable; urgency=low + + * Non-maintainer upload. + * port to new libavutil50 log API. (Closes: #591516) + + -- Reinhard Tartler Fri, 18 Feb 2011 20:35:54 +0100 + +avbin (7-1) unstable; urgency=low + + [ Andrew Straw ] + * Initial packaging. (Closes: #523809) + + [ Matthew Johnson ] + * Lintian tidyups + * Install header and docs + * Add watch file + * Fix clean target for double-builds + + -- Matthew Johnson Mon, 04 May 2009 00:24:42 +0100 --- avbin-7.orig/debian/control +++ avbin-7/debian/control @@ -0,0 +1,47 @@ +Source: avbin +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Andrew Straw +Uploaders: Matthew Johnson +Section: utils +Priority: extra +Build-Depends: debhelper (>= 7.0.50~), + dh-autoreconf, + autoconf, + automake, + libtool, + libavutil-dev, + libavcodec-dev, + libavformat-dev, + libswscale-dev +Standards-Version: 3.8.0 +Homepage: http://code.google.com/p/avbin/ +Vcs-Git: git://github.com/astraw/avbin-debian.git +Vcs-Browser: http://github.com/astraw/avbin-debian/tree/master + +Package: libavbin0 +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, + ${misc:Depends} +Description: cross-platform media decoding library + AVbin is a thin wrapper around FFmpeg, providing binary compatibility + for applications and languages that need it. + . + FFmpeg is a collection of audio and video codecs widely used in + projects such as mplayer, xine, GStreamer and VLC. It is under + continuous development; so much so that its developers rarely provide + a release, and SVN snapshots of the library must be statically linked + to avoid version incompatibilities. + +Package: libavbin-dev +Section: libdevel +Architecture: any +Depends: libavbin0 (= ${binary:Version}), + ${shlibs:Depends}, + ${misc:Depends} +Description: development files for libavbin + AVbin is a thin wrapper around FFmpeg, providing binary compatibility + for applications and languages that need it. + . + This package contains the header files and static libraries needed to + compile applications or shared objects that use libavbin. --- avbin-7.orig/debian/rules +++ avbin-7/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ --with autoreconf --sourcedirectory debian/build --- avbin-7.orig/debian/watch +++ avbin-7/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://code.google.com/p/avbin/ http://avbin.googlecode.com/files/avbin-src-([\d\.]*).tar.gz --- avbin-7.orig/debian/libavbin0.install +++ avbin-7/debian/libavbin0.install @@ -0,0 +1 @@ +usr/lib/libavbin.so.* --- avbin-7.orig/debian/compat +++ avbin-7/debian/compat @@ -0,0 +1 @@ +7 --- avbin-7.orig/debian/TODO +++ avbin-7/debian/TODO @@ -0,0 +1 @@ +Switch to quilt. --- avbin-7.orig/debian/autoreconf +++ avbin-7/debian/autoreconf @@ -0,0 +1 @@ +debian/build --- avbin-7.orig/debian/build/Makefile.am +++ avbin-7/debian/build/Makefile.am @@ -0,0 +1,10 @@ +# See http://sourceware.org/autobook/autobook/autobook_88.html +c_sources = ../../src/avbin.c + +lib_LTLIBRARIES= libavbin.la +libavbin_la_SOURCES= $(c_sources) +libavbin_la_CPPFLAGS= -DAVBIN_VERSION=7 -DFFMPEG_REVISION=15943 \ + -I$(top_srcdir) -I../../include -I/usr/include/libavformat \ + -I/usr/include/libavcodec -I/usr/include/libavutil -I/usr/include/libswscale +libavbin_la_LDFLAGS= -version-info 0:7:0 +libavbin_la_LIBADD= -lavutil -lavcodec -lavformat -lswscale --- avbin-7.orig/debian/build/configure.ac +++ avbin-7/debian/build/configure.ac @@ -0,0 +1,31 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.61]) +AC_INIT(avbin, 7.0, Alex.Holkner@gmail.com) +AC_CONFIG_SRCDIR([../../include/avbin.h]) +AM_INIT_AUTOMAKE([foreign subdir-objects]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_PROG_LIBTOOL + +# Checks for programs. +AC_PROG_CC + +# Checks for libraries. + +# Checks for header files. +AC_CHECK_HEADERS([stdint.h stdlib.h string.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_TYPE_INT16_T +AC_TYPE_INT64_T +AC_TYPE_SIZE_T +AC_TYPE_UINT8_T + +# Checks for library functions. +AC_FUNC_MALLOC + +AC_OUTPUT +AC_OUTPUT(Makefile)