Skip to content

Commit c7c326f

Browse files
committed
More debug
1 parent 68b3098 commit c7c326f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,18 @@ VideoDecoder::VideoStreamOptions::VideoStreamOptions(
406406
}
407407

408408
void print_codecContext(AVCodecContext* cc) {
409+
printf("AVCodecContext details:\n");
409410
printf("Codec ID: %d\n", cc->codec_id);
410411
printf("Codec Type: %d\n", cc->codec_type);
411412
printf("Codec Name: %s\n", cc->codec ? cc->codec->name : "unknown");
412413
printf("Bit Rate: %ld\n", cc->bit_rate);
413414
printf("Time Base: %d/%d\n", cc->time_base.num, cc->time_base.den);
414415
printf("GOP Size: %d\n", cc->gop_size);
415416
printf("Max B-Frames: %d\n", cc->max_b_frames);
417+
printf("bit_rate: %d\n", cc->bit_rate);
418+
printf("bit_rate_tolerance: %d\n", cc->bit_rate_tolerance);
419+
printf("global_quality: %d\n", cc->global_quality);
420+
printf("compression_level: %d\n", cc->compression_level);
416421
if (cc->codec_type == AVMEDIA_TYPE_VIDEO) {
417422
printf("Width: %d\n", cc->width);
418423
printf("Height: %d\n", cc->height);
@@ -1074,7 +1079,7 @@ VideoDecoder::AVFrameStream VideoDecoder::decodeAVFrame(
10741079

10751080
if (ffmpegStatus != AVSUCCESS && ffmpegStatus != AVERROR(EAGAIN)) {
10761081
// Non-retriable error
1077-
printf("Non-retriable error\n");
1082+
// printf("Non-retriable error\n");
10781083
break;
10791084
}
10801085

@@ -1084,22 +1089,22 @@ VideoDecoder::AVFrameStream VideoDecoder::decodeAVFrame(
10841089
// Yes, this is the frame we'll return; break out of the decoding loop.
10851090
// printf("%ld %ld\n", avFrame->pts, avFrame->duration);
10861091

1087-
printf("Found frame\n");
1092+
// printf("Found frame\n");
10881093
break;
10891094
} else if (ffmpegStatus == AVSUCCESS) {
10901095
// No, but we received a valid frame - just not the kind we're looking
10911096
// for. The logic below will read packets and send them to the decoder.
10921097
// But since we did just receive a frame, we should skip reading more
10931098
// packets and sending them to the decoder and just try to receive more
10941099
// frames from the decoder.
1095-
printf("Got AVSUCCESS, continue\n");
1100+
// printf("Got AVSUCCESS, continue\n");
10961101
continue;
10971102
}
10981103

10991104
if (reachedEOF) {
11001105
// We don't have any more packets to send to the decoder. So keep on
11011106
// pulling frames from its internal buffers.
1102-
printf("Reached EOF, continue\n");
1107+
// printf("Reached EOF, continue\n");
11031108
continue;
11041109
}
11051110

@@ -1138,19 +1143,20 @@ VideoDecoder::AVFrameStream VideoDecoder::decodeAVFrame(
11381143
}
11391144

11401145
if (packet->stream_index == activeStreamIndex_) {
1141-
printf("found packet for stream\n");
1146+
// printf("found packet for stream\n");
11421147
break;
11431148
} else {
1144-
printf("Not for stream, continue\n");
1149+
// printf("Not for stream, continue\n");
11451150
}
11461151
}
11471152

11481153
// We got a valid packet. Send it to the decoder, and we'll receive it in
11491154
// the next iteration.
1155+
printf("Sending packet:\n");
11501156
print_packet(packet.get());
11511157
ffmpegStatus =
11521158
avcodec_send_packet(streamInfo.codecContext.get(), packet.get());
1153-
print_packet(packet.get());
1159+
11541160
if (ffmpegStatus < AVSUCCESS) {
11551161
throw std::runtime_error(
11561162
"Could not push packet to decoder: " +
@@ -1179,6 +1185,7 @@ VideoDecoder::AVFrameStream VideoDecoder::decodeAVFrame(
11791185
// the file and that will flush the decoder.
11801186
streamInfo.currentPts = avFrame->pts;
11811187
streamInfo.currentDuration = getDuration(avFrame);
1188+
printf("Received avFrame:\n");
11821189
print_avFrame(avFrame.get());
11831190

11841191
return AVFrameStream(std::move(avFrame), activeStreamIndex_);

0 commit comments

Comments
 (0)