Revision 2cbd9c9c

View differences:

src/Chunkiser/output-stream-play.c
358 358
  }
359 359

  
360 360
  if (decoded) {
361
    now= av_gettime();
362 361
    if(AV_NOPTS_VALUE == pic.pkt_pts) {
363 362
      pic.pkt_pts = av_rescale_q(pkt.dts, o->video_time_base, AV_TIME_BASE_Q);
364 363
    } else {
365 364
      pic.pkt_pts = av_rescale_q(pic.pkt_pts, o->video_time_base, AV_TIME_BASE_Q);
366 365
    }
367
    if(o->pts0 == -1){
366
    if (o->pts0 == -1){
368 367
      o->pts0 = pic.pkt_pts;
369 368
      o->last_video_pts = pic.pkt_pts;
370 369
    }
371 370

  
371
    now = av_gettime();
372 372
    difft = pic.pkt_pts - o->pts0 + o->t0 + o->playout_delay - now;
373
    if(difft < 0){
373
    if (difft < 0) {
374 374
      o->consLate++;
375 375
      if (difft < o->maxDelay) {
376 376
        o->maxDelay = difft;
......
379 379
      o->consLate = 0;
380 380
      o->maxDelay = 0;
381 381
    }
382
    if(o->consLate >= o->cLimit) {
382
    if (o->consLate >= o->cLimit) {
383 383
      o->playout_delay -= o->maxDelay;
384
      o->consLate=0;
385
      o->maxDelay=0;
384
      o->consLate = 0;
385
      o->maxDelay = 0;
386 386
    }
387
    if(difft>=0){
387
    if (difft >= 0) {
388 388
      usleep(difft);
389 389
    } else {
390 390
      return NULL;
......
468 468
    if(!o->end){
469 469
      pkt = dequeue(&o->audioq);
470 470
      pthread_mutex_unlock(&o->lockaudio);
471
      difft = 0;
472 471
      now = av_gettime();
473 472
      difft = pkt.pts - o->pts0 + o->t0 + o->playout_delay - now;
474
      if(difft < 0) {
473
      if (difft < 0) {
475 474
        o->consLate++;
476
        if(difft < o->maxDelay) {
477
          o->maxDelay=difft;
475
        if (difft < o->maxDelay) {
476
          o->maxDelay = difft;
478 477
        }
479 478
      } else {
480 479
        o->consLate = 0;
481 480
        o->maxDelay = 0;
482 481
      }
483

  
484
      if(o->consLate >= o->cLimit) {
482
      if (o->consLate >= o->cLimit) {
485 483
        o->playout_delay -= o->maxDelay;
486 484
        o->consLate = 0;
487 485
        o->maxDelay = 0;
488 486
      }
489
      if(difft>=0) {
487
      if (difft >= 0) {
490 488
        usleep(difft);
491 489
        audio_write_packet(o, pkt);
492 490
      }
......
809 807

  
810 808
    if (pts != -1) {
811 809
      pts += (pts < o->prev_pts - ((1LL << 31) - 1)) ? ((o->prev_pts >> 32) + 1) << 32 : (o->prev_pts >> 32) << 32;
812
      //dprintf(" PTS2: %d\n", pts);
813 810
      o->prev_pts = pts;
814
      //dprintf("Frame %d has size %d --- PTS: %lld DTS: %lld\n", i, frame_size,
815
      //                                       av_rescale_q(pts, outctx->streams[0]->codec->time_base, AV_TIME_BASE_Q),
816
      //                                       av_rescale_q(dts, outctx->streams[0]->codec->time_base, AV_TIME_BASE_Q));
817

  
818 811
      pkt.pts = pts;
819 812
    } else {
820 813
      pkt.pts = AV_NOPTS_VALUE;
......
823 816
    o->prev_dts = dts;
824 817
    pkt.dts = dts;
825 818
    // pkt.data = p;
826
    pkt.data = av_mallocz(frame_size+FF_INPUT_BUFFER_PADDING_SIZE);
827
    memcpy(pkt.data,p,frame_size);
819
    pkt.data = av_mallocz(frame_size + FF_INPUT_BUFFER_PADDING_SIZE);
820
    memcpy(pkt.data, p, frame_size);
828 821
    p += frame_size;
829 822
    pkt.size = frame_size;
830 823

  

Also available in: Unified diff