1111#include < stdexcept>
1212#include < string_view>
1313#include " src/torchcodec/decoders/_core/DeviceInterface.h"
14+ #include " c10/util/Logging.h"
1415#include " torch/types.h"
1516
1617extern " C" {
@@ -657,7 +658,6 @@ bool VideoDecoder::canWeAvoidSeekingForStream(
657658// AVFormatContext if it is needed. We can skip seeking in certain cases. See
658659// the comment of canWeAvoidSeeking() for details.
659660void VideoDecoder::maybeSeekToBeforeDesiredPts () {
660- std::cerr << " maybeSeekToBeforeDesiredPts" << std::endl;
661661 if (activeStreamIndices_.size () == 0 ) {
662662 return ;
663663 }
@@ -677,9 +677,6 @@ void VideoDecoder::maybeSeekToBeforeDesiredPts() {
677677 int64_t desiredPtsForStream = *maybeDesiredPts_ * streamInfo.timeBase .den ;
678678 if (!canWeAvoidSeekingForStream (
679679 streamInfo, streamInfo.currentPts , desiredPtsForStream)) {
680- VLOG (5 ) << " Seeking is needed for streamIndex=" << streamIndex
681- << " desiredPts=" << desiredPtsForStream
682- << " currentPts=" << streamInfo.currentPts ;
683680 mustSeek = true ;
684681 break ;
685682 }
@@ -724,20 +721,14 @@ void VideoDecoder::maybeSeekToBeforeDesiredPts() {
724721
725722VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter (
726723 std::function<bool (int , AVFrame*)> filterFunction) {
727- std::cerr << " getDecodedOutputWithFilter" << std::endl;
728724 auto start = std::chrono::high_resolution_clock::now ();
729725 if (activeStreamIndices_.size () == 0 ) {
730726 throw std::runtime_error (" No active streams configured." );
731727 }
732- VLOG (9 ) << " Starting getDecodedOutputWithFilter()" ;
733728 resetDecodeStats ();
734729 if (maybeDesiredPts_.has_value ()) {
735- std::cerr << " \t has value" << std::endl;
736- VLOG (9 ) << " maybeDesiredPts_=" << *maybeDesiredPts_;
737- std::cerr << " \t logged pts" << std::endl;
738730 maybeSeekToBeforeDesiredPts ();
739731 maybeDesiredPts_ = std::nullopt ;
740- VLOG (9 ) << " seeking done" ;
741732 }
742733 auto seekDone = std::chrono::high_resolution_clock::now ();
743734 // Need to get the next frame or error from PopFrame.
@@ -752,13 +743,9 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
752743 StreamInfo& streamInfo = streams_[streamIndex];
753744 ffmpegStatus =
754745 avcodec_receive_frame (streamInfo.codecContext .get (), frame.get ());
755- VLOG (9 ) << " received frame" << " status=" << ffmpegStatus
756- << " streamIndex=" << streamInfo.stream ->index ;
757746 bool gotNonRetriableError =
758747 ffmpegStatus != AVSUCCESS && ffmpegStatus != AVERROR (EAGAIN);
759748 if (gotNonRetriableError) {
760- VLOG (9 ) << " Got non-retriable error from decoder: "
761- << getFFMPEGErrorStringFromErrorCode (ffmpegStatus);
762749 gotPermanentErrorOnAnyActiveStream = true ;
763750 break ;
764751 }
@@ -788,7 +775,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
788775 UniqueAVPacket packet (av_packet_alloc ());
789776 ffmpegStatus = av_read_frame (formatContext_.get (), packet.get ());
790777 decodeStats_.numPacketsRead ++;
791- VLOG (9 ) << " av_read_frame returned status: " << ffmpegStatus;
792778 if (ffmpegStatus == AVERROR_EOF) {
793779 // End of file reached. We must drain all codecs by sending a nullptr
794780 // packet.
@@ -811,8 +797,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
811797 " Could not read frame from input file: " +
812798 getFFMPEGErrorStringFromErrorCode (ffmpegStatus));
813799 }
814- VLOG (9 ) << " Got packet: stream_index=" << packet->stream_index
815- << " pts=" << packet->pts << " size=" << packet->size ;
816800 if (activeStreamIndices_.count (packet->stream_index ) == 0 ) {
817801 // This packet is not for any of the active streams.
818802 continue ;
@@ -850,10 +834,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
850834 std::chrono::duration_cast<std::chrono::milliseconds>(seekDone - start);
851835 auto seekToDecodeDone = std::chrono::duration_cast<std::chrono::milliseconds>(
852836 decodeDone - seekDone);
853- VLOG (3 ) << " Got frame: stream_index=" << activeStream.stream ->index
854- << " pts=" << frame->pts << " stats=" << decodeStats_
855- << " startToSeekDone=" << startToSeekDone.count () << " ms"
856- << " seekToDecodeDone=" << seekToDecodeDone.count () << " ms" ;
857837 RawDecodedOutput rawOutput;
858838 rawOutput.streamIndex = frameStreamIndex;
859839 rawOutput.frame = std::move (frame);
@@ -1021,7 +1001,6 @@ VideoDecoder::DecodedOutput VideoDecoder::getFrameAtIndex(
10211001 int streamIndex,
10221002 int64_t frameIndex,
10231003 std::optional<torch::Tensor> preAllocatedOutputTensor) {
1024- std::cerr << " getFrameAtIndex" << std::endl;
10251004 validateUserProvidedStreamIndex (streamIndex);
10261005 validateScannedAllStreams (" getFrameAtIndex" );
10271006
@@ -1196,7 +1175,6 @@ VideoDecoder::getFramesDisplayedByTimestampInRange(
11961175}
11971176
11981177VideoDecoder::RawDecodedOutput VideoDecoder::getNextRawDecodedOutputNoDemux () {
1199- std::cerr << " getNextRawDecodedOutputNoDemux" << std::endl;
12001178 auto rawOutput =
12011179 getDecodedOutputWithFilter ([this ](int frameStreamIndex, AVFrame* frame) {
12021180 StreamInfo& activeStream = streams_[frameStreamIndex];
@@ -1207,7 +1185,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getNextRawDecodedOutputNoDemux() {
12071185
12081186VideoDecoder::DecodedOutput VideoDecoder::getNextDecodedOutputNoDemux (
12091187 std::optional<torch::Tensor> preAllocatedOutputTensor) {
1210- std::cerr << " getNextDecodedOutputNoDemux" << std::endl;
12111188 auto rawOutput = getNextRawDecodedOutputNoDemux ();
12121189 return convertAVFrameToDecodedOutput (rawOutput, preAllocatedOutputTensor);
12131190}
0 commit comments