Resource Interchange File Format: Difference between revisions

Content deleted Content added
No edit summary
m Reverting possible vandalism by 2404:C0:5C40:0:0:0:2AE9:4FAB to version by Voidxor. Report False Positive? Thanks, ClueBot NG. (4414110) (Bot)
 
(185 intermediate revisions by more than 100 users not shown)
Line 1:
{{Short description|Tagged file structure for multimedia resource files}}
The '''Resource Interchange File Format''' ('''RIFF''') is a generic meta-format for storing data in tagged chunks. It was introduced in [[1991]] by [[Microsoft]] and [[International Business Machines|IBM]], and was presented by Microsoft as the default format for Windows 3.1 multimedia files. It is based on [[Electronic Arts]]'s [[Interchange File Format]], introduced in [[1985]], the only difference being that multi-byte integers are in [[endianness|little-endian]] format, native to the [[80x86]] processor series used in IBM PCs, rather than the [[Endianness|big-endian]] format native to the [[68k]] processor series used in [[Amiga]] and [[Apple Macintosh]] computers, where IFF files were heavily used.
{{More footnotes needed|date=January 2019}}
{{Infobox file format
| name = RIFF
| icon =
| iconcaption =
| icon_size =
| screenshot =
| screenshot_size =
| caption =
|_noextcode =
| extension = <!-- or: | extensions = -->
|_nomimecode =
| mime =
| type code =
| uniform_type =
| conforms_to =
| magic =
| developer =
| released = {{Start date and age|1991|08|df=yes}}
| latest_release_version =
| latest_release_date = <!-- {{start date and age|YYYY|mm|dd|df=yes/no}} -->
| type = [[Container format (digital)|Container format]]
| container_for =
| contained_by =
| extended_from = [[Interchange File Format]]
| extended_to = [[Audio Video Interleave|AVI]], [[ANI (animation file format)|ANI]], PAL, RDIB, RMIDI, RMMP, [[WAV]]
| standard = <!-- or: | standards = -->
| open = Yes
| free = Yes<ref>{{cite tech report |publisher=Library of Congress |___location=Washington, D.C. |series=Sustainability of Digital Formats |type=Full draft |title=RIFF (Resource Interchange File Format) |date=16 September 2004 |url=https://www.loc.gov/preservation/digital/formats/fdd/fdd000025.shtml |access-date=13 December 2021}}</ref>
| url =
}}
 
'''Resource Interchange File Format''' ('''RIFF''') is a generic file [[container format (digital)|container format]] for storing data in tagged [[Chunk (information)|chunks]].<ref>{{Cite book |title=Multimedia Programming Interface and Data Specifications 1.0 |url=https://www.mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/Docs/riffmci.pdf |pages=10–11 |publisher=IBM / Microsoft |date=August 1991 |access-date=2017-07-07}}</ref> It is primarily used for audio and video, though it can be used for arbitrary data.<ref name="LoC">{{cite web|url=http://www.digitalpreservation.gov/formats/fdd/fdd000025.shtml|title=RIFF (Resource Interchange File Format)|publisher=[[Library of Congress]]|work=Digital Preservation|date=2014-01-08|access-date=2014-03-11}}</ref>
The Microsoft implementation is mostly known through file formats like [[AVI]], [[ANI (animation file format)|ANI]] and [[WAV]], which use the RIFF meta-format as their basis.
 
The Microsoft implementation is mostly known through the container formats [[Audio Video Interleave|AVI]], [[ANI (animation file format)|ANI]] and [[WAV]], which use RIFF as their basis.<ref name="micriff">{{cite book|title=Encyclopedia of Graphics File Formats, Second Edition |date=1996 |author=James D. Murray |author2=William vanRyper |isbn=1-56592-161-5 |publisher=[[O'Reilly Media|O'Reilly]] |at=Microsoft RIFF |url=https://www.fileformat.info/format/riff/egff.htm |access-date=2016-04-07 |url-status=live |archive-url=https://web.archive.org/web/20051128020903/http://www.oreilly.com/www/centers/gff/formats/micriff/index.htm |archive-date=November 28, 2005 }}</ref>
RIFF files consist entirely of "chunks". The overall format is identical to IFF, except for the endianness as previously stated, and the different meaning of the chunk names.
 
== History ==
RIFF was introduced in 1991 by [[Microsoft]] and [[International Business Machines|IBM]] and used as the default format for [[Windows 3.1x|Windows 3.1]] multimedia files. It is based on [[Interchange File Format]] introduced by [[Electronic Arts]] in 1985 on the [[Amiga]]. IFF uses the [[Endianness|big-endian]] convention of the Amiga's [[Motorola 68000]] CPU, but in RIFF multi-[[byte]] integers are stored in the [[Endianness|little-endian]] order of the [[x86]] processors used in [[IBM PC compatible]]s. A RIFX format, which is big-endian, was also introduced.
 
In 2010 Google introduced the [[WebP]] picture format, which uses RIFF as a container.<ref>{{Cite web |url=http://code.google.com/speed/webp/docs/riff_container.html |title=RIFF Container |work=[[Google Code]] |access-date=1 October 2010 }}</ref>
 
== Explanation ==
RIFF files consist entirely of "[[Chunk (information)|chunks]]". The overall format is identical to [[Interchange File Format|IFF]], except for the endianness as previously stated, and the different meaning of the chunk names.
 
All chunks have the following format:
* 4 bytes: an [[ASCII]] identifier for this chunk, e.g.(examples are "fmt " orand "data"; note the space in "fmt ").
* 4 bytes: an unsigned, little-endian 32-[[bit]] integer with the length of this chunk (except this field itself and the chunk identifier).
* variable-sized field: the chunk data itself, of the size given in the previous field.
* a pad byte, if the chunk's length is not even.
 
Two chunk identifiers, "RIFF" and "LIST", introduce a chunk that can contain subchunks. TheirThe RIFF and LIST chunk data, (appearing after the identifier and length,) hashave the following format:
* 4 bytes: an ASCII identifier for this particular RIFF or LIST chunk (for RIFF in the typical case, ofthese the4 RIFFbytes chunk:describe forthe content of the entire file, such as "AVI " or "WAVE").
* rest of data: subchunks.
 
The file itself consists of one RIFF chunk, which then can contain further subchunks: hence, the first four bytes of a correctly- formatted RIFF file will spell out "R", "I", "F", "FRIFF".
 
More information about the RIFF format can be found in the [[Interchange File Format]] article.
 
[[RF64]] is a multichannel file format based on RIFF specification, developed by the [[European Broadcasting Union]]. It is [[Broadcast Wave Format|BWF]]-compatible and allows file sizes to exceed 4 [[gigabyte]]s. It does so by providing a "ds64" chunk with a 64-bit (8-byte) size.
 
== Use of the INFO chunk ==
The optional INFO chunk allows RIFF files to be "tagged" with information falling into a number of predefined categories, such as copyright ("ICOP"), comments ("ICMT"), artist ("IART"), in a standardised way. These details can be read from a RIFF file even if the rest of the file format is unrecognized. The standard also allows the use of user-defined fields. Programmers intending to use non-standard fields should bear in mind that the same non-standard subchunk ID may be used by different applications in different (and potentially incompatible) ways.
 
== Compatibility issues ==
The official Microsoft documentation for [[Windows 3.1]] states that the INFO chunk should be placed at the beginning of the file. This allows fast access to the file's descriptive [[metadata]], and lets file system software and multimedia file management applications quickly scan the top of each file and extract author information, icon thumbnails, preview audio, formatting information, and so on.
=== Initial difficulties with MIDI files ===
In line with their policy of using .RIFF for all Windows 3.1 "multimedia" files, Microsoft introduced a new variant on the existing [[MIDI|MIDI file]] format used for storing song information to be played on electronic musical instruments. Microsoft's MIDI file format consisted of a standard MIDI file enclosed in a RIFF wrapper, and had the file extension [[MIDI#RMID files|.RMI]]. Since the existing MIDI file format already supported embedded "tagging" information, this caused the disadvantage of having to deal with two file formats for the same type of information.
 
The MIDI Manufacturers Association have since embraced the RIFF-based MIDI file format, and used it as the basis of an "extended midifile" that also includes instrument data in "[[DLS format|DLS]]" format, embedded within the same .RMI file.
When [[Windows XP]]'s file management software encounters an RIFF-format file, it will automatically attempt to read this INFO chunk, and the user can specify some common RIFF fields (e.g. Author, Copyright date) that can be used to supplement the more usual file property fields such as file size and creation date.
 
=== INFO chunk placement problems ===
== Controversies ==
For cataloguing purposes, the optimal position for the INFO chunk is near the beginning of the file. However, since the INFO chunk is optional, it is often omitted from the detailed specifications of individual file formats, leading to some confusion over the correct position for this chunk within a file.
 
When dealing with large media files, the expansion or contraction of the INFO chunk during tag-editing can result in the following "data" section of the file having to be read and rewritten back to disk to accommodate the new header size. Since media files can be gigabytes in size, this is a potentially disk-intensive process. One workaround is to "pad out" the leading INFO chunk using dummy data (using a "dummy chunk" or "pad chunk") when the file is created. Later editing can then expand or contract the "dummy" field to keep the total size of the file header constant: an intelligently written piece of software can then overwrite just the file header when tagging data is changed, without modifying or moving the main body of the file.
* In line with their policy of using .RIFF for all Windows "multimedia" files, Microsoft introduced a new variant on the existing [[MIDI file]] format used for storing song information to be played on electronic musical instruments. Microsoft's "new" MIDI file file format consisted of a standard MIDIfile enclosed in a RIFF "wrapper", and had the extension [[.RMI]]. This caused some upset at the time, since it took a while for existing music software to be updated to use the new format, and not everyone accepted that the creation of a new file format was justified in this case.
 
Some programs have tried to address the problem by placing the INFO chunk at the end of a media file, after the main body of the file. This has resulted in two different conventions for chunk placement, with the attendant risk that some combinations of software can cause a file's INFO data to be ignored or permanently overwritten during editing. More sophisticated programs will take into account the possibility of "unexpected" chunk placement in files and respond accordingly. For instance, when the audio-editing program [[Audacity (audio editor)|Audacity]] encounters a .WAV file with end-placed INFO data, it will correctly identify and read the data, but on saving, will relocate the INFO chunk back to the file header.
* When dealing with large video files, expanding or contracting the INFO chunk can result in the entire file (which might be several gigabyes in size) having to be rewritten, which is a disk-intensive process. The correct workaround to this problem is to "pad out" the INFO chunk using dummy data (using a "dummy chunk" or "pad chunk") when a large file is created, so that later editing can expand or contract the "dummy" field to keep the total size of the INFO chunk constant: an intelligently-written piece of software can then overwrite just the INFO chunk when header data is changed, and does not have to modify or move the main body of the file. However, since this method requires a certain amount of additional work on the part of the software programmer, and since the full RIFF specifications were scattered amongst Microsoft's documentation, some programmers believed that it was legal (and simpler) to place the INFO chunk at the //end// of a RIFF file, and some faulty documentation began to circulate recommending this practice. Misplacing the INFO chunk in this way means that the data will not be read by all media programs, and also means that there is a risk that the entire INFO chunk may be accidentally discarded or overwritten by software that strictly adheres to the official file specification.
 
* Although [[CorelDRAW]] 10 nominally uses a RIFF file structure, itthe placesprogram's initial release placed the INFO chunk at the end, so that any embedded preview bitmap willwould not be displayed under Windows' file manager by default. AnA add-on"patch" utility supplied with the program fixes this problem.
 
== SeeRIFF alsoinfo tags ==
 
* [[Interchange File Format|IFF]]
RIFF information tags are found in WAV audio and AVI video files.
* [[AIFF]]
 
* [[FourCC]]
{| class="wikitable"
* [[BWF]] Broadcast Wave Format
|-
! Tag ID
! Tag name
! Writable
! Values / notes
|-
| DTIM
| DateTimeOriginal
| N
| ICC Profile "dtim" format values
|-
| TAPE
| TapeName
| N
|
|}
 
=== Converting DTIM time to normal time ===
The field consists of two values (v[0] and v[1]) separated with a space (0x20). Sample code:
<syntaxhighlight lang="c">
// time in seconds - "concatenate" date & time elements with a decimal point delimiter
TimeInSeconds = (v[0] * (2^32) + v[1]) * 10^(-7);
 
// shift basis from Jan 1, 1601 to Unix epoch Jan 1, 1970 (369 years & leap days)
UnixTimeStamp = TimeInSeconds - 134774 * 24 * 3600;
</syntaxhighlight>
 
== Some common RIFF file types ==
* [[WAV]] (Windows audio)
* [[Audio Video Interleave|AVI]] (Windows audiovisual)
* [[Musical Instrument Digital Interface#Standard files|RMI]] (Windows "RIFF MIDIfile")
* [[CorelDRAW|CDR]] (CorelDRAW vector graphics file)
* [[ANI (file format)|ANI]] (Animated Windows cursors)
* [[Palette (computing)|PAL]] (Palette)
* [[DLS format|DLS]] (Downloadable Sounds)
* [[WebP]] (An image format developed by Google)
* [[XMA (audio format)|XMA]] (Microsoft [[Xbox 360]] console audio format based on [[Windows Media Audio|WMA Pro]])
 
== See also ==
* [[.WAV]] (Windows audio)
* [[Interchange File Format|IFF]] (the [[big-endian]] format from which RIFF derives)
* [[.AVI]] (Windows audiovisual)
* [[Audio Interchange File Format|AIFF]]
* [[.RMI]] (Windows "RIFF MIDIfile")
* [[Broadcast Wave Format|BWF]] Broadcast Wave Format
* [[.CDR]] (CorelDRAW vector graphics file)
* [[Type–length–value|TLV]] (the generic format that RIFF is an example of)
* [[FourCC]] (the chunk identification approach used by many TLV formats, including IFF, as verbose [[Magic number (programming)#Format indicator|Magic number]])
 
== References ==
{{Reflist}}
 
== External links ==
* [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimedlibrary/htmwindows/_win32_resource_interchange_file_format_servicesdesktop/dd798636(v=vs.85).aspaspx Resource Interchange File Format Services]
* [http://msdnmsdn2.microsoft.com/archive/default.asp?url=/archive/en-us/dx81_clibrary/directx_cpp/htm/avirifffilereferencems779636(VS.asp85).aspx RIFF AVI file reference]<!--http://msdn.microsoft.com/en-us/library/windows/desktop/dd318189(v=vs.85).aspx-->
* [https://web.archive.org/web/20070517142746/http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dx81_vb/directx_vb/htm/_dx_reading_wave_files_dxaudio.asp Reading WAVE files]
* [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/DMusicClibrary/windows/htmdesktop/directmusicfileformatms807157.aspaspx DirectMusic file format]
* [http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q120253 Multimedia Registration Kit]
* [http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/RIFF.html Tag Names]
 
[[Category:Computer file{{Compression formats]]}}
 
[[Category:Computer file formats]]
[[de:Resource Interchange File Format]]
[[Category:Computer-related introductions in 1991]]
[[fr:Resource File Interchange Format]]
[[ru:RIFF]]
[[zh:RIFF]]