aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/riff_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/riff_extractor.c')
-rw-r--r--src/plugins/riff_extractor.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/plugins/riff_extractor.c b/src/plugins/riff_extractor.c
index 9ff700a..c030617 100644
--- a/src/plugins/riff_extractor.c
+++ b/src/plugins/riff_extractor.c
@@ -76,15 +76,19 @@ round_double (double num)
76 * @param s 0-terminated UTF8 string value with the meta data 76 * @param s 0-terminated UTF8 string value with the meta data
77 * @param t libextractor type for the meta data 77 * @param t libextractor type for the meta data
78 */ 78 */
79#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "riff", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0) 79#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "riff", t, \
80 EXTRACTOR_METAFORMAT_UTF8, \
81 "text/plain", s, strlen (s) \
82 + 1)) return; \
83} while (0)
80 84
81 85
82/** 86/**
83 * Main entry method for the 'video/x-msvideo' extraction plugin. 87 * Main entry method for the 'video/x-msvideo' extraction plugin.
84 * 88 *
85 * @param ec extraction context provided to the plugin 89 * @param ec extraction context provided to the plugin
86 */ 90 */
87void 91void
88EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec) 92EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec)
89{ 93{
90 ssize_t xsize; 94 ssize_t xsize;
@@ -98,22 +102,22 @@ EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec)
98 uint32_t height; 102 uint32_t height;
99 char codec[5]; 103 char codec[5];
100 char format[256]; 104 char format[256];
101 105
102 /* read header */ 106 /* read header */
103 if (72 > (xsize = ec->read (ec->cls, &data, 72))) 107 if (72 > (xsize = ec->read (ec->cls, &data, 72)))
104 return; 108 return;
105 xdata = data; 109 xdata = data;
106 110
107 /* check magic values */ 111 /* check magic values */
108 if ( (0 != memcmp (&xdata[0], 112 if ( (0 != memcmp (&xdata[0],
109 "RIFF", 4)) || 113 "RIFF", 4)) ||
110 (0 != memcmp (&xdata[8], "AVI ", 4)) || 114 (0 != memcmp (&xdata[8], "AVI ", 4)) ||
111 (0 != memcmp (&xdata[12], "LIST", 4)) || 115 (0 != memcmp (&xdata[12], "LIST", 4)) ||
112 (0 != memcmp (&xdata[20], "hdrlavih", 8)) ) 116 (0 != memcmp (&xdata[20], "hdrlavih", 8)) )
113 return; 117 return;
114 118
115 blockLen = fread_le (&xdata[28]); 119 blockLen = fread_le (&xdata[28]);
116 120
117 /* begin of AVI header at 32 */ 121 /* begin of AVI header at 32 */
118 fps = (unsigned int) round_double ((double) 1.0e6 / fread_le (&xdata[32])); 122 fps = (unsigned int) round_double ((double) 1.0e6 / fread_le (&xdata[32]));
119 duration = (unsigned int) round_double ((double) fread_le (&xdata[48]) 123 duration = (unsigned int) round_double ((double) fread_le (&xdata[48])
@@ -126,7 +130,7 @@ EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec)
126 130
127 if (pos != 131 if (pos !=
128 ec->seek (ec->cls, pos, SEEK_SET)) 132 ec->seek (ec->cls, pos, SEEK_SET))
129 return; 133 return;
130 if (32 > ec->read (ec->cls, &data, 32)) 134 if (32 > ec->read (ec->cls, &data, 32))
131 return; 135 return;
132 xdata = data; 136 xdata = data;
@@ -141,17 +145,18 @@ EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec)
141 memcpy (codec, &xdata[24], 4); 145 memcpy (codec, &xdata[24], 4);
142 codec[4] = '\0'; 146 codec[4] = '\0';
143 snprintf (format, 147 snprintf (format,
144 sizeof (format), 148 sizeof (format),
145 _("codec: %s, %u fps, %u ms"), 149 _ ("codec: %s, %u fps, %u ms"),
146 codec, fps, duration); 150 codec, fps, duration);
147 ADD (format, EXTRACTOR_METATYPE_FORMAT); 151 ADD (format, EXTRACTOR_METATYPE_FORMAT);
148 snprintf (format, 152 snprintf (format,
149 sizeof (format), 153 sizeof (format),
150 "%ux%u", 154 "%ux%u",
151 (unsigned int) width, 155 (unsigned int) width,
152 (unsigned int) height); 156 (unsigned int) height);
153 ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); 157 ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
154 ADD ("video/x-msvideo", EXTRACTOR_METATYPE_MIMETYPE); 158 ADD ("video/x-msvideo", EXTRACTOR_METATYPE_MIMETYPE);
155} 159}
156 160
161
157/* end of riff_extractor.c */ 162/* end of riff_extractor.c */