From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 389074C0E4 for ; Mon, 22 Jul 2024 09:44:00 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 14C6168D6E3; Mon, 22 Jul 2024 12:43:52 +0300 (EEST) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E45B268D553 for ; Mon, 22 Jul 2024 12:43:42 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=qt3eQ5R2; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 4F8804DE7 for ; Mon, 22 Jul 2024 11:43:39 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id z-6SSjbeyEd5 for ; Mon, 22 Jul 2024 11:43:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1721641418; bh=fjaYtA8S2N9NYDtTE/WWXbJ+4Ue/CjJ1kdALTdKSngY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qt3eQ5R2DbTtBARXkIMU6nIFLrc4uU8qnFFTCa8kw8nLtwEaamsCpVruihtvoP4Ro aQ09QUai/JdU8oERKIlpwgVZHqrKtWNqya2r9PqDlAv0GUd2tyKJiL5/ysODSUbxoD cYRQapAPZfLhb5hyXha58ma2c1wxbYtyNmHteGyTZhHCFV+jpVPdRttpT7baZ2ij/l zd1fLb1prp78Gqs/IyTtacjmxLtgShZm3gaE+wqDjmPdGgqdZnC4BCD1/IwEsliqc1 r+HeM9Xfp0y7b8K0PZxA1HvWL/hI4ibfpodUp9K2XYzut1XH3R2sjcOiK4WA+KdAh5 BDhFJMe+Ika/g== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 73B8F25F for ; Mon, 22 Jul 2024 11:43:37 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3E1413A031C for ; Mon, 22 Jul 2024 11:43:31 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Jul 2024 11:43:21 +0200 Message-ID: <20240722094322.28916-2-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240722094322.28916-1-anton@khirnov.net> References: <20240717205156.GT4991@pb2> <20240722094322.28916-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] lavc/ffv1: move damage handling code to decode_slice() 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: There is no reason to delay it and this is a more natural place for this code. --- libavcodec/ffv1dec.c | 53 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index aa2c35880e..5821a4156a 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -290,7 +290,7 @@ static int decode_slice(AVCodecContext *c, void *arg) if ((p->flags & AV_FRAME_FLAG_KEY) || sc->slice_reset_contexts) { ff_ffv1_clear_slice_state(f, sc); } else if (sc->slice_damaged) { - return AVERROR_INVALIDDATA; + goto handle_damage; } width = sc->slice_width; @@ -347,6 +347,32 @@ static int decode_slice(AVCodecContext *c, void *arg) } } +handle_damage: + if (sc->slice_damaged && f->last_picture.f) { + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->pix_fmt); + const uint8_t *src[4]; + uint8_t *dst[4]; + + ff_progress_frame_await(&f->last_picture, si); + + for (int j = 0; j < desc->nb_components; j++) { + int pixshift = desc->comp[j].depth > 8; + int sh = (j == 1 || j == 2) ? f->chroma_h_shift : 0; + int sv = (j == 1 || j == 2) ? f->chroma_v_shift : 0; + dst[j] = p->data[j] + p->linesize[j] * + (sc->slice_y >> sv) + ((sc->slice_x >> sh) << pixshift); + src[j] = f->last_picture.f->data[j] + f->last_picture.f->linesize[j] * + (sc->slice_y >> sv) + ((sc->slice_x >> sh) << pixshift); + + } + + av_image_copy(dst, p->linesize, src, + f->last_picture.f->linesize, + c->pix_fmt, + sc->slice_width, + sc->slice_height); + } + ff_progress_frame_report(&f->picture, si); return 0; @@ -964,31 +990,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, f->slice_count, sizeof(*f->slices)); - for (int i = f->slice_count - 1; i >= 0; i--) { - FFV1SliceContext *sc = &f->slices[i]; - if (sc->slice_damaged && f->last_picture.f) { - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); - const uint8_t *src[4]; - uint8_t *dst[4]; - ff_progress_frame_await(&f->last_picture, INT_MAX); - for (int j = 0; j < desc->nb_components; j++) { - int pixshift = desc->comp[j].depth > 8; - int sh = (j == 1 || j == 2) ? f->chroma_h_shift : 0; - int sv = (j == 1 || j == 2) ? f->chroma_v_shift : 0; - dst[j] = p->data[j] + p->linesize[j] * - (sc->slice_y >> sv) + ((sc->slice_x >> sh) << pixshift); - src[j] = f->last_picture.f->data[j] + f->last_picture.f->linesize[j] * - (sc->slice_y >> sv) + ((sc->slice_x >> sh) << pixshift); - - } - - av_image_copy(dst, p->linesize, src, - f->last_picture.f->linesize, - avctx->pix_fmt, - sc->slice_width, - sc->slice_height); - } - } ff_progress_frame_report(&f->picture, INT_MAX); ff_progress_frame_unref(&f->last_picture); -- 2.43.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".