meta-pytorch / meta-pytorch/torchcodec

Refactor C++ SingleStreamDecoder to consolidate addStream into constructor

Open
#1,064 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

refactor
Dominant language
Python
Stars
1.2k
Forks
125
Avg merge
22h 47m
Merged PRs (30d)
54

Description

Right now, the C++ SingleStreamDecoder class has two constructors: https://github.com/meta-pytorch/torchcodec/blob/1ea235aa6b71bc9d6ce070d4b849dc60974082b5/src/torchcodec/_core/SingleStreamDecoder.h#L34-L45

And separate from there, there is a public API for adding streams of different media types: https://github.com/meta-pytorch/torchcodec/blob/1ea235aa6b71bc9d6ce070d4b849dc60974082b5/src/torchcodec/_core/SingleStreamDecoder.h#L90-L97

Note that there is also a private member function that both of those call: https://github.com/meta-pytorch/torchcodec/blob/1ea235aa6b71bc9d6ce070d4b849dc60974082b5/src/torchcodec/_core/SingleStreamDecoder.h#L304-L309

This separation is a relic of when SingleStreamDecoder was trying to be more than just a single stream decoder. This API does not match the public Python API, and that fact causes some awkwardness, in particular with how we deal with custom frame mappings; see PR https://github.com/meta-pytorch/torchcodec/pull/1060#discussion_r2541371586 for more.

Note that one could imagine the current separation enables just getting metadata without adding a decoding stream, but that should be well supported with SeekMode::approximate.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/torchcodec/_core/SingleStreamDecoder.h, reviewing the constructors, public addStream API, and private helper linked in the issue. Read the custom frame-mapping discussion in PR #1060, then determine how constructor-based stream setup should align with the Python API while preserving metadata-only use through SeekMode::approximate. Done means the redundant separation is removed and both use cases remain supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.