From patchwork Sat May 30 16:05:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20023 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:bac9:0:0:0:0:0 with SMTP id a9csp1500364ybk; Sat, 30 May 2020 09:11:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOwgmKyCkHRTlM8XsC+2hBeRiQbBSpP69C3O5hy/QR34qVB8J/eQFxL3/f+VEJP3LAu9uN X-Received: by 2002:adf:ff82:: with SMTP id j2mr13361910wrr.375.1590855072411; Sat, 30 May 2020 09:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590855072; cv=none; d=google.com; s=arc-20160816; b=KdQmSDvwMQsqm3mrosisAfhejBguDvYlVDZy0a+OgO7jwKfi/XShhtSzBZxmx37b8G ZtFPvc8EwGGz+slC2wh85bVOD4sJ1D236Pha9s/EqJaDEPZq1K4mlTUIkYBC3wDJpJxa e1rq51cjpKzFujyu1peOd28pW4UmBLoVtVThwKiwK6hYZNIz4UEP+2ogO17bxbYHDpsr KKdAirFfnbO30gd8vLPF8Rp+xpFSseyhc7AwHjuffXxxCZm6spwjPIqqXMBFX2ILaIQr iwsGyOhdUbNEab5SaMK+YlHRFmADKJEINxs2Ru+PqCNaUMy2OuyESbwo9wWFJwEWq9u+ nKmA== 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:dkim-signature:delivered-to; bh=xa1kpI0dWUS83U2NoiYtJhrru/uBjID8lbyuSZC6IqM=; b=KG3IVpSB+9ATJLMVG0y72D7JfczBNO1ukSbuaqOVLPzuvSB5z9iLGayZArs6GfPSLF 1TrZE1dFE0pJyKXy72mrNiWtNTrNUrUlnXKRgdulYV3hy0FxYIYQ3pUpfBUWqqSLMONr AY8/ArLBa6tuK0pzDRRicA/fp0080vxjaE5lZWwGnBR2BkSuw86GDAVih1jN75AyIu4q wwWeBOsYnq8LaAEIieR29eqhA6MCorZox390+iIuSYcp7O6HW2fhvklht3vYk1aIdq0Q mBmlCYJjXj4iti8GnrL5pmm/+daq92gKek7VQ6uErcFatQWK2nrKA7BUbdAk1sXuvgOO ewDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="j/hu9Uy6"; 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 j3si12175274wrt.396.2020.05.30.09.11.12; Sat, 30 May 2020 09:11:12 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="j/hu9Uy6"; 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 747C868B0F2; Sat, 30 May 2020 19:06:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 70B3168B0F0 for ; Sat, 30 May 2020 19:06:46 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id j10so7160075wrw.8 for ; Sat, 30 May 2020 09:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LCc7lqyWt2o7ij24E960rNxSI0VqDVgkJg5cS3i1ms4=; b=j/hu9Uy6kJZJgW/47iZrX6EQglSqpFA0gIwKShoyNccHe/wpZfwOJeUrhigBHE/DiV pN+sqvV0iDxMqnnfOms1CWPNLYVuR+48R2ssNI1pC8f46cdB4o10pw43zFSxgNlU1R5W 8vW/nmF6R2GL9aQXj2KYXM7Kr1O8KKlKVAeMRn2SkSjyf275pze99MIBk0bdbZSvdyoy hFEhxRjX2dA/MPXzQfW5E9/Q0+GOlQ+IMKmiqzK1jVWkoi/JPuhx4dIfIKdLMmSfE1QP R0/p2zX0ZUkR0vgDj3VwULOGNK0w78to+6s9Iprmh54aPSvI/nsmUjAilGKrApoMWgca HSOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LCc7lqyWt2o7ij24E960rNxSI0VqDVgkJg5cS3i1ms4=; b=RSUir5nZYnQz2i3rKx+axlAaPBs8uBHO7L9uzRZt0tiQYbSpLRX5ow596iYrx1O9qN c4o8Q+vOuAZSvaQyIKVY2g2xkl0fwPMWhNrDqG/PRcquTM7zYF29kk/FNNd7OJE2/7YN NkVsZ1tU6r5nmrFVpsp3ne6jZJ+mptJsVKNLEf82SEKknBCVNbKZcqcoNlmGrLm1+mDt +MwF3taJA6zfg3M09n/ESM468noZM4wyfzm/ndqMpYEhRuPjavNsmXtmktoGR9wwkiZ/ XQsjOX1IDiXywu2SSMXRTM3OctxHNjB+7t5d4Iq0hzn0CHwXX3dtpBo6pzGxp0fHDQrW 4pvw== X-Gm-Message-State: AOAM530icCgaFJf+Y09XFEFlqqoM3AABG1uOZpE4lWviWDbW8Gg3taa9 tQxwSRRoLMhwsw+ExJG+Nc1S8PIj X-Received: by 2002:a5d:4c45:: with SMTP id n5mr14084298wrt.341.1590854805485; Sat, 30 May 2020 09:06:45 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id v27sm15186517wrv.81.2020.05.30.09.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 09:06:44 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 30 May 2020 18:05:33 +0200 Message-Id: <20200530160541.29517-28-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200530160541.29517-1-andreas.rheinhardt@gmail.com> References: <20200530160541.29517-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 28/36] avcodec/mjpega_dump_header_bsf: Miscellaneous improvements 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: uxxp3ziavHoB Content-Length: 2201 1. Instead of comparing two values read via AV_RL32 one can read both via AV_RN32 and compare the values. 2. Errors like AVERROR(ENOMEM) from failed allocations are now always forwarded. Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpega_dump_header_bsf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpega_dump_header_bsf.c b/libavcodec/mjpega_dump_header_bsf.c index 4ea55e88ba..98fd2f9250 100644 --- a/libavcodec/mjpega_dump_header_bsf.c +++ b/libavcodec/mjpega_dump_header_bsf.c @@ -77,7 +77,7 @@ static int mjpega_dump_header(AVBSFContext *ctx, AVPacket *pkt) return 0; } case APP1: - if (i + 12U <= pkt->size && AV_RL32(pkt->data + i + 8) == AV_RL32("mjpg")) { + if (i + 12U <= pkt->size && AV_RN32(pkt->data + i + 8) == AV_RN32("mjpg")) { av_log(ctx, AV_LOG_ERROR, "bitstream already formatted\n"); return 0; } @@ -85,9 +85,10 @@ static int mjpega_dump_header(AVBSFContext *ctx, AVPacket *pkt) } } av_log(ctx, AV_LOG_ERROR, "No valid SOS marker in bitstream\n"); + ret = AVERROR_INVALIDDATA; fail: av_packet_unref(pkt); - return AVERROR_INVALIDDATA; + return ret; } static const enum AVCodecID codec_ids[] = {