aboutsummaryrefslogtreecommitdiff
path: root/src/encoder
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoder')
-rw-r--r--src/encoder/video/cuda.c34
-rw-r--r--src/encoder/video/software.c26
-rw-r--r--src/encoder/video/vaapi.c28
-rw-r--r--src/encoder/video/vulkan.c16
4 files changed, 52 insertions, 52 deletions
diff --git a/src/encoder/video/cuda.c b/src/encoder/video/cuda.c
index 858f912..c878dc8 100644
--- a/src/encoder/video/cuda.c
+++ b/src/encoder/video/cuda.c
@@ -356,22 +356,22 @@ static gsr_supported_video_codecs gsr_video_encoder_cuda_get_supported_codecs(gs
static void gsr_video_encoder_cuda_stop(gsr_video_encoder_cuda *self, AVCodecContext *video_codec_context);
static bool gsr_video_encoder_cuda_start(gsr_video_encoder *encoder, AVCodecContext *video_codec_context, AVFrame *frame) {
- gsr_video_encoder_cuda *encoder_cuda = encoder->priv;
+ gsr_video_encoder_cuda *self = encoder->priv;
- const bool overclock = gsr_egl_get_display_server(encoder_cuda->params.egl) == GSR_DISPLAY_SERVER_X11 ? encoder_cuda->params.overclock : false;
- if(!gsr_cuda_load(&encoder_cuda->cuda, encoder_cuda->params.egl->x11.dpy, overclock)) {
+ const bool overclock = gsr_egl_get_display_server(self->params.egl) == GSR_DISPLAY_SERVER_X11 ? self->params.overclock : false;
+ if(!gsr_cuda_load(&self->cuda, self->params.egl->x11.dpy, overclock)) {
fprintf(stderr, "gsr error: gsr_video_encoder_cuda_start: failed to load cuda\n");
- gsr_video_encoder_cuda_stop(encoder_cuda, video_codec_context);
+ gsr_video_encoder_cuda_stop(self, video_codec_context);
return false;
}
- if(!gsr_video_encoder_cuda_setup_context(encoder_cuda, video_codec_context)) {
- gsr_video_encoder_cuda_stop(encoder_cuda, video_codec_context);
+ if(!gsr_video_encoder_cuda_setup_context(self, video_codec_context)) {
+ gsr_video_encoder_cuda_stop(self, video_codec_context);
return false;
}
- if(!gsr_video_encoder_cuda_setup_textures(encoder_cuda, video_codec_context, frame)) {
- gsr_video_encoder_cuda_stop(encoder_cuda, video_codec_context);
+ if(!gsr_video_encoder_cuda_setup_textures(self, video_codec_context, frame)) {
+ gsr_video_encoder_cuda_stop(self, video_codec_context);
return false;
}
@@ -402,7 +402,7 @@ void gsr_video_encoder_cuda_stop(gsr_video_encoder_cuda *self, AVCodecContext *v
}
static void gsr_video_encoder_cuda_copy_textures_to_frame(gsr_video_encoder *encoder, AVFrame *frame) {
- gsr_video_encoder_cuda *encoder_cuda = encoder->priv;
+ gsr_video_encoder_cuda *self = encoder->priv;
const int div[2] = {1, 2}; // divide UV texture size by 2 because chroma is half size
for(int i = 0; i < 2; ++i) {
CUDA_MEMCPY2D memcpy_struct;
@@ -414,26 +414,26 @@ static void gsr_video_encoder_cuda_copy_textures_to_frame(gsr_video_encoder *enc
memcpy_struct.dstY = 0;
memcpy_struct.dstMemoryType = CU_MEMORYTYPE_DEVICE;
- memcpy_struct.srcArray = encoder_cuda->mapped_arrays[i];
+ memcpy_struct.srcArray = self->mapped_arrays[i];
memcpy_struct.srcPitch = frame->width / div[i];
memcpy_struct.dstDevice = (CUdeviceptr)frame->data[i];
memcpy_struct.dstPitch = frame->linesize[i];
- memcpy_struct.WidthInBytes = frame->width * (encoder_cuda->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? 2 : 1);
+ memcpy_struct.WidthInBytes = frame->width * (self->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? 2 : 1);
memcpy_struct.Height = frame->height / div[i];
// TODO: Remove this copy if possible
- encoder_cuda->cuda.cuMemcpy2DAsync_v2(&memcpy_struct, encoder_cuda->cuda_stream);
+ self->cuda.cuMemcpy2DAsync_v2(&memcpy_struct, self->cuda_stream);
}
// TODO: needed?
- encoder_cuda->cuda.cuStreamSynchronize(encoder_cuda->cuda_stream);
+ self->cuda.cuStreamSynchronize(self->cuda_stream);
}
static void gsr_video_encoder_cuda_get_textures(gsr_video_encoder *encoder, unsigned int *textures, int *num_textures, gsr_destination_color *destination_color) {
- gsr_video_encoder_cuda *encoder_cuda = encoder->priv;
- textures[0] = encoder_cuda->target_textures[0];
- textures[1] = encoder_cuda->target_textures[1];
+ gsr_video_encoder_cuda *self = encoder->priv;
+ textures[0] = self->target_textures[0];
+ textures[1] = self->target_textures[1];
*num_textures = 2;
- *destination_color = encoder_cuda->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? GSR_DESTINATION_COLOR_P010 : GSR_DESTINATION_COLOR_NV12;
+ *destination_color = self->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? GSR_DESTINATION_COLOR_P010 : GSR_DESTINATION_COLOR_NV12;
}
static void gsr_video_encoder_cuda_destroy(gsr_video_encoder *encoder, AVCodecContext *video_codec_context) {
diff --git a/src/encoder/video/software.c b/src/encoder/video/software.c
index 4a4b78a..fe23156 100644
--- a/src/encoder/video/software.c
+++ b/src/encoder/video/software.c
@@ -77,7 +77,7 @@ static gsr_supported_video_codecs gsr_video_encoder_software_get_supported_codec
static void gsr_video_encoder_software_stop(gsr_video_encoder_software *self, AVCodecContext *video_codec_context);
static bool gsr_video_encoder_software_start(gsr_video_encoder *encoder, AVCodecContext *video_codec_context, AVFrame *frame) {
- gsr_video_encoder_software *encoder_software = encoder->priv;
+ gsr_video_encoder_software *self = encoder->priv;
video_codec_context->width = FFALIGN(video_codec_context->width, LINESIZE_ALIGNMENT);
video_codec_context->height = FFALIGN(video_codec_context->height, 2);
@@ -85,8 +85,8 @@ static bool gsr_video_encoder_software_start(gsr_video_encoder *encoder, AVCodec
frame->width = video_codec_context->width;
frame->height = video_codec_context->height;
- if(!gsr_video_encoder_software_setup_textures(encoder_software, video_codec_context, frame)) {
- gsr_video_encoder_software_stop(encoder_software, video_codec_context);
+ if(!gsr_video_encoder_software_setup_textures(self, video_codec_context, frame)) {
+ gsr_video_encoder_software_stop(self, video_codec_context);
return false;
}
@@ -101,28 +101,28 @@ void gsr_video_encoder_software_stop(gsr_video_encoder_software *self, AVCodecCo
}
static void gsr_video_encoder_software_copy_textures_to_frame(gsr_video_encoder *encoder, AVFrame *frame) {
- gsr_video_encoder_software *encoder_software = encoder->priv;
+ gsr_video_encoder_software *self = encoder->priv;
// TODO: hdr support
const unsigned int formats[2] = { GL_RED, GL_RG };
for(int i = 0; i < 2; ++i) {
- encoder_software->params.egl->glBindTexture(GL_TEXTURE_2D, encoder_software->target_textures[i]);
+ self->params.egl->glBindTexture(GL_TEXTURE_2D, self->target_textures[i]);
// We could use glGetTexSubImage and then we wouldn't have to use a specific linesize (LINESIZE_ALIGNMENT) that adds padding,
// but glGetTexSubImage is only available starting from opengl 4.5.
- encoder_software->params.egl->glGetTexImage(GL_TEXTURE_2D, 0, formats[i], GL_UNSIGNED_BYTE, frame->data[i]);
+ self->params.egl->glGetTexImage(GL_TEXTURE_2D, 0, formats[i], GL_UNSIGNED_BYTE, frame->data[i]);
}
- encoder_software->params.egl->glBindTexture(GL_TEXTURE_2D, 0);
+ self->params.egl->glBindTexture(GL_TEXTURE_2D, 0);
// cap_kms->kms.base.egl->eglSwapBuffers(cap_kms->kms.base.egl->egl_display, cap_kms->kms.base.egl->egl_surface);
- encoder_software->params.egl->glFlush();
- encoder_software->params.egl->glFinish();
+ self->params.egl->glFlush();
+ self->params.egl->glFinish();
}
static void gsr_video_encoder_software_get_textures(gsr_video_encoder *encoder, unsigned int *textures, int *num_textures, gsr_destination_color *destination_color) {
- gsr_video_encoder_software *encoder_software = encoder->priv;
- textures[0] = encoder_software->target_textures[0];
- textures[1] = encoder_software->target_textures[1];
+ gsr_video_encoder_software *self = encoder->priv;
+ textures[0] = self->target_textures[0];
+ textures[1] = self->target_textures[1];
*num_textures = 2;
- *destination_color = encoder_software->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? GSR_DESTINATION_COLOR_P010 : GSR_DESTINATION_COLOR_NV12;
+ *destination_color = self->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? GSR_DESTINATION_COLOR_P010 : GSR_DESTINATION_COLOR_NV12;
}
static void gsr_video_encoder_software_destroy(gsr_video_encoder *encoder, AVCodecContext *video_codec_context) {
diff --git a/src/encoder/video/vaapi.c b/src/encoder/video/vaapi.c
index 7c53647..9f3a807 100644
--- a/src/encoder/video/vaapi.c
+++ b/src/encoder/video/vaapi.c
@@ -299,12 +299,12 @@ static bool get_supported_video_codecs(VADisplay va_dpy, gsr_supported_video_cod
}
static gsr_supported_video_codecs gsr_video_encoder_vaapi_get_supported_codecs(gsr_video_encoder *encoder, bool cleanup) {
- gsr_video_encoder_vaapi *encoder_vaapi = encoder->priv;
+ gsr_video_encoder_vaapi *self = encoder->priv;
gsr_supported_video_codecs supported_video_codecs = {0};
char render_path[128];
- if(!gsr_card_path_get_render_path(encoder_vaapi->params.egl->card_path, render_path)) {
- fprintf(stderr, "gsr error: gsr_video_encoder_vaapi_get_supported_codecs: failed to get /dev/dri/renderDXXX file from %s\n", encoder_vaapi->params.egl->card_path);
+ if(!gsr_card_path_get_render_path(self->params.egl->card_path, render_path)) {
+ fprintf(stderr, "gsr error: gsr_video_encoder_vaapi_get_supported_codecs: failed to get /dev/dri/renderDXXX file from %s\n", self->params.egl->card_path);
return supported_video_codecs;
}
@@ -329,13 +329,13 @@ static gsr_supported_video_codecs gsr_video_encoder_vaapi_get_supported_codecs(g
static void gsr_video_encoder_vaapi_stop(gsr_video_encoder_vaapi *self, AVCodecContext *video_codec_context);
static bool gsr_video_encoder_vaapi_start(gsr_video_encoder *encoder, AVCodecContext *video_codec_context, AVFrame *frame) {
- gsr_video_encoder_vaapi *encoder_vaapi = encoder->priv;
+ gsr_video_encoder_vaapi *self = encoder->priv;
- if(encoder_vaapi->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD && video_codec_context->codec_id == AV_CODEC_ID_HEVC) {
+ if(self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD && video_codec_context->codec_id == AV_CODEC_ID_HEVC) {
// TODO: dont do this if using ffmpeg reports that this is not needed (AMD driver bug that was fixed recently)
video_codec_context->width = FFALIGN(video_codec_context->width, 64);
video_codec_context->height = FFALIGN(video_codec_context->height, 16);
- } else if(encoder_vaapi->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD && video_codec_context->codec_id == AV_CODEC_ID_AV1) {
+ } else if(self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD && video_codec_context->codec_id == AV_CODEC_ID_AV1) {
// TODO: Dont do this for VCN 5 and forward which should fix this hardware bug
video_codec_context->width = FFALIGN(video_codec_context->width, 64);
// AMD driver has special case handling for 1080 height to set it to 1082 instead of 1088 (1080 aligned to 16).
@@ -354,13 +354,13 @@ static bool gsr_video_encoder_vaapi_start(gsr_video_encoder *encoder, AVCodecCon
frame->width = video_codec_context->width;
frame->height = video_codec_context->height;
- if(!gsr_video_encoder_vaapi_setup_context(encoder_vaapi, video_codec_context)) {
- gsr_video_encoder_vaapi_stop(encoder_vaapi, video_codec_context);
+ if(!gsr_video_encoder_vaapi_setup_context(self, video_codec_context)) {
+ gsr_video_encoder_vaapi_stop(self, video_codec_context);
return false;
}
- if(!gsr_video_encoder_vaapi_setup_textures(encoder_vaapi, video_codec_context, frame)) {
- gsr_video_encoder_vaapi_stop(encoder_vaapi, video_codec_context);
+ if(!gsr_video_encoder_vaapi_setup_textures(self, video_codec_context, frame)) {
+ gsr_video_encoder_vaapi_stop(self, video_codec_context);
return false;
}
@@ -386,11 +386,11 @@ void gsr_video_encoder_vaapi_stop(gsr_video_encoder_vaapi *self, AVCodecContext
}
static void gsr_video_encoder_vaapi_get_textures(gsr_video_encoder *encoder, unsigned int *textures, int *num_textures, gsr_destination_color *destination_color) {
- gsr_video_encoder_vaapi *encoder_vaapi = encoder->priv;
- textures[0] = encoder_vaapi->target_textures[0];
- textures[1] = encoder_vaapi->target_textures[1];
+ gsr_video_encoder_vaapi *self = encoder->priv;
+ textures[0] = self->target_textures[0];
+ textures[1] = self->target_textures[1];
*num_textures = 2;
- *destination_color = encoder_vaapi->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? GSR_DESTINATION_COLOR_P010 : GSR_DESTINATION_COLOR_NV12;
+ *destination_color = self->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? GSR_DESTINATION_COLOR_P010 : GSR_DESTINATION_COLOR_NV12;
}
static void gsr_video_encoder_vaapi_destroy(gsr_video_encoder *encoder, AVCodecContext *video_codec_context) {
diff --git a/src/encoder/video/vulkan.c b/src/encoder/video/vulkan.c
index 9cf95bd..4b0f1ea 100644
--- a/src/encoder/video/vulkan.c
+++ b/src/encoder/video/vulkan.c
@@ -86,11 +86,11 @@ void gsr_video_encoder_vulkan_stop(gsr_video_encoder_vulkan *self, AVCodecContex
}
static void gsr_video_encoder_vulkan_get_textures(gsr_video_encoder *encoder, unsigned int *textures, int *num_textures, gsr_destination_color *destination_color) {
- gsr_video_encoder_vulkan *encoder_vaapi = encoder->priv;
- textures[0] = encoder_vaapi->target_textures[0];
- textures[1] = encoder_vaapi->target_textures[1];
+ gsr_video_encoder_vulkan *self = encoder->priv;
+ textures[0] = self->target_textures[0];
+ textures[1] = self->target_textures[1];
*num_textures = 2;
- *destination_color = encoder_vaapi->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? GSR_DESTINATION_COLOR_P010 : GSR_DESTINATION_COLOR_NV12;
+ *destination_color = self->params.color_depth == GSR_COLOR_DEPTH_10_BITS ? GSR_DESTINATION_COLOR_P010 : GSR_DESTINATION_COLOR_NV12;
}
static void gsr_video_encoder_vulkan_destroy(gsr_video_encoder *encoder, AVCodecContext *video_codec_context) {
@@ -104,20 +104,20 @@ gsr_video_encoder* gsr_video_encoder_vulkan_create(const gsr_video_encoder_vulka
if(!encoder)
return NULL;
- gsr_video_encoder_vulkan *encoder_vaapi = calloc(1, sizeof(gsr_video_encoder_vulkan));
- if(!encoder_vaapi) {
+ gsr_video_encoder_vulkan *encoder_vulkan = calloc(1, sizeof(gsr_video_encoder_vulkan));
+ if(!encoder_vulkan) {
free(encoder);
return NULL;
}
- encoder_vaapi->params = *params;
+ encoder_vulkan->params = *params;
*encoder = (gsr_video_encoder) {
.start = gsr_video_encoder_vulkan_start,
.copy_textures_to_frame = NULL,
.get_textures = gsr_video_encoder_vulkan_get_textures,
.destroy = gsr_video_encoder_vulkan_destroy,
- .priv = encoder_vaapi
+ .priv = encoder_vulkan
};
return encoder;