From patchwork Fri Feb 1 16:05:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitrij.Gresserman@loewe.de X-Patchwork-Id: 11944 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 C5EBD442061 for ; Fri, 1 Feb 2019 18:13:35 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DE839680807; Fri, 1 Feb 2019 18:05:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from krocs002.loewe.de (krocs002.loewe.de [195.243.0.124]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BDE176807A0 for ; Fri, 1 Feb 2019 18:05:06 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by krocs002.loewe.de (Postfix) with ESMTP id 43rhl41fmgz7xC6 for ; Fri, 1 Feb 2019 17:05:04 +0100 (CET) X-Virus-Scanned: amavisd-new at loewe.de Received: from krocs002.loewe.de ([127.0.0.1]) by localhost (krocs002.loewe.de [127.0.0.1]) (amavisd-new, port 2025) with ESMTP id 96mgTmcIzjOa for ; Fri, 1 Feb 2019 17:05:02 +0100 (CET) Received: from vmex10a.loewe.de (vmex10a.loewe.de [10.12.3.11]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by krocs002.loewe.de (Postfix) with ESMTPS id 43rhl23RBxz7tZy for ; Fri, 1 Feb 2019 17:05:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=loewe.de; s=krocs002; t=1549037102; bh=ojjr3p/BTyf+c8A/GAs7jnHlW43zbsYD+43YYqLGsOk=; h=From:To:Subject:Date; b=MQ5gQ8wwnpIrF2HTB555YnPY28spCLsK2EGdoqEKJRQiWY6l1l6zwilqUbaSlSmDC D96n8/jDDwFOScEWRvlAZPkf49GJJCYtJd+ilwE4z3gXsY5i6Ub8EKMqeddWoZlO6D nbkJdkGmL+TIACszZTUN1e9dQnc+834j/btDOEhY= Received: from CQEX10.loewe.de ([::1]) by VMEX10a.loewe.de ([::1]) with mapi id 14.03.0389.001; Fri, 1 Feb 2019 17:05:02 +0100 From: Gresserman Dmitrij To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: Access to the dolby vision decoder info Thread-Index: AdS5nelfF7HPk2/aSjO42TvJU8X+wg== Date: Fri, 1 Feb 2019 16:05:01 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [172.21.7.38] MIME-Version: 1.0 Subject: [FFmpeg-devel] Access to the dolby vision decoder info 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" Hello, i need access to the dolby vision decoder info. This includes the Dolby Vision Configuration Box and decoder configuration record (dvcC/dvvC). Also includes the DOVI Video Stream Descriptor. Here is my approach attached as a patch. Best regards [Ein einzigartiges Sounderlebnis mit Loewe und Mimi Defined™] ________________________________ Visit our website: https://www.loewe.tv/int [Facebook] [Instagram] [Pinterest] [YouTube] Loewe Technologies GmbH, Industriestraße 11, 96317 Kronach Tel. +49 9261 99-500 • Fax +49 9261 99-515 ccc@loewe.de • www.loewe.tv Executive Management: Dr. Ralf Vogt, Peter Nortmann • Registered Office: Kronach • Commercial Register: Amtsgericht Coburg HRB 5443 From 8193bc14390d7e36a768b0f19b99f8374e83b5f2 Mon Sep 17 00:00:00 2001 From: gressermdm Date: Thu, 31 Jan 2019 20:28:25 +0100 Subject: [PATCH 2/2] Access to the dolby vision decoder info --- libavcodec/avcodec.h | 9 +++++++ libavformat/dump.c | 39 +++++++++++++++++++++++++++++ libavformat/mov.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ libavformat/mpegts.c | 31 +++++++++++++++++++++++ 4 files changed, 148 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 81b30dc..f2f3d93 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1378,6 +1378,15 @@ enum AVPacketSideDataType { AV_PKT_DATA_REFERENCE_TRACK, /** + * This side data contains an unsigned integer byte stream of the + * DOVI Descriptor or Dolby Vision Configuration Box. + * In addition the type of the Descriptor/Box is also added as FourCC + * to the begin of the stream as 4 bytes. + * This information can be used to configure the decoder for Dolby Vision. + */ + AV_PKT_DOLBY_VISION_DECODER_INFO, + + /** * The number of side data types. * This is not part of the public API/ABI in the sense that it may * change when new side data types are added. diff --git a/libavformat/dump.c b/libavformat/dump.c index ef20070..974ccfb 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -398,6 +398,41 @@ static void dump_reference_track(void *ctx, AVPacketSideData *sd) av_log(ctx, AV_LOG_INFO, "%"PRIu32"", *track_id); } +static void dump_dolby_vision_decoder_info(void *ctx, AVStream *st, AVPacketSideData *sd) +{ + uint8_t *dolby_data; + + uint8_t dv_profile; + uint8_t dv_level; + uint8_t rpu_present_flag; + uint8_t el_presenet_flag; + uint8_t bl_present_flag; + + if (sd->size < 8){ + av_log(ctx, AV_LOG_INFO, "invalid data"); + return; + } + + dolby_data = sd->data; + if (!dolby_data) { + av_log(ctx, AV_LOG_INFO, "invalid data"); + return; + } + + av_log(ctx, AV_LOG_INFO, "(0x%"PRIx8"%"PRIx8"%"PRIx8"%"PRIx8") ", + dolby_data[0], dolby_data[1], dolby_data[2], dolby_data[3]); + dolby_data += 4; + + dv_profile = dolby_data[2] >> 1; + dv_level = ( dolby_data[2] << 7 ) + ( dolby_data[3] >> 3 ); + rpu_present_flag = dolby_data[3] & 4; + el_presenet_flag = dolby_data[3] & 2; + bl_present_flag = dolby_data[3] & 1; + + av_log(ctx, AV_LOG_INFO, "profile:%"PRIx8" level:%"PRIx8"%s%s%s", dv_profile, dv_level, + rpu_present_flag ? " rpu" : "", el_presenet_flag ? " el" : "", bl_present_flag ? " bl" : ""); +} + static void dump_sidedata(void *ctx, AVStream *st, const char *indent) { int i; @@ -461,6 +496,10 @@ static void dump_sidedata(void *ctx, AVStream *st, const char *indent) av_log(ctx, AV_LOG_INFO, "reference track: "); dump_reference_track(ctx, &sd); break; + case AV_PKT_DOLBY_VISION_DECODER_INFO: + av_log(ctx, AV_LOG_INFO, "dolby vision: "); + dump_dolby_vision_decoder_info(ctx, st, &sd); + break; default: av_log(ctx, AV_LOG_INFO, "unknown side data type %d (%d bytes)", sd.type, sd.size); diff --git a/libavformat/mov.c b/libavformat/mov.c index 922776e..057968f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6669,6 +6669,8 @@ static int mov_read_vdep(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR(ENOMEM); *track_id = (uint32_t)avio_rb32(pb); + if (c->fc->nb_streams < 1) + return AVERROR_INVALIDDATA; st = c->fc->streams[c->fc->nb_streams-1]; ret = av_stream_add_side_data(st, AV_PKT_DATA_REFERENCE_TRACK, (uint8_t *)track_id, sizeof(uint32_t)); @@ -6680,6 +6682,71 @@ static int mov_read_vdep(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static uint8_t *mov_read_dv_config(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + uint8_t *dolby_data; + AVStream *st; + size_t size_total; + int ret; + + if (c->fc->nb_streams < 1) + return NULL; + st = c->fc->streams[c->fc->nb_streams-1]; + + if (atom.size < 4) + return NULL; + + size_total = atom.size + 4; + + dolby_data = av_mallocz(size_total); + if (!dolby_data) + return NULL; + avio_read(pb, dolby_data+4, atom.size); + + ret = av_stream_add_side_data(st, AV_PKT_DOLBY_VISION_DECODER_INFO, + (uint8_t *)dolby_data, size_total); + if (ret < 0) { + av_free(dolby_data); + return NULL; + } + + return dolby_data; +} + +static int mov_read_dvcC(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + uint8_t *dolby_data; + dolby_data = mov_read_dv_config(c, pb, atom); + + if (dolby_data) { + dolby_data[0] = 'd'; + dolby_data[1] = 'v'; + dolby_data[2] = 'c'; + dolby_data[3] = 'C'; + } else { + return AVERROR_INVALIDDATA; + } + + return 0; +} + +static int mov_read_dvvC(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + uint8_t *dolby_data; + dolby_data = mov_read_dv_config(c, pb, atom); + + if (dolby_data) { + dolby_data[0] = 'd'; + dolby_data[1] = 'v'; + dolby_data[2] = 'v'; + dolby_data[3] = 'C'; + } else { + return AVERROR_INVALIDDATA; + } + + return 0; +} + static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('A','C','L','R'), mov_read_aclr }, { MKTAG('A','P','R','G'), mov_read_avid }, @@ -6774,6 +6841,8 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('m','d','c','v'), mov_read_mdcv }, { MKTAG('c','l','l','i'), mov_read_clli }, { MKTAG('v','d','e','p'), mov_read_vdep }, +{ MKTAG('d','v','c','C'), mov_read_dvcC }, +{ MKTAG('d','v','v','C'), mov_read_dvvC }, { 0, NULL } }; diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index edf6b57..af6ae5e 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2002,6 +2002,37 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type } } break; + case 0xb0: /* dovi descriptor */ + { + uint8_t *dolby_data; + size_t size_total; + int ret; + + if (desc_len < 4) + return AVERROR_INVALIDDATA; + size_total = desc_len + 4; + + dolby_data = av_mallocz(size_total); + if (!dolby_data) + return AVERROR(ENOMEM); + + dolby_data[0] = 'D'; + dolby_data[1] = 'O'; + dolby_data[2] = 'V'; + dolby_data[3] = 'I'; + + for ( int i = 4; i < size_total; i++ ) { + dolby_data[i] = get8(pp, desc_end); + } + + ret = av_stream_add_side_data(st, AV_PKT_DOLBY_VISION_DECODER_INFO, + (uint8_t *)dolby_data, size_total); + if (ret < 0) { + av_free(dolby_data); + return ret; + } + } + break; default: break; } -- 2.7.4