@@ -578,17 +578,25 @@ void SingleStreamDecoder::addVideoStream(
578578 activeStreamIndex_, customFrameMappings.value ());
579579 }
580580
581- // Resolve AUTO once based on the source bit depth, so downstream code
582- // only has to handle UINT8 / FLOAT32.
583- //
584- // TODO: programmatically enforce that OutputDtype is "resolved" (i.e. not
585- // AUTO) past this point.
586- if (streamInfo.videoStreamOptions .outputDtype == OutputDtype::AUTO ) {
587- const AVPixFmtDescriptor* desc = av_pix_fmt_desc_get (
588- static_cast <AVPixelFormat>(streamInfo.stream ->codecpar ->format ));
589- streamInfo.videoStreamOptions .outputDtype =
590- (desc != nullptr && desc->comp [0 ].depth > 8 ) ? OutputDtype::FLOAT32
591- : OutputDtype::UINT8 ;
581+ // Resolve the user-facing OutputDtypeConfig (which may be AUTO) into an
582+ // OutputDtype that downstream code can use directly.
583+ // TODO_HDR: This is basically our heuristic that defines how we identify HDR
584+ // videos, we might want to refine it.
585+ switch (streamInfo.videoStreamOptions .outputDtypeConfig ) {
586+ case OutputDtypeConfig::UINT8 :
587+ streamInfo.videoStreamOptions .outputDtype = OutputDtype::UINT8 ;
588+ break ;
589+ case OutputDtypeConfig::FLOAT32 :
590+ streamInfo.videoStreamOptions .outputDtype = OutputDtype::FLOAT32 ;
591+ break ;
592+ case OutputDtypeConfig::AUTO : {
593+ const AVPixFmtDescriptor* desc = av_pix_fmt_desc_get (
594+ static_cast <AVPixelFormat>(streamInfo.stream ->codecpar ->format ));
595+ streamInfo.videoStreamOptions .outputDtype =
596+ (desc != nullptr && desc->comp [0 ].depth > 8 ) ? OutputDtype::FLOAT32
597+ : OutputDtype::UINT8 ;
598+ break ;
599+ }
592600 }
593601
594602 // Set preRotationDims_ for the active stream. These are the raw encoded
@@ -1515,10 +1523,9 @@ torch::stable::Tensor SingleStreamDecoder::maybePermuteHWC2CHW(
15151523 }
15161524}
15171525
1526+ // TODO_HDR: should this be a single call along with maybePermuteHWC2CHW?
15181527torch::stable::Tensor SingleStreamDecoder::maybeConvertToFloat32 (
15191528 torch::stable::Tensor& tensor) {
1520- // AUTO has been resolved to UINT8 or FLOAT32 in addVideoStream, so we only
1521- // need to handle FLOAT32 here.
15221529 OutputDtype outputDtype =
15231530 streamInfos_[activeStreamIndex_].videoStreamOptions .outputDtype ;
15241531 if (outputDtype != OutputDtype::FLOAT32 ) {
0 commit comments