@@ -373,7 +373,7 @@ std::string CudaDeviceInterface::getDetails() {
373373// Below are methods exclusive to video encoding:
374374// --------------------------------------------------------------------------
375375namespace {
376- // RGB to YUV conversion matrices organized by color range and color space
376+ // RGB to YUV conversion matrices to use in NPP color conversion functions
377377struct ColorConversionMatrices {
378378 static constexpr Npp32f BT601_LIMITED[3 ][4 ] = {
379379 {0 .257f , 0 .504f , 0 .098f , 16 .0f },
@@ -406,19 +406,17 @@ struct ColorConversionMatrices {
406406 {0 .5f , -0 .459786f , -0 .040214f , 128 .0f }};
407407};
408408
409- // Returns the appropriate conversion matrix based on codec context color space
410- // and range
409+ // Returns conversion matrix based on codec context color space and range
411410const Npp32f (*getConversionMatrix (AVCodecContext* codecContext))[4] {
412- // Limited range (TV/Video range 16-235) - default if unspecified
413- if (codecContext->color_range == AVCOL_RANGE_MPEG ||
411+ if (codecContext->color_range == AVCOL_RANGE_MPEG || // limited range
414412 codecContext->color_range == AVCOL_RANGE_UNSPECIFIED) {
415413 if (codecContext->colorspace == AVCOL_SPC_BT470BG) {
416414 return ColorConversionMatrices::BT601_LIMITED;
417415 } else if (codecContext->colorspace == AVCOL_SPC_BT709) {
418416 return ColorConversionMatrices::BT709_LIMITED;
419417 } else if (codecContext->colorspace == AVCOL_SPC_BT2020_NCL) {
420418 return ColorConversionMatrices::BT2020_LIMITED;
421- } else { // AVCOL_SPC_UNSPECIFIED or unknown - default to BT.601
419+ } else { // default to BT.601
422420 return ColorConversionMatrices::BT601_LIMITED;
423421 }
424422 } else if (codecContext->color_range == AVCOL_RANGE_JPEG) { // full range
@@ -428,7 +426,7 @@ const Npp32f (*getConversionMatrix(AVCodecContext* codecContext))[4] {
428426 return ColorConversionMatrices::BT709_FULL;
429427 } else if (codecContext->colorspace == AVCOL_SPC_BT2020_NCL) {
430428 return ColorConversionMatrices::BT2020_FULL;
431- } else { // AVCOL_SPC_UNSPECIFIED or unknown - default to BT.601
429+ } else { // default to BT.601
432430 return ColorConversionMatrices::BT601_FULL;
433431 }
434432 }
0 commit comments