Skip to content

Commit

Permalink
Request limited color range by default
Browse files Browse the repository at this point in the history
Most devices currently use limited color range, but some recent devices
encode in full color range, which is currently not supported by the SDL
opengl render driver.

Fixes #4756 <#4756>
Refs <#4756 (comment)>
Refs libusb/#9311 <libsdl-org/SDL#9311>

Signed-off-by: Romain Vimont <[email protected]>
  • Loading branch information
yume-chan authored and rom1v committed Mar 30, 2024
1 parent db55edb commit bf62579
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.os.Build;
import android.os.Looper;
import android.os.SystemClock;
import android.view.Surface;
Expand Down Expand Up @@ -220,6 +221,9 @@ private static MediaFormat createFormat(String videoMimeType, int bitRate, int m
// must be present to configure the encoder, but does not impact the actual frame rate, which is variable
format.setInteger(MediaFormat.KEY_FRAME_RATE, 60);
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
format.setInteger(MediaFormat.KEY_COLOR_RANGE, MediaFormat.COLOR_RANGE_LIMITED);
}
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, DEFAULT_I_FRAME_INTERVAL);
// display the very first frame, and recover from bad quality when no new frames
format.setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, REPEAT_FRAME_DELAY_US); // µs
Expand Down

0 comments on commit bf62579

Please sign in to comment.