From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 697E7432DC for ; Sat, 20 Jul 2024 19:42:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6C59068D84C; Sat, 20 Jul 2024 22:42:42 +0300 (EEST) Received: from qs51p00im-qukt01080101.me.com (qs51p00im-qukt01080101.me.com [17.57.155.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AA32368CEEE for ; Sat, 20 Jul 2024 22:42:36 +0300 (EEST) Received: from [172.20.144.1] (qs51p00im-dlb-asmtp-mailmevip.me.com [17.57.155.28]) by qs51p00im-qukt01080101.me.com (Postfix) with ESMTPSA id 691B161802A2 for ; Sat, 20 Jul 2024 19:42:33 +0000 (UTC) Content-Type: multipart/mixed; boundary="Apple-Mail=_12D40393-0C2D-4D54-B4E6-603DA0165EE0" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Message-Id: <0D14065A-67C7-4C0A-B329-6978ECD86E00@mac.com> Date: Sat, 20 Jul 2024 13:42:29 -0600 To: ffmpeg-devel@ffmpeg.org X-Mailer: Apple Mail (2.3445.104.21) X-Proofpoint-GUID: dBWmrVqfN8SYr83-EIxVIrs0e-l3ZQnP X-Proofpoint-ORIG-GUID: dBWmrVqfN8SYr83-EIxVIrs0e-l3ZQnP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-20_16,2024-07-18_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=784 malwarescore=0 mlxscore=0 clxscore=1011 spamscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2407200144 Subject: [FFmpeg-devel] adding movflags 'write_pixeldensity' for APPUL RETINA displays X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Gagan Sidhu via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Gagan Sidhu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --Apple-Mail=_12D40393-0C2D-4D54-B4E6-603DA0165EE0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii hi, a fellow named DANIEL KAISER (EMPH I DID NOT CONTRIBUTE ANYTHING HERE) = took some time to contribute an 'movflags' option for people STUPID = enough to buy APPUL products that, of course, have an equally stupid and = BUZZY name like RETINA. since it works and it would be convenient to mainline, even though = stupid people don't deserve it, per carlos' suggestion i have taken a = minute to update the patch so it jives with the latest git. it's attached. thank you daniel kaiser.=20 remember ffmpeg team: should the patch meet your criteria for = introduction, please be sure to insult and berate the APPUL users = because they need it. bless, g --Apple-Mail=_12D40393-0C2D-4D54-B4E6-603DA0165EE0 Content-Disposition: attachment; filename=new_mov_pixeldensity.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="new_mov_pixeldensity.patch" Content-Transfer-Encoding: 7bit diff --git a/libavformat/movenc.c b/libavformat/movenc.c index a961390..c5eb12d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -78,6 +78,7 @@ { "delay_moov", "Delay writing the initial moov until the first fragment is cut, or until the first fragment flush", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "global_sidx", "Write a global sidx index at the start of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "skip_sidx", "Skip writing of sidx atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, + { "write_pixeldensity", "Write pixeldensity metdata for HiDPI videos in QT", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_PIXELDENSITY}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "write_colr", "Write colr atom even if the color info is unspecified (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "prefer_icc", "If writing colr atom prioritise usage of ICC profile if it exists in stream packet side data", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_PREFER_ICC}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, @@ -3413,6 +3414,56 @@ return size; } +static int mov_write_pixeldensity_meta_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track, AVFormatContext *s) +{ + int size = 0; + int64_t pos = avio_tell(pb); + avio_wb32(pb, 0); /* meta atom size */ + ffio_wfourcc(pb, "meta"); + + /* Metadata atom information as described in + * https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW9 + */ + avio_wb32(pb, 33); /* hdlr atom size: size (4) + 'hdlr' (4) + version/flags (4) + predefined (4) + 'mdta' (4) + + reserved (3*4) + name (1) = 33 */ + ffio_wfourcc(pb, "hdlr"); + avio_wb32(pb, 0); /* version (1 Byte) and flags (3 Bytes), must be zero */ + avio_wb32(pb, 0); /* "predefined", must be zero */ + ffio_wfourcc(pb, "mdta"); + avio_wb32(pb, 0); /* Reseverved, uint32_t[3] */ + avio_wb32(pb, 0); + avio_wb32(pb, 0); + avio_w8(pb, 0); /* Empty name (NULL-terminated) */ + + avio_wb32(pb, 56); /* keys atom size: size (4) + 'keys' (4) + version/flasgs (4) + entry_count (4) + + keys (32+8) = 56 */ + ffio_wfourcc(pb, "keys"); + avio_wb32(pb, 0); /* version (1 Byte) and flags (3 Bytes), must be zero */ + avio_wb32(pb, 1); /* entry count */ + avio_wb32(pb, 32 + 8); /* key size: size (4) + 'mdta' (4) + strlen(key) */ + ffio_wfourcc(pb, "mdta"); + avio_write(pb, "com.apple.quicktime.pixeldensity", 32); + + avio_wb32(pb, 48); /* ilst atom size: size (4) + 'ilst' (4) + value atom size (40) = 48 */ + ffio_wfourcc(pb, "ilst"); + avio_wb32(pb, 40); /* value atom size: size (4) + key (4) + data atom (32) = 40 */ + avio_wb32(pb, 1); /* metadata key index */ + + avio_wb32(pb, 32); /* data atom size: size (4) + 'data' (4) + data_type (4) + locale (4) + value (4 * 4) = 32 */ + ffio_wfourcc(pb, "data"); + avio_wb32(pb, 0x1e); /* data type */ + avio_wb32(pb, 0); /* locale */ + + /* actual data (value): consisting of 4 uint32_t: pixel width, pixel height, display width, display height */ + avio_wb32(pb, track->par->width); + avio_wb32(pb, track->par->height); + avio_wb32(pb, track->par->width / 2); + avio_wb32(pb, track->par->height / 2); + + size = update_size(pb, pos); + return size; +} + static int mov_write_trak_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track, AVStream *st) { @@ -3460,6 +3511,9 @@ static int mov_write_trak_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext mov_write_tapt_tag(pb, track); } } + if (mov->flags & FF_MOV_FLAG_PIXELDENSITY) { + mov_write_pixeldensity_meta_tag(pb, mov, track, st); + } mov_write_track_udta_tag(pb, mov, st); track->entry = entry_backup; track->chunkCount = chunk_backup; diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 68d6f23..ed7ea41 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -265,6 +265,7 @@ typedef struct MOVMuxContext { #define FF_MOV_FLAG_SKIP_SIDX (1 << 21) #define FF_MOV_FLAG_CMAF (1 << 22) #define FF_MOV_FLAG_PREFER_ICC (1 << 23) +#define FF_MOV_FLAG_PIXELDENSITY (1 << 24) int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); --Apple-Mail=_12D40393-0C2D-4D54-B4E6-603DA0165EE0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --Apple-Mail=_12D40393-0C2D-4D54-B4E6-603DA0165EE0--