History

fftools/ffmpeg_mux_init: Use 64bit for score computation in map_auto_video()

Fixes: signed integer overflow: 10 * 1952737655 cannot be represented in type 'int' Fixes: PoC_avi_demux

Michael Niedermayer committed 1 year ago

Commit 3cab0091 parent 3e05b891 file · +4 −4Browse files

Unified · Split

fftools/ffmpeg_mux_init.c+4−4
@@ -1593,7 +1593,7 @@ static int map_auto_video(Muxer *mux, const OptionsContext *o) · 1592 unmodified lines
1593{1593{
1594 AVFormatContext *oc = mux->fc;1594 AVFormatContext *oc = mux->fc;
1595 InputStream *best_ist = NULL;1595 InputStream *best_ist = NULL;
1596 int best_score = 0;1596 int64_t best_score = 0;
1597 int qcr;1597 int qcr;
1598 1598
1599 /* video: highest resolution */1599 /* video: highest resolution */
@@ -1604,16 +1604,16 @@ static int map_auto_video(Muxer *mux, const OptionsContext *o) · 4 unmodified lines
1604 for (int j = 0; j < nb_input_files; j++) {1604 for (int j = 0; j < nb_input_files; j++) {
1605 InputFile *ifile = input_files[j];1605 InputFile *ifile = input_files[j];
1606 InputStream *file_best_ist = NULL;1606 InputStream *file_best_ist = NULL;
1607 int file_best_score = 0;1607 int64_t file_best_score = 0;
1608 for (int i = 0; i < ifile->nb_streams; i++) {1608 for (int i = 0; i < ifile->nb_streams; i++) {
1609 InputStream *ist = ifile->streams[i];1609 InputStream *ist = ifile->streams[i];
1610 int score;1610 int64_t score;
1611 1611
1612 if (ist->user_set_discard == AVDISCARD_ALL ||1612 if (ist->user_set_discard == AVDISCARD_ALL ||
1613 ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)1613 ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
1614 continue;1614 continue;
1615 1615
1616 score = ist->st->codecpar->width * ist->st->codecpar->height1616 score = ist->st->codecpar->width * (int64_t)ist->st->codecpar->height
1617 + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)1617 + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)
1618 + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT);1618 + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT);
1619 if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))1619 if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t