Commit 30a1070c authored by Moto Hira's avatar Moto Hira Committed by moto
Browse files

Fix wrong frame allocation in StreamWriter (#2905)

Summary:
Pull Request resolved: https://github.com/pytorch/audio/pull/2905

In StreamWriter, if the tensor format is different from the encoding format, then a FilterGraph object is automatically inserted to convert the format.

The FilterGraph object operates on AVFrames. The input AVFrame must be allocated by us, but the output AVFrames is filled by FilterGraph, thus no need to allocate it.

Now the output AVFrame is used as input to encoder regardless of whether FilterGraph was inserted. Thus the output AVFrame has to be manually allocated by us when FilterGraph is not used.

The current code flips this condition and incorrectly allocates AVFrame when FilterGraph is present and does not allocate otherwise.

This commit fix that.

Reviewed By: xiaohui-zhang

Differential Revision: D41866198

fbshipit-source-id: 40799c147dc8166a979ecfb58ed8e502539a6aed
parent fbf968c0
......@@ -525,7 +525,7 @@ void StreamWriter::add_video_stream(
return get_video_frame(src_fmt, ctx);
}();
AVFramePtr dst_frame =
filter ? get_video_frame(ctx->pix_fmt, ctx) : AVFramePtr{};
filter ? AVFramePtr{} : get_video_frame(ctx->pix_fmt, ctx);
streams.emplace_back(OutputStream{
stream,
std::move(ctx),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment