From patchwork Thu Jul 9 19:20:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20933 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 E6A0544B0C4 for ; Thu, 9 Jul 2020 22:20:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C970568B5C3; Thu, 9 Jul 2020 22:20:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5DC3F68B56F for ; Thu, 9 Jul 2020 22:20:39 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id j18so3167595wmi.3 for ; Thu, 09 Jul 2020 12:20:39 -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=C2JaW9aGVXYRTc/+3DxAGnxH0IeA2UecFx46rGFGknk=; b=I0L0o8SDUIwp132J2XgzUIypN/wsShLiMsRPpofvQDBWKrdkZG1NpZAH0rYApZNroi uHcm+6g58MiGRho5rUeY96fFu1p5prWwRM4ovpef/PaLK01pAvkjsXXqMFNx8+MwMbXi jtHpJmkeCXBOIJ8bBXuuEPfiElRhr6ILlXHIL9Acg2ahnQ0Gtz4m9yHIX+2v14bC2hVq wFtfh9Tilw7W6sr3tSn0Lfjr/s0ZS7EIivQRMQ43xBDdwRuD9HEPDhpGO4dLV7z5FzOB V+xxqXPi+ds3AVw4Kc9n2MS4iK9p8uL6GVsI3ltJG0e9aVioEgnF/vt+5nBJhMtWtYvA 5ziQ== 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=C2JaW9aGVXYRTc/+3DxAGnxH0IeA2UecFx46rGFGknk=; b=h6mmy/lrIwinq4PuPI4QBeo7a1OWTIHujHCYzzJfXFFFBZVn6bdKGy7bHImIV2XSHy 9I9pk61MmzrkkQhBB4WHERF8zAnuSIS+Gv6jyi/CLndUhlINz8vr2xxoSAfAa9o17wOl C2A2dOOf8zzBfUyNkNqsmaEaXrrlPQDsqjcJlkAXtiRY8+V++KP1llTSiycZR07qMghy qcVg73K24Oh8ehcO4QGwykci9ENyBtN8z30dmqyxe/JvTYLUH4C+zEnQ3TadhmE2SWnI FyO7ClzOFyHu8s0CSNOVZEanuqxV4QHrjRzAwDqP9CcODNw/IgVgO07UMz9PHQkTvuTJ ujRw== X-Gm-Message-State: AOAM533jsu0dCkvSQjZeg10e9F/dfv7gvH0ZM5F1vszx3a3w4t81WDk9 XwsMhvLfhAmpzUP0VMIExgDhHRrD X-Google-Smtp-Source: ABdhPJwiUNbxXng9XaonRQyBkRcgHeKAd5B5th2hlk7F1jvq5rOFvZ8cggeqy9JWCLi0p2UWOpv6Cw== X-Received: by 2002:a1c:449:: with SMTP id 70mr1322574wme.149.1594322438605; Thu, 09 Jul 2020 12:20:38 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id p25sm5485330wmg.39.2020.07.09.12.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 12:20:37 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Jul 2020 21:20:17 +0200 Message-Id: <20200709192022.9412-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200709103542.19909-1-andreas.rheinhardt@gmail.com> References: <20200709103542.19909-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/17] avformat/avc: Discard empty NAL units during annex B->mp4 conversion 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" When an empty annex B NAL unit (i.e. 0x000001 immediately followed by a three or four-byte start code) is encountered during annex B->mp4 conversion, a NAL unit of size zero is created; this is invalid. Furthermore, several functions simply presumed all NAL units to be nonempty and treated the first byte as the NAL unit type. Ticket #7200 contains a sample with such NAL units. This commit skips empty NAL units during annex B->mp4 conversion, ensuring that the callers don't need to check for themselves. Signed-off-by: Andreas Rheinhardt --- libavformat/avc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavformat/avc.c b/libavformat/avc.c index 98462940ad..17fcd1e73f 100644 --- a/libavformat/avc.c +++ b/libavformat/avc.c @@ -104,6 +104,7 @@ const uint8_t *ff_avc_parse_nalu(const uint8_t **start, const uint8_t **nal_end, p += 3; } +search_again: next = avc_find_startcode_internal(p, end); if (next) { @@ -112,6 +113,12 @@ const uint8_t *ff_avc_parse_nalu(const uint8_t **start, const uint8_t **nal_end, } else { *nal_end = end; } + if (*nal_end == p) { + if (!next) + return NULL; + p = next; + goto search_again; + } *start = next; return p; }