I have forwarded this bug to the upstream bug tracker, and it was fixed within hours in the upstream git repository: http://sourceforge.net/p/minidlna/bugs/239/
Please see the attached patch for the upstream solution. I suggest using this patch instead of my home-made patch from a few days ago. It seems to do more than just fix the FTFBS to improve libav10 compatibility. This is only compile-tested and builds correctly in pbuilder with current debian sid. Someone should make sure everything still works at run-time. Regards, Florian
>From eb4bb68691bc0cfeecf032bdfcaf0b499b9abb33 Mon Sep 17 00:00:00 2001 From: Florian Will <florian.w...@gmail.com> Date: Thu, 15 May 2014 11:18:57 +0200 Subject: [PATCH] Fix FTBFS with libav10 Two upstream commits squashed into one: 361bc3: metadata: add libavcodec > 54 compatibility 05cde8: metadata: more libav10 compatibility changes --- libav.h | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ metadata.c | 93 ++++++++++++++++---------------------------------------------- 2 files changed, 104 insertions(+), 70 deletions(-) diff --git a/libav.h b/libav.h index 4e53164..69680a9 100644 --- a/libav.h +++ b/libav.h @@ -78,7 +78,88 @@ #define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO #endif +#if LIBAVCODEC_VERSION_INT <= ((51<<16)+(50<<8)+1) +#define CODEC_ID_WMAPRO CODEC_ID_NONE +#endif + +#if LIBAVCODEC_VERSION_MAJOR < 55 +#define AV_CODEC_ID_AAC CODEC_ID_AAC +#define AV_CODEC_ID_AC3 CODEC_ID_AC3 +#define AV_CODEC_ID_ADPCM_IMA_QT CODEC_ID_ADPCM_IMA_QT +#define AV_CODEC_ID_AMR_NB CODEC_ID_AMR_NB +#define AV_CODEC_ID_DTS CODEC_ID_DTS +#define AV_CODEC_ID_H264 CODEC_ID_H264 +#define AV_CODEC_ID_MP2 CODEC_ID_MP2 +#define AV_CODEC_ID_MP3 CODEC_ID_MP3 +#define AV_CODEC_ID_MPEG1VIDEO CODEC_ID_MPEG1VIDEO +#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO +#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4 +#define AV_CODEC_ID_MSMPEG4V3 CODEC_ID_MSMPEG4V3 +#define AV_CODEC_ID_PCM_S16LE CODEC_ID_PCM_S16LE +#define AV_CODEC_ID_VC1 CODEC_ID_VC1 +#define AV_CODEC_ID_WMAPRO CODEC_ID_WMAPRO +#define AV_CODEC_ID_WMAV1 CODEC_ID_WMAV1 +#define AV_CODEC_ID_WMAV2 CODEC_ID_WMAV2 +#define AV_CODEC_ID_WMV3 CODEC_ID_WMV3 +#endif + #if LIBAVUTIL_VERSION_INT < ((50<<16)+(13<<8)+0) #define av_strerror(x, y, z) snprintf(y, z, "%d", x) #endif +#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(31<<8)+0) +# if LIBAVUTIL_VERSION_INT < ((51<<16)+(5<<8)+0) && !defined(FF_API_OLD_METADATA2) +#define AV_DICT_IGNORE_SUFFIX AV_METADATA_IGNORE_SUFFIX +#define av_dict_get av_metadata_get +typedef AVMetadataTag AVDictionaryEntry; +# endif +#endif + +static inline int +lav_open(AVFormatContext **ctx, const char *filename) +{ + int ret; +#if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(17<<8)+0) + ret = avformat_open_input(ctx, filename, NULL, NULL); + if (ret == 0) + avformat_find_stream_info(*ctx, NULL); +#else + ret = av_open_input_file(ctx, filename, NULL, 0, NULL); + if (ret == 0) + av_find_stream_info(*ctx); +#endif + return ret; +} + +static inline void +lav_close(AVFormatContext *ctx) +{ +#if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(17<<8)+0) + avformat_close_input(&ctx); +#else + av_close_input_file(ctx); +#endif +} + +static inline int +lav_get_fps(AVStream *s) +{ +#if LIBAVCODEC_VERSION_MAJOR < 54 + if (s->r_frame_rate.den) + return s->r_frame_rate.num / s->r_frame_rate.den; +#else + if (s->avg_frame_rate.den) + return s->avg_frame_rate.num / s->avg_frame_rate.den; +#endif + return 0; +} + +static inline int +lav_get_interlaced(AVCodecContext *vc, AVStream *s) +{ +#if LIBAVCODEC_VERSION_MAJOR < 54 + return (vc->time_base.den ? (s->r_frame_rate.num / vc->time_base.den) : 0); +#else + return (vc->time_base.den ? (s->avg_frame_rate.num / vc->time_base.den) : 0); +#endif +} diff --git a/metadata.c b/metadata.c index dd6eae8..6f3f031 100644 --- a/metadata.c +++ b/metadata.c @@ -57,9 +57,8 @@ #define FLAG_RESOLUTION 0x00000400 #define FLAG_BITRATE 0x00000800 #define FLAG_FREQUENCY 0x00001000 -#define FLAG_BPS 0x00002000 -#define FLAG_CHANNELS 0x00004000 -#define FLAG_ROTATION 0x00008000 +#define FLAG_CHANNELS 0x00002000 +#define FLAG_ROTATION 0x00004000 /* Audio profile flags */ enum audio_profiles { @@ -76,40 +75,6 @@ enum audio_profiles { PROFILE_AUDIO_AMR }; -static inline int -lav_open(AVFormatContext **ctx, const char *filename) -{ - int ret; -#if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(17<<8)+0) - ret = avformat_open_input(ctx, filename, NULL, NULL); - if (ret == 0) - avformat_find_stream_info(*ctx, NULL); -#else - ret = av_open_input_file(ctx, filename, NULL, 0, NULL); - if (ret == 0) - av_find_stream_info(*ctx); -#endif - return ret; -} - -static inline void -lav_close(AVFormatContext *ctx) -{ -#if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(17<<8)+0) - avformat_close_input(&ctx); -#else - av_close_input_file(ctx); -#endif -} - -#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(31<<8)+0) -# if LIBAVUTIL_VERSION_INT < ((51<<16)+(5<<8)+0) && !defined(FF_API_OLD_METADATA2) -#define AV_DICT_IGNORE_SUFFIX AV_METADATA_IGNORE_SUFFIX -#define av_dict_get av_metadata_get -typedef AVMetadataTag AVDictionaryEntry; -# endif -#endif - /* This function shamelessly copied from libdlna */ #define MPEG_TS_SYNC_CODE 0x47 #define MPEG_TS_PACKET_LENGTH 188 @@ -299,8 +264,6 @@ free_metadata(metadata_t *m, uint32_t flags) free(m->bitrate); if( flags & FLAG_FREQUENCY ) free(m->frequency); - if( flags & FLAG_BPS ) - free(m->bps); if( flags & FLAG_CHANNELS ) free(m->channels); if( flags & FLAG_ROTATION ) @@ -772,10 +735,10 @@ GetVideoMetadata(const char *path, char *name) aac_object_type_t aac_type = AAC_INVALID; switch( ac->codec_id ) { - case CODEC_ID_MP3: + case AV_CODEC_ID_MP3: audio_profile = PROFILE_AUDIO_MP3; break; - case CODEC_ID_AAC: + case AV_CODEC_ID_AAC: if( !ac->extradata_size || !ac->extradata ) { @@ -816,12 +779,12 @@ GetVideoMetadata(const char *path, char *name) break; } break; - case CODEC_ID_AC3: - case CODEC_ID_DTS: + case AV_CODEC_ID_AC3: + case AV_CODEC_ID_DTS: audio_profile = PROFILE_AUDIO_AC3; break; - case CODEC_ID_WMAV1: - case CODEC_ID_WMAV2: + case AV_CODEC_ID_WMAV1: + case AV_CODEC_ID_WMAV2: /* WMA Baseline: stereo, up to 48 KHz, up to 192,999 bps */ if ( ac->bit_rate <= 193000 ) audio_profile = PROFILE_AUDIO_WMA_BASE; @@ -829,31 +792,24 @@ GetVideoMetadata(const char *path, char *name) else if ( ac->bit_rate <= 385000 ) audio_profile = PROFILE_AUDIO_WMA_FULL; break; - #if LIBAVCODEC_VERSION_INT > ((51<<16)+(50<<8)+1) - case CODEC_ID_WMAPRO: + case AV_CODEC_ID_WMAPRO: audio_profile = PROFILE_AUDIO_WMA_PRO; break; - #endif - case CODEC_ID_MP2: + case AV_CODEC_ID_MP2: audio_profile = PROFILE_AUDIO_MP2; break; - case CODEC_ID_AMR_NB: + case AV_CODEC_ID_AMR_NB: audio_profile = PROFILE_AUDIO_AMR; break; default: - if( (ac->codec_id >= CODEC_ID_PCM_S16LE) && - (ac->codec_id < CODEC_ID_ADPCM_IMA_QT) ) + if( (ac->codec_id >= AV_CODEC_ID_PCM_S16LE) && + (ac->codec_id < AV_CODEC_ID_ADPCM_IMA_QT) ) audio_profile = PROFILE_AUDIO_PCM; else DPRINTF(E_DEBUG, L_METADATA, "Unhandled audio codec [0x%X]\n", ac->codec_id); break; } xasprintf(&m.frequency, "%u", ac->sample_rate); - #if LIBAVCODEC_VERSION_INT < (52<<16) - xasprintf(&m.bps, "%u", ac->bits_per_sample); - #else - xasprintf(&m.bps, "%u", ac->bits_per_coded_sample); - #endif xasprintf(&m.channels, "%u", ac->channels); } if( vc ) @@ -879,7 +835,7 @@ GetVideoMetadata(const char *path, char *name) if( strcmp(ctx->iformat->name, "avi") == 0 ) { xasprintf(&m.mime, "video/x-msvideo"); - if( vc->codec_id == CODEC_ID_MPEG4 ) + if( vc->codec_id == AV_CODEC_ID_MPEG4 ) { fourcc[0] = vc->codec_tag & 0xff; fourcc[1] = vc->codec_tag>>8 & 0xff; @@ -903,7 +859,7 @@ GetVideoMetadata(const char *path, char *name) switch( vc->codec_id ) { - case CODEC_ID_MPEG1VIDEO: + case AV_CODEC_ID_MPEG1VIDEO: if( strcmp(ctx->iformat->name, "mpeg") == 0 ) { if( (vc->width == 352) && @@ -914,7 +870,7 @@ GetVideoMetadata(const char *path, char *name) xasprintf(&m.mime, "video/mpeg"); } break; - case CODEC_ID_MPEG2VIDEO: + case AV_CODEC_ID_MPEG2VIDEO: m.dlna_pn = malloc(64); off = sprintf(m.dlna_pn, "MPEG_"); if( strcmp(ctx->iformat->name, "mpegts") == 0 ) @@ -987,7 +943,7 @@ GetVideoMetadata(const char *path, char *name) m.dlna_pn = NULL; } break; - case CODEC_ID_H264: + case AV_CODEC_ID_H264: m.dlna_pn = malloc(128); off = sprintf(m.dlna_pn, "AVC_"); @@ -1005,11 +961,8 @@ GetVideoMetadata(const char *path, char *name) vc->height * vc->sample_aspect_ratio.den, 1024*1024); } - if (ctx->streams[video_stream]->r_frame_rate.den) - fps = ctx->streams[video_stream]->r_frame_rate.num / ctx->streams[video_stream]->r_frame_rate.den; - else - fps = 0; - interlaced = vc->time_base.den ? (ctx->streams[video_stream]->r_frame_rate.num / vc->time_base.den) : 0; + fps = lav_get_fps(ctx->streams[video_stream]); + interlaced = lav_get_interlaced(vc, ctx->streams[video_stream]); if( ((((vc->width == 1920 || vc->width == 1440) && vc->height == 1080) || (vc->width == 720 && vc->height == 480)) && fps == 59 && interlaced) || ((vc->width == 1280 && vc->height == 720) && fps == 59 && !interlaced) ) @@ -1298,7 +1251,7 @@ GetVideoMetadata(const char *path, char *name) } DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is h.264\n", video_stream, basepath); break; - case CODEC_ID_MPEG4: + case AV_CODEC_ID_MPEG4: fourcc[0] = vc->codec_tag & 0xff; fourcc[1] = vc->codec_tag>>8 & 0xff; fourcc[2] = vc->codec_tag>>16 & 0xff; @@ -1361,7 +1314,7 @@ GetVideoMetadata(const char *path, char *name) } } break; - case CODEC_ID_WMV3: + case AV_CODEC_ID_WMV3: /* I'm not 100% sure this is correct, but it works on everything I could get my hands on */ if( vc->extradata_size > 0 ) { @@ -1370,7 +1323,7 @@ GetVideoMetadata(const char *path, char *name) if( !((vc->extradata[0] >> 6) & 1) ) vc->profile = 0; } - case CODEC_ID_VC1: + case AV_CODEC_ID_VC1: if( strcmp(ctx->iformat->name, "asf") != 0 ) { DPRINTF(E_DEBUG, L_METADATA, "Skipping DLNA parsing for non-ASF VC1 file %s\n", path); @@ -1469,7 +1422,7 @@ GetVideoMetadata(const char *path, char *name) } } break; - case CODEC_ID_MSMPEG4V3: + case AV_CODEC_ID_MSMPEG4V3: xasprintf(&m.mime, "video/x-msvideo"); default: DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s [type %d]\n", -- 1.9.1