From c47ada6c12b4cd8c13ef13616029b4cbc8216376 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Sun, 16 Apr 2023 20:51:33 +0800 Subject: [PATCH] tmp --- main.c | 3 +++ simp_gtk_gl.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 721a113..f4f4cea 100644 --- a/main.c +++ b/main.c @@ -65,6 +65,7 @@ static void unrealize(GtkWidget *widget) static gboolean render(GtkGLArea* self, GdkGLContext* context, gpointer user_data) { + scf_loge("%s(),%d\n", __func__, __LINE__); simp_avio_t* gl = user_data; if (gtk_gl_area_get_error (self) != NULL) @@ -175,6 +176,8 @@ int main(int argc, char *argv[]) return -1; } + gl->view = gl_area; + simp_filter_add_input (f, in); simp_filter_add_output(f, alsa); simp_filter_add_output(f, gl); diff --git a/simp_gtk_gl.c b/simp_gtk_gl.c index 1862081..935941b 100644 --- a/simp_gtk_gl.c +++ b/simp_gtk_gl.c @@ -137,7 +137,8 @@ int _gtk_gl_open(simp_avio_t* io, const char* in, const char* out) if (!gl) return -ENOMEM; - io->priv = gl; + io->vopen = 1; + io->priv = gl; return 0; } @@ -177,12 +178,37 @@ static int _gl_init(simp_gl_t* gl) static int _gtk_gl_run(simp_avio_t* io) { - simp_gl_t* gl = io->priv; + scf_loge("%s(),%d\n", __func__, __LINE__); + simp_frame_t* f; + scf_list_t* l; + simp_gl_t* gl = io->priv; - float mvp[16]; + float mvp[16]; - if (!gl->init) + if (!gl->init) { _gl_init(gl); + gl->init = 0; + } + + pthread_mutex_lock (&io->mutex); + if (!scf_list_empty(&io->vout)) { + + l = scf_list_head(&io->vout); + f = scf_list_data(l, simp_frame_t, list); + scf_list_del(&f->list); + pthread_mutex_unlock(&io->mutex); + + int i; + for (i = 0; i < SIMP_GL_HEIGHT; i++) + memcpy(gl->y + i * SIMP_GL_WIDTH, f->frame->data[0] + i * f->frame->linesize[0], SIMP_GL_WIDTH); + + for (i = 0; i < SIMP_GL_HEIGHT / 2; i++) + memcpy(gl->u + i * SIMP_GL_WIDTH / 2, f->frame->data[1] + i * f->frame->linesize[1], SIMP_GL_WIDTH / 2); + + for (i = 0; i < SIMP_GL_HEIGHT / 2; i++) + memcpy(gl->v + i * SIMP_GL_WIDTH / 2, f->frame->data[2] + i * f->frame->linesize[2], SIMP_GL_WIDTH / 2); + } else + pthread_mutex_unlock(&io->mutex); compute_mvp(mvp, 0, 0, 0); -- 2.25.1