summaryrefslogtreecommitdiff
path: root/libavcodec/qsvenc.c
Commit message (Collapse)AuthorAge
* qsv: restrict OPAQUE memory to MFX_VERSION < 2.0Haihao Xiang2022-08-12
| | | | | | | | OPAQUE memory isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2] https://github.com/oneapi-src/oneVPL
* qsvenc: restrict MFX_RATECONTROL_LA_EXT to MFX_VERSION < 2.0Haihao Xiang2022-08-12
| | | | | | | | MFX_RATECONTROL_LA_EXT isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2] https://github.com/oneapi-src/oneVPL
* qsv: remove mfx/ prefix from mfx headersHaihao Xiang2022-08-12
| | | | | | | | | | | | | | | | | | | | | | | | The following Cflags has been added to libmfx.pc, so mfx/ prefix is no longer needed when including mfx headers in FFmpeg. Cflags: -I${includedir} -I${includedir}/mfx Some old versions of libmfx have the following Cflags in libmfx.pc Cflags: -I${includedir} We may add -I${includedir}/mfx to CFLAGS when running 'configure --enable-libmfx' for old versions of libmfx, if so, mfx headers without mfx/ prefix can be included too. If libmfx comes without pkg-config support, we may do a small change to the settings of the environment(e.g. set -I/opt/intel/mediasdk/include/mfx instead of -I/opt/intel/mediasdk/include to CFLAGS), then the build can find the mfx headers without mfx/ prefix After applying this change, we won't need to change #include for mfx headers when mfx headers are installed under a new directory. This is in preparation for oneVPL support (mfx headers in oneVPL are installed under vpl directory)
* libavcodec/qsvenc: Use parameter from AVCodecContext to reset qsv codecWenbin Chen2022-07-20
| | | | | | | | | | | | | | | Using parameter from AVCodecContext to reset qsv codec is more suitable for MFXVideoENCODE_Reset()'s usage. Per-frame metadata is more suitable for the usage of mfxEncodeCtrl being passed to MFXVideoENCODE_EncodeFrameAsync(). Now change it to use the value from AVCodecContext. Because q->param is passed to both "in" and "out" parameters when call MFXVideoENCODE_Query(), the value in q->param may be changed. New variables are added to store old configuration, so that we can detect real parameter change. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Change the parameter log to be thread safeWenbin Chen2022-07-20
| | | | | | | | Dividing one line log into several av_log() call is not thread safe. Now merge these strings into one av_log() call. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Enable fixed QP configure in qsv CQP runtimeYue Heng2022-06-27
| | | | | | | | | | Enable dynamic QP configuration in runtime on qsv encoder. Through AVFrame->metadata, we can set key "qsv_config_qp" to change QP configuration when we encode video in CQP mode. Signed-off-by: Yue Heng <yue.heng@intel.com> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: add ROI support to qsv encoderWenbin Chen2022-06-17
| | | | | | | | | Use The mfxEncoderCtrl parameter to enable ROI. Get side data "AVRegionOfInterest" and use it to configure "mfxExtEncoderROI" which is the MediaSDK's ROI configuration. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Add min/max QP control options for I/P/B frameYue Heng2022-06-06
| | | | | | | | | To do more accurate QP control, add min/max QP control on I/P/B frame separately to qsv encoder. qmax and qmin still work but newly-added options have higher priority. Signed-off-by: Yue Heng <yue.heng@intel.com> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
* qsv: add requirement for the mininal version of libmfxHaihao Xiang2022-05-25
| | | | | | | | | | libmfx 1.28 was released 3 years ago, it is easy to get a greater version than 1.28. We may remove lots of compile-time checks if adding the requirement for the minimal version in the configure script. Reviewed-by: softworkz <softworkz@hotmail.com> Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* qsvenc: fix typoHaihao Xiang2022-04-08
| | | | | Reviewed-by: U. Artie Eoff <ullysses.a.eoff@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Add more pixel format support to qsvencWenbin Chen2022-04-06
| | | | | | | | | Qsv encoder only support input P010 and nv12 format directly from system memory. For other format, we need to upload frame to device memory and input qsv format to encoder. Now add other system memory format support to qsv encoder. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
* libavcodec/qsvenc: enable LowDelayBRC and MaxFrameSizeI/MaxFrameSizeP for ↵He, Fan F2022-04-06
| | | | | | | | | | more accurate bitrate control Feature introduction of LowDelayBRC, MaxFrameSizeI and MaxFrameSizeP could be found here: https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md Signed-off-by: Dmitry Ermilov <dmitry.ermilov@intel.com> Signed-off-by: Fan F He <fan.f.he@intel.com>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-16
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* qsvenc: avoid dereferencing the null pointerTong Wu2022-02-28
| | | | | | | The variable AVFrame *frame could be a null pointer, now add a null pointer check to avoid dereferencing the null pointer. Signed-off-by: Tong Wu <tong1.wu@intel.com>
* libavcodec/qsvenc: add mbbrc to hevc_qsvWenbin Chen2022-02-28
| | | | | | | | Add mbbrc to hevc_qsv For detailed description, please see "mbbrc" part in: https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxextcodingoption2 Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
* libavcodec/qsvenc: add more ChromaFormat support to mjpeg_qsvWenbin Chen2022-02-28
| | | | | | | | ChromaForamt for mjpeg-qsv is always set to yuv420, and this will be wrong when encode other pixel format (for example yuyv422). ChromaFormat is changed to be adaptive to pix_fmt. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
* libavcodec/qsvenc_hevc: encode RGB format rawvideoWenbin Chen2022-02-22
| | | | | | | | | | | Add support for hevc_qsv to input RGB format frame. It will transform frame to yuv inside MediaSDK instead of using auto scale. Now hevc_qsv supports directly encoding BGRA and X2RGB10 format. The X2RGB10 correspond to the A2RGB20 format and BGRA correspond to RGB4 format in MediaSDK. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* avcodec/qsvenc: Reindent after the previous commitAndreas Rheinhardt2022-02-07
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/qsvenc: switch to new FIFO APIAnton Khirnov2022-02-07
|
* lavc/qsvenc: add tile encoding support for VP9Haihao Xiang2022-01-29
| | | | | | | Add -tile_rows and -tile_cols options to specify the number of tile rows and columns Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Add intra refresh to hevc_qsv and add new intra refresh ↵Wenbin Chen2022-01-27
| | | | | | | | | | | | parameter Add intra refresh support to hevc_qsv as well. Add an new intra refresh type: "horizontal", and an new param ref_cycle_dist. This param specify the distance between the beginnings of the intra-refresh cycles in frames. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Add b_strategy option to hevc_qsvWenbin Chen2022-01-27
| | | | | | | | Add b_strategy option to hevc_qsv. By enabling this option, encoder can use b frames as reference. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Add max slice size support to hevc_qsvWenbin Chen2022-01-27
| | | | | | | Add max_slice_size option to hevc_qsv as well. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: fix a memory leak problemWenbin Chen2022-01-24
| | | | | | | | | | "qf->frame" ref to input frame but it isn't released. av_frame_unref() is added before refering qf->frame to new frame to make sure the previous reference is released. Reported-by: Mark Samuelson <Mark.Samuelson@sonicfoundry.com> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Add transform skip to hevc_qsvWenbin Chen2022-01-21
| | | | | | | | | Add transform_skip option to hevc_qsv. By enabling this option, the transform_skip_enabled_flag in PPS will be set to 1. This option is supported on the platform equal or newer than ICL. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Add low latency P-pyramid support to qsvWenbin Chen2022-01-21
| | | | | | | | | | | Add low latency P-pyramid support to qsv. This feature relates to command line option "-p_strategy". To enable this flag, user also need to set "-bf" to 0. P-strategy has two modes "1-simple" and "2-pyramid". The details of the two models refer to https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#preftype Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Add DisableDeblockingIdc support to qsvWenbin Chen2022-01-21
| | | | | | | | Add dblk_idc option to 264_qsv and hevc_qsv. Turining on this opion can disable deblocking. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvenc: Add max_frame_size support to hevc_qsvWenbin Chen2022-01-21
| | | | | | | Add max_frame_size support to hevc_qsv as well. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvenc: add encode support for screen content coding extensionHaihao Xiang2022-01-18
| | | | | | Enables HEVC Screen Content Coding extension support on ICL+ platform Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvenc: add return check for ff_qsv_map_pixfmtLinjie Fu2022-01-10
| | | | | | | | Return an error directly if pixfmt is not supported for encoding, otherwise it may be hidden until query/check in MSDK. Signed-off-by: Linjie Fu <linjie.fu@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvenc: set base address for V planeHaihao Xiang2022-01-05
| | | | | | | | | | | | | The SDK checks Data.V when using system memory for VP9 encoding. This fixed the error below: $ ffmpeg -qsv_device /dev/dri/renderD129 -f lavfi -i yuvtestsrc -c:v vp9_qsv -f null - [vp9_qsv @ 0x55b8387cbe90] Error during encoding: NULL pointer (-2) Video encoding failed Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvenc: enable lookahead for hevc encodingZhong Li2021-12-23
| | | | | | | | | Update version based on the patch: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20211009015949.1510-1-haihao.xiang@intel.com/ Signed-off-by: Daniel Socek <daniel.socek@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com> Signed-off-by: Zhong Li <zhongli_dev@126.com>
* lavc/qsvenc: specify codec name when print profileZhong Li2021-12-23
| | | | | | | | It is more clear and easily to detect the issues similar to commit 3857ecbe70e81cb6ad7a7f155c311e8522b93b3e Signed-off-by: Zhong Li <zhongli_dev@126.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvenc: dump parameters for mjpeg encoding in verbose modeHaihao Xiang2021-12-19
| | | | Signed-off-by: Zhong Li <zhongli_dev@126.com>
* lavc/qsvenc: dump parameters for VP9 encoding in verbose modeHaihao Xiang2021-12-19
| | | | Signed-off-by: Zhong Li <zhongli_dev@126.com>
* lavc/qsvenc: add VP9 profilesHaihao Xiang2021-12-19
| | | | Signed-off-by: Zhong Li <zhongli_dev@126.com>
* lavc/qsvenc: define profile array per codecHaihao Xiang2021-12-19
| | | | | | | | | | | | | The SDK defines HEVC, VP9 and AV1 profiles in the same values e.g. MFX_PROFILE_HEVC_MAIN =1, MFX_PROFILE_VP9_0 =1, MFX_PROFILE_AV1_MAIN =1, To avoid potential errors when adding VP9, AV1 profiles later, this patch defines profile array per codec. Signed-off-by: Zhong Li <zhongli_dev@126.com>
* lavc/qsvenc: remove VC1 profilesHaihao Xiang2021-12-19
| | | | | | | | | | | | | | The SDK doesn't support VC1 encoding. In addition, both MFX_PROFILE_VC1_SIMPLE and MFX_PROFILE_HEVC_MAIN are 1 in the SDK, HEVC main profile is recognized as simple profile in the verbose output if don't remove VC1 profiles. $ ffmpeg -v verbose -qsv_device /dev/dri/renderD129 -f lavfi -i yuvtestsrc -c:v hevc_qsv -f null - [hevc_qsv @ 0x55bdf7eb4eb0] profile: simple; level: 21 Signed-off-by: Zhong Li <zhongli_dev@126.com>
* avcodec/qsvenc: Properly flush the FIFO on closeAndreas Rheinhardt2021-11-30
| | | | | | | | Freeing the new H.264 specific fields has been forgotten. (This leak only appears in case the encoder has not been completely drained.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/qsvenc: Fix leak of A53 dataAndreas Rheinhardt2021-11-30
| | | | | | | Up until now, it has only been freed when the QSVFrame is reused, so that the last one contained in it leaked at the end. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/qsvenc: Fix leak and crash when encoding H.264 due to A53_CCAndreas Rheinhardt2021-11-30
| | | | | | | | | | | | | | | | | | | | | Since commit 3bbe0c210b05fc6fbd7b1d4bbd8479db7f2cf957, the Payloads array of every QSVFrame leaks as soon as the frame is reused; the leak is small and not very noticeable, but if there is an attempt to use said array the ensuing crash is much more noticeable. This happens when encoding H.264 with A53 CC side data. Furthermore, if said array can not be allocated at all, an AVFrame leaks. Fix all of this by not allocating the array separately at all; put it in QSVFrame instead and restore the Payloads array upon reusing the frame. Finally, use av_freep() instead of av_free() to free the payload entries. Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/qsvenc: Remove dead code for user-provided buffersAndreas Rheinhardt2021-09-25
| | | | | | | Dead since commit 93016f5d1d280f9cb7856883af287fa66affc04c which ensured that the packets received by encoders are always blank. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/qsvenc: Fix memleaks upon allocation errorsAndreas Rheinhardt2021-09-25
| | | | | | | Fixes leaks in case the allocation of the H.264-specific stuff fails. Fixes Coverity issues #1442911 and #1442914. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-20
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/qsv_enc: do not reuse enc_ctrl from previous framesXu Guangxin2021-09-09
| | | | | | | | | fixes #8857 If we do not clear the enc_ctrl, we will reuse previous frames' data like FrameType. Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/qsvenc: allows the SDK runtime to choose LowPower/non-LowPower modesHaihao Xiang2021-08-12
| | | | | | | | | | | | | The SDK supports LowPower and non-LowPower modes, but some features are available only under one of the two modes. Currently non-LowPower mode is always chosen in FFmpeg if the mode is not set to LowPower explicitly. User will experience some SDK errors if a LowPower related feature is specified but the mode is not set to LowPower. With this patch, the mode is set to unknown by default in FFmpeg, the SDK is able to choose a workable mode for the specified features. Reviewed-by: Soft Works <softworkz@hotmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/qsvenc: pass the color properties to the SDKHaihao Xiang2021-08-04
| | | | | | | | | Otherwise the color properties won't be encoded into the bitstream header Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com> Reviewed-by: Soft Works <softworkz@hotmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* qsvenc: Value '0' is not a valid value for parameter GopOptFlagHaihao Xiang2021-07-27
| | | | | | | | The accepted values for GopOptFlag are MFX_GOP_CLOSED (1) and MFX_GOP_STRICT (2). Signed-off-by: Haihao Xiang <haihao.xiang@intel.com> Signed-off-by: Zhong Li <zhongli_dev@126.com>
* avcodec/qsvenc: clip global_quality for ICQ modes.Gyan Doshi2021-07-12
| | | | | | Allowed range is 1 to 51. Ref: https://software.intel.com/content/www/us/en/develop/articles/advanced-bitrate-control-methods-in-intel-media-sdk.html
* qsvenc_hevc: allow user set more coding optionsHaihao Xiang2021-07-02
| | | | | | | | | The SDK supports NalHrdConformance, RecoveryPointSEI and AUDelimiter for hevc encoder, so we may allow user to set these coding options like as what we did for h264_qsv encoder. Signed-off-by: Haihao Xiang <haihao.xiang@intel.com> Signed-off-by: Zhong Li <zhongli_dev@126.com>