mirror of https://git.ffmpeg.org/ffmpeg.git
Add id to AVChapter, untested (where do i find matroska files with chapters?).
Originally committed as revision 13255 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
8931e7b48a
commit
7a2a3e8e40
|
@ -760,11 +760,12 @@ AVProgram *av_new_program(AVFormatContext *s, int id);
|
||||||
* and should be ONLY used by demuxers.
|
* and should be ONLY used by demuxers.
|
||||||
*
|
*
|
||||||
* @param s media file handle
|
* @param s media file handle
|
||||||
|
* @param id unique id for this chapter
|
||||||
* @param start chapter start time in AV_TIME_BASE units
|
* @param start chapter start time in AV_TIME_BASE units
|
||||||
* @param end chapter end time in AV_TIME_BASE units
|
* @param end chapter end time in AV_TIME_BASE units
|
||||||
* @param title chapter title
|
* @param title chapter title
|
||||||
*/
|
*/
|
||||||
int ff_new_chapter(AVFormatContext *s, int64_t start, int64_t end, const char *title);
|
int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pts for a given stream.
|
* Set the pts for a given stream.
|
||||||
|
|
|
@ -2160,6 +2160,7 @@ matroska_parse_chapters(AVFormatContext *s)
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case MATROSKA_ID_EDITIONENTRY: {
|
case MATROSKA_ID_EDITIONENTRY: {
|
||||||
uint64_t end = AV_NOPTS_VALUE, start = AV_NOPTS_VALUE;
|
uint64_t end = AV_NOPTS_VALUE, start = AV_NOPTS_VALUE;
|
||||||
|
int64_t uid= -1;
|
||||||
char* title = NULL;
|
char* title = NULL;
|
||||||
/* if there is more than one chapter edition
|
/* if there is more than one chapter edition
|
||||||
we take only the first one */
|
we take only the first one */
|
||||||
|
@ -2235,9 +2236,11 @@ matroska_parse_chapters(AVFormatContext *s)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MATROSKA_ID_CHAPTERUID:
|
||||||
|
res = ebml_read_uint(matroska, &id, &uid);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(s, AV_LOG_INFO, "Ignoring unknown Chapter atom ID 0x%x\n", id);
|
av_log(s, AV_LOG_INFO, "Ignoring unknown Chapter atom ID 0x%x\n", id);
|
||||||
case MATROSKA_ID_CHAPTERUID:
|
|
||||||
case MATROSKA_ID_CHAPTERFLAGHIDDEN:
|
case MATROSKA_ID_CHAPTERFLAGHIDDEN:
|
||||||
case EBML_ID_VOID:
|
case EBML_ID_VOID:
|
||||||
res = ebml_read_skip(matroska);
|
res = ebml_read_skip(matroska);
|
||||||
|
@ -2250,11 +2253,11 @@ matroska_parse_chapters(AVFormatContext *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start != AV_NOPTS_VALUE) {
|
if (start != AV_NOPTS_VALUE && uid != -1) {
|
||||||
start = start * AV_TIME_BASE / 1000000000;
|
start = start * AV_TIME_BASE / 1000000000;
|
||||||
if (end != AV_NOPTS_VALUE)
|
if (end != AV_NOPTS_VALUE)
|
||||||
end = end * AV_TIME_BASE / 1000000000;
|
end = end * AV_TIME_BASE / 1000000000;
|
||||||
res = ff_new_chapter(s, start, end, title);
|
res = ff_new_chapter(s, uid, start, end, title);
|
||||||
}
|
}
|
||||||
av_free(title);
|
av_free(title);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2234,18 +2234,29 @@ void av_set_program_name(AVProgram *program, char *provider_name, char *name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_new_chapter(AVFormatContext *s, int64_t start, int64_t end, const char *title)
|
int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title)
|
||||||
{
|
{
|
||||||
AVChapter *chapter = av_mallocz(sizeof(AVChapter));
|
AVChapter *chapter = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i=0; i<s->num_chapters; i++)
|
||||||
|
if(s->chapters[i]->id == id)
|
||||||
|
chapter = s->chapters[i];
|
||||||
|
|
||||||
|
if(!chapter){
|
||||||
|
chapter= av_mallocz(sizeof(AVChapter));
|
||||||
if(!chapter)
|
if(!chapter)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
dynarray_add(&s->chapters, &s->num_chapters, chapter);
|
||||||
|
}
|
||||||
|
if(chapter->title)
|
||||||
|
av_free(chapter->title);
|
||||||
if (title)
|
if (title)
|
||||||
chapter->title = av_strdup(title);
|
chapter->title = av_strdup(title);
|
||||||
|
chapter->id = id;
|
||||||
chapter->start = start;
|
chapter->start = start;
|
||||||
chapter->end = end;
|
chapter->end = end;
|
||||||
|
|
||||||
dynarray_add(&s->chapters, &s->num_chapters, chapter);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue