From patchwork Sun Feb 25 11:44:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 46519 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51b:b0:19e:cdac:8cce with SMTP id gm27csp835860pzb; Sun, 25 Feb 2024 03:45:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUq0/V77k7cb7WbJWbWEv8VyHtg7o4Omqo6DFegzGJLxtC+OxeZrBxQ+q/YPDO6HK8IJ8puN+7T+/q4+PD00MJ4lVPCu+1tMRT2Jg== X-Google-Smtp-Source: AGHT+IF9gOL465N9x7JDf7MHivZAkU4UqlW12yqI4LhCmW6XHtUXl/ZzK7JLLj3EXVH2mOOcRQ+5 X-Received: by 2002:a17:906:6954:b0:a3f:c49e:54d with SMTP id c20-20020a170906695400b00a3fc49e054dmr3118302ejs.63.1708861525389; Sun, 25 Feb 2024 03:45:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708861525; cv=none; d=google.com; s=arc-20160816; b=CG8d9uYKL4DidnnTJvuf9aeVK+X2hbcDmBjVYlMSr/WtNTtWE2DCEtXgPcawAZHz9Y jawWU+BxV1kk+W16LU2hpm/hybiQ5j2auXAadtFgFArkRzJ+85fhitI1gB+3zu5Fiqt3 jvXZgtC3OO9bi49fvJ48jzF55CYCrfEb7koaQtq78htFzFk/9mIl3ToX97TfwVQ2tsEi 0JFBx4t14S4OozmuAzywpzp0Z2gbbTSLGmf1oJ50Ds6ggEnl9M9zEv2ueeEEdvtSY3m9 D82P3mjmMVuw4abgKl/GOtAC+UxiHr9b6dp49HiOmW0pVqTNqJON5Z19xUrnynvvv1+U k0iQ== 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=Wpp05FRL8CytLa1eDwoJsy+yzotmZ84Zaxmlc+Zn1K4=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=j8vzjJiRrFVW6sb4iyRXKWjiLIhyeFmYS3tfhxwcFtGnqxpztYo/QOmscoah9OonE1 uYiYyP6X/6zXqKWIChx+ZwTAcdEh7sXJxWTDw06xdb+Vmh0ZmPcCGfv1A/722XHf6w3Y wbOlGpRz3sBk1F4531kbkvQMR5dc06tq4q0GaiBov8YyOU8iN+znzlvmapSj2PgkOZKo B2g9os0kMXvBb0c6hlEkRw5xFvWtADz89CJSBDkNFVm0n9IKPRz1xDvd0ubT08Eu2BUK gjgI8H2DrMZWYy+LxWdBB3cmwDqcXVVsyG4Cz7jAD9WtlG7G8ExPfSLRwT55OTV7MEfd vgtw==; 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=HkQ5dvQf; 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 gt20-20020a170906f21400b00a3f11d50d9bsi1247335ejb.914.2024.02.25.03.45.25; Sun, 25 Feb 2024 03:45:25 -0800 (PST) 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=HkQ5dvQf; 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 111EA68AA09; Sun, 25 Feb 2024 13:45:06 +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 996A168C69F for ; Sun, 25 Feb 2024 13:44:57 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1708861497; bh=2tjRJyihc7W5JF/OzPOzcu0ZWz6cvY8nWNo6yY5f3aI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HkQ5dvQfJJ3k3ALMmaFMJZG/1RXQgMn+JxX1uOvYiGuelmOI9gFRIX8SyKgIioMW4 zhEvJms8jIH1uonEq465y5utvijZsWAe9A6hIxYCIjlVmJr4GWkgwkjJ8U6n9EQFXZ olj9Svj7KpI11EKa6n4mBl3NhD/PNXop77djf9r0= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 52E7942A98; Sun, 25 Feb 2024 12:44:57 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Sun, 25 Feb 2024 12:44:51 +0100 Message-ID: <20240225114451.27645-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240225114451.27645-1-ffmpeg@haasn.xyz> References: <20240225114451.27645-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: RXuH5Ag1sjUd 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 7debc4dedaa..f42dc77148f 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -727,6 +727,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; } @@ -818,6 +819,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; @@ -875,6 +877,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; } @@ -928,6 +936,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); @@ -976,6 +985,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 b6a0c08e488..f1d57b39f9a 100644 --- a/libavcodec/av1dec.h +++ b/libavcodec/av1dec.h @@ -30,6 +30,7 @@ #include "packet.h" #include "cbs.h" #include "cbs_av1.h" +#include "dovi_rpu.h" typedef struct AV1Frame { AVFrame *f; @@ -79,6 +80,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;