mirror of https://git.ffmpeg.org/ffmpeg.git
fftools/ffmpeg: depend on threads
ffmpeg will be switched to a fully threaded architecture, starting with muxers.
This commit is contained in:
parent
8e854cdd2e
commit
760ce4bc0b
|
@ -5,6 +5,7 @@ version <next>:
|
||||||
- Radiance HDR image support
|
- Radiance HDR image support
|
||||||
- ddagrab (Desktop Duplication) video capture filter
|
- ddagrab (Desktop Duplication) video capture filter
|
||||||
- ffmpeg -shortest_buf_duration option
|
- ffmpeg -shortest_buf_duration option
|
||||||
|
- ffmpeg now requires threading to be built
|
||||||
|
|
||||||
|
|
||||||
version 5.1:
|
version 5.1:
|
||||||
|
|
|
@ -3819,7 +3819,7 @@ avfilter_extralibs="pthreads_extralibs"
|
||||||
avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs"
|
avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs"
|
||||||
|
|
||||||
# programs
|
# programs
|
||||||
ffmpeg_deps="avcodec avfilter avformat"
|
ffmpeg_deps="avcodec avfilter avformat threads"
|
||||||
ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
|
ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
|
||||||
hflip_filter null_filter
|
hflip_filter null_filter
|
||||||
transpose_filter trim_filter vflip_filter"
|
transpose_filter trim_filter vflip_filter"
|
||||||
|
|
|
@ -161,9 +161,7 @@ static struct termios oldtty;
|
||||||
static int restore_tty;
|
static int restore_tty;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_THREADS
|
|
||||||
static void free_input_threads(void);
|
static void free_input_threads(void);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* sub2video hack:
|
/* sub2video hack:
|
||||||
Convert subtitles to video with alpha to insert them in filter graphs.
|
Convert subtitles to video with alpha to insert them in filter graphs.
|
||||||
|
@ -593,9 +591,7 @@ static void ffmpeg_cleanup(int ret)
|
||||||
|
|
||||||
av_freep(&output_streams[i]);
|
av_freep(&output_streams[i]);
|
||||||
}
|
}
|
||||||
#if HAVE_THREADS
|
|
||||||
free_input_threads();
|
free_input_threads();
|
||||||
#endif
|
|
||||||
for (i = 0; i < nb_input_files; i++) {
|
for (i = 0; i < nb_input_files; i++) {
|
||||||
avformat_close_input(&input_files[i]->ctx);
|
avformat_close_input(&input_files[i]->ctx);
|
||||||
av_packet_free(&input_files[i]->pkt);
|
av_packet_free(&input_files[i]->pkt);
|
||||||
|
@ -3670,7 +3666,6 @@ static int check_keyboard_interaction(int64_t cur_time)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_THREADS
|
|
||||||
static void *input_thread(void *arg)
|
static void *input_thread(void *arg)
|
||||||
{
|
{
|
||||||
InputFile *f = arg;
|
InputFile *f = arg;
|
||||||
|
@ -3788,7 +3783,6 @@ static int get_input_packet_mt(InputFile *f, AVPacket **pkt)
|
||||||
f->non_blocking ?
|
f->non_blocking ?
|
||||||
AV_THREAD_MESSAGE_NONBLOCK : 0);
|
AV_THREAD_MESSAGE_NONBLOCK : 0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int get_input_packet(InputFile *f, AVPacket **pkt)
|
static int get_input_packet(InputFile *f, AVPacket **pkt)
|
||||||
{
|
{
|
||||||
|
@ -3811,10 +3805,8 @@ static int get_input_packet(InputFile *f, AVPacket **pkt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_THREADS
|
|
||||||
if (f->thread_queue_size)
|
if (f->thread_queue_size)
|
||||||
return get_input_packet_mt(f, pkt);
|
return get_input_packet_mt(f, pkt);
|
||||||
#endif
|
|
||||||
*pkt = f->pkt;
|
*pkt = f->pkt;
|
||||||
return av_read_frame(f->ctx, *pkt);
|
return av_read_frame(f->ctx, *pkt);
|
||||||
}
|
}
|
||||||
|
@ -3954,15 +3946,11 @@ static int process_input(int file_index)
|
||||||
avcodec_flush_buffers(avctx);
|
avcodec_flush_buffers(avctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if HAVE_THREADS
|
|
||||||
free_input_thread(file_index);
|
free_input_thread(file_index);
|
||||||
#endif
|
|
||||||
ret = seek_to_start(ifile, is);
|
ret = seek_to_start(ifile, is);
|
||||||
#if HAVE_THREADS
|
|
||||||
thread_ret = init_input_thread(file_index);
|
thread_ret = init_input_thread(file_index);
|
||||||
if (thread_ret < 0)
|
if (thread_ret < 0)
|
||||||
return thread_ret;
|
return thread_ret;
|
||||||
#endif
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
av_log(NULL, AV_LOG_WARNING, "Seek to start failed.\n");
|
av_log(NULL, AV_LOG_WARNING, "Seek to start failed.\n");
|
||||||
else
|
else
|
||||||
|
@ -4204,11 +4192,9 @@ static int process_input(int file_index)
|
||||||
process_input_packet(ist, pkt, 0);
|
process_input_packet(ist, pkt, 0);
|
||||||
|
|
||||||
discard_packet:
|
discard_packet:
|
||||||
#if HAVE_THREADS
|
|
||||||
if (ifile->thread_queue_size)
|
if (ifile->thread_queue_size)
|
||||||
av_packet_free(&pkt);
|
av_packet_free(&pkt);
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
av_packet_unref(pkt);
|
av_packet_unref(pkt);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4375,10 +4361,8 @@ static int transcode(void)
|
||||||
|
|
||||||
timer_start = av_gettime_relative();
|
timer_start = av_gettime_relative();
|
||||||
|
|
||||||
#if HAVE_THREADS
|
|
||||||
if ((ret = init_input_threads()) < 0)
|
if ((ret = init_input_threads()) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
#endif
|
|
||||||
|
|
||||||
while (!received_sigterm) {
|
while (!received_sigterm) {
|
||||||
int64_t cur_time= av_gettime_relative();
|
int64_t cur_time= av_gettime_relative();
|
||||||
|
@ -4403,9 +4387,7 @@ static int transcode(void)
|
||||||
/* dump report by using the output first video and audio streams */
|
/* dump report by using the output first video and audio streams */
|
||||||
print_report(0, timer_start, cur_time);
|
print_report(0, timer_start, cur_time);
|
||||||
}
|
}
|
||||||
#if HAVE_THREADS
|
|
||||||
free_input_threads();
|
free_input_threads();
|
||||||
#endif
|
|
||||||
|
|
||||||
/* at the end of stream, we must flush the decoder buffers */
|
/* at the end of stream, we must flush the decoder buffers */
|
||||||
for (i = 0; i < nb_input_streams; i++) {
|
for (i = 0; i < nb_input_streams; i++) {
|
||||||
|
@ -4459,9 +4441,7 @@ static int transcode(void)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
#if HAVE_THREADS
|
|
||||||
free_input_threads();
|
free_input_threads();
|
||||||
#endif
|
|
||||||
|
|
||||||
if (output_streams) {
|
if (output_streams) {
|
||||||
for (i = 0; i < nb_output_streams; i++) {
|
for (i = 0; i < nb_output_streams; i++) {
|
||||||
|
|
|
@ -428,13 +428,11 @@ typedef struct InputFile {
|
||||||
|
|
||||||
AVPacket *pkt;
|
AVPacket *pkt;
|
||||||
|
|
||||||
#if HAVE_THREADS
|
|
||||||
AVThreadMessageQueue *in_thread_queue;
|
AVThreadMessageQueue *in_thread_queue;
|
||||||
pthread_t thread; /* thread reading from this file */
|
pthread_t thread; /* thread reading from this file */
|
||||||
int non_blocking; /* reading packets from the thread should not block */
|
int non_blocking; /* reading packets from the thread should not block */
|
||||||
int joined; /* the thread has been joined */
|
int joined; /* the thread has been joined */
|
||||||
int thread_queue_size; /* maximum number of queued packets */
|
int thread_queue_size; /* maximum number of queued packets */
|
||||||
#endif
|
|
||||||
} InputFile;
|
} InputFile;
|
||||||
|
|
||||||
enum forced_keyframes_const {
|
enum forced_keyframes_const {
|
||||||
|
|
|
@ -1383,9 +1383,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
|
||||||
f->pkt = av_packet_alloc();
|
f->pkt = av_packet_alloc();
|
||||||
if (!f->pkt)
|
if (!f->pkt)
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
#if HAVE_THREADS
|
|
||||||
f->thread_queue_size = o->thread_queue_size;
|
f->thread_queue_size = o->thread_queue_size;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* check if all codec options have been used */
|
/* check if all codec options have been used */
|
||||||
unused_opts = strip_specifiers(o->g->codec_opts);
|
unused_opts = strip_specifiers(o->g->codec_opts);
|
||||||
|
|
Loading…
Reference in New Issue