Add support for a --repeat command line option to vp8enc. This
addresses https://github.com/intel/libva-utils/issues/209.
diff --git a/encode/vp8enc.c b/encode/vp8enc.c
index e8de122..44d2790 100644
--- a/encode/vp8enc.c
+++ b/encode/vp8enc.c
@@ -111,6 +111,7 @@
{"error_resilient", no_argument, NULL, 9},
{"debug", no_argument, NULL, 10},
{"temp_svc", required_argument, NULL, 11},
+ {"repeat", required_argument, NULL, 12},
{NULL, no_argument, NULL, 0 }
};
@@ -142,6 +143,7 @@
int error_resilient;
int debug;
int temporal_svc_layers;
+ int repeat_times;
};
@@ -163,6 +165,7 @@
.error_resilient = 0,
.debug = 0,
.temporal_svc_layers = 1,
+ .repeat_times = 1,
};
struct vp8enc_vaapi_context {
@@ -280,7 +283,7 @@
vp8enc_write_word(header + 14, settings.height);
vp8enc_write_dword(header + 16, settings.frame_rate);
vp8enc_write_dword(header + 20, 1);
- vp8enc_write_dword(header + 24, settings.num_frames);
+ vp8enc_write_dword(header + 24, settings.num_frames * settings.repeat_times);
vp8enc_write_dword(header + 28, 0);
fwrite(header, 1, 32, vp8_file);
@@ -995,7 +998,8 @@
printf("--fn_num <num>\n how many frames to be encoded\n");
printf("--error_resilient Turn on Error resilient mode\n");
printf("--debug Turn debug info on\n");
- printf("--temp_svc <num> number of temporal layers 2 or 3\n");
+ printf("--temp_svc <num> Number of temporal layers 2 or 3\n");
+ printf("--repeat <num> Number of times to repeat the encoding\n");
}
void parameter_check(const char *param, int val, int min, int max)
@@ -1082,6 +1086,11 @@
parameter_check("--temp_svc",tmp_input,2,3);
settings.temporal_svc_layers = tmp_input;
break;
+ case 12:
+ tmp_input = atoi(optarg);
+ parameter_check("--repeat", tmp_input, 1, 1000000);
+ settings.repeat_times = tmp_input;
+ break;
case 'h':
case 0:
default:
@@ -1168,11 +1177,11 @@
vaapi_context.input_surface = vaapi_context.surfaces[SID_INPUT_PICTURE_0];
vaapi_context.upload_thread.input_surface_num = SID_INPUT_PICTURE_0;
- while (current_frame < settings.num_frames)
+ while (current_frame < settings.num_frames * settings.repeat_times)
{
fprintf(stderr,"\rProcessing frame: %d",current_frame);
- if ( (current_frame%settings.intra_period) == 0)
+ if ( (current_frame % settings.intra_period) == 0)
frame_type = KEY_FRAME;
else
frame_type = INTER_FRAME;
@@ -1187,8 +1196,8 @@
}
// Start Upload thread
- if((current_frame + 1) < settings.num_frames) {
- vaapi_context.upload_thread.processed_frame = current_frame + 1;
+ if((current_frame + 1) < settings.num_frames * settings.repeat_times) {
+ vaapi_context.upload_thread.processed_frame = (current_frame % settings.num_frames - 1) + 1;
if(vaapi_context.upload_thread.input_surface_num == SID_INPUT_PICTURE_0)
vaapi_context.upload_thread.input_surface_num = SID_INPUT_PICTURE_1;