From patchwork Mon Nov 23 19:10:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 23984 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 55BE944BAC5 for ; Mon, 23 Nov 2020 21:34:22 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 304F268BB79; Mon, 23 Nov 2020 21:34:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2C42868BB5C for ; Mon, 23 Nov 2020 21:34:16 +0200 (EET) Received: by mail-ed1-f42.google.com with SMTP id cq7so18333114edb.4 for ; Mon, 23 Nov 2020 11:34:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BbhuOjzs5X5UfbH4SobgKkgRT4ljaqYiBDWhhm7io3A=; b=jaJJL/rr6O9A9S2CwDNvakd6owIUpFKd/Cu1A8LrZGAyyAm7A7apWbnXuqcZA45x9N iQcWDNf2RRiE41xx2oS6njgxlVedmtsyfdgoTxysj2NUXF85amVqhCShmZRSE5Y/hjS1 QFw2PgkPf1IbU6QTsrhXo8SwtjBPOkjTpfyMiJU7fVzncgDEtqhG/5BxNwoQIC311/4V abAjPvGFc/WNkhrdMozSUz9twARxVBiuNPA9T1neOAb7LMbtoiIRNQ7W3ojjIWiZ4Fx/ 1BnNRwSN1R6gD8odScSFg8L2/SsNcxRbD0vTuF6u/D8rfLKg5ZqLmJh5EDumFootLoqw dbGA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=BbhuOjzs5X5UfbH4SobgKkgRT4ljaqYiBDWhhm7io3A=; b=fKbn+0BQcl6T3MaJvEbE2kZOGI9HMAB7ZqHxy6itGAgVfWbCeUcKbbSADeAHhrf7ww DGbC6zsM4IXrvdMzRJpP9FtySQE0MuHDAeMzU23e+s4CPtqM81Rb5+y2c5SNBvPf8NIe jxIdL3b9BzasEqXJgwdVJaR7kPiYVNE0fYIgSZiAKEo6Jhzynn+qGlIGXCmRa6qp1iBW NC8wDpNTXz4UdqOXL369QL5eVJ8Fapm7HdAlYB8hjh+Fli7XIWa0bSjzi1Xz7mu6dGGC JxhLzOQLXB+LYeeXa4pT62pSy+TfOqh3IjkjI15ZfMioiRRMyXFq6DK8DqkYRuFDyKDj bSCw== X-Gm-Message-State: AOAM533OpilMnYrJHsiksZnPBSTziShLwyH5DRlL76XFdjzxDAkNbc23 Z0//rbtUaSfzHunseyTDFUkqCC4Hq9OAoQ== X-Google-Smtp-Source: ABdhPJxyWYAk/GfNhreiGb0fy1iHb525rNTUT9KpYCvaYyfyJw6MhA3XXG3dZUWusPU3ZET8IPGcVg== X-Received: by 2002:a19:88a:: with SMTP id 132mr273043lfi.316.1606158653623; Mon, 23 Nov 2020 11:10:53 -0800 (PST) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id j19sm1469995lfb.29.2020.11.23.11.10.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 11:10:52 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Nov 2020 21:10:42 +0200 Message-Id: <20201123191046.28887-3-jeebjp@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123191046.28887-1-jeebjp@gmail.com> References: <20201123191046.28887-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] avcodec/cbs_av1: add support for standard MP4/Matroska extradata 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" This way API clients can just pass the AV1CodecConfigurationRecord as extradata as-is without further filtering. --- libavcodec/cbs_av1.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index 9badfe31e4..9ae2f59872 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -758,6 +758,39 @@ static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, goto fail; } + if (header && size && data[0] & 0x80) { + // first bit is nonzero, the extradata does not consist purely of + // OBUs. Expect MP4/Matroska AV1CodecConfigurationRecord + int config_record_version = data[0] & 0x7f; + + if (config_record_version != 1) { + av_log(ctx->log_ctx, AV_LOG_ERROR, + "Unknown version %d of AV1CodecConfigurationRecord " + "found!\n", + config_record_version); + err = AVERROR_INVALIDDATA; + goto fail; + } + + if (size <= 4) { + if (size < 4) { + av_log(ctx->log_ctx, AV_LOG_WARNING, + "Undersized AV1CodecConfigurationRecord v%d found!\n", + config_record_version); + err = AVERROR_INVALIDDATA; + goto fail; + } + + goto success; + } + + // In AV1CodecConfigurationRecord v1, actual OBUs start after + // four bytes. Thus set the offset as required for properly + // parsing them. + data += 4; + size -= 4; + } + while (size > 0) { AV1RawOBUHeader header; uint64_t obu_size; @@ -803,6 +836,7 @@ static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, size -= obu_length; } +success: err = 0; fail: ctx->trace_enable = trace;