Unified · Split
| @@ -915,14 +915,16 @@ static int mkv_write_chapters(AVFormatContext *s) · 914 unmodified lines | |||
| 915 | for (i = 0; i < s->nb_chapters; i++) { | 915 | for (i = 0; i < s->nb_chapters; i++) { |
| 916 | ebml_master chapteratom, chapterdisplay; | 916 | ebml_master chapteratom, chapterdisplay; |
| 917 | AVChapter *c = s->chapters[i]; | 917 | AVChapter *c = s->chapters[i]; |
| 918 | int chapterstart = av_rescale_q(c->start, c->time_base, scale); | ||
| 919 | int chapterend = av_rescale_q(c->end, c->time_base, scale); | ||
| 918 | AVDictionaryEntry *t = NULL; | 920 | AVDictionaryEntry *t = NULL; |
| 921 | if (chapterstart < 0 || chapterstart > chapterend) | ||
| 922 | return AVERROR_INVALIDDATA; | ||
| 919 | 923 | ||
| 920 | chapteratom = start_ebml_master(pb, MATROSKA_ID_CHAPTERATOM, 0); | 924 | chapteratom = start_ebml_master(pb, MATROSKA_ID_CHAPTERATOM, 0); |
| 921 | put_ebml_uint(pb, MATROSKA_ID_CHAPTERUID, c->id); | 925 | put_ebml_uint(pb, MATROSKA_ID_CHAPTERUID, c->id); |
| 922 | put_ebml_uint(pb, MATROSKA_ID_CHAPTERTIMESTART, | 926 | put_ebml_uint(pb, MATROSKA_ID_CHAPTERTIMESTART, chapterstart); |
| 923 | av_rescale_q(c->start, c->time_base, scale)); | 927 | put_ebml_uint(pb, MATROSKA_ID_CHAPTERTIMEEND, chapterend); |
| 924 | put_ebml_uint(pb, MATROSKA_ID_CHAPTERTIMEEND, | ||
| 925 | av_rescale_q(c->end, c->time_base, scale)); | ||
| 926 | put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGHIDDEN , 0); | 928 | put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGHIDDEN , 0); |
| 927 | put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGENABLED, 1); | 929 | put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGENABLED, 1); |
| 928 | if ((t = av_dict_get(c->metadata, "title", NULL, 0))) { | 930 | if ((t = av_dict_get(c->metadata, "title", NULL, 0))) { |