---------------------------------------------------------------------------
| 110 | |
| 111 | //--------------------------------------------------------------------------- |
| 112 | void File_Mpeg4_TimeCode::Streams_Finish() |
| 113 | { |
| 114 | if (Pos!=numeric_limits<int64s>::max()) |
| 115 | { |
| 116 | float64 FrameRate_WithDF; |
| 117 | if (tmcd_Duration && tmcd_Duration_TimeScale) |
| 118 | { |
| 119 | FrameRate_WithDF=(float64)tmcd_Duration_TimeScale/(float64)tmcd_Duration; |
| 120 | if (!NumberOfFrames) |
| 121 | NumberOfFrames=(int8u)float64_int64s(FrameRate_WithDF)/FrameMultiplier; |
| 122 | } |
| 123 | else |
| 124 | { |
| 125 | FrameRate_WithDF=NumberOfFrames; |
| 126 | if (DropFrame) |
| 127 | { |
| 128 | int FramesToRemove=0; |
| 129 | int NumberOfFramesMultiplier=0; |
| 130 | while (NumberOfFrames>NumberOfFramesMultiplier) |
| 131 | { |
| 132 | FramesToRemove+=108; |
| 133 | NumberOfFramesMultiplier+=30; |
| 134 | } |
| 135 | float64 FramesPerHour_NDF=FrameRate_WithDF*60*60; |
| 136 | FrameRate_WithDF*=(FramesPerHour_NDF-FramesToRemove)/FramesPerHour_NDF; |
| 137 | } |
| 138 | |
| 139 | } |
| 140 | |
| 141 | TimeCode TC((int64_t)Pos, NumberOfFrames-1, TimeCode::DropFrame(DropFrame)); |
| 142 | if (FrameMultiplier>1) |
| 143 | { |
| 144 | int64s Frames=TC.GetFrames(); |
| 145 | TC-=TC.GetFrames(); |
| 146 | TC=TimeCode((int64_t)(TC.ToFrames()*FrameMultiplier), NumberOfFrames*FrameMultiplier-1, TimeCode::DropFrame(DropFrame)); |
| 147 | TC+=Frames*FrameMultiplier; |
| 148 | } |
| 149 | Fill(Stream_Other, StreamPos_Last, Other_TimeCode_FirstFrame, TC.ToString().c_str()); |
| 150 | int64s FrameCount; |
| 151 | if (NumberOfFrames==mdhd_Duration_TimeScale) // Prioritize mdhd or edit list for in case there are drop frame and integer frame rate |
| 152 | { |
| 153 | if (FirstEditDuration!=(int64u)-1) |
| 154 | { |
| 155 | float64 FrameCountF=(float64)FirstEditDuration/mvhd_Duration_TimeScale*FrameRate_WithDF*FrameMultiplier; |
| 156 | FrameCount=(int64u)float64_int64s(FrameCountF); |
| 157 | if (FrameCountF-FrameCount>0.01) // TODO: avoid rouding issues and better way to manage partial frames |
| 158 | FrameCount++; |
| 159 | } |
| 160 | else |
| 161 | FrameCount=mdhd_Duration-FirstEditOffset; |
| 162 | } |
| 163 | else if (mvhd_Duration_TimeScale) |
| 164 | { |
| 165 | float64 FrameCountF=(float64)tkhd_Duration/mvhd_Duration_TimeScale*FrameRate_WithDF*FrameMultiplier; |
| 166 | FrameCount=(int64u)float64_int64s(FrameCountF); |
| 167 | if (FrameCountF-FrameCount>0.01) // TODO: avoid rouding issues and better way to manage partial frames |
| 168 | FrameCount++; |
| 169 | } |