From patchwork Tue Jun 20 23:36:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 42263 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp1737068pzb; Tue, 20 Jun 2023 16:36:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6u3rVSZ1K6Qdm8H2mJTS+TuzyJmp8UrYkpMJmbOA2IX4In7FG0KkoTilnHKDHo3+778BzX X-Received: by 2002:a17:907:3e90:b0:989:4cfe:313 with SMTP id hs16-20020a1709073e9000b009894cfe0313mr2431404ejc.14.1687304180931; Tue, 20 Jun 2023 16:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687304180; cv=none; d=google.com; s=arc-20160816; b=FqLWoNbis9d/8TC3anmWD1Fd+wjGVSlQDu+CW2juJ/Ze24zYN/HxZOZUqWLSQ0YIzv X8m2cPz5NbuZ2H8I3tQOE5v0TVz9xJ6KudNT00TJYUQTmeaocpe9KNxlqkpkh/R43+vT OstzmWCtjiS2ysCRjGA6IlNTZ2MhaGTY74ffsn8/EqgCS6C+85EZxnVt09OJtnkwuxFw Wmd1+Ch93Vm2JMqatBh5p7Dv0yBMcvUS+zDAxm4GhGhfuXSV20zR0RQn/zVyc0wBhQWm K9Jbc1wVNTKRU7inn4FGeXHjPeZOepmc306J5YyzxYIL6jZZUSyd/qKzyg3GJ6uctH+8 TtGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=IvMubvIOX7X278cM6zfW7FmEbTmQYrBLavvUvPr2r8g=; b=TDEBItqc7Dy9DqoLPctfig8C5daM7ie5C5tHiCpb7z9CyC1TR3NVl5axq/ARi/Fu8p A+xFHfyEJPmw9/qnuPe/F0cRPhcvWVruobxyvtVYOVE4+c788SrDqYkW0yOzQ8YY2ce4 lu84jrYNI0FCCG47199ZbpM14DF7Z4Wr0qULDF4F2r/jTB1G3emR7xeM8c6uUBaVkq+W B4XWqRqGdFvRcqJpDgdZEDeLezFWPkt666Vc/8m4Z1HCtJyXqpJV6zSdvyS9nTYN7qtd 059VA+5letD/s1Juj78i8WT46X3K+bjVjb7AyQTjdxPKr5n5fqxdvF30RYKw+V3gSj+w L+4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id jz14-20020a170906bb0e00b00977e4a1fe32si1793755ejb.539.2023.06.20.16.36.19; Tue, 20 Jun 2023 16:36:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1ED4C68C10F; Wed, 21 Jun 2023 02:36:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from us-smtp-delivery-44.mimecast.com (unknown [207.211.30.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D3A2C68B6C6 for ; Wed, 21 Jun 2023 02:36:09 +0300 (EEST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-149-Atkg9h9DOpKjy0knCy2yfg-1; Tue, 20 Jun 2023 19:36:06 -0400 X-MC-Unique: Atkg9h9DOpKjy0knCy2yfg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5E34805BFB for ; Tue, 20 Jun 2023 23:36:05 +0000 (UTC) Received: from nomad.redhat.com (vpn2-54-59.bne.redhat.com [10.64.54.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6520492C13; Tue, 20 Jun 2023 23:36:04 +0000 (UTC) From: airlied@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 21 Jun 2023 09:36:01 +1000 Message-Id: <20230620233601.1876939-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com Subject: [FFmpeg-devel] [PATCH] av1dec: handle dimension changes via get_format X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Dave Airlie Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IC6qRFCKhWZM From: Dave Airlie av1-1-b8-03-sizeup.ivf on vulkan causes gpu hangs as none of the images get resized when dimensions change, this detects the dim change and calls the get_format to reinit the context. --- libavcodec/av1dec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index e7f98a6c81..1cec328563 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -721,6 +721,7 @@ static av_cold int av1_decode_free(AVCodecContext *avctx) } static int set_context_with_sequence(AVCodecContext *avctx, + int *dim_change, const AV1RawSequenceHeader *seq) { int width = seq->max_frame_width_minus_1 + 1; @@ -753,6 +754,8 @@ static int set_context_with_sequence(AVCodecContext *avctx, int ret = ff_set_dimensions(avctx, width, height); if (ret < 0) return ret; + if (dim_change) + *dim_change = 1; } avctx->sample_aspect_ratio = (AVRational) { 1, 1 }; @@ -859,7 +862,7 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) goto end; } - ret = set_context_with_sequence(avctx, seq); + ret = set_context_with_sequence(avctx, NULL, seq); if (ret < 0) { av_log(avctx, AV_LOG_WARNING, "Failed to set decoder context.\n"); goto end; @@ -1202,7 +1205,7 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) CodedBitstreamUnit *unit = &s->current_obu.units[i]; AV1RawOBU *obu = unit->content; const AV1RawOBUHeader *header; - + int dim_change = 0; if (!obu) continue; @@ -1220,7 +1223,8 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) s->raw_seq = &obu->obu.sequence_header; - ret = set_context_with_sequence(avctx, s->raw_seq); + dim_change = 0; + ret = set_context_with_sequence(avctx, &dim_change, s->raw_seq); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to set context.\n"); s->raw_seq = NULL; @@ -1229,7 +1233,7 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) s->operating_point_idc = s->raw_seq->operating_point_idc[s->operating_point]; - if (s->pix_fmt == AV_PIX_FMT_NONE) { + if (s->pix_fmt == AV_PIX_FMT_NONE || dim_change) { ret = get_pixel_format(avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR,