1 /*
2 * AVI demuxer
3 * Copyright (c) 2001 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <stdint.h>
23
37
39 int64_t
frame_offset;
/* current frame (video) or byte (audio) counter
40 * (used to compute the pts) */
43
47 * (in the rate/scale sense) in bytes */
48
49 int64_t
cum_len;
/* temporary storage (used during seek) */
50 int prefix;
/* normally 'd'<<8 + 'c' or 'w'<<8 + 'b' */
55 * the MS dshow demuxer */
56
60
63
79 #define MAX_ODML_DEPTH 1000
82
83
86 { NULL },
87 };
88
95 };
96
97
99 { 'R', 'I', 'F', 'F', 'A', 'V', 'I', ' ' },
100 { 'R', 'I', 'F', 'F', 'A', 'V', 'I', 'X' },
101 { 'R', 'I', 'F', 'F', 'A', 'V', 'I', 0x19 },
102 { 'O', 'N', '2', ' ', 'O', 'N', '2', 'f' },
103 { 'R', 'I', 'F', 'F', 'A', 'M', 'V', ' ' },
104 { 0 }
105 };
106
108 { "strn", "title" },
109 { 0 },
110 };
111
114
115 #define print_tag(str, tag, size) \
116 av_dlog(NULL, "pos:%"PRIX64" %s: tag=%c%c%c%c size=0x%x\n", \
117 avio_tell(pb), str, tag & 0xff, \
118 (tag >> 8) & 0xff, \
119 (tag >> 16) & 0xff, \
120 (tag >> 24) & 0xff, \
121 size)
122
124 {
129 else
130 return 1;
131 }
132
134 {
137 int i;
138
139 /* check RIFF header */
144
147 break;
150
151 if (header[7] == 0x19)
153 "This file has been generated by a totally broken muxer.\n");
154
155 return 0;
156 }
157
159 {
163 int index_sub_type =
avio_r8(pb);
168 int stream_id = ((chunk_id & 0xFF) - '0') * 10 +
169 ((chunk_id >> 8 & 0xFF) - '0');
172 int i;
173 int64_t last_pos = -1;
174 int64_t filesize = avi->
fsize;
175
177 "longs_pre_entry:%d index_type:%d entries_in_use:%d "
178 "chunk_id:%X base:%16"PRIX64"\n",
179 longs_pre_entry,
180 index_type,
181 entries_in_use,
182 chunk_id,
183 base);
184
185 if (stream_id >= s->
nb_streams || stream_id < 0)
189
190 if (index_sub_type)
192
194
195 if (index_type && longs_pre_entry != 2)
197 if (index_type > 1)
199
200 if (filesize > 0 && base >= filesize) {
202 if (base >> 32 == (base & 0xFFFFFFFF) &&
203 (base & 0xFFFFFFFF) < filesize &&
204 filesize <= 0xFFFFFFFF)
205 base &= 0xFFFFFFFF;
206 else
208 }
209
210 for (i = 0; i < entries_in_use; i++) {
211 if (index_type) {
214 int key = len >= 0;
215 len &= 0x7FFFFFFF;
216
217 #ifdef DEBUG_SEEK
219 #endif
222
223 if (last_pos == pos || pos == base - 8)
228
230 last_pos = pos;
231 } else {
237
240
242
246 }
247
248 if (
avio_seek(pb, offset + 8, SEEK_SET) < 0)
249 return -1;
254
257 return -1;
258 }
259
260 }
261 }
263 return 0;
264 }
265
267 {
268 int i;
269 int64_t j;
270
276 int64_t pos,
size, ts;
277
279 continue;
280
281 while (max < 1024)
282 max += max;
283
287
288 for (j = 0; j <
size; j += max)
291 }
292 }
293
296 {
298 char key[5] = { 0 };
300
301 size += (size & 1);
302
303 if (size == UINT_MAX)
306 if (!value)
310
312
315 }
316
317 static const char months[12][4] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
318 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
319
321 {
322 char month[4], time[9],
buffer[64];
323 int i, day, year;
324 /* parse standard AVI date format (ie. "Mon Mar 10 15:04:43 2003") */
325 if (sscanf(date, "%*3s%*[ ]%3s%*[ ]%2d%*[ ]%8s%*[ ]%4d",
326 month, &day, time, &year) == 4) {
327 for (i = 0; i < 12; i++)
329 snprintf(buffer,
sizeof(buffer),
"%.4d-%.2d-%.2d %s",
330 year, i + 1, day, time);
332 }
333 } else if (date[4] == '/' && date[7] == '/') {
334 date[4] = date[7] = '-';
336 }
337 }
338
340 {
344 switch (tag) {
345 case MKTAG(
'n',
'c',
't',
'g'):
/* Nikon Tags */
346 {
351 const char *
name = NULL;
355 FFMIN(size,
sizeof(buffer) - 1));
356 switch (tag) {
357 case 0x03:
358 name = "maker";
359 break;
360 case 0x04:
361 name = "model";
362 break;
363 case 0x13:
364 name = "creation_time";
365 if (buffer[4] == ':' && buffer[7] == ':')
366 buffer[4] = buffer[7] = '-';
367 break;
368 }
369 if (name)
372 }
373 break;
374 }
375 default:
377 break;
378 }
379 }
380 }
381
383 {
389 int i;
392 int avih_width = 0, avih_height = 0;
393 int amv_file_format = 0;
394 uint64_t list_end = 0;
397
399
401 if (ret < 0)
403
405
409
410 /* first list tag */
411 stream_index = -1;
412 codec_type = -1;
413 frame_period = 0;
414 for (;;) {
416 goto fail;
419
421
422 switch (tag) {
423 case MKTAG(
'L',
'I',
'S',
'T'):
425 /* Ignored, except at start of video packets. */
427
429
430 if (tag1 ==
MKTAG(
'm',
'o',
'v',
'i')) {
432 if (size)
434 else
437 goto end_of_header;
438 }
else if (tag1 ==
MKTAG(
'I',
'N',
'F',
'O'))
440 else if (tag1 ==
MKTAG(
'n',
'c',
'd',
't'))
442
443 break;
444 case MKTAG(
'I',
'D',
'I',
'T'):
445 {
446 unsigned char date[64] = { 0 };
447 size += (size & 1);
451 break;
452 }
453 case MKTAG(
'd',
'm',
'l',
'h'):
456 break;
457 case MKTAG(
'a',
'm',
'v',
'h'):
458 amv_file_format = 1;
459 case MKTAG(
'a',
'v',
'i',
'h'):
460 /* AVI header */
461 /* using frame_period is bad idea */
463 avio_rl32(pb);
/* max. bytes per second */
466
472
474 break;
475 case MKTAG(
's',
't',
'r',
'h'):
476 /* stream header */
477
480
481 if (tag1 ==
MKTAG(
'p',
'a',
'd',
's')) {
483 break;
484 } else {
485 stream_index++;
487 if (!st)
488 goto fail;
489
490 st->
id = stream_index;
492 if (!ast)
493 goto fail;
495 }
496 if (amv_file_format)
497 tag1 = stream_index ?
MKTAG(
'a',
'u',
'd',
's')
498 : MKTAG('v', 'i', 'd', 's');
499
501
502 if (tag1 == MKTAG('i', 'a', 'v', 's') ||
503 tag1 == MKTAG('i', 'v', 'a', 's')) {
504 int64_t dv_dur;
505
506 /* After some consideration -- I don't think we
507 * have to support anything but DV in type1 AVIs. */
509 goto fail;
510
511 if (handler != MKTAG('d', 'v', 's', 'd') &&
512 handler != MKTAG('d', 'v', 'h', 'd') &&
513 handler != MKTAG('d', 'v', 's', 'l'))
514 goto fail;
515
524 if (CONFIG_DV_DEMUXER) {
527 goto fail;
528 } else
529 goto fail;
535
537 if (ast->
scale > 0 && ast->
rate > 0 && dv_dur > 0) {
540 }
541 /* else, leave duration alone; timing estimation in utils.c
542 * will make a guess based on bitrate. */
543
546 break;
547 }
548
551
560 "scale/rate is %u/%u which is invalid. "
561 "(This file has been generated by broken software.)\n",
564 if (frame_period) {
566 ast->
scale = frame_period;
567 } else {
570 }
571 }
573
576
583 }
586 av_dlog(s,
"%"PRIu32
" %"PRIu32
" %d\n",
588
589 switch (tag1) {
590 case MKTAG('v', 'i', 'd', 's'):
592
594 break;
595 case MKTAG('a', 'u', 'd', 's'):
597 break;
598 case MKTAG('t', 'x', 't', 's'):
600 break;
601 case MKTAG('d', 'a', 't', 's'):
603 break;
604 default:
606 }
612 }
613 }
616 break;
617 case MKTAG('s', 't', 'r', 'f'):
618 /* stream header */
619 if (!size)
620 break;
623 } else {
625 unsigned esize;
626 if (cur_pos < list_end)
627 size =
FFMIN(size, list_end - cur_pos);
631 break;
632 }
633 switch (codec_type) {
635 if (amv_file_format) {
641 break;
642 }
644
645 if (tag1 == MKTAG('D', 'X', 'S', 'B') ||
646 tag1 == MKTAG('D', 'X', 'S', 'A')) {
650 break;
651 }
652
653 if (size > 10 * 4 && size < (1 << 30) &&
size < avi->fsize) {
654 if (esize == size-1 && (esize&1)) {
656 } else
660 }
661
662 // FIXME: check if the encoder really did this correctly
665
666 /* Extract palette from extradata if bpp <= 8.
667 * This code assumes that extradata contains only palette.
668 * This is true for all paletted codecs implemented in
669 * FFmpeg. */
674
678 for (i = 0; i < pal_size / 4; i++)
679 ast->
pal[i] = 0xFFU<<24 |
AV_RL32(pal_src+4*i);
681 }
682
684
688 tag1);
689 /* This is needed to get the pict type which is necessary
690 * for generating correct pts. */
694
703 } else
705 "BottomUp", 9);
706 }
708
709 // avio_skip(pb, size - 5 * 4);
710 break;
713 if (ret < 0)
720 "sample size (%d) != block align (%d)\n",
724 }
725 /* 2-aligned
726 * (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
727 if (size & 1)
729 /* Force parsing as several audio frames can be in
730 * one packet and timestamps refer to packet start. */
732 /* ADTS header is in extradata, AAC without header must be
733 * stored as exact frames. Parser not needed and it will
734 * fail. */
738 /* AVI files with Xan DPCM audio (wrongly) declare PCM
739 * audio in the header but have Axan as stream_code_tag. */
744 }
745 if (amv_file_format) {
748 }
752 }
758 }
759 break;
764 break;
765 default:
770 break;
771 }
772 }
773 break;
774 case MKTAG('s', 't', 'r', 'd'):
779 } else {
781 if (cur_pos < list_end)
782 size =
FFMIN(size, list_end - cur_pos);
784
785 if (size<(1<<30)) {
788 }
789
792 }
793 break;
794 case MKTAG('i', 'n', 'd', 'x'):
800 goto fail;
802 break;
803 case MKTAG('v', 'p', 'r', 'p'):
804 if (stream_index < (
unsigned)s->
nb_streams && size > 9 * 4) {
806
813
819
820 if (active_aspect.
num && active_aspect.
den &&
821 active.
num && active.
den) {
823 av_dlog(s,
"vprp %d/%d %d/%d\n",
824 active_aspect.
num, active_aspect.
den,
826 }
827 size -= 9 * 4;
828 }
830 break;
831 case MKTAG('s', 't', 'r', 'n'):
834 if (ret < 0)
836 break;
837 }
838 default:
839 if (size > 1000000) {
841 "Something went wrong during header parsing, "
842 "I will ignore it and try to continue anyway.\n");
844 goto fail;
847 goto end_of_header;
848 }
849 /* skip tag */
850 size += (size & 1);
852 break;
853 }
854 }
855
856 end_of_header:
857 /* check stream number */
859
860 fail:
862 }
863
868
870 if (dict_entry && !strcmp(dict_entry->
value,
"PotEncoder"))
876 }
877
881 break;
882 }
883 // DV-in-AVI cannot be non-interleaved, if set this must be
884 // a mis-detection.
889 "Non-interleaved AVI without index, switching to interleaved\n");
891 }
892
896 }
897
900
901 return 0;
902 }
903
905 {
906 if (pkt->
size >= 7 &&
915 0, NULL, NULL, NULL, NULL);
918
920 goto error;
921
924 if (*desc)
926
929
933 goto error;
934
936 goto error;
937
945 }
947 memset(pkt, 0, sizeof(*pkt));
948 return 1;
949
950 error:
952 }
953 return 0;
954 }
955
958 {
960 int64_t ts, next_ts, ts_min = INT64_MAX;
962 int i;
963
966
972 if (ts <= next_ts && ts < ts_min) {
973 ts_min = ts;
974 sub_st = st;
975 }
976 }
977 }
978
979 if (sub_st) {
983
986 }
987 return sub_st;
988 }
989
991 {
992 if (d[0] >= '0' && d[0] <= '9' &&
993 d[1] >= '0' && d[1] <= '9') {
994 return (d[0] - '0') * 10 + (d[1] - '0');
995 } else {
996 return 100; // invalid stream ID
997 }
998 }
999
1000 /**
1001 *
1002 * @param exit_early set to 1 to just gather packet position without making the changes needed to actually read & return the packet
1003 */
1005 {
1009 unsigned int d[8];
1012
1013 start_sync:
1014 memset(d, -1, sizeof(d));
1016 int j;
1017
1018 for (j = 0; j < 7; j++)
1019 d[j] = d[j + 1];
1021
1022 size = d[4] + (d[5] << 8) + (d[6] << 16) + (d[7] << 24);
1023
1025 av_dlog(s,
"%X %X %X %X %X %X %X %X %"PRId64
" %u %d\n",
1026 d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], i, size, n);
1027 if (i*(avi->
io_fsize>0) + (uint64_t)size > avi->
fsize || d[0] > 127)
1028 continue;
1029
1030 // parse ix##
1031 if ((d[0] == 'i' && d[1] == 'x' && n < s->nb_streams) ||
1032 // parse JUNK
1033 (d[0] == 'J' && d[1] == 'U' && d[2] == 'N' && d[3] == 'K') ||
1034 (d[0] == 'i' && d[1] == 'd' && d[2] == 'x' && d[3] == '1')) {
1036 goto start_sync;
1037 }
1038
1039 // parse stray LIST
1040 if (d[0] == 'L' && d[1] == 'I' && d[2] == 'S' && d[3] == 'T') {
1042 goto start_sync;
1043 }
1044
1046
1049 continue;
1050
1051 // detect ##ix chunk and skip
1052 if (d[2] == 'i' && d[3] == 'x' && n < s->nb_streams) {
1054 goto start_sync;
1055 }
1056
1057 // parse ##dc/##wb
1058 if (n < s->nb_streams) {
1063
1064 if (!ast) {
1066 continue;
1067 }
1068
1072 // workaround for broken small-file-bug402.avi
1073 if ( d[2] == 'w' && d[3] == 'b'
1074 && n == 0
1077 && ast->
prefix ==
'd'*256+
'c'
1079 ) {
1080 n = 1;
1081 st = st1;
1082 ast = ast1;
1084 "Invalid stream + prefix combination, assuming audio.\n");
1085 }
1086 }
1087
1090 // FIXME: needs a little reordering
1091 (st->discard >= AVDISCARD_NONKEY &&
1092 !(pkt->flags & AV_PKT_FLAG_KEY)) */
1094 if (!exit_early) {
1097 goto start_sync;
1098 }
1099 }
1100
1101 if (d[2] == 'p' && d[3] == 'c' && size <= 4 * 256 + 4) {
1103 int last = (k +
avio_r8(pb) - 1) & 0xFF;
1104
1106
1107 // b + (g << 8) + (r << 16);
1108 for (; k <= last; k++)
1110
1112 goto start_sync;
1114 d[2] < 128 && d[3] < 128) ||
1115 d[2] * 256 + d[3] == ast->
prefix /* ||
1116 (d[2] == 'd' && d[3] == 'c') ||
1117 (d[2] == 'w' && d[3] == 'b') */) {
1118 if (exit_early)
1119 return 0;
1120 if (d[2] * 256 + d[3] == ast->
prefix)
1122 else {
1123 ast->
prefix = d[2] * 256 + d[3];
1125 }
1126
1130
1137 }
1138 }
1139 return 0;
1140 }
1141 }
1142 }
1143
1147 }
1148
1150 {
1153 int err;
1154 #if FF_API_DESTRUCT_PACKET
1155 void *dstr;
1156 #endif
1157
1158 if (CONFIG_DV_DEMUXER && avi->
dv_demux) {
1160 if (size >= 0)
1162 else
1164 }
1165
1167 int best_stream_index = 0;
1170 int64_t best_ts = INT64_MAX;
1171 int i;
1172
1177 int64_t last_ts;
1178
1180 continue;
1181
1184 continue;
1185
1189
1190 av_dlog(s,
"%"PRId64
" %d/%d %"PRId64
"\n", ts,
1191 st->time_base.num, st->time_base.den, ast->frame_offset);
1192 if (ts < best_ts) {
1193 best_ts = ts;
1194 best_st = st;
1195 best_stream_index = i;
1196 }
1197 }
1198 if (!best_st)
1200
1201 best_ast = best_st->priv_data;
1202 best_ts = best_ast->frame_offset;
1203 if (best_ast->remaining) {
1205 best_ts,
1208 } else {
1210 if (i >= 0)
1211 best_ast->frame_offset = best_st->index_entries[i].timestamp;
1212 }
1213
1214 if (i >= 0) {
1215 int64_t pos = best_st->index_entries[i].pos;
1216 pos += best_ast->packet_size - best_ast->remaining;
1219
1220 av_assert0(best_ast->remaining <= best_ast->packet_size);
1221
1223 if (!best_ast->remaining)
1224 best_ast->packet_size =
1225 best_ast->remaining = best_st->index_entries[i].size;
1226 }
1227 else
1229 }
1230
1232 if (avi->stream_index >= 0) {
1233 AVStream *st =
s->streams[avi->stream_index];
1236
1238 return 0;
1239
1240 // minorityreport.AVI block_align=1024 sample_size=1 IMA-ADPCM
1242 size = INT_MAX;
1244 // arbitrary multiplier to avoid tiny packets for raw PCM data
1246 else
1248
1253 if (err < 0)
1254 return err;
1255 size = err;
1256
1262 if (!pal) {
1264 "Failed to allocate data for palette\n");
1265 } else {
1268 }
1269 }
1270
1271 if (CONFIG_DV_DEMUXER && avi->dv_demux) {
1273 #if FF_API_DESTRUCT_PACKET
1277 #endif
1280 #if FF_API_DESTRUCT_PACKET
1284 #endif
1287 if (size < 0)
1292 avi->stream_index = -1;
1295 } else {
1296 /* XXX: How to handle B-frames in AVI? */
1298 // pkt->dts += ast->start;
1302 "dts:%"PRId64" offset:%"PRId64" %d/%d smpl_siz:%d "
1303 "base:%d st:%d size:%d\n",
1310 avi->stream_index,
1311 size);
1313
1317
1320
1323 int key=1;
1324 int i;
1326 for (i=0; i<
FFMIN(size,256); i++) {
1328 if (state == 0x1B6) {
1330 break;
1331 }
1332 }else
1333 break;
1334 state= (state<<8) +
pkt->
data[i];
1335 }
1336 if (!key)
1338 }
1341 }
1342 } else {
1344 }
1346 }
1349 avi->stream_index = -1;
1351 }
1352
1356 }
1358
1359 if (!avi->non_interleaved && st->
nb_index_entries>1 && avi->index_loaded>1) {
1361
1363 avi->non_interleaved= 1;
1365 }else if (avi->dts_max < dts)
1366 avi->dts_max = dts;
1367 }
1368
1369 return 0;
1370 }
1371
1373 return err;
1375 }
1376
1377 /* XXX: We make the implicit supposition that the positions are sorted
1378 * for each stream. */
1380 {
1383 int nb_index_entries, i;
1387 unsigned last_pos = -1;
1388 unsigned last_idx = -1;
1389 int64_t idx1_pos, first_packet_pos = 0, data_offset = 0;
1390 int anykey = 0;
1391
1392 nb_index_entries = size / 16;
1393 if (nb_index_entries <= 0)
1395
1402
1404 first_packet_pos = 0;
1406 }
1407
1408 /* Read the entries and sort them in each stream component. */
1409 for (i = 0; i < nb_index_entries; i++) {
1411 return -1;
1412
1417 av_dlog(s,
"%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",
1418 i, tag, flags, pos, len);
1419
1420 index = ((tag & 0xff) - '0') * 10;
1421 index += (tag >> 8 & 0xff) - '0';
1423 continue;
1426
1427 if (first_packet && first_packet_pos) {
1428 data_offset = first_packet_pos - pos;
1429 first_packet = 0;
1430 }
1431 pos += data_offset;
1432
1434
1435 // even if we have only a single stream, we should
1436 // switch to non-interleaved to get correct timestamps
1437 if (last_pos == pos)
1439 if (last_idx != pos && len) {
1442 last_idx= pos;
1443 }
1445 last_pos = pos;
1447 }
1448 if (!anykey) {
1449 for (index = 0; index < s->
nb_streams; index++) {
1453 }
1454 }
1455 return 0;
1456 }
1457
1459 {
1460 int i;
1461 int64_t last_start = 0;
1462 int64_t first_end = INT64_MAX;
1464 int *idx;
1465 int64_t min_pos, pos;
1466
1471
1472 if (n <= 0)
1473 continue;
1474
1475 if (n >= 2) {
1480 last_start = INT64_MAX;
1481 }
1482
1487 }
1489 if (last_start > first_end)
1490 return 1;
1492 if (!idx)
1493 return 0;
1494 for (min_pos=pos=0; min_pos!=INT64_MAX; pos= min_pos+1LU) {
1495 int64_t max_dts = INT64_MIN/2, min_dts= INT64_MAX/2;
1496 min_pos = INT64_MAX;
1497
1503 idx[i]++;
1504 if (idx[i] < n) {
1507 }
1508 if (idx[i])
1510 }
1513 return 1;
1514 }
1515 }
1517 return 0;
1518 }
1519
1521 {
1526 int64_t next;
1528
1530 goto the_end; // maybe truncated file
1532 for (;;) {
1536 break;
1537 next =
avio_tell(pb) + size + (size & 1);
1538
1539 av_dlog(s,
"tag=%c%c%c%c size=0x%x\n",
1540 tag & 0xff,
1541 (tag >> 8) & 0xff,
1542 (tag >> 16) & 0xff,
1543 (tag >> 24) & 0xff,
1544 size);
1545
1546 if (tag ==
MKTAG(
'i',
'd',
'x',
'1') &&
1549 ret = 0;
1550 }
else if (tag ==
MKTAG(
'L',
'I',
'S',
'T')) {
1552
1553 if (tag1 ==
MKTAG(
'I',
'N',
'F',
'O'))
1555 }else if (!ret)
1556 break;
1557
1559 break; // something is wrong here
1560 }
1561
1562 the_end:
1565 }
1566
1568 {
1575 }
1576
1578 int64_t timestamp,
int flags)
1579 {
1583 int64_t pos, pos_min;
1585
1586 /* Does not matter which stream is requested dv in avi has the
1587 * stream information in the first video stream.
1588 */
1590 stream_index = 0;
1591
1593 /* we only load the index on demand */
1596 }
1598
1599 st = s->
streams[stream_index];
1603 flags);
1604 if (index < 0) {
1606 av_log(s,
AV_LOG_DEBUG,
"Failed to find timestamp %"PRId64
" in index %"PRId64
" .. %"PRId64
"\n",
1611 }
1612
1613 /* find the position */
1616
1617 av_dlog(s,
"XX %"PRId64
" %d %"PRId64
"\n",
1619
1620 if (CONFIG_DV_DEMUXER && avi->
dv_demux) {
1621 /* One and only one real stream for DV in AVI, and it has video */
1622 /* offsets. Calling with other stream indexes should have failed */
1623 /* the av_index_search_timestamp call above. */
1624
1626 return -1;
1627
1628 /* Feed the DV video stream version of the timestamp to the */
1629 /* DV demux so it can synthesize correct timestamps. */
1631
1633 return 0;
1634 }
1635
1636 pos_min = pos;
1640
1643
1646 continue;
1647 }
1648
1650 continue;
1651
1652 // av_assert1(st2->codec->block_align);
1660 flags |
1663 if (index < 0)
1664 index = 0;
1667 }
1671
1673 continue;
1674
1676 st2,
1679 if (index < 0)
1680 index = 0;
1682 index--;
1684 }
1685
1686 /* do the seek */
1689 return -1;
1690 }
1693 return 0;
1694 }
1695
1697 {
1698 int i;
1700
1704 if (ast) {
1708 }
1711 }
1712 }
1713
1715
1716 return 0;
1717 }
1718
1720 {
1721 int i;
1722
1723 /* check file header */
1728
1729 return 0;
1730 }
1731
1741 .priv_class = &demuxer_class,
1742 };