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(
7676 // https://stackoverflow.com/questions/74351955/turn-off-sw-scale-conversion-to-planar-yuv-32-byte-alignment-requirements
7777 bool isWidthSwScaleCompatible = (outputDims_.width % 32 ) == 0 ;
7878
79- bool userRequestedSwScale =
80- videoStreamOptions_.colorConversionLibrary .has_value () &&
81- videoStreamOptions_.colorConversionLibrary .value () ==
82- ColorConversionLibrary::SWSCALE;
79+ bool userRequestedSwScale = videoStreamOptions_.colorConversionLibrary ==
80+ ColorConversionLibrary::SWSCALE;
8381
8482 // Note that we treat the transform limitation differently from the width
8583 // 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(
603603
604604 // Use specified dimensions or input dimensions
605605 // 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_;
608608
609609 // Use YUV420P as default output format
610610 // TODO-VideoEncoder: Enable other pixel formats
Original file line number Diff line number Diff line change @@ -499,10 +499,6 @@ void SingleStreamDecoder::addVideoStream(
499499 streamIndex, customFrameMappings.value ());
500500 }
501501
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!" );
506502 outputDims_ =
507503 FrameDims (streamMetadata.width .value (), streamMetadata.height .value ());
508504 for (auto & transform : transforms) {
Original file line number Diff line number Diff line change 1313namespace facebook ::torchcodec {
1414
1515enum ColorConversionLibrary {
16- // TODO: Add an AUTO option later.
1716 // Use the libavfilter library for color conversion.
1817 FILTERGRAPH,
1918 // Use the libswscale library for color conversion.
@@ -28,12 +27,17 @@ struct VideoStreamOptions {
2827 // utilize all cores. If not set, it will be the default FFMPEG behavior for
2928 // the given codec.
3029 std::optional<int > ffmpegThreadCount;
30+
3131 // Currently the dimension order can be either NHWC or NCHW.
3232 // H=height, W=width, C=channel.
3333 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+
3741 // By default we use CPU for decoding for both C++ and python users.
3842 torch::Device device = torch::kCPU ;
3943
You can’t perform that action at this time.
0 commit comments