Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v2 1/3] libavcodec/qsvdec: reinit decoder according to decode() return value
@ 2022-03-18  6:25 Wenbin Chen
  2022-03-18  6:25 ` [FFmpeg-devel] [PATCH v2 2/3] libavcodec/qsvdec: remove redundant decodeHeader() Wenbin Chen
  2022-03-18  6:25 ` [FFmpeg-devel] [PATCH v2 3/3] libavcodec/qsvdec: using suggested num to set init_pool_size Wenbin Chen
  0 siblings, 2 replies; 7+ messages in thread
From: Wenbin Chen @ 2022-03-18  6:25 UTC (permalink / raw)
  To: ffmpeg-devel

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>
---
 libavcodec/qsvdec.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 1b5bf85cb6..0b5e416867 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -630,6 +630,13 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
 
     } while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_ERR_MORE_SURFACE);
 
+    if (ret == MFX_ERR_INCOMPATIBLE_VIDEO_PARAM) {
+        q->reinit_flag = 1;
+        av_log(avctx, AV_LOG_DEBUG, "Video parameter change\n");
+        av_freep(&sync);
+        return 0;
+    }
+
     if (ret != MFX_ERR_NONE &&
         ret != MFX_ERR_MORE_DATA &&
         ret != MFX_WRN_VIDEO_PARAM_CHANGED &&
@@ -782,9 +789,9 @@ static int qsv_process_data(AVCodecContext *avctx, QSVContext *q,
 
     ret = qsv_decode_header(avctx, q, pkt, pix_fmt, &param);
 
-    if (ret >= 0 && (q->orig_pix_fmt != ff_qsv_map_fourcc(param.mfx.FrameInfo.FourCC) ||
+    if (q->reinit_flag || (ret >= 0 && (q->orig_pix_fmt != ff_qsv_map_fourcc(param.mfx.FrameInfo.FourCC) ||
         avctx->coded_width  != param.mfx.FrameInfo.Width ||
-        avctx->coded_height != param.mfx.FrameInfo.Height)) {
+        avctx->coded_height != param.mfx.FrameInfo.Height))) {
         AVPacket zero_pkt = {0};
 
         if (q->buffered_count) {
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-04-06 12:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-18  6:25 [FFmpeg-devel] [PATCH v2 1/3] libavcodec/qsvdec: reinit decoder according to decode() return value Wenbin Chen
2022-03-18  6:25 ` [FFmpeg-devel] [PATCH v2 2/3] libavcodec/qsvdec: remove redundant decodeHeader() Wenbin Chen
2022-03-18  6:25 ` [FFmpeg-devel] [PATCH v2 3/3] libavcodec/qsvdec: using suggested num to set init_pool_size Wenbin Chen
2022-03-18  7:40   ` Soft Works
2022-03-28  2:26     ` Xiang, Haihao
2022-04-02  8:52       ` Xiang, Haihao
2022-04-06 12:01         ` Xiang, Haihao

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git