comparison utils.c @ 570:d82ccc7cff1c libavformat

set keyframe flag at a more central place instead of in every demuxer for containers which only store intra only streams
author michael
date Fri, 22 Oct 2004 01:51:17 +0000
parents d141aa45ca86
children 640706a29efb
comparison
equal deleted inserted replaced
569:aca10aa7686f 570:d82ccc7cff1c
589 default: 589 default:
590 break; 590 break;
591 } 591 }
592 } 592 }
593 593
594 static int is_intra_only(AVCodecContext *enc){
595 if(enc->codec_type == CODEC_TYPE_AUDIO){
596 return 1;
597 }else if(enc->codec_type == CODEC_TYPE_VIDEO){
598 switch(enc->codec_id){
599 case CODEC_ID_MJPEG:
600 case CODEC_ID_MJPEGB:
601 case CODEC_ID_LJPEG:
602 case CODEC_ID_RAWVIDEO:
603 case CODEC_ID_DVVIDEO:
604 case CODEC_ID_HUFFYUV:
605 case CODEC_ID_ASV1:
606 case CODEC_ID_ASV2:
607 case CODEC_ID_VCR1:
608 return 1;
609 default: break;
610 }
611 }
612 return 0;
613 }
614
594 static int64_t lsb2full(int64_t lsb, int64_t last_ts, int lsb_bits){ 615 static int64_t lsb2full(int64_t lsb, int64_t last_ts, int lsb_bits){
595 int64_t mask = lsb_bits < 64 ? (1LL<<lsb_bits)-1 : -1LL; 616 int64_t mask = lsb_bits < 64 ? (1LL<<lsb_bits)-1 : -1LL;
596 int64_t delta= last_ts - mask/2; 617 int64_t delta= last_ts - mask/2;
597 return ((lsb - delta)&mask) + delta; 618 return ((lsb - delta)&mask) + delta;
598 } 619 }
614 compute_frame_duration(&num, &den, st, pc, pkt); 635 compute_frame_duration(&num, &den, st, pc, pkt);
615 if (den && num) { 636 if (den && num) {
616 pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num); 637 pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num);
617 } 638 }
618 } 639 }
640
641 if(is_intra_only(&st->codec))
642 pkt->flags |= PKT_FLAG_KEY;
619 643
620 /* do we have a video B frame ? */ 644 /* do we have a video B frame ? */
621 presentation_delayed = 0; 645 presentation_delayed = 0;
622 if (st->codec.codec_type == CODEC_TYPE_VIDEO) { 646 if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
623 /* XXX: need has_b_frame, but cannot get it if the codec is 647 /* XXX: need has_b_frame, but cannot get it if the codec is