Skip to content

Commit

Permalink
Use a larger pixel difference on real devices
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 554452842
  • Loading branch information
claincly authored and tianyif committed Aug 7, 2023
1 parent 2063db1 commit 6661a36
Showing 1 changed file with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.google.android.exoplayer2.util.GlUtil;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.Util;
import com.google.common.base.Ascii;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -55,39 +56,46 @@ public class BitmapPixelTestUtil {
private static final String TAG = "BitmapPixelTestUtil";

/**
* Maximum allowed average pixel difference between bitmaps generated using emulators.
* Maximum allowed average pixel difference between bitmaps generated using devices.
*
* <p>This value is for for 8-bit primaries in pixel difference-based tests.
*
* <p>The value is chosen so that differences in decoder behavior across emulator versions don't
* affect whether the test passes, but substantial distortions introduced by changes in tested
* components will cause the test to fail.
* <p>The value is chosen so that differences in decoder behavior across devices don't affect
* whether the test passes, but substantial distortions introduced by changes in tested components
* will cause the test to fail.
*
* <p>When the difference is close to the threshold, manually inspect expected/actual bitmaps to
* confirm failure, as it's possible this is caused by a difference in the codec or graphics
* implementation as opposed to an issue in the tested component.
*
* <p>This value is larger than {@link #MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} to support the
* larger variance in decoder outputs between different physical devices and emulators.
*/
public static final float MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE = 1f;
// TODO: b/279154364 - Stop allowing 15f threshold after bug is fixed.
public static final float MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE_DIFFERENT_DEVICE =
!Util.MODEL.equals("H8266") && !Util.MODEL.equals("H8416") ? 5f : 15f;

/**
* Maximum allowed average pixel difference between bitmaps generated using devices.
* Maximum allowed average pixel difference between bitmaps generated.
*
* <p>This value is for for 8-bit primaries in pixel difference-based tests.
*
* <p>The value is chosen so that differences in decoder behavior across devices don't affect
* whether the test passes, but substantial distortions introduced by changes in tested components
* will cause the test to fail.
* <p>The value is chosen so that differences in decoder behavior across emulator versions don't
* affect whether the test passes, but substantial distortions introduced by changes in tested
* components will cause the test to fail.
*
* <p>When the difference is close to the threshold, manually inspect expected/actual bitmaps to
* confirm failure, as it's possible this is caused by a difference in the codec or graphics
* implementation as opposed to an issue in the tested component.
*
* <p>This value is larger than {@link #MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE} to support the
* larger variance in decoder outputs between different physical devices and emulators.
* <p>The value is the same as {@link #MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE_DIFFERENT_DEVICE}
* if running on physical devices.
*/
// TODO: b/279154364 - Stop allowing 15f threshold after bug is fixed.
public static final float MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE_DIFFERENT_DEVICE =
!Util.MODEL.equals("H8266") && !Util.MODEL.equals("H8416") ? 5f : 15f;
public static final float MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE =
Ascii.toLowerCase(Util.DEVICE).contains("emulator")
|| Ascii.toLowerCase(Util.DEVICE).contains("generic")
? MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE_DIFFERENT_DEVICE
: 1f;

/**
* Maximum allowed average pixel difference between bitmaps with 16-bit primaries generated using
Expand Down

0 comments on commit 6661a36

Please sign in to comment.