From patchwork Mon Aug 2 18:50:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 29204 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp1818583ioh; Mon, 2 Aug 2021 11:50:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGxNkx4o/tXnB28QAv+/MJzPf/lnv4A/nWKMVMRv5coKF2wn0kztC17gljX7sMKmMeXmwy X-Received: by 2002:a50:d548:: with SMTP id f8mr21514620edj.357.1627930244754; Mon, 02 Aug 2021 11:50:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627930244; cv=none; d=google.com; s=arc-20160816; b=oXgiCDb9QKZxclgOAG8CwmI6xNCi/9DLvR64o66jd+Op3tMMBX5lSopOg6ektXndNN Qg0S166tKe109HdPwEdvJT54/H8IyDiIE6HqdpqZEZ/9OLbWWMkTV1Tta0273KR0pbG5 UIokMXtUOOUFrXlteoq5i7aCOKj8Y4uBihXb//pFUKDrRsmRAWN3wwW5E4zLM1e3tZGT 73uwZfLQafFqzfDkTbTaq3eNgW+vZfCZQ+gl2vXX9Bq6fO1Fdw8PQwutj0kihxkqg2W4 ticpCu8EAZZzIwqNiGcYFwEbDQgc4RMUm5TvdrlUhO9tlJlHOmQTe5qhcr+Qjxer4Gn/ DuTA== 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:references:in-reply-to :message-id:date:to:from:delivered-to; bh=ZUhKkHDfAWHemE+MyionV6ZbmwmZIaU1rZCH4gpkkCA=; b=zIAu4VOjJbX0R6a3IvLqdK2rYRNk5iHVORlPbqsAGnqDwsYWNn8IvLfgmkvspvKrJ9 nKII8QvGgKp/qoMXfj8NHmJVWn6i5TPhmIrPp0B71KsXHq5UgJQJVSKfylWGlAieScrD Z2RQJ4XvehHZYqaI+xKE+NLu51zMsLVJvS294iATxY5mh3e7qFsLu+n7uLdskf7qVK0k LS/5dxy3zzNq9PKDAagmRvKnnwVzmD5/YVoqfOvyKZ0Fkl03ZduNrUrr6lIwjbCRf0OM osdalYjF6a4Fdd+EwYRmCDHoKQCokUVP5s70pneq7EEMBUW5yfpkz2dQbxEPbXPklbSh KlAQ== 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 s18si12006333eji.59.2021.08.02.11.50.43; Mon, 02 Aug 2021 11:50:44 -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 966F86899DA; Mon, 2 Aug 2021 21:50:40 +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 A65CB6809BA for ; Mon, 2 Aug 2021 21:50:33 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0E350E593B; Mon, 2 Aug 2021 20:50:33 +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 vZjqHG_g0lh8; Mon, 2 Aug 2021 20:50:30 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 39F30E58F6; Mon, 2 Aug 2021 20:50:30 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Aug 2021 20:50:05 +0200 Message-Id: <20210802185005.21829-1-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] 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: Ta99bHX8Z6eY Also split error message to error and warning. Signed-off-by: Marton Balint --- libavcodec/mpeg12dec.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 858dca660c..49d865853b 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; @@ -1539,8 +1539,10 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1) s->mpeg_f_code[1][0] = get_bits(&s->gb, 4); s->mpeg_f_code[1][1] = get_bits(&s->gb, 4); if (!s->pict_type && s1->mpeg_enc_ctx_allocated) { - av_log(s->avctx, AV_LOG_ERROR, - "Missing picture start code, guessing missing values\n"); + av_log(s->avctx, AV_LOG_ERROR, "Missing picture start code\n"); + if (s->avctx->err_recognition & AV_EF_EXPLODE) + return AVERROR_INVALIDDATA; + av_log(s->avctx, AV_LOG_WARNING, "Guessing pict_type from mpeg_f_code\n"); 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);