return 0;
}
-/**
- * Get the number of samples of an audio frame. Return -1 on error.
- */
-int ff_get_audio_frame_size(AVCodecContext *enc, int size, int mux)
-{
- int frame_size;
-
- /* give frame_size priority if demuxing */
- if (!mux && enc->frame_size > 1)
- return enc->frame_size;
-
- if ((frame_size = av_get_audio_frame_duration(enc, size)) > 0)
- return frame_size;
-
- /* Fall back on using frame_size if muxing. */
- if (enc->frame_size > 1)
- return enc->frame_size;
-
- //For WMA we currently have no other means to calculate duration thus we
- //do it here by assuming CBR, which is true for all known cases.
- if (!mux && enc->bit_rate>0 && size>0 && enc->sample_rate>0 && enc->block_align>1) {
- if (enc->codec_id == AV_CODEC_ID_WMAV1 || enc->codec_id == AV_CODEC_ID_WMAV2)
- return ((int64_t)size * 8 * enc->sample_rate) / enc->bit_rate;
- }
-
- return -1;
-}
-
/**
* Return the frame duration in seconds. Return 0 if not available.
*/
}
break;
case AVMEDIA_TYPE_AUDIO:
- frame_size = ff_get_audio_frame_size(st->codec, pkt->size, 0);
+ frame_size = av_get_audio_frame_duration(st->codec, pkt->size);
if (frame_size <= 0 || st->codec->sample_rate <= 0)
break;
*pnum = frame_size;
av_log(s, AV_LOG_ERROR, "read_timestamp() failed in the middle\n");
return -1;
}
- assert(ts != AV_NOPTS_VALUE);
if (target_ts <= ts) {
pos_limit = start_pos - 1;
pos_max = pos;
break;
if (st->first_dts == AV_NOPTS_VALUE &&
!(ic->iformat->flags & AVFMT_NOTIMESTAMPS) &&
+ st->codec_info_nb_frames < ic->max_ts_probe &&
(st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO))
break;
av_dict_free(&s->metadata);
av_freep(&s->streams);
av_freep(&s->internal);
+ flush_packet_queue(s);
av_free(s);
}
stream_id = strtol(spec, &endptr, 0);
if (!*endptr)
return stream_id == st->id;
+ } else if (*spec == 'm' && *(spec + 1) == ':') {
+ AVDictionaryEntry *tag;
+ char *key, *val;
+ int ret;
+
+ spec += 2;
+ val = strchr(spec, ':');
+
+ key = val ? av_strndup(spec, val - spec) : av_strdup(spec);
+ if (!key)
+ return AVERROR(ENOMEM);
+
+ tag = av_dict_get(st->metadata, key, NULL, 0);
+ if (tag) {
+ if (!val || !strcmp(tag->value, val + 1))
+ ret = 1;
+ else
+ ret = 0;
+ } else
+ ret = 0;
+
+ av_freep(&key);
+ return ret;
} else if (!*spec) /* empty specifier, matches everything */
return 1;