From: yu.dongliang <18588496441@163.com> Date: Sat, 8 Apr 2023 14:53:23 +0000 (+0800) Subject: tmp X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=42fb040d0bfb64e417e64a54c696e48ed8b7e792;p=simplay.git tmp --- diff --git a/simp.c b/simp.c index cf38bde..4491bfc 100644 --- a/simp.c +++ b/simp.c @@ -63,8 +63,8 @@ int simp_avio_open(simp_avio_t** pio, const char* type, const char* path) scf_list_init(&io->vout); scf_list_init(&io->aout); - pthread_mutex_init(&io->mutex); - pthread_cond_init (&io->cond); + pthread_mutex_init(&io->mutex, NULL); + pthread_cond_init (&io->cond , NULL); io->tid = -1; io->width = -1; diff --git a/simp_ffmpeg_input.c b/simp_ffmpeg_input.c index 6efcdda..ba00995 100644 --- a/simp_ffmpeg_input.c +++ b/simp_ffmpeg_input.c @@ -1,5 +1,5 @@ #include"simp_ffmpeg.h" -#include"scf_log.h" +#include"scf_def.h" static int _video_init(simp_ffmpeg_t* priv) { @@ -194,7 +194,7 @@ static int _ffmpeg_close(simp_avio_t* io) return 0; } -int __ffmpeg_decode(simp_avio_t* io, AVCodecContext* dec_ctx, AVPacket* pkt, AVFrame* frame, scf_list_t* h) +static int __ffmpeg_decode(simp_avio_t* io, AVCodecContext* dec_ctx, AVPacket* pkt, AVFrame* frame, scf_list_t* h) { int ret = avcodec_send_packet(dec_ctx, pkt); if (ret < 0) { @@ -231,7 +231,7 @@ int __ffmpeg_decode(simp_avio_t* io, AVCodecContext* dec_ctx, AVPacket* pkt, AVF return 0; } -void* __ffmpeg_run(void* arg) +static void* __ffmpeg_run(void* arg) { simp_avio_t* io = arg; simp_ffmpeg_t* priv = io->priv; @@ -243,13 +243,13 @@ void* __ffmpeg_run(void* arg) if (!pkt) goto end; - while (!priv->exit) { + while (!io->exit) { int ret = av_read_frame(priv->fmt_ctx, pkt); if (ret < 0) { scf_loge("av_read_frame error, ret: %s\n", av_err2str(ret)); av_packet_free(&pkt); - priv->error = ret; + io->error = ret; break; } @@ -283,7 +283,7 @@ void* __ffmpeg_run(void* arg) } } - av_packet_unref(&pkt); + av_packet_unref(pkt); } end: diff --git a/simp_ffmpeg_output.c b/simp_ffmpeg_output.c index 447c007..db14f49 100644 --- a/simp_ffmpeg_output.c +++ b/simp_ffmpeg_output.c @@ -1,5 +1,5 @@ #include"simp_ffmpeg.h" -#include"scf_log.h" +#include"scf_def.h" static int _video_init(simp_ffmpeg_t* priv) { @@ -21,7 +21,7 @@ static int _video_init(simp_ffmpeg_t* priv) if (!priv->vdec_ctx) return -1; - priv->vdec_ctx->codec_id = c->codec_id; + priv->vdec_ctx->codec_id = c->id; priv->vdec_ctx->bit_rate = 1024 * 1024; priv->vdec_ctx->width = 1920; priv->vdec_ctx->height = 1080; @@ -63,7 +63,7 @@ static int _audio_init(simp_ffmpeg_t* priv) if (!priv->adec_ctx) return -1; - priv->adec_ctx->codec_id = c->codec_id; + priv->adec_ctx->codec_id = c->id; priv->adec_ctx->bit_rate = 64 * 1024; priv->adec_ctx->sample_rate = 44100; priv->adec_ctx->sample_fmt = AV_SAMPLE_FMT_FLTP; @@ -125,7 +125,7 @@ static int _ffmpeg_open(simp_avio_t* io, const char* path) error: if (priv->fmt_ctx) - avformat_close_output(&priv->fmt_ctx); + avformat_free_context(priv->fmt_ctx); if (priv->vdec_ctx) avcodec_close(priv->vdec_ctx); @@ -154,7 +154,7 @@ static int _ffmpeg_close(simp_avio_t* io) if (priv) { if (priv->fmt_ctx) - avformat_close_output(&priv->fmt_ctx); + avformat_free_context(priv->fmt_ctx); if (priv->vdec_ctx) avcodec_close(priv->vdec_ctx); @@ -175,7 +175,7 @@ static int _ffmpeg_close(simp_avio_t* io) return 0; } -int __ffmpeg_decode(simp_avio_t* io, AVCodecContext* dec_ctx, AVPacket* pkt, AVFrame* frame, scf_list_t* h) +static int __ffmpeg_decode(simp_avio_t* io, AVCodecContext* dec_ctx, AVPacket* pkt, AVFrame* frame, scf_list_t* h) { int ret = avcodec_send_packet(dec_ctx, pkt); if (ret < 0) { @@ -212,7 +212,7 @@ int __ffmpeg_decode(simp_avio_t* io, AVCodecContext* dec_ctx, AVPacket* pkt, AVF return 0; } -void* __ffmpeg_run(void* arg) +static void* __ffmpeg_run(void* arg) { simp_avio_t* io = arg; simp_ffmpeg_t* priv = io->priv; @@ -227,13 +227,10 @@ void* __ffmpeg_run(void* arg) if (!pkt) goto end; - while (!priv->exit) { + while (!io->exit) { pthread_mutex_lock(&io->mutex); pthread_mutex_unlock(&io->mutex); - - - } end: diff --git a/simp_filter.c b/simp_filter.c index ed9c19e..0a64851 100644 --- a/simp_filter.c +++ b/simp_filter.c @@ -62,14 +62,14 @@ static int _init_filters(simp_filter_t* f, const char* vfilters_descr, const cha voutputs = tmp; } - if (io->sample_rate > 0 && io->channels > 0 && io->aopen) { + if (io->sample_rate.den > 0 && io->channels > 0 && io->aopen) { snprintf(args, sizeof(args), "time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%"PRIx64, io->sample_rate.num, io->sample_rate.den, io->sample_rate.den /io->sample_rate.num, av_get_sample_fmt_name(io->sample_fmt), - av_get_default_channel_layout(io->channel_layout)); + av_get_default_channel_layout(io->channels)); ret = avfilter_graph_create_filter(&io->abuffersrc_ctx, abuffersrc, "in", args, NULL, f->agraph); if (ret < 0) @@ -185,8 +185,8 @@ int simp_filter_open(simp_filter_t** pf) scf_list_init(&f->inputs); scf_list_init(&f->outputs); - pthread_mutex_init(&f->mutex); - pthread_cond_init (&f->cond); + pthread_mutex_init(&f->mutex, NULL); + pthread_cond_init (&f->cond, NULL); f->tid = -1; return 0; @@ -223,7 +223,7 @@ static void* __filter_run(void* arg) int64_t time = sys_time - io->start_time; - if (vopen) { + if (io->vopen) { pthread_mutex_lock(&io->mutex); if (!scf_list_empty(&io->vin)) { @@ -256,7 +256,7 @@ static void* __filter_run(void* arg) } } - if (aopen) { + if (io->aopen) { pthread_mutex_lock(&io->mutex); if (!scf_list_empty(&io->ain)) { @@ -382,7 +382,7 @@ int simp_filter_run(simp_filter_t* f) int simp_filter_add_input(simp_filter_t* f, simp_avio_t* input) { if (f && input) { - scf_list_add_tail(&f->inputs, input); + scf_list_add_tail(&f->inputs, &input->list); return 0; } @@ -393,7 +393,7 @@ int simp_filter_add_input(simp_filter_t* f, simp_avio_t* input) int simp_filter_add_output(simp_filter_t* f, simp_avio_t* output) { if (f && output) { - scf_list_add_tail(&f->outputs, output); + scf_list_add_tail(&f->outputs, &output->list); return 0; }