if (st->first_dts != AV_NOPTS_VALUE ||
dts == AV_NOPTS_VALUE ||
st->cur_dts == AV_NOPTS_VALUE ||
+ st->cur_dts < INT_MIN + RELATIVE_TS_BASE ||
is_relative(dts))
return;
else if (start_time > start_time_text)
av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream starttime %f\n", start_time_text / (float)AV_TIME_BASE);
- if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text - end_time < AV_TIME_BASE)) {
+ if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text - (uint64_t)end_time < AV_TIME_BASE)) {
end_time = end_time_text;
} else if (end_time < end_time_text) {
av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream endtime %f\n", end_time_text / (float)AV_TIME_BASE);
if (s->programs[i]->id != prog_id)
continue;
- if (*endptr++ == ':') {
- int stream_idx = strtol(endptr, NULL, 0);
- return stream_idx >= 0 &&
- stream_idx < s->programs[i]->nb_stream_indexes &&
- st->index == s->programs[i]->stream_index[stream_idx];
+ if (*endptr++ == ':') { // p:<id>:....
+ if ( *endptr == 'a' || *endptr == 'v' ||
+ *endptr == 's' || *endptr == 'd') { // p:<id>:<st_type>[:<index>]
+ enum AVMediaType type;
+
+ switch (*endptr++) {
+ case 'v': type = AVMEDIA_TYPE_VIDEO; break;
+ case 'a': type = AVMEDIA_TYPE_AUDIO; break;
+ case 's': type = AVMEDIA_TYPE_SUBTITLE; break;
+ case 'd': type = AVMEDIA_TYPE_DATA; break;
+ default: av_assert0(0);
+ }
+ if (*endptr++ == ':') { // p:<id>:<st_type>:<index>
+ int stream_idx = strtol(endptr, NULL, 0), type_counter = 0;
+ for (j = 0; j < s->programs[i]->nb_stream_indexes; j++) {
+ int stream_index = s->programs[i]->stream_index[j];
+ if (st->index == s->programs[i]->stream_index[j]) {
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ return type_counter == stream_idx &&
+ (type == st->codecpar->codec_type ||
+ type == st->codec->codec_type);
+FF_ENABLE_DEPRECATION_WARNINGS
+#else
+ return type_counter == stream_idx &&
+ type == st->codecpar->codec_type;
+#endif
+ }
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (type == s->streams[stream_index]->codecpar->codec_type ||
+ type == s->streams[stream_index]->codec->codec_type)
+ type_counter++;
+FF_ENABLE_DEPRECATION_WARNINGS
+#else
+ if (type == s->streams[stream_index]->codecpar->codec_type)
+ type_counter++;
+#endif
+ }
+ return 0;
+ } else { // p:<id>:<st_type>
+ for (j = 0; j < s->programs[i]->nb_stream_indexes; j++)
+ if (st->index == s->programs[i]->stream_index[j]) {
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ return type == st->codecpar->codec_type ||
+ type == st->codec->codec_type;
+FF_ENABLE_DEPRECATION_WARNINGS
+#else
+ return type == st->codecpar->codec_type;
+#endif
+ }
+ return 0;
+ }
+
+ } else if ( *endptr == 'm') { // p:<id>:m:<metadata_spec>
+ AVDictionaryEntry *tag;
+ char *key, *val;
+ int ret = 0;
+
+ if (*(++endptr) != ':') {
+ av_log(s, AV_LOG_ERROR, "Invalid stream specifier syntax, missing ':' sign after :m.\n");
+ return AVERROR(EINVAL);
+ }
+
+ val = strchr(++endptr, ':');
+ key = val ? av_strndup(endptr, val - endptr) : av_strdup(endptr);
+ if (!key)
+ return AVERROR(ENOMEM);
+
+ for (j = 0; j < s->programs[i]->nb_stream_indexes; j++)
+ if (st->index == s->programs[i]->stream_index[j]) {
+ tag = av_dict_get(st->metadata, key, NULL, 0);
+ if (tag && (!val || !strcmp(tag->value, val + 1)))
+ ret = 1;
+
+ break;
+ }
+
+ av_freep(&key);
+ return ret;
+
+ } else { // p:<id>:<index>
+ int stream_idx = strtol(endptr, NULL, 0);
+ return stream_idx >= 0 &&
+ stream_idx < s->programs[i]->nb_stream_indexes &&
+ st->index == s->programs[i]->stream_index[stream_idx];
+ }
}
for (j = 0; j < s->programs[i]->nb_stream_indexes; j++)