Skip to content

Commit e360876

Browse files
author
Daniel Flores
committed
allocate keyFrames vec
1 parent d4684d3 commit e360876

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

examples/decoding/custom_frame_mappings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def decode_frames_from_n_videos(video_path, seek_mode = "exact", custom_frame_ma
134134
seek_mode=seek_mode,
135135
custom_frame_mappings=custom_frame_mappings
136136
)
137-
decoder.get_frames_in_range(start=0, stop=10)
137+
decoder.get_frames_in_range(start=0, stop=10)
138138

139139

140140
for video_path, json_path in ((short_video_path, short_json_path), (long_video_path, long_json_path)):

src/torchcodec/_core/SingleStreamDecoder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,10 @@ void SingleStreamDecoder::readCustomFrameMappingsUpdateMetadataAndIndex(
332332
is_key_frame.size(0) == duration.size(0),
333333
"all_frames, is_key_frame, and duration from custom_frame_mappings were not same size.");
334334

335-
// Allocate vector using num frames to reduce reallocations
335+
// Allocate vectors using num frames to reduce reallocations
336336
int64_t numFrames = all_frames.size(0);
337337
streamInfos_[streamIndex].allFrames.reserve(numFrames);
338+
streamInfos_[streamIndex].keyFrames.reserve(numFrames);
338339
// Access tensor data directly rather than element wise to speed up loop below
339340
auto* pts_data = all_frames.data_ptr<int64_t>();
340341
auto* is_key_frame_data = is_key_frame.data_ptr<bool>();

0 commit comments

Comments
 (0)