simp filter
authoryu.dongliang <18588496441@163.com>
Sun, 9 Apr 2023 09:11:47 +0000 (17:11 +0800)
committeryu.dongliang <18588496441@163.com>
Sun, 9 Apr 2023 09:11:54 +0000 (17:11 +0800)
simp_filter.c

index 303d1429acc12045918e7750d921455ac9ae0701..ad792a9cb30ae924fa0bd67c809a774391ef9e81 100644 (file)
@@ -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);
                }
        }