From 987170cb9dd036d3372c8feac6074d13d1b84dd2 Mon Sep 17 00:00:00 2001 From: Mans Rullgard <mans@mansr.com> Date: Wed, 8 Aug 2012 17:30:15 +0100 Subject: dict: add av_dict_count() This adds a function to retrieve the number of entries in a dictionary and updates the places directly accessing what should be an opaque struct to use this new function instead. Signed-off-by: Mans Rullgard <mans@mansr.com> --- libavformat/asfenc.c | 2 +- libavformat/utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libavformat') diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 7c824a5db4..bcb741e04d 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -316,7 +316,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data duration = asf->duration + PREROLL_TIME * 10000; has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4]; - metadata_count = s->metadata ? s->metadata->count : 0; + metadata_count = av_dict_count(s->metadata); bit_rate = 0; for(n=0;n<s->nb_streams;n++) { diff --git a/libavformat/utils.c b/libavformat/utils.c index 435ffc1c68..b850abfe1d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3306,7 +3306,7 @@ static void print_fps(double d, const char *postfix){ static void dump_metadata(void *ctx, AVDictionary *m, const char *indent) { - if(m && !(m->count == 1 && av_dict_get(m, "language", NULL, 0))){ + if(m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))){ AVDictionaryEntry *tag=NULL; av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent); -- cgit v1.2.3 From 885da7b08289321b88919e86d1574c8683a95a22 Mon Sep 17 00:00:00 2001 From: Anton Khirnov <anton@khirnov.net> Date: Thu, 9 Aug 2012 18:39:56 +0200 Subject: lavf: simplify is_intra_only() by using codec descriptors. --- libavformat/utils.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) (limited to 'libavformat') diff --git a/libavformat/utils.c b/libavformat/utils.c index b850abfe1d..64c5260cec 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -789,30 +789,14 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st, } } -static int is_intra_only(AVCodecContext *enc){ - if(enc->codec_type == AVMEDIA_TYPE_AUDIO){ - return 1; - }else if(enc->codec_type == AVMEDIA_TYPE_VIDEO){ - switch(enc->codec_id){ - case AV_CODEC_ID_MJPEG: - case AV_CODEC_ID_MJPEGB: - case AV_CODEC_ID_LJPEG: - case AV_CODEC_ID_PRORES: - case AV_CODEC_ID_RAWVIDEO: - case AV_CODEC_ID_DVVIDEO: - case AV_CODEC_ID_HUFFYUV: - case AV_CODEC_ID_FFVHUFF: - case AV_CODEC_ID_ASV1: - case AV_CODEC_ID_ASV2: - case AV_CODEC_ID_VCR1: - case AV_CODEC_ID_DNXHD: - case AV_CODEC_ID_JPEG2000: - case AV_CODEC_ID_MDEC: - return 1; - default: break; - } - } - return 0; +static int is_intra_only(enum AVCodecID id) +{ + const AVCodecDescriptor *d = avcodec_descriptor_get(id); + if (!d) + return 0; + if (d->type == AVMEDIA_TYPE_VIDEO && !(d->props & AV_CODEC_PROP_INTRA_ONLY)) + return 0; + return 1; } static void update_initial_timestamps(AVFormatContext *s, int stream_index, @@ -1034,7 +1018,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, // av_log(NULL, AV_LOG_ERROR, "OUTdelayed:%d/%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64"\n", presentation_delayed, delay, pkt->pts, pkt->dts, st->cur_dts); /* update flags */ - if(is_intra_only(st->codec)) + if (is_intra_only(st->codec->codec_id)) pkt->flags |= AV_PKT_FLAG_KEY; if (pc) pkt->convergence_duration = pc->convergence_duration; -- cgit v1.2.3