- Timestamp:
- Feb 28, 2011 6:59:47 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-codec/ffmpeg_codecs.c
r3420 r3425 206 206 /* Predefined info */ 207 207 pjmedia_vid_codec_info info; 208 pjmedia_format_id base_fmt_id; 208 209 func_packetize packetize; 209 210 func_unpacketize unpacketize; … … 246 247 { 247 248 { 248 {PJMEDIA_FORMAT_H263, {"H263",4}, PJMEDIA_RTP_PT_H263}, 249 {PJMEDIA_FORMAT_H263P, {"H263-1998",9}, PJMEDIA_RTP_PT_H263}, 250 PJMEDIA_FORMAT_H263, 249 251 &h263_packetize, &h263_unpacketize, &h263_parse_fmtp, 250 252 {2, { {{"CIF",3}, {"2",1}}, {{"QCIF",4}, {"1",1}}, } }, 251 253 }, 252 254 { 253 {PJMEDIA_FORMAT_H261, {"H261",4}, PJMEDIA_RTP_PT_H261}, 255 {PJMEDIA_FORMAT_H263, {"H263",4}, PJMEDIA_RTP_PT_H263}, 256 0, 257 &h263_packetize, &h263_unpacketize, &h263_parse_fmtp, 258 {2, { {{"CIF",3}, {"2",1}}, {{"QCIF",4}, {"1",1}}, } }, 254 259 }, 255 260 { 256 {PJMEDIA_FORMAT_MJPEG, {"JPEG",4}, PJMEDIA_RTP_PT_JPEG}, 261 {PJMEDIA_FORMAT_H261, {"H261",4}, PJMEDIA_RTP_PT_H261}, 262 }, 263 { 264 {PJMEDIA_FORMAT_MJPEG, {"JPEG",4}, PJMEDIA_RTP_PT_JPEG}, 265 }, 266 { 267 {PJMEDIA_FORMAT_MPEG4, {"MP4V",4}, PJMEDIA_RTP_PT_MPV}, 268 }, 269 { 270 {PJMEDIA_FORMAT_XVID, {"XVID",4}, PJMEDIA_RTP_PT_MPV}, 271 PJMEDIA_FORMAT_MPEG4, 257 272 }, 258 273 }; … … 448 463 449 464 450 static const ffmpeg_codec_desc* find_codec_ info(465 static const ffmpeg_codec_desc* find_codec_desc_by_info( 451 466 const pjmedia_vid_codec_info *info) 452 467 { … … 469 484 470 485 471 static int find_codec_i nfo_idx_by_fmt_id(pjmedia_format_id fmt_id)486 static int find_codec_idx_by_fmt_id(pjmedia_format_id fmt_id) 472 487 { 473 488 int i; … … 490 505 AVCodec *c; 491 506 pj_status_t status; 507 unsigned i; 492 508 493 509 if (ffmpeg_factory.pool != NULL) { … … 533 549 */ 534 550 551 //PJ_LOG(3, (THIS_FILE, "%s", c->name)); 535 552 status = CodecID_to_pjmedia_format_id(c->id, &fmt_id); 536 553 /* Skip if format ID is unknown */ … … 538 555 continue; 539 556 540 codec_info_idx = find_codec_i nfo_idx_by_fmt_id(fmt_id);557 codec_info_idx = find_codec_idx_by_fmt_id(fmt_id); 541 558 /* Skip if codec is unwanted by this wrapper (not listed in 542 559 * the codec info array) … … 635 652 } 636 653 654 /* Init unassigned encoder/decoder description from base codec */ 655 for (i = 0; i < PJ_ARRAY_SIZE(codec_desc); ++i) { 656 ffmpeg_codec_desc *desc = &codec_desc[i]; 657 658 if (desc->base_fmt_id && (!desc->dec || !desc->enc)) { 659 ffmpeg_codec_desc *base_desc = NULL; 660 int base_desc_idx; 661 pjmedia_dir copied_dir = PJMEDIA_DIR_NONE; 662 663 base_desc_idx = find_codec_idx_by_fmt_id(desc->base_fmt_id); 664 if (base_desc_idx != -1) 665 base_desc = &codec_desc[base_desc_idx]; 666 if (!base_desc || !base_desc->enabled) 667 continue; 668 669 /* Copy description from base codec */ 670 if (!desc->info.dec_fmt_id_cnt) { 671 desc->info.dec_fmt_id_cnt = base_desc->info.dec_fmt_id_cnt; 672 pj_memcpy(desc->info.dec_fmt_id, base_desc->info.dec_fmt_id, 673 sizeof(pjmedia_format_id)*desc->info.dec_fmt_id_cnt); 674 } 675 if (!desc->info.fps_cnt) { 676 desc->info.fps_cnt = base_desc->info.fps_cnt; 677 pj_memcpy(desc->info.fps, base_desc->info.fps, 678 sizeof(desc->info.fps[0])*desc->info.fps_cnt); 679 } 680 if (!desc->info.clock_rate) { 681 desc->info.clock_rate = base_desc->info.clock_rate; 682 } 683 if (!desc->dec && base_desc->dec) { 684 copied_dir |= PJMEDIA_DIR_DECODING; 685 desc->dec = base_desc->dec; 686 } 687 if (!desc->enc && base_desc->enc) { 688 copied_dir |= PJMEDIA_DIR_ENCODING; 689 desc->enc = base_desc->enc; 690 } 691 692 desc->info.dir |= copied_dir; 693 desc->enabled = (desc->info.dir != PJMEDIA_DIR_NONE); 694 695 if (copied_dir != PJMEDIA_DIR_NONE) { 696 const char *dir_name[] = {NULL, "encoder", "decoder", "codec"}; 697 PJ_LOG(5, (THIS_FILE, "The %.*s %s is using base codec (%.*s)", 698 desc->info.encoding_name.slen, 699 desc->info.encoding_name.ptr, 700 dir_name[copied_dir], 701 base_desc->info.encoding_name.slen, 702 base_desc->info.encoding_name.ptr)); 703 } 704 } 705 } 706 637 707 /* Register codec factory to codec manager. */ 638 708 status = pjmedia_vid_codec_mgr_register_factory(mgr, … … 691 761 PJ_ASSERT_RETURN(info, PJ_EINVAL); 692 762 693 desc = find_codec_ info(info);763 desc = find_codec_desc_by_info(info); 694 764 if (!desc) { 695 765 return PJMEDIA_CODEC_EUNSUP; … … 711 781 PJ_ASSERT_RETURN(info && attr, PJ_EINVAL); 712 782 713 desc = find_codec_ info(info);783 desc = find_codec_desc_by_info(info); 714 784 if (!desc) { 715 785 return PJMEDIA_CODEC_EUNSUP; … … 742 812 pjmedia_vid_codec_info codecs[]) 743 813 { 744 unsigned i ;814 unsigned i, max_cnt; 745 815 746 816 PJ_ASSERT_RETURN(codecs && *count > 0, PJ_EINVAL); 747 817 PJ_ASSERT_RETURN(factory == &ffmpeg_factory.base, PJ_EINVAL); 748 818 749 *count = PJ_MIN(*count, PJ_ARRAY_SIZE(codec_desc)); 750 751 for (i=0; i<*count; ++i) { 752 pj_memcpy(&codecs[i], &codec_desc[i].info, 753 sizeof(pjmedia_vid_codec_info)); 819 max_cnt = PJ_MIN(*count, PJ_ARRAY_SIZE(codec_desc)); 820 *count = 0; 821 822 for (i=0; i<max_cnt; ++i) { 823 if (codec_desc[i].enabled) { 824 pj_memcpy(&codecs[*count], &codec_desc[i].info, 825 sizeof(pjmedia_vid_codec_info)); 826 (*count)++; 827 } 754 828 } 755 829 … … 773 847 PJ_ASSERT_RETURN(factory == &ffmpeg_factory.base, PJ_EINVAL); 774 848 775 desc = find_codec_ info(info);849 desc = find_codec_desc_by_info(info); 776 850 if (!desc) { 777 851 return PJMEDIA_CODEC_EUNSUP; … … 928 1002 929 1003 /* Decoding only attributes */ 930 // this setting will be automatically fetched from the bitstream. 931 //ctx->coded_width = ff->param.dec_fmt.det.vid.size.w; 932 //ctx->coded_height = ff->param.dec_fmt.det.vid.size.h; 1004 1005 /* Width/height may be overriden by ffmpeg after first decoding. */ 1006 ctx->width = ctx->coded_width = ff->param.dec_fmt.det.vid.size.w; 1007 ctx->height = ctx->coded_height = ff->param.dec_fmt.det.vid.size.h; 933 1008 934 1009 /* For decoder, be more flexible */ … … 1199 1274 1200 1275 /* Validate output buffer size */ 1201 PJ_ASSERT_RETURN(ff->dec_vafp.framebytes <= output_buf_len, PJ_ETOOSMALL);1276 //PJ_ASSERT_RETURN(ff->dec_vafp.framebytes <= output_buf_len, PJ_ETOOSMALL); 1202 1277 1203 1278 /* Init frame to receive the decoded data, the ffmpeg codec context will … … 1311 1386 1312 1387 /* Check provided buffer size after format changed */ 1313 if (vafp->framebytes > output_buf_len)1314 return PJ_ETOOSMALL;1388 //if (vafp->framebytes > output_buf_len) 1389 //return PJ_ETOOSMALL; 1315 1390 1316 1391 /* Get the decoded data */
Note: See TracChangeset
for help on using the changeset viewer.