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

Add quality-performance trade-off setting #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
42 changes: 42 additions & 0 deletions encode/av1encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,45 @@ render_fr_buffer()
}
}

static void
render_quality_buffer()
{
VABufferID param_buf = VA_INVALID_ID;
VAStatus va_status;
VABufferID render_id = VA_INVALID_ID;

VAEncMiscParameterBuffer *misc_param;
VAEncMiscParameterBufferQualityLevel *misc_quality;

va_status = vaCreateBuffer(va_dpy, context_id,
VAEncMiscParameterBufferType,
sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterBufferQualityLevel),
1, NULL, &param_buf);
CHECK_VASTATUS(va_status, "vaCreateBuffer");

vaMapBuffer(va_dpy, param_buf, (void **)&misc_param);
misc_param->type = VAEncMiscParameterTypeQualityLevel;
misc_quality = (VAEncMiscParameterBufferQualityLevel *)misc_param->data;
memset(misc_quality, 0, sizeof(*misc_quality));

//quality_level range {1...7}, 1 is best quality, 7 is best performance
// 7 is default setting
misc_quality->quality_level = 7;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suppose this value should come from user?
if you are adding a setting to tune it


vaUnmapBuffer(va_dpy, param_buf);

render_id = param_buf;

va_status = vaRenderPicture(va_dpy, context_id, &render_id, 1);
CHECK_VASTATUS(va_status, "vaRenderPicture");

if (param_buf != VA_INVALID_ID)
{
vaDestroyBuffer(va_dpy, param_buf);
param_buf = VA_INVALID_ID;
}
}

static void
render_misc_buffer()
{
Expand Down Expand Up @@ -2821,6 +2860,9 @@ static int encode_frames(void)
render_misc_buffer();
}

// setting qulity-performance trade-off
if(current_frame_encoding == 0)
render_quality_buffer();

render_packedpicture(); //render packed frame header
render_picture(); //render frame PPS buffer
Expand Down