diff --git a/libav.h b/libav.h index 01da752..f04bb42 100644 --- a/libav.h +++ b/libav.h @@ -155,12 +155,54 @@ lav_get_fps(AVStream *s) } static inline int -lav_get_interlaced(AVCodecContext *vc, AVStream *s) +lav_get_interlaced(AVStream *s) { -#if LIBAVCODEC_VERSION_MAJOR < 54 - return (vc->time_base.den ? (s->r_frame_rate.num / vc->time_base.den) : 0); +#if LIBAVCODEC_VERSION_MAJOR >= 57 + return (s->time_base.den ? (s->avg_frame_rate.num / s->time_base.den) : 0); +#elif LIBAVCODEC_VERSION_MAJOR >= 54 + return (s->codec->time_base.den ? (s->avg_frame_rate.num / s->codec->time_base.den) : 0); #else - return (vc->time_base.den ? (s->avg_frame_rate.num / vc->time_base.den) : 0); + return (s->codec->time_base.den ? (s->r_frame_rate.num / s->codec->time_base.den) : 0); +#endif +} + +#if LIBAVCODEC_VERSION_MAJOR >= 57 +#define lav_codec_id(s) s->codecpar->codec_id +#define lav_codec_type(s) s->codecpar->codec_type +#define lav_codec_tag(s) s->codecpar->codec_tag +#define lav_sample_rate(s) s->codecpar->sample_rate +#define lav_bit_rate(s) s->codecpar->bit_rate +#define lav_channels(s) s->codecpar->channels +#define lav_width(s) s->codecpar->width +#define lav_height(s) s->codecpar->height +#define lav_profile(s) s->codecpar->profile +#define lav_level(s) s->codecpar->level +#define lav_sample_aspect_ratio(s) s->codecpar->sample_aspect_ratio +#else +#define lav_codec_id(x) x->codec->codec_id +#define lav_codec_type(s) s->codec->codec_type +#define lav_codec_tag(s) s->codec->codec_tag +#define lav_sample_rate(s) s->codec->sample_rate +#define lav_bit_rate(s) s->codec->bit_rate +#define lav_channels(s) s->codec->channels +#define lav_width(s) s->codec->width +#define lav_height(s) s->codec->height +#define lav_profile(s) s->codec->profile +#define lav_level(s) s->codec->level +#define lav_sample_aspect_ratio(s) s->codec->sample_aspect_ratio +#endif + +static inline uint8_t * +lav_codec_extradata(AVStream *s) +{ +#if LIBAVCODEC_VERSION_MAJOR >= 57 + if (!s->codecpar->extradata_size) + return NULL; + return s->codecpar->extradata; +#else + if (!s->codec->extradata_size) + return NULL; + return s->codec->extradata; #endif } @@ -169,7 +211,7 @@ lav_is_thumbnail_stream(AVStream *s, uint8_t **data, int *size) { #if LIBAVFORMAT_VERSION_INT >= ((54<<16)+(6<<8)) if (s->disposition & AV_DISPOSITION_ATTACHED_PIC && - s->codec->codec_id == AV_CODEC_ID_MJPEG) + lav_codec_id(s) == AV_CODEC_ID_MJPEG) { if (data) *data = s->attached_pic.data; diff --git a/metadata.c b/metadata.c index 2bfa8b9..72dc396 100644 --- a/metadata.c +++ b/metadata.c @@ -663,7 +663,7 @@ GetVideoMetadata(const char *path, char *name) int ret, i; struct tm *modtime; AVFormatContext *ctx = NULL; - AVCodecContext *ac = NULL, *vc = NULL; + AVStream *astream = NULL, *vstream = NULL; int audio_stream = -1, video_stream = -1; enum audio_profiles audio_profile = PROFILE_AUDIO_UNKNOWN; char fourcc[4]; @@ -692,27 +692,27 @@ GetVideoMetadata(const char *path, char *name) return 0; } //dump_format(ctx, 0, NULL, 0); - for( i=0; inb_streams; i++) + for( i=0; i < ctx->nb_streams; i++) { - if( ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO && + if( lav_codec_type(ctx->streams[i]) == AVMEDIA_TYPE_AUDIO && audio_stream == -1 ) { audio_stream = i; - ac = ctx->streams[audio_stream]->codec; + astream = ctx->streams[audio_stream]; continue; } - else if( ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO && + else if( lav_codec_type(ctx->streams[i]) == AVMEDIA_TYPE_VIDEO && !lav_is_thumbnail_stream(ctx->streams[i], &m.thumb_data, &m.thumb_size) && video_stream == -1 ) { video_stream = i; - vc = ctx->streams[video_stream]->codec; + vstream = ctx->streams[video_stream]; continue; } } path_cpy = strdup(path); basepath = basename(path_cpy); - if( !vc ) + if( !vstream ) { /* This must not be a video file. */ lav_close(ctx); @@ -722,24 +722,23 @@ GetVideoMetadata(const char *path, char *name) return 0; } - if( ac ) + if( astream ) { aac_object_type_t aac_type = AAC_INVALID; - switch( ac->codec_id ) + switch( lav_codec_id(astream) ) { case AV_CODEC_ID_MP3: audio_profile = PROFILE_AUDIO_MP3; break; case AV_CODEC_ID_AAC: - if( !ac->extradata_size || - !ac->extradata ) + if( !lav_codec_extradata(astream) ) { DPRINTF(E_DEBUG, L_METADATA, "No AAC type\n"); } else { uint8_t data; - memcpy(&data, ac->extradata, 1); + memcpy(&data, lav_codec_extradata(astream), 1); aac_type = data >> 3; } switch( aac_type ) @@ -747,24 +746,24 @@ GetVideoMetadata(const char *path, char *name) /* AAC Low Complexity variants */ case AAC_LC: case AAC_LC_ER: - if( ac->sample_rate < 8000 || - ac->sample_rate > 48000 ) + if( lav_sample_rate(astream) < 8000 || + lav_sample_rate(astream) > 48000 ) { DPRINTF(E_DEBUG, L_METADATA, "Unsupported AAC: sample rate is not 8000 < %d < 48000\n", - ac->sample_rate); + lav_sample_rate(astream)); break; } /* AAC @ Level 1/2 */ - if( ac->channels <= 2 && - ac->bit_rate <= 576000 ) + if( lav_channels(astream) <= 2 && + lav_bit_rate(astream) <= 576000 ) audio_profile = PROFILE_AUDIO_AAC; - else if( ac->channels <= 6 && - ac->bit_rate <= 1440000 ) + else if( lav_channels(astream) <= 6 && + lav_bit_rate(astream) <= 1440000 ) audio_profile = PROFILE_AUDIO_AAC_MULT5; else - DPRINTF(E_DEBUG, L_METADATA, "Unhandled AAC: %d channels, %d bitrate\n", - ac->channels, - ac->bit_rate); + DPRINTF(E_DEBUG, L_METADATA, "Unhandled AAC: %lld channels, %lld bitrate\n", + (long long)lav_channels(astream), + (long long)lav_bit_rate(astream)); break; default: DPRINTF(E_DEBUG, L_METADATA, "Unhandled AAC type [%d]\n", aac_type); @@ -778,10 +777,10 @@ GetVideoMetadata(const char *path, char *name) 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 ) + if ( lav_bit_rate(astream) <= 193000 ) audio_profile = PROFILE_AUDIO_WMA_BASE; /* WMA Full: stereo, up to 48 KHz, up to 385 Kbps */ - else if ( ac->bit_rate <= 385000 ) + else if ( lav_bit_rate(astream) <= 385000 ) audio_profile = PROFILE_AUDIO_WMA_FULL; break; case AV_CODEC_ID_WMAPRO: @@ -794,23 +793,23 @@ GetVideoMetadata(const char *path, char *name) audio_profile = PROFILE_AUDIO_AMR; break; default: - if( (ac->codec_id >= AV_CODEC_ID_PCM_S16LE) && - (ac->codec_id < AV_CODEC_ID_ADPCM_IMA_QT) ) + if( (lav_codec_id(astream) >= AV_CODEC_ID_PCM_S16LE) && + (lav_codec_id(astream) < 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); + DPRINTF(E_DEBUG, L_METADATA, "Unhandled audio codec [0x%X]\n", lav_codec_id(astream)); break; } - m.frequency = ac->sample_rate; - m.channels = ac->channels; + m.frequency = lav_sample_rate(astream); + m.channels = lav_channels(astream); } - if( vc ) + if( vstream ) { int off; int duration, hours, min, sec, ms; ts_timestamp_t ts_timestamp = NONE; DPRINTF(E_DEBUG, L_METADATA, "Container: '%s' [%s]\n", ctx->iformat->name, basepath); - xasprintf(&m.resolution, "%dx%d", vc->width, vc->height); + xasprintf(&m.resolution, "%dx%d", lav_width(vstream), lav_height(vstream)); if( ctx->bit_rate > 8 ) m.bitrate = ctx->bit_rate / 8; if( ctx->duration > 0 ) { @@ -827,12 +826,12 @@ GetVideoMetadata(const char *path, char *name) if( strcmp(ctx->iformat->name, "avi") == 0 ) { xasprintf(&m.mime, "video/x-msvideo"); - if( vc->codec_id == AV_CODEC_ID_MPEG4 ) + if( lav_codec_id(vstream) == AV_CODEC_ID_MPEG4 ) { - fourcc[0] = vc->codec_tag & 0xff; - fourcc[1] = vc->codec_tag>>8 & 0xff; - fourcc[2] = vc->codec_tag>>16 & 0xff; - fourcc[3] = vc->codec_tag>>24 & 0xff; + fourcc[0] = lav_codec_tag(vstream) & 0xff; + fourcc[1] = lav_codec_tag(vstream)>>8 & 0xff; + fourcc[2] = lav_codec_tag(vstream)>>16 & 0xff; + fourcc[3] = lav_codec_tag(vstream)>>24 & 0xff; if( memcmp(fourcc, "XVID", 4) == 0 || memcmp(fourcc, "DX50", 4) == 0 || memcmp(fourcc, "DIVX", 4) == 0 ) @@ -849,13 +848,13 @@ GetVideoMetadata(const char *path, char *name) if( m.mime ) goto video_no_dlna; - switch( vc->codec_id ) + switch( lav_codec_id(vstream) ) { case AV_CODEC_ID_MPEG1VIDEO: if( strcmp(ctx->iformat->name, "mpeg") == 0 ) { - if( (vc->width == 352) && - (vc->height <= 288) ) + if( (lav_width(vstream) == 352) && + (lav_height(vstream) <= 288) ) { m.dlna_pn = strdup("MPEG1"); } @@ -872,16 +871,16 @@ GetVideoMetadata(const char *path, char *name) DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s MPEG2 TS packet size %d\n", video_stream, basepath, m.resolution, raw_packet_size); off += sprintf(m.dlna_pn+off, "TS_"); - if( (vc->width >= 1280) && - (vc->height >= 720) ) + if( (lav_width(vstream) >= 1280) && + (lav_height(vstream) >= 720) ) { off += sprintf(m.dlna_pn+off, "HD_NA"); } else { off += sprintf(m.dlna_pn+off, "SD_"); - if( (vc->height == 576) || - (vc->height == 288) ) + if( (lav_height(vstream) == 576) || + (lav_height(vstream) == 288) ) off += sprintf(m.dlna_pn+off, "EU"); else off += sprintf(m.dlna_pn+off, "NA"); @@ -920,8 +919,8 @@ GetVideoMetadata(const char *path, char *name) DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s MPEG2 PS\n", video_stream, basepath, m.resolution); off += sprintf(m.dlna_pn+off, "PS_"); - if( (vc->height == 576) || - (vc->height == 288) ) + if( (lav_height(vstream) == 576) || + (lav_height(vstream) == 288) ) off += sprintf(m.dlna_pn+off, "PAL"); else off += sprintf(m.dlna_pn+off, "NTSC"); @@ -947,53 +946,53 @@ GetVideoMetadata(const char *path, char *name) int dlna_ts_present = dlna_timestamp_is_present(path, &raw_packet_size); off += sprintf(m.dlna_pn+off, "TS_"); - if (vc->sample_aspect_ratio.num) { + if (lav_sample_aspect_ratio(vstream).num) { av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, - vc->width * vc->sample_aspect_ratio.num, - vc->height * vc->sample_aspect_ratio.den, + lav_width(vstream) * lav_sample_aspect_ratio(vstream).num, + lav_height(vstream) * lav_sample_aspect_ratio(vstream).den, 1024*1024); } - 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) ) + fps = lav_get_fps(vstream); + interlaced = lav_get_interlaced(vstream); + if( ((((lav_width(vstream) == 1920 || lav_width(vstream) == 1440) && lav_height(vstream) == 1080) || + (lav_width(vstream) == 720 && lav_height(vstream) == 480)) && fps == 59 && interlaced) || + ((lav_width(vstream) == 1280 && lav_height(vstream) == 720) && fps == 59 && !interlaced) ) { - if( (vc->profile == FF_PROFILE_H264_MAIN || vc->profile == FF_PROFILE_H264_HIGH) && + if( (lav_profile(vstream) == FF_PROFILE_H264_MAIN || lav_profile(vstream) == FF_PROFILE_H264_HIGH) && audio_profile == PROFILE_AUDIO_AC3 ) { off += sprintf(m.dlna_pn+off, "HD_60_"); - vc->profile = FF_PROFILE_SKIP; + lav_profile(vstream) = FF_PROFILE_SKIP; } } - else if( ((vc->width == 1920 && vc->height == 1080) || - (vc->width == 1440 && vc->height == 1080) || - (vc->width == 1280 && vc->height == 720) || - (vc->width == 720 && vc->height == 576)) && + else if( ((lav_width(vstream) == 1920 && lav_height(vstream) == 1080) || + (lav_width(vstream) == 1440 && lav_height(vstream) == 1080) || + (lav_width(vstream) == 1280 && lav_height(vstream) == 720) || + (lav_width(vstream) == 720 && lav_height(vstream) == 576)) && interlaced && fps == 50 ) { - if( (vc->profile == FF_PROFILE_H264_MAIN || vc->profile == FF_PROFILE_H264_HIGH) && + if( (lav_profile(vstream) == FF_PROFILE_H264_MAIN || lav_profile(vstream) == FF_PROFILE_H264_HIGH) && audio_profile == PROFILE_AUDIO_AC3 ) { off += sprintf(m.dlna_pn+off, "HD_50_"); - vc->profile = FF_PROFILE_SKIP; + lav_profile(vstream) = FF_PROFILE_SKIP; } } - switch( vc->profile ) + switch( lav_profile(vstream) ) { case FF_PROFILE_H264_BASELINE: case FF_PROFILE_H264_CONSTRAINED_BASELINE: off += sprintf(m.dlna_pn+off, "BL_"); - if( vc->width <= 352 && - vc->height <= 288 && - vc->bit_rate <= 384000 ) + if( lav_width(vstream) <= 352 && + lav_height(vstream) <= 288 && + lav_bit_rate(vstream) <= 384000 ) { off += sprintf(m.dlna_pn+off, "CIF15_"); break; } - else if( vc->width <= 352 && - vc->height <= 288 && - vc->bit_rate <= 3000000 ) + else if( lav_width(vstream) <= 352 && + lav_height(vstream) <= 288 && + lav_bit_rate(vstream) <= 3000000 ) { off += sprintf(m.dlna_pn+off, "CIF30_"); break; @@ -1004,46 +1003,47 @@ GetVideoMetadata(const char *path, char *name) default: case FF_PROFILE_H264_MAIN: off += sprintf(m.dlna_pn+off, "MP_"); - if( vc->profile != FF_PROFILE_H264_BASELINE && - vc->profile != FF_PROFILE_H264_CONSTRAINED_BASELINE && - vc->profile != FF_PROFILE_H264_MAIN ) + if( lav_profile(vstream) != FF_PROFILE_H264_BASELINE && + lav_profile(vstream) != FF_PROFILE_H264_CONSTRAINED_BASELINE && + lav_profile(vstream) != FF_PROFILE_H264_MAIN ) { DPRINTF(E_DEBUG, L_METADATA, "Unknown AVC profile %d; assuming MP. [%s]\n", - vc->profile, basepath); + lav_profile(vstream), basepath); } - if( vc->width <= 720 && - vc->height <= 576 && - vc->bit_rate <= 10000000 ) + if( lav_width(vstream) <= 720 && + lav_height(vstream) <= 576 && + lav_bit_rate(vstream) <= 10000000 ) { off += sprintf(m.dlna_pn+off, "SD_"); } - else if( vc->width <= 1920 && - vc->height <= 1152 && - vc->bit_rate <= 20000000 ) + else if( lav_width(vstream) <= 1920 && + lav_height(vstream) <= 1152 && + lav_bit_rate(vstream) <= 20000000 ) { off += sprintf(m.dlna_pn+off, "HD_"); } else { - DPRINTF(E_DEBUG, L_METADATA, "Unsupported h.264 video profile! [%s, %dx%d, %dbps : %s]\n", - m.dlna_pn, vc->width, vc->height, vc->bit_rate, basepath); + DPRINTF(E_DEBUG, L_METADATA, "Unsupported h.264 video profile! [%s, %dx%d, %lldbps : %s]\n", + m.dlna_pn, lav_width(vstream), lav_height(vstream), + (long long)lav_bit_rate(vstream), basepath); free(m.dlna_pn); m.dlna_pn = NULL; } break; case FF_PROFILE_H264_HIGH: off += sprintf(m.dlna_pn+off, "HP_"); - if( vc->width <= 1920 && - vc->height <= 1152 && - vc->bit_rate <= 30000000 && + if( lav_width(vstream) <= 1920 && + lav_height(vstream) <= 1152 && + lav_bit_rate(vstream) <= 30000000 && audio_profile == PROFILE_AUDIO_AC3 ) { off += sprintf(m.dlna_pn+off, "HD_"); } else { - DPRINTF(E_DEBUG, L_METADATA, "Unsupported h.264 HP video profile! [%dbps, %d audio : %s]\n", - vc->bit_rate, audio_profile, basepath); + DPRINTF(E_DEBUG, L_METADATA, "Unsupported h.264 HP video profile! [%lldbps, %d audio : %s]\n", + (long long)lav_bit_rate(vstream), audio_profile, basepath); free(m.dlna_pn); m.dlna_pn = NULL; } @@ -1076,7 +1076,7 @@ GetVideoMetadata(const char *path, char *name) break; if( raw_packet_size == MPEG_TS_PACKET_LENGTH_DLNA ) { - if( vc->profile == FF_PROFILE_H264_HIGH || + if( lav_profile(vstream) == FF_PROFILE_H264_HIGH || dlna_ts_present ) ts_timestamp = VALID; else @@ -1107,11 +1107,11 @@ GetVideoMetadata(const char *path, char *name) { off += sprintf(m.dlna_pn+off, "MP4_"); - switch( vc->profile ) { + switch( lav_profile(vstream) ) { case FF_PROFILE_H264_BASELINE: case FF_PROFILE_H264_CONSTRAINED_BASELINE: - if( vc->width <= 352 && - vc->height <= 288 ) + if( lav_width(vstream) <= 352 && + lav_height(vstream) <= 288 ) { if( ctx->bit_rate < 600000 ) off += sprintf(m.dlna_pn+off, "BL_CIF15_"); @@ -1147,28 +1147,28 @@ GetVideoMetadata(const char *path, char *name) goto mp4_mp_fallback; } } - else if( vc->width <= 720 && - vc->height <= 576 ) + else if( lav_width(vstream) <= 720 && + lav_height(vstream) <= 576 ) { - if( vc->level == 30 && + if( lav_level(vstream) == 30 && audio_profile == PROFILE_AUDIO_AAC && ctx->bit_rate <= 5000000 ) off += sprintf(m.dlna_pn+off, "BL_L3L_SD_AAC"); - else if( vc->level <= 31 && + else if( lav_level(vstream) <= 31 && audio_profile == PROFILE_AUDIO_AAC && ctx->bit_rate <= 15000000 ) off += sprintf(m.dlna_pn+off, "BL_L31_HD_AAC"); else goto mp4_mp_fallback; } - else if( vc->width <= 1280 && - vc->height <= 720 ) + else if( lav_width(vstream) <= 1280 && + lav_height(vstream) <= 720 ) { - if( vc->level <= 31 && + if( lav_level(vstream) <= 31 && audio_profile == PROFILE_AUDIO_AAC && ctx->bit_rate <= 15000000 ) off += sprintf(m.dlna_pn+off, "BL_L31_HD_AAC"); - else if( vc->level <= 32 && + else if( lav_level(vstream) <= 32 && audio_profile == PROFILE_AUDIO_AAC && ctx->bit_rate <= 21000000 ) off += sprintf(m.dlna_pn+off, "BL_L32_HD_AAC"); @@ -1182,9 +1182,9 @@ GetVideoMetadata(const char *path, char *name) mp4_mp_fallback: off += sprintf(m.dlna_pn+off, "MP_"); /* AVC MP4 SD profiles - 10 Mbps max */ - if( vc->width <= 720 && - vc->height <= 576 && - vc->bit_rate <= 10000000 ) + if( lav_width(vstream) <= 720 && + lav_height(vstream) <= 576 && + lav_bit_rate(vstream) <= 10000000 ) { sprintf(m.dlna_pn+off, "SD_"); if( audio_profile == PROFILE_AUDIO_AC3 ) @@ -1197,16 +1197,16 @@ GetVideoMetadata(const char *path, char *name) else m.dlna_pn[10] = '\0'; } - else if( vc->width <= 1280 && - vc->height <= 720 && - vc->bit_rate <= 15000000 && + else if( lav_width(vstream) <= 1280 && + lav_height(vstream) <= 720 && + lav_bit_rate(vstream) <= 15000000 && audio_profile == PROFILE_AUDIO_AAC ) { off += sprintf(m.dlna_pn+off, "HD_720p_AAC"); } - else if( vc->width <= 1920 && - vc->height <= 1080 && - vc->bit_rate <= 21000000 && + else if( lav_width(vstream) <= 1920 && + lav_height(vstream) <= 1080 && + lav_bit_rate(vstream) <= 21000000 && audio_profile == PROFILE_AUDIO_AAC ) { off += sprintf(m.dlna_pn+off, "HD_1080i_AAC"); @@ -1220,9 +1220,9 @@ GetVideoMetadata(const char *path, char *name) } break; case FF_PROFILE_H264_HIGH: - if( vc->width <= 1920 && - vc->height <= 1080 && - vc->bit_rate <= 25000000 && + if( lav_width(vstream) <= 1920 && + lav_height(vstream) <= 1080 && + lav_bit_rate(vstream) <= 25000000 && audio_profile == PROFILE_AUDIO_AAC ) { off += sprintf(m.dlna_pn+off, "HP_HD_AAC"); @@ -1230,7 +1230,7 @@ GetVideoMetadata(const char *path, char *name) break; default: DPRINTF(E_DEBUG, L_METADATA, "AVC profile [%d] not recognized for file %s\n", - vc->profile, basepath); + lav_profile(vstream), basepath); free(m.dlna_pn); m.dlna_pn = NULL; break; @@ -1244,17 +1244,17 @@ GetVideoMetadata(const char *path, char *name) DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is h.264\n", video_stream, basepath); break; 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; - fourcc[3] = vc->codec_tag>>24 & 0xff; + fourcc[0] = lav_codec_tag(vstream) & 0xff; + fourcc[1] = lav_codec_tag(vstream)>>8 & 0xff; + fourcc[2] = lav_codec_tag(vstream)>>16 & 0xff; + fourcc[3] = lav_codec_tag(vstream)>>24 & 0xff; DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is MPEG4 [%c%c%c%c/0x%X]\n", video_stream, basepath, isprint(fourcc[0]) ? fourcc[0] : '_', isprint(fourcc[1]) ? fourcc[1] : '_', isprint(fourcc[2]) ? fourcc[2] : '_', isprint(fourcc[3]) ? fourcc[3] : '_', - vc->codec_tag); + lav_codec_tag(vstream)); if( strcmp(ctx->iformat->name, "mov,mp4,m4a,3gp,3g2,mj2") == 0 ) { @@ -1274,7 +1274,7 @@ GetVideoMetadata(const char *path, char *name) break; default: DPRINTF(E_DEBUG, L_METADATA, "No DLNA profile found for MPEG4-P2 3GP/0x%X file %s\n", - ac->codec_id, basepath); + lav_codec_id(astream), basepath); free(m.dlna_pn); m.dlna_pn = NULL; break; @@ -1288,18 +1288,18 @@ GetVideoMetadata(const char *path, char *name) off += sprintf(m.dlna_pn+off, "MP4_ASP_AAC"); } else if( ctx->bit_rate <= 4000000 && - vc->width <= 640 && - vc->height <= 480 && + lav_width(vstream) <= 640 && + lav_height(vstream) <= 480 && audio_profile == PROFILE_AUDIO_AAC ) { off += sprintf(m.dlna_pn+off, "MP4_SP_VGA_AAC"); } else { - DPRINTF(E_DEBUG, L_METADATA, "Unsupported h.264 video profile! [%dx%d, %dbps]\n", - vc->width, - vc->height, - ctx->bit_rate); + DPRINTF(E_DEBUG, L_METADATA, "Unsupported h.264 video profile! [%dx%d, %lldbps]\n", + lav_width(vstream), + lav_height(vstream), + (long long)ctx->bit_rate); free(m.dlna_pn); m.dlna_pn = NULL; } @@ -1308,12 +1308,12 @@ GetVideoMetadata(const char *path, char *name) break; 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 ) + if( lav_codec_extradata(vstream) ) { - if( !((vc->extradata[0] >> 3) & 1) ) - vc->level = 0; - if( !((vc->extradata[0] >> 6) & 1) ) - vc->profile = 0; + if( !((lav_codec_extradata(vstream)[0] >> 3) & 1) ) + lav_level(vstream) = 0; + if( !((lav_codec_extradata(vstream)[0] >> 6) & 1) ) + lav_profile(vstream) = 0; } case AV_CODEC_ID_VC1: if( strcmp(ctx->iformat->name, "asf") != 0 ) @@ -1325,9 +1325,9 @@ GetVideoMetadata(const char *path, char *name) off = sprintf(m.dlna_pn, "WMV"); DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is VC1\n", video_stream, basepath); xasprintf(&m.mime, "video/x-ms-wmv"); - if( (vc->width <= 176) && - (vc->height <= 144) && - (vc->level == 0) ) + if( (lav_width(vstream) <= 176) && + (lav_height(vstream) <= 144) && + (lav_level(vstream) == 0) ) { off += sprintf(m.dlna_pn+off, "SPLL_"); switch( audio_profile ) @@ -1346,9 +1346,9 @@ GetVideoMetadata(const char *path, char *name) break; } } - else if( (vc->width <= 352) && - (vc->height <= 288) && - (vc->profile == 0) && + else if( (lav_width(vstream) <= 352) && + (lav_height(vstream) <= 288) && + (lav_profile(vstream) == 0) && (ctx->bit_rate/8 <= 384000) ) { off += sprintf(m.dlna_pn+off, "SPML_"); @@ -1368,8 +1368,8 @@ GetVideoMetadata(const char *path, char *name) break; } } - else if( (vc->width <= 720) && - (vc->height <= 576) && + else if( (lav_width(vstream) <= 720) && + (lav_height(vstream) <= 576) && (ctx->bit_rate/8 <= 10000000) ) { off += sprintf(m.dlna_pn+off, "MED_"); @@ -1392,8 +1392,8 @@ GetVideoMetadata(const char *path, char *name) break; } } - else if( (vc->width <= 1920) && - (vc->height <= 1080) && + else if( (lav_width(vstream) <= 1920) && + (lav_height(vstream) <= 1080) && (ctx->bit_rate/8 <= 20000000) ) { off += sprintf(m.dlna_pn+off, "HIGH_"); @@ -1418,7 +1418,7 @@ GetVideoMetadata(const char *path, char *name) xasprintf(&m.mime, "video/x-msvideo"); default: DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s [type %d]\n", - video_stream, basepath, m.resolution, vc->codec_id); + video_stream, basepath, m.resolution, lav_codec_id(vstream)); break; } }