From patchwork Thu Mar 11 12:42:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 26340 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4BE8044A602 for ; Thu, 11 Mar 2021 14:43:36 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2A6D4689AB4; Thu, 11 Mar 2021 14:43:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5A4926805D1 for ; Thu, 11 Mar 2021 14:43:29 +0200 (EET) Received: by mail-qt1-f169.google.com with SMTP id x9so980855qto.8 for ; Thu, 11 Mar 2021 04:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=BBfJlx5d9ybsqHDltk09RHsAJaJuiBPfUhHqGPcEykI=; b=gk46PbEf/cEMm1y/upYGK4AmbQ0bbOuGsZf87qwb6AcG81SGQNEUXrgINhRBpXlUpj B4URRhr5eGOBvZMwBnMPWUYmrO2Azbrhqu7uy0EYbPKFlF0oZiMjIBWgu6Ud0eNQJm66 V3ztW7/FAuiS9oFweNtMVupTdEQu59WzGdnKlAnFu372C9tYLT2BL6eSsQjipCIbAe1H sFo4XfI5HRX7N8nSBo/daCcGoFhL5SUlANMb/5UokHV0TMSG8cboxsqrix/oDIfAStL6 o4hsLUhcZQhgb0OAyKo+zhK+xgxC5L0sgxJ6cu9FERLMptUg5daB8a3y2HkZ6Jhx7V6A XtNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=BBfJlx5d9ybsqHDltk09RHsAJaJuiBPfUhHqGPcEykI=; b=ci/E5KY3KuDhwUa0soTaYS2GGc8OjS24OH9L/7Sgm1OnVSu3VTKLrG9U7AoWSFO1Gp ylcGBwPrln5louLL3zPbtp3WqGX4p9OMuoizfVxHQJSsLGgx8tcFlMA6B+PDsam43Ggc QehCQfLt+4LAmemLGnJ/8zP0jPkUxm1zgr5rnVHTnuFQD1heKoESi71DX2F04kUUSv22 pHCyy5F3FRO+g2c8WmeUMTKa0QipsIltarfB0+sNVPwmxfk5JWaxx++Q1bbYfQ8iJMhM aYEja3ihc4riFDjwX5/BXsReZsE47JNCCeBTMgAlBQR6i8w32IM82X1JGiwAUOu7wS1p Wa0g== X-Gm-Message-State: AOAM531YcRMeT9RbpdMZAmC0U5D7U28ctvSdG51giPQFSBgj8qMGNEhv RLTgR0gxDLXdpmFfA9rGcRWiJGuGaLg= X-Google-Smtp-Source: ABdhPJxDcyEM8kYchSpNa+aqF0pIa2Nm8puh7BV9SH4CgscMjyIg57uYuLF+I0mQZDbszwPGKz9jFw== X-Received: by 2002:ac8:7a94:: with SMTP id x20mr7238746qtr.51.1615466607578; Thu, 11 Mar 2021 04:43:27 -0800 (PST) Received: from localhost.localdomain ([181.23.75.214]) by smtp.gmail.com with ESMTPSA id o23sm1629814qtm.31.2021.03.11.04.43.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 04:43:27 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Mar 2021 09:42:03 -0300 Message-Id: <20210311124203.310-1-jamrial@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avcodec/h264_slice: don't copy frame data during error concealment X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" In addition to the fact that av_image_copy() cannot handle hardware pixel formats, h->short_ref[0]->f may not be writable at this point. Based on a patch by Hendrik Leppkes. Signed-off-by: James Almer --- This version fixes the fuzzed sample Michael talked about. libavcodec/h264_slice.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index fa7a639053..14b945756b 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1599,14 +1599,15 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl, ff_thread_await_progress(&prev->tf, INT_MAX, 0); if (prev->field_picture) ff_thread_await_progress(&prev->tf, INT_MAX, 1); - av_image_copy(h->short_ref[0]->f->data, - h->short_ref[0]->f->linesize, - (const uint8_t **)prev->f->data, - prev->f->linesize, - prev->f->format, - prev->f->width, - prev->f->height); + ff_thread_release_buffer(h->avctx, &h->short_ref[0]->tf); + h->short_ref[0]->tf.f = h->short_ref[0]->f; + ret = ff_thread_ref_frame(&h->short_ref[0]->tf, &prev->tf); + if (ret < 0) + return ret; h->short_ref[0]->poc = prev->poc + 2U; + ff_thread_report_progress(&h->short_ref[0]->tf, INT_MAX, 0); + if (h->short_ref[0]->field_picture) + ff_thread_report_progress(&h->short_ref[0]->tf, INT_MAX, 1); } else if (!h->frame_recovered && !h->avctx->hwaccel) ff_color_frame(h->short_ref[0]->f, c); h->short_ref[0]->frame_num = h->poc.prev_frame_num;