+ // TODO: detect version of MFX--if the minor version is greater than
+ // or equal to 19, then can use the same alignment settings as H.264
+ // for HEVC
+ q->width_align = avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16;
+ q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align);
+
+ if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
+ // it is important that PicStruct be setup correctly from the
+ // start--otherwise, encoding doesn't work and results in a bunch
+ // of incompatible video parameter errors
+ q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
+ // height alignment always must be 32 for interlaced video
+ q->height_align = 32;
+ } else {
+ q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
+ // for progressive video, the height should be aligned to 16 for
+ // H.264. For HEVC, depending on the version of MFX, it should be
+ // either 32 or 16. The lower number is better if possible.
+ q->height_align = avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16;
+ }
+ q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, q->height_align);
+