From patchwork Fri Dec 11 10:56:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunzhenliang X-Patchwork-Id: 24542 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 D6D6B44B4CD for ; Fri, 11 Dec 2020 12:57:30 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AA2A568A8E2; Fri, 11 Dec 2020 12:57:30 +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-oln040092255091.outbound.protection.outlook.com [40.92.255.91]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A20BC68A76A for ; Fri, 11 Dec 2020 12:57:23 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FinahhorOKZ/CT4bqCxO2XlokLt5MoJXD0zbp+Jk/2GchieaFnEVicHyuWhDTSL/nk2Rst0m5MPLpQMdfWiHs36GDa2q4rkppWOFbdtqKQP2a+gh3ou82GMB+E0423NrnDZ5ytmPK8I3LnLqR372LcGAn4DvchlYcor2XJR8OhgNMoPvkIBgHlSIPvT8B5RuzaTYcjg+o1EnYavwFtoYk1vkRW90CtUKkKsVOPTuCP0LIDhrVh7yocJwL5Lmknk743emqVQnkcxY3YAZDL47JSCB0NPAJtKGbt2NMeFbtWVZJFVP4ETzSp3y1R+4dBor8G4JaQuNTrm8dJj2RFGw8A== 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=r9iFUKRtCTKMYxHnsaH+4tw6J6S+9RCw3XACst7SSQA=; b=kkuYKZW1fAP36FHr/9mmhFATHEbtpekcwL73rlQqa3r2t4yWdeD6qzc43Ewj190tBbGKCUKydpAvoxXTRhQDZs8/mSdImjU3lo7Vw0WdI2lBdZ61xs4ELSRCvFVNlcCAgw0tsNNhynlMW0qHET3jA+fAlE0RlgdSo0bDgbHa4O3AsPZDJ8DN0D3UhB/N1F/B6pcnppredTzEwVl8TsN+3BHzCuWY/jMJ6ajdbPz1qbtutwUETMYzyYavyWz7JFvkTaRnpc57BGr7SvJgUUVBBuIPak36g+PP6LALG75ZnKa0RAKkrLjoORI4POlB/sTmBql1tsSD6jknzV6k4yMBPA== 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=r9iFUKRtCTKMYxHnsaH+4tw6J6S+9RCw3XACst7SSQA=; b=fscp2SkdxsyT3xykteWg9MUqPMhbDh+ht90VTJzGGNvtGQddj4q40aYihePRS1p4avPbn2oCuQ75xSLfSXf87D0FFHhR9btXiRets9DQ1jRd9BDFa9ChE2kB/nkrNejkgNUm7tt7Tvi5QwRNvnHY2ujERTvqm13/nUaoOQ894Z42XzyZRmJFtGL1kHDbEHLRyxyULORIIodNV5Wypplqsqf5C36bwnOn2/MpRxyuIOSlSb/HmperJLjIg9ruTyp4KBEEt6+60HdeTr4Kde/9hAlnadmXHR193wu6q+YtJIFYCZqy4UUeco8GnlekSQjrDycgBJ4nlOuJe+GUGS36LA== Received: from HK2APC01FT033.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::41) by HK2APC01HT139.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::458) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12; Fri, 11 Dec 2020 10:57:20 +0000 Received: from TYAPR01MB4271.jpnprd01.prod.outlook.com (10.152.248.57) by HK2APC01FT033.mail.protection.outlook.com (10.152.248.190) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.18 via Frontend Transport; Fri, 11 Dec 2020 10:57:20 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:1F1F5B3B5EE4C95D08C1A76F9D51872C6EE78AC09C2C85625F7229F89E48975C; UpperCasedChecksum:AEC2D70EF7B10E82D4110F036B0FBCFAC1097B759F79C968873AF661B7701C5C; SizeAsReceived:7481; Count:47 Received: from TYAPR01MB4271.jpnprd01.prod.outlook.com ([fe80::911c:5157:bcab:d878]) by TYAPR01MB4271.jpnprd01.prod.outlook.com ([fe80::911c:5157:bcab:d878%5]) with mapi id 15.20.3654.014; Fri, 11 Dec 2020 10:57:20 +0000 From: hisunzhenliang@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Dec 2020 18:56:10 +0800 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: X-TMN: [ZXQ/hFqXqbPcE8AaGUVI6irHP3aFppq2] X-ClientProxiedBy: HK0PR01CA0066.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::30) To TYAPR01MB4271.jpnprd01.prod.outlook.com (2603:1096:404:c8::20) X-Microsoft-Original-Message-ID: <20201211105608.5251-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 HK0PR01CA0066.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::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; Fri, 11 Dec 2020 10:57:19 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 3300c77e-0967-4a0a-132b-08d89dc3882d X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UJIjRE5frp5NLRqmqPE/1nGh/8/6mWR9ltbL3ZQ9VvtmPGE7sziesWJbJNdqaoPFDZAE19nKsFprAvtDK2oaqvBFolgHu0+tMSv4JN0pDZhcHiE+leu+6KCJ7hl3JW4ZAwvd6c0BcrlSR8w679tzwqinICQQjweEQT0G/cAR1aHr4coflI5QrfD8te332udWk5JhCXtrlcxuh2/jUHR9/wnGeBE4V3Zjt/nFSnye78hi31JtyK+VPf9lXTXQLVdCESzz18AZl6/LfbEc05NrRILlsUfWk2NsVccYtcnRSXU5YmeMbmcViBMnQLjy2p6qzV080x4SgiVbT9wzBMw2nI8KyIdSN5p5cXtlxO0KwvqJeDBmsxHzfD1LII/wvt67mHjWniMynt/BjyeNqQzTvZFZneYGj991MYynimD9NF6g5AjLTCP9zoHHJqbDbNFJM4vYKnvt8B0T6vzLhLLERJZhBq+Ba+ud5MtUrrOjLzmkDZBgp2JXK79EC0PpuB7/hLYiMAyE+z1Y6BJg4bMP1xW0XmzrRAlbHWVcgJd9AUEqsBjYBQl3p9CL9blWbpCmIqmOJ130nj81KVSEGTI62Ut503JdC7a5IH/YL8Pp6YprqFqJbBihFXjeowkjItkSvU9cpFfTOTDlJlOgest4MRWuhPZKBfmx0R6JcDpAXRdE1Bx31PfCQ0KDGE+aOUeEluuQXuWx6kIVg== X-MS-TrafficTypeDiagnostic: HK2APC01HT139: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ew8wms+Wje47L1AQzXPk+yXQzw7oC33JAQ+hcjTsttB7R0NDXHg/WjbR3XBPLyVG8QEy3WzXAqgp9CJr5sigQk5k4gdjH9m9twDF9x5ExW0yIchAejHDmUyMfW4DucXDwcDB3TASlP7IypUUDtBjZ/gbca3V+USBL6cm0yd1NLD3wApINoq+yHDVzF0hBiUlnuxt2NE/PVg3SulmUYk1rA== X-MS-Exchange-AntiSpam-MessageData: u7gv423H82wzgYPkyn6RBvVkykcEHE2GFdBa2eEjR6fpMR3EiFK8x54EdchsCIEbW827Vwv3XJYumaXEdfFuzyzaJMcPLlbpzyLDA3o3yAcCJPQzP7TxUvAbHlRykApPlqClS6nnMKhvdSxlPZ4Pxg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 10:57:20.0994 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 3300c77e-0967-4a0a-132b-08d89dc3882d X-MS-Exchange-CrossTenant-AuthSource: HK2APC01FT033.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: HK2APC01HT139 Subject: [FFmpeg-devel] [PATCH, v5] 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 | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 18fa3f9b5e..1782d48489 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_h2645, 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_h2645 ? "3gp6" : "3gp4"); + minor = has_h2645 ? 0x100 : 0x200; } else if (mov->mode & MODE_3G2) { - ffio_wfourcc(pb, has_h264 ? "3g2b" : "3g2a"); - minor = has_h264 ? 0x20000 : 0x10000; + ffio_wfourcc(pb, has_h2645 ? "3g2b" : "3g2a"); + minor = has_h2645 ? 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,8 @@ 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; + uint32_t h265_codec_tag = 0; int i; for (i = 0; i < s->nb_streams; i++) { @@ -4975,6 +4976,10 @@ 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; + h265_codec_tag = st->codecpar->codec_tag; + } if (st->codecpar->codec_id == AV_CODEC_ID_AV1) has_av1 = 1; } @@ -4983,9 +4988,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 +5023,13 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) ffio_wfourcc(pb, "iso2"); if (has_h264) ffio_wfourcc(pb, "avc1"); + if (has_h265) { + // These brands need to be verified. + if (h265_codec_tag == MKTAG('h','e','v','1')) + ffio_wfourcc(pb, "hev1"); + else + ffio_wfourcc(pb, "hvc1"); + } } } @@ -7103,6 +7115,8 @@ 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_HEVC, MKTAG('h','v','c','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') },