Ticket #3000: dvd-fix.patch
File dvd-fix.patch, 3.6 KB (added by , 17 years ago) |
---|
-
libs/libavformat/mpeg.c
1440 1440 { 1441 1441 MpegDemuxContext *m = s->priv_data; 1442 1442 int len, size, startcode, c, flags, header_len; 1443 int64_t pts, dts; 1444 int64_t last_sync= url_ftell(&s->pb); 1443 int64_t pts, dts, last_pos; 1445 1444 1446 error_redo: 1447 url_fseek(&s->pb, last_sync, SEEK_SET); 1445 last_pos = -1; 1448 1446 redo: 1449 1447 /* next start code (should be immediately after) */ 1450 1448 m->header_state = 0xff; 1451 1449 size = MAX_SYNC_SIZE; 1452 1450 startcode = find_next_start_code(&s->pb, &size, &m->header_state); 1453 last_sync = url_ftell(&s->pb); 1454 //printf("startcode=%x pos=0x%"PRIx64"\n", startcode, url_ftell(&s->pb)); 1451 //printf("startcode=%x pos=0x%Lx\n", startcode, url_ftell(&s->pb)); 1455 1452 if (startcode < 0) 1456 1453 return AVERROR_IO; 1457 1454 if (startcode == PACK_START_CODE) … … 1484 1481 /* stuffing */ 1485 1482 for(;;) { 1486 1483 if (len < 1) 1487 goto error_redo;1484 goto redo; 1488 1485 c = get_byte(&s->pb); 1489 1486 len--; 1490 1487 /* XXX: for mpeg1, should test only bit 7 */ … … 1493 1490 } 1494 1491 if ((c & 0xc0) == 0x40) { 1495 1492 /* buffer scale & size */ 1493 if (len < 2) 1494 goto redo; 1496 1495 get_byte(&s->pb); 1497 1496 c = get_byte(&s->pb); 1498 1497 len -= 2; 1499 1498 } 1500 if ((c & 0xe0) == 0x20) { 1499 if ((c & 0xf0) == 0x20) { 1500 if (len < 4) 1501 goto redo; 1501 1502 dts = pts = get_pts(&s->pb, c); 1502 1503 len -= 4; 1503 if (c & 0x10){ 1504 dts = get_pts(&s->pb, -1); 1505 len -= 5; 1506 } 1504 } else if ((c & 0xf0) == 0x30) { 1505 if (len < 9) 1506 goto redo; 1507 pts = get_pts(&s->pb, c); 1508 dts = get_pts(&s->pb, -1); 1509 len -= 9; 1507 1510 } else if ((c & 0xc0) == 0x80) { 1508 1511 /* mpeg 2 PES */ 1509 1512 #if 0 /* some streams have this field set for no apparent reason */ … … 1516 1519 header_len = get_byte(&s->pb); 1517 1520 len -= 2; 1518 1521 if (header_len > len) 1519 goto error_redo; 1520 len -= header_len; 1521 if (flags & 0x80) { 1522 goto redo; 1523 if ((flags & 0xc0) == 0x80) { 1522 1524 dts = pts = get_pts(&s->pb, -1); 1525 if (header_len < 5) 1526 goto redo; 1523 1527 header_len -= 5; 1524 if (flags & 0x40) { 1525 dts = get_pts(&s->pb, -1); 1526 header_len -= 5; 1527 } 1528 len -= 5; 1529 } if ((flags & 0xc0) == 0xc0) { 1530 pts = get_pts(&s->pb, -1); 1531 dts = get_pts(&s->pb, -1); 1532 if (header_len < 10) 1533 goto redo; 1534 header_len -= 10; 1535 len -= 10; 1528 1536 } 1529 if(header_len < 0) 1530 goto error_redo; 1531 url_fskip(&s->pb, header_len); 1537 len -= header_len; 1538 while (header_len > 0) { 1539 get_byte(&s->pb); 1540 header_len--; 1541 } 1532 1542 } 1533 1543 else if( c!= 0xf ) 1534 1544 goto redo; 1535 1545 1536 1546 if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) { 1547 if (len < 1) 1548 goto redo; 1537 1549 startcode = get_byte(&s->pb); 1538 1550 len--; 1539 1551 if (startcode >= 0x80 && startcode <= 0xbf) { 1540 1552 /* audio: skip header */ 1553 if (len < 3) 1554 goto redo; 1541 1555 get_byte(&s->pb); 1542 1556 get_byte(&s->pb); 1543 1557 get_byte(&s->pb); 1544 1558 len -= 3; 1545 1559 } 1546 1560 } 1547 if(len<0)1548 goto error_redo;1549 1561 if(dts != AV_NOPTS_VALUE && ppos && s->build_index){ 1550 1562 int i; 1551 1563 for(i=0; i<s->nb_streams; i++){