aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/qsvdec.c
Commit message (Collapse)AuthorAgeFilesLines
* all: fix typos found by codespellTimo Rothenpieler7 days1-3/+3
|
* lavc/refstruct: move to lavu and make publicAnton Khirnov2024-12-151-2/+2
| | | | It is highly versatile and generally useful.
* lavc/qsvdec: Add vvc_mp4toannexb bsf for QSV VVC decoderFei Wang2024-08-161-1/+1
| | | | | | | | | | Fix error: $ ffmpeg -hwaccel qsv -i input.mp4 -f null - .. [vvc_qsv @ 0000026890D966C0] Error decoding stream header: unknown error (-1) [vvc_qsv @ 0000026890D966C0] Error decoding header Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* lavc/qsvdec: Add VVC decoderFei Wang2024-07-301-1/+6
| | | | Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* lavc/qsvdec: fix keyframesHaihao Xiang2024-05-291-2/+8
| | | | | | | | | MFX_FRAMETYPE_IDR is ORed to the frame type for AVC and HEVC keyframes, and MFX_FRAMETYPE_I is taken as keyframe flag for other codecs when getting the output surface from the SDK, hence we may mark the output frame as keyframe accordingly. Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvdec: Use coded_w/h for frame resolution when use system memoryFei Wang2024-05-271-8/+8
| | | | | | | | | Fix output mismatch when decode clip with crop(conf_win_*offset in syntax) info by using system memory: $ ffmpeg -c:v hevc_qsv -i conf_win_offet.bit -y out.yuv Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* lavc/qsvdec: Allow decoders to export crop informationFei Wang2024-05-271-1/+5
| | | | Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* lavc/qsvdec: update HDR side data on output AVFrame for AV1 decodingHaihao Xiang2024-05-271-1/+47
| | | | | | | The SDK may provide HDR metadata for HDR streams via mfxExtBuffer attached on output mfxFrameSurface1 Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvdec: require a dynamic frame pool if possibleHaihao Xiang2024-05-201-12/+45
| | | | | | | | | | | | | This allows a downstream element stores more frames from qsv decoders and fixes error in get_buffer(). $ ffmpeg -hwaccel qsv -hwaccel_output_format qsv -i input.mp4 -vf reverse -f null - [vist#0:0/h264 @ 0x562248f12c50] Decoding error: Cannot allocate memory [h264_qsv @ 0x562248f66b10] get_buffer() failed Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* avcodec/qsvdec: Check av_image_get_buffer_size() for failureMichael Niedermayer2024-05-151-3/+6
| | | | | | | | Fixes: CID1477406 Improper use of negative value Sponsored-by: Sovereign Tech Fund Reviewed-by: "Xiang, Haihao" <haihao.xiang@intel.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc/qsvdec: Use FFmpeg default 1/25 framerate if can't derive it from bitstreamFei Wang2024-04-291-0/+5
| | | | | | | | | | Fix error: $ ffmpeg -hwaccel qsv -i input.h265 -f null - ... [null @ 0x55da1a629200] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 3 >= 3 Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* avcodec/qsv: Use RefStruct API for memory id (mids) arrayAndreas Rheinhardt2024-04-191-1/+2
| | | | | | | Avoids allocations and therefore error checks and cleanup code; also avoids indirections. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/qsvdec: Do not print warning when draining cached framesHaihao Xiang2024-03-181-1/+3
| | | | | | | | | When all cached frames are drained, the output mfxSyncPoint pointer is NULL and MFX_ERR_MORE_DATA is returned, hence needn't print warning for this expected behavior, otherwise the user might think the output from qsv decoders are wrong. Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/*dec: use side data preference for mastering display/content light metadataAnton Khirnov2024-03-081-19/+27
|
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-141-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | Makes it robust against adding fields before it, which will be useful in following commits. Majority of the patch generated by the following Coccinelle script: @@ typedef AVOption; identifier arr_name; initializer list il; initializer list[8] il1; expression tail; @@ AVOption arr_name[] = { il, { il1, - tail + .unit = tail }, ... }; with some manual changes, as the script: * has trouble with options defined inside macros * sometimes does not handle options under an #else branch * sometimes swallows whitespace
* avcodec: Remove redundant pix_fmts from decodersAndreas Rheinhardt2024-02-091-11/+0
| | | | | | | | | | | | | | | AVCodec.pix_fmts is only intended for encoders (decoders use the get_format callback to let the user choose a pix fmt). So remove them for the decoders for which this is possible without further complications; keep them for now in the codecs that actually use them (by passing avctx->codec->pix_fmts to ff_get_formatt()). Also notice that some of these lists were wrong; e.g. 317b7b06fd97cd39feac7df57db22a30550351ff added support for YUV444P16 for cuviddec, but forgot to add it to pix_fmts. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-201-0/+1
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-221-1/+0
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/qsvdec: reduce info message when more data is requiredHaihao Xiang2023-12-051-1/+1
| | | | | | demote the info to AV_LOG_VERBOSE Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvdec: return 0 if more data is requiredHaihao Xiang2023-12-051-0/+3
| | | | | | | | The type of qsv decoders is FF_CODEC_CB_TYPE_DECODE which must not return AVERROR(EAGAIN). commit 42b20c9 added an assertion to check the returned value. Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* avcodec: use the new AVFrame key_frame flag in all decoders and encodersJames Almer2023-05-041-2/+6
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: use the new AVFrame interlace flags in all decoders and encodersJames Almer2023-05-041-3/+3
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/qsvdec: check ff_decode_frame_props() return valueAnton Khirnov2023-01-101-1/+3
|
* lavc/qsvdec: update HDR side data on output AVFrameHaihao Xiang2022-12-011-0/+73
| | | | | | | The SDK may provides HDR metadata for HDR streams via mfxExtBuffer attached on output mfxFrameSurface1 Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsv: add support for decoding & encoding 12bit contentFei Wang2022-10-101-1/+10
| | | | | | | | | | AV_PIX_FMT_P012, AV_PIX_FMT_Y212 and AV_PIX_FMT_XV36 are used in FFmpeg and MFX_FOURCC_P016, MFX_FOURCC_Y216, and MFX_FOURCC_Y416 are used in the SDK Signed-off-by: Fei Wang <fei.w.wang@intel.com> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsv: add support for decoding & encoding 10bit 4:4:4 contentHaihao Xiang2022-10-101-0/+2
| | | | | | | AV_PIX_FMT_XV30 is used in FFmpeg and MFX_FOURCC_Y410 is used in the SDK. Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsv: Add support for decoding & encoding 8bit 4:4:4 contentHaihao Xiang2022-09-071-0/+2
| | | | | | | AV_PIX_FMT_VUYX is used in FFmpeg and MFX_FOURCC_AYUV is used in the SDK Reviewed-by: Philip Langdale <philipl@overt.org> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* avcodec/codec_internal: Add macro to set AVCodec.long_nameAndreas Rheinhardt2022-09-031-1/+1
| | | | | | | | It reduces typing: Before this patch, there were 105 codecs whose long_name-definition exceeded the 80 char line length limit. Now there are only nine of them. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/qsv: create mfx session using oneVPL for decoding/encodingHaihao Xiang2022-08-121-0/+11
| | | | | | | | If qsv hwdevice is available, use the mfxLoader handle in qsv hwdevice to create mfx session. Otherwise create mfx session with a new mfxLoader handle. This is in preparation for oneVPL support
* qsv: restrict OPAQUE memory to MFX_VERSION < 2.0Haihao Xiang2022-08-121-0/+9
| | | | | | | | 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
* qsv: remove mfx/ prefix from mfx headersHaihao Xiang2022-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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)
* avcodec: Add FF_CODEC_CAP_NOT_INIT_THREADSAFEAndreas Rheinhardt2022-07-181-0/+1
| | | | | | | This is in preparation of switching the default init-thread-safety to a codec being init-thread-safe. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* libavcodec/qsvdec: Add more pixel format support to qsvdecWenbin Chen2022-04-061-6/+17
| | | | | | | | Qsv decoder only supports directly output nv12 and p010 to system memory. For other format, we need to download frame from qsv format to system memory. Now add other supported format to qsvdec. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
* libavcodec/qsvdec: using suggested num to set init_pool_sizeWenbin Chen2022-04-061-2/+12
| | | | | | | | | | | | The init_pool_size is set to be 64 and it is too many. Use IOSurfQuery to get NumFrameSuggest which is the suggested number of frame that needed to be allocated when initializing the decoder. Considering that the hevc_qsv encoder uses the most frame buffer, async is 4 (default) and max_b_frames is 8 (default) and decoder may followed by VPP, use NumFrameSuggest + 16 to set init_pool_size. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Guangxin Xu <guangxin.xu@intel.com>
* libavcodec/qsvdec: remove redundant decodeHeader()Wenbin Chen2022-04-061-14/+15
| | | | | | | | | | | | Since ffmpeg-qsv uses return value to reinit decoder, it doesn't need to decode header each time. Move qsv_decode_header's position so that it will be called only if codec needed to be reinitialized. Rearrange the code of flushing decoder and re-init decoder operation. Remove the buffer_count and use the got_frame to decide whether the decoder is drain. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Guangxin Xu <guangxin.xu@intel.com>
* libavcodec/qsvdec: reinit decoder according to decode() return valueWenbin Chen2022-04-061-2/+9
| | | | | | | | | | FFmpeg-qsv decoder reinit codec when width and height change, but there are not only resolution change need to reinit codec. I change it to use return value from DecodeFrameAsync() to decide whether decoder need to be reinitialized. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Guangxin Xu <guangxin.xu@intel.com>
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-051-1/+1
| | | | | | | | | | | This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Make FFCodec.decode use AVFrame*Andreas Rheinhardt2022-04-051-2/+1
| | | | | | | | This increases type-safety by avoiding conversions from/through void*. It also avoids the boilerplate "AVFrame *frame = data;" line for non-subtitle decoders. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-211-9/+10
| | | | | | | | | | | | | | | | Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-161-0/+2
| | | | | | | | 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>
* libavcodec/qsvdec: use the parameter from decodeHeader to configure surfaceWenbin Chen2022-02-221-2/+2
| | | | | | | | | | | MSDK recognizes both yuv420p10 and yuv420p9 as MFX_FOURCC_P010, but parameters are different. When decode yuv420p9 video, ffmpeg-qsv will use yuv420p10le to configure surface which is different with param from DecoderHeader and this will lead to error. Now change it use param from decoderHeader to configure surface. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvdec: switch to the new FIFO APIAnton Khirnov2022-02-071-54/+36
|
* lavc/qsvdec: export AVFilmGrainParams side dataHaihao Xiang2022-01-291-0/+91
| | | | | | | When AV_CODEC_EXPORT_DATA_FILM_GRAIN is present, AV1 decoder should disable film grain application and export the corresponding side data Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvdec: track the runtime session versionHaihao Xiang2022-01-291-0/+13
| | | | | | We may check the runtime version for the given features Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsv: allow to add more parameter buffers to QSV frameHaihao Xiang2022-01-291-3/+5
| | | | Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* libavcodec/qsvdec.c: using queue count to unref frameChen,Wenbin2022-01-121-2/+2
| | | | | | | | | | MSDK vc1 and av1 sometimes output frame into the same suface, but ffmpeg-qsv assume the surface will be used only once, so it will unref the frame when it receives the output surface. Now change it to unref frame according to queue count. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* lavc/qsvdec: needn't free the string for AV_OPT_TYPE_STRING AVOptionHaihao Xiang2022-01-051-2/+0
| | | | | | | The string for AV_OPT_TYPE_STRING AVOption gets freed by av_opt_free() when closing the AVCodecContext Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
* qsvdec: add support for HW_DEVICE_CTX methodHaihao Xiang2021-08-111-1/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows user set hw_device_ctx instead of hw_frames_ctx for QSV decoders, hence we may remove the ad-hoc libmfx setup code from FFmpeg. "-hwaccel_output_format format" is applied to QSV decoders after removing the ad-hoc libmfx code. In order to keep compatibility with old commandlines, the default format is set to AV_PIX_FMT_QSV, but this behavior will be removed in the future. Please set "-hwaccel_output_format qsv" explicitly if AV_PIX_FMT_QSV is expected. The normal device stuff works for QSV decoders now, user may use "-init_hw_device args" to initialise device and "-hwaccel_device devicename" to select a device for QSV decoders. "-qsv_device device" which was added for workarounding device selection in the ad-hoc libmfx code still works For example: $> ffmpeg -init_hw_device qsv=qsv:hw_any,child_device=/dev/dri/card0 -hwaccel qsv -c:v h264_qsv -i input.h264 -f null - /dev/dri/renderD128 is actually open for h264_qsv decoder in the above command without this patch. After applying this patch, /dev/dri/card0 is used. $> ffmpeg -init_hw_device vaapi=va:/dev/dri/card0 -init_hw_device qsv=hw@va -hwaccel_device hw -hwaccel qsv -c:v h264_qsv -i input.h264 -f null - device hw of type qsv is not usable in the above command without this patch. After applying this patch, this command works as expected. Reviewed-by: Soft Works <softworkz@hotmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/qsvdec: update color properties in codec contextHaihao Xiang2021-08-041-1/+19
| | | | | | | | User may get color properties from the SDK via VIDEO_SIGNAL_INFO extbuf Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com> Reviewed-by: Soft Works <softworkz@hotmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/qsvdec: fix ptsHaihao Xiang2021-06-201-3/+16
| | | | | | | | | | | | | | | | | The time base used for compressed bitstream and video frame in the SDK is { 1, 90000 }. [1][2] This can avoid the error message below from the muxer. $> ffmpeg -hwaccel qsv -c:v hevc_qsv -i input.h265 -f null - ... [null @ 0x561c24f6f2f0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 2 >= 2 [1]https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxbitstream [2]https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxframedata Signed-off-by: Zhong Li <zhongli_dev@126.com>