File tree Expand file tree Collapse file tree 4 files changed +12
-14
lines changed Expand file tree Collapse file tree 4 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -76,10 +76,8 @@ void CpuDeviceInterface::initialize(
76
76
// https://stackoverflow.com/questions/74351955/turn-off-sw-scale-conversion-to-planar-yuv-32-byte-alignment-requirements
77
77
bool isWidthSwScaleCompatible = (outputDims_.width % 32 ) == 0 ;
78
78
79
- bool userRequestedSwScale =
80
- videoStreamOptions_.colorConversionLibrary .has_value () &&
81
- videoStreamOptions_.colorConversionLibrary .value () ==
82
- ColorConversionLibrary::SWSCALE;
79
+ bool userRequestedSwScale = videoStreamOptions_.colorConversionLibrary ==
80
+ ColorConversionLibrary::SWSCALE;
83
81
84
82
// Note that we treat the transform limitation differently from the width
85
83
// limitation. That is, we consider the transforms being compatible with
Original file line number Diff line number Diff line change @@ -603,8 +603,8 @@ void VideoEncoder::initializeEncoder(
603
603
604
604
// Use specified dimensions or input dimensions
605
605
// TODO-VideoEncoder: Allow height and width to be set
606
- outWidth_ = videoStreamOptions. width . value_or ( inWidth_) ;
607
- outHeight_ = videoStreamOptions. height . value_or ( inHeight_) ;
606
+ outWidth_ = inWidth_;
607
+ outHeight_ = inHeight_;
608
608
609
609
// Use YUV420P as default output format
610
610
// TODO-VideoEncoder: Enable other pixel formats
Original file line number Diff line number Diff line change @@ -499,10 +499,6 @@ void SingleStreamDecoder::addVideoStream(
499
499
streamIndex, customFrameMappings.value ());
500
500
}
501
501
502
- TORCH_CHECK (
503
- !videoStreamOptions.width .has_value (), " width should have no value!" );
504
- TORCH_CHECK (
505
- !videoStreamOptions.height .has_value (), " height should have no value!" );
506
502
outputDims_ =
507
503
FrameDims (streamMetadata.width .value (), streamMetadata.height .value ());
508
504
for (auto & transform : transforms) {
Original file line number Diff line number Diff line change 13
13
namespace facebook ::torchcodec {
14
14
15
15
enum ColorConversionLibrary {
16
- // TODO: Add an AUTO option later.
17
16
// Use the libavfilter library for color conversion.
18
17
FILTERGRAPH,
19
18
// Use the libswscale library for color conversion.
@@ -28,12 +27,17 @@ struct VideoStreamOptions {
28
27
// utilize all cores. If not set, it will be the default FFMPEG behavior for
29
28
// the given codec.
30
29
std::optional<int > ffmpegThreadCount;
30
+
31
31
// Currently the dimension order can be either NHWC or NCHW.
32
32
// H=height, W=width, C=channel.
33
33
std::string dimensionOrder = " NCHW" ;
34
- std::optional<int > width;
35
- std::optional<int > height;
36
- std::optional<ColorConversionLibrary> colorConversionLibrary;
34
+
35
+ // By default we have to use filtergraph, as it is more general. We can only
36
+ // use swscale when we have met strict requirements. See
37
+ // CpuDeviceInterface::initialze() for the logic.
38
+ ColorConversionLibrary colorConversionLibrary =
39
+ ColorConversionLibrary::FILTERGRAPH;
40
+
37
41
// By default we use CPU for decoding for both C++ and python users.
38
42
torch::Device device = torch::kCPU ;
39
43
You can’t perform that action at this time.
0 commit comments