Mercurial > libavformat.hg
comparison nut.c @ 468:60f897e8dd2d libavformat
pass AVPacket into av_write_frame()
fixes the random dts/pts during encoding
asf preroll fix
no more initial zero frames for b frame encoding
mpeg-es dts during demuxing fixed
.ffm timestamp scale fixed, ffm is still broken though
author | michael |
---|---|
date | Sat, 29 May 2004 02:06:32 +0000 |
parents | 696f41bc8784 |
children | ac85aafd0971 |
comparison
equal
deleted
inserted
replaced
467:40069a91d1a0 | 468:60f897e8dd2d |
---|---|
689 int64_t mask = (1<<stream->msb_timestamp_shift)-1; | 689 int64_t mask = (1<<stream->msb_timestamp_shift)-1; |
690 int64_t delta= stream->last_pts - mask/2; | 690 int64_t delta= stream->last_pts - mask/2; |
691 return ((lsb - delta)&mask) + delta; | 691 return ((lsb - delta)&mask) + delta; |
692 } | 692 } |
693 | 693 |
694 static int nut_write_packet(AVFormatContext *s, int stream_index, | 694 static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) |
695 const uint8_t *buf, int size, int64_t pts) | |
696 { | 695 { |
697 NUTContext *nut = s->priv_data; | 696 NUTContext *nut = s->priv_data; |
698 StreamContext *stream= &nut->stream[stream_index]; | 697 StreamContext *stream= &nut->stream[pkt->stream_index]; |
699 ByteIOContext *bc = &s->pb; | 698 ByteIOContext *bc = &s->pb; |
700 int key_frame = 0, full_pts=0; | 699 int key_frame = 0, full_pts=0; |
701 AVCodecContext *enc; | 700 AVCodecContext *enc; |
702 int64_t coded_pts; | 701 int64_t coded_pts; |
703 int frame_type, best_length, frame_code, flags, i, size_mul, size_lsb, time_delta; | 702 int frame_type, best_length, frame_code, flags, i, size_mul, size_lsb, time_delta; |
704 const int64_t frame_start= url_ftell(bc); | 703 const int64_t frame_start= url_ftell(bc); |
705 | 704 int64_t pts= pkt->pts; |
706 if (stream_index > s->nb_streams) | 705 int size= pkt->size; |
707 return 1; | 706 int stream_index= pkt->stream_index; |
708 | 707 |
709 enc = &s->streams[stream_index]->codec; | 708 enc = &s->streams[stream_index]->codec; |
710 key_frame = enc->coded_frame->key_frame; | 709 key_frame = !!(pkt->flags & PKT_FLAG_KEY); |
711 if(enc->coded_frame->pts != AV_NOPTS_VALUE) | |
712 pts= av_rescale(enc->coded_frame->pts, stream->rate_num, stream->rate_den*(int64_t)AV_TIME_BASE); //FIXME XXX HACK | |
713 | 710 |
714 frame_type=0; | 711 frame_type=0; |
715 if(frame_start + size + 20 - FFMAX(nut->packet_start[1], nut->packet_start[2]) > MAX_DISTANCE) | 712 if(frame_start + size + 20 - FFMAX(nut->packet_start[1], nut->packet_start[2]) > MAX_DISTANCE) |
716 frame_type=2; | 713 frame_type=2; |
717 if(key_frame && !stream->last_key_frame) | 714 if(key_frame && !stream->last_key_frame) |
806 assert(size == size_lsb); | 803 assert(size == size_lsb); |
807 if(size > MAX_DISTANCE){ | 804 if(size > MAX_DISTANCE){ |
808 assert(frame_type > 1); | 805 assert(frame_type > 1); |
809 } | 806 } |
810 | 807 |
811 put_buffer(bc, buf, size); | 808 put_buffer(bc, pkt->data, size); |
812 | 809 |
813 update(nut, stream_index, frame_start, frame_type, frame_code, key_frame, size, pts); | 810 update(nut, stream_index, frame_start, frame_type, frame_code, key_frame, size, pts); |
814 | 811 |
815 return 0; | 812 return 0; |
816 } | 813 } |