Mercurial > libavformat.hg
comparison mov.c @ 1110:a188feae9a07 libavformat
simplify, completely ignore streams not recognized, that fixes seeking for some files
author | bcoudurier |
---|---|
date | Mon, 12 Jun 2006 13:09:19 +0000 |
parents | 04f092701779 |
children | f3088e843a35 |
comparison
equal
deleted
inserted
replaced
1109:725b291bf94f | 1110:a188feae9a07 |
---|---|
285 | 285 |
286 struct MOVParseTableEntry; | 286 struct MOVParseTableEntry; |
287 | 287 |
288 typedef struct MOVStreamContext { | 288 typedef struct MOVStreamContext { |
289 int ffindex; /* the ffmpeg stream id */ | 289 int ffindex; /* the ffmpeg stream id */ |
290 int is_ff_stream; /* Is this stream presented to ffmpeg ? i.e. is this an audio or video stream ? */ | |
291 long next_chunk; | 290 long next_chunk; |
292 long chunk_count; | 291 long chunk_count; |
293 int64_t *chunk_offsets; | 292 int64_t *chunk_offsets; |
294 int stts_count; | 293 int stts_count; |
295 Time2Sample *stts_data; | 294 Time2Sample *stts_data; |
1662 | 1661 |
1663 static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) | 1662 static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) |
1664 { | 1663 { |
1665 MOVContext *mov = (MOVContext *) s->priv_data; | 1664 MOVContext *mov = (MOVContext *) s->priv_data; |
1666 ByteIOContext *pb = &s->pb; | 1665 ByteIOContext *pb = &s->pb; |
1667 int i, j, nb, err; | 1666 int i, j, err; |
1668 MOV_atom_t atom = { 0, 0, 0 }; | 1667 MOV_atom_t atom = { 0, 0, 0 }; |
1669 | 1668 |
1670 mov->fc = s; | 1669 mov->fc = s; |
1671 mov->parse_table = mov_default_parse_table; | 1670 mov->parse_table = mov_default_parse_table; |
1672 | 1671 |
1687 /* some cleanup : make sure we are on the mdat atom */ | 1686 /* some cleanup : make sure we are on the mdat atom */ |
1688 if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset)) | 1687 if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset)) |
1689 url_fseek(pb, mov->mdat_offset, SEEK_SET); | 1688 url_fseek(pb, mov->mdat_offset, SEEK_SET); |
1690 | 1689 |
1691 mov->next_chunk_offset = mov->mdat_offset; /* initialise reading */ | 1690 mov->next_chunk_offset = mov->mdat_offset; /* initialise reading */ |
1692 mov->total_streams = nb = s->nb_streams; | 1691 |
1693 | |
1694 #if 1 | |
1695 for(i=0; i<s->nb_streams;) { | 1692 for(i=0; i<s->nb_streams;) { |
1693 MOVStreamContext *sc = (MOVStreamContext *)s->streams[i]->priv_data; | |
1694 | |
1696 if(s->streams[i]->codec->codec_type == CODEC_TYPE_MOV_OTHER) {/* not audio, not video, delete */ | 1695 if(s->streams[i]->codec->codec_type == CODEC_TYPE_MOV_OTHER) {/* not audio, not video, delete */ |
1697 av_free(s->streams[i]); | 1696 av_free(s->streams[i]); |
1698 for(j=i+1; j<s->nb_streams; j++) | 1697 mov_free_stream_context(sc); |
1698 for(j=i+1; j<s->nb_streams; j++) { | |
1699 s->streams[j-1] = s->streams[j]; | 1699 s->streams[j-1] = s->streams[j]; |
1700 mov->streams[j-1] = mov->streams[j]; | |
1701 } | |
1700 s->nb_streams--; | 1702 s->nb_streams--; |
1701 } else | 1703 } else { |
1704 if(!sc->time_rate) | |
1705 sc->time_rate=1; | |
1706 if(!sc->time_scale) | |
1707 sc->time_scale= mov->time_scale; | |
1708 av_set_pts_info(s->streams[i], 64, sc->time_rate, sc->time_scale); | |
1709 | |
1710 if(s->streams[i]->duration != AV_NOPTS_VALUE){ | |
1711 assert(s->streams[i]->duration % sc->time_rate == 0); | |
1712 s->streams[i]->duration /= sc->time_rate; | |
1713 } | |
1714 sc->ffindex = i; | |
1702 i++; | 1715 i++; |
1703 } | 1716 } |
1704 for(i=0; i<s->nb_streams;i++) { | 1717 } |
1705 MOVStreamContext *sc = (MOVStreamContext *)s->streams[i]->priv_data; | 1718 mov->total_streams = s->nb_streams; |
1706 | 1719 |
1707 if(!sc->time_rate) | |
1708 sc->time_rate=1; | |
1709 if(!sc->time_scale) | |
1710 sc->time_scale= mov->time_scale; | |
1711 av_set_pts_info(s->streams[i], 64, sc->time_rate, sc->time_scale); | |
1712 | |
1713 if(s->streams[i]->duration != AV_NOPTS_VALUE){ | |
1714 assert(s->streams[i]->duration % sc->time_rate == 0); | |
1715 s->streams[i]->duration /= sc->time_rate; | |
1716 } | |
1717 | |
1718 sc->ffindex = i; | |
1719 sc->is_ff_stream = 1; | |
1720 } | |
1721 #endif | |
1722 return 0; | 1720 return 0; |
1723 } | 1721 } |
1724 | 1722 |
1725 /* Yes, this is ugly... I didn't write the specs of QT :p */ | 1723 /* Yes, this is ugly... I didn't write the specs of QT :p */ |
1726 /* XXX:remove useless commented code sometime */ | 1724 /* XXX:remove useless commented code sometime */ |
1805 if(mov->next_chunk_offset < offset) { /* some meta data */ | 1803 if(mov->next_chunk_offset < offset) { /* some meta data */ |
1806 url_fskip(&s->pb, (offset - mov->next_chunk_offset)); | 1804 url_fskip(&s->pb, (offset - mov->next_chunk_offset)); |
1807 mov->next_chunk_offset = offset; | 1805 mov->next_chunk_offset = offset; |
1808 } | 1806 } |
1809 | 1807 |
1810 if(!sc->is_ff_stream || (s->streams[sc->ffindex]->discard >= AVDISCARD_ALL)) { | 1808 if(s->streams[sc->ffindex]->discard >= AVDISCARD_ALL) { |
1811 url_fskip(&s->pb, (offset - mov->next_chunk_offset)); | 1809 url_fskip(&s->pb, (offset - mov->next_chunk_offset)); |
1812 mov->next_chunk_offset = offset; | 1810 mov->next_chunk_offset = offset; |
1813 offset = INT64_MAX; | 1811 offset = INT64_MAX; |
1814 goto again; | 1812 goto again; |
1815 } | 1813 } |