You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avconv: replace no_packet array in transcode() with a var in InputStream
This simplifies splitting code for reading from input out of transcode().
This commit is contained in:
39
avconv.c
39
avconv.c
@@ -1954,7 +1954,7 @@ static int need_output(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int select_input_file(uint8_t *no_packet)
|
static int select_input_file(void)
|
||||||
{
|
{
|
||||||
int64_t ipts_min = INT64_MAX;
|
int64_t ipts_min = INT64_MAX;
|
||||||
int i, file_index = -1;
|
int i, file_index = -1;
|
||||||
@@ -1963,7 +1963,7 @@ static int select_input_file(uint8_t *no_packet)
|
|||||||
InputStream *ist = input_streams[i];
|
InputStream *ist = input_streams[i];
|
||||||
int64_t ipts = ist->last_dts;
|
int64_t ipts = ist->last_dts;
|
||||||
|
|
||||||
if (ist->discard || no_packet[ist->file_index])
|
if (ist->discard || input_files[ist->file_index]->eagain)
|
||||||
continue;
|
continue;
|
||||||
if (!input_files[ist->file_index]->eof_reached) {
|
if (!input_files[ist->file_index]->eof_reached) {
|
||||||
if (ipts < ipts_min) {
|
if (ipts < ipts_min) {
|
||||||
@@ -2095,6 +2095,22 @@ static int get_input_packet(InputFile *f, AVPacket *pkt)
|
|||||||
return av_read_frame(f->ctx, pkt);
|
return av_read_frame(f->ctx, pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int got_eagain(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < nb_input_files; i++)
|
||||||
|
if (input_files[i]->eagain)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void reset_eagain(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < nb_input_files; i++)
|
||||||
|
input_files[i]->eagain = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following code is the main loop of the file converter
|
* The following code is the main loop of the file converter
|
||||||
*/
|
*/
|
||||||
@@ -2104,13 +2120,8 @@ static int transcode(void)
|
|||||||
AVFormatContext *is, *os;
|
AVFormatContext *is, *os;
|
||||||
OutputStream *ost;
|
OutputStream *ost;
|
||||||
InputStream *ist;
|
InputStream *ist;
|
||||||
uint8_t *no_packet;
|
|
||||||
int no_packet_count = 0;
|
|
||||||
int64_t timer_start;
|
int64_t timer_start;
|
||||||
|
|
||||||
if (!(no_packet = av_mallocz(nb_input_files)))
|
|
||||||
exit_program(1);
|
|
||||||
|
|
||||||
ret = transcode_init();
|
ret = transcode_init();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -2136,12 +2147,11 @@ static int transcode(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* select the stream that we must read now */
|
/* select the stream that we must read now */
|
||||||
file_index = select_input_file(no_packet);
|
file_index = select_input_file();
|
||||||
/* if none, if is finished */
|
/* if none, if is finished */
|
||||||
if (file_index < 0) {
|
if (file_index < 0) {
|
||||||
if (no_packet_count) {
|
if (got_eagain()) {
|
||||||
no_packet_count = 0;
|
reset_eagain();
|
||||||
memset(no_packet, 0, nb_input_files);
|
|
||||||
av_usleep(10000);
|
av_usleep(10000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -2153,8 +2163,7 @@ static int transcode(void)
|
|||||||
ret = get_input_packet(input_files[file_index], &pkt);
|
ret = get_input_packet(input_files[file_index], &pkt);
|
||||||
|
|
||||||
if (ret == AVERROR(EAGAIN)) {
|
if (ret == AVERROR(EAGAIN)) {
|
||||||
no_packet[file_index] = 1;
|
input_files[file_index]->eagain = 1;
|
||||||
no_packet_count++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -2177,8 +2186,7 @@ static int transcode(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
no_packet_count = 0;
|
reset_eagain();
|
||||||
memset(no_packet, 0, nb_input_files);
|
|
||||||
|
|
||||||
if (do_pkt_dump) {
|
if (do_pkt_dump) {
|
||||||
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
|
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
|
||||||
@@ -2279,7 +2287,6 @@ static int transcode(void)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
av_freep(&no_packet);
|
|
||||||
#if HAVE_PTHREADS
|
#if HAVE_PTHREADS
|
||||||
free_input_threads();
|
free_input_threads();
|
||||||
#endif
|
#endif
|
||||||
|
1
avconv.h
1
avconv.h
@@ -230,6 +230,7 @@ typedef struct InputStream {
|
|||||||
typedef struct InputFile {
|
typedef struct InputFile {
|
||||||
AVFormatContext *ctx;
|
AVFormatContext *ctx;
|
||||||
int eof_reached; /* true if eof reached */
|
int eof_reached; /* true if eof reached */
|
||||||
|
int eagain; /* true if last read attempt returned EAGAIN */
|
||||||
int ist_index; /* index of first stream in ist_table */
|
int ist_index; /* index of first stream in ist_table */
|
||||||
int64_t ts_offset;
|
int64_t ts_offset;
|
||||||
int nb_streams; /* number of stream that avconv is aware of; may be different
|
int nb_streams; /* number of stream that avconv is aware of; may be different
|
||||||
|
Reference in New Issue
Block a user