Changeset 4057 for pjproject/trunk
- Timestamp:
- Apr 17, 2012 6:54:50 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/avi_player.c
r4048 r4057 49 49 #define SIGNATURE PJMEDIA_SIG_PORT_VID_AVI_PLAYER 50 50 51 #define VIDEO_CLOCK_RATE 90000 52 51 53 #if 0 52 54 # define TRACE_(x) PJ_LOG(4,x) … … 124 126 unsigned options; 125 127 pjmedia_format_id fmt_id; 128 unsigned usec_per_frame; 126 129 pj_uint16_t bits_per_sample; 127 130 pj_bool_t eof; … … 131 134 pj_oshandle_t fd; 132 135 pj_ssize_t size_left; 136 pj_timestamp next_ts; 133 137 134 138 pj_status_t (*cb)(pjmedia_port*, void*); … … 456 460 457 461 fport[i]->bits_per_sample = (vfi ? vfi->bpp : 0); 462 fport[i]->usec_per_frame = avi_hdr.avih_hdr.usec_per_frame; 458 463 pjmedia_format_init_video(&fport[i]->base.info.fmt, 459 464 fport[i]->fmt_id, … … 462 467 strl_hdr->rate, 463 468 strl_hdr->scale); 464 469 #if 0 470 /* The calculation below is wrong. strf_hdr->biSizeImage shows 471 * uncompressed size. Looks like we need to go the ugly way to 472 * get the bitrage: 473 * http://www.virtualdub.org/blog/pivot/entry.php?id=159 474 */ 475 bps = strf_hdr->biSizeImage * 8 * strl_hdr->rate / strl_hdr->scale; 476 if (bps==0) { 477 /* strf_hdr->biSizeImage may be zero for uncompressed RGB */ 478 bps = strf_hdr->biWidth * strf_hdr->biHeight * 479 strf_hdr->biBitCount * 480 strl_hdr->rate / strl_hdr->scale; 481 } 482 fport[i]->base.info.fmt.det.vid.avg_bps = bps; 483 fport[i]->base.info.fmt.det.vid.max_bps = bps; 484 #endif 465 485 } else { 466 486 strf_audio_hdr_t *strf_hdr = … … 468 488 469 489 fport[i]->bits_per_sample = strf_hdr->bits_per_sample; 490 fport[i]->usec_per_frame = avi_hdr.avih_hdr.usec_per_frame; 470 491 pjmedia_format_init_audio(&fport[i]->base.info.fmt, 471 492 fport[i]->fmt_id, … … 473 494 strf_hdr->nchannels, 474 495 strf_hdr->bits_per_sample, 475 20000 ,476 strf_hdr->bytes_per_sec ,477 strf_hdr->bytes_per_sec );496 20000 /* fport[i]->usec_per_frame */, 497 strf_hdr->bytes_per_sec * 8, 498 strf_hdr->bytes_per_sec * 8); 478 499 } 479 500 … … 696 717 frame->type = (fport->base.info.fmt.type == PJMEDIA_TYPE_VIDEO ? 697 718 PJMEDIA_FRAME_TYPE_VIDEO : PJMEDIA_FRAME_TYPE_AUDIO); 698 frame->timestamp.u64 = 0; 719 699 720 if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO) { 700 721 if (size_to_read > fport->size_left) … … 720 741 } while(1); 721 742 743 frame->timestamp.u64 = fport->next_ts.u64; 744 if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO) { 745 if (fport->usec_per_frame) { 746 fport->next_ts.u64 += (fport->usec_per_frame * 747 fport->base.info.fmt.det.aud.clock_rate / 748 1000000); 749 } else { 750 fport->next_ts.u64 += (frame->size * 751 fport->base.info.fmt.det.aud.clock_rate / 752 (fport->base.info.fmt.det.aud.avg_bps / 8)); 753 } 754 } else { 755 if (fport->usec_per_frame) { 756 fport->next_ts.u64 += (fport->usec_per_frame * VIDEO_CLOCK_RATE / 757 1000000); 758 } else { 759 fport->next_ts.u64 += (frame->size * VIDEO_CLOCK_RATE / 760 (fport->base.info.fmt.det.vid.avg_bps / 8)); 761 } 762 } 763 722 764 return PJ_SUCCESS; 723 765
Note: See TracChangeset
for help on using the changeset viewer.