+static gboolean
+mdat_recov_file_find_mdat (FILE * file, GError ** err)
+{
+ guint32 fourcc = 0, size = 0;
+ gboolean failure = FALSE;
+ while (fourcc != FOURCC_mdat && !failure) {
+ if (!read_atom_header (file, &fourcc, &size)) {
+ goto parse_error;
+ }
+ switch (fourcc) {
+ /* skip these atoms */
+ case FOURCC_ftyp:
+ case FOURCC_free:
+ case FOURCC_udta:
+ if (fseek (file, size - 8, SEEK_CUR) != 0) {
+ goto file_seek_error;
+ }
+ break;
+ case FOURCC_mdat:
+ break;
+ default:
+ GST_ERROR ("Unexpected atom in headers %" GST_FOURCC_FORMAT,
+ GST_FOURCC_ARGS (fourcc));
+ failure = TRUE;
+ break;
+ }
+ }
+
+ if (!failure) {
+ /* Reverse to mdat start */
+ if (fseek (file, -8, SEEK_CUR) != 0)
+ goto file_seek_error;
+ }
+
+ return !failure;
+
+parse_error:
+ g_set_error (err, ATOMS_RECOV_QUARK, ATOMS_RECOV_ERR_FILE,
+ "Failed to parse atom");
+ return FALSE;
+
+file_seek_error:
+ g_set_error (err, ATOMS_RECOV_QUARK, ATOMS_RECOV_ERR_FILE,
+ "Failed to seek to start of the file");
+ return FALSE;
+
+}
+