diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-07-05 11:34:34 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-07-05 11:34:34 +0200 |
commit | 56e9d15e0f9fb5c6ccaa9525dd7ec7a93659f6f7 (patch) | |
tree | 08bbb78f6964eb82f812f85e32af97fd22fc63ae /src/encoder/video/software.c | |
parent | 3400f4d5446357945fe5ce87eeb4dba472370a19 (diff) |
Fix capture incorrect alignment with cpu encoding for some window sizes
Diffstat (limited to 'src/encoder/video/software.c')
-rw-r--r-- | src/encoder/video/software.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/encoder/video/software.c b/src/encoder/video/software.c index c5fde4d..4666ffd 100644 --- a/src/encoder/video/software.c +++ b/src/encoder/video/software.c @@ -6,6 +6,8 @@ #include <stdlib.h> +#define LINESIZE_ALIGNMENT 4 + typedef struct { gsr_video_encoder_software_params params; @@ -28,7 +30,7 @@ static unsigned int gl_create_texture(gsr_egl *egl, int width, int height, int i } static bool gsr_video_encoder_software_setup_textures(gsr_video_encoder_software *self, AVCodecContext *video_codec_context, AVFrame *frame) { - int res = av_frame_get_buffer(frame, 1); // TODO: Align? + int res = av_frame_get_buffer(frame, LINESIZE_ALIGNMENT); if(res < 0) { fprintf(stderr, "gsr error: gsr_video_encoder_software_setup_textures: av_frame_get_buffer failed: %d\n", res); return false; @@ -61,6 +63,12 @@ static void gsr_video_encoder_software_stop(gsr_video_encoder_software *self, AV 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; + video_codec_context->width = FFALIGN(video_codec_context->width, LINESIZE_ALIGNMENT); + video_codec_context->height = FFALIGN(video_codec_context->height, 2); + + 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); return false; |