mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-25 16:52:31 +00:00
fftools/ffmpeg: report new streams from the input thread
This avoids a potential race with the demuxer adding new streams. It is also more efficient, since we no longer do inter-thread transfers of packets that will be just discarded.
This commit is contained in:
parent
9c16310fe5
commit
07da07ddb0
@ -3277,21 +3277,6 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void report_new_stream(int input_index, AVPacket *pkt)
|
||||
{
|
||||
InputFile *file = input_files[input_index];
|
||||
AVStream *st = file->ctx->streams[pkt->stream_index];
|
||||
|
||||
if (pkt->stream_index < file->nb_streams_warn)
|
||||
return;
|
||||
av_log(file->ctx, AV_LOG_WARNING,
|
||||
"New %s stream %d:%d at pos:%"PRId64" and DTS:%ss\n",
|
||||
av_get_media_type_string(st->codecpar->codec_type),
|
||||
input_index, pkt->stream_index,
|
||||
pkt->pos, av_ts2timestr(pkt->dts, &st->time_base));
|
||||
file->nb_streams_warn = pkt->stream_index + 1;
|
||||
}
|
||||
|
||||
static int transcode_init(void)
|
||||
{
|
||||
int ret = 0, i, j, k;
|
||||
@ -3831,13 +3816,6 @@ static int process_input(int file_index)
|
||||
|
||||
reset_eagain();
|
||||
|
||||
/* the following test is needed in case new streams appear
|
||||
dynamically in stream : we ignore them */
|
||||
if (pkt->stream_index >= ifile->nb_streams) {
|
||||
report_new_stream(file_index, pkt);
|
||||
goto discard_packet;
|
||||
}
|
||||
|
||||
ist = input_streams[ifile->ist_index + pkt->stream_index];
|
||||
|
||||
ist->data_size += pkt->size;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "libavutil/error.h"
|
||||
#include "libavutil/time.h"
|
||||
#include "libavutil/timestamp.h"
|
||||
#include "libavutil/thread.h"
|
||||
#include "libavutil/threadmessage.h"
|
||||
|
||||
@ -27,6 +28,20 @@
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
|
||||
static void report_new_stream(InputFile *file, const AVPacket *pkt)
|
||||
{
|
||||
AVStream *st = file->ctx->streams[pkt->stream_index];
|
||||
|
||||
if (pkt->stream_index < file->nb_streams_warn)
|
||||
return;
|
||||
av_log(file->ctx, AV_LOG_WARNING,
|
||||
"New %s stream %d:%d at pos:%"PRId64" and DTS:%ss\n",
|
||||
av_get_media_type_string(st->codecpar->codec_type),
|
||||
file->index, pkt->stream_index,
|
||||
pkt->pos, av_ts2timestr(pkt->dts, &st->time_base));
|
||||
file->nb_streams_warn = pkt->stream_index + 1;
|
||||
}
|
||||
|
||||
static void *input_thread(void *arg)
|
||||
{
|
||||
InputFile *f = arg;
|
||||
@ -51,6 +66,14 @@ static void *input_thread(void *arg)
|
||||
f->ctx->streams[pkt->stream_index]);
|
||||
}
|
||||
|
||||
/* the following test is needed in case new streams appear
|
||||
dynamically in stream : we ignore them */
|
||||
if (pkt->stream_index >= f->nb_streams) {
|
||||
report_new_stream(f, pkt);
|
||||
av_packet_unref(pkt);
|
||||
continue;
|
||||
}
|
||||
|
||||
queue_pkt = av_packet_alloc();
|
||||
if (!queue_pkt) {
|
||||
av_packet_unref(pkt);
|
||||
|
Loading…
Reference in New Issue
Block a user