Mercurial > libavformat.hg
comparison asf.c @ 885:da1d5db0ce5c libavformat
COSMETICS: Remove all trailing whitespace.
author | diego |
---|---|
date | Sat, 17 Dec 2005 18:14:38 +0000 |
parents | 91dcb9da9be6 |
children | d70e50f1495f |
comparison
equal
deleted
inserted
replaced
884:2ece9c9dd94c | 885:da1d5db0ce5c |
---|---|
23 | 23 |
24 #undef NDEBUG | 24 #undef NDEBUG |
25 #include <assert.h> | 25 #include <assert.h> |
26 | 26 |
27 #define FRAME_HEADER_SIZE 17 | 27 #define FRAME_HEADER_SIZE 17 |
28 // Fix Me! FRAME_HEADER_SIZE may be different. | 28 // Fix Me! FRAME_HEADER_SIZE may be different. |
29 | 29 |
30 static const GUID index_guid = { | 30 static const GUID index_guid = { |
31 0x33000890, 0xe5b1, 0x11cf, { 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb }, | 31 0x33000890, 0xe5b1, 0x11cf, { 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb }, |
32 }; | 32 }; |
33 | 33 |
196 asf_st = av_mallocz(sizeof(ASFStream)); | 196 asf_st = av_mallocz(sizeof(ASFStream)); |
197 if (!asf_st) | 197 if (!asf_st) |
198 goto fail; | 198 goto fail; |
199 st->priv_data = asf_st; | 199 st->priv_data = asf_st; |
200 st->start_time = asf->hdr.preroll; | 200 st->start_time = asf->hdr.preroll; |
201 st->duration = asf->hdr.send_time / | 201 st->duration = asf->hdr.send_time / |
202 (10000000 / 1000) - st->start_time; | 202 (10000000 / 1000) - st->start_time; |
203 get_guid(pb, &g); | 203 get_guid(pb, &g); |
204 if (!memcmp(&g, &audio_stream, sizeof(GUID))) { | 204 if (!memcmp(&g, &audio_stream, sizeof(GUID))) { |
205 type = CODEC_TYPE_AUDIO; | 205 type = CODEC_TYPE_AUDIO; |
206 } else if (!memcmp(&g, &video_stream, sizeof(GUID))) { | 206 } else if (!memcmp(&g, &video_stream, sizeof(GUID))) { |
422 ASFContext *asf = s->priv_data; | 422 ASFContext *asf = s->priv_data; |
423 ByteIOContext *pb = &s->pb; | 423 ByteIOContext *pb = &s->pb; |
424 uint32_t packet_length, padsize; | 424 uint32_t packet_length, padsize; |
425 int rsize = 9; | 425 int rsize = 9; |
426 int c; | 426 int c; |
427 | 427 |
428 assert((url_ftell(&s->pb) - s->data_offset) % asf->packet_size == 0); | 428 assert((url_ftell(&s->pb) - s->data_offset) % asf->packet_size == 0); |
429 | 429 |
430 c = get_byte(pb); | 430 c = get_byte(pb); |
431 if (c != 0x82) { | 431 if (c != 0x82) { |
432 if (!url_feof(pb)) | 432 if (!url_feof(pb)) |
433 av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, url_ftell(pb)); | 433 av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, url_ftell(pb)); |
434 } | 434 } |
605 /* new packet */ | 605 /* new packet */ |
606 av_new_packet(&asf_st->pkt, asf->packet_obj_size); | 606 av_new_packet(&asf_st->pkt, asf->packet_obj_size); |
607 asf_st->seq = asf->packet_seq; | 607 asf_st->seq = asf->packet_seq; |
608 asf_st->pkt.pts = asf->packet_frag_timestamp; | 608 asf_st->pkt.pts = asf->packet_frag_timestamp; |
609 asf_st->pkt.stream_index = asf->stream_index; | 609 asf_st->pkt.stream_index = asf->stream_index; |
610 asf_st->pkt.pos = | 610 asf_st->pkt.pos = |
611 asf_st->packet_pos= asf->packet_pos; | 611 asf_st->packet_pos= asf->packet_pos; |
612 //printf("new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n", | 612 //printf("new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n", |
613 //asf->stream_index, asf->packet_key_frame, asf_st->pkt.flags & PKT_FLAG_KEY, | 613 //asf->stream_index, asf->packet_key_frame, asf_st->pkt.flags & PKT_FLAG_KEY, |
614 //s->streams[asf->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO, asf->packet_obj_size); | 614 //s->streams[asf->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO, asf->packet_obj_size); |
615 if (s->streams[asf->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO) | 615 if (s->streams[asf->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO) |
616 asf->packet_key_frame = 1; | 616 asf->packet_key_frame = 1; |
617 if (asf->packet_key_frame) | 617 if (asf->packet_key_frame) |
618 asf_st->pkt.flags |= PKT_FLAG_KEY; | 618 asf_st->pkt.flags |= PKT_FLAG_KEY; |
619 } | 619 } |
620 | 620 |
703 asf->packet_frag_timestamp = 0; | 703 asf->packet_frag_timestamp = 0; |
704 asf->packet_multi_size = 0; | 704 asf->packet_multi_size = 0; |
705 asf->packet_obj_size = 0; | 705 asf->packet_obj_size = 0; |
706 asf->packet_time_delta = 0; | 706 asf->packet_time_delta = 0; |
707 asf->packet_time_start = 0; | 707 asf->packet_time_start = 0; |
708 | 708 |
709 for(i=0; i<s->nb_streams; i++){ | 709 for(i=0; i<s->nb_streams; i++){ |
710 asf_st= s->streams[i]->priv_data; | 710 asf_st= s->streams[i]->priv_data; |
711 av_free_packet(&asf_st->pkt); | 711 av_free_packet(&asf_st->pkt); |
712 asf_st->frag_offset=0; | 712 asf_st->frag_offset=0; |
713 asf_st->seq=0; | 713 asf_st->seq=0; |
722 ASFStream *asf_st; | 722 ASFStream *asf_st; |
723 int64_t pts; | 723 int64_t pts; |
724 int64_t pos= *ppos; | 724 int64_t pos= *ppos; |
725 int i; | 725 int i; |
726 int64_t start_pos[s->nb_streams]; | 726 int64_t start_pos[s->nb_streams]; |
727 | 727 |
728 for(i=0; i<s->nb_streams; i++){ | 728 for(i=0; i<s->nb_streams; i++){ |
729 start_pos[i]= pos; | 729 start_pos[i]= pos; |
730 } | 730 } |
731 | 731 |
732 pos= (pos+asf->packet_size-1-s->data_offset)/asf->packet_size*asf->packet_size+ s->data_offset; | 732 pos= (pos+asf->packet_size-1-s->data_offset)/asf->packet_size*asf->packet_size+ s->data_offset; |
733 *ppos= pos; | 733 *ppos= pos; |
734 url_fseek(&s->pb, pos, SEEK_SET); | 734 url_fseek(&s->pb, pos, SEEK_SET); |
735 | 735 |
736 //printf("asf_read_pts\n"); | 736 //printf("asf_read_pts\n"); |
737 asf_reset_header(s); | 737 asf_reset_header(s); |
738 for(;;){ | 738 for(;;){ |
739 if (av_read_frame(s, pkt) < 0){ | 739 if (av_read_frame(s, pkt) < 0){ |
740 av_log(s, AV_LOG_INFO, "seek failed\n"); | 740 av_log(s, AV_LOG_INFO, "seek failed\n"); |
741 return AV_NOPTS_VALUE; | 741 return AV_NOPTS_VALUE; |
742 } | 742 } |
743 | 743 |
744 pts= pkt->pts * 1000 / AV_TIME_BASE; | 744 pts= pkt->pts * 1000 / AV_TIME_BASE; |
745 | 745 |
746 av_free_packet(pkt); | 746 av_free_packet(pkt); |
747 if(pkt->flags&PKT_FLAG_KEY){ | 747 if(pkt->flags&PKT_FLAG_KEY){ |
748 i= pkt->stream_index; | 748 i= pkt->stream_index; |
752 assert((asf_st->packet_pos - s->data_offset) % asf->packet_size == 0); | 752 assert((asf_st->packet_pos - s->data_offset) % asf->packet_size == 0); |
753 pos= asf_st->packet_pos; | 753 pos= asf_st->packet_pos; |
754 | 754 |
755 av_add_index_entry(s->streams[i], pos, pts, pos - start_pos[i] + 1, AVINDEX_KEYFRAME); | 755 av_add_index_entry(s->streams[i], pos, pts, pos - start_pos[i] + 1, AVINDEX_KEYFRAME); |
756 start_pos[i]= asf_st->packet_pos + 1; | 756 start_pos[i]= asf_st->packet_pos + 1; |
757 | 757 |
758 if(pkt->stream_index == stream_index) | 758 if(pkt->stream_index == stream_index) |
759 break; | 759 break; |
760 } | 760 } |
761 } | 761 } |
762 | 762 |
767 } | 767 } |
768 | 768 |
769 static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags) | 769 static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags) |
770 { | 770 { |
771 ASFContext *asf = s->priv_data; | 771 ASFContext *asf = s->priv_data; |
772 | 772 |
773 if (asf->packet_size <= 0) | 773 if (asf->packet_size <= 0) |
774 return -1; | 774 return -1; |
775 | 775 |
776 if(av_seek_frame_binary(s, stream_index, pts, flags)<0) | 776 if(av_seek_frame_binary(s, stream_index, pts, flags)<0) |
777 return -1; | 777 return -1; |