Skip to content

[BC-Breaking] Change streaming decoding to return Iterator instead#1280

Merged
meta-codesync[bot] merged 1 commit intomainfrom
export-D90396373
Jan 29, 2026
Merged

[BC-Breaking] Change streaming decoding to return Iterator instead#1280
meta-codesync[bot] merged 1 commit intomainfrom
export-D90396373

Conversation

@moto-meta
Copy link
Contributor

Summary:
Context:

In #1264, the C++ Generator has been fixed and now we can bind the Generator object to Python, which allows to create Python Iterator object out of C++ Generator.

This makes the implementation of streaming decoding simpler and more aligned with how the underlying FFmpeg decoders work.

With #1268 and #1271, we adopted to NVDEC decoder, which in turn allowed to batch allocate the memory for decoded buffers, improving the performance

This commit applies the similar approach to software decoder. Although the memory allocation for the decoded frame is controlled by FFmpeg, so we don't have the same benefit as the case of NVDEC.
However, the resulting change in the user-facing interface "Optional[Frame]" -> "Iterator[Frame]" makes the handling of decoded frames less awkward as it naturally handles the case where the feeding the next packets or flushing will generate multiple batches of frames.


Differential Revision: D90396373

@meta-codesync
Copy link

meta-codesync bot commented Jan 28, 2026

@moto-meta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D90396373.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 28, 2026
@moto-meta moto-meta changed the title Change streaming decoding to return Iterator instead [BC-Breaking] Change streaming decoding to return Iterator instead Jan 28, 2026
facebook-github-bot pushed a commit that referenced this pull request Jan 28, 2026
Summary:
X-link: facebookexternal/Legion#3


Context:

In #1264, the C++ Generator has been fixed and now we can bind the Generator object to Python, which allows to create Python Iterator object out of C++ Generator.

This makes the implementation of streaming decoding simpler and more aligned with how the underlying FFmpeg decoders work.

With #1268 and #1271, we adopted to NVDEC decoder, which in turn allowed to batch allocate the memory for decoded buffers, improving the performance

This commit applies the similar approach to software decoder. Although the memory allocation for the decoded frame is controlled by FFmpeg, so we don't have the same benefit as the case of NVDEC.
However, the resulting change in the user-facing interface "Optional[Frame]" -> "Iterator[Frame]" makes the handling of decoded frames less awkward as it naturally handles the case where the feeding the next packets or flushing will generate multiple batches of frames.

Reviewed By: vbourgin

Differential Revision: D90396373
facebook-github-bot pushed a commit that referenced this pull request Jan 28, 2026
Summary:
X-link: facebookexternal/Legion#3


Context:

In #1264, the C++ Generator has been fixed and now we can bind the Generator object to Python, which allows to create Python Iterator object out of C++ Generator.

This makes the implementation of streaming decoding simpler and more aligned with how the underlying FFmpeg decoders work.

With #1268 and #1271, we adopted to NVDEC decoder, which in turn allowed to batch allocate the memory for decoded buffers, improving the performance

This commit applies the similar approach to software decoder. Although the memory allocation for the decoded frame is controlled by FFmpeg, so we don't have the same benefit as the case of NVDEC.
However, the resulting change in the user-facing interface "Optional[Frame]" -> "Iterator[Frame]" makes the handling of decoded frames less awkward as it naturally handles the case where the feeding the next packets or flushing will generate multiple batches of frames.

Reviewed By: vbourgin

Differential Revision: D90396373
facebook-github-bot pushed a commit that referenced this pull request Jan 29, 2026
Summary:
X-link: facebookexternal/Legion#3


Context:

In #1264, the C++ Generator has been fixed and now we can bind the Generator object to Python, which allows to create Python Iterator object out of C++ Generator.

This makes the implementation of streaming decoding simpler and more aligned with how the underlying FFmpeg decoders work.

With #1268 and #1271, we adopted to NVDEC decoder, which in turn allowed to batch allocate the memory for decoded buffers, improving the performance

This commit applies the similar approach to software decoder. Although the memory allocation for the decoded frame is controlled by FFmpeg, so we don't have the same benefit as the case of NVDEC.
However, the resulting change in the user-facing interface "Optional[Frame]" -> "Iterator[Frame]" makes the handling of decoded frames less awkward as it naturally handles the case where the feeding the next packets or flushing will generate multiple batches of frames.

Reviewed By: vbourgin

Differential Revision: D90396373
facebook-github-bot pushed a commit that referenced this pull request Jan 29, 2026
Summary:
X-link: facebookexternal/Legion#3


Context:

In #1264, the C++ Generator has been fixed and now we can bind the Generator object to Python, which allows to create Python Iterator object out of C++ Generator.

This makes the implementation of streaming decoding simpler and more aligned with how the underlying FFmpeg decoders work.

With #1268 and #1271, we adopted to NVDEC decoder, which in turn allowed to batch allocate the memory for decoded buffers, improving the performance

This commit applies the similar approach to software decoder. Although the memory allocation for the decoded frame is controlled by FFmpeg, so we don't have the same benefit as the case of NVDEC.
However, the resulting change in the user-facing interface "Optional[Frame]" -> "Iterator[Frame]" makes the handling of decoded frames less awkward as it naturally handles the case where the feeding the next packets or flushing will generate multiple batches of frames.

Reviewed By: vbourgin

Differential Revision: D90396373
Summary:
X-link: facebookexternal/Legion#3


Context:

In #1264, the C++ Generator has been fixed and now we can bind the Generator object to Python, which allows to create Python Iterator object out of C++ Generator.

This makes the implementation of streaming decoding simpler and more aligned with how the underlying FFmpeg decoders work.

With #1268 and #1271, we adopted to NVDEC decoder, which in turn allowed to batch allocate the memory for decoded buffers, improving the performance

This commit applies the similar approach to software decoder. Although the memory allocation for the decoded frame is controlled by FFmpeg, so we don't have the same benefit as the case of NVDEC.
However, the resulting change in the user-facing interface "Optional[Frame]" -> "Iterator[Frame]" makes the handling of decoded frames less awkward as it naturally handles the case where the feeding the next packets or flushing will generate multiple batches of frames.

Reviewed By: vbourgin

Differential Revision: D90396373
@meta-codesync meta-codesync bot merged commit 0150b84 into main Jan 29, 2026
107 of 108 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants