Display and control your Android device
Fix YUV conversion for full color range
Romain Vimontdb55edb19613
diff --git a/app/src/display.c b/app/src/display.cindex c8df615d..25c23265 100644--- a/app/src/display.c+++ b/app/src/display.c@@ -1,6 +1,7 @@#include "display.h"#include <assert.h>+#include <libavutil/pixfmt.h>#include "util/log.h"@@ -65,6 +66,7 @@ sc_display_init(struct sc_display *display, SDL_Window *window, bool mipmaps) {display->texture = NULL;display->pending.flags = 0;display->pending.frame = NULL;+ display->has_frame = false;return true;}@@ -196,9 +198,25 @@ sc_display_set_texture_size(struct sc_display *display, struct sc_size size) {return SC_DISPLAY_RESULT_OK;}+static SDL_YUV_CONVERSION_MODE+sc_display_to_sdl_color_range(enum AVColorRange color_range) {+ return color_range == AVCOL_RANGE_JPEG ? SDL_YUV_CONVERSION_JPEG+ : SDL_YUV_CONVERSION_AUTOMATIC;+}+static boolsc_display_update_texture_internal(struct sc_display *display,const AVFrame *frame) {+ if (!display->has_frame) {+ // First frame+ display->has_frame = true;++ // Configure YUV color range conversion+ SDL_YUV_CONVERSION_MODE sdl_color_range =+ sc_display_to_sdl_color_range(frame->color_range);+ SDL_SetYUVConversionMode(sdl_color_range);+ }+int ret = SDL_UpdateYUVTexture(display->texture, NULL,frame->data[0], frame->linesize[0],frame->data[1], frame->linesize[1],diff --git a/app/src/display.h b/app/src/display.hindex 643ce73c..590715ee 100644--- a/app/src/display.h+++ b/app/src/display.h@@ -33,6 +33,8 @@ struct sc_display {struct sc_size size;AVFrame *frame;} pending;++ bool has_frame;};enum sc_display_result {