diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-03-22 17:59:30 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-08-08 16:20:58 +0200 |
commit | 61d9f34c70039f739bebf6870547edd9655002ec (patch) | |
tree | cfa304f0683f8ad8c18bde58d5c58b7a361e0269 | |
parent | de9fb9fba7f6a7002ade2fe8c306a85fbf83e97d (diff) |
fftools/ffmpeg_demux: do not store demux packet in the context
Its use is local to input_thread().
-rw-r--r-- | fftools/ffmpeg.c | 1 | ||||
-rw-r--r-- | fftools/ffmpeg.h | 2 | ||||
-rw-r--r-- | fftools/ffmpeg_demux.c | 11 | ||||
-rw-r--r-- | fftools/ffmpeg_opt.c | 3 |
4 files changed, 10 insertions, 7 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 5019a4b287..6ff5432597 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -593,7 +593,6 @@ static void ffmpeg_cleanup(int ret) free_input_threads(); for (i = 0; i < nb_input_files; i++) { avformat_close_input(&input_files[i]->ctx); - av_packet_free(&input_files[i]->pkt); av_freep(&input_files[i]); } for (i = 0; i < nb_input_streams; i++) { diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index aa97f35310..2ac7cbe522 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -437,8 +437,6 @@ typedef struct InputFile { float readrate; int accurate_seek; - AVPacket *pkt; - AVThreadMessageQueue *in_thread_queue; pthread_t thread; /* thread reading from this file */ int non_blocking; /* reading packets from the thread should not block */ diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index d7dde1028f..31b233c4f4 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -117,10 +117,16 @@ static int seek_to_start(InputFile *ifile) static void *input_thread(void *arg) { InputFile *f = arg; - AVPacket *pkt = f->pkt; + AVPacket *pkt; unsigned flags = f->non_blocking ? AV_THREAD_MESSAGE_NONBLOCK : 0; int ret = 0; + pkt = av_packet_alloc(); + if (!pkt) { + ret = AVERROR(ENOMEM); + goto finish; + } + while (1) { DemuxMsg msg = { NULL }; @@ -185,9 +191,12 @@ static void *input_thread(void *arg) } } +finish: av_assert0(ret < 0); av_thread_message_queue_set_err_recv(f->in_thread_queue, ret); + av_packet_free(&pkt); + return NULL; } diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 25aa9aaff5..97f14b2a5b 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1407,9 +1407,6 @@ static int open_input_file(OptionsContext *o, const char *filename) f->rate_emu = 0; } - f->pkt = av_packet_alloc(); - if (!f->pkt) - exit_program(1); f->thread_queue_size = o->thread_queue_size; /* check if all codec options have been used */ |