From patchwork Sun Aug 1 01:54:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 29157 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp475562ioh; Sat, 31 Jul 2021 18:55:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkXrU20yY61uVcIfWrSZ9ClruirKTEuJQok4/gAJFYvYQVAtgRZMaJ4Gs0hF3FMdyswVjd X-Received: by 2002:a05:6402:26c6:: with SMTP id x6mr494231edd.175.1627782900552; Sat, 31 Jul 2021 18:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627782900; cv=none; d=google.com; s=arc-20160816; b=lVySL5AsmtCRq1OzgJErjGWpwrA/2niUGOJ/FMu2p+SVkxOw/qF2Ai0RHNVybIfrfn cKjbAtyQbzyQ/DSYtZH+jsyWeaGhfku8v+ji1OvSq0VxZaHhJd6FxlxCinvtj4I/gRCZ zEmiCycewyWfyiCYrHx2Z99hL/3C2isVaWKYI7AVqNSeEhupPsB4lZVvWipmtF72OHjX ahSFlrs0vHsl+mtfyo/rhn/4BIvmfpcVpGtd8CTJyy3aluDWIIsYIHbxNthIAlAFvAdS VrHxuRxHKtyM3AS2+JNn7hEg5nDpPfaeclyBN6OOO0V1QbVdDF39sBFtGQES/YqBtDEd Xm6w== 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=BAkSBwc5oFdJk1X5755Bc3ld5U0YNoUkDZ23raYrfTs=; b=bzG8zPJxrIyAX5744VZDFoP1i3MUneiSnH9i/88uu8AsqgoQXXxAithdDi5AS/+WDv zXsba2i36GFUTDQZqLNpTnB7C4Ne3QxrzA5PuyWl8xy5iv+/l/lfe4uDmlrqbMN+Nn5R S9fjhrtcUYtYw4+OLGYSQwqjJDezsdhfHZs1xQ7a+oJYFBiziHMLE2O+QfBV1Gy0liPP xW/uevo/azgJNUEtYjLiHzPbghhhq2DIS/Srn/YcVcArK/4XqfBukbpWpPaButCP/EBN bQWnhqxcRGe27hMvyP+2kcvlMS0TySaDj2RIS9cMw8Ms7oxXNn2EzK8nmZMOWRdYtn5T 0yAw== 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u15si6877667edt.211.2021.07.31.18.54.59; Sat, 31 Jul 2021 18:55:00 -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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 82CE768A320; Sun, 1 Aug 2021 04:54:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B6C31689739 for ; Sun, 1 Aug 2021 04:54:49 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8F556E5B71; Sun, 1 Aug 2021 03:54:49 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aY-exzeEpvqs; Sun, 1 Aug 2021 03:54:47 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A8AC3E58D4; Sun, 1 Aug 2021 03:54:47 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 1 Aug 2021 03:54:28 +0200 Message-Id: <20210801015429.17814-1-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/mpeg12dec: report error when picture type is unknown and err_detect is EXPLODE 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: a7LKXtZ+gck0 Signed-off-by: Marton Balint --- libavcodec/mpeg12dec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 858dca660c..129dc1c2aa 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1529,7 +1529,7 @@ static void mpeg_decode_quant_matrix_extension(MpegEncContext *s) load_matrix(s, s->chroma_inter_matrix, NULL, 0); } -static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1) +static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1) { MpegEncContext *s = &s1->mpeg_enc_ctx; @@ -1541,6 +1541,8 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1) if (!s->pict_type && s1->mpeg_enc_ctx_allocated) { av_log(s->avctx, AV_LOG_ERROR, "Missing picture start code, guessing missing values\n"); + if (s->avctx->err_recognition & AV_EF_EXPLODE) + return AVERROR_INVALIDDATA; if (s->mpeg_f_code[1][0] == 15 && s->mpeg_f_code[1][1] == 15) { if (s->mpeg_f_code[0][0] == 15 && s->mpeg_f_code[0][1] == 15) s->pict_type = AV_PICTURE_TYPE_I; @@ -1586,6 +1588,8 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1) ff_dlog(s->avctx, "alternate_scan=%d\n", s->alternate_scan); ff_dlog(s->avctx, "frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct); ff_dlog(s->avctx, "progressive_frame=%d\n", s->progressive_frame); + + return 0; } static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) @@ -2599,7 +2603,9 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, break; case 0x8: if (last_code == PICTURE_START_CODE) { - mpeg_decode_picture_coding_extension(s); + int ret = mpeg_decode_picture_coding_extension(s); + if (ret < 0) + return ret; } else { av_log(avctx, AV_LOG_ERROR, "ignoring pic cod ext after %X\n", last_code);