- /* Assuming there's three components, so bits per pixel component is _bits_per_pixel / 3 */
- int const lim_start = pow(2, _bits_per_pixel.get() / 3 - 4);
- int const lim_end = 235 * pow(2, _bits_per_pixel.get() / 3 - 8);
- int const total = pow(2, _bits_per_pixel.get() / 3);
+ auto pixel_quanta_product = video->pixel_quanta().x * video->pixel_quanta().y;
+ auto bits_per_main_pixel = pixel_quanta_product * _bits_per_pixel.get() / (pixel_quanta_product + 2);
+
+ int const lim_start = pow(2, bits_per_main_pixel - 4);
+ int const lim_end = 235 * pow(2, bits_per_main_pixel - 8);
+ int const total = pow(2, bits_per_main_pixel);