Skip to content

Bug: logic errors in Filter::Filter when handling stream indexes #1632

@programmerjake

Description

@programmerjake

here it checks against sources with the indexes into av_streams (filtered and maybe sorted, so not the same as ffmpeg's stream indexes):

while (true) {
if (index == av_streams.size()) {
graph = nullptr;
return;
}
if (av_streams.at(index)->codecpar->codec_type == type &&
sources.find(static_cast<int>(index)) == sources.end()) {
break;
}
index++;
}
index = av_streams.at(index)->index;

later it inserts into sources with the actual ffmpeg stream indexes:

sources.emplace(index, source);

sources.emplace(index, source);

also, sorting streams by height and then alphamerge-ing them if there's more than 1 seems incredibly sketchy:

if (video_input_count == 1) {
std::stable_sort(av_streams.begin(), av_streams.end(), [](auto lhs, auto rhs) {
return lhs->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && lhs->codecpar->height > rhs->codecpar->height;
});
std::vector<AVStream*> video_av_streams;
std::copy_if(av_streams.begin(), av_streams.end(), std::back_inserter(video_av_streams), [](auto s) {
return s->codecpar->codec_type == AVMEDIA_TYPE_VIDEO;
});
// TODO (fix) Use some form of stream meta data to do this.
// https://github.com/CasparCG/server/issues/832
if (video_av_streams.size() >= 2 &&
video_av_streams[0]->codecpar->height == video_av_streams[1]->codecpar->height) {
filter_spec = "alphamerge," + filter_spec;
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions