Add hardware acceleration force option

This commit is contained in:
Iwan Timmer 2016-01-16 14:04:05 +01:00
parent d582e2fa07
commit 72e649a66d
6 changed files with 17 additions and 4 deletions

View File

@ -62,6 +62,7 @@ static struct option long_options[] = {
{"windowed", no_argument, NULL, 't'}, {"windowed", no_argument, NULL, 't'},
{"surround", no_argument, NULL, 'u'}, {"surround", no_argument, NULL, 'u'},
{"fps", required_argument, NULL, 'v'}, {"fps", required_argument, NULL, 'v'},
{"forcehw", no_argument, NULL, 'w'},
{0, 0, 0, 0}, {0, 0, 0, 0},
}; };
@ -196,6 +197,8 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) {
case 'v': case 'v':
config->stream.fps = atoi(value); config->stream.fps = atoi(value);
break; break;
case 'w':
config->forcehw = true;
case 1: case 1:
if (config->action == NULL) if (config->action == NULL)
config->action = value; config->action = value;
@ -303,7 +306,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
} else { } else {
int option_index = 0; int option_index = 0;
int c; int c;
while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:no:p:q:r:s", long_options, &option_index)) != -1) { while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:no:p:q:r:stuv:w", long_options, &option_index)) != -1) {
parse_argument(c, optarg, config); parse_argument(c, optarg, config);
} }
} }

View File

@ -40,6 +40,7 @@ typedef struct _CONFIGURATION {
bool sops; bool sops;
bool localaudio; bool localaudio;
bool fullscreen; bool fullscreen;
bool forcehw;
struct input_config inputs[MAX_INPUTS]; struct input_config inputs[MAX_INPUTS];
int inputsCount; int inputsCount;
} CONFIGURATION, *PCONFIGURATION; } CONFIGURATION, *PCONFIGURATION;

View File

@ -89,6 +89,9 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys
if (config->fullscreen) if (config->fullscreen)
drFlags |= DISPLAY_FULLSCREEN; drFlags |= DISPLAY_FULLSCREEN;
if (config->forcehw)
drFlags |= FORCE_HARDWARE_ACCELERATION;
printf("Stream %d x %d, %d fps, %d kbps\n", config->stream.width, config->stream.height, config->stream.fps, config->stream.bitrate); printf("Stream %d x %d, %d fps, %d kbps\n", config->stream.width, config->stream.height, config->stream.fps, config->stream.bitrate);
LiStartConnection(server->address, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system), NULL, drFlags, server->serverMajorVersion); LiStartConnection(server->address, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system), NULL, drFlags, server->serverMajorVersion);
@ -142,6 +145,7 @@ static void help() {
printf("\t-mapping <file>\t\tUse <file> as gamepad mapping configuration file (use before -input)\n"); printf("\t-mapping <file>\t\tUse <file> as gamepad mapping configuration file (use before -input)\n");
printf("\t-input <device>\t\tUse <device> as input. Can be used multiple times\n"); printf("\t-input <device>\t\tUse <device> as input. Can be used multiple times\n");
printf("\t-audio <device>\t\tUse <device> as ALSA audio output device (default sysdefault)\n"); printf("\t-audio <device>\t\tUse <device> as ALSA audio output device (default sysdefault)\n");
printf("\t-forcehw \t\tTry to use video hardware acceleration\n");
#endif #endif
printf("\nUse Ctrl+Alt+Shift+Q to exit streaming session\n\n"); printf("\nUse Ctrl+Alt+Shift+Q to exit streaming session\n\n");
exit(0); exit(0);

View File

@ -18,3 +18,4 @@
*/ */
#define DISPLAY_FULLSCREEN 1 #define DISPLAY_FULLSCREEN 1
#define FORCE_HARDWARE_ACCELERATION 2

View File

@ -51,9 +51,11 @@ int ffmpeg_init(int width, int height, int perf_lvl, int thread_count) {
av_init_packet(&pkt); av_init_packet(&pkt);
#ifdef HAVE_VDPAU #ifdef HAVE_VDPAU
decoder = avcodec_find_decoder_by_name("h264_vdpau"); if (perf_lvl & HARDWARE_ACCELERATION) {
if (decoder != NULL) decoder = avcodec_find_decoder_by_name("h264_vdpau");
decoder_system = VDPAU; if (decoder != NULL)
decoder_system = VDPAU;
}
#endif #endif
if (decoder == NULL) { if (decoder == NULL) {

View File

@ -31,6 +31,8 @@
#define BILINEAR_FILTERING 0x10 #define BILINEAR_FILTERING 0x10
// Uses a faster bilinear filtering with lower image quality // Uses a faster bilinear filtering with lower image quality
#define FAST_BILINEAR_FILTERING 0x20 #define FAST_BILINEAR_FILTERING 0x20
// Uses hardware acceleration
#define HARDWARE_ACCELERATION 0x40
int ffmpeg_init(int width, int height, int perf_lvl, int thread_count); int ffmpeg_init(int width, int height, int perf_lvl, int thread_count);
void ffmpeg_destroy(void); void ffmpeg_destroy(void);