changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: file: add (very) basic support for detecting mpeg4 formats

changeset 7423: fb55099449b9
parent 7422: 714b929020e9
child 7424: cd934c6c7513
author: Alex Musolino <alex@musolino.id.au>
date: Fri, 01 Nov 2019 12:05:11 +1030
files: sys/src/cmd/file.c
description: file: add (very) basic support for detecting mpeg4 formats
     1.1--- a/sys/src/cmd/file.c
     1.2+++ b/sys/src/cmd/file.c
     1.3@@ -152,6 +152,7 @@ int	ismbox(void);
     1.4 int	islimbo(void);
     1.5 int	istga(void);
     1.6 int	ismp3(void);
     1.7+int	ismp4(void);
     1.8 int	ismung(void);
     1.9 int	isp9bit(void);
    1.10 int	isp9font(void);
    1.11@@ -201,6 +202,7 @@ int	(*call[])(void) =
    1.12 	isface,		/* ascii face file */
    1.13 	istga,
    1.14 	ismp3,
    1.15+	ismp4,
    1.16 
    1.17 	/* last resorts */
    1.18 	ismung,		/* entropy compressed/encrypted */
    1.19@@ -1242,6 +1244,24 @@ ismp3(void)
    1.20 	return 0;
    1.21 }
    1.22 
    1.23+int
    1.24+ismp4(void)
    1.25+{
    1.26+	if(nbuf <= 12)
    1.27+		return 0;
    1.28+	if(memcmp(&buf[4], "ftyp", 4) != 0)
    1.29+		return 0;
    1.30+	if(memcmp(&buf[8], "isom", 4) == 0){
    1.31+		print("%s\n", mime ? "video/mp4" : "mp4 video");
    1.32+		return 1;
    1.33+	}
    1.34+	if(memcmp(&buf[8], "M4A ", 4) == 0){
    1.35+		print("%s\n", mime ? "audio/m4a" : "m4a audio");
    1.36+		return 1;
    1.37+	}
    1.38+	return 0;
    1.39+}
    1.40+
    1.41 /*
    1.42  * low entropy means encrypted
    1.43  */