comparison mov.c @ 954:7d778342142f libavformat

mov split chunks removal patch by (Baptiste COUDURIER / baptiste.coudurier smartjog com>
author michael
date Sun, 12 Feb 2006 14:53:47 +0000
parents 76deb0728cbd
children 8e5de2f2eece
comparison
equal deleted inserted replaced
953:76deb0728cbd 954:7d778342142f
61 61
62 62
63 #undef NDEBUG 63 #undef NDEBUG
64 #include <assert.h> 64 #include <assert.h>
65 65
66 /* Allows seeking (MOV_SPLIT_CHUNKS should also be defined) */ 66 /* Allows seeking */
67 #define MOV_SEEK 67 #define MOV_SEEK
68
69 /* allows chunk splitting - should work now... */
70 /* in case you can't read a file, try commenting */
71 #define MOV_SPLIT_CHUNKS
72 68
73 /* Special handling for movies created with Minolta Dimaxe Xi*/ 69 /* Special handling for movies created with Minolta Dimaxe Xi*/
74 /* this fix should not interfere with other .mov files, but just in case*/ 70 /* this fix should not interfere with other .mov files, but just in case*/
75 #define MOV_MINOLTA_FIX 71 #define MOV_MINOLTA_FIX
76 72
1748 int i, a, b, m; 1744 int i, a, b, m;
1749 int size; 1745 int size;
1750 int idx; 1746 int idx;
1751 size = 0x0FFFFFFF; 1747 size = 0x0FFFFFFF;
1752 1748
1753 #ifdef MOV_SPLIT_CHUNKS
1754 if (mov->partial) { 1749 if (mov->partial) {
1755 sc = mov->partial; 1750 sc = mov->partial;
1756 idx = sc->sample_to_chunk_index; 1751 idx = sc->sample_to_chunk_index;
1757 1752
1758 if (idx < 0) return 0; 1753 if (idx < 0) return 0;
1770 offset = mov->next_chunk_offset; 1765 offset = mov->next_chunk_offset;
1771 /* extract the sample */ 1766 /* extract the sample */
1772 1767
1773 goto readchunk; 1768 goto readchunk;
1774 } 1769 }
1775 #endif
1776 1770
1777 again: 1771 again:
1778 sc = 0; 1772 sc = 0;
1779 if(offset == INT64_MAX) 1773 if(offset == INT64_MAX)
1780 best_dts= INT64_MAX; 1774 best_dts= INT64_MAX;
1867 1861
1868 idx = sc->sample_to_chunk_index; 1862 idx = sc->sample_to_chunk_index;
1869 if (idx + 1 < sc->sample_to_chunk_sz && sc->next_chunk >= sc->sample_to_chunk[idx + 1].first) 1863 if (idx + 1 < sc->sample_to_chunk_sz && sc->next_chunk >= sc->sample_to_chunk[idx + 1].first)
1870 idx++; 1864 idx++;
1871 sc->sample_to_chunk_index = idx; 1865 sc->sample_to_chunk_index = idx;
1872 #ifdef MOV_SPLIT_CHUNKS
1873 /* split chunks into samples */ 1866 /* split chunks into samples */
1874 if (sc->sample_size == 0 || sc->sample_size > 100) { 1867 if (sc->sample_size == 0 || sc->sample_size > 100) {
1875 if (idx >= 0 && sc->sample_to_chunk[idx].count != 1) { 1868 if (idx >= 0 && sc->sample_to_chunk[idx].count != 1) {
1876 mov->partial = sc; 1869 mov->partial = sc;
1877 /* we'll have to get those samples before next chunk */ 1870 /* we'll have to get those samples before next chunk */
1881 1874
1882 sc->current_sample++; 1875 sc->current_sample++;
1883 }else if(idx + 1 < sc->sample_to_chunk_sz){ 1876 }else if(idx + 1 < sc->sample_to_chunk_sz){
1884 sc->current_sample += sc->sample_size * sc->sample_to_chunk[idx].count; 1877 sc->current_sample += sc->sample_size * sc->sample_to_chunk[idx].count;
1885 } 1878 }
1886 #endif
1887 1879
1888 readchunk: 1880 readchunk:
1889 dprintf("chunk: %lli -> %lli (%i)\n", offset, offset + size, size); 1881 dprintf("chunk: %lli -> %lli (%i)\n", offset, offset + size, size);
1890 if(size == 0x0FFFFFFF) 1882 if(size == 0x0FFFFFFF)
1891 size = mov->mdat_size + mov->mdat_offset - offset; 1883 size = mov->mdat_size + mov->mdat_offset - offset;
1965 } 1957 }
1966 1958
1967 return 0; 1959 return 0;
1968 } 1960 }
1969 1961
1970 #if defined(MOV_SPLIT_CHUNKS) && defined(MOV_SEEK) 1962 #if defined(MOV_SEEK)
1971 /** 1963 /**
1972 * Seek method based on the one described in the Appendix C of QTFileFormat.pdf 1964 * Seek method based on the one described in the Appendix C of QTFileFormat.pdf
1973 */ 1965 */
1974 static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags) 1966 static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
1975 { 1967 {
2184 sizeof(MOVContext), 2176 sizeof(MOVContext),
2185 mov_probe, 2177 mov_probe,
2186 mov_read_header, 2178 mov_read_header,
2187 mov_read_packet, 2179 mov_read_packet,
2188 mov_read_close, 2180 mov_read_close,
2189 #if defined(MOV_SPLIT_CHUNKS) && defined(MOV_SEEK) 2181 #if defined(MOV_SEEK)
2190 mov_read_seek, 2182 mov_read_seek,
2191 #endif 2183 #endif
2192 }; 2184 };
2193 2185
2194 int mov_init(void) 2186 int mov_init(void)