From patchwork Sun Mar 10 14:01:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 46931 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dc95:b0:1a1:738b:6bc0 with SMTP id ky21csp735158pzb; Sun, 10 Mar 2024 07:02:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXYI6vxtjVXvrnOckJ0kzqpfKC+ytso1VgxL+XOaik53kZyuM52/K4DCTs4BhQuTNe1NPz0vxhjeuiK9kCI4NKZb/AJlSVf/ZIGaA== X-Google-Smtp-Source: AGHT+IGqorzpaSD6MXvoptm2R53aT6UJ/9Dm6Byiq/m5ospXBzrE/h8WZc3w/ssMgUZmEEEKPtja X-Received: by 2002:a05:6512:39ce:b0:513:a833:cda2 with SMTP id k14-20020a05651239ce00b00513a833cda2mr681226lfu.53.1710079370262; Sun, 10 Mar 2024 07:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710079370; cv=none; d=google.com; s=arc-20160816; b=YbxPiDAwK1Ls5Bo7OtpUHCBZeOxWCTuYkCRnT6Cx8ElJqKLdM8axo4imSzR8bpr43s Dq9cFld2vjcMdxSKPKd3VOoVn2U4v50qjAL6QPi1R/SxlWXPrJy1lsNESMrhYsD1N4dY JIH/3J967Br238ua2HzNr2jz02/TFVHFXz23PN2YZ625KLs/J81l2VDSo+63PkRIn4kf IW1Q685DEY32pQchJDAssjQCoYdn81Jcg9HPzBS1F+tPERynpFcd0hkbhzyOuGfgZFPP aC83xI8d4QWwcIMqB6310d8wpFFu+3uSFtQ7QT3HqXZwybwqLv3CBfV8GLvPBKk24Pon iTnQ== 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=ziG+WCse+swgjumds+N6InP4dM/a50+32y7ZzDwTQ/I=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=Xhh0gnFDm6FtgLK81K9iYcUwhVhU7CCPtMJ2vmIOtoRRufddINX+TNNVkOlcTYYEkn OtW4teNZhukfqyO4wLad7xSh/mi2yCKNw7YrM08d5QAlPHsdpDdjcWLbXCBcOQ95VK4H WpqyScQVWePHqeQEXkF5uVOW/SQYaI9jwTAFu/Xab7QqhezdtEoCTWwwNxc6R8/JNPdV trqYj+BWsvCTDjh+/IXFS0nyU/qc7n5E3tg9AaQ70k3CZqz/KTa8TGCO7a3p7M606spz LLHXZIvqhEWahslPMcXgBRSFQuAMceeEB+Z74XEraNA2q6T2Z1JEE3LnXaDNAs0/enkb CbsA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=LYjfsqmP; 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 l25-20020a056402345900b005671d4c0714si1623255edc.161.2024.03.10.07.02.42; Sun, 10 Mar 2024 07:02:50 -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=@haasn.xyz header.s=mail header.b=LYjfsqmP; 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 B23B768CE21; Sun, 10 Mar 2024 16:02:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ACD7B68BCA7 for ; Sun, 10 Mar 2024 16:02:23 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1710079343; bh=Ae5obRiYVyvJDY8GY8IVJ7CViKvP0JVX0ow1cBDJWcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LYjfsqmPAmlbpFnoM4441vWY61YT99kg7NJ+MUz609ThsQFCgpYyZViTzYFYEtPZs uLG/8irc/h5l4LgoPteDdWtHGMhkAUNpjKYvTGsjBSg3W7sOTDYOU0NWKLf/ezhF/J uL8wJdM3S7OJjgYMxK1ED5zG/7PAPpwRKLc0/zTM= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 70BCF4255D; Sun, 10 Mar 2024 15:02:23 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Mar 2024 15:01:13 +0100 Message-ID: <20240310140112.41366-4-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240310140112.41366-2-ffmpeg@haasn.xyz> References: <20240310140112.41366-2-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/3] avcodec/av1dec: parse DV profile 10 T.35 OBU 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: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Vmdij5sAoL6X From: Niklas Haas See previous commit. --- libavcodec/av1dec.c | 25 +++++++++++++++++++++++++ libavcodec/av1dec.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index bbb5634773f..e6346b51dbe 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -734,6 +734,7 @@ static av_cold int av1_decode_free(AVCodecContext *avctx) ff_cbs_fragment_free(&s->current_obu); ff_cbs_close(&s->cbc); + ff_dovi_ctx_unref(&s->dovi); return 0; } @@ -828,6 +829,7 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) { AV1DecContext *s = avctx->priv_data; AV1RawSequenceHeader *seq; + const AVPacketSideData *sd; int ret; s->avctx = avctx; @@ -883,6 +885,12 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) ff_cbs_fragment_reset(&s->current_obu); } + s->dovi.logctx = avctx; + s->dovi.dv_profile = 10; // default for AV1 + sd = ff_get_coded_side_data(avctx, AV_PKT_DATA_DOVI_CONF); + if (sd && sd->size > 0) + ff_dovi_update_cfg(&s->dovi, (AVDOVIDecoderConfigurationRecord *) sd->data); + return ret; } @@ -936,6 +944,7 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, const AV1RawMetadataITUTT35 *itut_t35) { GetByteContext gb; + AV1DecContext *s = avctx->priv_data; int ret, provider_code; bytestream2_init(&gb, itut_t35->payload, itut_t35->payload_size); @@ -985,6 +994,22 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, return ret; break; } + case 0x3B: { // dolby_provider_code + int provider_oriented_code = bytestream2_get_be32(&gb); + if (itut_t35->itu_t_t35_country_code != 0xB5 || provider_oriented_code != 0x800) + break; + + ret = ff_dovi_rpu_parse(&s->dovi, gb.buffer, gb.buffer_end - gb.buffer); + if (ret < 0) { + av_log(avctx, AV_LOG_WARNING, "Error parsing DOVI OBU.\n"); + break; // ignore + } + + ret = ff_dovi_attach_side_data(&s->dovi, frame); + if (ret < 0) + return ret; + break; + } default: // ignore unsupported provider codes break; } diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h index a6ad80c12ab..336eb613597 100644 --- a/libavcodec/av1dec.h +++ b/libavcodec/av1dec.h @@ -31,6 +31,7 @@ #include "packet.h" #include "cbs.h" #include "cbs_av1.h" +#include "dovi_rpu.h" typedef struct AV1Frame { AVFrame *f; @@ -81,6 +82,7 @@ typedef struct AV1DecContext { AV1RawMetadataHDRCLL *cll; AV1RawOBU *mdcv_ref; ///< RefStruct reference backing mdcv AV1RawMetadataHDRMDCV *mdcv; + DOVIContext dovi; AVFifo *itut_t35_fifo; uint16_t tile_num;