Changeset 4081


Ignore:
Timestamp:
Apr 24, 2012 1:06:39 PM (7 years ago)
Author:
bennylp
Message:

Misc (re #1446): support newer libavcodec version (major: 54) which deprecated few APIs

File:
1 edited

Legend:

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

    r4056 r4081  
    5353#endif 
    5454 
     55/* Various compatibility */ 
     56#if LIBAVCODEC_VER_AT_LEAST(53,20) 
     57#  define AV_OPT_SET(obj,name,val,opt)  av_opt_set(obj,name,val,opt) 
     58#  define AV_OPT_SET_INT(obj,name,val)  av_opt_set_int(obj,name,val,0) 
     59#  define AVCODEC_OPEN(ctx,c)           avcodec_open2(ctx,c,NULL) 
     60#else 
     61#  define AV_OPT_SET(obj,name,val,opt)  av_set_string3(obj,name,val,opt,NULL) 
     62#  define AV_OPT_SET_INT(obj,name,val)  av_set_int(obj,name,val) 
     63#  define AVCODEC_OPEN(ctx,c)           avcodec_open(ctx,c) 
     64#endif 
     65 
    5566 
    5667/* Prototypes for FFMPEG codecs factory */ 
     
    379390        } 
    380391        if (profile && 
    381             av_set_string3(ctx->priv_data, "profile", profile, 0, NULL)) 
     392            AV_OPT_SET(ctx->priv_data, "profile", profile, 0)) 
    382393        { 
    383394            PJ_LOG(3, (THIS_FILE, "Failed to set H264 profile")); 
     
    396407 
    397408        /* Limit NAL unit size as we prefer single NAL unit packetization */ 
    398         if (!av_set_int(ctx->priv_data, "slice-max-size", ff->param.enc_mtu)) 
     409        if (!AV_OPT_SET_INT(ctx->priv_data, "slice-max-size", ff->param.enc_mtu)) 
    399410        { 
    400411            PJ_LOG(3, (THIS_FILE, "Failed to set H264 max NAL size to %d", 
     
    403414 
    404415        /* Apply intra-refresh */ 
    405         if (!av_set_int(ctx->priv_data, "intra-refresh", 1)) 
     416        if (!AV_OPT_SET_INT(ctx->priv_data, "intra-refresh", 1)) 
    406417        { 
    407418            PJ_LOG(3, (THIS_FILE, "Failed to set x264 intra-refresh")); 
     
    411422         * Let's just use the x264 predefined preset & tune. 
    412423         */ 
    413         if (av_set_string3(ctx->priv_data, "preset", "veryfast", 0, NULL)) 
    414         { 
     424        if (AV_OPT_SET(ctx->priv_data, "preset", "veryfast", 0)) { 
    415425            PJ_LOG(3, (THIS_FILE, "Failed to set x264 preset 'veryfast'")); 
    416426        } 
    417         if (av_set_string3(ctx->priv_data, "tune", "animation+zerolatency", 
    418                            0, NULL)) 
    419         { 
     427        if (AV_OPT_SET(ctx->priv_data, "tune", "animation+zerolatency", 0)) { 
    420428            PJ_LOG(3, (THIS_FILE, "Failed to set x264 tune 'zerolatency'")); 
    421429        } 
     
    595603 
    596604    pjmedia_ffmpeg_add_ref(); 
     605#if !LIBAVCODEC_VER_AT_LEAST(53,20) 
     606    /* avcodec_init() dissappeared between version 53.20 and 54.15, not sure 
     607     * exactly when  
     608     */ 
    597609    avcodec_init(); 
     610#endif 
    598611    avcodec_register_all(); 
    599612 
     
    11201133         * not working (e.g: rate control). 
    11211134         */ 
    1122 #if LIBAVCODEC_VER_AT_LEAST(52,113) 
     1135#if LIBAVCODEC_VER_AT_LEAST(52,113) && !LIBAVCODEC_VER_AT_LEAST(53,20) 
    11231136        ctx->rc_lookahead = 0; 
    11241137#endif 
     
    11511164 
    11521165        pj_mutex_lock(ff_mutex); 
    1153         err = avcodec_open(ff->enc_ctx, ff->enc); 
     1166        err = AVCODEC_OPEN(ff->enc_ctx, ff->enc); 
    11541167        pj_mutex_unlock(ff_mutex); 
    11551168        if (err < 0) { 
     
    11661179 
    11671180        pj_mutex_lock(ff_mutex); 
    1168         err = avcodec_open(ff->dec_ctx, ff->dec); 
     1181        err = AVCODEC_OPEN(ff->dec_ctx, ff->dec); 
    11691182        pj_mutex_unlock(ff_mutex); 
    11701183        if (err < 0) { 
Note: See TracChangeset for help on using the changeset viewer.