Skip to content

Commit 2a78b84

Browse files
committed
Renaming
1 parent 88196c5 commit 2a78b84

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

src/torchcodec/_core/BetaCudaDeviceInterface.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -513,22 +513,22 @@ void BetaCudaDeviceInterface::convertAVFrameToFrameOutput(
513513
}
514514

515515
void BetaCudaDeviceInterface::FrameBuffer::markAsBeingDecoded(int slotId) {
516-
auto it = frameBuffer_.find(slotId);
516+
auto it = map_.find(slotId);
517517
TORCH_CHECK(
518-
it == frameBuffer_.end(),
518+
it == map_.end(),
519519
"Slot ",
520520
slotId,
521521
" is already occupied. This should never happen.");
522522

523-
frameBuffer_.emplace(slotId, Slot(slotId, SlotState::BEING_DECODED));
523+
map_.emplace(slotId, Slot(slotId, SlotState::BEING_DECODED));
524524
}
525525

526526
void BetaCudaDeviceInterface::FrameBuffer::markSlotReadyAndSetInfo(
527527
int slotId,
528528
CUVIDPARSERDISPINFO* dispInfo) {
529-
auto it = frameBuffer_.find(slotId);
529+
auto it = map_.find(slotId);
530530
TORCH_CHECK(
531-
it != frameBuffer_.end(),
531+
it != map_.end(),
532532
"Could not find matching slot with slotId ",
533533
slotId,
534534
". This should never happen.");
@@ -538,19 +538,19 @@ void BetaCudaDeviceInterface::FrameBuffer::markSlotReadyAndSetInfo(
538538
}
539539

540540
void BetaCudaDeviceInterface::FrameBuffer::free(int slotId) {
541-
auto it = frameBuffer_.find(slotId);
541+
auto it = map_.find(slotId);
542542
TORCH_CHECK(
543-
it != frameBuffer_.end(),
543+
it != map_.end(),
544544
"Tried to free non-existing slot with slotId",
545545
slotId,
546546
". This should never happen.");
547-
frameBuffer_.erase(it);
547+
map_.erase(it);
548548
}
549549

550550
BetaCudaDeviceInterface::FrameBuffer::Slot*
551551
BetaCudaDeviceInterface::FrameBuffer::findReadySlotWithLowestPts() {
552552
Slot* outputSlot = nullptr;
553-
for (auto& [_, slot] : frameBuffer_) {
553+
for (auto& [_, slot] : map_) {
554554
if (slot.state == SlotState::READY_FOR_OUTPUT &&
555555
(outputSlot == nullptr ||
556556
slot.dispInfo.timestamp < outputSlot->dispInfo.timestamp)) {

src/torchcodec/_core/BetaCudaDeviceInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ class BetaCudaDeviceInterface : public DeviceInterface {
9090
Slot* findReadySlotWithLowestPts();
9191

9292
void clear() {
93-
frameBuffer_.clear();
93+
map_.clear();
9494
}
9595

9696
private:
97-
std::unordered_map<int, Slot> frameBuffer_;
97+
std::unordered_map<int, Slot> map_;
9898
};
9999

100100
UniqueAVFrame convertCudaFrameToAVFrame(

test/test_decoders.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,9 +1406,13 @@ def test_get_frames_at_tensor_indices(self):
14061406
@pytest.mark.parametrize("asset", (NASA_VIDEO, TEST_SRC_2_720P, BT709_FULL_RANGE))
14071407
@pytest.mark.parametrize("contiguous_indices", (True, False))
14081408
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
1409-
def test_beta_cuda_interface_get_frame_at(self, asset, contiguous_indices, seek_mode):
1409+
def test_beta_cuda_interface_get_frame_at(
1410+
self, asset, contiguous_indices, seek_mode
1411+
):
14101412
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
1411-
beta_decoder = VideoDecoder(asset.path, device="cuda:0:beta", seek_mode=seek_mode)
1413+
beta_decoder = VideoDecoder(
1414+
asset.path, device="cuda:0:beta", seek_mode=seek_mode
1415+
)
14121416

14131417
assert ref_decoder.metadata == beta_decoder.metadata
14141418

@@ -1429,9 +1433,13 @@ def test_beta_cuda_interface_get_frame_at(self, asset, contiguous_indices, seek_
14291433
@pytest.mark.parametrize("asset", (NASA_VIDEO, TEST_SRC_2_720P, BT709_FULL_RANGE))
14301434
@pytest.mark.parametrize("contiguous_indices", (True, False))
14311435
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
1432-
def test_beta_cuda_interface_get_frames_at(self, asset, contiguous_indices, seek_mode):
1436+
def test_beta_cuda_interface_get_frames_at(
1437+
self, asset, contiguous_indices, seek_mode
1438+
):
14331439
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
1434-
beta_decoder = VideoDecoder(asset.path, device="cuda:0:beta", seek_mode=seek_mode)
1440+
beta_decoder = VideoDecoder(
1441+
asset.path, device="cuda:0:beta", seek_mode=seek_mode
1442+
)
14351443

14361444
assert ref_decoder.metadata == beta_decoder.metadata
14371445

@@ -1454,7 +1462,9 @@ def test_beta_cuda_interface_get_frames_at(self, asset, contiguous_indices, seek
14541462
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
14551463
def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
14561464
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
1457-
beta_decoder = VideoDecoder(asset.path, device="cuda:0:beta", seek_mode=seek_mode)
1465+
beta_decoder = VideoDecoder(
1466+
asset.path, device="cuda:0:beta", seek_mode=seek_mode
1467+
)
14581468

14591469
assert ref_decoder.metadata == beta_decoder.metadata
14601470

@@ -1474,7 +1484,9 @@ def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
14741484
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
14751485
def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
14761486
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
1477-
beta_decoder = VideoDecoder(asset.path, device="cuda:0:beta", seek_mode=seek_mode)
1487+
beta_decoder = VideoDecoder(
1488+
asset.path, device="cuda:0:beta", seek_mode=seek_mode
1489+
)
14781490

14791491
assert ref_decoder.metadata == beta_decoder.metadata
14801492

@@ -1496,7 +1508,9 @@ def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
14961508
def test_beta_cuda_interface_backwards(self, asset, seek_mode):
14971509

14981510
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
1499-
beta_decoder = VideoDecoder(asset.path, device="cuda:0:beta", seek_mode=seek_mode)
1511+
beta_decoder = VideoDecoder(
1512+
asset.path, device="cuda:0:beta", seek_mode=seek_mode
1513+
)
15001514

15011515
assert ref_decoder.metadata == beta_decoder.metadata
15021516

0 commit comments

Comments
 (0)