From: yu.dongliang <18588496441@163.com> Date: Sun, 9 Apr 2023 09:11:47 +0000 (+0800) Subject: simp filter X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=e8a83529b2a26fbc7e86ca17aeeaa9f804cd7e0b;p=simplay.git simp filter --- diff --git a/simp_filter.c b/simp_filter.c index 303d142..ad792a9 100644 --- a/simp_filter.c +++ b/simp_filter.c @@ -306,10 +306,8 @@ static void* __filter_run(void* arg) } while (!f->exit) { - sleep(2); - - int vn = 0; - int an = 0; + int vn = 0; + int an = 0; for (l = scf_list_head(&f->inputs); l != scf_list_sentinel(&f->inputs); l != scf_list_next(l)) { io = scf_list_data(l, simp_avio_t, list); @@ -345,13 +343,14 @@ static void* __filter_run(void* arg) for (l = scf_list_head(&f->outputs); l != scf_list_sentinel(&f->outputs); l != scf_list_next(l)) { io = scf_list_data(l, simp_avio_t, list); - vf = simp_frame_alloc(); + vf = calloc(1, sizeof(simp_frame_t)); if (!vf) { f->error = -ENOMEM; goto error; } - if (av_frame_copy(vf->frame, f->vframe) < 0) { + vf->frame = av_frame_clone(f->vframe); + if (!vf->frame) { simp_frame_free(vf); vf = NULL; @@ -359,16 +358,16 @@ static void* __filter_run(void* arg) goto error; } - scf_loge("\n"); pthread_mutex_lock(&io->mutex); scf_list_add_tail(&io->vout, &vf->list); pthread_cond_signal(&io->cond); pthread_mutex_unlock(&io->mutex); vf = NULL; } + + av_frame_unref(f->vframe); } - scf_loge("\n"); while (1) { int ret = av_buffersink_get_frame(f->abuffersink_ctx, f->aframe); @@ -381,7 +380,6 @@ static void* __filter_run(void* arg) goto error; } - scf_loge("\n"); for (l = scf_list_head(&f->outputs); l != scf_list_sentinel(&f->outputs); l != scf_list_next(l)) { io = scf_list_data(l, simp_avio_t, list); @@ -400,13 +398,14 @@ static void* __filter_run(void* arg) goto error; } - scf_loge("\n"); pthread_mutex_lock(&io->mutex); scf_list_add_tail(&io->aout, &af->list); pthread_cond_signal(&io->cond); pthread_mutex_unlock(&io->mutex); af = NULL; } + + av_frame_unref(f->aframe); } }