Implement foundation for HDR support

Likely not functional for any decoder yet
This commit is contained in:
Cameron Gutman 2022-11-08 19:40:03 -06:00
parent 28ace51874
commit c2f21b955d
6 changed files with 49 additions and 44 deletions

View File

@ -742,7 +742,9 @@ int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, b
// used to use 60 here but that locked the frame rate to 60 FPS // used to use 60 here but that locked the frame rate to 60 FPS
// on GFE 3.20.3. // on GFE 3.20.3.
int fps = config->fps > 60 ? 0 : config->fps; int fps = config->fps > 60 ? 0 : config->fps;
snprintf(url, sizeof(url), "https://%s:%u/launch?uniqueid=%s&uuid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d&surroundAudioInfo=%d&remoteControllersBitmap=%d&gcmap=%d", server->serverInfo.address, server->httpsPort, unique_id, uuid_str, appId, config->width, config->height, fps, sops, rikey_hex, rikeyid, localaudio, surround_info, gamepad_mask, gamepad_mask); snprintf(url, sizeof(url), "https://%s:%u/launch?uniqueid=%s&uuid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d&surroundAudioInfo=%d&remoteControllersBitmap=%d&gcmap=%d%s",
server->serverInfo.address, server->httpsPort, unique_id, uuid_str, appId, config->width, config->height, fps, sops, rikey_hex, rikeyid, localaudio, surround_info, gamepad_mask, gamepad_mask,
config->enableHdr ? "&hdrMode=1&clientHdrCapVersion=0&clientHdrCapSupportedFlagsInUint32=0&clientHdrCapMetaDataId=NV_STATIC_METADATA_TYPE_1&clientHdrCapDisplayData=0x0x0x0x0x0x0x0x0x0x0" : "");
} else } else
snprintf(url, sizeof(url), "https://%s:%u/resume?uniqueid=%s&uuid=%s&rikey=%s&rikeyid=%d&surroundAudioInfo=%d", server->serverInfo.address, server->httpsPort, unique_id, uuid_str, rikey_hex, rikeyid, surround_info); snprintf(url, sizeof(url), "https://%s:%u/resume?uniqueid=%s&uuid=%s&rikey=%s&rikeyid=%d&surroundAudioInfo=%d", server->serverInfo.address, server->httpsPort, unique_id, uuid_str, rikey_hex, rikeyid, surround_info);

View File

@ -74,6 +74,7 @@ static struct option long_options[] = {
{"nomouseemulation", no_argument, NULL, '4'}, {"nomouseemulation", no_argument, NULL, '4'},
{"pin", required_argument, NULL, '5'}, {"pin", required_argument, NULL, '5'},
{"port", required_argument, NULL, '6'}, {"port", required_argument, NULL, '6'},
{"hdr", no_argument, NULL, '7'},
{0, 0, 0, 0}, {0, 0, 0, 0},
}; };
@ -252,6 +253,9 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) {
case '6': case '6':
config->port = atoi(value); config->port = atoi(value);
break; break;
case '7':
config->stream.enableHdr = true;
break;
case 1: case 1:
if (config->action == NULL) if (config->action == NULL)
config->action = value; config->action = value;

View File

@ -202,6 +202,7 @@ static void help() {
printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n"); printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n"); printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");
printf("\t-codec <codec>\t\tSelect used codec: auto/h264/h265 (default auto)\n"); printf("\t-codec <codec>\t\tSelect used codec: auto/h264/h265 (default auto)\n");
printf("\t-hdr\t\tEnable HDR streaming (experimental, requires host and device support)\n");
printf("\t-remote <yes/no/auto>\t\t\tEnable optimizations for WAN streaming (default auto)\n"); printf("\t-remote <yes/no/auto>\t\t\tEnable optimizations for WAN streaming (default auto)\n");
printf("\t-app <app>\t\tName of app to stream\n"); printf("\t-app <app>\t\tName of app to stream\n");
printf("\t-nosops\t\t\tDon't allow GFE to modify game settings\n"); printf("\t-nosops\t\t\tDon't allow GFE to modify game settings\n");
@ -316,6 +317,10 @@ int main(int argc, char* argv[]) {
exit(-1); exit(-1);
} }
config.stream.supportsHevc = config.codec != CODEC_H264 && (config.codec == CODEC_HEVC || platform_supports_hevc(system)); config.stream.supportsHevc = config.codec != CODEC_H264 && (config.codec == CODEC_HEVC || platform_supports_hevc(system));
if (config.stream.enableHdr && !config.stream.supportsHevc) {
fprintf(stderr, "HDR streaming requires HEVC codec\n");
exit(-1);
}
#ifdef HAVE_SDL #ifdef HAVE_SDL
if (system == SDL) if (system == SDL)

View File

