Add video_to_full_range implementation for RGB48LE.
authorCarl Hetherington <cth@carlh.net>
Mon, 24 May 2021 22:56:03 +0000 (00:56 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 25 May 2021 19:35:12 +0000 (21:35 +0200)
src/lib/image.cc

index eff53a2aae15635811795408b608cf07a9e6e73d..5b926d77c07feb69e52daeeb44c1655f8b51d2b1 100644 (file)
@@ -1440,6 +1440,22 @@ Image::video_range_to_full_range ()
                }
                break;
        }
                }
                break;
        }
+       case AV_PIX_FMT_RGB48LE:
+       {
+               float const factor = 65536.0 / 56064.0;
+               uint16_t* p = reinterpret_cast<uint16_t*>(data()[0]);
+               int const lines = sample_size(0).height;
+               for (int y = 0; y < lines; ++y) {
+                       uint16_t* q = p;
+                       int const line_size_pixels = line_size()[0] / 2;
+                       for (int x = 0; x < line_size_pixels; ++x) {
+                               *q = clamp(lrintf((*q - 4096) * factor), 0L, 65535L);
+                               ++q;
+                       }
+                       p += stride()[0] / 2;
+               }
+               break;
+       }
        case AV_PIX_FMT_GBRP12LE:
        {
                float const factor = 4096.0 / 3504.0;
        case AV_PIX_FMT_GBRP12LE:
        {
                float const factor = 4096.0 / 3504.0;