| 68 | } |
| 69 | |
| 70 | void FFMS_Index::Finalize(std::vector<SharedAVContext> const& video_contexts, const char *Format) { |
| 71 | for (size_t i = 0, end = size(); i != end; ++i) { |
| 72 | FFMS_Track& track = (*this)[i]; |
| 73 | |
| 74 | if (!strcmp(Format, "mpeg") || !strcmp(Format, "mpegts") || !strcmp(Format, "mpegtsraw")) |
| 75 | if (std::any_of(track.begin(), track.end(), [](FrameInfo F) { return F.PTS == AV_NOPTS_VALUE; })) |
| 76 | track.RevertToDTS(); |
| 77 | |
| 78 | // Some audio tracks are simply insane junk (seen with als) and will have a single(?) super long packet and |
| 79 | // apart from that look legit and be chosen instead of usable audio. This hopefully rejects some of it. |
| 80 | // Caused by sample in https://github.com/FFMS/ffms2/issues/351 |
| 81 | if (track.TT == FFMS_TYPE_AUDIO) { |
| 82 | if (track.size() <= 10 && track.size() > 0 && track[0].SampleCount > 1000000) |
| 83 | track.clear(); |
| 84 | } |
| 85 | |
| 86 | // H.264 PAFF needs to have some frames hidden |
| 87 | // |
| 88 | // Don't send any WMV/ASF files, since they (as far as we know) cannot contain PAFF, |
| 89 | // but may also have valid, split packets, with pos equal to the previous pos. |
| 90 | if (video_contexts[i].CodecContext && video_contexts[i].CodecContext->codec_id == AV_CODEC_ID_H264 && !!strcmp(Format, "asf")) |
| 91 | track.MaybeHideFrames(); |
| 92 | |
| 93 | track.FinalizeTrack(); |
| 94 | |
| 95 | if (track.TT != FFMS_TYPE_VIDEO) continue; |
| 96 | |
| 97 | if (video_contexts[i].CodecContext && video_contexts[i].CodecContext->has_b_frames) { |
| 98 | track.MaxBFrames = video_contexts[i].CodecContext->has_b_frames; |
| 99 | continue; |
| 100 | } |
| 101 | |
| 102 | // Whether or not has_b_frames gets set during indexing seems |
| 103 | // to vary based on version of FFmpeg/Libav, so do an extra |
| 104 | // check for b-frames if it's 0. |
| 105 | for (size_t f = 0; f < track.size(); ++f) { |
| 106 | if (track[f].FrameType == AV_PICTURE_TYPE_B) { |
| 107 | track.MaxBFrames = 1; |
| 108 | break; |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | bool FFMS_Index::CompareFileSignature(const char *Filename) { |
| 115 | int64_t CFilesize; |
no test coverage detected