@ -42,31 +42,28 @@ int aml_setup(int videoFormat, int width, int height, int redrawRate, void* cont
codecParam.noblock = 0; codecParam.noblock = 0;
codecParam.am_sysinfo.param = 0; codecParam.am_sysinfo.param = 0;
switch (videoFormat) { if (videoFormat & VIDEO_FORMAT_MASK_H264) {
case VIDEO_FORMAT_H264: if (width > 1920 || height > 1080) {
if (width > 1920 || height > 1080) { codecParam.video_type = VFORMAT_H264_4K2K;
codecParam.video_type = VFORMAT_H264_4K2K; codecParam.am_sysinfo.format = VIDEO_DEC_FORMAT_H264_4K2K;
codecParam.am_sysinfo.format = VIDEO_DEC_FORMAT_H264_4K2K; } else {
} else { codecParam.video_type = VFORMAT_H264;
codecParam.video_type = VFORMAT_H264; codecParam.am_sysinfo.format = VIDEO_DEC_FORMAT_H264;
codecParam.am_sysinfo.format = VIDEO_DEC_FORMAT_H264;
// Workaround for decoding special case of C1, 1080p, H264 // Workaround for decoding special case of C1, 1080p, H264
int major, minor; int major, minor;
struct utsname name; struct utsname name;
uname(&name); uname(&name);
int ret = sscanf(name.release, "%d.%d", &major, &minor); int ret = sscanf(name.release, "%d.%d", &major, &minor);
if (!(major > 3 || (major == 3 && minor >= 14)) && width == 1920 && height == 1080) if (!(major > 3 || (major == 3 && minor >= 14)) && width == 1920 && height == 1080)
codecParam.am_sysinfo.param = (void*) UCODE_IP_ONLY_PARAM; codecParam.am_sysinfo.param = (void*) UCODE_IP_ONLY_PARAM;
} }
break; } else if (videoFormat & VIDEO_FORMAT_MASK_H265) {
case VIDEO_FORMAT_H265: codecParam.video_type = VFORMAT_HEVC;
codecParam.video_type = VFORMAT_HEVC; codecParam.am_sysinfo.format = VIDEO_DEC_FORMAT_HEVC;
codecParam.am_sysinfo.format = VIDEO_DEC_FORMAT_HEVC; } else {
break; printf("Video format not supported\n");
default: return -1;
printf("Video format not supported\n");
return -1;
} }
codecParam.am_sysinfo.width = width; codecParam.am_sysinfo.width = width;

View File

@ -60,13 +60,13 @@ int ffmpeg_init(int videoFormat, int width, int height, int perf_lvl, int buffer
} }
ffmpeg_decoder = perf_lvl & VAAPI_ACCELERATION ? VAAPI : SOFTWARE; ffmpeg_decoder = perf_lvl & VAAPI_ACCELERATION ? VAAPI : SOFTWARE;
switch (videoFormat) { if (videoFormat & VIDEO_FORMAT_MASK_H264) {
case VIDEO_FORMAT_H264: decoder = avcodec_find_decoder_by_name("h264");
decoder = avcodec_find_decoder_by_name("h264"); } else if (videoFormat & VIDEO_FORMAT_MASK_H265) {
break; decoder = avcodec_find_decoder_by_name("hevc");
case VIDEO_FORMAT_H265: } else {
decoder = avcodec_find_decoder_by_name("hevc"); printf("Video format not supported\n");
break; return -1;
} }
if (decoder == NULL) { if (decoder == NULL) {

View File

@ -254,18 +254,15 @@ int rk_setup(int videoFormat, int width, int height, int redrawRate, void* conte
int ret; int ret;
int i; int i;
int j; int j;
int format = 0; int format;
switch (videoFormat) { if (videoFormat & VIDEO_FORMAT_MASK_H264) {
case VIDEO_FORMAT_H264: format = RK_H264;
format = RK_H264; } else if (videoFormat & VIDEO_FORMAT_MASK_H265) {
break; format = RK_H265;
case VIDEO_FORMAT_H265: } else {
format = RK_H265; fprintf(stderr, "Video format not supported\n");
break; return -1;
default:
fprintf(stderr, "Video format not supported\n");
return -1;
} }
MppCodingType mpp_type = (MppCodingType)format; MppCodingType mpp_type = (MppCodingType)format;
@ -328,7 +325,7 @@ int rk_setup(int videoFormat, int width, int height, int redrawRate, void* conte
continue; continue;
} }
for (j = 0; j < ovr->count_formats; j++) { for (j = 0; j < ovr->count_formats; j++) {
if (ovr->formats[j] == DRM_FORMAT_NV12) { if (ovr->formats[j] == ((videoFormat & VIDEO_FORMAT_MASK_10BIT) ? DRM_FORMAT_NV12_10 : DRM_FORMAT_NV12)) {
break; break;
} }
} }