From patchwork Fri Dec 11 03:38:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunzhenliang X-Patchwork-Id: 24537 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 EBBB344AA23 for ; Fri, 11 Dec 2020 05:54:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C18BD68A631; Fri, 11 Dec 2020 05:54:49 +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-oln040092255076.outbound.protection.outlook.com [40.92.255.76]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CB22A68A18D for ; Fri, 11 Dec 2020 05:54:42 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eHjkvYg62EfzxYJFc7D5XMHZ0iycU4M3YpSJYyLu0vetvFk/sgxpaXYYzdunMxyH39emLoFooGV/0rsCDWQt2YSputLbrQIU/MvVy/sJVkj/Y4crrBfydBZ3oqB9UIK68FoaxAdDPBx+TsuOuo7zcM97/KHNNMSLUSWls/WeJ+5kO2snWGq/1+PDAmKwZUtMvkn+tjTW0+j1qOFc61jRnt5UQxfpC+zhIckKykojkeb1lvPnA9Y67tmQgff0FFeF4SJNXuYKrIQqEX5v/zs5MrWvEOewSkUtB9ThaKONCseeVjYJkH7aY9/9dCRNWIuaWI66e3u4llHfTJBk+MOFdg== 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=3I3VsiXejWDHGWPVG0VwGGUboebQiVp1Y5fC7OsV2tQ=; b=b5LIsKj8GAR/XeA9OnmEHBmT1KkACPGPl1PImJx/oHkAr0pToT75cjHVHF3IKokYTuXpeN/657uqAGJ74u7eu8To6C5lBQuQW3lF6Hy+u+mvlR3XBvfvQ89dFoAi+Lq2F+y/QnoeWRz3YxV9VJpsfN3NLwGK3LJrRXXoCBjbgPO44yurVRonkOk1rDQfTfqmHPTik2RpH6eKa8EGdLRxR3aIvWRd9KWOKjxXvuKphT/YQERlO7z5eCeU4o91obeS6qmELeZQvEd6pEpenElTIkb2PPvuRtZhUXCW9rz/paVmbp1Xzte/WlqbaD31ixeLxYx6lUdQkCZMvaQTjdSBOg== 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=3I3VsiXejWDHGWPVG0VwGGUboebQiVp1Y5fC7OsV2tQ=; b=vDwO3RBfCuczq65O2xD0rTbSoFjOuqncTngr2BPj3WGIVXv3IDxAW2CmKmEEvWwidF1tcQp1FARZ0qt5cI3xnZ5Y8+HBavwh/kmQZaRTT63CdUSd7VRgPHQnnlM4f0+PDexN+TnFabbzu9Cyy/DAruYZHgghCf8nDTMI0379R67bvdUjyBMOh0roD0pkanUQfPt55o3j1/rK7YhUvLHA1xem7U6wo0XkGaMEkh0gOljPaVdx16pPmq6a3hsbVlb7qyZlgOCVAIznifUP3aQdQ/+uVjGsOVcxVeRQgsk1mzY1WnWdMCHNIhT33TFhDkh5gXEmGhSbdmpC+7HgAK8cqA== Received: from PU1APC01FT031.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebe::43) by PU1APC01HT022.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebe::275) 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 03:39:25 +0000 Received: from TYAPR01MB4271.jpnprd01.prod.outlook.com (10.152.252.51) by PU1APC01FT031.mail.protection.outlook.com (10.152.252.226) 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 03:39:25 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:848A4875263A3FF09C46C6D6554A5163F072DD4D5972A5551D3A385FE2A9D74A; UpperCasedChecksum:E56546062D71E203041AD752F13E3BDBA047F7424FCC61FE78E8258CCBAF2C08; 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 03:39:25 +0000 From: hisunzhenliang@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Dec 2020 11:38:12 +0800 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: X-TMN: [pg0ENU2Skmi8YFzDJlulEfMeBtkMeaX6] X-ClientProxiedBy: HK2PR06CA0020.apcprd06.prod.outlook.com (2603:1096:202:2e::32) To TYAPR01MB4271.jpnprd01.prod.outlook.com (2603:1096:404:c8::20) X-Microsoft-Original-Message-ID: <20201211033810.29638-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 HK2PR06CA0020.apcprd06.prod.outlook.com (2603:1096:202:2e::32) 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 03:39:23 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 105afbba-47a6-4561-d508-08d89d865b72 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UK8FaET1AYvNqq0LBu5NDqr+jk43idfgTh7ixfYiS3HiW4gQ3GOOUiBgWO4MuRwfx9CIrlIV4dp7FYMlR9/Mp5bwhkKTdITW4fMIjOyK8XedMU5QkZkjJNIJ+i+KEAgvNDHZC3xBvZw1MhVePCkFxeh3UqfDinzWCMU9/zgy+5QqjxRFWus9aYAI2hSe5+OHC2iF1FfH/edbaKU9ZHFKBtXdTZuFfUGTiqXyCfvOObc9IgRtSUNpY0zzwFaet2i13GSOn4ueXn/L9TgMvnxb9UvfEV171i/eCVbLZFhFbXP7NNc5ws/O2gPQP4OV7lXabKOt3kGaW6wWL1ch/KNf5LY4Zu6zfFyshrEMyPzujzOGN58Uk8gaG8eDiALIMpHVIDlMQ23r2lnf0BMtojYsJ3vsbo1R7VbCny9I3n65jX/84Hulop2nroWC6yk6DFFAoZWSlDL2cL/bGBoZYU5uQmwxm00Yl6wNkEpnYJCqvv9+LKXPkKUYhGJvcvVss0sqi4Wc0jX77t91T84e7wILclGATh4cx2rdLa5GVl3sEQKQhgOOX+Ri89baNyjwmFqJUDz2Zq07nqRfsqN5aEM9442tGaPZSoJ4/buui+un/n4ebmgrtUto7ef8GuD9IJ5NNVRB0grjlDOphkbJPJ0Y2t2tLJA8fyth5En6bD81cYilgCYOYQBysnDDgFI6K9bRwpC3oWcFpQX2w== X-MS-TrafficTypeDiagnostic: PU1APC01HT022: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w5VxPi4KPiEOavGWLhDlVAFUFEK/cVmq2/1kHp8ZhAclCluTgf7qutYdEkVSzBUHZGXlpn96oTk4+YxJz/0H5GzaUucuQXM4w7981PovMFFPklwn8xhZlJporhvXYrcTra5K8MxtSdU99mIa6GslRztUPrV2LuD64EFpXM+FsThaZdQSZr3mZoNL8b9lk2wvW588djpeCfWzqYHB9/lW3g== X-MS-Exchange-AntiSpam-MessageData: ppiDIUSdj/8tD76xJ2C0+oYuxiiollhUnDcQEVdBFm5hFXBi03+T70XlMGmH8xoFxYU+W9knSKo5fSh95Ap4D3M4CJ5pb9X3Fuyrse2I7gNcCJntpwt/KVu01NG1y7Dy+oafoC+PGHqagwmQpAyq/g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 03:39:25.7456 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 105afbba-47a6-4561-d508-08d89d865b72 X-MS-Exchange-CrossTenant-AuthSource: PU1APC01FT031.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: PU1APC01HT022 Subject: [FFmpeg-devel] [PATCH v2] 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 | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 18fa3f9b5e..c100dd0269 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,9 @@ 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_hev1 = 0; + int h265_codec_tag_hvc1 = 0; int i; for (i = 0; i < s->nb_streams; i++) { @@ -4975,6 +4977,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_hev1 = st->codecpar->codec_tag; + else + h265_codec_tag_hvc1 = st->codecpar->codec_tag; + } if (st->codecpar->codec_id == AV_CODEC_ID_AV1) has_av1 = 1; } @@ -4983,9 +4992,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 +5027,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_hev1) + ffio_wfourcc(pb, "hev1"); + if (h265_codec_tag_hvc1) + ffio_wfourcc(pb, "hvc1"); + } } } @@ -7103,6 +7118,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') },