From patchwork Fri Dec 11 04:49:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunzhenliang X-Patchwork-Id: 24538 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 5119344A573 for ; Fri, 11 Dec 2020 06:50:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2517468A568; Fri, 11 Dec 2020 06:50:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-oln040092253022.outbound.protection.outlook.com [40.92.253.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 35C91688098 for ; Fri, 11 Dec 2020 06:50:42 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cinCMnOup3FVcLvt91Y0JqgDyBUajpOrL6qZql/htruuQrfq9SDhbhzUEf2vx4wVpFRDvjtTMoh2Ca2+qcpjbWrO/M6fwowTRKWTJX85C4dvuxhljR+UYRPVx2CY3mlQlyYfLNxX/O/7KuavEZ5inaxLqw2x8+9s6nlO0J4XVUj69LKqC8300UOL5LvnJs/7m/IirAdMR9tNNdQXuk/wbEYh4NKr/vu6gg1Scq4B0ANjSCo6W9tjQwCPAPpZdyMdHRr4iHyHgAP52/ZiEtafS7rK1fOXLrC1v5KrTAD/5zkr4zmhpcdR0epxEXbXpuWgR+MPl7umLjoptnVglt/xmg== 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=LIrWumDU6SitgWV4gnro1+PCt17G3iRblIytjhIisrY=; b=gjygAl6GGfx/gEyyuqa2GT+sKTfoxfBviLv2nYT0m6UMiYpB5OvxAIebtw7yv+wxAA748FR5W5FqnGyPQlUfn74afnzyn/Je8QTGXKjOKGGW4puOWUS9g5MJxqtSe6IIs8ttPFzippr1orm8l8ivfoJgXr6lRpLVhrJOTwvBD9h2uKGDG3AQAmmvPiO2zkKwKkeLwi9FZEzXd5BnDXaJOiJ+a+pMPT6xN4NqdMIQHAaovQB+TFSF3NgtpeCPGMqIu1LINR30V+3vL+oB/bl5XB0/rOOg2ArjI9p4pXR7xczF+LZLTSw9RWRO41xu49dXzJGAhUYfLBvRqwNJkjOtWw== 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=LIrWumDU6SitgWV4gnro1+PCt17G3iRblIytjhIisrY=; b=pO6x4gVOCrKlEubUNsQt2kLZ/wVaCd0eyPr10UsM1YVn2ySPt4QnPycPz+5fjLdDEYyxfqGuzCna8XUm3y5xcuMQddHKvu4CuwJIwb3LZ+hlaNFVnPxnBoIjEie55+0UVppIJJUe3pWgSJsa68fchzmS3sv4GQKzObK9gkJv1J0ZFISzforPgj3Z5EXuUVwsR+7CEYBNBO/Ve0khnb2V6dtJ5vSm3p/+36W1Kz18mltitd7RNbvFds5y4W4ruWgKAHh1PJ/AjdKANiH1QOqZ8cH1xJa/xIrrHzQFZGpfAXUcy9cItkXHGGNnCP6pKsmRONnUutu4qE8UZP1gFpobJw== Received: from SG2APC01FT013.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebd::4d) by SG2APC01HT202.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebd::322) 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 04:50:39 +0000 Received: from TYAPR01MB4271.jpnprd01.prod.outlook.com (10.152.250.60) by SG2APC01FT013.mail.protection.outlook.com (10.152.250.186) 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 04:50:39 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:859E36AF7BB4BDD7B9CF0608ADE5C49D7CCD6D9F59F13EC434A204274885B48D; UpperCasedChecksum:6F9575AEBA0AE2892899A3EB1ADBF72B0657607E7C2C8F8658BBCAC2D7126CC5; SizeAsReceived:7472; 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 04:50:39 +0000 From: hisunzhenliang@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Dec 2020 12:49:59 +0800 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: X-TMN: [tx3EWzWVmDeLyog6mCYLMMz9kCo7N1/9] X-ClientProxiedBy: HKAPR03CA0008.apcprd03.prod.outlook.com (2603:1096:203:c8::13) To TYAPR01MB4271.jpnprd01.prod.outlook.com (2603:1096:404:c8::20) X-Microsoft-Original-Message-ID: <20201211044958.17189-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 HKAPR03CA0008.apcprd03.prod.outlook.com (2603:1096:203:c8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.11 via Frontend Transport; Fri, 11 Dec 2020 04:50:37 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 9fbf7d2c-121c-4dd1-fa88-08d89d904e96 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UK8FaET1AYvNqq0LBu5NDqrJPP/kuZP5u29qAFaXXJ6URTnFFQsWJdyFrzJnvx11XMjcH/x79aMYZ1e6RM57IuFS/zwyxZM/xAQ05nVziayY1luu6MKPNhXuSDcCrpi40E2elxs/A37jyCBVEvqcCaDU35G0lQGtzJeD1VDgCNuP8m+yrPgYp0dspBpUwpumRLJnfwKJ3p6tiqzV9Hvb0n/t2cOPWz5qKnpfHArVXIJZM5tF9/YOqoQCH0tyWnzxGh/JxZ8xkXJdAZ+kO4RsHD6zP7x5PVdUgPnEEhCZ+LMBPBO/Y1CFokbvBtEYkFRSJnR9m+0CrrnnLjdQ6r+LZ5z9QlHniq1cgLLco0PgNVoPkGuEwKiRpGRvIujUaZMevXWARjpVzLmwVqFssjygc7eBvNanPI0IFV07m2AzNPh3A4EjIWmfNyBj4yOCqaZjNeJ5KR8rcy7vvvIMZg+s0CoFU+MBTQ1s6RepAYZx536qaQqtuSJzVIJTj6ABd+PYPrHvyeCcmlntQxJxQ7cbh1njHxV3/qd57lxH5n955B2CA3CLMv+mb7inA5VbTlDLM/X6NFlO+tqHiGkVV60dbbeaycP8TN5M3WzAROqA6B9FzSOrp/XVFL2CZcpHVoLfTNZNnUseHSrHCGMllWQOUFvA+VqsxtM46xfg/hQFxukpeGEHVqsIUEkRoUprivMIxv+F9fH5qnTpQ== X-MS-TrafficTypeDiagnostic: SG2APC01HT202: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eHyc52czpNrZFuC+k1YIGcbAtNt3aE+qkfaC8H+MW3UyCt+G3WRY0UjxNXgND1DnJVDvhw7VtUWkz3LI3pRykSXUHPAtYGasgJqQmb+eRSZpyPmS/OJ9dchPkhRufVP8O8R3EXQ+cCUSQROtkKV58tVM5jSD0nPSOJN5FNoHHyXWJpXaBo/2Pcz1O+rE9nd0TJNg5h1cBffWeGRQsE5MHw== X-MS-Exchange-AntiSpam-MessageData: l3vWNWBf5XmQ0dvfKx3qrh6/BtCvAeoHG2IHGnpf/xeVIq3RmJAkt0iHVgrvxamo033kEjluxWRUZoUObw9IQXc31/+ev7l5b4zx6oJdkSpYTqXyoyfO15oMrjvcpkiJII8tRWpA1VU3lp2luoYyZQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 04:50:39.0135 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 9fbf7d2c-121c-4dd1-fa88-08d89d904e96 X-MS-Exchange-CrossTenant-AuthSource: SG2APC01FT013.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: SG2APC01HT202 Subject: [FFmpeg-devel] [PATCH, v3] 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 | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 18fa3f9b5e..0c9fd16ce6 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; + int h265_codec_tag = 0; int i; for (i = 0; i < s->nb_streams; i++) { @@ -4975,6 +4976,13 @@ 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_tag == MKTAG('h','e','v','1')) + h265_codec_tag = st->codecpar->codec_tag; + else + h265_codec_tag = st->codecpar->codec_tag; + } if (st->codecpar->codec_id == AV_CODEC_ID_AV1) has_av1 = 1; } @@ -4983,9 +4991,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 +5026,12 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) ffio_wfourcc(pb, "iso2"); if (has_h264) ffio_wfourcc(pb, "avc1"); + if (has_h265){ + if (h265_codec_tag == MKTAG('h','e','v','1')) + ffio_wfourcc(pb, "hev1"); + else + ffio_wfourcc(pb, "hvc1"); + } } } @@ -7103,6 +7117,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') },