Revision 06599638 libavformat/nutdec.c

View differences:

libavformat/nutdec.c
637 637
    return 0;
638 638
}
639 639

  
640
static int decode_frame_header(NUTContext *nut, int *flags_ret, int64_t *pts, int *stream_id, int frame_code){
640
static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, int frame_code){
641 641
    AVFormatContext *s= nut->avf;
642 642
    ByteIOContext *bc = &s->pb;
643 643
    StreamContext *stc;
......
682 682
        get_v(bc);
683 683
    if(flags&FLAG_CHECKSUM){
684 684
        get_be32(bc); //FIXME check this
685
    }else if(size > 2*nut->max_distance){
685
    }else if(size > 2*nut->max_distance || FFABS(stc->last_pts - *pts) > stc->max_pts_distance){
686 686
        av_log(s, AV_LOG_ERROR, "frame size > 2max_distance and no checksum\n");
687 687
        return -1;
688 688
    }
689
    *flags_ret= flags;
690 689

  
691 690
    stc->last_pts= *pts;
692
    stc->last_key_frame= flags&FLAG_KEY; //FIXME change to last flags
691
    stc->last_flags= flags;
693 692

  
694 693
    return size;
695 694
}
......
697 696
static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
698 697
    AVFormatContext *s= nut->avf;
699 698
    ByteIOContext *bc = &s->pb;
700
    int size, stream_id, flags, discard;
699
    int size, stream_id, discard;
701 700
    int64_t pts, last_IP_pts;
701
    StreamContext *stc;
702 702

  
703
    size= decode_frame_header(nut, &flags, &pts, &stream_id, frame_code);
703
    size= decode_frame_header(nut, &pts, &stream_id, frame_code);
704 704
    if(size < 0)
705 705
        return -1;
706 706

  
707
    if (flags & FLAG_KEY)
708
        nut->stream[stream_id].skip_until_key_frame=0;
707
    stc= &nut->stream[stream_id];
708

  
709
    if (stc->last_flags & FLAG_KEY)
710
        stc->skip_until_key_frame=0;
709 711

  
710 712
    discard= s->streams[ stream_id ]->discard;
711 713
    last_IP_pts= s->streams[ stream_id ]->last_IP_pts;
712
    if(  (discard >= AVDISCARD_NONKEY && !(flags & FLAG_KEY))
714
    if(  (discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY))
713 715
       ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
714 716
       || discard >= AVDISCARD_ALL
715
       || nut->stream[stream_id].skip_until_key_frame){
717
       || stc->skip_until_key_frame){
716 718
        url_fskip(bc, size);
717 719
        return 1;
718 720
    }
719 721

  
720 722
    av_get_packet(bc, pkt, size);
721 723
    pkt->stream_index = stream_id;
722
    if (flags & FLAG_KEY)
724
    if (stc->last_flags & FLAG_KEY)
723 725
        pkt->flags |= PKT_FLAG_KEY;
724 726
    pkt->pts = pts;
725 727

  

Also available in: Unified diff