File tree Expand file tree Collapse file tree 3 files changed +7
-13
lines changed
Expand file tree Collapse file tree 3 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -70,12 +70,6 @@ void CpuDeviceInterface::initializeVideo(
7070 // If we have any transforms, replace filters_ with the filter strings from
7171 // the transforms. As noted above, we decide between swscale and filtergraph
7272 // when we actually decode a frame.
73- //
74- // Note: We explicitly add the format conversion filter at the end to ensure
75- // that color conversion happens AFTER the transforms, not before. This
76- // matches the behavior of the reference generation in the test suite.
77- // Without this, FFmpeg's automatic format negotiation might insert the
78- // conversion before the transforms, which would produce different results.
7973 std::stringstream filters;
8074 bool first = true ;
8175 for (const auto & transform : transforms) {
Original file line number Diff line number Diff line change @@ -109,9 +109,8 @@ class CpuDeviceInterface : public DeviceInterface {
109109 //
110110 // If we had to apply transforms in the output pixel format and colorspace,
111111 // we could achieve that by calling sws_scale() twice: once to do the resize
112- // and another time to do the format conversion. But that goes against the
113- // whole point of calling sws_scale() directly, as it's a performance
114- // optimization.
112+ // and another time to do the format conversion. But that will be slower,
113+ // which goes against the whole point of calling sws_scale() directly.
115114 std::string filters_ = " format=rgb24" ;
116115
117116 // The flags we supply to swsContext_, if it used. The flags control the
Original file line number Diff line number Diff line change @@ -51,10 +51,11 @@ def generate_frame_by_index(
5151 )
5252 output_bmp = f"{ base_path } .bmp"
5353
54- # Note that we have an exlicit format conversion to rgb24 in our filtergraph specification,
55- # which always happens AFTER any of the filters that we receive as input. We do this to
56- # ensure that the color conversion happens AFTER the filters, matching the behavior of the
57- # torchcodec filtergraph implementation.
54+ # Note that we have an exlicit format conversion to rgb24 in our filtergraph
55+ # specification, and we always place the user-supplied filters BEFORE the
56+ # format conversion. We do this to ensure that the filters are applied in
57+ # the pixel format and colorspace of the input frames. This behavior matches
58+ # the TorchCodec implementation.
5859 select = f"select='eq(n\\ ,{ frame_index } )'"
5960 format = "format=rgb24"
6061 if filters is not None :
You can’t perform that action at this time.
0 commit comments