Ticket #4831: apatch.patch

File apatch.patch, 8.1 KB (added by Andrew Van Til, 11 years ago)

version testing patch

  • libavcodec/qsv.c

    diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
    index 4c8e6b0..db3f81a 100644
    a b int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)  
    3535    switch (codec_id) {
    3636    case AV_CODEC_ID_H264:
    3737        return MFX_CODEC_AVC;
    38 #if QSV_VERSION_ATLEAST(1, 8)
     38//#if QSV_VERSION_ATLEAST(1, 8)
    3939    case AV_CODEC_ID_HEVC:
    4040        return MFX_CODEC_HEVC;
    41 #endif
     41//#endif
    4242    case AV_CODEC_ID_MPEG1VIDEO:
    4343    case AV_CODEC_ID_MPEG2VIDEO:
    4444        return MFX_CODEC_MPEG2;
    int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,  
    172172                                 const char *load_plugins)
    173173{
    174174    mfxIMPL impl   = MFX_IMPL_AUTO_ANY;
    175     mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } };
     175    mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } };   
     176    mfxVersion actualVer;
    176177
    177178    const char *desc;
    178179    int ret;
    int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,  
    183184        return ff_qsv_error(ret);
    184185    }
    185186
     187    ret = MFXQueryVersion(qs->session, &actualVer);
     188    if (ret < 0)
     189        return ff_qsv_error(ret);
     190
     191    qs->version = actualVer;
     192
     193    av_log(avctx, AV_LOG_INFO, "QSV SDK Version: v%d.%d\n", qs->version.Major, qs->version.Minor);
     194
    186195    ret = ff_qsv_set_display_handle(avctx, qs);
    187196    if (ret < 0)
    188197        return ret;
  • libavcodec/qsv_internal.h

    diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
    index b9ad199..9542f4e 100644
    a b  
    4141#include "libavutil/frame.h"
    4242
    4343#define QSV_VERSION_MAJOR 1
    44 #define QSV_VERSION_MINOR 9
     44#define QSV_VERSION_MINOR 6
    4545
    4646#define ASYNC_DEPTH_DEFAULT 4       // internal parallelism
    4747
    48 #define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
    49     (MFX_VERSION_MAJOR > (MAJOR) ||         \
    50      MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
     48/*#define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
     49   (MFX_VERSION_MAJOR > (MAJOR) ||         \
     50     MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))*/
    5151
    5252typedef struct QSVFrame {
    5353    AVFrame *frame;
    typedef struct QSVFrame {  
    6161} QSVFrame;
    6262
    6363typedef struct QSVSession {
    64     mfxSession session;
     64    mfxSession session;   
     65    mfxVersion version;
    6566#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
    6667    int        fd_display;
    6768    VADisplay  va_display;
  • libavcodec/qsvenc.c

    diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
    index 1aeab03..510f023 100644
    a b static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)  
    107107        q->param.mfx.RateControlMethod = MFX_RATECONTROL_CBR;
    108108        ratecontrol_desc = "constant bitrate (CBR)";
    109109    } else if (!avctx->rc_max_rate) {
    110 #if QSV_VERSION_ATLEAST(1,7)
     110//#if QSV_VERSION_ATLEAST(1,7)
    111111        if (q->look_ahead) {
    112112            q->param.mfx.RateControlMethod = MFX_RATECONTROL_LA;
    113113            ratecontrol_desc = "lookahead (LA)";
    114114        } else
    115 #endif
     115//#endif
    116116        {
    117117            q->param.mfx.RateControlMethod = MFX_RATECONTROL_AVBR;
    118118            ratecontrol_desc = "average variable bitrate (AVBR)";
    static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)  
    140140
    141141        break;
    142142    case MFX_RATECONTROL_AVBR:
    143 #if QSV_VERSION_ATLEAST(1,7)
     143//#if QSV_VERSION_ATLEAST(1,7)
    144144    case MFX_RATECONTROL_LA:
    145 #endif
     145//#endif
    146146        q->param.mfx.TargetKbps  = avctx->bit_rate / 1000;
    147147        q->param.mfx.Convergence = q->avbr_convergence;
    148148        q->param.mfx.Accuracy    = q->avbr_accuracy;
    static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)  
    161161                                        MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN;
    162162
    163163        q->extparam[0] = (mfxExtBuffer *)&q->extco;
     164        if(q->internal_qs.version.Major >= 1){
     165            if(q->internal_qs.version.Minor >= 6) { //#if QSV_VERSION_ATLEAST(1,6)
     166                q->extco2.Header.BufferId      = MFX_EXTBUFF_CODING_OPTION2;
     167                q->extco2.Header.BufferSz      = sizeof(q->extco2);
     168
     169                if(q->internal_qs.version.Minor >= 7) {//#if QSV_VERSION_ATLEAST(1,7)
     170                    // valid value range is from 10 to 100 inclusive
     171                    // to instruct the encoder to use the default value this should be set to zero
     172                    q->extco2.LookAheadDepth        = q->look_ahead_depth != 0 ? FFMAX(10, q->look_ahead_depth) : 0;
     173                }//#endif
     174                if(q->internal_qs.version.Minor >= 8) {//#if QSV_VERSION_ATLEAST(1,8)
     175                        q->extco2.LookAheadDS           = q->look_ahead_downsampling;
     176                } //#endif
     177
     178                q->extparam[1] = (mfxExtBuffer *)&q->extco2;
     179
     180            }//#endif
     181        }
    164182
    165 #if QSV_VERSION_ATLEAST(1,6)
    166         q->extco2.Header.BufferId      = MFX_EXTBUFF_CODING_OPTION2;
    167         q->extco2.Header.BufferSz      = sizeof(q->extco2);
    168 
    169 #if QSV_VERSION_ATLEAST(1,7)
    170         // valid value range is from 10 to 100 inclusive
    171         // to instruct the encoder to use the default value this should be set to zero
    172         q->extco2.LookAheadDepth        = q->look_ahead_depth != 0 ? FFMAX(10, q->look_ahead_depth) : 0;
    173 #endif
    174 #if QSV_VERSION_ATLEAST(1,8)
    175         q->extco2.LookAheadDS           = q->look_ahead_downsampling;
    176 #endif
    177 
    178         q->extparam[1] = (mfxExtBuffer *)&q->extco2;
    179 
    180 #endif
    181183        q->param.ExtParam    = q->extparam;
    182184        q->param.NumExtParam = FF_ARRAY_ELEMS(q->extparam);
    183185    }
    int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)  
    236238{
    237239    int ret;
    238240
    239     q->param.IOPattern  = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
     241    q->param.IOPattern  = MFX_IOPATTERN_IN_SYSTEM_MEMORY; //Why isn't opaque memory being used?
    240242    q->param.AsyncDepth = q->async_depth;
    241243
    242244    q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
  • libavcodec/qsvenc.h

    diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
    index 2a21f82..a3e85ad 100644
    a b typedef struct QSVEncContext {  
    5050    mfxFrameAllocRequest req;
    5151
    5252    mfxExtCodingOption  extco;
    53 #if QSV_VERSION_ATLEAST(1,6)
     53//#if QSV_VERSION_ATLEAST(1,6)
    5454    mfxExtCodingOption2 extco2;
    5555    mfxExtBuffer *extparam[2];
    56 #else
    57     mfxExtBuffer *extparam[1];
    58 #endif
     56//#else
     57//    mfxExtBuffer *extparam[1];
     58//#endif
    5959
    6060    AVFifoBuffer *async_fifo;
    6161
  • libavcodec/qsvenc_h264.c

    diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
    index b569efe..cc9a572 100644
    a b static const AVOption options[] = {  
    7171    { "avbr_convergence", "Convergence of the AVBR ratecontrol", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
    7272    { "pic_timing_sei",    "Insert picture timing SEI with pic_struct_syntax element", OFFSET(qsv.pic_timing_sei), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
    7373
    74 #if QSV_VERSION_ATLEAST(1,7)
     74/*#if QSV_VERSION_ATLEAST(1,7)*/
    7575    { "look_ahead",       "Use VBR algorithm with look ahead",    OFFSET(qsv.look_ahead),       AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
    7676    { "look_ahead_depth", "Depth of look ahead in number frames", OFFSET(qsv.look_ahead_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, VE },
    77 #endif
     77/*#endif*/
    7878
    79 #if QSV_VERSION_ATLEAST(1,8)
     79/*#if QSV_VERSION_ATLEAST(1,8)*/
    8080    { "look_ahead_downsampling", NULL, OFFSET(qsv.look_ahead_downsampling), AV_OPT_TYPE_INT, { .i64 = MFX_LOOKAHEAD_DS_UNKNOWN }, MFX_LOOKAHEAD_DS_UNKNOWN, MFX_LOOKAHEAD_DS_2x, VE, "look_ahead_downsampling" },
    8181    { "unknown"                , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_UNKNOWN }, INT_MIN, INT_MAX,     VE, "look_ahead_downsampling" },
    8282    { "off"                    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_OFF     }, INT_MIN, INT_MAX,     VE, "look_ahead_downsampling" },
    8383    { "2x"                     , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_2x      }, INT_MIN, INT_MAX,     VE, "look_ahead_downsampling" },
    84 #endif
     84/*#endif*/
    8585
    8686    { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
    8787    { "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN      }, INT_MIN, INT_MAX,     VE, "profile" },