Changeset 3824


Ignore:
Timestamp:
Oct 18, 2011 6:46:49 AM (13 years ago)
Author:
bennylp
Message:

Compile error with older ffmpeg due to H.264 modification (re #1390)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/ffmpeg_codecs.c

    r3819 r3824  
    4040#define THIS_FILE   "ffmpeg_codecs.c" 
    4141 
     42#define LIBAVCODEC_VER_AT_LEAST(major,minor)  (LIBAVCODEC_VERSION_MAJOR > major || \ 
     43                                               (LIBAVCODEC_VERSION_MAJOR == major && \ 
     44                                                LIBAVCODEC_VERSION_MINOR >= minor)) 
     45 
    4246#include "../pjmedia/ffmpeg_util.h" 
    4347#include <libavcodec/avcodec.h> 
    4448#include <libavformat/avformat.h> 
    45 #include <libavutil/opt.h> 
     49#if LIBAVCODEC_VER_AT_LEAST(53,20) 
     50  /* Needed by 264 so far, on libavcodec 53.20 */ 
     51# include <libavutil/opt.h> 
     52#endif 
    4653 
    4754 
     
    220227 
    221228 
    222 #if PJMEDIA_HAS_FFMPEG_CODEC_H264 && \ 
    223     (LIBAVCODEC_VERSION_MAJOR < 53 || LIBAVCODEC_VERSION_MINOR < 20) 
     229#if PJMEDIA_HAS_FFMPEG_CODEC_H264 && !LIBAVCODEC_VER_AT_LEAST(53,20) 
    224230#   error "Must use libavcodec version 53.20 or later to enable FFMPEG H264" 
    225231#endif 
     
    230236 
    231237/* Codec specific functions */ 
     238#if PJMEDIA_HAS_FFMPEG_CODEC_H264 
    232239static pj_status_t h264_preopen(ffmpeg_private *ff); 
    233240static pj_status_t h264_postopen(ffmpeg_private *ff); 
    234241static FUNC_PACKETIZE(h264_packetize); 
    235242static FUNC_UNPACKETIZE(h264_unpacketize); 
     243#endif 
    236244 
    237245static pj_status_t h263_preopen(ffmpeg_private *ff); 
     
    990998static void print_ffmpeg_err(int err) 
    991999{ 
    992 #if LIBAVCODEC_VERSION_MAJOR > 52 || \ 
    993     (LIBAVCODEC_VERSION_MAJOR >= 52 && LIBAVCODEC_VERSION_MINOR >= 72) 
     1000#if LIBAVCODEC_VER_AT_LEAST(52,72) 
    9941001    char errbuf[512]; 
    9951002    if (av_strerror(err, errbuf, sizeof(errbuf)) >= 0) 
     
    10221029    /* Allocate ffmpeg codec context */ 
    10231030    if (ff->param.dir & PJMEDIA_DIR_ENCODING) { 
     1031#if LIBAVCODEC_VER_AT_LEAST(53,20) 
    10241032        ff->enc_ctx = avcodec_alloc_context3(ff->enc); 
     1033#else 
     1034        ff->enc_ctx = avcodec_alloc_context(); 
     1035#endif 
    10251036        if (ff->enc_ctx == NULL) 
    10261037            goto on_error; 
    10271038    } 
    10281039    if (ff->param.dir & PJMEDIA_DIR_DECODING) { 
     1040#if LIBAVCODEC_VER_AT_LEAST(53,20) 
    10291041        ff->dec_ctx = avcodec_alloc_context3(ff->dec); 
     1042#else 
     1043        ff->dec_ctx = avcodec_alloc_context(); 
     1044#endif 
    10301045        if (ff->dec_ctx == NULL) 
    10311046            goto on_error; 
     
    10531068         * not working (e.g: rate control). 
    10541069         */ 
    1055 #if LIBAVCODEC_VERSION_MAJOR > 52 || \ 
    1056     (LIBAVCODEC_VERSION_MAJOR >= 52 && LIBAVCODEC_VERSION_MINOR >= 113) 
     1070#if LIBAVCODEC_VER_AT_LEAST(52,113) 
    10571071        ctx->rc_lookahead = 0; 
    10581072#endif 
     
    14841498    output->timestamp = input->timestamp; 
    14851499 
    1486 #if LIBAVCODEC_VERSION_MAJOR > 52 || \ 
    1487     (LIBAVCODEC_VERSION_MAJOR >= 52 && LIBAVCODEC_VERSION_MINOR >= 72) 
     1500#if LIBAVCODEC_VER_AT_LEAST(52,72) 
    14881501    //avpacket.flags = AV_PKT_FLAG_KEY; 
    14891502#else 
     
    14911504#endif 
    14921505 
    1493 #if LIBAVCODEC_VERSION_MAJOR > 52 || \ 
    1494     (LIBAVCODEC_VERSION_MAJOR >= 52 && LIBAVCODEC_VERSION_MINOR >= 72) 
     1506#if LIBAVCODEC_VER_AT_LEAST(52,72) 
    14951507    err = avcodec_decode_video2(ff->dec_ctx, &avframe,  
    14961508                                &got_picture, &avpacket); 
Note: See TracChangeset for help on using the changeset viewer.