- Timestamp:
- Apr 25, 2012 5:12:55 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/ffmpeg_vid_codecs.c
r4081 r4083 64 64 #endif 65 65 66 #if LIBAVCODEC_VER_AT_LEAST(53,61) 67 /* Not sure when AVCodec::encode2 is introduced. It appears in 68 * libavcodec 53.61 where some codecs actually still use AVCodec::encode 69 * (e.g: H263, H264). 70 */ 71 # define AVCODEC_HAS_ENCODE(c) (c->encode || c->encode2) 72 #else 73 # define AVCODEC_HAS_ENCODE(c) (c->encode) 74 #endif 75 #define AVCODEC_HAS_DECODE(c) (c->decode) 76 66 77 67 78 /* Prototypes for FFMPEG codecs factory */ … … 644 655 645 656 /* Skip duplicated codec implementation */ 646 if ((c->encode && (desc->info.dir & PJMEDIA_DIR_ENCODING)) || 647 (c->decode && (desc->info.dir & PJMEDIA_DIR_DECODING))) 657 if ((AVCODEC_HAS_ENCODE(c) && (desc->info.dir & PJMEDIA_DIR_ENCODING)) 658 || 659 (AVCODEC_HAS_DECODE(c) && (desc->info.dir & PJMEDIA_DIR_DECODING))) 648 660 { 649 661 continue; … … 651 663 652 664 /* Get raw/decoded format ids in the encoder */ 653 if (c->pix_fmts && c->encode) {665 if (c->pix_fmts && AVCODEC_HAS_ENCODE(c)) { 654 666 pjmedia_format_id raw_fmt[PJMEDIA_VID_CODEC_MAX_DEC_FMT_CNT]; 655 667 unsigned raw_fmt_cnt = 0; … … 716 728 717 729 /* Get ffmpeg encoder instance */ 718 if (c->encode&& !desc->enc) {730 if (AVCODEC_HAS_ENCODE(c) && !desc->enc) { 719 731 desc->info.dir |= PJMEDIA_DIR_ENCODING; 720 732 desc->enc = c; … … 722 734 723 735 /* Get ffmpeg decoder instance */ 724 if ( c->decode&& !desc->dec) {736 if (AVCODEC_HAS_DECODE(c) && !desc->dec) { 725 737 desc->info.dir |= PJMEDIA_DIR_DECODING; 726 738 desc->dec = c; … … 1393 1405 pj_uint8_t *p = (pj_uint8_t*)input->buf; 1394 1406 AVFrame avframe; 1395 pj_uint8_t *out_buf = (pj_uint8_t*)output->buf; 1396 int out_buf_len = output_buf_len; 1397 int err; 1407 AVPacket avpacket; 1408 int err, got_packet; 1398 1409 //AVRational src_timebase; 1399 1410 /* For some reasons (e.g: SSE/MMX usage), the avcodec_encode_video() must … … 1435 1446 } 1436 1447 1437 err = avcodec_encode_video(ff->enc_ctx, out_buf, out_buf_len, &avframe); 1448 av_init_packet(&avpacket); 1449 avpacket.data = (pj_uint8_t*)output->buf; 1450 avpacket.size = output_buf_len; 1451 1452 #if LIBAVCODEC_VER_AT_LEAST(54,15) 1453 err = avcodec_encode_video2(ff->enc_ctx, &avpacket, &avframe, &got_packet); 1454 if (!err && got_packet) 1455 err = avpacket.size; 1456 #else 1457 PJ_UNUSED_ARG(got_packet); 1458 err = avcodec_encode_video(ff->enc_ctx, avpacket.data, avpacket.size, &avframe); 1459 #endif 1460 1438 1461 if (err < 0) { 1439 1462 print_ffmpeg_err(err);
Note: See TracChangeset
for help on using the changeset viewer.