mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-12 01:40:04 +01:00
fftools/ffmpeg: add thread-aware transcode scheduling infrastructure
See the comment block at the top of fftools/ffmpeg_sched.h for more details on what this scheduler is for. This commit adds the scheduling code itself, along with minimal integration with the rest of the program: * allocating and freeing the scheduler * passing it throughout the call stack in order to register the individual components (demuxers/decoders/filtergraphs/encoders/muxers) with the scheduler The scheduler is not actually used as of this commit, so it should not result in any change in behavior. That will change in future commits.
This commit is contained in:
@@ -297,7 +297,7 @@ fail:
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
static void *muxer_thread(void *arg)
|
||||
void *muxer_thread(void *arg)
|
||||
{
|
||||
Muxer *mux = arg;
|
||||
OutputFile *of = &mux->of;
|
||||
@@ -580,7 +580,9 @@ static int thread_start(Muxer *mux)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int print_sdp(void)
|
||||
int print_sdp(const char *filename);
|
||||
|
||||
int print_sdp(const char *filename)
|
||||
{
|
||||
char sdp[16384];
|
||||
int i;
|
||||
@@ -613,19 +615,18 @@ static int print_sdp(void)
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
if (!sdp_filename) {
|
||||
if (!filename) {
|
||||
printf("SDP:\n%s\n", sdp);
|
||||
fflush(stdout);
|
||||
} else {
|
||||
ret = avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL);
|
||||
ret = avio_open2(&sdp_pb, filename, AVIO_FLAG_WRITE, &int_cb, NULL);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename);
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", filename);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
avio_print(sdp_pb, sdp);
|
||||
avio_closep(&sdp_pb);
|
||||
av_freep(&sdp_filename);
|
||||
}
|
||||
|
||||
// SDP successfully written, allow muxer threads to start
|
||||
@@ -661,7 +662,7 @@ int mux_check_init(Muxer *mux)
|
||||
nb_output_dumped++;
|
||||
|
||||
if (sdp_filename || want_sdp) {
|
||||
ret = print_sdp();
|
||||
ret = print_sdp(sdp_filename);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error writing the SDP.\n");
|
||||
return ret;
|
||||
@@ -984,6 +985,8 @@ void of_free(OutputFile **pof)
|
||||
ost_free(&of->streams[i]);
|
||||
av_freep(&of->streams);
|
||||
|
||||
av_freep(&mux->sch_stream_idx);
|
||||
|
||||
av_dict_free(&mux->opts);
|
||||
|
||||
av_packet_free(&mux->sq_pkt);
|
||||
|
||||
Reference in New Issue
Block a user