From patchwork Thu Dec 10 08:04:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunzhenliang X-Patchwork-Id: 24468 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 0CFE2449DFD for ; Thu, 10 Dec 2020 10:09:13 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E4BE868A62A; Thu, 10 Dec 2020 10:09:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from APC01-PU1-obe.outbound.protection.outlook.com (mail-oln040092254082.outbound.protection.outlook.com [40.92.254.82]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3DDF4689BDC for ; Thu, 10 Dec 2020 10:09:06 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M8x2bKu0lZa39YglPcZ9KOlij//jbk1fH8J0NVk5oOImw7fyOn8Dd+KUn/bUP4X/z5l+ny9KQmBT+cBraprAEm0GDyCzaIh+jxU+V5Dijryu0hMx6v36bndiE/+SABZJd+Tg6ew92P5hK4oVrMNlZWPGfJMAecBJKOIqqd7M7JFSHnvJ6rTZ9cVhExQqF4LWlgUeI4ykABXUWsc0rmLRin3WHTglQ+DBpfNxB/e8WQ/N5KfbrZFJmBsxgJb6F5RyJilQJNdUUXyeAxi0S6/Tpudew8PfghbnfzAtwBeQX7IUud8AcUib+bHpwqWMEftyknHDPQ3dpN49a436B753oQ== 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=Pn875Rxo7m0rsi0YZaXNEowZ/jDvV2NnRT1L2rmknAw=; b=jMg6ACR3AHhD8+qT21BPFcpVbJ8QWtUIG132TthGACafICg9s8L0WRV19Uvyl3JatuXiUZo5ISIf/9pWC7AU++9Vyf2cS0+QFChGDmVQuxIXWhzwWgAHIjHeR3E8qCBD0DleoBafQC7QXEngQ8njyUXqpC34JuJ5I5Ianx7HTUdOQd2yQjo763t9IMGWBGorGmpgtO1o9VlMrFIxITtcextSbIA4isNM9eWTAjsbzmxJwF5m+6cqANduXuKYTkssCtQwdOC5jCPeRLXBesCkvNTL+LPWhePrrJisU9RoiyDzpaVD0MGrzMlt/9KJu9GyKxDyTqbVFwdJEkkp2xWTWw== 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=Pn875Rxo7m0rsi0YZaXNEowZ/jDvV2NnRT1L2rmknAw=; b=R1C1Ek2EpG4A9CPrkNBpK70nMO2BT4/Dj+JeFEp737EAlwIUCroEtWKoF584evj9BVYcfenDOzpBq/n9x09qiwUu/mdalrK0FbIkdjyqPy3C7X16v8joGxCgJj4ziuYah7F4tG3Jc10eu/Z5RggKb1rufTfCsjeyyZDp6zpOhp1tkLmu/rBayJHWylQ+8YfHKngombaoxSfBE3f4AxoAZOAScbqts/cNzjogyATda/W43E3/qCdlSueBlbZUwnL7G/KwG795KHFLD6GBN2+U7XW7N8BJoRrI3aVHGgIx0fj0LtyF2qVNP5wloUa8pF5PDaep9nkqfwZAvNtGaxDvuA== Received: from SG2APC01FT034.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebd::53) by SG2APC01HT019.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebd::314) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12; Thu, 10 Dec 2020 08:09:02 +0000 Received: from SL2PR06MB3052.apcprd06.prod.outlook.com (2a01:111:e400:7ebd::47) by SG2APC01FT034.mail.protection.outlook.com (2a01:111:e400:7ebd::204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Thu, 10 Dec 2020 08:09:01 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:3E81E8E961D20F30F2396BB379978E46E54DB5FE157F52F19ABA9B90E54160AB; UpperCasedChecksum:EC79A999E77DF3F71E42D0CE3BB52FEDB0891DA1A0C3CE192DE4BED42C80FDA0; SizeAsReceived:7277; Count:45 Received: from SL2PR06MB3052.apcprd06.prod.outlook.com ([fe80::e017:3126:7767:7d17]) by SL2PR06MB3052.apcprd06.prod.outlook.com ([fe80::e017:3126:7767:7d17%7]) with mapi id 15.20.3654.013; Thu, 10 Dec 2020 08:09:01 +0000 From: hisunzhenliang@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Dec 2020 16:04:45 +0800 Message-ID: X-Mailer: git-send-email 2.20.1 X-TMN: [omppytFDyvaoofGb0om6V0zGzI2rteBq] X-ClientProxiedBy: HK2PR04CA0086.apcprd04.prod.outlook.com (2603:1096:202:15::30) To SL2PR06MB3052.apcprd06.prod.outlook.com (2603:1096:100:2f::19) X-Microsoft-Original-Message-ID: <20201210080445.20245-1-hisunzhenliang@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sun-PC.o.bj.ebupt.net (223.70.157.162) by HK2PR04CA0086.apcprd04.prod.outlook.com (2603:1096:202:15::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Thu, 10 Dec 2020 08:09:01 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 45 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 3557d175-06b0-4823-1ff5-08d89ce2dabb X-MS-Exchange-SLBlob-MailProps: uIjBWfsAVx+P3zeSryL/mJKImhKcUnEsYCSV7nN9mNnsjj2SSeO5+j9mbBJE5rfHWkyLg9eR/potftUnpOgtO7hLVyck6i95hg3QPLcCTuuX0U1k/1soebVXWhBQjeBG1k5PWWIBiIaPPlguQfcr7YUuW5GeDBhG17zmXTSQH/t7KI4VW0NR789MJMwinl4GHfODSL9mijFblxLWR4gNEtYmTx8U7mb0i3fD5QT1xpq0XhRpMNG6T4p/syYxZl1K+k65Q2KTJ4r+t838omndFOUrAy1nhUB9eaC0UR6GqGNHgfINousiWMOFTfVxN0Et/79lvfTnrVijImd7RtDDg48tg4prZTzijXSi9GMGymyjBvc1SkE5xxp5il19+fwoidHuKnxxL2RgX5ZS8di1CqdeIBv26K6OQiim6INEI3Lu9UJdIWuSqlooecFSkska+y0hS1llvkaaoSQoa0vhReS1hqdOORLtTnKEFzYOV4ifU+q/OxaTW0HympDLTG5ZKhoSkQnFRB87vQ7i/gFgFWfc3T1SmSJnOEkQlGqERzc4wQOJLvVlH4l2D61K0xYjihLVFDXOMzZxtkDz6liIEvetlnypJPEwN0qY4oypXo5z8WuHuxXj/lNMIA5Sjnswlae/aejjan8RE6vHZZtxgelVyw4XJGe5g7wWQlW+7oct6asRkzA4WzRA0vZHmN//ctDLvLWm+QYNYapQOEAdAA== X-MS-TrafficTypeDiagnostic: SG2APC01HT019: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0TVtUVJf0bmR7jO5jDw343jAf6CVpnZfWvMWvevQkkKJHLzxwdNlDjmd5YTflG6bqLTMLoW59jTxFv/uCPuLOWnDQk475JuSz7SzBxiNh7WoKOf8yUfq4LqgJgZR2frueRywlyw/fcJNzAdR6cmdT8I5RlL2o4jr11U1pPi6QTXGt50/MrzLGBbPXpHCpwZFptK8mk3mg5in88u+m49Bzw== X-MS-Exchange-AntiSpam-MessageData: o+WOabfA2qWZKJfK67k7TuwcdKYoAdFrA3qPsNSgg4tsaXn9O33GUA8NTu0b5kP2X6UR6tkvvNslWUD+W7WCWWywFndd4Ti5YvAb+Sn6iSR26k5NU5+mPmTlXr7iJ3TaMKAsipJm73yl+xUUbgq1Zg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2020 08:09:01.8044 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 3557d175-06b0-4823-1ff5-08d89ce2dabb X-MS-Exchange-CrossTenant-AuthSource: SG2APC01FT034.eop-APC01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2APC01HT019 Subject: [FFmpeg-devel] [PATCH] libavformat/movenc: add support for HEVC in .3gp 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: hisunzhenliang@outlook.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: SunZhenliang Just add HEVC's tag in 3gp tag list and it works to support HEVC in 3gp files. Signed-off-by: SunZhenliang --- libavformat/movenc.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 18fa3f9b5e..2dd8c8789d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4923,7 +4923,7 @@ static int mov_write_mdat_tag(AVIOContext *pb, MOVMuxContext *mov) } static void mov_write_ftyp_tag_internal(AVIOContext *pb, AVFormatContext *s, - int has_h264, int has_video, int write_minor) + int has_h26_, int has_video, int write_minor) { MOVMuxContext *mov = s->priv_data; int minor = 0x200; @@ -4931,11 +4931,11 @@ static void mov_write_ftyp_tag_internal(AVIOContext *pb, AVFormatContext *s, if (mov->major_brand && strlen(mov->major_brand) >= 4) ffio_wfourcc(pb, mov->major_brand); else if (mov->mode == MODE_3GP) { - ffio_wfourcc(pb, has_h264 ? "3gp6" : "3gp4"); - minor = has_h264 ? 0x100 : 0x200; + ffio_wfourcc(pb, has_h26_ ? "3gp6" : "3gp4"); + minor = has_h26_ ? 0x100 : 0x200; } else if (mov->mode & MODE_3G2) { - ffio_wfourcc(pb, has_h264 ? "3g2b" : "3g2a"); - minor = has_h264 ? 0x20000 : 0x10000; + ffio_wfourcc(pb, has_h26_ ? "3g2b" : "3g2a"); + minor = has_h26_ ? 0x20000 : 0x10000; } else if (mov->mode == MODE_PSP) ffio_wfourcc(pb, "MSNV"); else if (mov->mode == MODE_MP4 && mov->flags & FF_MOV_FLAG_FRAGMENT && @@ -4964,7 +4964,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) { MOVMuxContext *mov = s->priv_data; int64_t pos = avio_tell(pb); - int has_h264 = 0, has_av1 = 0, has_video = 0; + int has_h264 = 0, has_h265 = 0, has_av1 = 0, has_video = 0; int i; for (i = 0; i < s->nb_streams; i++) { @@ -4975,6 +4975,8 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) has_video = 1; if (st->codecpar->codec_id == AV_CODEC_ID_H264) has_h264 = 1; + if (st->codecpar->codec_id == AV_CODEC_ID_H265) + has_h265 = 1; if (st->codecpar->codec_id == AV_CODEC_ID_AV1) has_av1 = 1; } @@ -4983,9 +4985,9 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) ffio_wfourcc(pb, "ftyp"); // Write major brand - mov_write_ftyp_tag_internal(pb, s, has_h264, has_video, 1); + mov_write_ftyp_tag_internal(pb, s, has_h264 || has_h265 , has_video, 1); // Write the major brand as the first compatible brand as well - mov_write_ftyp_tag_internal(pb, s, has_h264, has_video, 0); + mov_write_ftyp_tag_internal(pb, s, has_h264 || has_h265, has_video, 0); // Write compatible brands, ensuring that we don't write the major brand as a // compatible brand a second time. @@ -5018,6 +5020,8 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) ffio_wfourcc(pb, "iso2"); if (has_h264) ffio_wfourcc(pb, "avc1"); + if (has_h265) + ffio_wfourcc(pb, "hev1"); } } @@ -7103,6 +7107,7 @@ static int mov_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt) static const AVCodecTag codec_3gp_tags[] = { { AV_CODEC_ID_H263, MKTAG('s','2','6','3') }, { AV_CODEC_ID_H264, MKTAG('a','v','c','1') }, + { AV_CODEC_ID_HEVC, MKTAG('h','e','v','1') }, { AV_CODEC_ID_MPEG4, MKTAG('m','p','4','v') }, { AV_CODEC_ID_AAC, MKTAG('m','p','4','a') }, { AV_CODEC_ID_AMR_NB, MKTAG('s','a','m','r') },