You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
fftools/ffmpeg: only set OutputStream.frame_number for video encoding
It is unused otherwise. Rename the field to vsync_frame_number to better reflect its current purpose.
This commit is contained in:
@@ -1184,7 +1184,7 @@ static void do_video_out(OutputFile *of,
|
|||||||
|
|
||||||
switch (ost->vsync_method) {
|
switch (ost->vsync_method) {
|
||||||
case VSYNC_VSCFR:
|
case VSYNC_VSCFR:
|
||||||
if (ost->frame_number == 0 && delta0 >= 0.5) {
|
if (ost->vsync_frame_number == 0 && delta0 >= 0.5) {
|
||||||
av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0));
|
av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0));
|
||||||
delta = duration;
|
delta = duration;
|
||||||
delta0 = 0;
|
delta0 = 0;
|
||||||
@@ -1192,7 +1192,7 @@ static void do_video_out(OutputFile *of,
|
|||||||
}
|
}
|
||||||
case VSYNC_CFR:
|
case VSYNC_CFR:
|
||||||
// FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
|
// FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
|
||||||
if (frame_drop_threshold && delta < frame_drop_threshold && ost->frame_number) {
|
if (frame_drop_threshold && delta < frame_drop_threshold && ost->vsync_frame_number) {
|
||||||
nb_frames = 0;
|
nb_frames = 0;
|
||||||
} else if (delta < -1.1)
|
} else if (delta < -1.1)
|
||||||
nb_frames = 0;
|
nb_frames = 0;
|
||||||
@@ -1225,7 +1225,7 @@ static void do_video_out(OutputFile *of,
|
|||||||
* But there may be reordering, so we can't throw away frames on encoder
|
* But there may be reordering, so we can't throw away frames on encoder
|
||||||
* flush, we need to limit them here, before they go into encoder.
|
* flush, we need to limit them here, before they go into encoder.
|
||||||
*/
|
*/
|
||||||
nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
|
nb_frames = FFMIN(nb_frames, ost->max_frames - ost->vsync_frame_number);
|
||||||
nb0_frames = FFMIN(nb0_frames, nb_frames);
|
nb0_frames = FFMIN(nb0_frames, nb_frames);
|
||||||
|
|
||||||
memmove(ost->last_nb0_frames + 1,
|
memmove(ost->last_nb0_frames + 1,
|
||||||
@@ -1237,7 +1237,7 @@ static void do_video_out(OutputFile *of,
|
|||||||
nb_frames_drop++;
|
nb_frames_drop++;
|
||||||
av_log(NULL, AV_LOG_VERBOSE,
|
av_log(NULL, AV_LOG_VERBOSE,
|
||||||
"*** dropping frame %"PRId64" from stream %d at ts %"PRId64"\n",
|
"*** dropping frame %"PRId64" from stream %d at ts %"PRId64"\n",
|
||||||
ost->frame_number, ost->st->index, ost->last_frame->pts);
|
ost->vsync_frame_number, ost->st->index, ost->last_frame->pts);
|
||||||
}
|
}
|
||||||
if (nb_frames > (nb0_frames && ost->last_dropped) + (nb_frames > nb0_frames)) {
|
if (nb_frames > (nb0_frames && ost->last_dropped) + (nb_frames > nb0_frames)) {
|
||||||
if (nb_frames > dts_error_threshold * 30) {
|
if (nb_frames > dts_error_threshold * 30) {
|
||||||
@@ -1331,7 +1331,7 @@ static void do_video_out(OutputFile *of,
|
|||||||
exit_program(1);
|
exit_program(1);
|
||||||
|
|
||||||
ost->sync_opts++;
|
ost->sync_opts++;
|
||||||
ost->frame_number++;
|
ost->vsync_frame_number++;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_frame_unref(ost->last_frame);
|
av_frame_unref(ost->last_frame);
|
||||||
|
@@ -462,7 +462,8 @@ typedef struct OutputStream {
|
|||||||
int source_index; /* InputStream index */
|
int source_index; /* InputStream index */
|
||||||
AVStream *st; /* stream in the output file */
|
AVStream *st; /* stream in the output file */
|
||||||
int encoding_needed; /* true if encoding needed for this stream */
|
int encoding_needed; /* true if encoding needed for this stream */
|
||||||
int64_t frame_number;
|
/* number of frames emitted by the video-encoding sync code */
|
||||||
|
int64_t vsync_frame_number;
|
||||||
/* input pts and corresponding output pts
|
/* input pts and corresponding output pts
|
||||||
for A/V sync */
|
for A/V sync */
|
||||||
struct InputStream *sync_ist; /* input stream to sync against */
|
struct InputStream *sync_ist; /* input stream to sync against */
|
||||||
|
@@ -232,18 +232,8 @@ static void submit_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
|
|||||||
|
|
||||||
void of_submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
|
void of_submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
|
||||||
{
|
{
|
||||||
AVStream *st = ost->st;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (pkt) {
|
|
||||||
/*
|
|
||||||
* Counting encoded video frames needs to be done separately because of
|
|
||||||
* reordering, see do_video_out().
|
|
||||||
*/
|
|
||||||
if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed))
|
|
||||||
ost->frame_number++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (of->mux->header_written) {
|
if (of->mux->header_written) {
|
||||||
submit_packet(of, ost, pkt);
|
submit_packet(of, ost, pkt);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user