Revision 84df78b4 libavformat/mpegtsenc.c

View differences:

libavformat/mpegtsenc.c
701 701
    uint8_t *buf= pkt->data;
702 702
    uint8_t *data= NULL;
703 703
    MpegTSWriteStream *ts_st = st->priv_data;
704
    const uint8_t *access_unit_index = NULL;
705 704
    const uint64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
706 705
    int64_t dts = AV_NOPTS_VALUE, pts = AV_NOPTS_VALUE;
707 706

  
......
732 731
            buf  = data;
733 732
            size = pkt->size+6;
734 733
        }
735
        access_unit_index = buf;
736
    } else {
737
        access_unit_index = pkt->data;
738
    }
739

  
740
    if (!access_unit_index) {
741
        av_log(s, AV_LOG_ERROR, "error, could not find access unit start\n");
742
        return -1;
743 734
    }
744 735

  
745 736
    if (st->codec->codec_type == CODEC_TYPE_SUBTITLE ||
......
750 741
        return 0;
751 742
    }
752 743

  
744
    if (ts_st->payload_pts == AV_NOPTS_VALUE) {
745
        ts_st->payload_dts = dts;
746
        ts_st->payload_pts = pts;
747
    }
748

  
753 749
    // audio
754 750
    while (size > 0) {
755 751
        len = DEFAULT_PES_PAYLOAD_SIZE - ts_st->payload_index;
......
759 755
        buf += len;
760 756
        size -= len;
761 757
        ts_st->payload_index += len;
762
        if (access_unit_index && access_unit_index < buf &&
763
            ts_st->payload_pts == AV_NOPTS_VALUE &&
764
            ts_st->payload_dts == AV_NOPTS_VALUE) {
765
            ts_st->payload_dts = dts;
766
            ts_st->payload_pts = pts;
767
        }
768 758
        if (ts_st->payload_index >= DEFAULT_PES_PAYLOAD_SIZE) {
769 759
            mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
770 760
                             ts_st->payload_pts, ts_st->payload_dts);
771 761
            ts_st->payload_pts = AV_NOPTS_VALUE;
772 762
            ts_st->payload_dts = AV_NOPTS_VALUE;
773 763
            ts_st->payload_index = 0;
774
            access_unit_index = NULL; // unset access unit to avoid setting pts/dts again
775 764
        }
776 765
    }
777 766

  

Also available in: Unified diff