comparison libmpdemux/muxer_mpeg.c @ 22909:94183c81ec0c

reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
author nicodvb
date Sat, 07 Apr 2007 08:51:26 +0000
parents 2d01760be338
children 60498e21115a
comparison
equal deleted inserted replaced
22908:af17e1f03199 22909:94183c81ec0c
1458 int skip_cnt; 1458 int skip_cnt;
1459 uint64_t init_delay = 0; 1459 uint64_t init_delay = 0;
1460 muxer_stream_t *s, *vs, *as; 1460 muxer_stream_t *s, *vs, *as;
1461 muxer_headers_t *vpriv = NULL, *apriv = NULL; 1461 muxer_headers_t *vpriv = NULL, *apriv = NULL;
1462 muxer_priv_t *priv = (muxer_priv_t *) muxer->priv; 1462 muxer_priv_t *priv = (muxer_priv_t *) muxer->priv;
1463 double duration;
1464 uint64_t iduration, iaduration;
1463 1465
1464 /* 1466 /*
1465 analyzes all streams and decides what to flush 1467 analyzes all streams and decides what to flush
1466 trying to respect an interleaving distribution 1468 trying to respect an interleaving distribution
1467 equal to the v_bitrate/a_bitrate proportion 1469 equal to the v_bitrate/a_bitrate proportion
1493 if(found) 1495 if(found)
1494 { 1496 {
1495 mp_msg(MSGT_MUXER, MSGL_DBG2, "\nVIDEO, FLUSH %d frames (of %d), 0 to %d\n", n, vpriv->framebuf_used, n-1); 1497 mp_msg(MSGT_MUXER, MSGL_DBG2, "\nVIDEO, FLUSH %d frames (of %d), 0 to %d\n", n, vpriv->framebuf_used, n-1);
1496 1498
1497 vpriv = (muxer_headers_t*) vs->priv; 1499 vpriv = (muxer_headers_t*) vs->priv;
1498 1500
1499 if(as != NULL) apriv = (muxer_headers_t*) as->priv; 1501 duration = 0;
1502 iduration = 0;
1503 for(i = 0; i < n; i++)
1504 iduration += vpriv->framebuf[i].idur;
1505 duration = (double) (iduration / 27000000.0);
1506
1507 if(as != NULL)
1508 {
1509 apriv = (muxer_headers_t*) as->priv;
1510 iaduration = 0;
1511 for(i = 0; i < apriv->framebuf_used; i++)
1512 {
1513 iaduration += apriv->framebuf[i].idur;
1514 }
1515 if(iaduration < iduration)
1516 {
1517 mp_msg(MSGT_MUXER, MSGL_DBG2, "Not enough audio data exit\n");
1518 return 0;
1519 }
1520 }
1521
1500 if(as != NULL && (apriv->size == 0)) 1522 if(as != NULL && (apriv->size == 0))
1501 { 1523 {
1502 apriv = (muxer_headers_t*) as->priv;
1503 init_delay = vpriv->framebuf[0].pts - vpriv->framebuf[0].dts; 1524 init_delay = vpriv->framebuf[0].pts - vpriv->framebuf[0].dts;
1504 1525
1505 for(i = 0; i < apriv->framebuf_cnt; i++) 1526 for(i = 0; i < apriv->framebuf_cnt; i++)
1506 { 1527 {
1507 apriv->framebuf[i].pts += init_delay; 1528 apriv->framebuf[i].pts += init_delay;