summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2014-08-04 10:00:13 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2014-08-04 10:00:13 +0800
commitd5556ffb964699bfe2a1b44af1038c8a320c94aa (patch)
tree415dae112e2179fe258954189147ca5dc421f40c
parentab8cd4a14867c0b9cf33733ff44855a362c2989a (diff)
h264encode: check driver supports the RateControl control mode or not
https://bugs.freedesktop.org/show_bug.cgi?id=76720 Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
-rw-r--r--test/encode/h264encode.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/test/encode/h264encode.c b/test/encode/h264encode.c
index 94ce13f..ce96f92 100644
--- a/test/encode/h264encode.c
+++ b/test/encode/h264encode.c
@@ -127,7 +127,15 @@ static int minimal_qp = 0;
static int intra_period = 30;
static int intra_idr_period = 60;
static int ip_period = 1;
-static int rc_mode = VA_RC_VBR;
+static int rc_mode = -1;
+static int rc_default_modes[] = {
+ VA_RC_VBR,
+ VA_RC_CQP,
+ VA_RC_VBR_CONSTRAINED,
+ VA_RC_CBR,
+ VA_RC_VCM,
+ VA_RC_NONE,
+};
static unsigned long long current_frame_encoding = 0;
static unsigned long long current_frame_display = 0;
static unsigned long long current_IDR_display = 0;
@@ -1146,7 +1154,21 @@ static int init_va(void)
printf("\n");
- /* need to check if support rc_mode */
+ if (rc_mode == -1 || !(rc_mode & tmp)) {
+ if (rc_mode != -1) {
+ printf("Warning: Don't support the specified RateControl mode: %s!!!, switch to ", rc_to_string(rc_mode));
+ }
+
+ for (i = 0; i < sizeof(rc_default_modes) / sizeof(rc_default_modes[0]); i++) {
+ if (rc_default_modes[i] & tmp) {
+ rc_mode = rc_default_modes[i];
+ break;
+ }
+ }
+
+ printf("RateControl mode: %s\n", rc_to_string(rc_mode));
+ }
+
config_attrib[config_attrib_num].type = VAConfigAttribRateControl;
config_attrib[config_attrib_num].value = rc_mode;
config_attrib_num++;
@@ -2222,7 +2244,8 @@ static int deinit_va()
static int print_input()
{
printf("\n\nINPUT:Try to encode H264...\n");
- printf("INPUT: RateControl : %s\n", rc_to_string(rc_mode));
+ if (rc_mode != -1)
+ printf("INPUT: RateControl : %s\n", rc_to_string(rc_mode));
printf("INPUT: Resolution : %dx%d, %d frames\n",
frame_width, frame_height, frame_count);
printf("INPUT: FrameRate : %d\n", frame_rate);