From patchwork Wed Aug 31 11:35:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: erkki.seppala.ext@nokia.com X-Patchwork-Id: 367 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp328633vsd; Wed, 31 Aug 2016 04:38:56 -0700 (PDT) X-Received: by 10.194.156.195 with SMTP id wg3mr8547559wjb.152.1472643535903; Wed, 31 Aug 2016 04:38:55 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x8si23294526wme.6.2016.08.31.04.38.52; Wed, 31 Aug 2016 04:38:55 -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=@nokia.onmicrosoft.com; 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; dmarc=fail (p=NONE dis=NONE) header.from=nokia.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 61798689B3A; Wed, 31 Aug 2016 14:36:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0135.outbound.protection.outlook.com [104.47.2.135]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 77B63680D07 for ; Wed, 31 Aug 2016 14:36:10 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=AWPz0vzQ4qRPso/NPPk+DF3CebgIGl+zdmkTM033h8k=; b=iPeBBOYxs4pKJBbOecAfY3n7qZ5UlwmyGnckGC5W13Sljx9kba3WTgJww0T3c04Z88/m/grpEgA8dObJWhy3yPz978ds0YO3LhbGUgyKfRHfWjprBzoQECccWhC0Hg9bOkfrYOiHjUoQQXs7hGJ1s3YTbjMdNmWQKg9fAsK0Ze8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=erkki.seppala.ext@nokia.com; Received: from erkkise-laptop.vincit.intranet (131.228.2.27) by HE1PR0701MB2540.eurprd07.prod.outlook.com (10.168.129.18) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.599.9; Wed, 31 Aug 2016 11:36:14 +0000 Received: by erkkise-laptop.vincit.intranet (Postfix, from userid 1000) id EDF6C4CB958; Wed, 31 Aug 2016 14:36:01 +0300 (EEST) From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= To: Date: Wed, 31 Aug 2016 14:35:56 +0300 Message-ID: <1472643361-10118-14-git-send-email-erkki.seppala.ext@nokia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472643361-10118-1-git-send-email-erkki.seppala.ext@nokia.com> References: <1471943019-14136-1-git-send-email-erkki.seppala.ext@nokia.com> MIME-Version: 1.0 X-Originating-IP: [131.228.2.27] X-ClientProxiedBy: AMSPR04CA0024.eurprd04.prod.outlook.com (10.242.87.142) To HE1PR0701MB2540.eurprd07.prod.outlook.com (10.168.129.18) X-MS-Office365-Filtering-Correlation-Id: 590228f2-9bbd-4be4-b37b-08d3d19303fd X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2540; 2:wvt/6YZGTtHU8PMXsajVgF1EX1Y5PdNs9FEqlW/R/7k+BSKhz7mc5y1YZcD1qOMA6grxi2cESV1lhht1icAigDhnczmqEQAPx4/ggnVCsdmP3A3zjsPgewgsR9tB7ZXmWPcq3GarWj9Da3U5McpEWyE8snqvSS6gJLqRIz6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cd8XT4+7moS8WHIesQIpXOxFXuCP+c1T3EGyiJmeytRdRVAZf68WhyyBzCnvDlZyqYlDpvJxGheXelvf5grXejQqnUKTxf92p9aGDtoM0ABzw0gnuHJgeXmFzTn2oIGXVoJrWgZEmD+OfmNP4x0v+BfyI5XbsdIYnIpsOGvpXzO+0EaYqxfF+m6KAXPWxzWZwdY14sMrY5OzQ72K9ItvJ7Dnc7XVGU2KAbPFfpLR16gVBQG0ABFBkmRnYrM/avWKN6z4cw87yrUY81AUQXTAfva7FjeIP1HXUvydnD2/8jh0WUI2pBe1iPQQ5SIaiKoWqz/ouGEGVNZE0Vzbchob0GKwF5S+ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(82608151540597); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:HE1PR0701MB2540; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0701MB2540; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2540; 4:ErxC63Tr7RkYf198VOxyQjCpKajkSm3B6nGbwW0xWAU6MZEynQCzo9QprAm69ir8pIM/n/E55aex3C9bMTGYpvGP5i9V5GLL7tNoI0o6YdKbiGtLwWFraygvDgHMz+i+rgqYeD9CuIDUXmpBe17XQYP5/nSBwPGmRJ0CTJauEJl+5Awz3uLwwoGVUq1CtUeJeZO2+EfiJXpd4UQqzBDILqx0gULa3K0MjmD+7AqLBogp4nLL/x2BpbiI7a93hMf7KS3CAG1HV238nwhvLGwHPufbgH6368DbH/0ZXpspOMTucBgHzyT+7186tZ+0URlEf+B954pn4Lsd2iU/ygoGtypQszbz3yeGLxSu2advjmmbYQ6effIxpuHi8d9HXhLbnSpmXTzdUF3tXbXok66uudrl3p5NpOy/BY3b/n9H4KWww+W6kqg1ppzXmGP2h55NHceRi9cDk9sqP7RiC0xEgA== X-Forefront-PRVS: 00514A2FE6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(101416001)(50226002)(305945005)(6116002)(7736002)(7846002)(586003)(3846002)(229853001)(50986999)(76176999)(68736007)(42186005)(2351001)(5820100001)(50466002)(8676002)(81156014)(81166006)(52956003)(86362001)(122856001)(45336002)(46386002)(19580405001)(92566002)(2950100001)(5660300001)(97736004)(107886002)(2906002)(2870700001)(90966002)(189998001)(105586002)(4001430100002)(66066001)(33646002)(47776003)(450100001)(110136002)(106356001)(36756003)(4326007)(23676002)(19580395003); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0701MB2540; H:erkkise-laptop.vincit.intranet; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nokia.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA3MDFNQjI1NDA7MjM6bGdBeWJhRFViUEtXUEo5ZzdJRUEwUS9i?= =?utf-8?B?NElKbEFTWENqRnRCRkpoTE1NTEFNd0dpYnBDampuSXpiVkNIcEY3dkpSNDI5?= =?utf-8?B?NEhueXJVQWF3NEhWS3pVbGNPdGlkRDBmNVB1a0FhOFEwQzNyTFZrdTJiaTV1?= =?utf-8?B?aGlBRzYrWFdINGxaMTlXYWVmTWV2ekpZUkM2Qm45cTJsanNvQXplWS9FcHBW?= =?utf-8?B?TitxRTRzaHFrUjhWWHhGTTN3bitvdUwwRy9KWFY3WUIrWjJocWw4VDVwOERW?= =?utf-8?B?dUhaVkZVOWdabWpGOUZUNllPTEQ3YW1md2JvQlNRbHhPbmZRK25UT2dIYytz?= =?utf-8?B?QklrU3dOWWI0Vmd0N0NRMVhNUnlxRTJUaWd0RFNlOGZmQnZlNjVWb1Z5bXFa?= =?utf-8?B?Qnc3cjdzWmYvZGZWZ0RjaWE2TFlodEE2SVpIN01DSS9EZGwvMFVvekRjcFZM?= =?utf-8?B?b3Q2Q3dtWm13QWJxTkczeFR4TFBuOGV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ymnKtrYyY3L5QmzNS20Z3k3+J0+nMTuZ/hzL+1VQrF43jnt0Mjc2WpxOgCeAyEajMrKjHnt0NYvDESbXFzmsil4y5RDK8aepw3WqqdSJPaglsD/Jie/dLyZbQNMh3xqIZiComvcTFoQ1bMf3GzXCWlhhFySShcX5SDJGYS/Ax0hxS/1QXwwechJ/vHBnqLV3aMgWr/o/Q13lF4/5QEXD7/NrlZfsV8Zw1oJ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2016 11:36:14.6067 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0701MB2540 Subject: [FFmpeg-devel] [PATCH v2 13/18] avformat/mov: read urim metadata from meta 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 Cc: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= , OZOPlayer Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The data is read into side packet AV_PKT_DATA_TIMED_METADATA_INFO of format AVTimedMetadata. Signed-off-by: Erkki Seppälä Signed-off-by: OZOPlayer --- libavformat/mov.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 0544d13..a353a35 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2039,6 +2039,145 @@ static int mov_rewrite_dvd_sub_extradata(AVStream *st) return 0; } +static int mov_parse_urim_uri_data(AVIOContext *pb, AVStream *st, MOVMeta *meta) +{ + int64_t size = avio_rb32(pb); + uint32_t uri = avio_rb32(pb); /* "uri " */ + avio_r8(pb); /* version */ + avio_rb24(pb); /* flags */ + + if (size < 12 || size >= 1024) + return AVERROR(ENOMEM); + + if (uri == AV_RB32("uri ")) { + int remaining = size - 12; + int64_t pos = avio_tell(pb); + uint32_t string_len = 0; + + while (string_len < remaining && avio_r8(pb) != 0) { + ++string_len; + } + avio_seek(pb, pos, SEEK_SET); + + if (string_len >= remaining) + return AVERROR_INVALIDDATA; + + meta->tag = MKTAG('u', 'r', 'i', 'm'); + meta->data = av_malloc(string_len + 1); + if (!meta->data) + return AVERROR(ENOMEM); + + avio_read(pb, meta->data, string_len); + ((char*) meta->data)[string_len] = 0; + meta->length = string_len; + remaining -= string_len; + avio_r8(pb); /* read the null terminator */ + remaining--; + + avio_skip(pb, remaining); + } else { + avio_skip(pb, size - 12); + } + + return 0; +} + +static int mov_parse_urim_conf_data(AVIOContext *pb, AVStream *st, int64_t remaining, MOVMeta *meta) +{ + int64_t size; + uint32_t tag; + int64_t data_size; + + if (remaining < 12) + return 0; + + size = avio_rb32(pb); + tag = avio_rl32(pb); + avio_r8(pb); /* version */ + avio_rb24(pb); /* flags */ + remaining -= 12; + data_size = size - 12; + + if (data_size < 0 || data_size > remaining) { + avio_skip(pb, remaining); + return 0; + } + + meta->conf.data = av_malloc(data_size); + if (!meta->conf.data) + return AVERROR(ENOMEM); + + meta->conf.tag = tag; + meta->conf.length = data_size; + avio_read(pb, meta->conf.data, data_size); + remaining -= data_size; + avio_skip(pb, remaining); + + return 0; +} + +static int mov_parse_urim_data(AVIOContext *pb, AVStream *st, int64_t remaining) +{ + int64_t pos = avio_tell(pb); + int ret; + MOVMeta meta; + + memset(&meta, 0, sizeof(meta)); + + ret = mov_parse_urim_uri_data(pb, st, &meta); + if (ret) + return ret; + + remaining -= avio_tell(pb) - pos; + ret = mov_parse_urim_conf_data(pb, st, remaining, &meta); + + // all data has been collected; now build the actual side channel + // object from the collected data + if (ret == 0) { + int tmdLength = sizeof(AVTimedMetadataInfo) + meta.length + meta.conf.length; + AVTimedMetadataInfo *tmd = av_malloc(tmdLength); + if (!tmd) { + ret = -1; + } else { + AVPacketSideData *sd; + ret = av_reallocp_array(&st->side_data, + st->nb_side_data + 1, sizeof(*sd)); + if (ret >= 0) { + char* data; + + sd = st->side_data + st->nb_side_data; + st->nb_side_data++; + + sd->type = AV_PKT_DATA_TIMED_METADATA_INFO; + sd->size = sizeof(*tmd) + meta.length + meta.conf.length; + sd->data = (uint8_t*) tmd; + + tmd->meta_tag[0] = (meta.tag >> 0) & 0xff; + tmd->meta_tag[1] = (meta.tag >> 8) & 0xff; + tmd->meta_tag[2] = (meta.tag >> 16) & 0xff; + tmd->meta_tag[3] = (meta.tag >> 24) & 0xff; + tmd->meta_length = meta.length; + tmd->conf_tag[0] = (meta.conf.tag >> 0) & 0xff; + tmd->conf_tag[1] = (meta.conf.tag >> 8) & 0xff; + tmd->conf_tag[2] = (meta.conf.tag >> 16) & 0xff; + tmd->conf_tag[3] = (meta.conf.tag >> 24) & 0xff; + tmd->conf_length = meta.conf.length; + data = (char*) (tmd + 1); + + memcpy(data, meta.data, meta.length); + data += meta.length; + memcpy(data, meta.conf.data, meta.conf.length); + } else { + av_freep(&tmd); + } + } + } + av_freep(&meta.data); + av_freep(&meta.conf.data); + + return ret; +} + static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int64_t size) @@ -2098,6 +2237,8 @@ FF_ENABLE_DEPRECATION_WARNINGS } } } + } else if (st->codecpar->codec_tag == MKTAG('u', 'r', 'i', 'm')) { + ret = mov_parse_urim_data(pb, st, size); } else { /* other codec type, just skip (rtp, mp4s ...) */ avio_skip(pb, size);