From patchwork Thu Jan 9 10:09:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Praveen Kumar X-Patchwork-Id: 17272 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a05:6214:1865:0:0:0:0 with SMTP id eh5csp371817qvb; Thu, 9 Jan 2020 02:09:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwfWoBJGZ96qxme1fXBXrIkCtHPFn9oJH8ol8Il4RZMn3Hd+b1Yh15fry2Qjsztl0ARgohV X-Received: by 2002:a17:906:b88c:: with SMTP id hb12mr9396559ejb.150.1578564590629; Thu, 09 Jan 2020 02:09:50 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h8si4137297edr.138.2020.01.09.02.09.49; Thu, 09 Jan 2020 02:09:50 -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=@outlook.com header.s=selector1 header.b=FFYQNdE+; arc=fail (body hash mismatch); 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 sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 594E46880B2; Thu, 9 Jan 2020 12:09:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from APC01-HK2-obe.outbound.protection.outlook.com (mail-oln040092255077.outbound.protection.outlook.com [40.92.255.77]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA0856880B2 for ; Thu, 9 Jan 2020 12:09:38 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AUEMNEW6/cceVMhvvzoIhYTBLYfAsBi0/5G1FdHG/0QeWaqxsvimOdWcbr6SvhAHNsrHnTZ3VW5FAhVCKb2tSvXEzfZ6qEwyrvQEFaXkJRJ/MtXhU9INc3VBdVHEgK7/g/N/k3/8WVyzwrM5GqxMd9pD6KwR9hO6Jb5nVlfrPTRniApTSYD/QHCHCNGKgj8ZcSdmspIQkl/Quf5xkTkuc/TaBtIC3CL49lpEYgZg4KDUTUX7r7Y/M6FJrVRdWZvqmr6bPVO79rXrJL3HezGj1Ippok1UIvuC64b+0EQAQ560ceFl2BuUlX6tHsqURckJJHvVsIsjUPwgLCY6Pz5b/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+bCbht+eAUNLoFIplrx7qaG8WviWgVhQdWcUiiZqOn0=; b=V9f+0GCa0kA0BrzCerNAPB2Bce0P4mzmLi1nq1mfbzzzPgJu38/4G81TIIs46ZAoCGcAAfp7JmAfSA6mhfBVFyjDxk3fWEVLKvK7WiQXGwaJpzm4nff9vL8bSlbhI7LGVHirjjqVCUvNknXm5Ovn7L+X30OC9U5BPVobvU9/y40TgCaDqAi5le713L+K+mnaDRF14hoLdQgKGzY/1kACBzj8d+RZTd7bgEMBDh8vGZKdcHBq24LhRi1ydukG2p2WqDHdMG8Lrq+f3wAQHzAamhlBLTPTH0wQgOpClCsHA97VvuufQ7LBw/Ixn9DOxK9XikPFk3edL1Uktojl9h5Ofg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+bCbht+eAUNLoFIplrx7qaG8WviWgVhQdWcUiiZqOn0=; b=FFYQNdE+To73QqabP6L70ond37bpgowtPqIADCGuBpdXkgdaW5F0cSxFosd8LNpT7mKjMac+68goAM4Q7OQlOEYQ9zQnPVRvkUez43Z060ZWkX713QqHoLwrcBFVgHVYaUlfdkhbdez1itqNcHmTPLqZuVOP0Gcfx+JeMco2RlXcyFCxA1PIpAtU7B5qN+pC+4mlYpuP/Xu7EVY7Tc1b1MY1RPbNmYwfi/KlEcaPbnG04B1hivz8EkLj/QQ8kFDVqMpPau6fyvtYLQvB++4yocnsCXhd5C5EqeUQSasHklrgcH6QrcogUY65DDbRi/w7l27/lEsnVu+yfzmR0d4uCQ== Received: from PU1APC01FT021.eop-APC01.prod.protection.outlook.com (10.152.252.54) by PU1APC01HT040.eop-APC01.prod.protection.outlook.com (10.152.253.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11; Thu, 9 Jan 2020 10:09:34 +0000 Received: from MA1PR01MB3865.INDPRD01.PROD.OUTLOOK.COM (10.152.252.54) by PU1APC01FT021.mail.protection.outlook.com (10.152.252.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11 via Frontend Transport; Thu, 9 Jan 2020 10:09:34 +0000 Received: from MA1PR01MB3865.INDPRD01.PROD.OUTLOOK.COM ([fe80::40e8:608d:fe6b:4838]) by MA1PR01MB3865.INDPRD01.PROD.OUTLOOK.COM ([fe80::40e8:608d:fe6b:4838%5]) with mapi id 15.20.2623.008; Thu, 9 Jan 2020 10:09:34 +0000 From: Praveen Kumar To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH] Support for Frame Duplication (Doubling/Tripling) by FFMPEG's HEVC Decoder by parsing the picture_struct SEI value(Requirement:http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html) Thread-Index: AQHVxtQnxktzSGq2IkKiWFfIUQ08lA== Date: Thu, 9 Jan 2020 10:09:34 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:868BA0AC6F4C5C703F6C6B51413FE081859E1FA5934D6F8040D10CD6D402A98D; UpperCasedChecksum:AECA84B4AE1670FBE13395549ADE6071AAF0D482165B58935DF27DEA9F28140C; SizeAsReceived:7238; Count:42 x-tmn: [K/oojEdI+j8i63RrwIRBAQ+NlJmFkzisd6K+2oty1JgGKLtn0eXc4RWAG2Djc/K0] x-ms-publictraffictype: Email x-incomingheadercount: 42 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: bab363af-5988-45fd-5ee5-08d794ec06c9 x-ms-traffictypediagnostic: PU1APC01HT040: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: p3a52iJZx6vnRJx9B6UC1OR+5eXPsjzCruI5P7RsPNakWlo5ORM3xGaxLvumFIeNQxVHUHBka1PI5XhCrYEuiA6ysSy+bAZ4XN7YLlbF/jYHQUBtC8w+PufgOGHebxWbGRGqRciFx3nDDwqBcYcWgsfpz+lpn+LifebfHwILGtp2OJJ0494T8FKZG3YzJ0cCbQXC4iZpPa1FUgMrE1zRNjjJkbY2B7mwFCmMARWP2vo= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: bab363af-5988-45fd-5ee5-08d794ec06c9 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jan 2020 10:09:34.1988 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1APC01HT040 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] Support for Frame Duplication (Doubling/Tripling) by FFMPEG's HEVC Decoder by parsing the picture_struct SEI value(Requirement:http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html) 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" X-TUID: fCGOEIJPbDOm Content-Length: 5782 Hi, Re-sending the patch after incorporating the review comments over the previous patch sent yesterday. This patch has the implementation for supporting frame duplication (doubling/ tripling) by FFmpeg's HEVC decoder based on the picture_structre SEI value present in the encoded video. picture_structure value of 7 implies doubling and 8 implies tripling. The value of picture_structure is set while encoding. This addresses the requirement mentioned in the thread http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html Thanks & Regards, Praveen From a118cb7b050a29ef6ca6724e44d82c8c519e9a05 Mon Sep 17 00:00:00 2001 From: Praveen Karadugattu Date: Thu, 9 Jan 2020 15:23:41 +0530 Subject: [PATCH] Support for Frame Duplication (Doubling/Tripling) by FFMPEG's HEVC Decoder by parsing the picture_struct SEI value(Requirement:http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html) --- libavcodec/hevc_parser.c | 8 ++++++++ libavcodec/hevc_sei.c | 6 ++++++ libavcodec/hevc_sei.h | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c index b444b99..ebb683d 100644 --- a/libavcodec/hevc_parser.c +++ b/libavcodec/hevc_parser.c @@ -30,6 +30,7 @@ #include "h2645_parse.h" #include "internal.h" #include "parser.h" +#include "mpegutils.h" #define START_CODE 0x000001 ///< start_code_prefix_one_3bytes @@ -232,6 +233,13 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, case HEVC_NAL_RADL_R: case HEVC_NAL_RASL_N: case HEVC_NAL_RASL_R: + if (ctx->sei.picture_timing.picture_struct == HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING) { + avctx->ticks_per_frame = 2; + s->repeat_pict = 3; + } else if (ctx->sei.picture_timing.picture_struct == HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING) { + avctx->ticks_per_frame = 2; + s->repeat_pict = 5; + } ret = hevc_parse_slice_header(s, nal, avctx); if (ret) return ret; diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index 562ce8b..6057069 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -144,6 +144,12 @@ static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb, const HEVCPa } else if (pic_struct == 1 || pic_struct == 9 || pic_struct == 11) { av_log(logctx, AV_LOG_DEBUG, "TOP Field\n"); h->picture_struct = AV_PICTURE_STRUCTURE_TOP_FIELD; + } else if (pic_struct == 7) { + av_log(logctx, AV_LOG_DEBUG, "Frame/Field Doubling\n"); + h->picture_struct = HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING; + } else if (pic_struct == 8) { + av_log(logctx, AV_LOG_DEBUG, "Frame/Field Tripling\n"); + h->picture_struct = HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING; } get_bits(gb, 2); // source_scan_type get_bits(gb, 1); // duplicate_flag diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h index 2769d41..a44ccca 100644 --- a/libavcodec/hevc_sei.h +++ b/libavcodec/hevc_sei.h @@ -59,6 +59,11 @@ typedef enum { HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO = 165, } HEVC_SEI_Type; +typedef enum { + HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING = 7, + HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING = 8 +} HEVC_SEI_PicStructType; + typedef struct HEVCSEIPictureHash { uint8_t md5[3][16]; uint8_t is_md5;