From patchwork Mon Nov 23 19:10:41 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: 23981 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 53D5F44A18E for ; Mon, 23 Nov 2020 21:17:59 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3877568BB8D; Mon, 23 Nov 2020 21:17:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 46B3868B9EF for ; Mon, 23 Nov 2020 21:17:58 +0200 (EET) Received: by mail-lj1-f194.google.com with SMTP id i17so19286573ljd.3 for ; Mon, 23 Nov 2020 11:17:58 -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=VKJPDSKqxRln6lQtSKVf+HVR/9yPTOof2MsADcKVgdE=; b=UiVa5lk0hFr7BbZFWGkU1g2EWFWCc+BlEgO+KzVziWGQ1bSGAT5nUOosG5GhMA5zhH lP24/5FnLuEh54QOvYDzDRB+X5Na8Dd4OEYm/ZBA0/bT/YFX8QK7/kwdmyyS+8090LW+ 7dTIXvDT9wgA0pJH+gDLiPIeLuFKvwsoGvmkKtqSHimUch6K9qLG60QznxBkrPNCu30v pGElVA0zx3ivYO7bVF+fBQudXqF0dmLtKl80sCM55U1qRBN4ZHX0z501dN4sL/6eaMnH T0nQNQ7fEOo+Nqz4iGKHBIngUKi0KWLo0SNucoqt8buxl4hipWD3fxpT9Z8aPFzKkSEj LryA== 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=VKJPDSKqxRln6lQtSKVf+HVR/9yPTOof2MsADcKVgdE=; b=SGKWeTIYhMbYx3m/vAKLGmjK7gZI6iUnQ7K1j4dy5PJFDpw9NrBwMkTm/Ssstx/vRT +s7Sa546ymn2FaXbj2d2UmTHW1GUCsjKkMIyVZO4rhhejdvFq212CpbxuptpcUcH8pWE W4d6QRE/jdZ+0UCIFnjjhBZWxzd+BignR75k6uhmuCYnwhfGStnpzkG5XYZZlQ6VkLuP cvujqlUwYhOp6hhaRv7/4dbfD+bMnuevBfWZeXn5p/Mg3DH6SU/g3gX3VsFrzRztpgGI pHMx8BNhHkAe/Xod6hGmSeF+3hzrGk0t8gClmqv5pZPgfvwysoK4sWYCgy/KC7hq9PxW 04/A== X-Gm-Message-State: AOAM530405Er3zLzcvgfF+Xq24vzyxVkd/66V9YdqD+j6H5HO+QsLHuB kxz1e/ALjjMlL9UhPlO+1Ci2UgDZTHmNLQ== X-Google-Smtp-Source: ABdhPJwyzfu6G6X4MfO8sEnl6b/eEzI43F/7NwrbQ7bFw0jpmK5zBSmD1gQ+TcSZF4TlSZygiQ+zGQ== X-Received: by 2002:a2e:9d99:: with SMTP id c25mr350584ljj.213.1606158652257; Mon, 23 Nov 2020 11:10:52 -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.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 11:10:50 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Nov 2020 21:10:41 +0200 Message-Id: <20201123191046.28887-2-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 1/6] cbs: Add function to read extradata from an AVCodecContext 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" From: Mark Thompson This is useful in decoders and parsers, matching the way that bitstream filters read extradata from AVCodecParameters. --- libavcodec/cbs.c | 77 ++++++++++++++++++++++++------------------------ libavcodec/cbs.h | 11 +++++++ 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index c8c526ab12..f98531e131 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -223,66 +223,67 @@ static int cbs_fill_fragment_data(CodedBitstreamFragment *frag, return 0; } -int ff_cbs_read_extradata(CodedBitstreamContext *ctx, - CodedBitstreamFragment *frag, - const AVCodecParameters *par) +static int cbs_read_data(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + AVBufferRef *buf, + const uint8_t *data, size_t size, + int header) { int err; - err = cbs_fill_fragment_data(frag, par->extradata, - par->extradata_size); - if (err < 0) - return err; - - err = ctx->codec->split_fragment(ctx, frag, 1); - if (err < 0) - return err; - - return cbs_read_fragment_content(ctx, frag); -} - -int ff_cbs_read_packet(CodedBitstreamContext *ctx, - CodedBitstreamFragment *frag, - const AVPacket *pkt) -{ - int err; - - if (pkt->buf) { - frag->data_ref = av_buffer_ref(pkt->buf); + if (buf) { + frag->data_ref = av_buffer_ref(buf); if (!frag->data_ref) return AVERROR(ENOMEM); - frag->data = pkt->data; - frag->data_size = pkt->size; + frag->data = (uint8_t *)data; + frag->data_size = size; } else { - err = cbs_fill_fragment_data(frag, pkt->data, pkt->size); + err = cbs_fill_fragment_data(frag, data, size); if (err < 0) return err; } - err = ctx->codec->split_fragment(ctx, frag, 0); + err = ctx->codec->split_fragment(ctx, frag, header); if (err < 0) return err; return cbs_read_fragment_content(ctx, frag); } -int ff_cbs_read(CodedBitstreamContext *ctx, - CodedBitstreamFragment *frag, - const uint8_t *data, size_t size) +int ff_cbs_read_extradata(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVCodecParameters *par) { - int err; + return cbs_read_data(ctx, frag, NULL, + par->extradata, + par->extradata_size, 1); +} - err = cbs_fill_fragment_data(frag, data, size); - if (err < 0) - return err; +int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVCodecContext *avctx) +{ + return cbs_read_data(ctx, frag, NULL, + avctx->extradata, + avctx->extradata_size, 1); +} - err = ctx->codec->split_fragment(ctx, frag, 0); - if (err < 0) - return err; +int ff_cbs_read_packet(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVPacket *pkt) +{ + return cbs_read_data(ctx, frag, pkt->buf, + pkt->data, pkt->size, 0); +} - return cbs_read_fragment_content(ctx, frag); +int ff_cbs_read(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const uint8_t *data, size_t size) +{ + return cbs_read_data(ctx, frag, NULL, + data, size, 0); } static int cbs_write_unit_data(CodedBitstreamContext *ctx, diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index 635921b11e..3fd0a0ef33 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -262,6 +262,17 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVCodecParameters *par); +/** + * Read the extradata bitstream found in a codec context into a + * fragment, then split into units and decompose. + * + * This acts identical to ff_cbs_read_extradata() for the case where + * you already have a codec context. + */ +int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVCodecContext *avctx); + /** * Read the data bitstream from a packet into a fragment, then * split into units and decompose. 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; From patchwork Mon Nov 23 19:10:43 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: 23983 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 82C3244AC61 for ; Mon, 23 Nov 2020 21:19:14 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 64CA468BB9E; Mon, 23 Nov 2020 21:19:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 862E768B7BF for ; Mon, 23 Nov 2020 21:19:08 +0200 (EET) Received: by mail-ed1-f66.google.com with SMTP id q3so18248801edr.12 for ; Mon, 23 Nov 2020 11:19:08 -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=ICuo+vGLAHGYsnmwdMu67RKYlPKxg1dDe9jq4rU1BEg=; b=L7inJ57s0nYAhBwzamovW8quHw2srC9gEuuB8KYfNq00P4P5dWVryWKXE7nab6HWkd 5s4GvzJS1Bsb7GLTQheXxbugfEMTbVJpxH2wpKR4bct94WPcks7JYqOjazAuQitouKBU MmGPdgda3RLMqHpjcEmRoeMEn0X7zfajLntYqdiRefHotY+Ao5MJguehOwejgqa7a9XY i7JoDZuef7pIV0YHWhFi5AjQ4VBwp7G6UWDSWJKlFxX8hNcfVe7dRT20znWJKbYumBQ+ ZSFSxJQvZ+zPF6GM1tmHQ8YNADuCbu0AzuuXT+NgtSyaLcO+UWbaWX+2soJFUx1BlNTY UC4A== 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=ICuo+vGLAHGYsnmwdMu67RKYlPKxg1dDe9jq4rU1BEg=; b=PqYi+mo0xHehF3NWUL+dPhvHUu1e4A/EnAjprxAtGuwCQmX/bxwqwfC6kaS2Z5meiR AJga20hHJtveNm8DfWUdOMfusfOBFmbsoWcKqv4sI+xtt+D6tMy05Rk1z8/Dfrb1fBCc fCEHR/p/ejYnGOLgCVHLaetcsgVQlNG9XMdrmgX4CrisKRt7cP38Rf836+wnbjAX4ooC pGLGqVKm2IM2/KU6iCnhl2a29v8L4EhfHHtfGj93nBg+ZkoStkdi8oYPjTRqrYabugEF DIvqvSGC844Xo7G/0BZwEOiR99ogxLoVx4Ej9uhilGlVy3tcyZd4tU8B/U2O6g08YRNW mkTA== X-Gm-Message-State: AOAM533pRrCgkVk9EFtLE/rP81bqwlmnXvOemQJt9Pwa7c3O2c2FZBr4 Wq7+eq1piMjO1xjMlOrsztt5jdhmV9XiWA== X-Google-Smtp-Source: ABdhPJzlOrwjDSIHhy+fZ5eQOyis50yIxRsPLW3S83PV0+CIkknDH7cqEfX9DmHPu8qkIH6sxtqjMQ== X-Received: by 2002:a2e:9dcd:: with SMTP id x13mr322640ljj.147.1606158655631; Mon, 23 Nov 2020 11:10:55 -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.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 11:10:54 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Nov 2020 21:10:43 +0200 Message-Id: <20201123191046.28887-4-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 3/6] avcodec/av1{dec, parser}: move to ff_cbs_read_extradata_from_codec 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 lets us re-utilize the extradata-related checks in the CBS to add support for passing the AV1CodecConfigurationRecord as extradata as-is without further filtering. --- libavcodec/av1_parser.c | 2 +- libavcodec/av1dec.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c index 14826d816e..181ff3a1be 100644 --- a/libavcodec/av1_parser.c +++ b/libavcodec/av1_parser.c @@ -73,7 +73,7 @@ static int av1_parser_parse(AVCodecParserContext *ctx, if (avctx->extradata_size && !s->parsed_extradata) { s->parsed_extradata = 1; - ret = ff_cbs_read(s->cbc, td, avctx->extradata, avctx->extradata_size); + ret = ff_cbs_read_extradata_from_codec(s->cbc, td, avctx); if (ret < 0) { av_log(avctx, AV_LOG_WARNING, "Failed to parse extradata.\n"); } diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index c1967f03bd..ce051d4e6d 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -616,8 +616,9 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) return ret; if (avctx->extradata && avctx->extradata_size) { - ret = ff_cbs_read(s->cbc, &s->current_obu, avctx->extradata, - avctx->extradata_size); + ret = ff_cbs_read_extradata_from_codec(s->cbc, + &s->current_obu, + avctx); if (ret < 0) { av_log(avctx, AV_LOG_WARNING, "Failed to read extradata.\n"); return ret; From patchwork Mon Nov 23 19:10:44 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: 23976 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 5491E449287 for ; Mon, 23 Nov 2020 21:16:31 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 379B168BB17; Mon, 23 Nov 2020 21:16:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D2F3268B922 for ; Mon, 23 Nov 2020 21:16:24 +0200 (EET) Received: by mail-lf1-f68.google.com with SMTP id j205so25325492lfj.6 for ; Mon, 23 Nov 2020 11:16:24 -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=BOxElckCt/97+Ln4BeEmL33sqT0bAW6SbDFpuoe9Ja4=; b=Mz5qpj0Z3++ERDarTQSzAvpN2yLB4UdMbLBI6P0lcdloWl4L8AVrVAkIzZA8WmUphk gFfn+ZTfRp3auAujTaHHcHt07lvs95cc5EHjv9r3SM1fFPHE+EBoorMM7UrsviJjtWsc fu7HnTaWxDOb4wK8H3/o12I+PIRjymYOtq6M9TVK8FSk/NI7/G1HCHV1OsLDVu1UZft2 CdnatxhvJLzefLynxzltPZ0wNckXV5+mySdnqbB0ia5dZRMOoFnZI1QSNHWUS9YlON3j GUdrw38xPTmO3k11HaWKYCyUKrLfZwOrVos08tmP2bKoHnOPPzc2cdVWiCM5W7FjbeRT J/rQ== 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=BOxElckCt/97+Ln4BeEmL33sqT0bAW6SbDFpuoe9Ja4=; b=loI4oRODHnxMCAry8tK5GYdwCdaejaKdM+vLM0O4Ur9PfSTbCVjOkGG69uoUmK9We1 pAeHEkHkgrIsb1JfslXxqhg3opxGwH67vXhHz9tb8q4j1S/Poa6e5sF9kbE/i/0OppSo qZbvnz8h7qu1QREhxTEwhs2dlmEB2b6L7/X4sXIaZv4rwNdoBD6YHXiFbo7HRbQHavMV cfCSOQ41pKz6z5+Zf40ksSQSDv9pCadvMLb78uTom+QCUhUWGrH1rna48wAxzFgOIkj8 nsObdClkLiHfcpmeZqBr0Yk///UsjPHlqvrxpQIjo7zwaGQHY1NcONxc1pC/pWuKqefZ fDKQ== X-Gm-Message-State: AOAM532eRoL0qTi43g+lSq4IWtyI4oPNEuDqKsjOHz34BWFW2x2YHjkK XNFW5Z1/1s1j8Ddm8aICQNG5JpSCNCw5Rg== X-Google-Smtp-Source: ABdhPJxXp8pqDCtxNLxm4AkHx7FnXVgVEvmKa/uwt4y2snrMZIJPiljWtPC6Lrl0HWfiukuypwuQPQ== X-Received: by 2002:a19:c897:: with SMTP id y145mr269820lff.214.1606158657014; Mon, 23 Nov 2020 11:10:57 -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.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 11:10:55 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Nov 2020 21:10:44 +0200 Message-Id: <20201123191046.28887-5-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 4/6] avformat/av1: add support for passing through MP4/Matroska av1c 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" --- libavformat/av1.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libavformat/av1.c b/libavformat/av1.c index 0cbffb1fd8..5512c4e0f7 100644 --- a/libavformat/av1.c +++ b/libavformat/av1.c @@ -375,6 +375,20 @@ int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size) if (size <= 0) return AVERROR_INVALIDDATA; + if (buf[0] & 0x80) { + // first bit is nonzero, the passed data does not consist purely of + // OBUs. Expect that the data is already in AV1CodecConfigurationRecord + // format. + int config_record_version = buf[0] & 0x7f; + if (config_record_version != 1 || size < 4) { + return AVERROR_INVALIDDATA; + } + + avio_write(pb, buf, size); + + return 0; + } + ret = avio_open_dyn_buf(&meta_pb); if (ret < 0) return ret; From patchwork Mon Nov 23 19:10:45 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: 23977 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 11269449287 for ; Mon, 23 Nov 2020 21:16:53 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F139D68BB81; Mon, 23 Nov 2020 21:16:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6668568BB7E for ; Mon, 23 Nov 2020 21:16:46 +0200 (EET) Received: by mail-ed1-f67.google.com with SMTP id y4so18275225edy.5 for ; Mon, 23 Nov 2020 11:16:46 -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=VAiRkJ3ftDw2uFQHVE9fokhj8m+jqN5kQbaX/F9kYMA=; b=HX6W5mFrzIPNQylNyp1gj+L9ZhDZJHkb33+ihgCrDvL19nizzhJF2RVSePJzDbOseV R1Pk7ppaaggahfTwdUcxjqn6n2gkbkhVBlcqqikhBbxV3ivnivesXs4HwjZ4ToQOnieK qklMjKG073snZbuCdN9vKUvxGwveccoLOIa0d8sIdohzLb3zzbBW6dpLb06sDwhMTfoM 11TyNBlKQUnIwuUSfm5K5hAOc3X0tkplqdTxP/EHekYIH8NtsFYZ4npp65h9F5xENX2U NXm7CRkg4WcDhMYXZQ1f8I5gEaqqihJZ3FzNEW20+G0Uz7J7ojtVxTxX/7WCwRj1tu0n EdGQ== 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=VAiRkJ3ftDw2uFQHVE9fokhj8m+jqN5kQbaX/F9kYMA=; b=ZmQE2JKMSKRFeU+GU0sJhbzQrRhFcG4No0+Vx8C7ajvxg7LlQ74TbwhTev5xnAcHlH ZMkO2rwKSMvDHSHPjZRGPsDeLQSFv5fisNbNZA8LZpzBF0OoFYDyUKuRVeiEM4/G/Yrg BSyDVQewSyG4EKCW04L19aPFnUCbSo/BVRHOpl81v7EQb7wG+yKC5Q46EuC5GNGPc+kD 3mvYP+Qt2dyQrb/sLMkwZjTr2BOe3QdhfEzmFBn8A0Gwg5c7rAjiLA85A7rFE/zE87u7 8zEW3bc1mD+x/6n++CtpyZ8NvtuY3BmjGid9hFI+7owmenGSjRKMQJfDvmaKTHune6Qa irMQ== X-Gm-Message-State: AOAM531HqsqqcU70MRefj2ULhMP3Zp8S46QhLErYlbJaEZNn7y3NwwcD PzEdGgmHgkSeb/gCbXx28EjEJRsHm9il2Q== X-Google-Smtp-Source: ABdhPJzulzGPSaIqwLRs1x0+tApLYILPkdune9aENAp12lFAc3s/I1B1octXqwjui+Jn7K1Tt3df3w== X-Received: by 2002:a2e:975a:: with SMTP id f26mr378345ljj.81.1606158657988; Mon, 23 Nov 2020 11:10:57 -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.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 11:10:57 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Nov 2020 21:10:45 +0200 Message-Id: <20201123191046.28887-6-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 5/6] avformat/mov: remove special handling of av1c 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" Libavcodec can now handle the AV1CodecConfigurationRecord structure as-is when passed as extradata, so the standard behavior of read-box-into-extradata should suffice, just like with AVC and HEVC. --- libavformat/mov.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2b90e31170..2698269b4d 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5324,34 +5324,6 @@ static int mov_read_tmcd(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } -static int mov_read_av1c(MOVContext *c, AVIOContext *pb, MOVAtom atom) -{ - AVStream *st; - int ret; - - if (c->fc->nb_streams < 1) - return 0; - st = c->fc->streams[c->fc->nb_streams - 1]; - - if (atom.size < 4) { - av_log(c->fc, AV_LOG_ERROR, "Empty AV1 Codec Configuration Box\n"); - return AVERROR_INVALIDDATA; - } - - /* For now, propagate only the OBUs, if any. Once libavcodec is - updated to handle isobmff style extradata this can be removed. */ - avio_skip(pb, 4); - - if (atom.size == 4) - return 0; - - ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size - 4); - if (ret < 0) - return ret; - - return 0; -} - static int mov_read_vpcc(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; @@ -6875,7 +6847,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('A','A','L','P'), mov_read_avid }, { MKTAG('A','R','E','S'), mov_read_ares }, { MKTAG('a','v','s','s'), mov_read_avss }, -{ MKTAG('a','v','1','C'), mov_read_av1c }, +{ MKTAG('a','v','1','C'), mov_read_glbl }, { MKTAG('c','h','p','l'), mov_read_chpl }, { MKTAG('c','o','6','4'), mov_read_stco }, { MKTAG('c','o','l','r'), mov_read_colr }, From patchwork Mon Nov 23 19:10:46 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: 23980 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 34B6C44A18E for ; Mon, 23 Nov 2020 21:17:38 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1880E68BB90; Mon, 23 Nov 2020 21:17:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EAD2F68B8D9 for ; Mon, 23 Nov 2020 21:17:31 +0200 (EET) Received: by mail-lf1-f42.google.com with SMTP id t6so9208812lfl.13 for ; Mon, 23 Nov 2020 11:17:31 -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=u4ywVsguUaNvvYxSl559bqleevJX31909sx2vB7CcD0=; b=Aoek48Q45YjYUycHyo9iZkeXRwytx+Oxw0scyKHt9IejBZx6B4JKOq9S0ZGOCF/+rp Z8M1MU92YMPv3xx4s8XzG0H/gco4syE4xNM7NibEfPar+LRtDQktEa3E+7SkGqikdSJf +lAUORBh6iNxIV0rfvgckd3LOBfjaXgcqOZ8FTFgzMTdYmiShZdWyDxw5rr6z8JeeeCY bgVadzU1sVn26IlGLaVkIHcEeIhPUwRK4K3+bjVO52Wo+RQ41LlIt8IXjlOB+bOWw4jP 0ZXIfTbX4FqVE5lEjneWwVAooocUGNYMiW9AOcOnXCzdccsyB6jwfYB1BNRRuznhUY0a O3DQ== 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=u4ywVsguUaNvvYxSl559bqleevJX31909sx2vB7CcD0=; b=gatNzqYzzF7a/kSqsM3zt5tJOTIs+eOk7obddPDzO5zBHiqnK1uS/Lbhoxk22C8fpL oVtSgCZSn+1h1ZW6+EzDP0UQk9G0zXLhY/J3saBUq/hwXofal0bfEmwGAfMDiOuBRk3Q kwgEkF6OBmqGGuGPbVZotKg6qnSXK9/vEZNpnk2hIFQyfpvz7hy0PkfubOhaDRozZZzx tA6drzV+6zig/S1iza5nnbhwzZT76jyV6xcBbYU7hT5euu04aroMbxpXrSjINJYQb4T0 eyWn8ib5QHaBjY/2X6GDRKfOnTBPr2Oow3raz49APxJSuR483Pk23kwVsKKeZ1UMTnsE aqnQ== X-Gm-Message-State: AOAM530fXcngEQX22xNGvk8z5aev5iJ9p1uZ5rbTFoN82Wf1sdWiG0To Ex47eoaHW6J0Xw4mcm4faNq7yq3c2rk2cg== X-Google-Smtp-Source: ABdhPJzfmIW3UELvDSggsH8S8NsAdHUc3dMQObH6pO4uRGOBZ2+EqkTRt+EY7FSHn351if45kmZ2+g== X-Received: by 2002:a19:ecf:: with SMTP id 198mr227815lfo.193.1606158659242; Mon, 23 Nov 2020 11:10:59 -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.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 11:10:58 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 23 Nov 2020 21:10:46 +0200 Message-Id: <20201123191046.28887-7-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 6/6] avformat/matroskadec: remove special handling of av1c 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" Libavcodec can now handle the standard AV1CodecConfigurationRecord extradata as-is. --- libavformat/matroskadec.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 44db2c8358..da0fadd47a 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2661,10 +2661,6 @@ static int matroska_parse_tracks(AVFormatContext *s) /* we don't need any value stored in CodecPrivate. make sure that it's not exported as extradata. */ track->codec_priv.size = 0; - } else if (codec_id == AV_CODEC_ID_AV1 && track->codec_priv.size) { - /* For now, propagate only the OBUs, if any. Once libavcodec is - updated to handle isobmff style extradata this can be removed. */ - extradata_offset = 4; } track->codec_priv.size -= extradata_offset;