| 613 | } |
| 614 | |
| 615 | void FFMS_VideoSource::SetVideoProperties() { |
| 616 | VP.RFFDenominator = FormatContext->streams[VideoTrack]->time_base.num; |
| 617 | VP.RFFNumerator = FormatContext->streams[VideoTrack]->time_base.den; |
| 618 | if (CodecContext->codec_id == AV_CODEC_ID_H264) { |
| 619 | if (VP.RFFNumerator & 1) |
| 620 | VP.RFFDenominator *= 2; |
| 621 | else |
| 622 | VP.RFFNumerator /= 2; |
| 623 | } |
| 624 | VP.NumFrames = Frames.VisibleFrameCount(); |
| 625 | VP.TopFieldFirst = !!(DecodeFrame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST); |
| 626 | VP.ColorSpace = CodecContext->colorspace; |
| 627 | VP.ColorRange = CodecContext->color_range; |
| 628 | // these pixfmt's are deprecated but still used |
| 629 | if (CodecContext->pix_fmt == AV_PIX_FMT_YUVJ420P || |
| 630 | CodecContext->pix_fmt == AV_PIX_FMT_YUVJ422P || |
| 631 | CodecContext->pix_fmt == AV_PIX_FMT_YUVJ444P |
| 632 | ) |
| 633 | VP.ColorRange = AVCOL_RANGE_JPEG; |
| 634 | |
| 635 | |
| 636 | VP.FirstTime = ((Frames[Frames.RealFrameNumber(0)].PTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; |
| 637 | VP.LastTime = ((Frames[Frames.RealFrameNumber(Frames.VisibleFrameCount()-1)].PTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; |
| 638 | VP.LastEndTime = (((Frames[Frames.RealFrameNumber(Frames.VisibleFrameCount()-1)].PTS + Frames.LastDuration) * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; |
| 639 | |
| 640 | if (CodecContext->width <= 0 || CodecContext->height <= 0) |
| 641 | throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC, |
| 642 | "Codec returned zero size video"); |
| 643 | |
| 644 | // attempt to correct framerate to the proper NTSC fraction, if applicable |
| 645 | CorrectRationalFramerate(&VP.FPSNumerator, &VP.FPSDenominator); |
| 646 | // correct the timebase, if necessary |
| 647 | CorrectTimebase(&VP, &Frames.TB); |
| 648 | |
| 649 | // Set AR variables |
| 650 | VP.SARNum = CodecContext->sample_aspect_ratio.num; |
| 651 | VP.SARDen = CodecContext->sample_aspect_ratio.den; |
| 652 | |
| 653 | // Set input and output formats now that we have a CodecContext |
| 654 | DetectInputFormat(); |
| 655 | |
| 656 | OutputFormat = InputFormat; |
| 657 | OutputColorSpace = InputColorSpace; |
| 658 | OutputColorRange = InputColorRange; |
| 659 | } |
| 660 | |
| 661 | bool FFMS_VideoSource::HasPendingDelayedFrames() { |
| 662 | if (Stage == DecodeStage::APPLY_DELAY) { |
nothing calls this directly
no test coverage detected