Ticket #4831: apatch.patch
| File apatch.patch, 8.1 KB (added by , 11 years ago) |
|---|
-
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) 35 35 switch (codec_id) { 36 36 case AV_CODEC_ID_H264: 37 37 return MFX_CODEC_AVC; 38 #if QSV_VERSION_ATLEAST(1, 8)38 //#if QSV_VERSION_ATLEAST(1, 8) 39 39 case AV_CODEC_ID_HEVC: 40 40 return MFX_CODEC_HEVC; 41 #endif41 //#endif 42 42 case AV_CODEC_ID_MPEG1VIDEO: 43 43 case AV_CODEC_ID_MPEG2VIDEO: 44 44 return MFX_CODEC_MPEG2; … … int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, 172 172 const char *load_plugins) 173 173 { 174 174 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; 176 177 177 178 const char *desc; 178 179 int ret; … … int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, 183 184 return ff_qsv_error(ret); 184 185 } 185 186 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 186 195 ret = ff_qsv_set_display_handle(avctx, qs); 187 196 if (ret < 0) 188 197 return ret; -
libavcodec/qsv_internal.h
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index b9ad199..9542f4e 100644
a b 41 41 #include "libavutil/frame.h" 42 42 43 43 #define QSV_VERSION_MAJOR 1 44 #define QSV_VERSION_MINOR 944 #define QSV_VERSION_MINOR 6 45 45 46 46 #define ASYNC_DEPTH_DEFAULT 4 // internal parallelism 47 47 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))*/ 51 51 52 52 typedef struct QSVFrame { 53 53 AVFrame *frame; … … typedef struct QSVFrame { 61 61 } QSVFrame; 62 62 63 63 typedef struct QSVSession { 64 mfxSession session; 64 mfxSession session; 65 mfxVersion version; 65 66 #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE 66 67 int fd_display; 67 68 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) 107 107 q->param.mfx.RateControlMethod = MFX_RATECONTROL_CBR; 108 108 ratecontrol_desc = "constant bitrate (CBR)"; 109 109 } else if (!avctx->rc_max_rate) { 110 #if QSV_VERSION_ATLEAST(1,7)110 //#if QSV_VERSION_ATLEAST(1,7) 111 111 if (q->look_ahead) { 112 112 q->param.mfx.RateControlMethod = MFX_RATECONTROL_LA; 113 113 ratecontrol_desc = "lookahead (LA)"; 114 114 } else 115 #endif115 //#endif 116 116 { 117 117 q->param.mfx.RateControlMethod = MFX_RATECONTROL_AVBR; 118 118 ratecontrol_desc = "average variable bitrate (AVBR)"; … … static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) 140 140 141 141 break; 142 142 case MFX_RATECONTROL_AVBR: 143 #if QSV_VERSION_ATLEAST(1,7)143 //#if QSV_VERSION_ATLEAST(1,7) 144 144 case MFX_RATECONTROL_LA: 145 #endif145 //#endif 146 146 q->param.mfx.TargetKbps = avctx->bit_rate / 1000; 147 147 q->param.mfx.Convergence = q->avbr_convergence; 148 148 q->param.mfx.Accuracy = q->avbr_accuracy; … … static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) 161 161 MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN; 162 162 163 163 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 } 164 182 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 inclusive171 // to instruct the encoder to use the default value this should be set to zero172 q->extco2.LookAheadDepth = q->look_ahead_depth != 0 ? FFMAX(10, q->look_ahead_depth) : 0;173 #endif174 #if QSV_VERSION_ATLEAST(1,8)175 q->extco2.LookAheadDS = q->look_ahead_downsampling;176 #endif177 178 q->extparam[1] = (mfxExtBuffer *)&q->extco2;179 180 #endif181 183 q->param.ExtParam = q->extparam; 182 184 q->param.NumExtParam = FF_ARRAY_ELEMS(q->extparam); 183 185 } … … int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) 236 238 { 237 239 int ret; 238 240 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? 240 242 q->param.AsyncDepth = q->async_depth; 241 243 242 244 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 { 50 50 mfxFrameAllocRequest req; 51 51 52 52 mfxExtCodingOption extco; 53 #if QSV_VERSION_ATLEAST(1,6)53 //#if QSV_VERSION_ATLEAST(1,6) 54 54 mfxExtCodingOption2 extco2; 55 55 mfxExtBuffer *extparam[2]; 56 #else57 mfxExtBuffer *extparam[1];58 #endif56 //#else 57 // mfxExtBuffer *extparam[1]; 58 //#endif 59 59 60 60 AVFifoBuffer *async_fifo; 61 61 -
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[] = { 71 71 { "avbr_convergence", "Convergence of the AVBR ratecontrol", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, 72 72 { "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 }, 73 73 74 #if QSV_VERSION_ATLEAST(1,7) 74 /*#if QSV_VERSION_ATLEAST(1,7)*/ 75 75 { "look_ahead", "Use VBR algorithm with look ahead", OFFSET(qsv.look_ahead), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE }, 76 76 { "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*/ 78 78 79 #if QSV_VERSION_ATLEAST(1,8) 79 /*#if QSV_VERSION_ATLEAST(1,8)*/ 80 80 { "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" }, 81 81 { "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_UNKNOWN }, INT_MIN, INT_MAX, VE, "look_ahead_downsampling" }, 82 82 { "off" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_OFF }, INT_MIN, INT_MAX, VE, "look_ahead_downsampling" }, 83 83 { "2x" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_2x }, INT_MIN, INT_MAX, VE, "look_ahead_downsampling" }, 84 #endif 84 /*#endif*/ 85 85 86 86 { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" }, 87 87 { "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, VE, "profile" },
