Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AV1e] allow user select entrypoint between for av1 encoder #337

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions encode/av1encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@ static FH fh;
static SH sh;
struct BitOffsets offsets;

//Default entrypoint for Encode
static VAEntrypoint requested_entrypoint = -1;

static unsigned long long current_frame_encoding = 0;
static unsigned long long current_frame_display = 0;
Expand Down Expand Up @@ -653,9 +655,11 @@ static void print_help()
printf(" --height <number>\n");
printf(" --width <number>\n");
printf(" --base_q_idx <number> 1-255\n");
printf(" --normal_mode select VAEntrypointEncSlice as entrypoint\n");
printf(" --low_power_mode select VAEntrypointEncSliceLP as entrypoint\n");

printf(" sample usage");
printf("./av1encode -n 8 -f 30 --intra_period 4 --ip_period 1 --rcmode CQP --srcyuv ./input.yuv --recyuv ./rec.yuv --fourcc IYUV --level 8 --height 1080 --width 1920 --base_q_idx 128 -o ./out.av1 -t 3360000 -u 210 -d 420 --LDB");
printf("./av1encode -n 8 -f 30 --intra_period 4 --ip_period 1 --rcmode CQP --srcyuv ./input.yuv --recyuv ./rec.yuv --fourcc IYUV --level 8 --height 1080 --width 1920 --base_q_idx 128 -o ./out.av1 -t 3360000 -u 210 -d 420 --LDB --low_power_mode");


}
Expand All @@ -679,6 +683,8 @@ static void process_cmdline(int argc, char *argv[])
{"width", required_argument, NULL, 11 },
{"base_q_idx", required_argument, NULL, 12},
{"LDB", no_argument, NULL, 13},
{"normal_mode", no_argument, NULL, 14},
{"low_power_mode", no_argument, NULL, 15},
{NULL, no_argument, NULL, 0 }

};
Expand Down Expand Up @@ -739,6 +745,12 @@ static void process_cmdline(int argc, char *argv[])
case 13:
ips.LDB = 1;
break;
case 14:
requested_entrypoint = VAEntrypointEncSlice;
break;
case 15:
requested_entrypoint = VAEntrypointEncSliceLP;
break;
case 't':
ips.target_bitrate = atoi(optarg);
break;
Expand Down Expand Up @@ -875,7 +887,43 @@ static int init_va(void)
va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
CHECK_VASTATUS(va_status, "vaInitialize");
av1_profile = VAProfileAV1Profile0;
entryPoint = VAEntrypointEncSliceLP;

// select entrypoint

int num_entrypoints = vaMaxNumEntrypoints(va_dpy);
VAEntrypoint* entrypoints = malloc(num_entrypoints * sizeof(*entrypoints));
if (!entrypoints) {
fprintf(stderr, "error: failed to initialize VA entrypoints array\n");
exit(1);
}

vaQueryConfigEntrypoints(va_dpy, av1_profile, entrypoints, &num_entrypoints);
int support_encode = 0;
for (int slice_entrypoint = 0; slice_entrypoint < num_entrypoints; slice_entrypoint++)
{
if (requested_entrypoint == -1) {
//Select the entry point based on what is avaiable
if ((entrypoints[slice_entrypoint] == VAEntrypointEncSlice) ||
(entrypoints[slice_entrypoint] == VAEntrypointEncSliceLP)) {
support_encode = 1;
entryPoint = entrypoints[slice_entrypoint];
break;
}
} else if ((entrypoints[slice_entrypoint] == requested_entrypoint)) {
//Select the entry point based on what was requested in cmd line option
support_encode = 1;
entryPoint = entrypoints[slice_entrypoint];
break;
}
}

if(entrypoints)
free(entrypoints);

if (support_encode == 0) {
printf("Can't find VAEntrypointEncSlice or VAEntrypointEncSliceLP for AV1 profiles\n");
exit(1);
}

unsigned int i;
for (i = 0; i < VAConfigAttribTypeMax; i++)
Expand Down